Bug 290801 - date(1) does not render correctly on man.freebsd.org
Summary: date(1) does not render correctly on man.freebsd.org
Status: Closed FIXED
Alias: None
Product: Documentation
Classification: Unclassified
Component: Manual Pages (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Mateusz Piotrowski
URL: https://man.freebsd.org/cgi/man.cgi?q...
Keywords:
Depends on:
Blocks:
 
Reported: 2025-11-04 20:24 UTC by Mateusz Piotrowski
Modified: 2025-11-12 09:44 UTC (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mateusz Piotrowski freebsd_committer freebsd_triage 2025-11-04 20:24:43 UTC
The format code `%N` doesn't appear at all, even though it is
definitely found in the manual source code:
https://github.com/freebsd/freebsd-src/blob/release/14.1.0/bin/date/date.1

Reported by: jinwookjeongg@gmail.com via hackers@.
Comment 1 Marek Zarychta 2025-11-04 20:42:58 UTC
(In reply to Mateusz Piotrowski from comment #0)
I can see it working in stable/15. Could you explain your use case where it fails?
Comment 2 cyric@mm.st 2025-11-04 22:06:07 UTC
(In reply to Marek Zarychta from comment #1)
This is specifically about man page rendering on the website, i.e. https://man.freebsd.org/cgi/man.cgi?query=date.

See e.g. the STANDARDS subsection.

Output from man(1):

     The ‘%N’ conversion specification for nanoseconds is a non-standard
     extension.  It is compatible with GNU date's ‘%N’.

Website version:

       The  `conversion	 specification	for  nanoseconds  is  a	  non-standard
       extension.  It is compatible with GNU date's `''
Comment 3 B.S. 2025-11-04 23:52:33 UTC
It is not just the %N symbol itself that is not rendering correctly on https://man.freebsd.org/cgi/man.cgi?query=date

Viewing source to see the raw html:

> <a name="HISTORY" href="#end"><b>HISTORY</b></a>
>       A <b>date</b> command appeared in Version 1 AT&amp;T UNIX.
>       ...
>       The <b>-I</b> flag was added in	FreeBSD	12.0.
>
>       The `conversion specification was added in FreeBSD'

Compare that last line to the man page: https://github.com/freebsd/freebsd-src/blob/release/14.1.0/bin/date/date.1

> The
> .Ql %N
> conversion specification was added in
> .Fx 14.1 .

The "14.1" has been "eaten" by the %N.

Interestingly, html output from mandoc is fine:

> mandoc -T html date.1

Produces:

> <p class="Pp">The &#x2018;<code class="Li">%N</code>&#x2019; conversion
>    specification was added in <span class="Ux">FreeBSD 14.1</span>.</p>

This renders correctly - but man.freebsd.org clearly does not use mandoc html.
Comment 4 B.S. 2025-11-05 02:54:10 UTC
I believe man.freebsd.org uses groff(1) (version 1.23.0?) which struggles with %N presumably as it is a references & citations macro for issue number: see https://man.freebsd.org/cgi/man.cgi?query=groff_mdoc 

To replicate the website's History section error: $ groff -mdoc -T html date.1

> <p style="margin-left:9%; margin-top: 1em">The
> <b>&minus;I</b> flag was added in FreeBSD&nbsp;12.0.</p>
> 
> <p style="margin-left:9%; margin-top: 1em">The
> &lsquo;conversion specification was added in FreeBSD&rsquo;

Or in plain ASCII, generating an mdoc warning: $ groff -a -mdoc  

> The <->I flag was added in FreeBSD 12.0.
> mdoc warning: Using a macro as first argument cancels effect of .Li (#618)
> Usage: .%N issue_number ... (#618)
> The <oq>conversion specification was added in FreeBSD<cq>

While mandoc(1) generates the desired html, it still warns with -Tlint:

$ mandoc -Tlint date.1

> mandoc: date.1:146:8: WARNING: skipping empty macro: No
> mandoc: date.1:331:5: WARNING: macro neither callable nor escaped: %N
> mandoc: date.1:594:5: WARNING: macro neither callable nor escaped: %N
> mandoc: date.1:597:5: WARNING: macro neither callable nor escaped: %N
> mandoc: date.1:618:5: WARNING: macro neither callable nor escaped: %N
> mandoc: date.1:198:2: STYLE: useless macro: Tn
> mandoc: date.1:511:2: STYLE: useless macro: Tn
Comment 5 B.S. 2025-11-05 03:49:41 UTC
Each "%N" in date.1 should be escaped as "\&%N", as done in https://github.com/freebsd/freebsd-src/blob/main/contrib/mandoc/mdoc.7

Post-sed, the groff output is much better:

> <p style="margin-left:9%; margin-top: 1em">The
> <b>&minus;I</b> flag was added in FreeBSD&nbsp;12.0.</p>
> 
> <p style="margin-left:9%; margin-top: 1em">The
> &lsquo;%N&rsquo; conversion specification was added in
> FreeBSD&nbsp;14.1. FreeBSD&nbsp;14.3 September 10, 2024
> DATE(1)</p>
Comment 6 commit-hook freebsd_committer freebsd_triage 2025-11-05 12:38:13 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=e878ba8eea7206b3a435338c6eed0e4264e0ce14

commit e878ba8eea7206b3a435338c6eed0e4264e0ce14
Author:     Mateusz Piotrowski <0mp@FreeBSD.org>
AuthorDate: 2025-11-05 12:34:31 +0000
Commit:     Mateusz Piotrowski <0mp@FreeBSD.org>
CommitDate: 2025-11-05 12:36:35 +0000

    date.1: Lint with mandoc

    Specifically, remove Tn macors, replace Li with Ql, and escape %N to
    address date.1's rendering issues on man.freebsd.org.

    PR:             290801
    Reported by:    jinwookjeongg@gmail.com
    MFC after:      1 week
    Sponsored by:   Klara, Inc.

 bin/date/date.1 | 35 ++++++++++++++++++-----------------
 1 file changed, 18 insertions(+), 17 deletions(-)
Comment 7 Mateusz Piotrowski freebsd_committer freebsd_triage 2025-11-05 12:39:24 UTC
Thanks everyone! I've committed a fix.
Comment 8 commit-hook freebsd_committer freebsd_triage 2025-11-12 09:43:56 UTC
A commit in branch stable/15 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=6ef503c80ff3d5d219b30e63124f704721148a4b

commit 6ef503c80ff3d5d219b30e63124f704721148a4b
Author:     Mateusz Piotrowski <0mp@FreeBSD.org>
AuthorDate: 2025-11-05 12:34:31 +0000
Commit:     Mateusz Piotrowski <0mp@FreeBSD.org>
CommitDate: 2025-11-12 09:43:34 +0000

    date.1: Lint with mandoc

    Specifically, remove Tn macors, replace Li with Ql, and escape %N to
    address date.1's rendering issues on man.freebsd.org.

    PR:             290801
    Reported by:    jinwookjeongg@gmail.com
    MFC after:      1 week
    Sponsored by:   Klara, Inc.

    (cherry picked from commit e878ba8eea7206b3a435338c6eed0e4264e0ce14)

 bin/date/date.1 | 35 ++++++++++++++++++-----------------
 1 file changed, 18 insertions(+), 17 deletions(-)
Comment 9 commit-hook freebsd_committer freebsd_triage 2025-11-12 09:44:58 UTC
A commit in branch stable/14 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=6c185061a63b6db6676c6a24e6bf0802774a07fa

commit 6c185061a63b6db6676c6a24e6bf0802774a07fa
Author:     Mateusz Piotrowski <0mp@FreeBSD.org>
AuthorDate: 2025-11-05 12:34:31 +0000
Commit:     Mateusz Piotrowski <0mp@FreeBSD.org>
CommitDate: 2025-11-12 09:43:49 +0000

    date.1: Lint with mandoc

    Specifically, remove Tn macors, replace Li with Ql, and escape %N to
    address date.1's rendering issues on man.freebsd.org.

    PR:             290801
    Reported by:    jinwookjeongg@gmail.com
    MFC after:      1 week
    Sponsored by:   Klara, Inc.

    (cherry picked from commit e878ba8eea7206b3a435338c6eed0e4264e0ce14)

 bin/date/date.1 | 35 ++++++++++++++++++-----------------
 1 file changed, 18 insertions(+), 17 deletions(-)