summaryrefslogtreecommitdiff
path: root/rst_context.lua
diff options
context:
space:
mode:
authorPhilipp Gesang <pgesang@ix.urz.uni-heidelberg.de>2010-09-16 15:33:22 +0200
committerPhilipp Gesang <pgesang@ix.urz.uni-heidelberg.de>2010-09-16 15:33:22 +0200
commit65bee7f493520e0dc75084f2dc68c52e6a5521d1 (patch)
treecd1e6837ad849bf888582cc8cceb0510a9c4c4df /rst_context.lua
parent853269887cbef331d95e5cb410ac4f6110a3cee4 (diff)
downloadcontext-rst-65bee7f493520e0dc75084f2dc68c52e6a5521d1.tar.gz
fixed literal blocks inside paragraphs
Diffstat (limited to 'rst_context.lua')
-rw-r--r--rst_context.lua17
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)