Diff options
| author | ||
|---|---|---|
| committer | ||
| commit | ||
| parent | ||
| tree | ||
| download | ||
Carry a man page's text as plain strings
lpeg's constant, query and numbered captures already do what the token
helpers did, and nothing ever read the tokens of an escape that draws
nothing.
| -rw-r--r-- | custom/extensions/about-render.lua | 39 |
1 file changed, 16 insertions, 23 deletions
diff --git a/custom/extensions/about-render.lua b/custom/extensions/about-render.lua index c498ad8..5738b00 100644 --- a/custom/extensions/about-render.lua +++ b/custom/extensions/about-render.lua @@ -706,15 +706,8 @@ if has_lpeg then } local backslash = P("\\") - local function text_token(text) return { kind = "text", text = text } end - local skip_token = { kind = "skip" } - local function skip() return skip_token end local function font_token(name) - return { kind = "font", font = fonts[name] or "R" } - end - local function char_token(name) return text_token(man_chars[name] or "") end - local function string_token(name) - return text_token(man_strings[name] or "") + return { font = fonts[name] or "R" } end -- \( takes a two character name and \[ a longer one, bounded so that a @@ -727,18 +720,18 @@ if has_lpeg then -- the escapes that only steer hyphenation or breaks. local man_inline_grammar = Ct(( (backslash * P("f") * (named + C(P(1)))) / font_token - + (backslash * S('"#') * P(1) ^ 0) / skip - + (backslash * P("-")) / function() return text_token("-") end - + (backslash * P("e")) / function() return text_token("\\") end - + (backslash * S(" 0~")) / function() return text_token(" ") end - + (backslash * S("&|^%:cud{}")) / skip - + (backslash * named) / char_token - + (backslash * P("*") * (named + C(P(1)))) / string_token - + (backslash * P("s") * S("+-") ^ -1 * (named + digit * digit ^ -1)) / skip - + (backslash * S("mM") * (named + P(1))) / skip - + (backslash * C(P(1))) / text_token - + backslash / skip - + C((1 - backslash) ^ 1) / text_token + + backslash * S('"#') * P(1) ^ 0 + + (backslash * P("-")) / "-" + + (backslash * P("e")) / "\\" + + (backslash * S(" 0~")) / " " + + backslash * S("&|^%:cud{}") + + (backslash * named) / man_chars + + (backslash * P("*") * (named + C(P(1)))) / man_strings + + (backslash * P("s") * S("+-") ^ -1 * (named + digit * digit ^ -1)) / 0 + + (backslash * S("mM") * (named + P(1))) / 0 + + backslash * C(P(1)) + + backslash + + C((1 - backslash) ^ 1) ) ^ 0) local function in_font(font, nodes) @@ -761,9 +754,9 @@ if has_lpeg then end end for _, token in ipairs(tokens) do - if token.kind == "text" then - parts[#parts + 1] = token.text - elseif token.kind == "font" then + if type(token) == "string" then + parts[#parts + 1] = token + else flush() font = token.font end |
