summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2011-09-04 16:15:46 +0000
committerKarl Berry <karl@freefriends.org>2011-09-04 16:15:46 +0000
commit841c5f458bf7b90d65b290eb953ebf36c5be5fe6 (patch)
treeb757f2e983fedd3de24e3104b592c811d77e3f23
parentef838896ded10ade336b3c720b17fb10553bc5c6 (diff)
context-filter (29aug11)
git-svn-id: svn://tug.org/texlive/trunk@23800 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r--Master/texmf-dist/doc/context/third/filter/filter.txt9
-rw-r--r--Master/texmf-dist/tex/context/third/filter/t-filter.tex28
-rw-r--r--Master/texmf-dist/tex/context/third/filter/t-module-catcodes.tex16
3 files changed, 40 insertions, 13 deletions
diff --git a/Master/texmf-dist/doc/context/third/filter/filter.txt b/Master/texmf-dist/doc/context/third/filter/filter.txt
index 62243a553ca..b4ecf06e0c2 100644
--- a/Master/texmf-dist/doc/context/third/filter/filter.txt
+++ b/Master/texmf-dist/doc/context/third/filter/filter.txt
@@ -305,8 +305,7 @@ Standard options
- `before` and `after`: to set the spacing of the environment or enclose the
output in a frame, etc.
-- `style` and `color` (these currently only work in MkIV): to set the color and
- style of the output.
+- `style` and `color`: to set the color and style of the output.
- `indentnext`: Should the next line be indented?
- `setups`: specify a list of setups (defined using `\startsetups`). These
setups may be used to define commands that are needed inside the environment.
@@ -362,6 +361,8 @@ of all options. The current defaults are
Passing options to filters
--------------------------
+**Note** This option does not work for MkII or for inline snippets
+
Sometimes it is useful to pass options to a filter. For example, `pandoc`
converts many different formats to ConTeXt (actually, to many different output
formats, but that is irrelevant here). Instead of defining a separate
@@ -398,7 +399,6 @@ Thus, the pandoc environment may be defined as
-o \externalfilteroutputfile\space \externalfilterinputfile},
format=markdown]
-
Macro variant
-------------
@@ -597,3 +597,6 @@ Version History
- Added `state=stop` option to skip running external filter.
- **2011.08.23**
- Added `bufferbefore` and `bufferafter` options
+- **2011.08.28**
+ - Internal change: Defined own macros for setting attrbutes rather than
+ using built-in ones.
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 2d89f168ef4..156c78df19b 100644
--- a/Master/texmf-dist/tex/context/third/filter/t-filter.tex
+++ b/Master/texmf-dist/tex/context/third/filter/t-filter.tex
@@ -1,15 +1,15 @@
%D \module
%D [ file=t-filter,
-%D version=2011.08.23,
+%D version=2011.08.28,
%D title=\CONTEXT\ User Module,
%D subtitle=Filter,
%D author=Aditya Mahajan,
%D date=\currentdate,
%D copyright=Aditya Mahajan,
-%D email=adityam <at> umich <dot> edu,
+%D email=adityam <at> ieee <dot> org,
%D license=Simplified BSD License]
-\writestatus{loading}{ConTeXt User Module / Filter}
+\writestatus{loading}{ConTeXt User Module / Filter ver: 2011.08.28}
\ifx\undefined\normalexpanded \let\normalexpanded\expanded \fi
@@ -264,6 +264,20 @@
\def\externalfilter::get_last_character_aux#1#2%
{\ifx#2\relax#1\else\@EA\externalfilter::get_last_character_aux\@EA#2\fi}
+%D \subsubject {Setting font and color attributes}
+
+
+\starttexdefinition externalfilter::attributes_start #1#2#3
+ % id style color
+ \edef\externalfilter::attributes_style{\getvalue{#1parameter}{#2}}
+ \edef\externalfilter::attributes_color{\getvalue{#1parameter}{#3}}
+
+ \expandafter\startcolor\expandafter[\externalfilter::attributes_color]
+ \expandafter\doconvertfont{\externalfilter::attributes_style}
+\stoptexdefinition
+
+\def\externalfilter::attributes_stop{\stopcolor}
+
%D \subsubject {Set the name of output directory}
\starttexdefinition externalfilter::set_directory
@@ -347,7 +361,8 @@
\externalfilterparameter{\c!buffer\c!after}]
[\externalfilter::id]
\startluacode
- os.rename("\jobname-\externalfilter::id.\f!temporaryextension", "\externalfilter::input_file")
+ %% On Windows, os.rename does not overwrite files :(
+ file.copy("\jobname-\externalfilter::id.\f!temporaryextension", "\externalfilter::input_file")
\stopluacode
\stopmode
@@ -402,11 +417,10 @@
\externalfilterparameter\c!before
\begingroup
- \doifmode\s!mkiv
- {\dosetexternalfilterattributes\c!style\c!color}
-
+ \externalfilter::attributes_start \externalfilter::id \c!style \c!color
\processcommacommand[\externalfilterparameter\c!setups]\directsetup
\externalfilterparameter\c!readcommand\externalfilter::output_file
+ \externalfilter::attributes_stop
\endgroup
\externalfilterparameter\c!after
diff --git a/Master/texmf-dist/tex/context/third/filter/t-module-catcodes.tex b/Master/texmf-dist/tex/context/third/filter/t-module-catcodes.tex
index 539ca19f4e3..84ea132dfbd 100644
--- a/Master/texmf-dist/tex/context/third/filter/t-module-catcodes.tex
+++ b/Master/texmf-dist/tex/context/third/filter/t-module-catcodes.tex
@@ -1,15 +1,15 @@
%D \module
%D [ file=t-module-catcodes,
-%D version=2011.04.02,
+%D version=2011.08.28,
%D title=\CONTEXT\ User Module,
%D subtitle=Module Catcodes,
%D author=Aditya Mahajan,
%D date=\currentdate,
%D copyright=Aditya Mahajan,
-%D email=adityam <at> umich <dot> edu,
+%D email=adityam <at> ieee <dot> org,
%D license=Simplified BSD License]
-\writestatus{loading}{ConTeXt User Module / Module Catcodes}
+\writestatus{loading}{ConTeXt User Module / Module Catcodes ver: 2011.08.28}
\startmodule [module-catcodes]
% EXPERIMENTAL: Catcode table for internal commands
@@ -64,4 +64,14 @@
{\popcatcodetable}
+\ifdefined \activeendoflinetoken \else
+ % from catc-ini.mkiv
+ \bgroup
+ \catcode \tabasciicode \activecatcode \gdef\activetabtoken {^^I}
+ \gdef\outputnewlinechar {^^J}
+ \catcode \formfeedasciicode \activecatcode \gdef\activeformfeedtoken {^^L}
+ \catcode \endoflineasciicode \activecatcode \gdef\activeendoflinetoken{^^M}
+ \egroup
+\fi
+
\stopmodule