summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/third/rst/t-rst.mkiv
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/context/third/rst/t-rst.mkiv')
-rw-r--r--Master/texmf-dist/tex/context/third/rst/t-rst.mkiv80
1 files changed, 79 insertions, 1 deletions
diff --git a/Master/texmf-dist/tex/context/third/rst/t-rst.mkiv b/Master/texmf-dist/tex/context/third/rst/t-rst.mkiv
index 0359335d1bd..35ba054de2a 100644
--- a/Master/texmf-dist/tex/context/third/rst/t-rst.mkiv
+++ b/Master/texmf-dist/tex/context/third/rst/t-rst.mkiv
@@ -112,9 +112,29 @@
%D Thus, the user should never supply any of these manually,
%D neither before nor after \type{\typesetRSTfile}.
%D
+%D We now handle rogue utf-8 byte order marks on demand, just set
+%D the optional parameter \type{stripBOM} to {\em true}.
+%D
+%D There also is an option \type{expandtab} to convert tabs
+%D (ascii 0x09) to indents prior to converting reST input. The
+%D expansion width defaults to {\em 4} and can be configured
+%D through the parameter \type{shiftwidth} (takes an integer).
+%D
%D \showsetup{typesetRSTfile}
-\def\typesetRSTfile#1{\ctxlua{thirddata.rst.do_rst_file("#1")}}
+\def\do_typeset_RST_file[#1]#2{%
+ \iffirstargument
+ \getparameters[RST][#1]%
+ \doifdefined{RSTstripBOM} {\ctxlua{thirddata.rst.strip_BOM = \RSTstripBOM}}%
+ \doifdefined{RSTexpandtab} {\ctxlua{thirddata.rst.expandtab = \RSTexpandtab}}%
+ \doifdefined{RSTshiftwidth}{\ctxlua{thirddata.rst.shiftwidth = \RSTshiftwidth}}%
+ \fi
+ \ctxlua{thirddata.rst.do_rst_file("#2")}%
+}
+
+\def\typesetRSTfile{%
+ \dosingleempty\do_typeset_RST_file%
+}
%D \subsection{Typesetting Inline Snippets}
%D
@@ -158,6 +178,64 @@
\ctxlua{thirddata.rst.do_rst_snippet(\!!bs#1\!!es)}%
}
+%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{%
+ \dotripleempty\do_define_RST_inclusion%
+}
+
+\def\do_RST_inclusion[#1]{%
+ \iffirstargument
+ \ctxlua{thirddata.rst.get_rst_inclusion("#1")}%
+ \fi%
+}
+
+\def\do_RST_setups{%
+ \ctxlua{thirddata.rst.do_rst_setups()}%
+}
+
+\def\startRSTproject{
+ \begingroup
+ \def\RSTinclusion{\dosingleempty\do_RST_inclusion}
+ \do_RST_setups
+ \starttext%
+}
+
+\def\stopRSTproject{
+ \stoptext \endgroup \endinput
+}
+
\protect \endinput
% vim:ft=context:sw=2:ts=2