From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: ** X-Spam-Status: No, score=2.7 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, FROM_SUSPICIOUS_NTLD,PDS_OTHER_BAD_TLD,T_TVD_MIME_EPI autolearn=no autolearn_force=no version=3.4.4 Received: (qmail 407 invoked from network); 8 Aug 2021 17:35:06 -0000 Received: from bsd.lv (HELO mandoc.bsd.lv) (66.111.2.12) by inbox.vuxu.org with ESMTPUTF8; 8 Aug 2021 17:35:06 -0000 Received: from fantadrom.bsd.lv (localhost [127.0.0.1]) by mandoc.bsd.lv (OpenSMTPD) with ESMTP id b8f1dce6 for ; Sun, 8 Aug 2021 12:35:03 -0500 (EST) Received: from tarta.nabijaczleweli.xyz (139-28-40-42.artus.net.pl [139.28.40.42]) by mandoc.bsd.lv (OpenSMTPD) with ESMTP id 88d1a432 for ; Sun, 8 Aug 2021 12:35:01 -0500 (EST) Received: from tarta.nabijaczleweli.xyz (unknown [192.168.1.250]) by tarta.nabijaczleweli.xyz (Postfix) with ESMTPSA id 90EB73602F7 for ; Sun, 8 Aug 2021 19:35:00 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=nabijaczleweli.xyz; s=202006; t=1628444100; bh=dX8mEg/lFjE/A6s/m3zlyBmOdyQlicGSaL/fNGJMVpQ=; h=Resent-From:Resent-Date:Resent-To:Date:From:To:Cc:Subject: References:In-Reply-To:From; b=W7+yg1AGZMDcRqJcqDCnJ1loT1AmCtb9c2VN3Q3NTNomMU9SJNGbCTanDwRhQtWRv E/345fWWmY+RzsV3SZopm03RTVO2C1lwkj8AJtN5CJqUkJCP/1o1zEVTF+r83N3HjV G4XNSk1vopxVfwN45qHL7Ut+cTePErtAwJUN1wGNykVRZliaDCOM0YLmorQDUSJqFd peN0ooYg55+ONMYXojTy1M8DPFbsD8OdVLn83B7V1pvMw4eUKIxy3pIzeNTVJWLhxB CDIdXjxgdWnLRx2QvkvrJiuoKMy7AC2ByGLHKHIYEeBeMbZhc7FfPA5JuO5OTKYmZk 2+HwyF7IUaBsg== Resent-From: =?utf-8?B?0L3QsNCx?= Resent-Date: Sun, 8 Aug 2021 19:34:59 +0200 Resent-Message-ID: <20210808173459.or7muynaqbyviiil@tarta.nabijaczleweli.xyz> Resent-To: tech@mandoc.bsd.lv Date: Sun, 8 Aug 2021 15:24:53 +0200 From: =?utf-8?B?0L3QsNCx?= To: tech@mandoc.bsd.lv Cc: 992002@bugs.debian.org Subject: [PATCH][Debian#992002] tbl: allow two-character fonts and format fonts in -Thtml Message-ID: <20210808132452.bekkztprjqoup3pa@tarta.nabijaczleweli.xyz> Mail-Followup-To: tech@mandoc.bsd.lv, 992002@bugs.debian.org References: <20210808111135.zisbfzlqqdsq35om@tarta.nabijaczleweli.xyz> <20210808124919.hevbw4gv6pis72pq@tarta.nabijaczleweli.xyz> X-Mailinglist: mandoc-tech Reply-To: tech@mandoc.bsd.lv MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="3kmafmretvzbsyhz" Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20210205 --3kmafmretvzbsyhz Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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. =D0=BD=D0=B0=D0=B1 --- With this patch, the following document: -- >8 -- =2EDd =2EDt V 1 =2EOs =2E \fBtext\fItext\f(BItext\f(CRtext\f(CBtext\f(CItext\fR =2EPp =2ETS lfB lfI lfBI lb li lbi lfCR lfCB lfCI . text text text text text text text text text =2ETE -- >8 -- Renders to a teletype with the expected fonts: b, ul, bul; b, ul, bul; normal, b, ul -Thtml -Ofragment yields, as expected: -- >8 --
V(1) General Commands Manual V(1)
texttexttexttexttexttext

text text text text text text text text text
August 8, 2021 Debian
-- >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; }; =20 --- mdocml-1.14.5.orig/tbl_html.c +++ mdocml-1.14.5/tbl_html.c @@ -25,6 +25,7 @@ #include =20 #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 =3D NULL; =20 + int flags =3D cp->flags; for (i =3D dp->hspans; i > 0; i--) cp =3D 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 !=3D NULL) - print_text(h, dp->string); + if (dp->string !=3D NULL) { + const char *font =3D NULL; + switch (flags & (TBL_CELL_BOLD | TBL_CELL_ITALIC | TBL_CELL_FONTCW)) { + case TBL_CELL_BOLD: + font =3D "\\fB"; + break; + case TBL_CELL_ITALIC: + font =3D "\\fI"; + break; + case TBL_CELL_BOLD | TBL_CELL_ITALIC: + font =3D "\\f(BI"; + break; + case TBL_CELL_FONTCW: + font =3D "\\f(CR"; + break; + case TBL_CELL_FONTCW | TBL_CELL_BOLD: + font =3D "\\f(CB"; + break; + case TBL_CELL_FONTCW | TBL_CELL_ITALIC: + font =3D "\\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); + } } =20 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] =3D=3D '(') goto mod; =20 - /* Support only one-character font-names for now. */ - - if (p[*pos] =3D=3D '\0' || (p[*pos + 1] !=3D ' ' && p[*pos + 1] !=3D '.')= ) { + if (p[*pos] =3D=3D '\0' || (!isalnum(p[*pos + 1]) && p[*pos + 1] !=3D ' '= && p[*pos + 1] !=3D '.')) { mandoc_msg(MANDOCERR_FT_BAD, ln, *pos, "TS %s", p + *pos - 1); if (p[*pos] !=3D '\0') @@ -182,23 +180,27 @@ mod: goto mod; } =20 - switch (p[(*pos)++]) { - case '3': - case 'B': + char fn[3] =3D {'\0'}, *fp =3D fn; + fn[0] =3D p[(*pos)++]; + fn[1] =3D p[*pos] =3D=3D ' ' || p[*pos] =3D=3D '.' ? '\0' : p[(*pos)++]; + +refont: + if (!strcmp(fp, "3") || !strcmp(fp, "B")) cp->flags |=3D TBL_CELL_BOLD; - goto mod; - case '2': - case 'I': + else if (!strcmp(fp, "2") || !strcmp(fp, "I")) cp->flags |=3D 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 |=3D TBL_CELL_BOLD | TBL_CELL_ITALIC; + else if (fp[0] =3D=3D 'C' && fp[1]) { + cp->flags |=3D 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; } =20 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; =20 prev_font =3D 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; + } =20 term_word(tp, dp->string); =20 --3kmafmretvzbsyhz Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEfWlHToQCjFzAxEFjvP0LAY0mWPEFAmEP2yEACgkQvP0LAY0m WPHPbRAAo5LsmKxXYS2SJAqHI2A82RBn9o21knOainGn1P6dUOk7eyHvA3NBZPQb RsXKA+6BaCjfKWGkB1jJvT42XCqbaTODwx0q9rTj6QwCSB0PulHDH7IlvKjjpyi1 xPG9Kg9wpoQnJVCU1o9cWCW/j2ZEuXy6oneVKpI1ldesKK8LPBi0KdUGyqUmdscL o4RnjHQBTryR3HIENTx4B3qIt2KFjUC1tnvVIG+QiULdSqu81jg/5u8tgUwOA2Pk tCAytbncWbmXHny9z97Vrd1sXjC6e+i9y2GegR8kenfrPZG0V5h664GAtOZHofuJ OOeBrivc7DBXOBuxq6dfuOfSwqScSvELjBu005ORKUrZ3C7dSuA3rXUFQCbTLLEc cRIgYTb16aoErmrLC9Pi/XfP64epbCVKNXQPs2Jyzf1QQ2bgwtOyicP/HRSQ5iBv DxHNBIPUuOCU+D6weaTeRFWp9DAYYs28eFMOw+QchAGupmwnNvtr5nE9wEYbfocf JWMvr9+NmAErcfEW8JdzZg3AyKvJUZecxDz9rL7XRD1yDOac76sqQzWiJL/57tK1 i5ozMoKlIBgw0oU9rMcihXw9b7F/GP24afKrMh8Ix+O1mK7AjwecOW80GWfkcpMB hyJoY31IdPurt7D6dOjUIqK/dW9olhMw7z32aadhVSSa1YnbpKs= =aHdU -----END PGP SIGNATURE----- --3kmafmretvzbsyhz-- -- To unsubscribe send an email to tech+unsubscribe@mandoc.bsd.lv