diff options
-rw-r--r-- | mdoc_man.c | 10 | ||||
-rw-r--r-- | mdoc_term.c | 2 | ||||
-rw-r--r-- | term.c | 12 | ||||
-rw-r--r-- | term.h | 1 |
4 files changed, 24 insertions, 1 deletions
@@ -256,6 +256,7 @@ static int outflags; #define MMAN_An_split (1 << 9) /* author mode is "split" */ #define MMAN_An_nosplit (1 << 10) /* author mode is "nosplit" */ #define MMAN_PD (1 << 11) /* inter-paragraph spacing disabled */ +#define MMAN_nbrword (1 << 12) /* do not break the next word */ #define BL_STACK_MAX 32 @@ -364,6 +365,12 @@ print_word(const char *s) case (ASCII_HYPH): putchar('-'); break; + case (' '): + if (MMAN_nbrword & outflags) { + printf("\\ "); + break; + } + /* FALLTHROUGH */ default: putchar((unsigned char)*s); break; @@ -371,6 +378,7 @@ print_word(const char *s) if (TPremain) TPremain--; } + outflags &= ~MMAN_nbrword; } static void @@ -1028,6 +1036,8 @@ pre_fa(DECL_ARGS) while (NULL != n) { font_push('I'); + if (MDOC_SYNPRETTY & n->flags) + outflags |= MMAN_nbrword; print_node(meta, n); font_pop(); if (NULL != (n = n->next)) diff --git a/mdoc_term.c b/mdoc_term.c index e0f14456..a68a4698 100644 --- a/mdoc_term.c +++ b/mdoc_term.c @@ -1564,6 +1564,8 @@ termp_fn_pre(DECL_ARGS) for (n = n->next; n; n = n->next) { assert(MDOC_TEXT == n->type); term_fontpush(p, TERMFONT_UNDER); + if (pretty) + p->flags |= TERMP_NBRWORD; term_word(p, n->string); term_fontpop(p); @@ -407,6 +407,7 @@ term_fontpop(struct termp *p) void term_word(struct termp *p, const char *word) { + const char nbrsp[2] = { ASCII_NBRSP, 0 }; const char *seq, *cp; char c; int sz, uc; @@ -438,7 +439,15 @@ term_word(struct termp *p, const char *word) word++; continue; } - ssz = strcspn(word, "\\"); + if (TERMP_NBRWORD & p->flags) { + if (' ' == *word) { + encode(p, nbrsp, 1); + word++; + continue; + } + ssz = strcspn(word, "\\ "); + } else + ssz = strcspn(word, "\\"); encode(p, word, ssz); word += (int)ssz; continue; @@ -513,6 +522,7 @@ term_word(struct termp *p, const char *word) break; } } + p->flags &= ~TERMP_NBRWORD; } static void @@ -71,6 +71,7 @@ struct termp { #define TERMP_SENTENCE (1 << 1) /* Space before a sentence. */ #define TERMP_NOSPACE (1 << 2) /* No space before words. */ #define TERMP_NONOSPACE (1 << 3) /* No space (no autounset). */ +#define TERMP_NBRWORD (1 << 4) /* Make next word nonbreaking. */ #define TERMP_KEEP (1 << 5) /* Keep words together. */ #define TERMP_PREKEEP (1 << 6) /* ...starting with the next one. */ #define TERMP_SKIPCHAR (1 << 7) /* Skip the next character. */ |