summaryrefslogtreecommitdiff
path: root/mod/tex/context/third/rst/t-rst.mkiv
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/t-rst.mkiv
parent3ffabd8881aaeaeb1d159f89ca1e7dec46d0954d (diff)
downloadcontext-rst-9d00a058df52d261861fcc7a9d4dd6474a5f7f53.tar.gz
macros for inline reST parsing
Diffstat (limited to 'mod/tex/context/third/rst/t-rst.mkiv')
-rw-r--r--mod/tex/context/third/rst/t-rst.mkiv53
1 files changed, 52 insertions, 1 deletions
diff --git a/mod/tex/context/third/rst/t-rst.mkiv b/mod/tex/context/third/rst/t-rst.mkiv
index e76d3db..ffcd839 100644
--- a/mod/tex/context/third/rst/t-rst.mkiv
+++ b/mod/tex/context/third/rst/t-rst.mkiv
@@ -37,6 +37,57 @@
\setupreST [ ]
%D This command loads and processes the \type{*.rst} file.
-\def\typesetRSTfile#1{\ctxlua{do_rst_file("#1")}}
+\def\typesetRSTfile#1{\ctxlua{rst.do_rst_file("#1")}}
+
+%D To process inline reST markup we’ll have to reset all catcodes
+%D except for grouping, escaping and cs arguments.
+\ifdefined\RSTcatcodes \else
+ \newcatcodetable \RSTcatcodes
+ \startcatcodetable \RSTcatcodes
+ \catcode`\^^I = 12 % ascii tab is a blank space
+ \catcode`\^^M = 12 % ascii return is end-line
+ \catcode`\^^L = 12 % ascii form-feed
+ \catcode`\ = 10 % ascii space is blank space
+ \catcode`\^^Z = 12
+ \catcode`\\ = 0
+ \catcode`\% = 12
+ \catcode`\# = 6
+ \catcode`\_ = 12
+ \catcode`\^ = 12
+ \catcode`\& = 12
+ \catcode`\| = 12
+ \catcode`\{ = 1
+ \catcode`\} = 2
+ \catcode`\~ = 12
+ \catcode`\$ = 12
+ \stopcatcodetable
+\fi
+
+%D The environment \type{\[start|stop]RST} and the macro
+%D \type{\RST} allow access to reST-parser from inside a
+%D \CONTEXT-document when the module is loaded.
+\unexpanded\def\startRST{
+ \setcatcodetable \RSTcatcodes%
+ \dostartRST%
+}
+
+\let\stopRST\relax
+
+\def\dostartRST#1\stopRST{%
+ \edef\RSTdata{#1}%
+ \setcatcodetable \ctxcatcodes%
+ \ctxlua{rst.do_rst_snippet([[\RSTdata]])}%
+}
+
+\def\RST{%
+ \setcatcodetable \RSTcatcodes%
+ \doRST%
+}
+
+\def\doRST#1{%
+ \def\RSTdata{#1}%
+ \setcatcodetable \ctxcatcodes%
+ \ctxlua{rst.do_rst_snippet([[\RSTdata]])}%
+}
\protect \endinput