diff options
Diffstat (limited to '')
-rw-r--r--custom/extensions/about-render.lua13
1 file changed, 9 insertions, 4 deletions
diff --git a/custom/extensions/about-render.lua b/custom/extensions/about-render.lua
index 4e4b50b..73b1336 100644
--- a/custom/extensions/about-render.lua
+++ b/custom/extensions/about-render.lua
@@ -291,7 +291,7 @@ end
local render_markdown, render_man
if has_lpeg then
- local P, R, S, C, Ct = lpeg.P, lpeg.R, lpeg.S, lpeg.C, lpeg.Ct
+ local P, R, S, B, C, Ct = lpeg.P, lpeg.R, lpeg.S, lpeg.B, lpeg.C, lpeg.Ct
local space = S(" \t")
local whitespace = S(" \t\r\n\f\v")
@@ -345,6 +345,11 @@ if has_lpeg then
local address = (alnum + S(".!#$%&'*+/=?^_`{|}~-")) ^ 1
* P("@") * alnum * (alnum + S(".-")) ^ 0
+ -- An underscore inside a word belongs to the word, as in snake_case,
+ -- so it neither opens nor closes emphasis.
+ local word = alnum + R("\128\255")
+ local inner = B(word) * P("_") ^ 1 * #word
+
-- A character reference passes through for the browser to decode,
-- within CommonMark's lengths. Its shape leaves no room for markup, and
-- a name the browser does not know shows as written.
@@ -370,10 +375,10 @@ if has_lpeg then
+ (P("!") * label * target) / node_image
+ (label * target) / node_link
+ (P("**") * C((1 - P("**")) ^ 1) * P("**")) / node_strong
- + (P("__") * C((1 - P("__")) ^ 1) * P("__")) / node_strong
+ + (-B(word) * P("__") * C((inner + (1 - P("__"))) ^ 1) * P("__") * -word) / node_strong
+ (P("*") * C((1 - whitespace) * (1 - P("*")) ^ 0) * P("*")) / node_em
- + (P("_") * C((1 - whitespace) * (1 - P("_")) ^ 0) * P("_")) / node_em
- + C((1 - marker) ^ 1) / node_text
+ + (-B(word) * P("_") * C((1 - whitespace) * (inner + (1 - P("_"))) ^ 0) * P("_") * -word) / node_em
+ + C((1 - marker + inner) ^ 1) / node_text
+ C(P(1)) / node_text
) ^ 0)