Can you send your patches to upstream directly please?
See https://mandoc.bsd.lv/contact.html

It’s awkward for Debian maintainers to sit in the middle.
Thanks!

On Sun, 8 Aug 2021 at 14:51, наб <nabijaczlew...@nabijaczleweli.xyz> wrote:

> Control: retitle -1 mandoc: -Thtml: tbl font requests ignored
> Control: tags -1 + patch
>
> Easy enough, oddly. Patch attached, applies cleanly on top of 1.22.4-6.
> Please consider it.
>
> Given 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 --
>
> When rendering to a teletype, the fonts are
>   b, ul, bul;  b, ul, bul;  normal, b, ul
> this is as expected!
>
> -Thtml -Ofragment yields
> -- >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 --
>
> This is, also, as expected, if suboptimal because of the general
> HTML \fC[BI] handling.
>
> Best,
> наб
> --- 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);
>
>

-- 
Best regards,
Michael

Reply via email to