From 5009205ff9d52ef6018eda1bbb849de03b7ad621 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Mon, 31 Jan 2011 16:55:15 +0000 Subject: context-filter (30jan11) git-svn-id: svn://tug.org/texlive/trunk@21239 c570f23f-e606-0410-a88d-b1316a301751 --- .../texmf-dist/doc/context/third/filter/filter.txt | 21 ++++++- .../tex/context/third/filter/t-filter.tex | 71 +++++++++++++--------- 2 files changed, 60 insertions(+), 32 deletions(-) (limited to 'Master/texmf-dist') diff --git a/Master/texmf-dist/doc/context/third/filter/filter.txt b/Master/texmf-dist/doc/context/third/filter/filter.txt index 6723e0d14e6..7aad30d6ad6 100644 --- a/Master/texmf-dist/doc/context/third/filter/filter.txt +++ b/Master/texmf-dist/doc/context/third/filter/filter.txt @@ -261,7 +261,7 @@ and `after` options. These are executed before and after the output file is read using `readcommand`. Typically, these options are used to set the spacing around the environment or enclose the output in a frame, etc. -`\defineexternalfilter` also accepts a `setup` option to specify a list of +`\defineexternalfilter` also accepts a `setups` option to specify a list of setups (defined using `\startsetup`). These setups may be used to define commands that are needed inside the environment. @@ -360,7 +360,17 @@ Macro variant For some cases, a macro `\inline{...}` is more natural to use rather than the environment `\start` ... `\stop`. The `\inline...` variant is meant for simple cases, so it does not accept any options in square -brackets. +brackets. This macro is similar to `\type` macro, and its argument can be +written in two ways: either as a group `{...}` or delimited by arbitrary tokens. +Thus, all the following are valid: + + \defineexternalfilter[markdown][...] + + \inlinemarkdown{both braces{}} + + \inlinemarkdown+an opening brace {+ + + \inlinemarkdown!a closing brace }! @@ -457,4 +467,9 @@ Version History - **2010.10.30**: - Added `directory=...` option to `\defineexternalfilter` and `\setupexternalfilters`. - +- **2010.12.04**: + - Bugfix in `directory` code. The option `directory=../something` was + handled incorrectly. +- **2011.01.28** + - Bugfix. The filter counter was not incremented inside a group. Made the + increment global. diff --git a/Master/texmf-dist/tex/context/third/filter/t-filter.tex b/Master/texmf-dist/tex/context/third/filter/t-filter.tex index 5f7ba878e5c..6decb102466 100644 --- a/Master/texmf-dist/tex/context/third/filter/t-filter.tex +++ b/Master/texmf-dist/tex/context/third/filter/t-filter.tex @@ -1,6 +1,6 @@ %D \module %D [ file=t-filter, -%D version=2010.10.30 +%D version=2011.01.29, %D title=\CONTEXT\ User Module, %D subtitle=Filter, %D author=Aditya Mahajan, @@ -22,7 +22,7 @@ %D The first step is to set the interface variables. This allows me to use %D \type{\c!filter} etc. in the module definition, and thereby reduces the risk %D of a typo. Currently, only English names are provided. If someone wants, I -%D can also add other multi-linugal names. +%D can also add other multi-lingual names. \startinterface all \setinterfaceconstant {filter} {filter} @@ -40,6 +40,7 @@ \setinterfacemessage{externalfilter}{notfound} {file -- cannot be found} \setinterfacemessage{externalfilter}{missing} {output file missing} \setinterfacemessage{externalfilter}{forbidden} {Fatal Error: Cannot use absolute path -- as directory} +\setinterfacemessage{externalfilter}{slash} {Appending / to directory -- } %D \subsubject {Name space} %D @@ -49,15 +50,16 @@ %D \filename{mult-aux.mkiv}. But, that macro is not defined in \MKII; so I %D repeat simplified versions of the definitions here. -\def\??externalfilter??{externalfilter} +\def\????externalfilter{@@@@externalfilter} +\def\!!externalfilter {externalfilter} \def\currentexternalfilter{} -\def\externalfiltercountername{\??externalfilter??-\currentexternalfilter-counter} +\def\externalfiltercountername{\????externalfilter-\currentexternalfilter-counter} %D \subsubject {Read value of parameters} \def\externalfilterparameter#1% {\csname - \docheckparentparameter{\??externalfilter??\currentexternalfilter}{#1}% + \docheckparentparameter{\????externalfilter\currentexternalfilter}{#1}% \endcsname} \def\docheckparentparameter#1#2% @@ -107,9 +109,9 @@ \def\dosetupexternalfilters[#1][#2]% {\ifsecondargument - \getparameters[\??externalfilter??#1][#2]% + \getparameters[\????externalfilter#1][#2]% \else - \getparameters[\??externalfilter??][#1]% + \getparameters[\????externalfilter][#1]% \fi} @@ -121,7 +123,7 @@ \def\dodefineexternalfilter[#1][#2]% {\doshowfilterstatus{defining filter : #1}% \edef\currentexternalfilter{#1}% - \getparameters[\??externalfilter??#1][\s!parent=\??externalfilter??,#2]% + \getparameters[\????externalfilter#1][\s!parent=\????externalfilter,#2]% \doif{\externalfilterparameter\c!continue}\v!yes {\expandafter\newcounter\csname\externalfiltercountername\endcsname}% \setvalue{\e!start#1}{\bgroup\obeylines\dodoubleargument\dostartexternalfilter[#1]}% @@ -135,7 +137,7 @@ \egroup %\bgroup in \start#1 \edef\currentexternalfilter {#1}% \begingroup % to keep assignments local - \getparameters[\??externalfilter??#1][\c!name=,#2]% + \getparameters[\????externalfilter#1][\c!name=,#2]% \setexternalfilterfilenames % Capture the contents of the buffer \dostartbuffer[\externalfiltertmpfile][\e!start#1][\e!stop#1]} @@ -143,7 +145,7 @@ \def\doprocessexternalfilterfile[#1][#2]#3% {\begingroup \edef\currentexternalfilter {#1}% - \getparameters[\??externalfilter??#1][\c!name=,#2]% TODO: Add continue=yes + \getparameters[\????externalfilter#1][\c!name=,#2]% TODO: Add continue=yes % Currently filters with a pipe (|) fail with continue=yes \setexternalfilterdirectory \edef\externalfilterinputfile {#3}% @@ -159,9 +161,9 @@ \endgroup} \def\doinlineexternalfilter[#1]% - {\begingroup % to keep assignments local - \edef\currentexternalfilter {#1}% - \getparameters[\??externalfilter??#1][\c!name=,\c!continue=\v!no]% + {\edef\currentexternalfilter {#1}% + \begingroup % to keep assignments local + \getparameters[\????externalfilter#1][\c!name=,\c!continue=\v!no]% \setexternalfilterfilenames \pushcatcodetable \futurelet\next\dodoinlineexternalfilter} @@ -202,6 +204,19 @@ %D \section {Helper Functions} %D +%D \subsubject {First and last character of a string} + +\def\getfirstcharacter#1% + {\dogetfirstcharacter#1\relax} + +\def\dogetfirstcharacter#1#2\relax{#1} + +\def\getlastcharacter#1% + {\@EA\dogetlastcharacter#1\relax} + +\def\dogetlastcharacter#1#2% + {\ifx#2\relax#1\else\@EA\dogetlastcharacter\@EA#2\fi} + %D \subsubject {Set the name of output directory} \def\setexternalfilterdirectory @@ -209,18 +224,16 @@ \doifsomething{\getexternalfilterdirectory}\dosetexternalfilterdirectory} \def\dosetexternalfilterdirectory - {\expandafter\docheckdirectorystart\getexternalfilterdirectory\@nil - \expandafter\docheckdirectorystop\getexternalfilterdirectory/\@nil} - -\def\docheckdirectorystart#1#2\@nil - {\doif{#1}{/} + {\doif{\getfirstcharacter\getexternalfilterdirectory}{/} {\writeline - \showmessage\??externalfilter??{forbidden}\getexternalfilterdirectory + \showmessage\!!externalfilter{forbidden}\getexternalfilterdirectory \batchmode - \normalend}} - -\def\docheckdirectorystop#1#2/#3\@nil - {\edef\getexternalfilterdirectory{#1#2/}} + \errmessage{} + \normalend} + \doifnot{\getlastcharacter\getexternalfilterdirectory}{/} + {\showmessage\!!externalfilter{slash}\getexternalfilterdirectory + \edef\getexternalfilterdirectory{\getexternalfilterdirectory/}}} + %D \subsubject {Set file names} @@ -233,10 +246,10 @@ {\setexternalfilterdirectory % Set the name of temp file for the filter \doifelse{\externalfilterparameter\c!continue}\v!yes - {\edef\externalfiltertmpfile{\??externalfilter??-\currentexternalfilter-\csname\externalfiltercountername\endcsname}} - {\edef\externalfiltertmpfile{\??externalfilter??-\currentexternalfilter}} + {\edef\externalfiltertmpfile{\!!externalfilter-\currentexternalfilter-\csname\externalfiltercountername\endcsname}} + {\edef\externalfiltertmpfile{\!!externalfilter-\currentexternalfilter}} \doifsomething{\externalfilterparameter\c!name} - {\edef\externalfiltertmpfile{\externalfilterparameter\c!name}} + {\edef\externalfiltertmpfile{\!!externalfilter-\currentexternalfilter-\externalfilterparameter\c!name}} % The following macros are useful for filter= and filtercommand= options % The basename of the external file \edef\externalfilterbasefile {\jobname-\externalfiltertmpfile}% @@ -271,7 +284,7 @@ \endgroup % Finalization \doif{\externalfilterparameter\c!continue}\v!yes - {\expandafter\increment\csname\externalfiltercountername\endcsname}% + {\doglobal\expandafter\increment\csname\externalfiltercountername\endcsname}% } %D \subsubject {Execute Filter} @@ -292,9 +305,9 @@ {\doif{\externalfilterparameter\c!read}\v!yes {\doiffileelse{\externalfilteroutputfile} {\dodoreadprocessedfile} - {\showmessage\??externalfilter??{notfound}\externalfilteroutputfile + {\showmessage\!!externalfilter{notfound}\externalfilteroutputfile \blank - {\tttf [[\getmessage\??externalfilter??{missing}]]}% + {\tttf [[\getmessage\!!externalfilter{missing}]]}% \blank }}} -- cgit v1.2.3