diff options
author | Ingo Schwarze <schwarze@openbsd.org> | 2018-10-25 01:32:40 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@openbsd.org> | 2018-10-25 01:32:40 +0000 |
commit | c5692d062ca3cb8eb15948d7fbc2f5eb68be6cda (patch) | |
tree | 94de759c7f7feb9b61764095e908e723f0ae0499 | |
parent | e4c12a05e0760bea4427e66a5914d9fed0111dee (diff) | |
download | mandoc-c5692d062ca3cb8eb15948d7fbc2f5eb68be6cda.tar.gz |
Implement the \f(CW and \f(CR (constant width font) escape sequences
for HTML output. Somewhat relevant because pod2man(1) relies on this.
Missing feature reported by Pali dot Rohar at gmail dot com.
Note that constant width font was already correctly selected before
this when required by semantic markup. Only attempting physical
markup with the low-level escape sequence was ineffective.
-rw-r--r-- | html.c | 10 | ||||
-rw-r--r-- | html.h | 1 | ||||
-rw-r--r-- | mandoc.c | 7 | ||||
-rw-r--r-- | mandoc.h | 1 | ||||
-rw-r--r-- | mdoc_markdown.c | 1 | ||||
-rw-r--r-- | roff.c | 1 | ||||
-rw-r--r-- | term.c | 1 |
7 files changed, 21 insertions, 1 deletions
@@ -228,6 +228,9 @@ print_metaf(struct html *h, enum mandoc_esc deco) case ESCAPE_FONTBI: font = HTMLFONT_BI; break; + case ESCAPE_FONTCW: + font = HTMLFONT_CW; + break; case ESCAPE_FONT: case ESCAPE_FONTROMAN: font = HTMLFONT_NONE; @@ -255,6 +258,9 @@ print_metaf(struct html *h, enum mandoc_esc deco) h->metaf = print_otag(h, TAG_B, ""); print_otag(h, TAG_I, ""); break; + case HTMLFONT_CW: + h->metaf = print_otag(h, TAG_SPAN, "c", "Li"); + break; default: break; } @@ -408,6 +414,7 @@ print_encode(struct html *h, const char *p, const char *pend, int norecurse) case ESCAPE_FONTBOLD: case ESCAPE_FONTITALIC: case ESCAPE_FONTBI: + case ESCAPE_FONTCW: case ESCAPE_FONTROMAN: if (0 == norecurse) print_metaf(h, esc); @@ -738,6 +745,9 @@ print_text(struct html *h, const char *word) h->metaf = print_otag(h, TAG_B, ""); print_otag(h, TAG_I, ""); break; + case HTMLFONT_CW: + h->metaf = print_otag(h, TAG_SPAN, "c", "Li"); + break; default: print_indent(h); break; @@ -72,6 +72,7 @@ enum htmlfont { HTMLFONT_BOLD, HTMLFONT_ITALIC, HTMLFONT_BI, + HTMLFONT_CW, HTMLFONT_MAX }; @@ -304,8 +304,13 @@ mandoc_escape(const char **end, const char **start, int *sz) case ESCAPE_FONT: if (*sz == 2) { if (**start == 'C') { + if ((*start)[1] == 'W' || + (*start)[1] == 'R') { + gly = ESCAPE_FONTCW; + break; + } /* - * Treat constant-width font modes + * Treat other constant-width font modes * just like regular font modes. */ (*start)++; @@ -438,6 +438,7 @@ enum mandoc_esc { ESCAPE_FONTITALIC, /* italic font mode */ ESCAPE_FONTBI, /* bold italic font mode */ ESCAPE_FONTROMAN, /* roman font mode */ + ESCAPE_FONTCW, /* constant width font mode */ ESCAPE_FONTPREV, /* previous font mode */ ESCAPE_NUMBERED, /* a numbered glyph */ ESCAPE_UNICODE, /* a unicode codepoint */ diff --git a/mdoc_markdown.c b/mdoc_markdown.c index d6310abb..0cefcfac 100644 --- a/mdoc_markdown.c +++ b/mdoc_markdown.c @@ -600,6 +600,7 @@ md_word(const char *s) nextfont = "***"; break; case ESCAPE_FONT: + case ESCAPE_FONTCW: case ESCAPE_FONTROMAN: nextfont = ""; break; @@ -3361,6 +3361,7 @@ roff_char(ROFF_ARGS) case ESCAPE_FONTITALIC: case ESCAPE_FONTBOLD: case ESCAPE_FONTBI: + case ESCAPE_FONTCW: case ESCAPE_FONTPREV: font++; break; @@ -510,6 +510,7 @@ term_word(struct termp *p, const char *word) term_fontrepl(p, TERMFONT_BI); continue; case ESCAPE_FONT: + case ESCAPE_FONTCW: case ESCAPE_FONTROMAN: term_fontrepl(p, TERMFONT_NONE); continue; |