tech@mandoc.bsd.lv
 help / color / mirror / Atom feed
* Bizarre .Nm-breaking-.Bd's-<pre> in -Thtml behaviour?
@ 2021-10-12 19:42 наб
  2021-10-15 23:16 ` Bizarre .Nm-breaking-.Bd's-<pre> in -Thtml behaviour analysis + not a patch наб
  0 siblings, 1 reply; 2+ messages in thread
From: наб @ 2021-10-12 19:42 UTC (permalink / raw)
  To: tech

[-- Attachment #1: Type: text/plain, Size: 1483 bytes --]

Hi!

This one's weird, since I've written dozens of this sort of table before
and it's always worked, but this is somehow broken. A minimal example is
-- >8 --
.Sh NAME
.Nm a
.
.Sh EXAMPLES
.Bd -literal
.Nm
b
.Ed
-- >8 --

Which yields
-- >8 --
nabijaczleweli@tarta:~/uwu/mandoc$ ./mandoc -mdoc -Thtml -Ofragment ../kl.8
<table class="head">
  <tr>
    <td class="head-ltitle">UNTITLED</td>
    <td class="head-vol">LOCAL</td>
    <td class="head-rtitle">UNTITLED</td>
  </tr>
</table>
<div class="manual-text">
<section class="Sh">
<h1 class="Sh" id="NAME"><a class="permalink" href="#NAME">NAME</a></h1>
<p class="Pp"><code class="Nm">a</code></p>
</section>
<section class="Sh">
<h1 class="Sh" id="EXAMPLES"><a class="permalink" href="#EXAMPLES">EXAMPLES</a></h1>
<div class="Bd Li">
<pre><code class="Nm"></code></pre>
a
b</div>
</section>
</div>
<table class="foot">
  <tr>
    <td class="foot-date"></td>
    <td class="foot-os"></td>
  </tr>
</table>
-- >8 --

Note how a and b are both (a) past Nm and (b) past the <pre>. This has
an additional funny side-effect of inlining the rest of the display
block. Macros still work, but text is laid normally by the browser,
rather than literally.

I don't know what triggers this in this case and not all others,
but an explicit .Nm argument fixes it (but that's, uh, suboptimal).

Happens on mandoc 1.14.5-1 off Debian and 2021-10-12T21:41:37+02:00 off
CVS.

Best,
наб

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Bizarre .Nm-breaking-.Bd's-<pre> in -Thtml behaviour analysis + not a patch
  2021-10-12 19:42 Bizarre .Nm-breaking-.Bd's-<pre> in -Thtml behaviour? наб
@ 2021-10-15 23:16 ` наб
  0 siblings, 0 replies; 2+ messages in thread
From: наб @ 2021-10-15 23:16 UTC (permalink / raw)
  To: tech

[-- Attachment #1: Type: text/plain, Size: 4381 bytes --]

Ha, got it!

On Tue, Oct 12, 2021 at 09:42:30PM +0200, наб wrote:
> This one's weird, since I've written dozens of this sort of table before
> and it's always worked, but this is somehow broken. A minimal example is
> -- >8 --
> .Sh NAME
> .Nm a
> .
> .Sh EXAMPLES
> .Bd -literal
> .Nm
> b
> .Ed
> -- >8 --

If you apply this:
-- >8 --
Index: mdoc_html.c
===================================================================
RCS file: /cvs/mandoc/mdoc_html.c,v
retrieving revision 1.342
diff -u -r1.342 mdoc_html.c
--- mdoc_html.c	30 Mar 2021 19:26:20 -0000	1.342
+++ mdoc_html.c	15 Oct 2021 22:58:35 -0000
@@ -335,6 +335,8 @@
 {
 
 	while (n != NULL) {
+if(!strcmp(n->string ?: "", "a"))
+	fprintf(stderr, "a: %d\n", n->flags);
 		print_mdoc_node(meta, n, h);
 		n = n->next;
 	}
-- >8 --

Then the original test file gives this:
-- >8 --
nabijaczleweli@babtop:/tmp/mandoc$ stdbuf -o0  ./mandoc -Thtml -Ofragment /tmp/a.1 -mdoc
<table class="head">
  <tr>
    <td class="head-ltitle">UNTITLED</td>
    <td class="head-vol">LOCAL</td>
    <td class="head-rtitle">UNTITLED</td>
  </tr>
</table>
<div class="manual-text">
<section class="Sh">
<h1 class="Sh" id="NAME"><a class="permalink" href="#NAME">NAME</a></h1>
<p class="Pp"><code class="Nm">a: 3
a</code></p>
</section>
<section class="Sh">
<h1 class="Sh" id="EXAMPLES"><a class="permalink" href="#EXAMPLES">EXAMPLES</a></h1>
<div class="Bd Li">
<pre><code class="Nm">a: 515
</code></pre>
a
b</div>
</section>
</div>
<table class="foot">
  <tr>
    <td class="foot-date"></td>
    <td class="foot-os"></td>
  </tr>
</table>
-- >8 --

But one with an explicit ".Nm a" instead,
which yields correct output, gives this:
-- >8 --
nabijaczleweli@babtop:/tmp/mandoc$ stdbuf -o0  ./mandoc -Thtml -Ofragment /tmp/a2.1 -mdoc
<table class="head">
  <tr>
    <td class="head-ltitle">UNTITLED</td>
    <td class="head-vol">LOCAL</td>
    <td class="head-rtitle">UNTITLED</td>
  </tr>
</table>
<div class="manual-text">
<section class="Sh">
<h1 class="Sh" id="NAME"><a class="permalink" href="#NAME">NAME</a></h1>
<p class="Pp"><code class="Nm">a: 3
a</code></p>
</section>
<section class="Sh">
<h1 class="Sh" id="EXAMPLES"><a class="permalink" href="#EXAMPLES">EXAMPLES</a></h1>
<div class="Bd Li">
<pre><code class="Nm">a: 259
a</code>
b</pre>
</div>
</section>
</div>
<table class="foot">
  <tr>
    <td class="foot-date"></td>
    <td class="foot-os"></td>
  </tr>
</table>
-- >8 --

A glance at the flags gives us
	259 = 0b0100000011 = NODE_NOFILL|NODE_VALID|NODE_ENDED
	515 = 0b1000000011 = NODE_NOSRC |NODE_VALID|NODE_ENDED

This explodes in print_mdoc_node(), which does
-- >8 --
static void print_mdoc_node(MDOC_ARGS) {
    if (n->type == ROFFT_COMMENT || n->flags & NODE_NOPRT)
        return;

    if ((n->flags & NODE_NOFILL) == 0)
        html_fillmode(h, ROFF_fi);
    else if (html_fillmode(h, ROFF_nf) == ROFF_nf &&
        n->tok != ROFF_fi && n->flags & NODE_LINE)
        print_endline(h);

    ...
-- >8 --

Explicit Nm takes the latter branch, implicit the former,
and setting fillmode to fi outputs the dreaded "</code></pre>".

Needless to say, the fix is to set NODE_NOFILL on implicit Nms,
like it's done on explicit Nms:
-- >8 --
nabijaczleweli@babtop:/tmp/mandoc$ stdbuf -o0  ./mandoc -Thtml -Ofragment /tmp/a.1 -mdoc
<table class="head">
  <tr>
    <td class="head-ltitle">UNTITLED</td>
    <td class="head-vol">LOCAL</td>
    <td class="head-rtitle">UNTITLED</td>
  </tr>
</table>
<div class="manual-text">
<section class="Sh">
<h1 class="Sh" id="NAME"><a class="permalink" href="#NAME">NAME</a></h1>
<p class="Pp"><code class="Nm">a: 3
a</code></p>
</section>
<section class="Sh">
<h1 class="Sh" id="EXAMPLES"><a class="permalink" href="#EXAMPLES">EXAMPLES</a></h1>
<div class="Bd Li">
<pre><code class="Nm">a: 771
a</code>
b</pre>
</div>
</section>
</div>
<table class="foot">
  <tr>
    <td class="foot-date"></td>
    <td class="foot-os"></td>
  </tr>
</table>
-- >8 --

Where
	771 = 0b1100000011 = NODE_NOSRC|NODE_NOFILL|NODE_VALID|NODE_ENDED

Since ISTR you being somehow morally opposed to taking my patches,
my friendly advice is that I've found the code that sets this flag
to be at the tail-end of post_nm(), instead.

Best,
наб

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-10-15 23:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-12 19:42 Bizarre .Nm-breaking-.Bd's-<pre> in -Thtml behaviour? наб
2021-10-15 23:16 ` Bizarre .Nm-breaking-.Bd's-<pre> in -Thtml behaviour analysis + not a patch наб

tech@mandoc.bsd.lv

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://inbox.vuxu.org/mandoc-tech

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 mandoc-tech mandoc-tech/ https://inbox.vuxu.org/mandoc-tech \
		tech@mandoc.bsd.lv
	public-inbox-index mandoc-tech

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.vuxu.org/vuxu.archive.mandoc.tech


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git