diff options
Diffstat (limited to 'rst_context.lua')
-rw-r--r-- | rst_context.lua | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/rst_context.lua b/rst_context.lua index 0abcdc6..a46e0a2 100644 --- a/rst_context.lua +++ b/rst_context.lua @@ -740,7 +740,7 @@ function rst_context.option_item (tab) ]], tab[1], tab[2]) end -function rst_context.literal_block (str) +function rst_context.literal_block (str, included) local indent = P" "^1 local stripme = indent:match(str) or 0 @@ -758,13 +758,22 @@ function rst_context.literal_block (str) str = strip:match(str) --strip:print() -- grammar consists of 45 rules only; wheras a plain -- pattern has 60+ - return [[ + str = [[ -\\starttyping[lines=hyphenated] +\starttyping[lines=hyphenated] ]] .. str .. [[ -\\stoptyping +\stoptyping ]] + if included then -- escaping can ruin your day + return str:gsub("\\", "\\\\") + else + return str + end +end + +function rst_context.included_literal_block (str) + return rst_context.literal_block(str, true) end function rst_context.line_block (str) |