aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/html.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2013-08-08 20:07:47 +0000
committerIngo Schwarze <schwarze@openbsd.org>2013-08-08 20:07:47 +0000
commitcbcd971bbd4927814d654460337a6774684b3d8f (patch)
treea16bde046faa01e1fc65164f1b20f8dc356001d7 /html.c
parentb9c9c79db57653ef779df3251313389a9fe378ec (diff)
downloadmandoc-cbcd971bbd4927814d654460337a6774684b3d8f.tar.gz
mandoc-cbcd971bbd4927814d654460337a6774684b3d8f.tar.zst
mandoc-cbcd971bbd4927814d654460337a6774684b3d8f.zip
Implement the roff(7) font-escape sequence \f(BI "bold+italic".
This improves the formatting of about 40 base manuals and reduces groff-mandoc formatting differences in base by about 5%.
Diffstat (limited to 'html.c')
-rw-r--r--html.c45
1 files changed, 35 insertions, 10 deletions
diff --git a/html.c b/html.c
index 115b79a0..9d28b427 100644
--- a/html.c
+++ b/html.c
@@ -1,7 +1,7 @@
-/* $Id: html.c,v 1.151 2012/05/31 22:29:13 schwarze Exp $ */
+/* $Id: html.c,v 1.152 2013/08/08 20:07:47 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
- * Copyright (c) 2011, 2012 Ingo Schwarze <schwarze@openbsd.org>
+ * Copyright (c) 2011, 2012, 2013 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
@@ -235,6 +235,9 @@ print_metaf(struct html *h, enum mandoc_esc deco)
case (ESCAPE_FONTBOLD):
font = HTMLFONT_BOLD;
break;
+ case (ESCAPE_FONTBI):
+ font = HTMLFONT_BI;
+ break;
case (ESCAPE_FONT):
/* FALLTHROUGH */
case (ESCAPE_FONTROMAN):
@@ -253,10 +256,20 @@ print_metaf(struct html *h, enum mandoc_esc deco)
h->metal = h->metac;
h->metac = font;
- if (HTMLFONT_NONE != font)
- h->metaf = HTMLFONT_BOLD == font ?
- print_otag(h, TAG_B, 0, NULL) :
- print_otag(h, TAG_I, 0, NULL);
+ switch (font) {
+ case (HTMLFONT_ITALIC):
+ h->metaf = print_otag(h, TAG_I, 0, NULL);
+ break;
+ case (HTMLFONT_BOLD):
+ h->metaf = print_otag(h, TAG_B, 0, NULL);
+ break;
+ case (HTMLFONT_BI):
+ h->metaf = print_otag(h, TAG_B, 0, NULL);
+ print_otag(h, TAG_I, 0, NULL);
+ break;
+ default:
+ break;
+ }
}
int
@@ -367,6 +380,8 @@ print_encode(struct html *h, const char *p, int norecurse)
/* FALLTHROUGH */
case (ESCAPE_FONTITALIC):
/* FALLTHROUGH */
+ case (ESCAPE_FONTBI):
+ /* FALLTHROUGH */
case (ESCAPE_FONTROMAN):
if (0 == norecurse)
print_metaf(h, esc);
@@ -544,10 +559,20 @@ print_text(struct html *h, const char *word)
}
assert(NULL == h->metaf);
- if (HTMLFONT_NONE != h->metac)
- h->metaf = HTMLFONT_BOLD == h->metac ?
- print_otag(h, TAG_B, 0, NULL) :
- print_otag(h, TAG_I, 0, NULL);
+ switch (h->metac) {
+ case (HTMLFONT_ITALIC):
+ h->metaf = print_otag(h, TAG_I, 0, NULL);
+ break;
+ case (HTMLFONT_BOLD):
+ h->metaf = print_otag(h, TAG_B, 0, NULL);
+ break;
+ case (HTMLFONT_BI):
+ h->metaf = print_otag(h, TAG_B, 0, NULL);
+ print_otag(h, TAG_I, 0, NULL);
+ break;
+ default:
+ break;
+ }
assert(word);
if ( ! print_encode(h, word, 0)) {