tech@mandoc.bsd.lv
 help / color / mirror / Atom feed
From: Ingo Schwarze <schwarze@usta.de>
To: nabijaczleweli@nabijaczleweli.xyz
Cc: tech@mandoc.bsd.lv, 992002@bugs.debian.org
Subject: Re: [PATCH][Debian#992002] tbl: allow two-character fonts and format fonts in -Thtml
Date: Mon, 9 Aug 2021 10:58:19 +0200	[thread overview]
Message-ID: <20210809085819.GA81032@athene.usta.de> (raw)
In-Reply-To: <20210808132452.bekkztprjqoup3pa@tarta.nabijaczleweli.xyz>

Hello Nab,

Nab wrote on Sun, Aug 08, 2021 at 03:24:53PM +0200:

> tbl's -Thtml ignores font requests;

Not in CVS HEAD; see https://cvsweb.bsd.lv/mandoc/tbl_html.c revision 1.34,
committed on May 16 earlier this year.

> additionally, the tbl f-request
> parser only allows single-character fonts.

Yes, that is still a missing feature.

> Cf. the Debian bug
> (http://bugs.debian.org/992002) for additional context.
> 
> Please consider the following patch.

Thank you very much for sending quite a non-trivial patch.
That was very helpful in understanding what exactly is needed.

I started from your patch and changed a few aspects:

 * You couldn't possibly know that i'm trying to work towards a
   unified system for identifying fonts using the mandoc.h
   enum mandoc_esc ESCAPE_FONT* identifiers.  Having different
   font identifiers for each output module is not good.
   So i added ESCAPE_FONTCB and ESCAPE_FONTCI and used those.
   A nice side effect is that CB and CI now work in HTML
   for all of \f, .ft, and tbl(7) f and that tbl(7) fBI
   now also works for terminal output.
 * GNU tbl(1) appears to ignore space characters between the f
   modifier and the font name, so "lf   B" is the same as "lfB".

> With this patch, the following document:
> -- >8 --
> .Dd
> .Dt V 1
> .Os
> .
> \fBtext\fItext\f(BItext\f(CRtext\f(CBtext\f(CItext\fR
> .Pp
> .TS
> lfB lfI lfBI lb li lbi lfCR lfCB lfCI .
> text	text	text	text	text	text	text	text	text
> .TE
> -- >8 --
> 
> Renders to a teletype with the expected fonts:
>   b, ul, bul;  b, ul, bul;  normal, b, ul

Not quite.  The expected output for lbi is ul, not bul.
The i overrides the b rather than add to it.
So lbi is the same as lfI, not as lfBI.

> -Thtml -Ofragment yields, as expected:
> -- >8 --
[...]
> <table class="tbl">
>   <tr>
>     <td><b>text</b></td>
>     <td><i>text</i></td>
>     <td><b><i>text</i></b></td>
>     <td><b>text</b></td>
>     <td><i>text</i></td>
>     <td><b><i>text</i></b></td>

Again, <td><i>text</i></td> with my version of the patch.

>     <td><span class="Li">text</span></td>
>     <td><b>text</b></td>
>     <td><i>text</i></td>

These become:

      <td><span class="Li"><b>text</b></span></td>
      <td><span class="Li"><i>text</i></span></td>

Could you please check out from CVS (instead of the last release),
apply the following patch, and tell me whether it looks reasonable
and works for you?

When this gets committed, i will credit you for reporting the
missing feature.  Do i understand correctly that "Nabija" is your
first name and "Czleweli" your last name?

Thanks again,
  Ingo

-- 
Ingo Schwarze             <schwarze@usta.de>
http://www.openbsd.org/   <schwarze@openbsd.org>
http://mandoc.bsd.lv/     <schwarze@mandoc.bsd.lv>


Index: html.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/html.c,v
retrieving revision 1.273
diff -u -p -r1.273 html.c
--- html.c	2 Jun 2021 17:51:38 -0000	1.273
+++ html.c	9 Aug 2021 07:50:02 -0000
@@ -1,7 +1,7 @@
 /* $Id: html.c,v 1.273 2021/06/02 17:51:38 schwarze Exp $ */
 /*
- * Copyright (c) 2011-2015, 2017-2020 Ingo Schwarze <schwarze@openbsd.org>
  * Copyright (c) 2008-2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
+ * Copyright (c) 2011-2015, 2017-2021 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
@@ -240,8 +240,10 @@ html_setfont(struct html *h, enum mandoc
 	case ESCAPE_FONTITALIC:
 	case ESCAPE_FONTBOLD:
 	case ESCAPE_FONTBI:
-	case ESCAPE_FONTCW:
 	case ESCAPE_FONTROMAN:
+	case ESCAPE_FONTCR:
+	case ESCAPE_FONTCB:
+	case ESCAPE_FONTCI:
 		break;
 	case ESCAPE_FONT:
 		font = ESCAPE_FONTROMAN;
@@ -272,9 +274,17 @@ print_metaf(struct html *h)
 		h->metaf = print_otag(h, TAG_B, "");
 		print_otag(h, TAG_I, "");
 		break;
-	case ESCAPE_FONTCW:
+	case ESCAPE_FONTCR:
 		h->metaf = print_otag(h, TAG_SPAN, "c", "Li");
 		break;
+	case ESCAPE_FONTCB:
+		h->metaf = print_otag(h, TAG_SPAN, "c", "Li");
+		print_otag(h, TAG_B, "");
+		break;
+	case ESCAPE_FONTCI:
+		h->metaf = print_otag(h, TAG_SPAN, "c", "Li");
+		print_otag(h, TAG_I, "");
+		break;
 	default:
 		break;
 	}
@@ -503,8 +513,10 @@ print_encode(struct html *h, const char 
 		case ESCAPE_FONTBOLD:
 		case ESCAPE_FONTITALIC:
 		case ESCAPE_FONTBI:
-		case ESCAPE_FONTCW:
 		case ESCAPE_FONTROMAN:
+		case ESCAPE_FONTCR:
+		case ESCAPE_FONTCB:
+		case ESCAPE_FONTCI:
 			if (0 == norecurse) {
 				h->flags |= HTML_NOSPACE;
 				if (html_setfont(h, esc))
Index: man_validate.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/man_validate.c,v
retrieving revision 1.155
diff -u -p -r1.155 man_validate.c
--- man_validate.c	30 Oct 2020 13:24:33 -0000	1.155
+++ man_validate.c	9 Aug 2021 07:50:02 -0000
@@ -239,7 +239,9 @@ check_tag(struct roff_node *n, struct ro
 			case ESCAPE_FONTITALIC:
 			case ESCAPE_FONTBI:
 			case ESCAPE_FONTROMAN:
-			case ESCAPE_FONTCW:
+			case ESCAPE_FONTCR:
+			case ESCAPE_FONTCB:
+			case ESCAPE_FONTCI:
 			case ESCAPE_FONTPREV:
 			case ESCAPE_IGNORE:
 				break;
Index: mandoc.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/mandoc.c,v
retrieving revision 1.118
diff -u -p -r1.118 mandoc.c
--- mandoc.c	24 Oct 2020 22:57:39 -0000	1.118
+++ mandoc.c	9 Aug 2021 07:50:02 -0000
@@ -1,7 +1,7 @@
 /*	$Id: mandoc.c,v 1.118 2020/10/24 22:57:39 schwarze Exp $ */
 /*
  * Copyright (c) 2008-2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
- * Copyright (c) 2011-2015, 2017-2020 Ingo Schwarze <schwarze@openbsd.org>
+ * Copyright (c) 2011-2015, 2017-2021 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
@@ -74,12 +74,12 @@ mandoc_font(const char *cp, int sz)
 		case 'C':
 			switch (cp[1]) {
 			case 'B':
-				return ESCAPE_FONTBOLD;
+				return ESCAPE_FONTCB;
 			case 'I':
-				return ESCAPE_FONTITALIC;
+				return ESCAPE_FONTCI;
 			case 'R':
 			case 'W':
-				return ESCAPE_FONTCW;
+				return ESCAPE_FONTCR;
 			default:
 				return ESCAPE_ERROR;
 			}
Index: mandoc.h
===================================================================
RCS file: /home/cvs/mandoc/mandoc/mandoc.h,v
retrieving revision 1.272
diff -u -p -r1.272 mandoc.h
--- mandoc.h	4 Jul 2021 15:38:26 -0000	1.272
+++ mandoc.h	9 Aug 2021 07:50:02 -0000
@@ -291,7 +291,9 @@ enum	mandoc_esc {
 	ESCAPE_FONTITALIC, /* italic font mode */
 	ESCAPE_FONTBI, /* bold italic font mode */
 	ESCAPE_FONTROMAN, /* roman font mode */
-	ESCAPE_FONTCW, /* constant width font mode */
+	ESCAPE_FONTCR, /* constant width font mode */
+	ESCAPE_FONTCB, /* constant width bold font mode */
+	ESCAPE_FONTCI, /* constant width italic font mode */
 	ESCAPE_FONTPREV, /* previous font mode */
 	ESCAPE_NUMBERED, /* a numbered glyph */
 	ESCAPE_UNICODE, /* a unicode codepoint */
Index: mandoc_headers.3
===================================================================
RCS file: /home/cvs/mandoc/mandoc/mandoc_headers.3,v
retrieving revision 1.33
diff -u -p -r1.33 mandoc_headers.3
--- mandoc_headers.3	13 Mar 2020 15:32:28 -0000	1.33
+++ mandoc_headers.3	9 Aug 2021 07:50:02 -0000
@@ -1,6 +1,6 @@
 .\"	$Id: mandoc_headers.3,v 1.33 2020/03/13 15:32:28 schwarze Exp $
 .\"
-.\" Copyright (c) 2014-2020 Ingo Schwarze <schwarze@openbsd.org>
+.\" Copyright (c) 2014-2021 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
@@ -167,7 +167,11 @@ parse tree; can be used everywhere.
 Requires
 .In sys/types.h
 for
-.Vt size_t .
+.Vt size_t
+and
+.Qq Pa mandoc.h
+for
+.Vt enum mandoc_esc .
 .Pp
 Provides
 .Vt enum tbl_cellt ,
Index: mdoc_markdown.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/mdoc_markdown.c,v
retrieving revision 1.36
diff -u -p -r1.36 mdoc_markdown.c
--- mdoc_markdown.c	22 Jun 2020 19:20:40 -0000	1.36
+++ mdoc_markdown.c	9 Aug 2021 07:50:02 -0000
@@ -603,16 +603,18 @@ md_word(const char *s)
 				md_rawword("markdown");
 				continue;
 			case ESCAPE_FONTBOLD:
+			case ESCAPE_FONTCB:
 				nextfont = "**";
 				break;
 			case ESCAPE_FONTITALIC:
+			case ESCAPE_FONTCI:
 				nextfont = "*";
 				break;
 			case ESCAPE_FONTBI:
 				nextfont = "***";
 				break;
 			case ESCAPE_FONT:
-			case ESCAPE_FONTCW:
+			case ESCAPE_FONTCR:
 			case ESCAPE_FONTROMAN:
 				nextfont = "";
 				break;
Index: out.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/out.c,v
retrieving revision 1.79
diff -u -p -r1.79 out.c
--- out.c	31 Dec 2019 22:58:41 -0000	1.79
+++ out.c	9 Aug 2021 07:50:02 -0000
@@ -22,11 +22,13 @@
 #include <assert.h>
 #include <ctype.h>
 #include <stdint.h>
+#include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <time.h>
 
 #include "mandoc_aux.h"
+#include "mandoc.h"
 #include "tbl.h"
 #include "out.h"
 
Index: roff.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/roff.c,v
retrieving revision 1.377
diff -u -p -r1.377 roff.c
--- roff.c	27 Jun 2021 17:57:55 -0000	1.377
+++ roff.c	9 Aug 2021 07:50:03 -0000
@@ -3667,7 +3667,9 @@ roff_char(ROFF_ARGS)
 		case ESCAPE_FONTITALIC:
 		case ESCAPE_FONTBOLD:
 		case ESCAPE_FONTBI:
-		case ESCAPE_FONTCW:
+		case ESCAPE_FONTCR:
+		case ESCAPE_FONTCB:
+		case ESCAPE_FONTCI:
 		case ESCAPE_FONTPREV:
 			font++;
 			break;
Index: roff_term.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/roff_term.c,v
retrieving revision 1.22
diff -u -p -r1.22 roff_term.c
--- roff_term.c	3 Sep 2020 20:43:15 -0000	1.22
+++ roff_term.c	9 Aug 2021 07:50:03 -0000
@@ -112,9 +112,11 @@ roff_term_pre_ft(ROFF_TERM_ARGS)
 	cp = n->child->string;
 	switch (mandoc_font(cp, (int)strlen(cp))) {
 	case ESCAPE_FONTBOLD:
+	case ESCAPE_FONTCB:
 		term_fontrepl(p, TERMFONT_BOLD);
 		break;
 	case ESCAPE_FONTITALIC:
+	case ESCAPE_FONTCI:
 		term_fontrepl(p, TERMFONT_UNDER);
 		break;
 	case ESCAPE_FONTBI:
@@ -124,7 +126,7 @@ roff_term_pre_ft(ROFF_TERM_ARGS)
 		term_fontlast(p);
 		break;
 	case ESCAPE_FONTROMAN:
-	case ESCAPE_FONTCW:
+	case ESCAPE_FONTCR:
 		term_fontrepl(p, TERMFONT_NONE);
 		break;
 	default:
Index: tbl.7
===================================================================
RCS file: /home/cvs/mandoc/mandoc/tbl.7,v
retrieving revision 1.34
diff -u -p -r1.34 tbl.7
--- tbl.7	2 Mar 2019 21:03:02 -0000	1.34
+++ tbl.7	9 Aug 2021 07:50:03 -0000
@@ -178,10 +178,11 @@ of any other column also having the
 .Cm e
 modifier.
 .It Cm f
-The next character selects the font to use for this cell.
+The next one or two characters select the font to use for this cell.
+One-character font names must be followed by a blank or period.
 See the
 .Xr roff 7
-manual for supported one-character font names.
+manual for supported font names.
 .It Cm i
 Use an italic font for the contents of this cell.
 .It Cm m
Index: tbl.h
===================================================================
RCS file: /home/cvs/mandoc/mandoc/tbl.h,v
retrieving revision 1.1
diff -u -p -r1.1 tbl.h
--- tbl.h	12 Dec 2018 21:54:35 -0000	1.1
+++ tbl.h	9 Aug 2021 07:50:03 -0000
@@ -1,7 +1,7 @@
 /*	$Id: tbl.h,v 1.1 2018/12/12 21:54:35 schwarze Exp $ */
 /*
  * Copyright (c) 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
- * Copyright (c) 2014, 2015, 2017, 2018 Ingo Schwarze <schwarze@openbsd.org>
+ * Copyright (c) 2014,2015,2017,2018,2021 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
@@ -57,14 +57,13 @@ struct	tbl_cell {
 	int		  vert;     /* Width of subsequent vertical line. */
 	int		  col;      /* Column number, starting from 0. */
 	int		  flags;
-#define	TBL_CELL_BOLD	 (1 << 0)   /* b, B, fB */
-#define	TBL_CELL_ITALIC	 (1 << 1)   /* i, I, fI */
 #define	TBL_CELL_TALIGN	 (1 << 2)   /* t, T */
 #define	TBL_CELL_UP	 (1 << 3)   /* u, U */
 #define	TBL_CELL_BALIGN	 (1 << 4)   /* d, D */
 #define	TBL_CELL_WIGN	 (1 << 5)   /* z, Z */
 #define	TBL_CELL_EQUAL	 (1 << 6)   /* e, E */
 #define	TBL_CELL_WMAX	 (1 << 7)   /* x, X */
+	enum mandoc_esc	  font;
 	enum tbl_cellt	  pos;
 };
 
Index: tbl_data.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/tbl_data.c,v
retrieving revision 1.55
diff -u -p -r1.55 tbl_data.c
--- tbl_data.c	18 May 2021 13:22:43 -0000	1.55
+++ tbl_data.c	9 Aug 2021 07:50:03 -0000
@@ -78,6 +78,7 @@ getdata(struct tbl_node *tbl, struct tbl
 		if (dp->layout->last->col + 1 < dp->opts->cols) {
 			cp = mandoc_calloc(1, sizeof(*cp));
 			cp->pos = TBL_CELL_LEFT;
+			cp->font = ESCAPE_FONTROMAN;
 			cp->spacing = SIZE_MAX;
 			dp->layout->last->next = cp;
 			cp->col = dp->layout->last->col + 1;
Index: tbl_html.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/tbl_html.c,v
retrieving revision 1.35
diff -u -p -r1.35 tbl_html.c
--- tbl_html.c	16 May 2021 23:18:35 -0000	1.35
+++ tbl_html.c	9 Aug 2021 07:50:03 -0000
@@ -243,10 +243,7 @@ print_tbl(struct html *h, const struct t
 		    "border-right-style", rborder);
 		if (dp->string != NULL) {
 			save_font = h->metac;
-			if (dp->layout->flags & TBL_CELL_BOLD)
-				html_setfont(h, ESCAPE_FONTBOLD);
-			else if (dp->layout->flags & TBL_CELL_ITALIC)
-				html_setfont(h, ESCAPE_FONTITALIC);
+			html_setfont(h, dp->layout->font);
 			if (dp->layout->pos == TBL_CELL_LONG)
 				print_text(h, "\\[u2003]");  /* em space */
 			print_text(h, dp->string);
Index: tbl_layout.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/tbl_layout.c,v
retrieving revision 1.49
diff -u -p -r1.49 tbl_layout.c
--- tbl_layout.c	1 Sep 2020 18:25:28 -0000	1.49
+++ tbl_layout.c	9 Aug 2021 07:50:03 -0000
@@ -1,7 +1,8 @@
 /*	$Id: tbl_layout.c,v 1.49 2020/09/01 18:25:28 schwarze Exp $ */
 /*
  * Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
- * Copyright (c) 2012, 2014, 2015, 2017 Ingo Schwarze <schwarze@openbsd.org>
+ * Copyright (c) 2012, 2014, 2015, 2017, 2020, 2021
+ *               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
@@ -67,6 +68,8 @@ mods(struct tbl_node *tbl, struct tbl_ce
 	char		*endptr;
 	unsigned long	 spacing;
 	size_t		 sz;
+	int		 isz;
+	enum mandoc_esc	 fontesc;
 
 mod:
 	while (p[*pos] == ' ' || p[*pos] == '\t')
@@ -105,7 +108,7 @@ mod:
 
 	switch (tolower((unsigned char)p[(*pos)++])) {
 	case 'b':
-		cp->flags |= TBL_CELL_BOLD;
+		cp->font = ESCAPE_FONTBOLD;
 		goto mod;
 	case 'd':
 		cp->flags |= TBL_CELL_BALIGN;
@@ -116,7 +119,7 @@ mod:
 	case 'f':
 		break;
 	case 'i':
-		cp->flags |= TBL_CELL_ITALIC;
+		cp->font = ESCAPE_FONTITALIC;
 		goto mod;
 	case 'm':
 		mandoc_msg(MANDOCERR_TBLLAYOUT_MOD, ln, *pos, "m");
@@ -170,40 +173,34 @@ mod:
 		goto mod;
 	}
 
+	while (p[*pos] == ' ')
+		(*pos)++;
+
 	/* Ignore parenthised font names for now. */
 
 	if (p[*pos] == '(')
 		goto mod;
 
-	/* Support only one-character font-names for now. */
-
-	if (p[*pos] == '\0' || (p[*pos + 1] != ' ' && p[*pos + 1] != '.')) {
+	isz = 0;
+	if (p[*pos] != '\0')
+		isz++;
+	if (strchr(" .", p[*pos + isz]) == NULL)
+		isz++;
+	
+	fontesc = mandoc_font(p + *pos, isz);
+
+	switch (fontesc) {
+	case ESCAPE_FONTPREV:
+	case ESCAPE_ERROR:
 		mandoc_msg(MANDOCERR_FT_BAD,
 		    ln, *pos, "TS %s", p + *pos - 1);
-		if (p[*pos] != '\0')
-			(*pos)++;
-		if (p[*pos] != '\0')
-			(*pos)++;
-		goto mod;
-	}
-
-	switch (p[(*pos)++]) {
-	case '3':
-	case 'B':
-		cp->flags |= TBL_CELL_BOLD;
-		goto mod;
-	case '2':
-	case 'I':
-		cp->flags |= TBL_CELL_ITALIC;
-		goto mod;
-	case '1':
-	case 'R':
-		goto mod;
+		break;
 	default:
-		mandoc_msg(MANDOCERR_FT_BAD,
-		    ln, *pos - 1, "TS f%c", p[*pos - 1]);
-		goto mod;
+		cp->font = fontesc;
+		break;
 	}
+	*pos += isz;
+	goto mod;
 }
 
 static void
@@ -362,6 +359,7 @@ cell_alloc(struct tbl_node *tbl, struct 
 
 	p = mandoc_calloc(1, sizeof(*p));
 	p->spacing = SIZE_MAX;
+	p->font = ESCAPE_FONTROMAN;
 	p->pos = pos;
 
 	if ((pp = rp->last) != NULL) {
Index: tbl_term.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/tbl_term.c,v
retrieving revision 1.74
diff -u -p -r1.74 tbl_term.c
--- tbl_term.c	25 Oct 2020 18:28:23 -0000	1.74
+++ tbl_term.c	9 Aug 2021 07:50:03 -0000
@@ -1,7 +1,7 @@
 /*	$Id: tbl_term.c,v 1.74 2020/10/25 18:28:23 schwarze Exp $ */
 /*
  * Copyright (c) 2009, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
- * Copyright (c) 2011-2020 Ingo Schwarze <schwarze@openbsd.org>
+ * Copyright (c) 2011-2021 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
@@ -923,10 +923,24 @@ tbl_word(struct termp *tp, const struct 
 	int		 prev_font;
 
 	prev_font = tp->fonti;
-	if (dp->layout->flags & TBL_CELL_BOLD)
-		term_fontpush(tp, TERMFONT_BOLD);
-	else if (dp->layout->flags & TBL_CELL_ITALIC)
-		term_fontpush(tp, TERMFONT_UNDER);
+	switch (dp->layout->font) {
+		case ESCAPE_FONTBI:
+			term_fontpush(tp, TERMFONT_BI);
+			break;
+		case ESCAPE_FONTBOLD:
+		case ESCAPE_FONTCB:
+			term_fontpush(tp, TERMFONT_BOLD);
+			break;
+		case ESCAPE_FONTITALIC:
+		case ESCAPE_FONTCI:
+			term_fontpush(tp, TERMFONT_UNDER);
+			break;
+		case ESCAPE_FONTROMAN:
+		case ESCAPE_FONTCR:
+			break;
+		default:
+			abort();
+	}
 
 	term_word(tp, dp->string);
 
Index: term.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/term.c,v
retrieving revision 1.282
diff -u -p -r1.282 term.c
--- term.c	2 Sep 2020 16:40:36 -0000	1.282
+++ term.c	9 Aug 2021 07:50:03 -0000
@@ -589,16 +589,18 @@ term_word(struct termp *p, const char *w
 			uc = *seq;
 			break;
 		case ESCAPE_FONTBOLD:
+		case ESCAPE_FONTCB:
 			term_fontrepl(p, TERMFONT_BOLD);
 			continue;
 		case ESCAPE_FONTITALIC:
+		case ESCAPE_FONTCI:
 			term_fontrepl(p, TERMFONT_UNDER);
 			continue;
 		case ESCAPE_FONTBI:
 			term_fontrepl(p, TERMFONT_BI);
 			continue;
 		case ESCAPE_FONT:
-		case ESCAPE_FONTCW:
+		case ESCAPE_FONTCR:
 		case ESCAPE_FONTROMAN:
 			term_fontrepl(p, TERMFONT_NONE);
 			continue;
Index: tree.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/tree.c,v
retrieving revision 1.89
diff -u -p -r1.89 tree.c
--- tree.c	8 Apr 2020 11:56:04 -0000	1.89
+++ tree.c	9 Aug 2021 07:50:03 -0000
@@ -1,7 +1,7 @@
 /* $Id: tree.c,v 1.89 2020/04/08 11:56:04 schwarze Exp $ */
 /*
- * Copyright (c) 2013-2015, 2017-2020 Ingo Schwarze <schwarze@openbsd.org>
  * Copyright (c) 2008, 2009, 2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
+ * Copyright (c) 2013-2015, 2017-2021 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
@@ -471,10 +471,28 @@ print_span(const struct tbl_span *sp, in
 			else {
 				printf("%d", cp->col);
 				print_cellt(dp->layout->pos);
-				if (cp->flags & TBL_CELL_BOLD)
+				switch (cp->font) {
+				case ESCAPE_FONTBOLD:
 					putchar('b');
-				if (cp->flags & TBL_CELL_ITALIC)
+					break;
+				case ESCAPE_FONTITALIC:
 					putchar('i');
+					break;
+				case ESCAPE_FONTBI:
+					fputs("bi", stdout);
+					break;
+				case ESCAPE_FONTCR:
+					putchar('c');
+					break;
+				case ESCAPE_FONTCB:
+					fputs("cb", stdout);
+					break;
+				case ESCAPE_FONTCI:
+					fputs("ci", stdout);
+					break;
+				default:
+					abort();
+				}
 				if (cp->flags & TBL_CELL_TALIGN)
 					putchar('t');
 				if (cp->flags & TBL_CELL_UP)
Index: regress/roff/esc/f.out_html
===================================================================
RCS file: /home/cvs/mandoc/mandoc/regress/roff/esc/f.out_html,v
retrieving revision 1.2
diff -u -p -r1.2 f.out_html
--- regress/roff/esc/f.out_html	3 Sep 2019 18:19:51 -0000	1.2
+++ regress/roff/esc/f.out_html	9 Aug 2021 07:50:04 -0000
@@ -1,4 +1,4 @@
 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
+typewriter: <span class="Li">roman</span><span class="Li"><b>bold</b></span><span class="Li">roman</span><span class="Li"><i>italic</i></span>roman
Index: regress/roff/ft/badargs.out_html
===================================================================
RCS file: /home/cvs/mandoc/mandoc/regress/roff/ft/badargs.out_html,v
retrieving revision 1.4
diff -u -p -r1.4 badargs.out_html
--- regress/roff/ft/badargs.out_html	3 Sep 2019 18:19:52 -0000	1.4
+++ regress/roff/ft/badargs.out_html	9 Aug 2021 07:50:04 -0000
@@ -1,6 +1,7 @@
   <br/>
   default font <i>italic</i> <b><i>bold italic</i></b>
-    <span class="Li">typeqriter</span> <span class="Li">roman</span> <b>bold</b>
-    <i>italic</i> <b>bold</b> <b>still bold</b> <i>italic</i> <i>back to
-    bold</i> <i>back to italic</i>
+    <span class="Li">typeqriter</span> <span class="Li">roman</span>
+    <span class="Li"><b>bold</b></span> <span class="Li"><i>italic</i></span>
+    <b>bold</b> <b>still bold</b> <i>italic</i> <i>back to bold</i> <i>back to
+    italic</i>
   <br/>
Index: regress/tbl/mod/Makefile
===================================================================
RCS file: /home/cvs/mandoc/mandoc/regress/tbl/mod/Makefile,v
retrieving revision 1.4
diff -u -p -r1.4 Makefile
--- regress/tbl/mod/Makefile	27 Jun 2017 19:51:48 -0000	1.4
+++ regress/tbl/mod/Makefile	9 Aug 2021 07:50:04 -0000
@@ -1,15 +1,16 @@
 # $OpenBSD: Makefile,v 1.2 2015/02/10 11:02:19 schwarze Exp $
 
-REGRESS_TARGETS	 = badfont expand expand-toowide font misalign spacing width
-LINT_TARGETS	 = badfont font
+REGRESS_TARGETS	 = badfont expand expand-toowide font font-eol
+REGRESS_TARGETS	+= misalign spacing width
+LINT_TARGETS	 = badfont font font-eol
 
-# groff-1.22.3 defects:
+# groff-1.22.4 defects:
 # - The "f" font modifier swallows a following newline character.
 # - When space is insufficient (on either side) for properly aligning
 #   a number, GNU tbl(1) moves the number too much to the right,
 #   overflowing the column, even if space would be sufficient without
 #   left padding.
 
-SKIP_GROFF	 = badfont misalign
+SKIP_GROFF	 = font-eol misalign
 
 .include <bsd.regress.mk>
Index: regress/tbl/mod/badfont.in
===================================================================
RCS file: /home/cvs/mandoc/mandoc/regress/tbl/mod/badfont.in,v
retrieving revision 1.2
diff -u -p -r1.2 badfont.in
--- regress/tbl/mod/badfont.in	4 Jul 2017 15:26:56 -0000	1.2
+++ regress/tbl/mod/badfont.in	9 Aug 2021 07:50:04 -0000
@@ -1,15 +1,17 @@
 .\" $OpenBSD: badfont.in,v 1.2 2017/07/04 14:53:27 schwarze Exp $
-.TH TBL-MOD-BADFONT 1 "February 10, 2015"
+.TH TBL-MOD-BADFONT 1 "August 9, 2021"
 .SH NAME
 tbl-mod-badfont \- invalid font modifiers in table layouts
 .SH DESCRIPTION
 normal text
 .TS
 box tab(:);
-lfB lf
+lfI lfX
+lfB lfIB
 lfI lf.
 lfB lfI.
-bold:none
-italic:none
+italic:one char
+bold:two chars
+italic:dot
 bold:italic
 .TE
Index: regress/tbl/mod/badfont.out_ascii
===================================================================
RCS file: /home/cvs/mandoc/mandoc/regress/tbl/mod/badfont.out_ascii,v
retrieving revision 1.2
diff -u -p -r1.2 badfont.out_ascii
--- regress/tbl/mod/badfont.out_ascii	28 Jun 2021 20:13:08 -0000	1.2
+++ regress/tbl/mod/badfont.out_ascii	9 Aug 2021 07:50:04 -0000
@@ -6,9 +6,10 @@ N\bNA\bAM\bME\bE
 D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN
        normal text
 
-       +----------------+
-       |b\bbo\bol\bld\bd     none   |
-       |_\bi_\bt_\ba_\bl_\bi_\bc   none   |
-       |b\bbo\bol\bld\bd     _\bi_\bt_\ba_\bl_\bi_\bc |
-       +----------------+
-OpenBSD                        February 10, 2015            TBL-MOD-BADFONT(1)
+       +-------------------+
+       |_\bi_\bt_\ba_\bl_\bi_\bc   one char  |
+       |b\bbo\bol\bld\bd     two chars |
+       |_\bi_\bt_\ba_\bl_\bi_\bc   dot       |
+       |b\bbo\bol\bld\bd     _\bi_\bt_\ba_\bl_\bi_\bc    |
+       +-------------------+
+OpenBSD                         August 9, 2021              TBL-MOD-BADFONT(1)
Index: regress/tbl/mod/badfont.out_lint
===================================================================
RCS file: /home/cvs/mandoc/mandoc/regress/tbl/mod/badfont.out_lint,v
retrieving revision 1.4
diff -u -p -r1.4 badfont.out_lint
--- regress/tbl/mod/badfont.out_lint	4 Jul 2017 15:26:56 -0000	1.4
+++ regress/tbl/mod/badfont.out_lint	9 Aug 2021 07:50:04 -0000
@@ -1,2 +1,3 @@
-mandoc: badfont.in:9:7: WARNING: unknown font, skipping request: TS f
-mandoc: badfont.in:10:7: WARNING: unknown font, skipping request: TS f.
+mandoc: badfont.in:9:7: WARNING: unknown font, skipping request: TS fX
+mandoc: badfont.in:10:7: WARNING: unknown font, skipping request: TS fIB
+mandoc: badfont.in:11:7: WARNING: unknown font, skipping request: TS f.
Index: regress/tbl/mod/font-eol.in
===================================================================
RCS file: regress/tbl/mod/font-eol.in
diff -N regress/tbl/mod/font-eol.in
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ regress/tbl/mod/font-eol.in	9 Aug 2021 07:50:04 -0000
@@ -0,0 +1,13 @@
+.\" $OpenBSD: badfont.in,v 1.2 2017/07/04 14:53:27 schwarze Exp $
+.TH TBL-MOD-FONT-EOL 1 "August 9, 2021"
+.SH NAME
+tbl-mod-font-eol \- font modifier at eol in table layout
+.SH DESCRIPTION
+normal text
+.TS
+box tab(:);
+lfB lf
+lfB lfI.
+bold:none
+bold:italic
+.TE
Index: regress/tbl/mod/font-eol.out_ascii
===================================================================
RCS file: regress/tbl/mod/font-eol.out_ascii
diff -N regress/tbl/mod/font-eol.out_ascii
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ regress/tbl/mod/font-eol.out_ascii	9 Aug 2021 07:50:04 -0000
@@ -0,0 +1,13 @@
+TBL-MOD-FONT-EOL(1)         General Commands Manual        TBL-MOD-FONT-EOL(1)
+
+N\bNA\bAM\bME\bE
+       tbl-mod-font-eol - font modifier at eol in table layout
+
+D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN
+       normal text
+
+       +--------------+
+       |b\bbo\bol\bld\bd   none   |
+       |b\bbo\bol\bld\bd   _\bi_\bt_\ba_\bl_\bi_\bc |
+       +--------------+
+OpenBSD                         August 9, 2021             TBL-MOD-FONT-EOL(1)
Index: regress/tbl/mod/font-eol.out_lint
===================================================================
RCS file: regress/tbl/mod/font-eol.out_lint
diff -N regress/tbl/mod/font-eol.out_lint
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ regress/tbl/mod/font-eol.out_lint	9 Aug 2021 07:50:04 -0000
@@ -0,0 +1 @@
+mandoc: font-eol.in:9:7: WARNING: unknown font, skipping request: TS f
Index: regress/tbl/mod/font.out_lint
===================================================================
RCS file: /home/cvs/mandoc/mandoc/regress/tbl/mod/font.out_lint,v
retrieving revision 1.5
diff -u -p -r1.5 font.out_lint
--- regress/tbl/mod/font.out_lint	4 Jul 2017 15:26:56 -0000	1.5
+++ regress/tbl/mod/font.out_lint	9 Aug 2021 07:50:04 -0000
@@ -1,4 +1,3 @@
-mandoc: font.in:9:6: WARNING: unknown font, skipping request: TS fCW|ci
 mandoc: font.in:19:2: WARNING: tab in filled text
 mandoc: font.in:19:4: WARNING: tab in filled text
 mandoc: font.in:19:6: WARNING: tab in filled text
--
 To unsubscribe send an email to tech+unsubscribe@mandoc.bsd.lv


  reply	other threads:[~2021-08-09  8:58 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20210808111135.zisbfzlqqdsq35om@tarta.nabijaczleweli.xyz>
     [not found] ` <handler.992002.B.162842110127724.ack@bugs.debian.org>
     [not found]   ` <20210808124919.hevbw4gv6pis72pq@tarta.nabijaczleweli.xyz>
     [not found]     ` <CANnVG6k_czNfH5qNt9N3oOFF+v2i0eNfF92GO5vVK1sad9TRTw@mail.gmail.com>
2021-08-08 13:24       ` наб
2021-08-09  8:58         ` Ingo Schwarze [this message]
2021-08-09 23:08           ` наб
2021-08-10 13:43             ` Ingo Schwarze

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210809085819.GA81032@athene.usta.de \
    --to=schwarze@usta.de \
    --cc=992002@bugs.debian.org \
    --cc=nabijaczleweli@nabijaczleweli.xyz \
    --cc=tech@mandoc.bsd.lv \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).