summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile.depend8
-rw-r--r--html.c5
-rw-r--r--html.h1
-rw-r--r--man_html.c1
-rw-r--r--mandoc.c95
-rw-r--r--mandoc.h1
-rw-r--r--mandoc_headers.35
-rw-r--r--mdoc_html.c1
-rwxr-xr-xregress/regress.pl20
-rw-r--r--regress/roff/esc/Makefile3
-rw-r--r--regress/roff/esc/f.in23
-rw-r--r--regress/roff/esc/f.out_ascii17
-rw-r--r--regress/roff/esc/f.out_html6
-rw-r--r--regress/roff/ft/Makefile3
-rw-r--r--regress/roff/ft/badargs.in21
-rw-r--r--regress/roff/ft/badargs.out_ascii7
-rw-r--r--regress/roff/ft/badargs.out_html9
-rw-r--r--regress/roff/ft/badargs.out_lint4
-rw-r--r--roff.7118
-rw-r--r--roff_html.c16
-rw-r--r--roff_term.c24
-rw-r--r--roff_validate.c26
-rw-r--r--tbl_html.c1
23 files changed, 252 insertions, 163 deletions
diff --git a/Makefile.depend b/Makefile.depend
index 827b4763..5817765c 100644
--- a/Makefile.depend
+++ b/Makefile.depend
@@ -34,7 +34,7 @@ html.o: html.c config.h mandoc_aux.h mandoc_ohash.h compat_ohash.h mandoc.h roff
lib.o: lib.c config.h roff.h libmdoc.h lib.in
main.o: main.c config.h mandoc_aux.h mandoc.h mandoc_xr.h roff.h mdoc.h man.h mandoc_parse.h tag.h main.h manconf.h mansearch.h
man.o: man.c config.h mandoc_aux.h mandoc.h roff.h man.h libmandoc.h roff_int.h libman.h
-man_html.o: man_html.c config.h mandoc_aux.h roff.h man.h out.h html.h main.h
+man_html.o: man_html.c config.h mandoc_aux.h mandoc.h roff.h man.h out.h html.h main.h
man_macro.o: man_macro.c config.h mandoc.h roff.h man.h libmandoc.h roff_int.h libman.h
man_term.o: man_term.c config.h mandoc_aux.h roff.h man.h out.h term.h main.h
man_validate.o: man_validate.c config.h mandoc_aux.h mandoc.h roff.h man.h libmandoc.h roff_int.h libman.h
@@ -49,7 +49,7 @@ manpath.o: manpath.c config.h mandoc_aux.h manconf.h
mansearch.o: mansearch.c config.h mandoc_aux.h mandoc_ohash.h compat_ohash.h manconf.h mansearch.h dbm.h
mdoc.o: mdoc.c config.h mandoc_aux.h mandoc.h roff.h mdoc.h libmandoc.h roff_int.h libmdoc.h
mdoc_argv.o: mdoc_argv.c config.h mandoc_aux.h mandoc.h roff.h mdoc.h libmandoc.h roff_int.h libmdoc.h
-mdoc_html.o: mdoc_html.c config.h mandoc_aux.h roff.h mdoc.h out.h html.h main.h
+mdoc_html.o: mdoc_html.c config.h mandoc_aux.h mandoc.h roff.h mdoc.h out.h html.h main.h
mdoc_macro.o: mdoc_macro.c config.h mandoc.h roff.h mdoc.h libmandoc.h roff_int.h libmdoc.h
mdoc_man.o: mdoc_man.c config.h mandoc_aux.h mandoc.h roff.h mdoc.h man.h out.h main.h
mdoc_markdown.o: mdoc_markdown.c mandoc_aux.h mandoc.h roff.h mdoc.h main.h
@@ -61,7 +61,7 @@ out.o: out.c config.h mandoc_aux.h tbl.h out.h
preconv.o: preconv.c config.h mandoc.h roff.h mandoc_parse.h libmandoc.h
read.o: read.c config.h mandoc_aux.h mandoc.h roff.h mdoc.h man.h mandoc_parse.h libmandoc.h roff_int.h
roff.o: roff.c config.h mandoc_aux.h mandoc_ohash.h compat_ohash.h mandoc.h roff.h mandoc_parse.h libmandoc.h roff_int.h tbl_parse.h eqn_parse.h predefs.in
-roff_html.o: roff_html.c roff.h out.h html.h
+roff_html.o: roff_html.c mandoc.h roff.h out.h html.h
roff_term.o: roff_term.c mandoc.h roff.h out.h term.h
roff_validate.o: roff_validate.c mandoc.h roff.h libmandoc.h roff_int.h
soelim.o: soelim.c config.h compat_stringlist.h
@@ -69,7 +69,7 @@ st.o: st.c config.h mandoc.h roff.h libmdoc.h
tag.o: tag.c config.h mandoc_aux.h mandoc_ohash.h compat_ohash.h tag.h
tbl.o: tbl.c config.h mandoc_aux.h mandoc.h tbl.h libmandoc.h tbl_parse.h tbl_int.h
tbl_data.o: tbl_data.c config.h mandoc_aux.h mandoc.h tbl.h libmandoc.h tbl_int.h
-tbl_html.o: tbl_html.c config.h tbl.h out.h html.h
+tbl_html.o: tbl_html.c config.h mandoc.h tbl.h out.h html.h
tbl_layout.o: tbl_layout.c config.h mandoc_aux.h mandoc.h tbl.h libmandoc.h tbl_int.h
tbl_opts.o: tbl_opts.c config.h mandoc.h tbl.h libmandoc.h tbl_int.h
tbl_term.o: tbl_term.c config.h mandoc.h tbl.h out.h term.h
diff --git a/html.c b/html.c
index 010eac68..4d4dacf3 100644
--- a/html.c
+++ b/html.c
@@ -117,7 +117,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 *
@@ -210,7 +209,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;
@@ -236,7 +235,7 @@ print_metaf(struct html *h, enum mandoc_esc deco)
font = HTMLFONT_NONE;
break;
default:
- abort();
+ return;
}
if (h->metaf) {
diff --git a/html.h b/html.h
index ed9a988c..561308bb 100644
--- a/html.h
+++ b/html.h
@@ -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/man_html.c b/man_html.c
index 6221e7ce..0f193362 100644
--- a/man_html.c
+++ b/man_html.c
@@ -26,6 +26,7 @@
#include <string.h>
#include "mandoc_aux.h"
+#include "mandoc.h"
#include "roff.h"
#include "man.h"
#include "out.h"
diff --git a/mandoc.c b/mandoc.c
index aec05f73..94a58e3f 100644
--- a/mandoc.c
+++ b/mandoc.c
@@ -38,6 +38,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;
@@ -367,47 +420,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/mandoc.h b/mandoc.h
index 657e5c5c..a9d460eb 100644
--- a/mandoc.h
+++ b/mandoc.h
@@ -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/mandoc_headers.3 b/mandoc_headers.3
index 18612685..9fb1b1e1 100644
--- a/mandoc_headers.3
+++ b/mandoc_headers.3
@@ -556,7 +556,10 @@ or
Requires
.In sys/types.h
for
-.Vt size_t
+.Vt size_t ,
+.Pa mandoc.h
+for
+.Vt enum mandoc_esc ,
and
.Qq Pa out.h
for
diff --git a/mdoc_html.c b/mdoc_html.c
index d7678cec..4b9c7eb0 100644
--- a/mdoc_html.c
+++ b/mdoc_html.c
@@ -27,6 +27,7 @@
#include <unistd.h>
#include "mandoc_aux.h"
+#include "mandoc.h"
#include "roff.h"
#include "mdoc.h"
#include "out.h"
diff --git a/regress/regress.pl b/regress/regress.pl
index 8c62a147..b9fb849b 100755
--- a/regress/regress.pl
+++ b/regress/regress.pl
@@ -79,23 +79,25 @@ sub syshtml ($@) {
open my $outfd, '>', $outfile or die "$outfile: $!";
my $infd;
my $pid = open3 undef, $infd, undef, @_;
- my $state;
+ my $state = 0;
while (<$infd>) {
chomp;
if (!$state && s/.*<math class="eqn">//) {
- $state = 1;
+ $state = 'math';
next unless length;
+ } elsif (/^BEGINTEST/) {
+ $state = 'other';
}
- $state = 1 if /^BEGINTEST/;
- if ($state && s/<\/math>.*//) {
+ if ($state eq 'math') {
s/^ *//;
- print $outfd "$_\n" if length;
- undef $state;
- next;
+ if (s/<\/math>.*//) {
+ print $outfd "$_\n" if length;
+ $state = 0;
+ next;
+ }
}
- s/^ *//;
print $outfd "$_\n" if $state;
- undef $state if /^ENDTEST/;
+ $state = 0 if /^ENDTEST/;
}
close $outfd;
close $infd;
diff --git a/regress/roff/esc/Makefile b/regress/roff/esc/Makefile
index 74f153d5..1be8b179 100644
--- a/regress/roff/esc/Makefile
+++ b/regress/roff/esc/Makefile
@@ -1,7 +1,8 @@
-# $OpenBSD: Makefile,v 1.11 2015/04/29 18:32:57 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/roff/esc/f.in b/regress/roff/esc/f.in
index 7d8f9ec0..3eaca449 100644
--- a/regress/roff/esc/f.in
+++ b/regress/roff/esc/f.in
@@ -1,13 +1,12 @@
-.\" $OpenBSD: f.in,v 1.3 2017/07/04 14:53:27 schwarze Exp $
-.Dd $Mdocdate$
-.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/roff/esc/f.out_ascii b/regress/roff/esc/f.out_ascii
index fb8520f8..797dbe86 100644
--- a/regress/roff/esc/f.out_ascii
+++ b/regress/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/roff/esc/f.out_html b/regress/roff/esc/f.out_html
new file mode 100644
index 00000000..332e0f00
--- /dev/null
+++ b/regress/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/roff/ft/Makefile b/regress/roff/ft/Makefile
index 5d2accbb..0eadb05d 100644
--- a/regress/roff/ft/Makefile
+++ b/regress/roff/ft/Makefile
@@ -1,6 +1,7 @@
-# $OpenBSD: Makefile,v 1.1 2014/07/05 12:33:54 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/roff/ft/badargs.in b/regress/roff/ft/badargs.in
index 82269609..ac3ee72a 100644
--- a/regress/roff/ft/badargs.in
+++ b/regress/roff/ft/badargs.in
@@ -1,9 +1,23 @@
-.\" $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.5 2018/12/16 00:10:03 schwarze Exp $
+.TH "FT-BADARGS" 1 "December 15, 2018"
.SH NAME
ft-badargs \(en font request with bad arguments
.SH DESCRIPTION
+BEGINTEST
+.br
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 +28,6 @@ italic
back to bold
.ft
back to italic
+.ft R
+.br
+ENDTEST
diff --git a/regress/roff/ft/badargs.out_ascii b/regress/roff/ft/badargs.out_ascii
index 30bfed3c..07c2392a 100644
--- a/regress/roff/ft/badargs.out_ascii
+++ b/regress/roff/ft/badargs.out_ascii
@@ -6,8 +6,11 @@ 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/roff/ft/badargs.out_html b/regress/roff/ft/badargs.out_html
new file mode 100644
index 00000000..8b30ab05
--- /dev/null
+++ b/regress/roff/ft/badargs.out_html
@@ -0,0 +1,9 @@
+BEGINTEST
+<br/>
+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>
+<br/>
+ENDTEST</div>
diff --git a/regress/roff/ft/badargs.out_lint b/regress/roff/ft/badargs.out_lint
index 36c8c0bf..493aaeb4 100644
--- a/regress/roff/ft/badargs.out_lint
+++ b/regress/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:25:7: ERROR: skipping excess arguments: ft ... bogus
+mandoc: badargs.in:23:2: WARNING: unknown font, skipping request: ft foo
diff --git a/roff.7 b/roff.7
index 66b7da90..5dfc0bb3 100644
--- a/roff.7
+++ b/roff.7
@@ -132,20 +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.
-The indicator or numerical representative may be preceded by C
-(constant-width), which is ignored.
-.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
@@ -156,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.
@@ -890,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.
@@ -2006,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/roff_html.c b/roff_html.c
index ea123561..fc0f2e30 100644
--- a/roff_html.c
+++ b/roff_html.c
@@ -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/roff_term.c b/roff_term.c
index eb566abe..d0acc4f0 100644
--- a/roff_term.c
+++ b/roff_term.c
@@ -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/roff_validate.c b/roff_validate.c
index ee14188b..0aaace13 100644
--- a/roff_validate.c
+++ b/roff_validate.c
@@ -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/tbl_html.c b/tbl_html.c
index dd0778f0..52e20886 100644
--- a/tbl_html.c
+++ b/tbl_html.c
@@ -24,6 +24,7 @@
#include <stdlib.h>
#include <string.h>
+#include "mandoc.h"
#include "tbl.h"
#include "out.h"
#include "html.h"