summaryrefslogtreecommitdiff
path: root/Master
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2011-10-26 00:52:12 +0000
committerKarl Berry <karl@freefriends.org>2011-10-26 00:52:12 +0000
commit03df168a0c5297ed8c9e409e6edaae4b6068fb89 (patch)
tree822ce91ffeaad4ff3856beabde508dadb28ff2ef /Master
parentda5493ad3c20657570e1d068c107c1d115d03b05 (diff)
context-filter (24oct11)
git-svn-id: svn://tug.org/texlive/trunk@24389 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master')
-rw-r--r--Master/texmf-dist/doc/context/third/filter/filter.txt60
-rw-r--r--Master/texmf-dist/tex/context/third/filter/t-filter.tex50
2 files changed, 105 insertions, 5 deletions
diff --git a/Master/texmf-dist/doc/context/third/filter/filter.txt b/Master/texmf-dist/doc/context/third/filter/filter.txt
index ab4e9c6f90c..1b03acaaac1 100644
--- a/Master/texmf-dist/doc/context/third/filter/filter.txt
+++ b/Master/texmf-dist/doc/context/third/filter/filter.txt
@@ -106,7 +106,7 @@ Using this filter from within ConTeXt is pretty simple:
Yes, its that easy! The only thing to note is that TeX macros gobble spaces, so
we have to manually insert a space after `\externalfilteroutputfile`.
-This defines three things:
+This defines four things:
1. An environment
@@ -131,6 +131,14 @@ This defines three things:
The argument to the macro is a filename, which is processed by `pandoc` and
the output is included back in ConTeXt.
+4. A macro
+
+ \processmarkdownbuffer[...]
+
+ The argument to the macro is the name of a buffer, which is written to an
+ external file, processesd by `pandoc` and the output included back in
+ ConTeXt.
+
Dealing with slow filters
-------------------------
@@ -339,6 +347,12 @@ I can hide the output of a particular R-environment by
...
\stopR
+The macros `\processmarkdownfile` and `\processmarkdownbuffer` also accept user
+options. The usage is
+
+ \processmarkdownfile [.-.=.-.]{filename}
+ \processmarkdownbuffer[...=...][buffer]
+
A setup to control them all
---------------------------
@@ -441,6 +455,50 @@ options:
The options in the `[...]` are the same as those for `\defineexternalfilter`.
+Processing Existing Buffers
+---------------------------
+
+Like all macros built on top of buffers, the `\start<filter>` ...
+`\stop<filter>` environment does not work well inside the argument of another
+command. The `\process<filter>buffer` macro is handy for such macros.
+
+Suppose you want to write some markdown text in a footnote. Using
+
+ \footnote{ ....
+ \startmarkdown
+ ...
+ \stopmarkdown}
+
+gives an error message:
+
+ ! File ended while scanning use of \dododowithbuffer.
+
+ system > tex > error on line 0 in file : File ended while scanning use
+ of \dododowithbuffer ...
+
+ <empty file>
+
+ <inserted text>
+ \par
+
+To avoid this, define a buffer at the outer level
+
+ \startbuffer[footnote-markdown]
+ ...
+ \stopbuffer
+
+and then use
+
+ \footnote{... \processmarkdownbuffer[footnote-markdown]}
+
+The `\process<filter>buffer` macro also takes an optional argument for setup
+options:
+
+ \process<filter>buffer[...][...]
+
+The options in the first `[...]` are the same as those for `\defineexternalfilter`.
+
+
Prepend and append text
-----------------------
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 266c8e182ea..e44550de3ea 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.09.14,
+%D version=2011.10.22,
%D title=\CONTEXT\ User Module,
%D subtitle=Filter,
%D author=Aditya Mahajan,
@@ -9,7 +9,7 @@
%D email=adityam <at> ieee <dot> org,
%D license=Simplified BSD License]
-\writestatus{loading}{Filter (ver: 2011.09.14)}
+\writestatus{loading}{Filter (ver: 2011.10.22)}
\ifx\undefined\normalexpanded \let\normalexpanded\expanded \fi
@@ -111,6 +111,7 @@
\setvalue {\e!stop#1}{\externalfilter::process_filter}
\setvalue{process#1file}{\dodoubleargument\externalfilter::process_file[#1]}
+ \setvalue{process#1buffer}{\dotripleargument\externalfilter::process_buffer[#1]}
\setvalue{inline#1}{\dodoubleargument\externalfilter::inline[#1]}
\stoptexdefinition
@@ -132,6 +133,9 @@
\stoptexdefinition
\starttexdefinition externalfilter::process_file [#1][#2]#3
+ % #1 = filter
+ % #2 = options
+ % #3 = filename
\begingroup
\edef\externalfilter::name{#1}
@@ -154,12 +158,43 @@
\endgroup
\stoptexdefinition
+
+\starttexdefinition externalfilter::process_buffer [#1][#2][#3]
+ % #1 = filter
+ % #2 = options
+ % #3 = buffer
+ \begingroup
+
+ \edef\externalfilter::name{#1}
+ \ifthirdargument
+ \setupexternalfilter[#1][\c!name=,#2]
+ \fi
+
+ \externalfilter::set_directory
+
+ \ifthirdargument
+ \edef\externalfilter::temp_file{#3}
+ \else
+ \edef\externalfilter::temp_file{#2}
+ \fi
+
+ \externalfilter::set_filenames_extras
+ % In MkII, the above function sets the wrong value of
+ % \type{\externalfilter::input_file}. So, we reset that name here.
+ \doifmode\s!mkii
+ {\edef\externalfilter::input_file {\externalfilter::base_file.\f!temporaryextension}}
+
+ \iftraceexternalfilters \externalfilter::show_filenames \fi
+
+ \externalfilter::process_filter
+
+\stoptexdefinition
\starttexdefinition externalfilter::inline [#1][#2]
\edef\externalfilter::name{#1}
\begingroup % to keep assignments local
- \setupexternalfilter[#1][\c!name=,\c!before=,\c!after=,#2]
+ \setupexternalfilter[#1][\c!numbering=,\c!name=,\c!before=,\c!after=,#2]
\externalfilter::set_filenames
@@ -317,6 +352,13 @@
\doifsomething{\externalfilterparameter\c!name}
{\edef\externalfilter::temp_file{\externalfilter::temp_prefix-\externalfilter::name-\externalfilterparameter\c!name}}
+
+ \externalfilter::set_filenames_extras
+
+ \iftraceexternalfilters \externalfilter::show_filenames \fi
+\stoptexdefinition
+
+\starttexdefinition externalfilter::set_filenames_extras
% The following macros are useful for filter= and filtercommand= options
% The basename of the external file
\edef\externalfilter::base_file {\jobname-\externalfilter::temp_file}
@@ -337,10 +379,10 @@
% Append directory name to the name of the output file
\edef\externalfilter::output_file{\externalfilter::get_directory\externalfilterparameter\c!output}
- \iftraceexternalfilters \externalfilter::show_filenames \fi
\stoptexdefinition
+
%D \subsubject {Process Filter}
%D
%D Execute filter, read the output and do book-keeping if needed.