From be72c72006d56ab6957f5b7505229a123162afff Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Tue, 27 Oct 2026 23:02:45 -1000 Subject: Render the man pages that generators write DocBook, pod2man and hand written pages leaked roff onto the page. Font escapes inside no fill blocks, comments, layout escapes such as \% and \c, the colours and half line moves around DocBook's links, and the requests and macro definitions their preambles open with all showed through. Those now draw nothing, the common named characters and strings render, .EX and pod2man's .Vb read as code, a .TP tag takes a line of its own and the alternating font macros switch fonts between their arguments. Anything rarer still falls back to its text. --- tests/extensions/test-about-render.lua | 71 +++++++++++++++++++++++++++++++++- 1 file changed, 69 insertions(+), 2 deletions(-) (limited to 'tests/extensions') diff --git a/tests/extensions/test-about-render.lua b/tests/extensions/test-about-render.lua index 7341385..f95da7e 100644 --- a/tests/extensions/test-about-render.lua +++ b/tests/extensions/test-about-render.lua @@ -257,6 +257,15 @@ render("README.md", string.rep("# a\n", 50000)) render("README.md", "| a | b |\n|---|---|\n| x" .. string.rep(" ", 40000) .. "y | z |") h.check("a long run of spaces is trimmed quickly", os.clock() - started < 10) +-- The long forms of the man escapes scan for a closing bracket or quote, so +-- they are bounded the same way, and a line of openers stays linear. +started = os.clock() +render("page.1", string.rep("\\[", 100000)) +render("page.1", string.rep("\\f[", 100000)) +render("page.1", string.rep("\\h'", 100000)) +render("page.1", string.rep("\\s[", 100000)) +h.check("a line of unclosed man escapes renders quickly", os.clock() - started < 10) + out = render("README.md", "Title\n=====\n\nBody") h.contains("equals signs under a line make a heading", out, "

Title

Body

") @@ -334,13 +343,71 @@ h.contains("the bold macro renders strong", out, "

bold words out = render("page.1", "a \\fBbold\\fR c") h.contains("font escapes carry across a run", out, "

a bold c

") -out = render("page.1", "x \\(em y \\- z") -h.contains("character escapes are translated", out, "

x - y - z

") +out = render("page.1", "x \\(em y \\- z \\(bu \\[co]") +h.contains("character escapes are translated", out, "

x — y - z • ©

") + +out = render("page.1", "\\*(lqquoted\\*(rq\\*R") +h.contains("predefined strings are expanded", out, "

“quoted”®

") + +out = render("page.1", "a\\%b c\\:d \\s-1SMALL\\s0 text \\\" a comment") +h.contains("escapes that only steer the layout draw nothing", out, "

ab cd SMALL text

") out = render("page.1", ".nf\ncode \n.fi\nafter") h.contains("a no fill block renders as code", out, "
code <x>\n
") h.contains("filling resumes after it", out, "

after

") +out = render("page.1", ".nf\n\\fBgit\\fR \\-\\-version\n.fi") +h.contains("a no fill block shows the text of its escapes", out, "
git --version\n
") + +out = render("page.1", ".EX\nline \n.EE") +h.contains("an example block renders as code", out, "
line <one>\n
") + +out = render("page.1", ".TP\n.B \\-v\nBe verbose.") +h.contains("a tag takes a line of its own", out, "

-v
\nBe verbose.

") + +out = render("page.1", ".IP \\(bu 2\nAn item.\n.IP \\-v 4\nA flag.") +h.contains("a bullet leads its item", out, "

• \nAn item.

") +h.contains("a longer tag takes a line of its own", out, "

-v
\nA flag.

") + +out = render("page.1", ".BR ls (1),\n.IR file .txt") +h.contains("alternating macros switch fonts between arguments", out, + "ls(1),\nfile.txt") + +out = render("page.1", '.B "two words" three') +h.contains("a quoted argument keeps its blank", out, "two words three") + +out = render("page.1", "one\n.br\ntwo\n.\nthree") +h.contains("a break request breaks the line", out, "

one
\ntwo\nthree

") + +-- pod2man and asciidoctor open their pages with macro definitions and +-- conditional requests, none of which may reach the page as text. +out = render("page.1", table.concat({ + ".de Vb", ".nf", "..", ".de IX", "..", ".if n .ds Aq '", ".ie \\n(.g \\{\\", + ". nr x 1", ".\\}", ".SH NAME", ".IX Header \"NAME\"", ".Vb 2", "\\& code", ".Ve", "after", +}, "\n")) +h.excludes("a page's own macro is not drawn", out, "Header") +h.excludes("a roff request is not drawn", out, "Aq") +h.contains("the heading after the preamble renders", out, "

NAME

") +h.contains("pod2man's verbatim macros render code", out, "
  code\n
") +h.contains("text after the definitions renders", out, "

after

") + +out = render("page.1", ".if n \\\n\\{\\\n.ds x y\n.\\}\nafter") +h.contains("a conditional block's requests and braces draw nothing", out, + "

after

") + +out = render("page.1", "The \\m[blue]\\fBManual\\fR\\m[]\\s-2\\u[1]\\d\\s+2 here") +h.contains("DocBook's link colours and footnote marks draw nothing", out, + "

The Manual[1] here

") + +out = render("page.1", ".de x\n.B hidden\n.. \nshown") +h.contains("a definition ends at two dots with blanks after them", out, + "

shown

") + +out = render("page.1", ".TP\n.PD 0\n.B \\-a\nall\n.PD\nDon\\*(Aqt") +h.excludes("a spacing macro draws nothing", out, ">0") +h.contains("DocBook's apostrophe string expands", out, "Don't") + + out = render("page.1", '.\\" a comment\nvisible') h.excludes("a roff comment is dropped", out, "comment") h.contains("the line after it renders", out, "visible") -- cgit 2.12.1