diff options
author | Ingo Schwarze <schwarze@openbsd.org> | 2021-08-10 12:55:03 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@openbsd.org> | 2021-08-10 12:55:03 +0000 |
commit | 2c155e88b6e2ca5d3f75e9b16fcff86b8059f886 (patch) | |
tree | 7a6b42adef0485bb1febdd1c821de1046e7c1bfb /html.c | |
parent | ae3479c0b3b054123f6cd2e229271f9435c958de (diff) | |
download | mandoc-2c155e88b6e2ca5d3f75e9b16fcff86b8059f886.tar.gz mandoc-2c155e88b6e2ca5d3f75e9b16fcff86b8059f886.tar.zst mandoc-2c155e88b6e2ca5d3f75e9b16fcff86b8059f886.zip |
Support two-character font names (BI, CW, CR, CB, CI)
in the tbl(7) layout font modifier.
Get rid of the TBL_CELL_BOLD and TBL_CELL_ITALIC flags and use
the usual ESCAPE_FONT* enum mandoc_esc members from mandoc.h instead,
which simplifies and unifies some code.
While here, also support CB and CI in roff(7) \f escape sequences
and in roff(7) .ft requests for all output modes. Using those is
certainly not recommended because portability is limited even with
groff, but supporting them makes some existing third-party manual
pages look better, in particular in HTML output mode.
Bug-compatible with groff as far as i'm aware, except that i consider
font names starting with the '\n' (ASCII 0x0a line feed) character
so insane that i decided to not support them.
Missing feature reported by nabijaczleweli dot xyz in
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=992002.
I used none of the code from the initial patch submitted by
nabijaczleweli, but some of their ideas.
Final patch tested by them, too.
Diffstat (limited to 'html.c')
-rw-r--r-- | html.c | 22 |
1 files changed, 17 insertions, 5 deletions
@@ -1,7 +1,7 @@ -/* $Id: html.c,v 1.273 2021/06/02 17:51:38 schwarze Exp $ */ +/* $Id: html.c,v 1.274 2021/08/10 12:55:03 schwarze Exp $ */ /* - * Copyright (c) 2011-2015, 2017-2020 Ingo Schwarze <schwarze@openbsd.org> * Copyright (c) 2008-2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv> + * Copyright (c) 2011-2015, 2017-2021 Ingo Schwarze <schwarze@openbsd.org> * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -240,8 +240,10 @@ html_setfont(struct html *h, enum mandoc_esc font) case ESCAPE_FONTITALIC: case ESCAPE_FONTBOLD: case ESCAPE_FONTBI: - case ESCAPE_FONTCW: case ESCAPE_FONTROMAN: + case ESCAPE_FONTCR: + case ESCAPE_FONTCB: + case ESCAPE_FONTCI: break; case ESCAPE_FONT: font = ESCAPE_FONTROMAN; @@ -272,9 +274,17 @@ print_metaf(struct html *h) h->metaf = print_otag(h, TAG_B, ""); print_otag(h, TAG_I, ""); break; - case ESCAPE_FONTCW: + case ESCAPE_FONTCR: h->metaf = print_otag(h, TAG_SPAN, "c", "Li"); break; + case ESCAPE_FONTCB: + h->metaf = print_otag(h, TAG_SPAN, "c", "Li"); + print_otag(h, TAG_B, ""); + break; + case ESCAPE_FONTCI: + h->metaf = print_otag(h, TAG_SPAN, "c", "Li"); + print_otag(h, TAG_I, ""); + break; default: break; } @@ -503,8 +513,10 @@ 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: + case ESCAPE_FONTCR: + case ESCAPE_FONTCB: + case ESCAPE_FONTCI: if (0 == norecurse) { h->flags |= HTML_NOSPACE; if (html_setfont(h, esc)) |