aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2018-12-16 00:17:02 +0000
committerIngo Schwarze <schwarze@openbsd.org>2018-12-16 00:17:02 +0000
commitfb7ea55796176565141285c5c6de1d3127655116 (patch)
tree63b21db96671f3ca27e3f0658ae34a5d8babc63d
parentd672f8cb82878baf3834e938c4c416f4493952cf (diff)
downloadmandoc-fb7ea55796176565141285c5c6de1d3127655116.tar.gz
mandoc-fb7ea55796176565141285c5c6de1d3127655116.tar.zst
mandoc-fb7ea55796176565141285c5c6de1d3127655116.zip
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. In regress.pl, only strip leading whitespace in math mode.
-rw-r--r--Makefile.depend8
-rw-r--r--html.c7
-rw-r--r--html.h3
-rw-r--r--man_html.c3
-rw-r--r--mandoc.c97
-rw-r--r--mandoc.h3
-rw-r--r--mandoc_headers.37
-rw-r--r--mdoc_html.c3
-rwxr-xr-xregress/regress.pl22
-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.7122
-rw-r--r--roff_html.c18
-rw-r--r--roff_term.c26
-rw-r--r--roff_validate.c28
-rw-r--r--tbl_html.c3
23 files changed, 266 insertions, 177 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 da381a47..11cec6e0 100644
--- a/html.c
+++ b/html.c
@@ -1,4 +1,4 @@
-/* $Id: html.c,v 1.246 2018/12/15 19:30:26 schwarze Exp $ */
+/* $Id: html.c,v 1.247 2018/12/16 00:17:02 schwarze Exp $ */
/*
* Copyright (c) 2008-2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011-2015, 2017, 2018 Ingo Schwarze <schwarze@openbsd.org>
@@ -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 477f50b4..baba4cc7 100644
--- a/html.h
+++ b/html.h
@@ -1,4 +1,4 @@
-/* $Id: html.h,v 1.95 2018/10/25 01:32:40 schwarze Exp $ */
+/* $Id: html.h,v 1.96 2018/12/16 00:17:02 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/man_html.c b/man_html.c
index 6bdae3e0..bd04b5bc 100644
--- a/man_html.c
+++ b/man_html.c
@@ -1,4 +1,4 @@
-/* $Id: man_html.c,v 1.159 2018/12/13 11:55:46 schwarze Exp $ */
+/* $Id: man_html.c,v 1.160 2018/12/16 00:17:02 schwarze Exp $ */
/*
* Copyright (c) 2008-2012, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2013,2014,2015,2017,2018 Ingo Schwarze <schwarze@openbsd.org>
@@ -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 50882ba0..02bcf954 100644
--- a/mandoc.c
+++ b/mandoc.c
@@ -1,4 +1,4 @@
-/* $Id: mandoc.c,v 1.111 2018/12/15 19:30:26 schwarze Exp $ */
+/* $Id: mandoc.c,v 1.112 2018/12/16 00:17:02 schwarze Exp $ */
/*
* Copyright (c) 2008-2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011-2015, 2017, 2018 Ingo Schwarze <schwarze@openbsd.org>
@@ -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 0519d041..a44b192e 100644
--- a/mandoc.h
+++ b/mandoc.h
@@ -1,4 +1,4 @@
-/* $Id: mandoc.h,v 1.261 2018/12/15 19:30:26 schwarze Exp $ */
+/* $Id: mandoc.h,v 1.262 2018/12/16 00:17:02 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/mandoc_headers.3 b/mandoc_headers.3
index e98f4174..e7138d73 100644
--- a/mandoc_headers.3
+++ b/mandoc_headers.3
@@ -1,4 +1,4 @@
-.Dd $Mdocdate: December 14 2018 $
+.Dd $Mdocdate: December 16 2018 $
.Dt MANDOC_HEADERS 3
.Os
.Sh NAME
@@ -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 b4138b2e..4a155260 100644
--- a/mdoc_html.c
+++ b/mdoc_html.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_html.c,v 1.317 2018/12/13 11:55:46 schwarze Exp $ */
+/* $Id: mdoc_html.c,v 1.318 2018/12/16 00:17:02 schwarze Exp $ */
/*
* Copyright (c) 2008-2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2014,2015,2016,2017,2018 Ingo Schwarze <schwarze@openbsd.org>
@@ -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 8d7245cb..9d8fcf58 100755
--- a/regress/regress.pl
+++ b/regress/regress.pl
@@ -1,6 +1,6 @@
#!/usr/bin/env perl
#
-# $Id: regress.pl,v 1.8 2017/07/18 18:47:06 schwarze Exp $
+# $Id: regress.pl,v 1.9 2018/12/16 00:17:04 schwarze Exp $
#
# Copyright (c) 2017 Ingo Schwarze <schwarze@openbsd.org>
#
@@ -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 571161d3..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: 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/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 7541c549..3ccf1093 100644
--- a/roff.7
+++ b/roff.7
@@ -1,4 +1,4 @@
-.\" $Id: roff.7,v 1.108 2018/12/15 19:30:26 schwarze Exp $
+.\" $Id: roff.7,v 1.109 2018/12/16 00:17:02 schwarze Exp $
.\"
.\" Copyright (c) 2010, 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
.\" Copyright (c) 2010-2018 Ingo Schwarze <schwarze@openbsd.org>
@@ -15,7 +15,7 @@
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: December 15 2018 $
+.Dd $Mdocdate: December 16 2018 $
.Dt ROFF 7
.Os
.Sh NAME
@@ -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 aec483e4..adcbbf5b 100644
--- a/roff_html.c
+++ b/roff_html.c
@@ -1,4 +1,4 @@
-/* $Id: roff_html.c,v 1.14 2018/12/13 11:55:47 schwarze Exp $ */
+/* $Id: roff_html.c,v 1.15 2018/12/16 00:17:02 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/roff_term.c b/roff_term.c
index 6d0da8b9..a98f88f9 100644
--- a/roff_term.c
+++ b/roff_term.c
@@ -1,4 +1,4 @@
-/* $Id: roff_term.c,v 1.16 2018/12/14 01:18:26 schwarze Exp $ */
+/* $Id: roff_term.c,v 1.17 2018/12/16 00:17:02 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/roff_validate.c b/roff_validate.c
index 5593dd8a..d4cf6f6b 100644
--- a/roff_validate.c
+++ b/roff_validate.c
@@ -1,4 +1,4 @@
-/* $Id: roff_validate.c,v 1.14 2018/12/14 05:18:03 schwarze Exp $ */
+/* $Id: roff_validate.c,v 1.15 2018/12/16 00:17:02 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/tbl_html.c b/tbl_html.c
index d516be9e..98c7b96c 100644
--- a/tbl_html.c
+++ b/tbl_html.c
@@ -1,4 +1,4 @@
-/* $Id: tbl_html.c,v 1.30 2018/12/12 21:54:35 schwarze Exp $ */
+/* $Id: tbl_html.c,v 1.31 2018/12/16 00:17:02 schwarze Exp $ */
/*
* Copyright (c) 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2014, 2015, 2017, 2018 Ingo Schwarze <schwarze@openbsd.org>
@@ -24,6 +24,7 @@
#include <stdlib.h>
#include <string.h>
+#include "mandoc.h"
#include "tbl.h"
#include "out.h"
#include "html.h"