diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2021-03-30 06:50:44 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2021-03-30 06:50:44 -0700 |
commit | 6c46061340369c1aa1b353f44fb543a3e3a00ca1 (patch) | |
tree | 746bf6222fc2ce1ceb392e025cc79f6b7fa00117 /man2html | |
parent | a41f7f47743345ddff6aa7bc34720daca83ee006 (diff) | |
download | man-6c46061340369c1aa1b353f44fb543a3e3a00ca1.tar.gz man-6c46061340369c1aa1b353f44fb543a3e3a00ca1.tar.bz2 man-6c46061340369c1aa1b353f44fb543a3e3a00ca1.zip |
definition list cleanup.
- Get rid of compact attribute from <dl>.
- RS now generates a <dl class="indent">
- IP generates <dl class="items"> we can target with styling.
- IP without argument doesn't start definition list.
Diffstat (limited to 'man2html')
-rw-r--r-- | man2html/man2html.c | 48 |
1 files changed, 37 insertions, 11 deletions
diff --git a/man2html/man2html.c b/man2html/man2html.c index 825680b..ead4ac8 100644 --- a/man2html/man2html.c +++ b/man2html/man2html.c @@ -361,6 +361,19 @@ out_html(char *c) { } } +static void +out_htmlf(char *c, ...) +{ + va_list vl; + char buf[512]; + + va_start (vl, c); + vsnprintf(buf, sizeof buf, c, vl); + va_end (vl); + + out_html(buf); +} + /* --------------------------------------------------------------- */ /* All references to dl_set and itemdepth are here. */ /* --------------------------------------------------------------- */ @@ -370,10 +383,12 @@ static int dl_set[30]= { 0 }; #define DL 1 #define UL 2 #define OL 3 -static char *dl_open[4] = { "", "<dl compact>\n", "<ul>", "<ol>" }; +static char *dl_open[4] = { "", "<dl>\n", "<ul>", "<ol>" }; +static char *dl_open_cls[4] = { "", "<dl class=\"%s\">\n", + "<ul class=\"%s\">", "<ol class=\"%s\">" }; static char *dl_close[4] = { "", "</dl>\n", "</ul>", "</ol>" }; -static inline void +static void dl_begin(void) { if (itemdepth < SIZE(dl_set) && dl_set[itemdepth] == noDL) { out_html(dl_open[DL]); @@ -382,7 +397,16 @@ dl_begin(void) { out_html("<dt>"); } -static inline void +static void +dl_begin_class(const char *class) { + if (itemdepth < SIZE(dl_set) && dl_set[itemdepth] == noDL) { + out_htmlf(dl_open_cls[DL], class); + dl_set[itemdepth]=DL; + } + out_html("<dt>"); +} + +static void dl_end(void) { if (itemdepth < SIZE(dl_set)) { int type = dl_set[itemdepth]; @@ -393,19 +417,19 @@ dl_end(void) { } } -static inline void +static void dl_newlevel(void) { itemdepth++; if (itemdepth < SIZE(dl_set)) dl_set[itemdepth]=noDL; - out_html("<dl compact><dt><dd>"); + out_htmlf(dl_open_cls[DL], "indent"); } -static inline void +static void dl_endlevel(void) { if (itemdepth) { dl_end(); - out_html("</dl>\n"); + out_html("</dl>"); itemdepth--; } } @@ -2101,11 +2125,13 @@ scan_request(char *c) { case V('I','P'): sl = fill_words(c+j, wordlist, SIZE(wordlist), &words, '\n'); c = sl+1; - dl_begin(); - if (words) { - scan_troff(wordlist[0], 1,NULL); + if (words) { + dl_begin_class("items"); + if (words) { + scan_troff(wordlist[0], 1,NULL); + } + out_html("<dd>"); } - out_html("<dd>"); curpos = 0; break; case V('T','P'): |