summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mod/tex/context/interface/third/t-rst.xml38
-rw-r--r--mod/tex/context/third/rst/t-rst.mkiv31
2 files changed, 67 insertions, 2 deletions
diff --git a/mod/tex/context/interface/third/t-rst.xml b/mod/tex/context/interface/third/t-rst.xml
index cce4f3a..40015e2 100644
--- a/mod/tex/context/interface/third/t-rst.xml
+++ b/mod/tex/context/interface/third/t-rst.xml
@@ -42,4 +42,42 @@
</cd:sequence>
</cd:command>
+ <cd:command name="RSTproject" generated="no" type="environment" file="t-rst.mkiv">
+ <cd:sequence>
+ <cd:variable value="RST"/>
+ </cd:sequence>
+ </cd:command>
+
+ <cd:command name="defineRSTinclusion" generated="no" file="t-rst.mkiv">
+ <cd:sequence>
+ <cd:variable value="defineRSTinclusion"/>
+ </cd:sequence>
+ <cd:arguments>
+ <cd:content n="1" optional="yes" name="id"/>
+ <cd:content n="2" optional="yes" name="filename"/>
+ <cd:assignments n="3" list="yes" optional="yes">
+ <cd:parameter name="expandtab">
+ <cd:constant type="false" default="false"/>
+ <cd:constant type="true"/>
+ </cd:parameter>
+ <cd:parameter name="shiftwidth">
+ <cd:constant type="cd:number" default="4"/>
+ </cd:parameter>
+ <cd:parameter name="stripBOM">
+ <cd:constant type="false" default="false"/>
+ <cd:constant type="true"/>
+ </cd:parameter>
+ </cd:assignments>
+ </cd:arguments>
+ </cd:command>
+
+ <cd:command name="RSTinclusion" generated="no" file="t-rst.mkiv">
+ <cd:sequence>
+ <cd:variable value="RSTinclusion"/>
+ </cd:sequence>
+ <cd:arguments>
+ <cd:content n="1" optional="yes" name="id"/>
+ </cd:arguments>
+ </cd:command>
+
</cd:interface>
diff --git a/mod/tex/context/third/rst/t-rst.mkiv b/mod/tex/context/third/rst/t-rst.mkiv
index 7971e3f..35ba054 100644
--- a/mod/tex/context/third/rst/t-rst.mkiv
+++ b/mod/tex/context/third/rst/t-rst.mkiv
@@ -178,14 +178,41 @@
\ctxlua{thirddata.rst.do_rst_snippet(\!!bs#1\!!es)}%
}
-\def\do_define_RST_inclusion[#1][#2]{%
+%D \subsection{Including multiple reST files}
+%D
+%D \macros
+%D {defineRSTinclusion,startRSTproject,RSTinclusion}
+%D
+%D When content is split among multiple files, these macros allow
+%D for including them in arbitrary order. Note that setups from
+%D previous includes, unless overwritten, will remain defined.
+%D \type{\defineRSTinclusion} takes three arguments: the first one
+%D will be the identifier that can be used to refer to the actual
+%D inclusion, which is specified via the second argument as a
+%D filename. The third optional argument receives the usual
+%D setups \type{stripBOM}, \type{expandtab} and
+%D \type{shiftwidth}.
+%D
+%D Defined inclusions can be typeset only within an the
+%D \type{\startRSTproject} environment using the macro
+%D \type{RSTinclusion}. Between those inclusion all kinds of
+%D \TEX\ code except for \type{\starttext} and \type{\stoptext}
+%D are permitted.
+
+\def\do_define_RST_inclusion[#1][#2][#3]{%
+ \ifthirdargument
+ \getparameters[RST][#3]%
+ \doifdefined{RSTstripBOM} {\ctxlua{thirddata.rst.strip_BOM = \RSTstripBOM}}%
+ \doifdefined{RSTexpandtab} {\ctxlua{thirddata.rst.expandtab = \RSTexpandtab}}%
+ \doifdefined{RSTshiftwidth}{\ctxlua{thirddata.rst.shiftwidth = \RSTshiftwidth}}%
+ \fi
\ifsecondargument
\ctxlua{thirddata.rst.do_rst_inclusion("#1", "#2")}%
\fi%
}
\def\defineRSTinclusion{%
- \dodoubleempty\do_define_RST_inclusion%
+ \dotripleempty\do_define_RST_inclusion%
}
\def\do_RST_inclusion[#1]{%