From 179a0c039f3817ff5b312c03b7919238a2e6ed9b Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Thu, 29 Oct 2026 14:37:26 -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. 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/t0501-about-render.sh | 43 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) (limited to 'tests/t0501-about-render.sh') diff --git a/tests/t0501-about-render.sh b/tests/t0501-about-render.sh index 263c79b..339c5e2 100755 --- a/tests/t0501-about-render.sh +++ b/tests/t0501-about-render.sh @@ -39,7 +39,20 @@ test_expect_success 'create a repository with a markdown readme' ' See the [roadmap](ROADMAP.md#plan). EOF - git add README.md && + cat >tool.1 <<-\EOF && + .TH TOOL 1 + .SH NAME + tool \- does one thing \(em well + .SH OPTIONS + .TP + .B \-v + Be \fIverbose\fR. + .nf + tool \-v + .fi + EOF + echo "Plain notes & more" >NOTES && + git add README.md tool.1 NOTES && git commit -m "add readme" && git branch next ) @@ -53,11 +66,20 @@ test_expect_success 'point cgit at it through the about filter' ' repo.path=$PWD/repos/md/.git repo.readme=:README.md repo.about-filter=lua:$EXTENSIONS_DIRECTORY/about-render.lua + repo.url=man + repo.path=$PWD/repos/md/.git + repo.readme=:tool.1 + repo.about-filter=lua:$EXTENSIONS_DIRECTORY/about-render.lua + repo.url=txt + repo.path=$PWD/repos/md/.git + repo.readme=:NOTES + repo.about-filter=lua:$EXTENSIONS_DIRECTORY/about-render.lua EOF ' if test "$CGIT_HAS_LUA" -eq 1 then + test_set_prereq CGIT_LUA if cgit_lua_probe "$PWD/repos/md/.git" lpeg then test_set_prereq CGIT_LUA_LPEG @@ -91,10 +113,27 @@ test_expect_success CGIT_LUA_LPEG 'the link stays on the branch shown' ' grep "roadmap" tmp ' +test_expect_success CGIT_LUA_LPEG 'the about page renders a man page' ' + cgit_url "man/about/" >tmp && + grep "

NAME

" tmp && + grep "tool - does one thing — well" tmp && + grep "-v
" tmp && + grep "
tool -v <file>" tmp &&
+	! grep "\\\\f" tmp
+'
+
+test_expect_success CGIT_LUA 'the about page shows plain text as it is' '
+	cgit_url "txt/about/" >tmp &&
+	grep "
Plain <b>notes</b> & more" tmp
+'
+
 test_expect_success CGIT_LUA_NOLPEG 'without lpeg the readme is served escaped' '
 	cgit_url "md/about/" >tmp &&
 	grep "
" tmp &&
-	grep "# The Title" tmp
+	grep "# The Title" tmp &&
+	cgit_url "man/about/" >tmp &&
+	grep "
" tmp &&
+	grep ".SH NAME" tmp
 '
 
 test_done
-- 
cgit