diff options
author | Karl Berry <karl@freefriends.org> | 2011-08-26 22:28:27 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2011-08-26 22:28:27 +0000 |
commit | c2b5d929f28df0fa1349a5515c6ca7475ea24388 (patch) | |
tree | 098bb0e00075333412ddaa2b257483c0d9f05739 /Master/texmf-dist/tex | |
parent | 5c3e7d14dc14232cab367595070b49c281524cad (diff) |
context-filter (24aug11)
git-svn-id: svn://tug.org/texlive/trunk@23712 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex')
-rw-r--r-- | Master/texmf-dist/tex/context/third/filter/t-filter.tex | 99 |
1 files changed, 68 insertions, 31 deletions
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 6f95644953f..2d89f168ef4 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.06.12, +%D version=2011.08.23, %D title=\CONTEXT\ User Module, %D subtitle=Filter, %D author=Aditya Mahajan, @@ -36,15 +36,6 @@ \setinterfaceconstant {readcommand} {readcommand} \stopinterface -\def\m!externalfilter{t-filter} - -%D \subsubject {Messages} - -\setinterfacemessage{externalfilter}{title} {\m!externalfilter} -\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} @@ -62,6 +53,17 @@ \doifmode\s!mkiv {\installattributehandler \externalfilter::namespace \externalfilter::id} +\def\m!externalfilter{t-filter} + +%D \subsubject {Messages} + +\setinterfacemessage\m!externalfilter{title} {\m!externalfilter} +\setinterfacemessage\m!externalfilter{notfound} {file -- cannot be found} +\setinterfacemessage\m!externalfilter{missing} {output file missing} +\setinterfacemessage\m!externalfilter{forbidden} {Fatal Error: Cannot use absolute path -- as directory} +\setinterfacemessage\m!externalfilter{slash} {Appending / to directory -- } +\setinterfacemessage\m!externalfilter{reuse} {\c!state=\v!stop : Not running filter on file --} + % For backward compatibility \let\setupexternalfilters \setupexternalfilter @@ -72,12 +74,10 @@ \let\traceexternalfilters\traceexternalfilterstrue \starttexdefinition externalfilter::show_filenames - \iftraceexternalfilters - \writestatus\m!externalfilter{current filter : \externalfilter::name} - \writestatus\m!externalfilter{base file : \externalfilter::base_file} - \writestatus\m!externalfilter{input file : \externalfilter::input_file} - \writestatus\m!externalfilter{output file : \externalfilter::output_file} - \fi + \writestatus\m!externalfilter{current filter : \externalfilter::name} + \writestatus\m!externalfilter{base file : \externalfilter::base_file} + \writestatus\m!externalfilter{input file : \externalfilter::input_file} + \writestatus\m!externalfilter{output file : \externalfilter::output_file} \stoptexdefinition \starttexdefinition externalfilter::show_status #1 @@ -100,8 +100,8 @@ \starttexdefinition externalfilter::define [#1][#2] \externalfilter::show_status{defining filter : #1} + \setupexternalfilter[#1][\s!parent=\externalfilter::namespace,#2] \edef\externalfilter::name{#1} - \getparameters[\externalfilter::namespace#1][\s!parent=\externalfilter::namespace,#2] \doif{\externalfilterparameter\c!continue}\v!yes {\expandafter\newcounter\csname\externalfilter::count\endcsname} @@ -111,6 +111,7 @@ \setvalue{process#1file}{\dodoubleargument\externalfilter::process_file[#1]} \setvalue{inline#1}{\externalfilter::inline[#1]} + \stoptexdefinition \starttexdefinition externalfilter::start [#1][#2] @@ -121,7 +122,7 @@ \edef\externalfilter::name{#1} \begingroup % to keep assignments local - \getparameters[\externalfilter::namespace#1][\c!name=,#2] + \setupexternalfilter[#1][\c!name=,#2] \externalfilter::set_filenames @@ -133,7 +134,7 @@ \begingroup \edef\externalfilter::name{#1} - \getparameters[\externalfilter::namespace#1][\c!name=,#2] + \setupexternalfilter[#1][\c!name=,#2] \externalfilter::set_directory @@ -146,7 +147,7 @@ % \c!directory; even if the input is from some other directory \def\externalfilter::output_file{\externalfilter::get_directory\externalfilterparameter\c!output} - \externalfilter::show_filenames + \iftraceexternalfilters \externalfilter::show_filenames \fi \externalfilter::execute_filter \externalfilter::read_processed_file @@ -157,7 +158,7 @@ \edef\externalfilter::name{#1} \begingroup % to keep assignments local - \getparameters[\externalfilter::namespace#1][\c!name=] + \setupexternalfilter[#1][\c!name=] \externalfilter::set_filenames @@ -165,6 +166,7 @@ \futurelet\next\externalfilter::inline_aux \stoptexdefinition + %D \subsubject {Catcode tables} %D %D Just to be sure, I define all catcode tables that are needed within the @@ -272,13 +274,13 @@ \starttexdefinition externalfilter::set_directory_aux \doif{\externalfilter::get_first_character\externalfilter::get_directory}{/} {\writeline - \showmessage\externalfilter::id{forbidden}\externalfilter::get_directory + \showmessage\m!externalfilter{forbidden}\externalfilter::get_directory \batchmode \errmessage{} \normalend} \doifnot{\externalfilter::get_last_character\externalfilter::get_directory}{/} - {\showmessage\externalfilter::id{slash}\externalfilter::get_directory + {\showmessage\m!externalfilter{slash}\externalfilter::get_directory \edef\externalfilter::get_directory{\externalfilter::get_directory/}} \stoptexdefinition @@ -320,7 +322,7 @@ % Append directory name to the name of the output file \edef\externalfilter::output_file{\externalfilter::get_directory\externalfilterparameter\c!output} - \externalfilter::show_filenames + \iftraceexternalfilters \externalfilter::show_filenames \fi \stoptexdefinition @@ -330,7 +332,25 @@ \starttexdefinition externalfilter::process_filter % By defualt, buffers are in memory in MkIV. So, we save them to disk - \doifmode\s!mkiv{\savebuffer[\externalfilter::temp_file][\externalfilter::input_file]} + % To imitate the behavior of MkII, we need + % + % \doifmode\s!mkiv{\savebuffer[\externalfilter::temp_file][\externalfilter::input_file]} + % + % However, in MkIV, we can save a list of buffers to a file. The empty + % elements of the list are ignored. So, instead we use the following + %\doifmode\s!mkiv + %{\savebuffer[\externalfilterparameter{\c!buffer\c!before},\externalfilter::temp_file,\externalfilterparameter{\c!buffer\c!after}] + % [\externalfilter::input_file]} + \startmode[\s!mkiv] + \savebuffer[\externalfilterparameter{\c!buffer\c!before}, + \externalfilter::temp_file, + \externalfilterparameter{\c!buffer\c!after}] + [\externalfilter::id] + \startluacode + os.rename("\jobname-\externalfilter::id.\f!temporaryextension", "\externalfilter::input_file") + \stopluacode + \stopmode + \externalfilter::execute_filter \externalfilter::read_processed_file @@ -351,10 +371,16 @@ \externalfilter::show_filtercommand \doifelse{\externalfilterparameter\c!continue}\v!yes - {\doifmode{*first} - {\executesystemcommand - {mtxrun --ifchanged=\externalfilter::input_file\space - --direct \externalfilterparameter\c!filtercommand}}} + {\doifelse{\externalfilterparameter\c!state}\v!stop + {\showmessage\m!externalfilter{reuse}\externalfilter::input_file} + {\doifmode{*first} + {\doifmodeelse{force} + {\message{\externalfilterparameter\c!filtercommand} + \executesystemcommand + {\externalfilterparameter\c!filtercommand}} + {\executesystemcommand + {mtxrun --ifchanged=\externalfilter::input_file\space + --direct \externalfilterparameter\c!filtercommand}}}}} {\executesystemcommand {\externalfilterparameter\c!filtercommand}} \stoptexdefinition @@ -365,9 +391,10 @@ \doif{\externalfilterparameter\c!read}\v!yes {\doiffileelse{\externalfilter::output_file} {\externalfilter::read_processed_file_aux} - {\showmessage\externalfilter::id{notfound}\externalfilter::output_file + {\showmessage\m!externalfilter{notfound}\externalfilter::output_file + \externalfilter::show_filenames \blank - {\tttf [[\getmessage\externalfilter::id{missing}]]} + {\tttf [[\getmessage\m!externalfilter{missing}]]} \blank}} \stoptexdefinition @@ -402,12 +429,22 @@ \c!output=\externalfilterbasefile.tex, \c!filter=, \c!filtercommand={\externalfilterparameter\c!filter\space \externalfilter::input_file}, + \c!buffer\c!before=, + \c!buffer\c!after=, ] +\doifmodeelse{reuse} + {\setupexternalfilters[state=stop]} + {\setupexternalfilters[state=start]} + \def\externalfilterbasefile {\externalfilter::base_file} \def\externalfilterinputfile {\externalfilter::input_file} \def\externalfilteroutputfile{\externalfilter::output_file} \def\currentexternalfilter {\externalfilter::name} + +% Default value +\def\externalfilter::input_file {} +\def\externalfilter::output_file{} \protectmodulecatcodes \stopmodule |