summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2018-10-25 01:32:40 +0000
committerIngo Schwarze <schwarze@openbsd.org>2018-10-25 01:32:40 +0000
commitc5692d062ca3cb8eb15948d7fbc2f5eb68be6cda (patch)
tree94de759c7f7feb9b61764095e908e723f0ae0499
parente4c12a05e0760bea4427e66a5914d9fed0111dee (diff)
downloadmandoc-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.c10
-rw-r--r--html.h1
-rw-r--r--mandoc.c7
-rw-r--r--mandoc.h1
-rw-r--r--mdoc_markdown.c1
-rw-r--r--roff.c1
-rw-r--r--term.c1
7 files changed, 21 insertions, 1 deletions
diff --git a/html.c b/html.c
index 8926ca2b..6d984717 100644
--- a/html.c
+++ b/html.c
@@ -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;
diff --git a/html.h b/html.h
index 46f9cebd..ed9a988c 100644
--- a/html.h
+++ b/html.h
@@ -72,6 +72,7 @@ enum htmlfont {
HTMLFONT_BOLD,
HTMLFONT_ITALIC,
HTMLFONT_BI,
+ HTMLFONT_CW,
HTMLFONT_MAX
};
diff --git a/mandoc.c b/mandoc.c
index f9cfa4ea..d2396c2a 100644
--- a/mandoc.c
+++ b/mandoc.c
@@ -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)++;
diff --git a/mandoc.h b/mandoc.h
index 52c9232f..ad1a6d3c 100644
--- a/mandoc.h
+++ b/mandoc.h
@@ -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;
diff --git a/roff.c b/roff.c
index eff423dc..9c545abc 100644
--- a/roff.c
+++ b/roff.c
@@ -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;
diff --git a/term.c b/term.c
index 52d3fa68..0ceb28d6 100644
--- a/term.c
+++ b/term.c
@@ -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;