diff options
author | Philipp Gesang <pgesang@ix.urz.uni-heidelberg.de> | 2011-05-08 17:07:24 +0200 |
---|---|---|
committer | Philipp Gesang <pgesang@ix.urz.uni-heidelberg.de> | 2011-05-08 17:07:24 +0200 |
commit | 3f33e70656de07a55c014276a23814d1dd968229 (patch) | |
tree | 240101bf4e8fc213e6627ce29293fd45e641dc26 /mod/tex | |
parent | 3f0ea559afbbfbe7c4642df946a2407800d29c68 (diff) | |
download | context-rst-3f33e70656de07a55c014276a23814d1dd968229.tar.gz |
xml interface; extended module documentation
Diffstat (limited to 'mod/tex')
-rw-r--r-- | mod/tex/context/interface/third/t-rst.xml | 32 | ||||
-rw-r--r-- | mod/tex/context/third/rst/rst_setups.lua | 1 | ||||
-rw-r--r-- | mod/tex/context/third/rst/t-rst.mkiv | 106 |
3 files changed, 114 insertions, 25 deletions
diff --git a/mod/tex/context/interface/third/t-rst.xml b/mod/tex/context/interface/third/t-rst.xml new file mode 100644 index 0000000..52a9380 --- /dev/null +++ b/mod/tex/context/interface/third/t-rst.xml @@ -0,0 +1,32 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes"?> + +<cd:interface xmlns:cd="http://www.pragma-ade.com/commands" + name="context" + language="en" + version="0.4; 2011-05-08 15:08:34+0200"> + + <cd:command name="typesetRSTfile" generated="no" file="t-rst.mkiv"> + <cd:sequence> + <cd:variable value="typesetRSTfile"/> + </cd:sequence> + <cd:arguments> + <cd:content n="1" optional="no"/> + </cd:arguments> + </cd:command> + + <cd:command name="RST" generated="no" file="t-rst.mkiv"> + <cd:sequence> + <cd:variable value="RST"/> + </cd:sequence> + <cd:arguments> + <cd:content n="1" optional="no"/> + </cd:arguments> + </cd:command> + + <cd:command name="RST" generated="no" type="environment" file="t-rst.mkiv"> + <cd:sequence> + <cd:variable value="RST"/> + </cd:sequence> + </cd:command> + +</cd:interface> diff --git a/mod/tex/context/third/rst/rst_setups.lua b/mod/tex/context/third/rst/rst_setups.lua index c10a914..102652b 100644 --- a/mod/tex/context/third/rst/rst_setups.lua +++ b/mod/tex/context/third/rst/rst_setups.lua @@ -208,6 +208,7 @@ function optional_setups.breaks () % Fancy transitions % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Get Wolfgang’s module at <https://bitbucket.org/wolfs/fancybreak>. \usemodule[fancybreak] \setupfancybreak[symbol=star] ]] diff --git a/mod/tex/context/third/rst/t-rst.mkiv b/mod/tex/context/third/rst/t-rst.mkiv index a332df9..0359335 100644 --- a/mod/tex/context/third/rst/t-rst.mkiv +++ b/mod/tex/context/third/rst/t-rst.mkiv @@ -1,6 +1,6 @@ %D \module [ %D file=t-rst, -%D version=0.3 ‘How to Recognise Different Types of Trees from Quite a Long Way Away’ +%D version=0.4 ‘Owl-stretching time’ %D title=\CONTEXT\ User Module, %D subtitle=reStructuredText, %D author=Philipp Gesang, @@ -9,50 +9,74 @@ %D license=2-clause BSD, %D ] -%M \usemodule[rst] -%M \loadsetups[t-rst.xml] +%M \usemodule [rst] +%M \usemodule [int-load] +%M \loadsetups [t-letterspace.xml] + +%C Read the license conditions in the file \type{COPYING}. + +%M \definecolor [gutenred] [x=bf221f] % rubrication from digitized Göttingen Gutenberg bible +%M \setupinteraction [contrastcolor=gutenred,color=gutenred] +%M +%M \define\beautifyshowsetups{% +%M \unexpanded \def \setupnumfont {\rm}% +%M \unexpanded \def \setuptxtfont {\rm}% +%M \unexpanded \def \setupintfont {\rm\sc\Word}% +%M \unexpanded \def \setupvarfont {\rm\it}% +%M \unexpanded \def \setupoptfont {\rm\it}% +%M \unexpanded \def \setupalwcolor {gutenred}% +%M \unexpanded \def \setupoptcolor {gutenred}% +%M \defineframedtext [setuptext] [ +%M frame=off, +%M background=color, +%M backgroundcolor=gray:2, +%M width=\hsize, +%M height=fit, +%M align=right, +%M offset=0.75em, +%M ]% +%M } +%M +%M \let \Oldshowsetup \showsetup +%M +%M \define [1] \showsetup {% +%M \bgroup \beautifyshowsetups% +%M \Oldshowsetup{#1}% +%M \egroup% +%M } \writestatus{loading}{ConTeXt User Module / reStructuredText} + \unprotect \startinterface all \setinterfacevariable {RST} {RST} \stopinterface -\definenamespace [RST] [ +\definenamespace [\v!RST] [ type=module, comment=reStructuredText module, - version=0.3, - name=RST, - style=no, - command=yes, - setup=list, - parent=RST, + version=0.4, + name=\v!RST, + style=\v!no, + command=\v!yes, + setup=\v!list, + parent=\v!RST, ] %D Loading the reStructuredText parser. \ctxloadluafile{rst_parser} +%D Easy way to define a global test setting. Activated +%D by \type{\usemodule[rst][test=yes]}. + \startmoduletestsection \ctxlua{thirddata.rst_helpers.rst_debug = true} \stopmoduletestsection -%%% Leaving this here in case we need to revert to locally -%%% toggling debugging code. - -%\def\RST_enable_verbose{% - %\doif{\RSTparameter{debug}}\v!yes\ctxlua{thirddata.rst_helpers.rst_debug = true}% -%} -%\appendtoks \RST_enable_verbose \to \everysetupRST - -%D Setting some globals. -%\setupRST [debug=no] - -%D This command loads and processes the \type{*.rst} file. -\def\typesetRSTfile#1{\ctxlua{thirddata.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. + \newcatcodetable \RST_catcodes \startcatcodetable \RST_catcodes \catcode`\^^I = 12 @@ -73,11 +97,43 @@ \catcode`\$ = 12 \stopcatcodetable +%D \section {User-level Commands} +%D +%D \subsection{Typesetting reST-Files} +%D +%D \macros +%D {typesetRSTfile} +%D +%D This command loads and processes an \type{*.rst} file. +%D All necessary setups for the elements to be used (e.g. tables) +%D have to be specified {\em before} this macro is called. +%D As \type{\typesetRSTfile} is intended to process a single file +%D only, it will handle \type{\start|stoptext} automatically. +%D Thus, the user should never supply any of these manually, +%D neither before nor after \type{\typesetRSTfile}. +%D +%D \showsetup{typesetRSTfile} + +\def\typesetRSTfile#1{\ctxlua{thirddata.rst.do_rst_file("#1")}} + +%D \subsection{Typesetting Inline Snippets} +%D +%D reST markup can be handy in situations where \CONTEXT\ markup +%D would result in unappropriately verbose source code, e.g. when +%D typesetting tables with simple layout. +%D +%D \macros +%D {RST,startRST} +%D %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. +%D \CONTEXT\ document when the module is loaded. +%D +%D \showsetup{RST} +%D \showsetup{startRST} % Wolfgang’s code below. + \unexpanded \def \startRST{% \begingroup \setcatcodetable \RST_catcodes |