summaryrefslogtreecommitdiff
path: root/Master
diff options
context:
space:
mode:
Diffstat (limited to 'Master')
-rw-r--r--Master/texmf-dist/doc/context/third/filter/filter.txt8
-rw-r--r--Master/texmf-dist/tex/context/third/filter/t-filter.tex121
2 files changed, 67 insertions, 62 deletions
diff --git a/Master/texmf-dist/doc/context/third/filter/filter.txt b/Master/texmf-dist/doc/context/third/filter/filter.txt
index 7aad30d6ad6..942882d89d6 100644
--- a/Master/texmf-dist/doc/context/third/filter/filter.txt
+++ b/Master/texmf-dist/doc/context/third/filter/filter.txt
@@ -268,12 +268,12 @@ commands that are needed inside the environment.
The order in which these options are executed is:
\def\dodoreadprocessedfile
- {\bgroup
- \externalfilterparameter\c!before
+ {\externalfilterparameter\c!before
+ \begingroup
\processcommacommand[\externalfilterparameter\c!setups]\directsetup
\externalfilterparameter\c!readcommand\externalfilteroutputfile
- \externalfilterparameter\c!after
- \egroup}
+ \endgroup
+ \externalfilterparameter\c!after}
Options to a specific environment
---------------------------------
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 6decb102466..b9ec5d5e5f2 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=2011.01.29,
+%D version=2011.02.05,
%D title=\CONTEXT\ User Module,
%D subtitle=Filter,
%D author=Aditya Mahajan,
@@ -43,38 +43,16 @@
\setinterfacemessage{externalfilter}{slash} {Appending / to directory -- }
%D \subsubject {Name space}
-%D
-%D I use the name space \type{externalfilter} for all variables. A lot of this
-%D code comes from Wolfgang Schuster and is also implemented in
-%D \filename{mult-aux.mkiv}. I could just call \type{\installnamespace} macro from
-%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}
-%D \subsubject {Read value of parameters}
-
-\def\externalfilterparameter#1%
- {\csname
- \docheckparentparameter{\????externalfilter\currentexternalfilter}{#1}%
- \endcsname}
-
-\def\docheckparentparameter#1#2%
- {\ifcsname#1#2\endcsname
- #1#2%
- \else
- \expandafter\redocheckparentparameter\csname#1\s!parent\endcsname{#2}%
- \fi}
+\ifx\undefined\normalexpanded \let\normalexpanded\expanded \fi
-\def\redocheckparentparameter#1#2%
- {\ifx#1\relax
- \s!empty
- \else
- \docheckparentparameter{#1}{#2}%
- \fi}
+\installparameterhandler \????externalfilter \!!!!externalfilter
+\installsetuphandler \????externalfilter {externalfilters} %Note the plural
%D \section {Tracing Macros}
@@ -101,19 +79,6 @@
\stoptexdefinition
%D \section {The main user macros}
-%D
-%D \subsubject {Setup values of parameters}
-
-\def\setupexternalfilters
- {\dodoubleargument\dosetupexternalfilters}
-
-\def\dosetupexternalfilters[#1][#2]%
- {\ifsecondargument
- \getparameters[\????externalfilter#1][#2]%
- \else
- \getparameters[\????externalfilter][#1]%
- \fi}
-
%D \subsubject {Define a new filter}
@@ -145,12 +110,12 @@
\def\doprocessexternalfilterfile[#1][#2]#3%
{\begingroup
\edef\currentexternalfilter {#1}%
- \getparameters[\????externalfilter#1][\c!name=,#2]% TODO: Add continue=yes
- % Currently filters with a pipe (|) fail with continue=yes
+ \getparameters[\????externalfilter#1][\c!name=,\c!continue=\v!yes,#2]%
+ %NOTE: Currently filters with a pipe (|) fail with continue=yes
\setexternalfilterdirectory
\edef\externalfilterinputfile {#3}%
- \splitfiletype {#3}%
- %BEWARE. \edef doesn not work
+ \splitfilename {#3}%
+ %NOTE: \edef doesn not work
\def\externalfilterbasefile {\splitoffname}%
% The output is always in the directory specified by
% \c!directory; even if the input is from some other directory
@@ -163,11 +128,48 @@
\def\doinlineexternalfilter[#1]%
{\edef\currentexternalfilter {#1}%
\begingroup % to keep assignments local
- \getparameters[\????externalfilter#1][\c!name=,\c!continue=\v!no]%
+ \getparameters[\????externalfilter#1][\c!name=]%
\setexternalfilterfilenames
\pushcatcodetable
\futurelet\next\dodoinlineexternalfilter}
+%D \subsubject {Catcode tables}
+%D
+%D Just to be sure, I define all catcode tables that are needed within the
+%D module. Some of these are repetition of what is defined in ConTeXt, but the
+%D internal names keep on changing which is a maintenance nightmare.
+
+\newcatcodetable \externalfilterreadcatcodes
+\newcatcodetable \externalfilterwritecatcodes
+\newcatcodetable \externalfilterverbcatcodes
+
+\startcatcodetable \externalfilterreadcatcodes % same as typcatcodesa
+ \catcode\tabasciicode \othercatcode
+ \catcode\endoflineasciicode \othercatcode
+ \catcode\formfeedasciicode \othercatcode
+ \catcode\spaceasciicode \othercatcode
+ \catcode\endoffileasciicode \othercatcode
+ \catcode\leftbraceasciicode \begingroupcatcode
+ \catcode\rightbraceasciicode\endgroupcatcode
+\stopcatcodetable
+
+\startcatcodetable \externalfilterwritecatcodes
+ \catcode\backslashasciicode = \escapecatcode
+ \catcode\leftbraceasciicode = \begingroupcatcode
+ \catcode\rightbraceasciicode = \endgroupcatcode
+ \catcode\endoflineasciicode = \activecatcode
+ \catcode\formfeedasciicode = \activecatcode
+ \catcode\spaceasciicode = \activecatcode
+\stopcatcodetable
+
+\startcatcodetable \externalfilterverbcatcodes % same as vrbcatcodes
+ \catcode\tabasciicode \othercatcode
+ \catcode\endoflineasciicode\othercatcode
+ \catcode\formfeedasciicode \othercatcode
+ \catcode\spaceasciicode \othercatcode
+ \catcode\endoffileasciicode\othercatcode
+\stopcatcodetable
+
%D \subsubject {Write argument to file verbatim}
%D
%D Surprisingly, there is nothing in the core to define a function that write its
@@ -181,11 +183,11 @@
\fi}
\def\dodoinlineexternalfilterA
- {\setcatcodetable \typcatcodesa
+ {\setcatcodetable \externalfilterreadcatcodes
\redoinlineexternalfilter}
\def\dodoinlineexternalfilterB#1%
- {\setcatcodetable \vrbcatcodes
+ {\setcatcodetable \externalfilterverbcatcodes
\def\dododoinlineexternalfilterB##1#1{\redoinlineexternalfilter{##1}}%
\dododoinlineexternalfilterB}
@@ -198,6 +200,9 @@
\popcatcodetable
\doexecuteexternalfilter
\doreadprocessedfile
+ % Finalization
+ \doif{\externalfilterparameter\c!continue}\v!yes
+ {\doglobal\expandafter\increment\csname\externalfiltercountername\endcsname}%
\endgroup}
@@ -226,12 +231,12 @@
\def\dosetexternalfilterdirectory
{\doif{\getfirstcharacter\getexternalfilterdirectory}{/}
{\writeline
- \showmessage\!!externalfilter{forbidden}\getexternalfilterdirectory
+ \showmessage\!!!!externalfilter{forbidden}\getexternalfilterdirectory
\batchmode
\errmessage{}
\normalend}
\doifnot{\getlastcharacter\getexternalfilterdirectory}{/}
- {\showmessage\!!externalfilter{slash}\getexternalfilterdirectory
+ {\showmessage\!!!!externalfilter{slash}\getexternalfilterdirectory
\edef\getexternalfilterdirectory{\getexternalfilterdirectory/}}}
@@ -246,10 +251,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{\!!externalfilter-\currentexternalfilter-\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}%
@@ -305,19 +310,19 @@
{\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
}}}
\def\dodoreadprocessedfile
- {\begingroup
- \externalfilterparameter\c!before
+ {\externalfilterparameter\c!before
+ \begingroup
\processcommacommand[\externalfilterparameter\c!setups]\directsetup
\externalfilterparameter\c!readcommand\externalfilteroutputfile
- \externalfilterparameter\c!after
- \endgroup}
+ \endgroup
+ \externalfilterparameter\c!after}
%D \section {Default Values}