diff options
author | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2010-11-29 00:12:03 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2010-11-29 00:12:03 +0000 |
commit | 02878e6742aa9d7d2bc5f7b505bb066cdf405f44 (patch) | |
tree | 2c189ca62a7eaa9ee19f7e8640a955c70f6260bf /usr.bin/mandoc/man_html.c | |
parent | 514764d951001cf00df0f01dc4067490b6f10c67 (diff) |
Implement the roff .ft (change font) request for man(7).
Of course, we don't want to encourage low-level physical markup,
but pod2man(1) writes such requests, so Perl manuals contain them,
and some Xenocara and lots and lots of ports manuals use them as well.
In base and Xenocara, this will reduce mandoc -Tlint ERROR noise;
in ports, it will improve rendering of many manuals.
Diffstat (limited to 'usr.bin/mandoc/man_html.c')
-rw-r--r-- | usr.bin/mandoc/man_html.c | 47 |
1 files changed, 46 insertions, 1 deletions
diff --git a/usr.bin/mandoc/man_html.c b/usr.bin/mandoc/man_html.c index c2852273b81..22d544b6231 100644 --- a/usr.bin/mandoc/man_html.c +++ b/usr.bin/mandoc/man_html.c @@ -1,6 +1,7 @@ -/* $Id: man_html.c,v 1.19 2010/10/15 20:45:03 schwarze Exp $ */ +/* $Id: man_html.c,v 1.20 2010/11/29 00:12:02 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv> + * Copyright (c) 2010 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 @@ -60,6 +61,7 @@ static int a2width(const struct man_node *, static int man_alt_pre(MAN_ARGS); static int man_br_pre(MAN_ARGS); static int man_ign_pre(MAN_ARGS); +static int man_ft_pre(MAN_ARGS); static int man_in_pre(MAN_ARGS); static int man_literal_pre(MAN_ARGS); static void man_root_post(MAN_ARGS); @@ -115,6 +117,7 @@ static const struct htmlman mans[MAN_MAX] = { { man_in_pre, NULL }, /* in */ { NULL, NULL }, /* TS */ { NULL, NULL }, /* TE */ + { man_ft_pre, NULL }, /* ft */ }; @@ -731,6 +734,48 @@ man_I_pre(MAN_ARGS) /* ARGSUSED */ static int +man_ft_pre(MAN_ARGS) +{ + const char *cp; + + if (NULL == n->child) { + print_ofont(h, h->metal); + return(0); + } + + cp = n->child->string; + switch (*cp) { + case ('4'): + /* FALLTHROUGH */ + case ('3'): + /* FALLTHROUGH */ + case ('B'): + print_ofont(h, HTMLFONT_BOLD); + break; + case ('2'): + /* FALLTHROUGH */ + case ('I'): + print_ofont(h, HTMLFONT_ITALIC); + break; + case ('P'): + print_ofont(h, h->metal); + break; + case ('1'): + /* FALLTHROUGH */ + case ('C'): + /* FALLTHROUGH */ + case ('R'): + print_ofont(h, HTMLFONT_NONE); + break; + default: + break; + } + return(0); +} + + +/* ARGSUSED */ +static int man_literal_pre(MAN_ARGS) { |