From 65bee7f493520e0dc75084f2dc68c52e6a5521d1 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Thu, 16 Sep 2010 15:33:22 +0200 Subject: fixed literal blocks inside paragraphs --- rst_context.lua | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'rst_context.lua') 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) -- cgit v1.2.3