summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/back-exp.mkiv
diff options
context:
space:
mode:
authorTaco Hoekwater <taco@elvenkind.com>2011-06-01 08:54:21 +0000
committerTaco Hoekwater <taco@elvenkind.com>2011-06-01 08:54:21 +0000
commitd7ccb42582f85acf30568913610ccf4d602023fb (patch)
tree7292e3545a420676878e7451b68892d360c62cb6 /Master/texmf-dist/tex/context/base/back-exp.mkiv
parent2d62a6fe9b80def59c392268022f1f9a2d6e358f (diff)
commit context 2011.05.18
git-svn-id: svn://tug.org/texlive/trunk@22719 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/context/base/back-exp.mkiv')
-rw-r--r--Master/texmf-dist/tex/context/base/back-exp.mkiv127
1 files changed, 127 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/context/base/back-exp.mkiv b/Master/texmf-dist/tex/context/base/back-exp.mkiv
new file mode 100644
index 00000000000..88272fca70c
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/back-exp.mkiv
@@ -0,0 +1,127 @@
+%D \module
+%D [ file=back-exp,
+%D version=2010.08.22,
+%D title=\CONTEXT\ Backend Macros,
+%D subtitle=XML export,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright=\PRAGMA]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{ConTeXt Backend Macros / XML export}
+
+\registerctxluafile{back-exp.lua}{1.001}
+
+%D This is an experimental exporter and a logical follow up on tagging. The
+%D exporter assumes a properly tagged document. Some elements get a couple
+%D of attributes becaus eitherwise rendering information would get lost. In
+%D general we assume that when the \XML\ is converted to \HTML\ some stylesheet
+%D is applied anyway.
+
+\unprotect
+
+% we can replace this by a more generic attributeset mechanism where we bind
+% to any element (needed anyway, see userdata thingies)
+
+\definesystemattribute[taggedrows] [public]
+\definesystemattribute[taggedcolumns][public]
+\definesystemattribute[taggedalign] [public]
+\definesystemattribute[taggedpar] [public]
+\definesystemattribute[taggedpacked] [public]
+\definesystemattribute[taggedsymbol] [public]
+\definesystemattribute[taggedinsert] [public]
+\definesystemattribute[taggedtag] [public]
+
+\def\setelementexporttag
+ {\dotripleargument\dosetelementexporttag}
+
+\def\dosetelementexporttag[#1][#2][#3]%
+ {\ifthirdargument
+ \ctxlua{structures.tags.settagproperty("#1","#2", "#3")}%
+ \else\ifsecondargument
+ \ctxlua{structures.tags.settagproperty("#1","export", "#2")}%
+ \fi\fi}
+
+\newcount\tagparcounter
+
+\let\dotagsetparcounter\relax
+
+\appendtoks
+ \dotagsetparcounter
+\to \everypar
+
+\appendtoks
+ \dotagsetparcounter
+\to \neverypar
+
+\appendtoks
+ \dotagsetparcounter
+\to \everytabulatepar % tricky, maybe this should be neverypar
+
+\appendtoks
+ \def\dotagnoftablecolumns{\attribute\taggedcolumnsattribute\!!counta}%
+ \def\dotagnoftablerows {\attribute\taggedrowsattribute \!!countb}%
+\to \everyenableelements
+
+\appendtoks
+ \def\dotagTABLEalign{\attribute\taggedalignattribute\raggedstatus}%
+ \def\dotagTABLEcell {\char\zerocount}%
+\to \everyenableelements
+
+\appendtoks
+ \def\dotagtabulatealign{\attribute\taggedalignattribute\ifcase\tabulatealign\attributeunsetvalue\or\plusthree\or\plusone\or\plustwo\or\attributeunsetvalue\fi}%
+\to \everyenableelements
+
+\appendtoks
+ \def\dotagsynonym{\ctxlua{structures.tags.setsynonym("\currentsynonym","\currentsynonymtag")}}%
+\to \everyenableelements
+
+\appendtoks
+ \def\dotagsorting{\ctxlua{structures.tags.setsorting("\currentsorting","\currentsortingtag")}}%
+\to \everyenableelements
+
+\appendtoks
+ \def\dotagsetparcounter{\global\advance\tagparcounter\plusone\attribute\taggedparattribute\tagparcounter}%
+\to \everyenableelements
+
+\appendtoks
+ \def\dotagsetitemize{\ctxlua{structures.tags.setitemgroup(\ifconditional\packlistitem true\else false\fi,"\currentitemsymbol")}}%
+\to \everyenableelements
+
+\appendtoks
+ \def\dotagsetdescriptiontag{\ctxlua{structures.tags.setdescriptionid("\currentdescription",\currentdescriptionnumberentry)}}%
+\to \everyenableelements
+
+\appendtoks
+ \def\dotagsetnotesymbol{\ctxlua{structures.tags.setdescriptionid("\currentnote",\currentnotenumber)}}%
+\to \everyenableelements
+
+\appendtoks
+ \unexpanded\def\doverbatimspace{\char32\relax}% will be done permanently
+\to \everyenableelements
+
+% The action: \setupbackend[export=yes] % or filename
+
+\def\c!export {export} % maybe: option={css,xhtml}
+\def\c!css {css}
+\def\c!xhtml {xhtml}
+
+\appendtoks
+ \doifsomething{\backendparameter\c!xhtml}
+ {\enabledirectives[backend.export.xhtml=\backendparameter\c!xhtml]}%
+ \doifsomething{\backendparameter\c!css}
+ {\enabledirectives[backend.export.css={\backendparameter\c!css}]}%
+\to \everysetupbackend
+
+\appendtoks
+ \doifsomething{\backendparameter\c!export}
+ {\setupstructure
+ [\c!state=\v!start]%
+ \enabledirectives
+ [backend.export=\backendparameter\c!export]}%
+\to \everysetupbackend
+
+\protect \endinput