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 | 6d7bd68376bb91e0b5c2ea4ec175b367ed946fc5 (patch) | |
tree | b0f9734269df7b90bac3701dd8a4ac62cc8550f0 | |
parent | a93cab0159f106fce2adae204f5e9a1011800296 (diff) | |
download | mandoc-6d7bd68376bb91e0b5c2ea4ec175b367ed946fc5.tar.gz mandoc-6d7bd68376bb91e0b5c2ea4ec175b367ed946fc5.tar.zst mandoc-6d7bd68376bb91e0b5c2ea4ec175b367ed946fc5.zip |
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 | 12 | ||||
-rw-r--r-- | html.h | 3 | ||||
-rw-r--r-- | mandoc.c | 9 | ||||
-rw-r--r-- | mandoc.h | 3 | ||||
-rw-r--r-- | mdoc_markdown.c | 3 | ||||
-rw-r--r-- | roff.c | 3 | ||||
-rw-r--r-- | term.c | 3 |
7 files changed, 28 insertions, 8 deletions
@@ -1,4 +1,4 @@ -/* $Id: html.c,v 1.241 2018/10/02 14:56:47 schwarze Exp $ */ +/* $Id: html.c,v 1.242 2018/10/25 01:32:40 schwarze Exp $ */ /* * Copyright (c) 2008-2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2011-2015, 2017, 2018 Ingo Schwarze <schwarze@openbsd.org> @@ -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; @@ -1,4 +1,4 @@ -/* $Id: html.h,v 1.94 2018/10/02 14:56:47 schwarze Exp $ */ +/* $Id: html.h,v 1.95 2018/10/25 01:32:40 schwarze Exp $ */ /* * Copyright (c) 2008-2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2017, 2018 Ingo Schwarze <schwarze@openbsd.org> @@ -72,6 +72,7 @@ enum htmlfont { HTMLFONT_BOLD, HTMLFONT_ITALIC, HTMLFONT_BI, + HTMLFONT_CW, HTMLFONT_MAX }; @@ -1,4 +1,4 @@ -/* $Id: mandoc.c,v 1.107 2018/08/20 18:06:56 schwarze Exp $ */ +/* $Id: mandoc.c,v 1.108 2018/10/25 01:32:40 schwarze Exp $ */ /* * Copyright (c) 2008-2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2011-2015, 2017, 2018 Ingo Schwarze <schwarze@openbsd.org> @@ -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)++; @@ -1,4 +1,4 @@ -/* $Id: mandoc.h,v 1.253 2018/08/25 16:53:39 schwarze Exp $ */ +/* $Id: mandoc.h,v 1.254 2018/10/25 01:32:40 schwarze Exp $ */ /* * Copyright (c) 2010, 2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010-2018 Ingo Schwarze <schwarze@openbsd.org> @@ -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 301b71c7..bfa25a66 100644 --- a/mdoc_markdown.c +++ b/mdoc_markdown.c @@ -1,4 +1,4 @@ -/* $Id: mdoc_markdown.c,v 1.26 2018/08/17 20:33:38 schwarze Exp $ */ +/* $Id: mdoc_markdown.c,v 1.27 2018/10/25 01:32:40 schwarze Exp $ */ /* * Copyright (c) 2017, 2018 Ingo Schwarze <schwarze@openbsd.org> * @@ -600,6 +600,7 @@ md_word(const char *s) nextfont = "***"; break; case ESCAPE_FONT: + case ESCAPE_FONTCW: case ESCAPE_FONTROMAN: nextfont = ""; break; @@ -1,4 +1,4 @@ -/* $Id: roff.c,v 1.341 2018/08/25 16:53:39 schwarze Exp $ */ +/* $Id: roff.c,v 1.342 2018/10/25 01:32:40 schwarze Exp $ */ /* * Copyright (c) 2008-2012, 2014 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010-2015, 2017, 2018 Ingo Schwarze <schwarze@openbsd.org> @@ -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; @@ -1,4 +1,4 @@ -/* $Id: term.c,v 1.275 2018/08/16 13:54:06 schwarze Exp $ */ +/* $Id: term.c,v 1.276 2018/10/25 01:32:41 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010-2018 Ingo Schwarze <schwarze@openbsd.org> @@ -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; |