Diff options
| author | Bryce Kwon <bryce@brycekwon.com> | |
|---|---|---|
| committer | Bryce Kwon <bryce@brycekwon.com> | |
| commit | ||
| parent | ||
| tree | ||
| download | ||
Drop the readme hooks that nothing reads
Nothing in assets/ or in README's list of hooks reads a fenced block's
data-lang or the manpage class on a man page's wrapper, so the header
now names the two wrappers the stylesheet does style.
Diffstat (limited to '')
| -rw-r--r-- | custom/extensions/about-render.lua | 21 | |
| -rw-r--r-- | tests/extensions/test-about-render.lua | 9 | |
| -rwxr-xr-x | tests/t0501-about-render.sh | 2 |
3 files changed, 12 insertions, 20 deletions
diff --git a/custom/extensions/about-render.lua b/custom/extensions/about-render.lua index 808dd08..9474225 100644 --- a/custom/extensions/about-render.lua +++ b/custom/extensions/about-render.lua @@ -3,8 +3,9 @@ -- interpreter so a readme costs no extra process per request. Markdown, man -- pages and plain text are the three formats, chosen from the readme's file -- extension, and anything that fails to parse falls back to escaped plain --- text. The wrappers it emits carry the classes that assets/cgit.css styles. --- It runs on Lua 5.1 through 5.5 and LuaJIT. +-- text. Markdown and man pages come out in div.markdown and plain text in +-- pre.plaintext, the two wrappers assets/cgit.css styles. It runs on Lua 5.1 +-- through 5.5 and LuaJIT. -- -- about-filter=lua:/usr/local/lib/cgit/filters/about-render.lua @@ -285,13 +286,7 @@ emit_blocks = function(blocks) elseif kind == "hr" then html("<hr>") elseif kind == "code" then - html("<pre><code") - if block.lang and block.lang ~= "" then - html(" data-lang='") - html_attr(block.lang) - html("'") - end - html(">") + html("<pre><code>") html_txt(block.text) html("</code></pre>") elseif kind == "blockquote" then @@ -452,7 +447,6 @@ if has_lpeg then return nodes end - local lang_char = R("az", "AZ", "09") + S("_.+#-") local heading_line = C(P("#") * P("#") ^ -5) * space ^ 1 * C(P(1) ^ 0) -- A run of equals signs or dashes under a paragraph turns it into a -- heading, as on GitHub, rather than reading as more of its text. @@ -463,7 +457,7 @@ if has_lpeg then return space ^ 0 * P(mark) * (space ^ 0 * P(mark)) ^ 2 * space ^ 0 * eol end local break_line = thematic("-") + thematic("*") + thematic("_") - local fence_line = space ^ 0 * (C(P("`") ^ 3) + C(P("~") ^ 3)) * space ^ 0 * C(lang_char ^ 0) + local fence_line = space ^ 0 * (C(P("`") ^ 3) + C(P("~") ^ 3)) local close_backtick = space ^ 0 * P("`") ^ 3 * space ^ 0 * eol local close_tilde = space ^ 0 * P("~") ^ 3 * space ^ 0 * eol local quote_line = space ^ 0 * P(">") @@ -548,7 +542,7 @@ if has_lpeg then local blocks, i, n = {}, 1, #lines while i <= n do local line = lines[i] - local fence, lang = fence_line:match(line) + local fence = fence_line:match(line) local hashes, title = heading_line:match(line) local mark = item_line:match(line) if line:match("^%s*$") then @@ -568,7 +562,6 @@ if has_lpeg then end blocks[#blocks + 1] = { kind = "code", - lang = lang, text = body, } elseif hashes then @@ -1007,7 +1000,7 @@ if has_lpeg then if not ok then return render_plaintext(text) end - html("<div class='markdown manpage'>") + html("<div class='markdown'>") pcall(emit_blocks, blocks) html("</div>") end diff --git a/tests/extensions/test-about-render.lua b/tests/extensions/test-about-render.lua index 88c136c..b744e95 100644 --- a/tests/extensions/test-about-render.lua +++ b/tests/extensions/test-about-render.lua @@ -219,8 +219,7 @@ out = render("README.md", "[](y)\n\n\ntext") h.contains("a paragraph of badges leaves nothing behind", out, "<div class='markdown'><p>text</p></div>") out = render("README.md", "```lua\nlocal x = 1 < 2\n```\nafter") -h.contains("a fenced block carries its language", out, - "<pre><code data-lang='lua'>local x = 1 < 2\n</code></pre>") +h.contains("a fenced block renders as code", out, "<pre><code>local x = 1 < 2\n</code></pre>") h.contains("text after the fence renders on", out, "<p>after</p>") out = render("README.md", "~~~\n**not bold**\n~~~") @@ -329,7 +328,7 @@ h.contains("an oversized readme renders as plain text", out, "<pre class='plaint -- Man pages. out = render("page.1", ".SH NAME") -h.contains("a section heading renders", out, "<div class='markdown manpage'><h2 id='name'>NAME</h2></div>") +h.contains("a section heading renders", out, "<div class='markdown'><h2 id='name'>NAME</h2></div>") out = render("page.man", '.SH "TWO WORDS"') h.contains("a quoted heading argument is unquoted", out, "<h2 id='two-words'>TWO WORDS</h2>") @@ -393,7 +392,7 @@ h.contains("text after the definitions renders", out, "<p>after</p>") 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, - "<div class='markdown manpage'><p>after</p></div>") + "<div class='markdown'><p>after</p></div>") 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, @@ -401,7 +400,7 @@ h.contains("DocBook's link colours and footnote marks draw nothing", out, out = render("page.1", ".de x\n.B hidden\n.. \nshown") h.contains("a definition ends at two dots with blanks after them", out, - "<div class='markdown manpage'><p>shown</p></div>") + "<div class='markdown'><p>shown</p></div>") 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") diff --git a/tests/t0501-about-render.sh b/tests/t0501-about-render.sh index 339c5e2..222ddfd 100755 --- a/tests/t0501-about-render.sh +++ b/tests/t0501-about-render.sh @@ -115,7 +115,7 @@ test_expect_success CGIT_LUA_LPEG 'the link stays on the branch shown' ' test_expect_success CGIT_LUA_LPEG 'the about page renders a man page' ' cgit_url "man/about/" >tmp && - grep "<div class=.markdown manpage.><h2 id=.name.>NAME</h2>" tmp && + grep "<div class=.markdown.><h2 id=.name.>NAME</h2>" tmp && grep "tool - does one thing — well" tmp && grep "<strong>-v</strong><br>" tmp && grep "<pre><code>tool -v <file>" tmp && |
