summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@cvs.openbsd.org>2018-12-15 23:33:21 +0000
committerIngo Schwarze <schwarze@cvs.openbsd.org>2018-12-15 23:33:21 +0000
commitc435f684013b13f8286956412bb611ffe3ab5c0a (patch)
tree1333fd954431797accba4c6eef9be77dbb045771
parent3962ec0010304a43d14512a8b79da75485655694 (diff)
Yet another round of improvements to manual font selection.
Unify handling of \f and .ft. Support \f4 (bold+italic). Support ".ft BI" and ".ft CW" for terminal output. Support the .ft request in HTML output. Reject the bogus fonts \f(C1, \f(C2, \f(C3, and \f(CP.
-rw-r--r--regress/usr.bin/mandoc/roff/esc/Makefile3
-rw-r--r--regress/usr.bin/mandoc/roff/esc/f.in23
-rw-r--r--regress/usr.bin/mandoc/roff/esc/f.out_ascii17
-rw-r--r--regress/usr.bin/mandoc/roff/esc/f.out_html6
-rw-r--r--regress/usr.bin/mandoc/roff/ft/Makefile3
-rw-r--r--regress/usr.bin/mandoc/roff/ft/badargs.in19
-rw-r--r--regress/usr.bin/mandoc/roff/ft/badargs.out_ascii5
-rw-r--r--regress/usr.bin/mandoc/roff/ft/badargs.out_html14
-rw-r--r--regress/usr.bin/mandoc/roff/ft/badargs.out_lint4
-rw-r--r--share/man/man7/roff.7118
-rw-r--r--usr.bin/mandoc/html.c7
-rw-r--r--usr.bin/mandoc/html.h3
-rw-r--r--usr.bin/mandoc/man_html.c3
-rw-r--r--usr.bin/mandoc/mandoc.c97
-rw-r--r--usr.bin/mandoc/mandoc.h3
-rw-r--r--usr.bin/mandoc/mdoc_html.c3
-rw-r--r--usr.bin/mandoc/roff_html.c18
-rw-r--r--usr.bin/mandoc/roff_term.c26
-rw-r--r--usr.bin/mandoc/roff_validate.c28
-rw-r--r--usr.bin/mandoc/tbl_html.c3
20 files changed, 245 insertions, 158 deletions
diff --git a/regress/usr.bin/mandoc/roff/esc/Makefile b/regress/usr.bin/mandoc/roff/esc/Makefile
index 7d0a753df75..1be8b179a85 100644
--- a/regress/usr.bin/mandoc/roff/esc/Makefile
+++ b/regress/usr.bin/mandoc/roff/esc/Makefile
@@ -1,7 +1,8 @@
-# $OpenBSD: Makefile,v 1.14 2018/12/15 19:30:20 schwarze Exp $
+# $OpenBSD: Makefile,v 1.15 2018/12/15 23:33:20 schwarze Exp $
REGRESS_TARGETS = one two multi B c c_man e f h l O o p w z
REGRESS_TARGETS += ignore invalid unsupp
+HTML_TARGETS = f
LINT_TARGETS = B h l O w ignore invalid unsupp
.include <bsd.regress.mk>
diff --git a/regress/usr.bin/mandoc/roff/esc/f.in b/regress/usr.bin/mandoc/roff/esc/f.in
index 571161d308c..3eaca449104 100644
--- a/regress/usr.bin/mandoc/roff/esc/f.in
+++ b/regress/usr.bin/mandoc/roff/esc/f.in
@@ -1,13 +1,12 @@
-.\" $OpenBSD: f.in,v 1.3 2017/07/04 14:53:27 schwarze Exp $
-.Dd $Mdocdate: July 4 2017 $
-.Dt ESC-F 1
-.Os
-.Sh NAME
-.Nm esc-f
-.Nd the roff escape f sequence: font changes
-.Sh DESCRIPTION
-numbers: \f3bold\f2italic\f1roman
-.br
+.\" $OpenBSD: f.in,v 1.4 2018/12/15 23:33:20 schwarze Exp $
+.TH ESC-F 1 "December 15, 2018"
+.SH NAME
+esc-f \- the roff escape f sequence: font changes
+.SH DESCRIPTION
+.nf
+BEGINTEST
+numbers: \f4bolditalic\f3bold\f2italic\f1roman
letters: \fBbold\fIitalic\fPback\f(BIbolditalic\fRroman
-.br
-multiletter: \f[B]bold\f[I]italic\f[P]back\f[BI]bolditalic\f[R]roman
+multiletter: \f[B]bold\f[]empty\f[I]italic\f[P]back\f[BI]bolditalic\f[R]roman
+typewriter: \f(CWroman\f(CBbold\f(CRroman\f(CIitalic\fRroman
+ENDTEST
diff --git a/regress/usr.bin/mandoc/roff/esc/f.out_ascii b/regress/usr.bin/mandoc/roff/esc/f.out_ascii
index fb8520f86af..797dbe8669d 100644
--- a/regress/usr.bin/mandoc/roff/esc/f.out_ascii
+++ b/regress/usr.bin/mandoc/roff/esc/f.out_ascii
@@ -1,11 +1,18 @@
ESC-F(1) General Commands Manual ESC-F(1)
+
+
NNAAMMEE
- eesscc--ff - the roff escape f sequence: font changes
+ esc-f - the roff escape f sequence: font changes
DDEESSCCRRIIPPTTIIOONN
- numbers: bboolldd_i_t_a_l_i_croman
- letters: bboolldd_i_t_a_l_i_cbbaacckk_bb_oo_ll_dd_ii_tt_aa_ll_ii_ccroman
- multiletter: bboolldd_i_t_a_l_i_cbbaacckk_bb_oo_ll_dd_ii_tt_aa_ll_ii_ccroman
+ BEGINTEST
+ numbers: _bb_oo_ll_dd_ii_tt_aa_ll_ii_ccbboolldd_i_t_a_l_i_croman
+ letters: bboolldd_i_t_a_l_i_cbbaacckk_bb_oo_ll_dd_ii_tt_aa_ll_ii_ccroman
+ multiletter: bboollddempty_i_t_a_l_i_cback_bb_oo_ll_dd_ii_tt_aa_ll_ii_ccroman
+ typewriter: romanbboollddroman_i_t_a_l_i_croman
+ ENDTEST
+
+
-OpenBSD July 4, 2017 OpenBSD
+OpenBSD December 15, 2018 ESC-F(1)
diff --git a/regress/usr.bin/mandoc/roff/esc/f.out_html b/regress/usr.bin/mandoc/roff/esc/f.out_html
new file mode 100644
index 00000000000..332e0f008cc
--- /dev/null
+++ b/regress/usr.bin/mandoc/roff/esc/f.out_html
@@ -0,0 +1,6 @@
+BEGINTEST
+numbers: <b><i>bolditalic</i></b><b>bold</b><i>italic</i>roman
+letters: <b>bold</b><i>italic</i><b>back</b><b><i>bolditalic</i></b>roman
+multiletter: <b>bold</b>empty<i>italic</i>back<b><i>bolditalic</i></b>roman
+typewriter: <span class="Li">roman</span><b>bold</b><span class="Li">roman</span><i>italic</i>roman
+ENDTEST
diff --git a/regress/usr.bin/mandoc/roff/ft/Makefile b/regress/usr.bin/mandoc/roff/ft/Makefile
index 65ee249896b..0eadb05dd89 100644
--- a/regress/usr.bin/mandoc/roff/ft/Makefile
+++ b/regress/usr.bin/mandoc/roff/ft/Makefile
@@ -1,6 +1,7 @@
-# $OpenBSD: Makefile,v 1.2 2017/05/05 02:06:17 schwarze Exp $
+# $OpenBSD: Makefile,v 1.3 2018/12/15 23:33:20 schwarze Exp $
REGRESS_TARGETS = badargs badargs-mdoc
+HTML_TARGETS = badargs
LINT_TARGETS = badargs badargs-mdoc
SKIP_TMAN = badargs
diff --git a/regress/usr.bin/mandoc/roff/ft/badargs.in b/regress/usr.bin/mandoc/roff/ft/badargs.in
index 82269609d3a..b5174783b7f 100644
--- a/regress/usr.bin/mandoc/roff/ft/badargs.in
+++ b/regress/usr.bin/mandoc/roff/ft/badargs.in
@@ -1,9 +1,22 @@
-.\" $OpenBSD: badargs.in,v 1.3 2017/07/04 14:53:27 schwarze Exp $
-.TH "FT-BADARGS" 1 "July 5, 2014"
+.\" $OpenBSD: badargs.in,v 1.4 2018/12/15 23:33:20 schwarze Exp $
+.TH "FT-BADARGS" 1 "December 15, 2018"
.SH NAME
ft-badargs \(en font request with bad arguments
.SH DESCRIPTION
+BEGINTEST
default font
+.ft I
+italic
+.ft BI
+bold italic
+.ft CR
+typeqriter
+.ft CW
+roman
+.ft CB
+bold
+.ft CI
+italic
.ft B
bold
.ft foo
@@ -14,3 +27,5 @@ italic
back to bold
.ft
back to italic
+.ft R
+ENDTEST
diff --git a/regress/usr.bin/mandoc/roff/ft/badargs.out_ascii b/regress/usr.bin/mandoc/roff/ft/badargs.out_ascii
index 30bfed3c99e..6bc36867359 100644
--- a/regress/usr.bin/mandoc/roff/ft/badargs.out_ascii
+++ b/regress/usr.bin/mandoc/roff/ft/badargs.out_ascii
@@ -6,8 +6,9 @@ NNAAMMEE
ft-badargs - font request with bad arguments
DDEESSCCRRIIPPTTIIOONN
- default font bboolldd ssttiillll bboolldd _i_t_a_l_i_c bbaacckk ttoo bboolldd _b_a_c_k _t_o _i_t_a_l_i_c
+ BEGINTEST default font _i_t_a_l_i_c _bb_oo_ll_dd _ii_tt_aa_ll_ii_cc typeqriter roman bboolldd _i_t_a_l_i_c
+ bboolldd ssttiillll bboolldd _i_t_a_l_i_c bbaacckk ttoo bboolldd _b_a_c_k _t_o _i_t_a_l_i_c ENDTEST
-OpenBSD July 5, 2014 FT-BADARGS(1)
+OpenBSD December 15, 2018 FT-BADARGS(1)
diff --git a/regress/usr.bin/mandoc/roff/ft/badargs.out_html b/regress/usr.bin/mandoc/roff/ft/badargs.out_html
new file mode 100644
index 00000000000..1985961ad7a
--- /dev/null
+++ b/regress/usr.bin/mandoc/roff/ft/badargs.out_html
@@ -0,0 +1,14 @@
+BEGINTEST default font <i></i><i>italic</i> <b><i></i></b><b><i>bold
+ italic</i></b> <span class="Li"></span><span class="Li">typeqriter</span>
+ <span class="Li"></span><span class="Li">roman</span> <b></b><b>bold</b>
+ <i></i> <i>italic</i> <b></b><b>bold</b> <b>still bold</b>
+ <i></i><i>italic</i> <i></i><i>back to bold</i> <i></i><i>back to italic</i>
+ ENDTEST</div>
+<table class="foot">
+ <tr>
+ <td class="foot-date">December 15, 2018</td>
+ <td class="foot-os"></td>
+ </tr>
+</table>
+</body>
+</html>
diff --git a/regress/usr.bin/mandoc/roff/ft/badargs.out_lint b/regress/usr.bin/mandoc/roff/ft/badargs.out_lint
index 36c8c0bf260..b8ad4612ac4 100644
--- a/regress/usr.bin/mandoc/roff/ft/badargs.out_lint
+++ b/regress/usr.bin/mandoc/roff/ft/badargs.out_lint
@@ -1,2 +1,2 @@
-mandoc: badargs.in:11:7: ERROR: skipping excess arguments: ft ... bogus
-mandoc: badargs.in:9:2: WARNING: unknown font, skipping request: ft foo
+mandoc: badargs.in:24:7: ERROR: skipping excess arguments: ft ... bogus
+mandoc: badargs.in:22:2: WARNING: unknown font, skipping request: ft foo
diff --git a/share/man/man7/roff.7 b/share/man/man7/roff.7
index 13bc85e2632..3991e39b4b4 100644
--- a/share/man/man7/roff.7
+++ b/share/man/man7/roff.7
@@ -1,4 +1,4 @@
-.\" $OpenBSD: roff.7,v 1.88 2018/12/15 19:30:19 schwarze Exp $
+.\" $OpenBSD: roff.7,v 1.89 2018/12/15 23:33:20 schwarze Exp $
.\"
.\" Copyright (c) 2010, 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
.\" Copyright (c) 2010-2018 Ingo Schwarze <schwarze@openbsd.org>
@@ -132,18 +132,73 @@ One-letter backslash escape.
See
.Xr mandoc_char 7
for a complete list.
-.Ss Text Decoration
-Terms may be text-decorated using the
-.Sq \ef
-escape followed by an indicator: B (bold), I (italic), R (regular), or P
-(revert to previous mode).
-A numerical representation 3, 2, or 1 (bold, italic, and regular,
-respectively) may be used instead.
-.Pp
-The two-character indicator
-.Sq BI
-requests a font that is both bold and italic.
-It may not be portable to old roff implementations.
+.Ss Font Selection
+In
+.Xr mdoc 7
+and
+.Xr man 7
+documents, fonts are usually selected with macros.
+The
+.Ic \ef
+escape sequence and the
+.Ic \&ft
+request can be used to manually change the font,
+but this is not recommended in
+.Xr mdoc 7
+documents.
+Such manual font changes are overridden by many subsequent macros.
+.Pp
+The following fonts are supported:
+.Pp
+.Bl -tag -width CW -offset indent -compact
+.It Cm B
+Bold font.
+.It Cm BI
+A font that is both bold and italic.
+.It Cm CB
+Bold constant width font.
+Same as
+.Cm B
+in terminal output.
+.It Cm CI
+Italic constant width font.
+Same as
+.Cm I
+in terminal output.
+.It Cm CR
+Regular constant width font.
+Same as
+.Cm R
+in terminal output.
+.It Cm CW
+An alias for
+.Cm CR .
+.It Cm I
+Italic font.
+.It Cm P
+Return to the previous font.
+If a macro caused a font change since the last
+.Ic \ef
+eascape sequence or
+.Ic \&ft
+request, this returns to the font before the last font change in
+the macro rather than to the font before the last manual font change.
+.It Cm R
+Roman font.
+This is the default font.
+.It Cm 1
+An alias for
+.Cm R .
+.It Cm 2
+An alias for
+.Cm I .
+.It Cm 3
+An alias for
+.Cm B .
+.It Cm 4
+An alias for
+.Cm BI .
+.El
.Pp
Examples:
.Bl -tag -width Ds -offset indent -compact
@@ -154,12 +209,6 @@ Write in \fIitalic\fP, then return to previous font mode.
.It Li \ef(BIbold italic\efP
Write in \f(BIbold italic\fP, then return to previous font mode.
.El
-.Pp
-Text decoration is
-.Em not
-recommended for
-.Xr mdoc 7 ,
-which encourages semantic annotation.
.Ss Whitespace
Whitespace consists of the space character.
In text lines, whitespace is preserved within a line.
@@ -888,27 +937,12 @@ This is a Heirloom extension and currently ignored.
Conditionally define a special font.
This is a groff extension and currently ignored.
.It Ic \&ft Op Ar font
-Change the font.
-The following
+Change the font; see
+.Sx Font Selection .
+The
.Ar font
-arguments are supported:
-.Bl -tag -width 4n -offset indent
-.It Cm B , BI , CB , 3 , 4
-switches to
-.Sy bold
-font
-.It Cm I , CI , 2
-switches to
-.Em underlined
-font
-.It Cm R , CR , CW , 1
-switches to normal font
-.It Cm P No "or no argument"
-switches back to the previous font
-.El
-.Pp
-This request takes effect only locally and may be overridden
-by macros and escape sequences.
+argument defaults to
+.Cm P .
.It Ic \&ftr Ar newname Op Ar oldname
Translate font name.
This is a groff extension and currently ignored.
@@ -2004,11 +2038,15 @@ and
Switch to the font
.Ar name ,
see
-.Sx Text Decoration .
+.Sx Font Selection .
For short names, there are variants
.Ic \ef Ns Ar c
and
.Ic \ef( Ns Ar cc .
+An empty name
+.Ic \ef[]
+defaults to
+.Ic \efP .
.It Ic \eg[ Ns Ar name Ns Ic \&]
Interpolate the format of a number register; ignored by
.Xr mandoc 1 .
diff --git a/usr.bin/mandoc/html.c b/usr.bin/mandoc/html.c
index 9c93eb64e55..a2783f1ef34 100644
--- a/usr.bin/mandoc/html.c
+++ b/usr.bin/mandoc/html.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: html.c,v 1.116 2018/12/15 19:30:19 schwarze Exp $ */
+/* $OpenBSD: html.c,v 1.117 2018/12/15 23:33:20 schwarze Exp $ */
/*
* Copyright (c) 2008-2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011-2015, 2017, 2018 Ingo Schwarze <schwarze@openbsd.org>
@@ -115,7 +115,6 @@ static void print_ctag(struct html *, struct tag *);
static int print_escape(struct html *, char);
static int print_encode(struct html *, const char *, const char *, int);
static void print_href(struct html *, const char *, const char *, int);
-static void print_metaf(struct html *, enum mandoc_esc);
void *
@@ -208,7 +207,7 @@ print_gen_head(struct html *h)
print_tagq(h, t);
}
-static void
+void
print_metaf(struct html *h, enum mandoc_esc deco)
{
enum htmlfont font;
@@ -234,7 +233,7 @@ print_metaf(struct html *h, enum mandoc_esc deco)
font = HTMLFONT_NONE;
break;
default:
- abort();
+ return;
}
if (h->metaf) {
diff --git a/usr.bin/mandoc/html.h b/usr.bin/mandoc/html.h
index 5604507e118..b16f973a918 100644
--- a/usr.bin/mandoc/html.h
+++ b/usr.bin/mandoc/html.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: html.h,v 1.57 2018/10/25 01:21:30 schwarze Exp $ */
+/* $OpenBSD: html.h,v 1.58 2018/12/15 23:33:20 schwarze Exp $ */
/*
* Copyright (c) 2008-2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2017, 2018 Ingo Schwarze <schwarze@openbsd.org>
@@ -125,6 +125,7 @@ void roff_html_pre(struct html *, const struct roff_node *);
void print_gen_comment(struct html *, struct roff_node *);
void print_gen_decls(struct html *);
void print_gen_head(struct html *);
+void print_metaf(struct html *, enum mandoc_esc);
struct tag *print_otag(struct html *, enum htmltag, const char *, ...);
void print_tagq(struct html *, const struct tag *);
void print_stagq(struct html *, const struct tag *);
diff --git a/usr.bin/mandoc/man_html.c b/usr.bin/mandoc/man_html.c
index 2d8fe40de4d..a420656083d 100644
--- a/usr.bin/mandoc/man_html.c
+++ b/usr.bin/mandoc/man_html.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: man_html.c,v 1.112 2018/12/13 11:55:14 schwarze Exp $ */
+/* $OpenBSD: man_html.c,v 1.113 2018/12/15 23:33:20 schwarze Exp $ */
/*
* Copyright (c) 2008-2012, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2013,2014,2015,2017,2018 Ingo Schwarze <schwarze@openbsd.org>
@@ -24,6 +24,7 @@
#include <string.h>
#include "mandoc_aux.h"
+#include "mandoc.h"
#include "roff.h"
#include "man.h"
#include "out.h"
diff --git a/usr.bin/mandoc/mandoc.c b/usr.bin/mandoc/mandoc.c
index f4249a4b78f..24c4a8823b3 100644
--- a/usr.bin/mandoc/mandoc.c
+++ b/usr.bin/mandoc/mandoc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mandoc.c,v 1.79 2018/12/15 19:30:19 schwarze Exp $ */
+/* $OpenBSD: mandoc.c,v 1.80 2018/12/15 23:33:20 schwarze Exp $ */
/*
* Copyright (c) 2008-2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011-2015, 2017, 2018 Ingo Schwarze <schwarze@openbsd.org>
@@ -36,6 +36,59 @@ static char *time2a(time_t);
enum mandoc_esc
+mandoc_font(const char *cp, int sz)
+{
+ switch (sz) {
+ case 0:
+ return ESCAPE_FONTPREV;
+ case 1:
+ switch (cp[0]) {
+ case 'B':
+ case '3':
+ return ESCAPE_FONTBOLD;
+ case 'I':
+ case '2':
+ return ESCAPE_FONTITALIC;
+ case 'P':
+ return ESCAPE_FONTPREV;
+ case 'R':
+ case '1':
+ return ESCAPE_FONTROMAN;
+ case '4':
+ return ESCAPE_FONTBI;
+ default:
+ return ESCAPE_ERROR;
+ }
+ case 2:
+ switch (cp[0]) {
+ case 'B':
+ switch (cp[1]) {
+ case 'I':
+ return ESCAPE_FONTBI;
+ default:
+ return ESCAPE_ERROR;
+ }
+ case 'C':
+ switch (cp[1]) {
+ case 'B':
+ return ESCAPE_FONTBOLD;
+ case 'I':
+ return ESCAPE_FONTITALIC;
+ case 'R':
+ case 'W':
+ return ESCAPE_FONTCW;
+ default:
+ return ESCAPE_ERROR;
+ }
+ default:
+ return ESCAPE_ERROR;
+ }
+ default:
+ return ESCAPE_ERROR;
+ }
+}
+
+enum mandoc_esc
mandoc_escape(const char **end, const char **start, int *sz)
{
const char *local_start;
@@ -365,47 +418,7 @@ mandoc_escape(const char **end, const char **start, int *sz)
switch (gly) {
case ESCAPE_FONT:
- if (*sz == 2) {
- if (**start == 'C') {
- if ((*start)[1] == 'W' ||
- (*start)[1] == 'R') {
- gly = ESCAPE_FONTCW;
- break;
- }
- /*
- * Treat other constant-width font modes
- * just like regular font modes.
- */
- (*start)++;
- (*sz)--;
- } else {
- if ((*start)[0] == 'B' && (*start)[1] == 'I')
- gly = ESCAPE_FONTBI;
- break;
- }
- } else if (*sz != 1) {
- if (*sz == 0)
- gly = ESCAPE_FONTPREV;
- break;
- }
-
- switch (**start) {
- case '3':
- case 'B':
- gly = ESCAPE_FONTBOLD;
- break;
- case '2':
- case 'I':
- gly = ESCAPE_FONTITALIC;
- break;
- case 'P':
- gly = ESCAPE_FONTPREV;
- break;
- case '1':
- case 'R':
- gly = ESCAPE_FONTROMAN;
- break;
- }
+ gly = mandoc_font(*start, *sz);
break;
case ESCAPE_SPECIAL:
if (**start == 'c') {
diff --git a/usr.bin/mandoc/mandoc.h b/usr.bin/mandoc/mandoc.h
index 2e4a9dc0317..835ee2c95e2 100644
--- a/usr.bin/mandoc/mandoc.h
+++ b/usr.bin/mandoc/mandoc.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: mandoc.h,v 1.203 2018/12/15 19:30:19 schwarze Exp $ */
+/* $OpenBSD: mandoc.h,v 1.204 2018/12/15 23:33:20 schwarze Exp $ */
/*
* Copyright (c) 2010, 2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2012-2018 Ingo Schwarze <schwarze@openbsd.org>
@@ -270,6 +270,7 @@ enum mandoc_esc {
};
+enum mandoc_esc mandoc_font(const char *, int sz);
enum mandoc_esc mandoc_escape(const char **, const char **, int *);
void mandoc_msg_setoutfile(FILE *);
const char *mandoc_msg_getinfilename(void);
diff --git a/usr.bin/mandoc/mdoc_html.c b/usr.bin/mandoc/mdoc_html.c
index 2c2d0c0842a..598a5020bf6 100644
--- a/usr.bin/mandoc/mdoc_html.c
+++ b/usr.bin/mandoc/mdoc_html.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mdoc_html.c,v 1.192 2018/12/13 11:55:14 schwarze Exp $ */
+/* $OpenBSD: mdoc_html.c,v 1.193 2018/12/15 23:33:20 schwarze Exp $ */
/*
* Copyright (c) 2008-2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2014,2015,2016,2017,2018 Ingo Schwarze <schwarze@openbsd.org>
@@ -25,6 +25,7 @@
#include <unistd.h>
#include "mandoc_aux.h"
+#include "mandoc.h"
#include "roff.h"
#include "mdoc.h"
#include "out.h"
diff --git a/usr.bin/mandoc/roff_html.c b/usr.bin/mandoc/roff_html.c
index cf3e198af15..9cf1c3b1b71 100644
--- a/usr.bin/mandoc/roff_html.c
+++ b/usr.bin/mandoc/roff_html.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: roff_html.c,v 1.14 2018/12/13 11:55:14 schwarze Exp $ */
+/* $OpenBSD: roff_html.c,v 1.15 2018/12/15 23:33:20 schwarze Exp $ */
/*
* Copyright (c) 2010 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2014, 2017, 2018 Ingo Schwarze <schwarze@openbsd.org>
@@ -18,8 +18,10 @@
#include <sys/types.h>
#include <assert.h>
-#include <stddef.h>
+#include <stdio.h>
+#include <string.h>
+#include "mandoc.h"
#include "roff.h"
#include "out.h"
#include "html.h"
@@ -30,12 +32,13 @@ typedef void (*roff_html_pre_fp)(ROFF_HTML_ARGS);
static void roff_html_pre_br(ROFF_HTML_ARGS);
static void roff_html_pre_ce(ROFF_HTML_ARGS);
+static void roff_html_pre_ft(ROFF_HTML_ARGS);
static void roff_html_pre_sp(ROFF_HTML_ARGS);
static const roff_html_pre_fp roff_html_pre_acts[ROFF_MAX] = {
roff_html_pre_br, /* br */
roff_html_pre_ce, /* ce */
- NULL, /* ft */
+ roff_html_pre_ft, /* ft */
NULL, /* ll */
NULL, /* mc */
NULL, /* po */
@@ -75,6 +78,15 @@ roff_html_pre_ce(ROFF_HTML_ARGS)
}
static void
+roff_html_pre_ft(ROFF_HTML_ARGS)
+{
+ const char *cp;
+
+ cp = n->child->string;
+ print_metaf(h, mandoc_font(cp, (int)strlen(cp)));
+}
+
+static void
roff_html_pre_sp(ROFF_HTML_ARGS)
{
print_paragraph(h);
diff --git a/usr.bin/mandoc/roff_term.c b/usr.bin/mandoc/roff_term.c
index 747fe591f69..80e6b90a885 100644
--- a/usr.bin/mandoc/roff_term.c
+++ b/usr.bin/mandoc/roff_term.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: roff_term.c,v 1.16 2018/12/14 01:17:46 schwarze Exp $ */
+/* $OpenBSD: roff_term.c,v 1.17 2018/12/15 23:33:20 schwarze Exp $ */
/*
* Copyright (c) 2010,2014,2015,2017,2018 Ingo Schwarze <schwarze@openbsd.org>
*
@@ -18,6 +18,7 @@
#include <assert.h>
#include <stdio.h>
+#include <string.h>
#include "mandoc.h"
#include "roff.h"
@@ -113,25 +114,22 @@ roff_term_pre_ft(ROFF_TERM_ARGS)
{
const char *cp;
- if (*(cp = n->child->string) == 'C')
- cp++;
-
- switch (*cp) {
- case '4':
- case '3':
- case 'B':
+ cp = n->child->string;
+ switch (mandoc_font(cp, (int)strlen(cp))) {
+ case ESCAPE_FONTBOLD:
term_fontrepl(p, TERMFONT_BOLD);
break;
- case '2':
- case 'I':
+ case ESCAPE_FONTITALIC:
term_fontrepl(p, TERMFONT_UNDER);
break;
- case 'P':
+ case ESCAPE_FONTBI:
+ term_fontrepl(p, TERMFONT_BI);
+ break;
+ case ESCAPE_FONTPREV:
term_fontlast(p);
break;
- case '1':
- case 'C':
- case 'R':
+ case ESCAPE_FONTROMAN:
+ case ESCAPE_FONTCW:
term_fontrepl(p, TERMFONT_NONE);
break;
default:
diff --git a/usr.bin/mandoc/roff_validate.c b/usr.bin/mandoc/roff_validate.c
index d9b17b5f5f3..839d42c7ed9 100644
--- a/usr.bin/mandoc/roff_validate.c
+++ b/usr.bin/mandoc/roff_validate.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: roff_validate.c,v 1.14 2018/12/14 05:17:45 schwarze Exp $ */
+/* $OpenBSD: roff_validate.c,v 1.15 2018/12/15 23:33:20 schwarze Exp $ */
/*
* Copyright (c) 2010, 2017, 2018 Ingo Schwarze <schwarze@openbsd.org>
*
@@ -104,30 +104,8 @@ roff_valid_ft(ROFF_VALID_ARGS)
}
cp = n->child->string;
- switch (*cp) {
- case '1':
- case '2':
- case '3':
- case '4':
- case 'I':
- case 'P':
- case 'R':
- if (cp[1] == '\0')
- return;
- break;
- case 'B':
- if (cp[1] == '\0' || (cp[1] == 'I' && cp[2] == '\0'))
- return;
- break;
- case 'C':
- if (cp[1] != '\0' && cp[2] == '\0' &&
- strchr("BIRW", cp[1]) != NULL)
- return;
- break;
- default:
- break;
- }
-
+ if (mandoc_font(cp, (int)strlen(cp)) != ESCAPE_ERROR)
+ return;
mandoc_msg(MANDOCERR_FT_BAD, n->line, n->pos, "ft %s", cp);
roff_node_delete(man, n);
}
diff --git a/usr.bin/mandoc/tbl_html.c b/usr.bin/mandoc/tbl_html.c
index 6bfe462aea3..a4a448ef42e 100644
--- a/usr.bin/mandoc/tbl_html.c
+++ b/usr.bin/mandoc/tbl_html.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tbl_html.c,v 1.25 2018/12/12 21:54:30 schwarze Exp $ */
+/* $OpenBSD: tbl_html.c,v 1.26 2018/12/15 23:33:20 schwarze Exp $ */
/*
* Copyright (c) 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2014, 2015, 2017, 2018 Ingo Schwarze <schwarze@openbsd.org>
@@ -22,6 +22,7 @@
#include <stdlib.h>
#include <string.h>
+#include "mandoc.h"
#include "tbl.h"
#include "out.h"
#include "html.h"