summaryrefslogtreecommitdiff
path: root/mod/tex/context/third/rst/rst_parser.lua
diff options
context:
space:
mode:
authorPhilipp Gesang <pgesang@ix.urz.uni-heidelberg.de>2011-01-04 23:20:58 +0100
committerPhilipp Gesang <pgesang@ix.urz.uni-heidelberg.de>2011-01-04 23:20:58 +0100
commit9d00a058df52d261861fcc7a9d4dd6474a5f7f53 (patch)
tree4bd03ec65f73b851605661f9041b0e41fe057333 /mod/tex/context/third/rst/rst_parser.lua
parent3ffabd8881aaeaeb1d159f89ca1e7dec46d0954d (diff)
downloadcontext-rst-9d00a058df52d261861fcc7a9d4dd6474a5f7f53.tar.gz
macros for inline reST parsing
Diffstat (limited to 'mod/tex/context/third/rst/rst_parser.lua')
-rw-r--r--mod/tex/context/third/rst/rst_parser.lua32
1 files changed, 27 insertions, 5 deletions
diff --git a/mod/tex/context/third/rst/rst_parser.lua b/mod/tex/context/third/rst/rst_parser.lua
index 580204c..ba9b4c8 100644
--- a/mod/tex/context/third/rst/rst_parser.lua
+++ b/mod/tex/context/third/rst/rst_parser.lua
@@ -1361,7 +1361,7 @@ local function save_file (name, data)
return 0
end
-local function get_setups ()
+local function get_setups (inline)
local optional_setups = optional_setups -- might expect lots of calls
local setups = [[
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -1391,7 +1391,7 @@ local function get_setups ()
local f = optional_setups[item]
setups = f and setups .. f() or setups
end
- return setups .. [[
+ setups = setups .. [[
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -1400,8 +1400,11 @@ local function get_setups ()
%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-\starttext
]]
+ if not inline then
+ setups = setups .. "\n\\starttext"
+ end
+ return setups
end
local function main()
@@ -1440,11 +1443,11 @@ do
strip_comments = Cs((comment + 1)^0)
end
-function do_rst_file(fname)
+function rst.do_rst_file(fname)
local rst_parser = parser
local raw_data = load_file(fname)
local processed = rst_parser:match(raw_data)
- local setups = get_setups()
+ local setups = get_setups(false)
local tmp_file = tex.jobname .. "–rst_temporary.tex.tmp"
if processed then
@@ -1454,6 +1457,25 @@ function do_rst_file(fname)
end
end
+function rst.do_rst_snippet(txt)
+ local processed = parser:match(txt)
+ local setups = get_setups(true)
+ local tmp_file = tex.jobname .. "–rst_temporary.tex.tmp"
+
+ if processed then
+ warn("·cs·",txt)
+ processed = strip_comments:match(setups..processed)
+ save_file (tmp_file,processed)
+ context.input("./"..tmp_file)
+ else
+ warn("·cs·",txt)
+ context.par()
+ context("{\\bf context-rst could not process snippet.\\par}")
+ context.type(txt)
+ context.par()
+ end
+end
+
if not context then
return main()