diff options
Diffstat (limited to 'rst_helpers.lua')
-rw-r--r-- | rst_helpers.lua | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/rst_helpers.lua b/rst_helpers.lua index 92f41a2..d70e247 100644 --- a/rst_helpers.lua +++ b/rst_helpers.lua @@ -594,19 +594,22 @@ do whitespace = S" \t\v" + P"\n" / function() linelength = 0 end, nowhitespace = 1 - V"whitespace", ignore = P[[\\type{]] * (1 - P"}")^0 * P"}", + -- the initial whitespace of the “other” pattern must not be + -- enforced (“^1”) as it will break the exceptions (“ignore” + -- pattern)! In general it is better to have the wrapper ignore some + -- valid breaks than to not have it matching some valid strings at + -- all. other = Cmt(V"whitespace"^0 * (V"ignore" + (1 - V"whitespace")^1), function(s,i,w) linelength = linelength + ulen(w) return true end), wrapme = Cmt(V"whitespace"^1 * (1 - V"whitespace" - V"ignore")^1, function(s,i,w) local lw = ulen(w) - print(w) if linelength + lw > width then linelength = lw return true end return false - --end) / function (word) return "\n" .. match(V"whitespace"^1 * C((1 - V"whitespace")^1), word) end, end) / function (word) return "\n" .. word:match("[^%s]+") end, } |