Debian Bug report logs - #992002
mandoc: -Thtml: tbl font requests ignored

version graph

Package: mandoc; Maintainer for mandoc is Andrea Pappacoda <[email protected]>; Source for mandoc is src:mdocml (PTS, buildd, popcon).

Reported by: наб <[email protected]>

Date: Sun, 8 Aug 2021 11:15:02 UTC

Severity: normal

Tags: patch

Found in version 1.14.51

Full log


Message #24 received at [email protected] (full text, mbox, reply):

Received: (at 992002) by bugs.debian.org; 8 Aug 2021 13:24:55 +0000
From [email protected] Sun Aug 08 13:24:55 2021
X-Spam-Checker-Version: SpamAssassin 3.4.2-bugs.debian.org_2005_01_02
	(2018-09-13) on buxtehude.debian.org
X-Spam-Level: 
X-Spam-Status: No, score=-15.2 required=4.0 tests=BAYES_00,DKIM_SIGNED,
	DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FOURLA,FROM_SUSPICIOUS_NTLD,
	MURPHY_DRUGS_REL8,PDS_OTHER_BAD_TLD,PGPSIGNATURE,RDNS_NONE,
	SPF_HELO_NONE,SPF_PASS,TXREP,WORD_WITHOUT_VOWELS autolearn=ham
	autolearn_force=no version=3.4.2-bugs.debian.org_2005_01_02
X-Spam-Bayes: score:0.0000 Tokens: new, 18; hammy, 150; neutral, 221; spammy,
	0. spammytokens: hammytokens:0.000-+--H*UA:NeoMutt,
	0.000-+--H*u:NeoMutt, 0.000-+--H*ct:application,
	0.000-+--H*ct:protocol, 0.000-+--H*ct:micalg
Return-path: <[email protected]>
Received: from [139.28.40.42] (port=49528 helo=tarta.nabijaczleweli.xyz)
	by buxtehude.debian.org with esmtp (Exim 4.92)
	(envelope-from <[email protected]>)
	id 1mCinP-0002r9-EQ
	for [email protected]; Sun, 08 Aug 2021 13:24:55 +0000
Received: from tarta.nabijaczleweli.xyz (unknown [192.168.1.250])
	by tarta.nabijaczleweli.xyz (Postfix) with ESMTPSA id 453C7360ED6;
	Sun,  8 Aug 2021 15:24:53 +0200 (CEST)
DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=nabijaczleweli.xyz;
	s=202006; t=1628429093;
	bh=dX8mEg/lFjE/A6s/m3zlyBmOdyQlicGSaL/fNGJMVpQ=;
	h=Date:From:To:Cc:Subject:References:In-Reply-To:From;
	b=op2oRU1gxKWcclvDg0hT6noPR/Bo1EOf5xYcg8iN9Kak5BD/n3NbuuHRm/Rf4U819
	 n/dJigYt7V9f2amb/7RXmMqgRhYs4mIj0mF1s8a8mRx9p49RbIvnEhADcUyGhmMz1w
	 aZY+LwDkGDubV9F1y0/NJcjRkYGoq+73PkxUjqh+5AnUO/VBkcQA0wEyoh5fIxPm8F
	 07Hmpzh+Km86uSFYRjwqCZDwDQ3yg9eAI+jsROYYdCNMqIr2Mc4nSWxBpEFFAe4cQs
	 8gZN7FoVmq0yuqV+2lLvODgtdSpYpUF+9LTB0SgW38yAOMobw+oAc03uNeB3cf5voM
	 fnzP6YB7iw+kw==
Date: Sun, 8 Aug 2021 15:24:52 +0200
From: наб <[email protected]>
To: [email protected]
Cc: [email protected]
Subject: [PATCH][Debian#992002] tbl: allow two-character fonts and format
 fonts in -Thtml
Message-ID: <[email protected]>
Mail-Followup-To: [email protected], [email protected]
References: <[email protected]>
 <[email protected]>
 <[email protected]>
 <CANnVG6k_czNfH5qNt9N3oOFF+v2i0eNfF92GO5vVK1sad9TRTw@mail.gmail.com>
MIME-Version: 1.0
Content-Type: multipart/signed; micalg=pgp-sha512;
	protocol="application/pgp-signature"; boundary="3kmafmretvzbsyhz"
Content-Disposition: inline
In-Reply-To: <CANnVG6k_czNfH5qNt9N3oOFF+v2i0eNfF92GO5vVK1sad9TRTw@mail.gmail.com>
User-Agent: NeoMutt/20210205
[Message part 1 (text/plain, inline)]
Hi!

tbl's -Thtml ignores font requests; additionally, the tbl f-request
parser only allows single-character fonts. Cf. the Debian bug
(http://bugs.debian.org/992002) for additional context.

Please consider the following patch.
наб

---
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

-Thtml -Ofragment yields, as expected:
-- >8 --
<table class="head">
  <tr>
    <td class="head-ltitle">V(1)</td>
    <td class="head-vol">General Commands Manual</td>
    <td class="head-rtitle">V(1)</td>
  </tr>
</table>
<div class="manual-text"><b>text</b><i>text</i><b><i>text</i></b><span class="Li">text</span><b>text</b><i>text</i>
<p class="Pp"></p>
<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>
    <td><span class="Li">text</span></td>
    <td><b>text</b></td>
    <td><i>text</i></td>
  </tr>
</table>
</div>
<table class="foot">
  <tr>
    <td class="foot-date">August 8, 2021</td>
    <td class="foot-os">Debian</td>
  </tr>
</table>
-- >8 --

--- mdocml-1.14.5.orig/tbl.7
+++ mdocml-1.14.5/tbl.7
@@ -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 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
--- mdocml-1.14.5.orig/tbl.h
+++ mdocml-1.14.5/tbl.h
@@ -59,12 +59,13 @@ struct	tbl_cell {
 	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 */
+#define	TBL_CELL_FONTCW	 (1 << 2)   /* fC[RBI] */
+#define	TBL_CELL_TALIGN	 (1 << 3)   /* t, T */
+#define	TBL_CELL_UP	 (1 << 4)   /* u, U */
+#define	TBL_CELL_BALIGN	 (1 << 5)   /* d, D */
+#define	TBL_CELL_WIGN	 (1 << 6)   /* z, Z */
+#define	TBL_CELL_EQUAL	 (1 << 7)   /* e, E */
+#define	TBL_CELL_WMAX	 (1 << 8)   /* x, X */
 	enum tbl_cellt	  pos;
 };
 
--- mdocml-1.14.5.orig/tbl_html.c
+++ mdocml-1.14.5/tbl_html.c
@@ -25,6 +25,7 @@
 #include <string.h>
 
 #include "mandoc.h"
+#include "mandoc_aux.h"
 #include "tbl.h"
 #include "out.h"
 #include "html.h"
@@ -218,6 +219,7 @@ print_tbl(struct html *h, const struct t
 		else
 			valign = NULL;
 
+		int flags = cp->flags;
 		for (i = dp->hspans; i > 0; i--)
 			cp = cp->next;
 		switch (cp->vert) {
@@ -239,8 +241,36 @@ print_tbl(struct html *h, const struct t
 		    "vertical-align", valign,
 		    "text-align", halign,
 		    "border-right-style", rborder);
-		if (dp->string != NULL)
-			print_text(h, dp->string);
+		if (dp->string != NULL) {
+			const char *font = NULL;
+			switch (flags & (TBL_CELL_BOLD | TBL_CELL_ITALIC | TBL_CELL_FONTCW)) {
+				case TBL_CELL_BOLD:
+					font = "\\fB";
+					break;
+				case TBL_CELL_ITALIC:
+					font = "\\fI";
+					break;
+				case TBL_CELL_BOLD | TBL_CELL_ITALIC:
+					font = "\\f(BI";
+					break;
+				case TBL_CELL_FONTCW:
+					font = "\\f(CR";
+					break;
+				case TBL_CELL_FONTCW | TBL_CELL_BOLD:
+					font = "\\f(CB";
+					break;
+				case TBL_CELL_FONTCW | TBL_CELL_ITALIC:
+					font = "\\f(CI";
+					break;
+			}
+			if (font) {
+				char *str;
+				mandoc_asprintf(&str, "%s%s\\fP", font, dp->string);
+				print_text(h, str);
+				free(str);
+			} else
+				print_text(h, dp->string);
+		}
 	}
 
 	print_tagq(h, tt);
--- mdocml-1.14.5.orig/tbl_layout.c
+++ mdocml-1.14.5/tbl_layout.c
@@ -170,9 +170,7 @@ mod:
 	if (p[*pos] == '(')
 		goto mod;
 
-	/* Support only one-character font-names for now. */
-
-	if (p[*pos] == '\0' || (p[*pos + 1] != ' ' && p[*pos + 1] != '.')) {
+	if (p[*pos] == '\0' || (!isalnum(p[*pos + 1]) && p[*pos + 1] != ' ' && p[*pos + 1] != '.')) {
 		mandoc_msg(MANDOCERR_FT_BAD,
 		    ln, *pos, "TS %s", p + *pos - 1);
 		if (p[*pos] != '\0')
@@ -182,23 +180,27 @@ mod:
 		goto mod;
 	}
 
-	switch (p[(*pos)++]) {
-	case '3':
-	case 'B':
+	char fn[3] = {'\0'}, *fp = fn;
+	fn[0] = p[(*pos)++];
+	fn[1] = p[*pos] == ' ' || p[*pos] == '.' ? '\0' : p[(*pos)++];
+
+refont:
+	if (!strcmp(fp, "3") || !strcmp(fp, "B"))
 		cp->flags |= TBL_CELL_BOLD;
-		goto mod;
-	case '2':
-	case 'I':
+	else if (!strcmp(fp, "2") || !strcmp(fp, "I"))
 		cp->flags |= TBL_CELL_ITALIC;
-		goto mod;
-	case '1':
-	case 'R':
-		goto mod;
-	default:
+	else if (!strcmp(fp, "1") || !strcmp(fp, "R"))
+		;
+	else if (!strcmp(fp, "BI"))
+		cp->flags |= TBL_CELL_BOLD | TBL_CELL_ITALIC;
+	else if (fp[0] == 'C' && fp[1]) {
+		cp->flags |= TBL_CELL_FONTCW;
+		++fp;
+		goto refont;
+	} else
 		mandoc_msg(MANDOCERR_FT_BAD,
-		    ln, *pos - 1, "TS f%c", p[*pos - 1]);
-		goto mod;
-	}
+		    ln, *pos - strlen(fn), "TS f%s", fn);
+	goto mod;
 }
 
 static void
--- mdocml-1.14.5.orig/tbl_term.c
+++ mdocml-1.14.5/tbl_term.c
@@ -922,10 +922,17 @@ 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->flags & (TBL_CELL_BOLD | TBL_CELL_ITALIC)) {
+		case TBL_CELL_BOLD | TBL_CELL_ITALIC:
+			term_fontpush(tp, TERMFONT_BI);
+			break;
+		case TBL_CELL_BOLD:
+			term_fontpush(tp, TERMFONT_BOLD);
+			break;
+		case TBL_CELL_ITALIC:
+			term_fontpush(tp, TERMFONT_UNDER);
+			break;
+	}
 
 	term_word(tp, dp->string);
 
[signature.asc (application/pgp-signature, inline)]

Send a report that this bug log contains spam.


Debian bug tracking system administrator <[email protected]>. Last modified: Tue May 13 11:18:27 2025; Machine Name: buxtehude

Debian Bug tracking system

Debbugs is free software and licensed under the terms of the GNU General Public License version 2. The current version can be obtained from https://bugs.debian.org/debbugs-source/.

Copyright © 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson, 2005-2017 Don Armstrong, and many other contributors.