+%D \stopbuffer
+%D
+%D \showelements [context] [p]
+
+\defineXMLenvironment [context:p] {} \endgraf
+\defineXMLsingular [context:p] \endgraf
+
+%D \elements {pageref,textref,lineref}
+%D
+%D \startbuffer
+%D You can ask for a page (the last pagenumber
+%D is aka page ), text or line reference
+%D with the following three elements. The label may be any valid &context;
+%D reference label.
+%D \stopbuffer
+%D
+%D \showelements [context] [references]
+
+\defineXMLpickup [context:pageref] [label=] {\at} {[\XMLop{label}]}
+\defineXMLpickup [context:textref] [label=] {\in} {[\XMLop{label}]}
+\defineXMLpickup [context:lineref] [label=] {\inline} {[\XMLop{label}]}
+
+%D \elements{text}
+%D
+%D \startbuffer
+%D If you have a self contained &xml; file, you need to signal &context; the
+%D begin and end of the document. The following elements can be used for
+%D that purpose:
+%D
+%D
+%D
+%D ...
+%D
+%D
+%D \stopbuffer
+%D
+%D \showelements [context] [text]
+
+\defineXMLenvironment [context:text] \starttext \stoptext
+
+%D \elements {em}
+%D
+%D \startbuffer
+%D Authors often want some control over the way a text is typeset, which is
+%D why we provide the em element. We may only hope that
+%D the author is consistent in his decisions on what to emphasize.
+%D \stopbuffer
+%D
+%D \showelements [context] [em]
+
+\defineXMLgrouped [context:em] \em
+
+%D \elements {b}
+%D
+%D \startbuffer
+%D Bold is not always beautiful but if you really want it, you can
+%D get it by using this element.
+%D \stopbuffer
+%D
+%D \showelements [context] [b]
+
+\defineXMLgrouped [context:b] \bf
+
+%D \elements {verbatim,typing,line,verb,type}
+%D
+%D \startbuffer
+%D Although the following method can be used to typeset a piece of code
+%D verbatim
+%D
+%D verbatim !
+%D ]]>
+%D
+%D we prefer the more structured:
+%D
+%D
+%D Dit \is nogal verbatim !
+%D Dit is {nogal} verbatim !
+%D Dit is verbatim !
+%D
+%D \stopbuffer
+%D
+%D The element to tag inline verbatim is .
+%D
+%D \showelements [context] [verbatim]
+
+\defineXMLenvironment [context:verbatim]
+ {\startpacked
+ \defineXMLargument[context:line]{\endgraf\type}}
+ {\stoppacked}
+
+\defineXMLenvironment [context:typing]
+ {\startpacked\defineXMLargument[context:line]{\endgraf\type}}
+ {\stoppacked}
+
+\defineXMLargument [context:verb] \type
+\defineXMLargument [context:type] \type
+
+%D \elements {itemize,item}
+%D
+%D \startbuffer
+%D Itemized lists are quite common in documents, al least in the ones that
+%D we produce. For the moment we only provide a few options, later we will
+%D hook it into the &context; attribute handler.
+%D
+%D
+%D test
+%D test
+%D
+%D
+%D
+%D test
+%D test what?
+%D
+%D \stopbuffer
+%D
+%D \showelements [context] [itemize]
+
+\defineXMLenvironment [context:itemize] [type=,packed=]
+ {\let\XMLoptions\empty
+ \doifsomethingXMLop{type}{\addtocommalist{\XMLop{type}}\XMLoptions}%
+ \doifXMLop{packed}{yes}{\addtocommalist{packed}\XMLoptions}%
+ \expanded{\startitemize[\XMLoptions]}}
+ {\stopitemize}
+
+\defineXMLenvironment [context:item] [label=]
+ {\expanded{\item[\XMLop{label}]}}
+ {\endgraf}
+
+%D \elements {externalfigure}
+%D
+%D \startbuffer
+%D The previous examples already demonstrated how we can include a graphic:
+%D
+%D
+%D
+%D
+%D \stopbuffer
+%D
+%D \showelements [context] [externalfigure]
+
+\defineXMLsingular [context:externalfigure] [\??ef] [base=,label=,file=]
+ {\bgroup % \getXMLta \expandXMLta \expandXMLtp{file}%
+ \expandXMLta
+ \getXMLta % expand entities first
+ \doifelsenothing{\XMLtp{label}}
+ {\expanded{\externalfigure[\XMLtp{file}][\XMLta]}}
+ {\doifsomething{\XMLtp{base}}{\usefigurebase[\XMLtp{base}]}%
+ \expanded{\externalfigure[\XMLtp{label}][\XMLta]}}
+ \egroup}
+
+%D \elements {fixed}
+%D \setupexternalfigures[directory={../sample}]
+%D \startbuffer
+%D Something fixed will end up at the place where it defined in the input
+%D stream. The main idea behind this element is that it gives you control
+%D over the placement.
+%D
+%D
+%D
+%D
+%D
+%D
+%D
+%D
+%D
+%D
+%D \stopbuffer
+%D
+%D \showelements [context] [fixed]
+
+\defineXMLenvironment [context:fixed] [type=figure,location=,label=]
+ {\bgroup
+ \defineXMLsave[context:caption]
+ \defineXMLsave[context:content]}
+ {\expanded{\startfixed[\XMLop{location}]}%
+ \doifXMLdataelse{context:caption}
+ {\startcombination[1*1]
+ {\XMLflush{context:content}} {\XMLflush{context:caption}}
+ \stopcombination}
+ {\XMLflush{context:content}}%
+ \stopfixed
+ \egroup}
+
+%D \elements {float}
+%D \setupexternalfigures[directory={../sample}]
+%D \startbuffer
+%D A floating body will be placed at the first location available, unless
+%D a location is specified. As with the fixed element,
+%D you can provide a caption.
+%D
+%D
+%D
+%D
+%D
+%D
This is a cow!
+%D
+%D \stopbuffer
+%D
+%D \showelements [context] [float]
+
+\defineXMLenvironment [context:float] [type=figure,location=here,label=]
+ {\bgroup
+ \defineXMLsave[context:caption]
+ \defineXMLsave[context:content]}
+ {\expanded
+ {\placefloat
+ [\XMLop{type}] [\XMLop{location}] [\XMLop{label}]
+ {\XMLflush{context:caption}} {\XMLflush{context:content}}}
+ \egroup}
+
+%D \elements {quotation,quote}
+%D
+%D \startbuffer
+%D There is a (not so) subtle difference between a display
+%D quotation and an inline
+%D one.
+%D \stopbuffer
+%D
+%D \showelements [context] [table]
+
+\defineXMLgrouped [context:quote] \quote
+\defineXMLgrouped [context:quotation] \quotation
+
+%D \elements {table,tr,td}
+%D
+%D \startbuffer
+%D There are (currently) three table mechanisms in &context;. One of them
+%D resembles the well known &html; tables.
+%D
+%D
+%D
+%D
one
a
first
+%D
two
b
second
+%D
+%D
+%D
+%D As you can see here, we use a similar syntax but stick to the &context;
+%D attributes (which provide quite advanced control over the layout).
+%D
+%D
+%D
+%D
xx
xx
+%D
xx
xx
+%D
+%D
+%D \stopbuffer
+%D
+%D \showelements [context] [table]
+
+\defineXMLenvironment [context:table] [\@@tbl\@@tbl]
+ {\bgroup
+ \defineXMLnested [context:tr] [\@@tbl] {\expanded{\bTR[\theXMLarguments{\@@tbl}}]} \eTR
+ \defineXMLnested [context:td] [\@@tbl] {\expanded{\bTD[\theXMLarguments{\@@tbl}}]} \eTD
+ \expanded{\bTABLE[\theXMLarguments{\@@tbl\@@tbl}]}}
+ {\eTABLE
+ \egroup}
+
+%D \elements {tabulate,tspec,thead,tbody,ttail,trule,tr,td}
+%D
+%D \startbuffer
+%D The second mechanism that we support is tabulation. The advantage of this
+%D mechanism is that it it well tuned for tables that have much text in the
+%D cells and cross page boundaires.
+%D
+%D
+%D
+%D
+%D
+%D
+%D
+%D
bagger
bagger
bagger
+%D
+%D
+%D
+%D
+%D
+%D
+%D
bagger
bagger
bagger
+%D
bagg
ger
gr
+%D
bag
er
gger
+%D
+%D
+%D \stopbuffer
+%D
+%D \showelements [context] [tabulate]
+
+\newtoks\XMLtabtoks
+
+\defineXMLgrouped [context:tabulate] {\XMLtabtoks{|l|p|}}
+
+\defineXMLpickup [context:tbody]
+ {\expanded{\definetabulate[dummy][\the\XMLtabtoks]}
+ \startdummy\XMLflush{context:thead}}
+ {\XMLflush{context:ttail}\stopdummy}
+
+\defineXMLsave [context:thead]
+\defineXMLsave [context:ttail]
+
+\defineXMLenvironment[context:tspec]
+ {\XMLtabtoks\emptytoks}
+ {\appendtoks|\to\XMLtabtoks}
+
+\defineXMLsingular [context:trule] % verrrry ugly
+ {\crcr\noalign{\kern-\lineheight}\HL}
+
+\defineXMLsingular [context:tcell] [align=]
+ {\appendtoks|\to\XMLtabtoks
+ \expanded{\processallactionsinset
+ [\XMLop{align}]}
+ [ paragraph=>\appendtoks p\to\XMLtabtoks,
+ left=>\appendtoks l\to\XMLtabtoks,
+ right=>\appendtoks r\to\XMLtabtoks,
+ center=>\appendtoks c\to\XMLtabtoks,
+ middle=>\appendtoks c\to\XMLtabtoks]}
+
+\defineXMLenvironment [context:tr] {\ignorespaces} {\NC\NR}
+\defineXMLenvironment [context:td] {\NC} {\ignorespaces}
+
+%D \elements {hide}
+%D
+%D \startbuffer
+%D This is the way to [this is gone] something for the
+%D typesetting engine. Normally this element is only used for testing
+%D purposes.
+%D \stopbuffer
+%D
+%D \showelements [context] [tabulate]
+
+\defineXMLignore[context:hide]
+
+%D \elements {unknown}
+%D
+%D \startbuffer
+%D We can go on and on and with defining elements that map onto
+%D &context; commands, but why not just use &tex; input syntax then?
+%D \stopbuffer
+%D
+%D \showelements [context] [unknown]
+
+\defineXMLsingular [context:unknown] \unknown
+
+%D A (for the moment) private one.
+
+\defineXMLargument [context:element] \type
+
+%D The following common schema definitions apply:
+%D
+%D {\setupcolors[state=stop]\showXSDcomponent[context][definitions]}
+
+\defineXMLargument [context:chapter] [label=] {\chapter[\XMLop{label}]}
+\defineXMLargument [context:section] [label=] {\section[\XMLop{label}]}
+\defineXMLargument [context:subsection] [label=] {\subsection[\XMLop{label}]}
+\defineXMLargument [context:subsubsection] [label=] {\subsubsection[\XMLop{label}]}
+\defineXMLargument [context:subsubsubsection] [label=] {\subsubsubsection[\XMLop{label}]}
+
+\defineXMLargument [context:title] [label=] {\title[\XMLop{label}]}
+\defineXMLargument [context:subject] [label=] {\subject[\XMLop{label}]}
+\defineXMLargument [context:subsubject] [label=] {\subsubject[\XMLop{label}]}
+\defineXMLargument [context:subsubsubject] [label=] {\subsubsubject[\XMLop{label}]}
+\defineXMLargument [context:subsubsubsubject] [label=] {\subsubsubsubject[\XMLop{label}]}
+
+\defineXMLenvironment [context:frontmatter] \startfrontmatter \stopfrontmatter
+\defineXMLenvironment [context:bodymatter] \startbodymatter \stopbodymatter
+\defineXMLenvironment [context:backmatter] \startbackmatter \stopbackmatter
+\defineXMLenvironment [context:appendices] \startappendices \stopappendices
+
+\defineXMLargument [context:index] [key=]
+ {\doifelsenothingXMLop{key}{\index}{\expanded{\index[\XMLop{key}]}}}
+
+% \enableXMLfiledata
+
+% Needed for example (stickers and so):
+
+\defineXMLenvironment [context:makeup]
+ \startstandardmakeup \stopstandardmakeup
+
+\protect \endinput
+
+% TO DO
+
+\defineXMLenvironment [combination] [columns=2,rows=1]
+ {\scratchtoks\emptytoks
+ \expanded{\appendtoks \noexpand \startcombination
+ [\XMLop{columns}*\XMLop{rows}]}\to \scratchtoks}
+ {\appendtoks \stopcombination \to \scratchtoks
+ \the\scratchtoks}
+
+\defineXMLprocess[combinationentry]
+
+\defineXMLpickup [combinationitem]
+ {\appendtoks\bgroup}{\egroup\to\scratchtoks}
+
+\defineXMLpickup [combinationcaption]
+ {\appendtoks\bgroup}{\egroup\to\scratchtoks}
+
+\endinput
diff --git a/Master/texmf-dist/tex/context/modules/mkii/x-contml.xsd b/Master/texmf-dist/tex/context/modules/mkii/x-contml.xsd
new file mode 100644
index 00000000000..3b71e31e850
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkii/x-contml.xsd
@@ -0,0 +1,375 @@
+
+
+
+
+
+
+
+
+ This schema describes a class of presentations. The structure is
+ (normally) reflected in the design.
+
+ author: Hans Hagen, copyright: PRAGMA-ADE / Hasselt NL
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Master/texmf-dist/tex/context/modules/mkii/x-corres.mkii b/Master/texmf-dist/tex/context/modules/mkii/x-corres.mkii
new file mode 100644
index 00000000000..effd79a5b31
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkii/x-corres.mkii
@@ -0,0 +1,136 @@
+%D \module
+%D [ file=x-corres,
+%D version=2003.12.15, % replaces keep-02a cum suis
+%D title=\CONTEXT\ XML Modules,
+%D subtitle=Handling Correspondence Base,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+%D The selection spec:
+
+\setvariables
+ [contacts]
+ [selection=,
+ file=x-corres.xml] % fall back
+
+%D First we define the group expansion pass:
+
+\startsetups[contacts:collect]
+
+ \defineXMLprocess [contacts]
+
+ \defineXMLignore [contact]
+
+ \defineXMLargument [contactfile]
+ \processfile
+
+ \defineXMLenvironmentsave [contactgroup] [label=]
+ {\startXMLmappinggroup[contacts]}
+ {\XMLaddcontactgrouptoselection
+ \stopXMLmappinggroup}
+
+\stopsetups
+
+%D Next we define the main processing pass:
+
+\startsetups[contacts:process]
+
+ \defineXMLprocess[contacts]
+
+ \defineXMLignore [contactgroup]
+
+ \defineXMLargument [contactfile]
+ \processfile
+
+ \defineXMLenvironmentsave[contact] [label=]
+ {\startXMLmappinggroup[contacts]}
+ {\XMLselectcontact
+ \stopXMLmappinggroup}
+
+\stopsetups
+
+\startXMLmapping[contacts]
+
+ \defineXMLsave [initials]
+ \defineXMLsave [formalname]
+ \defineXMLsave [informalname]
+ \defineXMLsave [title]
+ \defineXMLsave [prefix]
+ \defineXMLsave [suffix]
+ \defineXMLsave [telephone]
+ \defineXMLsave [mobiletelephone]
+ \defineXMLsave [telefax]
+ \defineXMLsave [email]
+ \defineXMLsave [address]
+ \defineXMLsave [information]
+
+ \defineXMLenvironment [p] \endgraf \endgraf
+
+ \defineXMLargument [member] \XMLaddcontacttoselection
+
+\stopXMLmapping
+
+%D The selection macros: we expand groups and replace them
+%D by contact labels in the selection spec.
+
+\def\XMLaddcontactgrouptoselection
+ {\edef\XMLcontactlist{\getvariable{contacts}{selection}}%
+ \edef\XMLgrouplabel {\XMLop{label}}%
+ \expanded{\doifinset{\XMLgrouplabel}{\XMLcontactlist}}
+ {\let\XMLgrouplist\empty
+ \XMLflush{contactgroup}%
+ \substituteincommalist\XMLgrouplabel\XMLgrouplist\XMLcontactlist
+ \expanded
+ {\globalsetvariables
+ [contacts]
+ [selection={\XMLcontactlist}]}}}
+
+\def\XMLaddcontacttoselection#1%
+ {\addtocommalist{#1}\XMLgrouplist}
+
+%D The main selector:
+
+\def\XMLselectcontact
+ {\edef\XMLcontactlist {\getvariable{contacts}{selection}}%
+ \edef\XMLcontactlabel{\XMLop{label}}%
+ \doifelsenothing{\XMLcontactlist}
+ {\donetrue}
+ {\expanded{\doifinsetelse{\XMLcontactlabel}{\XMLcontactlist}}
+ {\donetrue}
+ {\donefalse}}%
+ \ifdone
+ \XMLflush{contact}%
+ \setups[contact:handle]%
+ \fi}
+
+%D The default:
+
+\startsetups[contact:handle]
+
+ \XMLflush{address}
+
+\stopsetups
+
+\setups[contacts:process]
+
+%D Handy:
+
+\def\XMLprocesscontacts
+ {\dosingleempty\XMLprocesscontacts}
+
+\def\XMLprocesscontacts[#1]%
+ {\bgroup
+ \doifelsenothing{#1}
+ {\XMLprocesscontacts[\getvariable{contacts}{file}]}
+ {\setups[contacts:collect]%
+ \processcommacommand[#1]\processXMLfile
+ \setups[contacts:process]%
+ \processcommacommand[#1]\processXMLfile}%
+ \egroup}
+
+\endinput
diff --git a/Master/texmf-dist/tex/context/modules/mkii/x-corres.rng b/Master/texmf-dist/tex/context/modules/mkii/x-corres.rng
new file mode 100644
index 00000000000..09de5d26718
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkii/x-corres.rng
@@ -0,0 +1,170 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Master/texmf-dist/tex/context/modules/mkii/x-dir-01.mkii b/Master/texmf-dist/tex/context/modules/mkii/x-dir-01.mkii
new file mode 100644
index 00000000000..6e4192a1326
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkii/x-dir-01.mkii
@@ -0,0 +1,145 @@
+%D \module
+%D [ file=x-dir-01,
+%D version=2003.05.10, % around that time -)
+%D title=\CONTEXT\ Directory Handling,
+%D subtitle=Overview (1),
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\setuppapersize
+ [S6][S6]
+
+\setuplayout
+ [width=middle,
+ height=middle,
+ backspace=12pt,
+ topspace=12pt,
+ bottomspace=32pt,
+ header=0pt,
+ footer=0pt,
+ bottomdistance=9pt,
+ bottom=18pt]
+
+\setupinteractionmenu
+ [bottom]
+ [state=start,
+ frame=off,
+ rightoffset=-3pt,
+ background=color,
+ backgroundcolor=TextColor,
+ middle=\hskip4pt,
+ left=\hfill]
+
+\startinteractionmenu[bottom]
+ \but [PreviousJump] Previous Jump \\
+ \but [previouspage] Previous Page \\
+ \but [nextpage] Next Page \\
+\stopinteractionmenu
+
+\setupbackgrounds
+ [page]
+ [backgroundoffset=3pt,
+ background=color,
+ backgroundcolor=PageColor]
+
+\setupbackgrounds
+ [text]
+ [background=color,
+ backgroundcolor=TextColor]
+
+\definecolor [PageColor] [r=.6,g=.7,b=.8]
+\definecolor [TextColor] [r=.7,g=.8,b=.9]
+\definecolor [DoneColor] [s=.5]
+
+\startmode[colorscheme-red]
+
+ \definecolor [PageColor] [r=.9,g=.7,b=.6]
+ \definecolor [TextColor] [r=.9,g=.8,b=.7]
+
+\stopmode
+
+\startmode[colorscheme-green]
+
+ \definecolor [PageColor] [r=.6,g=.8,b=.7]
+ \definecolor [TextColor] [r=.7,g=.9,b=.8]
+
+\stopmode
+
+\setupcolors
+ [state=start]
+
+\setupinteraction
+ [state=start,
+ menu=on,
+ color=,
+ display=new,
+ contrastcolor=DoneColor,
+ style=]
+
+\definehead
+ [directory]
+ [subject]
+
+\setuphead
+ [directory]
+ [style=\tfc]
+
+\setupbodyfont
+ [tt]
+
+\defineXMLenvironment [files] [url=]
+ {\doifelsenothing{\XMLop{url}}
+ {\xdef\XMLDIRurl{}}
+ {\xdef\XMLDIRurl{\XMLop{url}/}}
+ \startXMLignore}
+ {\stopXMLignore}
+
+\newcounter\NOfEntries
+
+\startsetups[xmldir:file]
+
+ \doglobal\increment\NOfEntries
+
+ \goto {\hbox to \hsize \bgroup
+
+ \XMLflush{base}
+ \hss
+ \hbox to 2em{\XMLflush{type}\hss}
+ \quad
+ \quad
+ \hbox to 5em{\hss\XMLflush{size}}
+ \quad
+ \quad
+ \XMLflush{date}
+
+ \egroup} [url(\XMLDIRurl\XMLop{name})]% [program(\XMLDIRurl\XMLop{name})]
+
+\stopsetups
+
+\defineXMLenvironment [directory] [name=]
+ {\directory{Path \XMLop{name}}}
+ {}
+
+\defineXMLenvironment [file] [name=]
+ {\bgroup}
+ {\setups[xmldir:file]
+ \endgraf
+ \egroup}
+
+\defineXMLsave[base]
+\defineXMLsave[type]
+\defineXMLsave[size]
+\defineXMLsave[date]
+
+\starttext
+
+ \processXMLfilegrouped{\inputfilename}
+
+ \ifnum\NOfEntries=0 There are no files found that match the pattern. \fi
+
+\stoptext
diff --git a/Master/texmf-dist/tex/context/modules/mkii/x-dir-02.mkii b/Master/texmf-dist/tex/context/modules/mkii/x-dir-02.mkii
new file mode 100644
index 00000000000..90c32d7042c
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkii/x-dir-02.mkii
@@ -0,0 +1,130 @@
+%D \module
+%D [ file=x-dir-02,
+%D version=2003.05.10, % around that time -)
+%D title=\CONTEXT\ Directory Handling,
+%D subtitle=Overview (2),
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\setuplayout
+ [width=middle,
+ height=middle,
+ backspace=.5cm,
+ topspace=.5cm,
+ header=1cm,
+ footer=0cm]
+
+\definehead
+ [directory]
+ [subject]
+
+\setuphead
+ [directory]
+ [style=\tfa]
+
+\setupbodyfont
+ [tt]
+
+\setuptabulate
+ [before=,after=]
+
+\setupcombinations
+ [location=top]
+
+\defineXMLenvironment [files] [root=.,url=]
+ {\doifelsenothing{\XMLop{url}}
+ {\xdef\XMLDIRurl{}}
+ {\xdef\XMLDIRurl{\XMLop{url}/}}
+ \startXMLignore}
+ {\stopXMLignore}
+
+\newcounter\NOfEntries
+
+\startsetups[xmldir:file:normal]
+
+ \doglobal\increment\NOfEntries
+
+ \startfiguretext
+ [left,none]
+ []
+ {}
+ {\hbox
+ {\externalfigure
+ [\XMLpar{files}{root}{.}/\XMLpar{directory}{name}{.}/\XMLop{name}]
+ [frame=on,width=6cm]
+ \quad
+ \framed[width=\figurewidth,height=\figureheight]{}}}
+ \strut \vskip-\lineheight
+ \starttabulate[|l|l|]
+ \NC base \NC \XMLflush{base} \NC \NR
+ \NC type \NC \XMLflush{type} \NC \NR
+ \NC width \NC \figurenaturalwidth \NC \NR
+ \NC height \NC \figurenaturalheight \NC \NR
+ \NC date \NC \XMLflush{date} \NC \NR
+ \NC size \NC \XMLflush{size} \NC \NR
+ \stoptabulate
+ \stopfiguretext
+
+\stopsetups
+
+\startsetups[xmldir:file:small]
+
+ \doglobal\increment\NOfEntries
+
+ \startlinecorrection
+
+ \startcombination
+ {\externalfigure
+ [\XMLpar{files}{root}{.}/\XMLpar{directory}{name}{.}/\XMLop{name}]
+ [frame=on,width=3cm]}
+ {}
+ {\vbox{\starttabulate[|l|l|]
+ \NC base \NC \XMLflush{base} \NC \NR
+ \NC type \NC \XMLflush{type} \NC \NR
+ \NC date \NC \XMLflush{date} \NC \NR
+ \stoptabulate}}
+ {}
+ \stopcombination
+
+ \stoplinecorrection
+
+\stopsetups
+
+\defineXMLenvironment [directory] [name=]
+ {\directory{Path \XMLop{name}}}
+ {}
+
+\defineXMLenvironment [file] [name=]
+ {\bgroup}
+ {% the next quick hack is really needed
+ \expanded{\defconvertedargument\noexpand\asciia{./\jobfilename}.pdf}%
+ \expanded{\defconvertedargument\noexpand\asciib{\XMLpar{directory}{name}{.}/\XMLop{name}}}%
+ % else we can not do an overview of the curent path
+ \doifnot\asciia\asciib
+ {\doifmodeelse{alternative-small}
+ {\setups[xmldir:file:small]}
+ {\setups[xmldir:file:normal]}
+ \endgraf}
+ \egroup}
+
+\defineXMLsave[base]
+\defineXMLsave[type]
+\defineXMLsave[size]
+\defineXMLsave[date]
+
+\starttext
+
+ \doifmode{alternative-small}{\startcolumns[balance=no]}
+
+ \processXMLfilegrouped{\inputfilename}
+
+ \doifmode{alternative-small}{\stopcolumns}
+
+ \ifnum\NOfEntries=0 There are no files found that match the pattern. \fi
+
+\stoptext
diff --git a/Master/texmf-dist/tex/context/modules/mkii/x-dir-05.mkii b/Master/texmf-dist/tex/context/modules/mkii/x-dir-05.mkii
new file mode 100644
index 00000000000..53e73c5eb86
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkii/x-dir-05.mkii
@@ -0,0 +1,51 @@
+%D \module
+%D [ file=x-dir-05,
+%D version=2003.05.10, % around that time -)
+%D title=\CONTEXT\ Directory Handling,
+%D subtitle=Access,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\setvariables
+ [filestate]
+ [name=,base=,type=,size=,permissions=,date=]
+
+\def\savefilestate
+ {\dodoubleargument\dosavefilestate}
+
+\def\dosavefilestate[#1][#2]%
+ {\startnointerference
+ \setxvariables
+ [#1]
+ [name=#2,base=,type=,size=,permissions=,date=]
+ \executesystemcommand{texmfstart xmltools.rb --dir --pattern=\getvariable{#1}{name} --output=xmldir.tmp}
+ \defineXMLprocess [files]
+ \defineXMLprocess [directory]
+ \defineXMLenvironment [file]
+ {\defineXMLsave [base]
+ \defineXMLsave [type]
+ \defineXMLsave [size]
+ \defineXMLsave [permissions]
+ \defineXMLsave [date]}
+ {\setxvariables
+ [#1]
+ [name=\XMLop{name},
+ base=\XMLflush{base},
+ type=\XMLflush{type},
+ size=\XMLflush{size},
+ permissions=\XMLflush{permissions},
+ date=\XMLflush{date}]}
+ \startXMLignore
+ \processXMLfile{xmldir.tmp}
+ \stopXMLignore
+ \stopnointerference}
+
+\def\getfilestate#1% old one
+ {\savefilestate[filestate][#1]}
+
+\endinput
diff --git a/Master/texmf-dist/tex/context/modules/mkii/x-fdf-00.mkii b/Master/texmf-dist/tex/context/modules/mkii/x-fdf-00.mkii
new file mode 100644
index 00000000000..fd4bea7e74c
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkii/x-fdf-00.mkii
@@ -0,0 +1,41 @@
+%
+%
+%
+% first
+%
+%
+% second
+%
+%
+%
+%
+% previous method:
+%
+% object
+% data
+% fields
+% field
+
+\defineXMLprocess[fdf:xfdf]
+\defineXMLprocess[fdf:fields]
+\defineXMLignore [fdf:f]
+\defineXMLpush [fdf:value]
+
+\defineXMLenvironment [fdf:field] [name=,value=]
+ {\XMLerase{fdf:value}}
+ {\gsaveXMLdata{fdf:\XMLop{name}}{fdf:value}}
+
+\defineXMLsingular [fdf:field] [name=,value=]
+ {\gsaveXMLasdata{fdf:\XMLop{name}}{\XMLop{value}}}
+
+\def\doifelseFDFfield#1{\doifelseXMLelement{fdf:#1}}
+\def\flushFDFfield #1{\flushXMLelement {fdf:#1}}
+\def\processFDFfield #1{\processXMLelement {fdf:#1}}
+
+\def\loadFDFfile#1%
+ {\bgroup
+ \autoXMLnamespace[fdf]%
+ \processXMLfilegrouped{#1}%
+ \egroup}
+
+\endinput
diff --git a/Master/texmf-dist/tex/context/modules/mkii/x-fe.mkii b/Master/texmf-dist/tex/context/modules/mkii/x-fe.mkii
new file mode 100644
index 00000000000..dcf415850a3
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkii/x-fe.mkii
@@ -0,0 +1,143 @@
+%D \module
+%D [ file=x-fe,
+%D version=2004.03.12, % based on earlier experiments
+%D title=\FOXET,
+%D subtitle=Simple Extensions,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+%D Extensions: fe:definecolor
+
+% menus
+% extra areas
+% protruding and hz
+% compound
+% title container
+% more float placements
+
+\unprotect
+
+% \XMLattributes{aural},
+
+\defineXMLnested
+ [fe:table-next]
+ [id=,
+ \XMLattributes{accessibility},
+ \XMLattributes{border-padding-background},
+ \XMLattributes{relative-position},
+ border-after-precedence=,
+ border-before-precedence=,
+ border-end-precedence=,
+ border-start-precedence=,
+ visibility=]
+ {\bTABLEnext}
+ {\eTABLEnext}
+
+% definitions
+
+\defineXMLcommand
+ [fe:definecolor]
+ [name=,r=,g=,b=,c=,m=,y=,k=,s=,p=,a=,t=]
+ {\expanded{\definecolor[\XMLop{name}]
+ [r=\XMLop r,g=\XMLop g,b=\XMLop b,
+ c=\XMLop c,m=\XMLop m,y=\XMLop y,k=\XMLop k,
+ s=\XMLop s,p=\XMLop p,a=\XMLop a,t=\XMLop t]}}
+
+\defineXMLcommand
+ [fe:definefontsynonym]
+ [name=,file=,encoding=]
+ {\doifelsenothing{\XMLop{encoding}}
+ {\expanded{\definefontsynonym[\XMLop{name}][\XMLop{file}][encoding=\XMLop{encoding}]}}
+ {\expanded{\definefontsynonym[\XMLop{name}][\XMLop{file}]}}}
+
+%D Extensions: fe:include
+
+\defineXMLsingular
+ [fe:include]
+ [url=,n=1]
+ {\doifelse{\XMLop{n}}{1}
+ {\readfile{\XMLpar{fe:include}{url}{}}{}{}}
+ {\dorecurse{\XMLop{n}}{\readfile{\XMLpar{fe:include}{url}{}}{}{}\endgraf}}}
+
+%D Extensions: fe:sample
+
+\defineXMLenvironment
+ [fe:sample]
+ [origin=unknown]
+ {\removeunwantedspaces\ignorespaces}
+ {\removeunwantedspaces}
+
+%D Extensions: fe:
+
+% \defineXMLenvironmentsave
+% [fe:loop]
+% [n=1]
+% {}
+% {\dorecurse{\XMLop{n}}{\XMLflush{fe:loop}}}
+
+\defineXMLargument
+ [fe:loop]
+ [n=1]
+ {\dorecurse{\XMLop{n}}}
+
+%D Extensions: fe:compound
+
+\defineXMLsingular
+ [fe:compound]
+ [character=-]
+ {\prewordbreak\XMLop{character}\prewordbreak}
+
+%D Extensions: fe:message
+
+\defineXMLargument
+ [fe:message]
+ [category=XML-FO]
+ {\expanded{\writestatus{\XMLop{category}}}}
+
+%D Handy
+
+\defineXMLargument
+ [fe:trace]
+ [attribute=,option=]
+ {\showXMLinh[\XMLop{attribute}]%
+ \XMLval{fe:trace}{\XMLop{option}}{}}
+
+\mapXMLvalue
+ {fe:trace}
+ {font}
+ {\hbox\bgroup\infofont[%
+ \xFOfont/\xFOfontsize/\xFOfontsizeadjust/\xFOfontfamily/\xFOfontweight/\xFOfontstyle/\xFOfontvariant:\FOfontdefinition
+ ]\egroup}
+
+%D Extensions:
+
+\startsetups fe:page:option:fit:start
+ \startTEXpage[margin=page]
+\stopsetups
+
+\startsetups fe:page:option:fit:stop
+ \stopTEXpage
+\stopsetups
+
+\useMPlibrary[pre]
+
+\mapXMLvalue {fe:tracing} {true} {\tracingFOtrue}
+\mapXMLvalue {fe:tracing} {false} {\tracingFOfalse}
+\mapXMLvalue {fe:testgrid} {true} {\setupbackgrounds[page][background=pagegrid]}
+
+\startsetups fe:setup
+ \XMLval{fe:tracing} {\XMLop{fe:tracing}} {}
+ \XMLval{fe:testgrid}{\XMLop{fe:testgrid}}{}
+\stopsetups
+
+%D Private (testing)
+
+\defineXMLcommand[fe:synchronizeoutput]{\synchronizeoutput}
+
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/modules/mkii/x-fig-00.dtd b/Master/texmf-dist/tex/context/modules/mkii/x-fig-00.dtd
new file mode 100644
index 00000000000..34b4d0bef9b
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkii/x-fig-00.dtd
@@ -0,0 +1,24 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Master/texmf-dist/tex/context/modules/mkii/x-fig-00.mkii b/Master/texmf-dist/tex/context/modules/mkii/x-fig-00.mkii
new file mode 100644
index 00000000000..2e000c64ca7
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkii/x-fig-00.mkii
@@ -0,0 +1,252 @@
+%D \module
+%D [ file=x-fig-00,
+%D version=2001.03.21,
+%D title=\CONTEXT\ Style File,
+%D subtitle=Figure Base Loading,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+% \readfile{x-res-04} \donothing \donothing \endinput
+
+% naast label, ook fig als ref en dan naar fig ref springen
+
+%D This module implements an interface to a figure database
+%D and file. The database is formatted in \XML\ conforming
+%D the following \DTD:
+%D
+%D \typefile{x-fig-00.dtd}
+%D
+%D A figure base coded this way looks like:
+%D
+%D \starttyping
+%D
+%D
+%D
+%D
+%D
+%D PRAGMA Advanced Document Engineering
+%D Manuals
+%D Beginners Manual
+%D A bunch of figures.
+%D
+%D
+%D
+%D
+%D
+%D
+%D
+%D \stoptyping
+%D
+%D You can convert this base into a \PDF\ file using
+%D \TEXEXEC\ and another module in this suite.
+%D
+%D \starttyping
+%D texexec --pdf --use=fig-make yourfile.xml
+%D \stoptyping
+%D
+%D You can now select a graphic from this file using the
+%D
+%D \starttyping
+%D \externalfigure[a dutch cow][width=4cm]
+%D \stoptyping
+%D
+%D This module overloads this command so that a figure is
+%D it first searched in the list of databases.
+%D
+%D \starttyping
+%D \usemodule [fig-base]
+%D \usefigurebases[yourfile]
+%D \stoptyping
+%D
+%D The special keyword \type {reset} can be used to reset
+%D this list.
+
+%D We park some mkiv code here. Eventually we will hook this into mkiv
+%D searching differently (just a standard feature, no need for loading
+%D modules because we need less code). Actually, what we do here is more
+%D like res-*: we load the xml file once.
+
+% \startluacode
+%
+% document.figurebases = { }
+% document.figurebases.data = { }
+% document.figurebases.found = { }
+%
+% function document.figurebases.find(basename,askedlabel)
+% document.figurebases.found = { }
+% local base = document.figurebases.data[basename]
+% local page = 0
+% if not base then
+% base = xml.load(basename)
+% document.figurebases.data[basename] = base
+% end
+% for e, d, k in xml.elements(base,"figurelibrary/figure/label") do
+% page = page + 1
+% if xml.content(d[k]) == askedlabel then
+% document.figurebases.found = {
+% name = xml.filters.text(e,"file"),
+% page = page,
+% }
+% return true
+% end
+% end
+% return false
+% end
+%
+% function commands.findfigurefilenameinbase(basename,askedlabel)
+% if document.figurebases.find(basename,askedlabel) then
+% commands.xdef("figurefilename",document.figurebases.found.name or "")
+% commands.xdef("figurefilepage",document.figurebases.found.page or "")
+% end
+% end
+%
+% \stopluacode
+%
+% \def\findfigurefilenameinbase#1#2%
+% {\ctxlua{commands.findfigurefilenameinbase("#1","\askedlabel")}}
+
+\startcommands dutch english
+ german czech
+ italian romanian
+
+ usefigurebase: gebruikfiguurbestand usefigurebase
+ usefigurebase usefigurebase
+ usefigurebase usefigurebase
+
+\stopcommands
+
+\unprotect
+
+\consultutilityfilefalse
+
+\startXMLmapping [-] [figbase]
+
+\defineXMLprocess [figurelibrary]
+\defineXMLignore [description]
+\defineXMLignore [copyright]
+\defineXMLignore [comment]
+\defineXMLignore [status]
+\defineXMLpush [file]
+\defineXMLpush [label]
+\defineXMLpush [dummy]
+\defineXMLenvironment [figure] \figbase@StartFigure \figbase@StopFigure
+
+\stopXMLmapping
+
+\newcounter\figurefilepage
+
+\def\figbase@StartFigure
+ {\bgroup}
+
+\def\figbase@StopFigure
+ {\doglobal\increment\figurefilepage
+ \doif\askedlabel{\XMLpop{label}}
+ {\doglobal\settrue\figurefiledone
+ \xdef\figurefilename{\XMLpop{file}}\endinput}%
+ \egroup}
+
+\def\findfigurefilenameinbase#1#2% sets \figurefilename and \figurefilepage
+ {\processXMLfilegrouped{#1}}
+
+\def\getfigurefilename#1#2%
+ {\startnointerference
+ \traceXMLelementsfalse
+ \startXMLmapping[-][figbase]
+ \resetfigurefilebase
+ \XMLerase{file}
+ \XMLerase{dummy}
+ \XMLerase{label}
+ \xdef\figurefilebase{#1}%
+ \doglobal\newcounter\figurefilepage
+ \def\askedlabel{#2}
+ \processcommacommand[\figurepathlist]\dogetfigurefilename
+ \stopXMLmapping
+ \stopnointerference}
+
+\globalletempty\figurebasepath
+
+\def\dogetfigurefilename#1%
+ {\ifx\figurefilename\empty
+ \bgroup
+ \xdef\figurefilebasepath{#1}%
+ \assignfullfilename{#1}{\figurefilebase}\to\filename
+ \doiffileelse{\filename.xml}
+ {\doshowfigurestate{base file : \filename}%
+ \expanded{\findfigurefilenameinbase{\filename.xml}{\askedlabel}}}
+ \donothing
+ \ifx\figurefilename\empty\else
+% \globallet\figurefilebase\figurefilebase
+ \globallet\figurefilebase\filename % hm, bad omen that this is needed
+ \fi
+ \egroup
+ \fi}
+
+\def\resetfigurefilebase
+ {\globalletempty\figurefilebase
+ \globalletempty\figurefilename
+ \globalletempty\figurefilebasepath
+ \globalletempty\figurefilepage}
+
+\def\doanalyzefiguredimensionsfromfile
+ {\ifcase\figurestatus \ifx\figurebaselist\empty \else
+ \resetfigurefilebase
+ \doshowfigurestate{base list : \figurebaselist}%
+ \processcommacommand[\figurebaselist]\dodoanalyzefiguredimensionsfromfile
+ \ifx\figurefilename\empty
+ \doshowfigurestate{base warning : no matching name found}%
+ \else
+ \doiffileelse{\figurefilebase.pdf}
+ {\doshowfigurestate{base file : \figurefilebase.pdf}%
+ \doshowfigurestate{base page : \figurefilepage}%
+ \let\figurepathlist\figurefilebasepath
+ \analyzefigurefilename{\figurefilebase.pdf}\wantedfigurelabel
+ \let\wantedfigurepage\figurefilepage}
+ {\doshowfigurestate{base missing : \figurefilebase.pdf}}
+ \fi
+ \ifcase\figurestatus
+ \analyzefigurefilename\expandedfigurename\wantedfigurelabel
+ \fi
+ \fi \fi}
+
+\def\dodoanalyzefiguredimensionsfromfile#1%
+ {\doshowfigurestate{base check : \wantedfigurename\space in #1}%
+ \getfigurefilename{#1}\wantedfigurename
+ \ifx\figurefilename\empty\else
+ \quitcommalist
+ \fi}
+
+\def\usefigurebase[#1]%
+ {\doifelse{#1}\v!reset
+ {\let\figurebaselist\empty}
+ {\addtocommalist{#1}\figurebaselist}}
+
+\let\figurebaselist\empty
+
+\resetfigurefilebase
+
+\protect \endinput
+
+\usefigurebase[figtest]
+
+\externalfigure[koetje] [width=3cm]
+\externalfigure[de molen op de dijk][width=3cm]
+\externalfigure[de molen op de dijk][width=2cm]
+\externalfigure[weet ik veel] [width=3cm]
+\externalfigure[weet ik veel] [width=2cm]
+\externalfigure[weet ik wat] [width=2cm]
+\externalfigure[koe] [width=2cm]
diff --git a/Master/texmf-dist/tex/context/modules/mkii/x-fig-00.xsd b/Master/texmf-dist/tex/context/modules/mkii/x-fig-00.xsd
new file mode 100644
index 00000000000..615841a1e6c
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkii/x-fig-00.xsd
@@ -0,0 +1,77 @@
+
+
+
+
+
+
+
This schema described the figure database. This base
+ can be used to collect graphics that later can be used
+ in applications like ConTeXt.
+
+
+* Test
+** Test
+* Test1
+ * Test2
+* Test
+
+Test
+====
+
+> test
+> test **123** *123*
+> test `code`
+
+test
+
+Test
+====
+
+> test
+> test
+> test
+
+test
+oeps
+
+more
+
+ code
+ code
+
+oeps
+
+[an example][a]
+
+[an example] [2]
+
+[a]: http://example.com/ "Optional *oeps* Title Here"
+[2]: http://example.com/ 'Optional Title Here'
+[3]: http://example.com/ (Optional Title Here)
+
+[an example][a]
+
+[an example] [2]
+
+[an [tricky] example](http://example.com/ "Title")
+
+[This **xx** link](http://example.net/)
+ ]]
+
+-- This snippet takes some 4 seconds in the original parser (the one that is
+-- a bit clearer from the perspective of grammars but somewhat messy with
+-- respect to the captures. In the above parser it takes .1 second. Also,
+-- in the later case only memory is the limit.
+
+ local two = [[
+Test
+====
+* Test
+** Test
+* Test
+** Test
+* Test
+
+Test
+====
+
+> test
+> test
+> test
+
+test
+
+Test
+====
+
+> test
+> test
+> test
+
+test
+ ]]
+
+ local function test(str)
+ local n = 1 -- 000
+ local t = os.clock()
+ local one = convert(str)
+ -- print("runtime",1,#str,#one,os.clock()-t)
+ str = string.rep(str,n)
+ local t = os.clock()
+ local two = convert(str)
+ print(two)
+ -- print("runtime",n,#str,#two,os.clock()-t)
+ -- print(format("==============\n%s\n==============",one))
+ end
+
+ -- test(one)
+ -- test(two)
+ -- test(io.read("*all"))
+
+
+end
diff --git a/Master/texmf-dist/tex/context/modules/mkiv/m-markdown.mkiv b/Master/texmf-dist/tex/context/modules/mkiv/m-markdown.mkiv
new file mode 100644
index 00000000000..6e003651309
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkiv/m-markdown.mkiv
@@ -0,0 +1,88 @@
+%D \module
+%D [ file=x-markdown,
+%D version=2011.07.19,
+%D title=\CONTEXT\ Modules,
+%D subtitle=Processing MarkDown,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%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 Modules / MarkDown Renderer}
+
+%D This module deals with markdown which is a document encoding that
+%D some \CONTEXT\ like much. It reminds me of the kind of minimal coding
+%D we used before we ran into \TEX\ and were using a somewhat simple
+%D rendering (pagination, etc) of documents. As I'm no user myself, it
+%D is up to others to provide documentation and examples.
+
+\registerctxluafile{m-markdown}{1.001}
+
+\unprotect
+
+% basic interface
+
+\definebuffer[markdown]
+
+\unexpanded\def\stopmarkdown
+ {\ctxlua{moduledata.markdown.typesetbuffer("\thedefinedbuffer{markdown}")}}
+
+\unexpanded\def\processmarkdownfile#1% maybe [] or both
+ {\ctxlua{moduledata.markdown.typesetfile("#1")}}
+
+\unexpanded\def\markdown#1% maybe [] or both
+ {\ctxlua{moduledata.markdown.typesetstring(\!!bs#1\!!es)}}
+
+% commands
+
+\defineitemgroup
+ [markdownitemize]
+
+\definetyping
+ [markdowntyping]
+
+\definetype
+ [markdowntype]
+
+\definetype
+ [markdowninlinehtml]
+
+\definetyping
+ [markdowndisplayhtml]
+
+\definedelimitedtext
+ [markdownblockquote]
+ [quotation]
+
+\definehighlight
+ [markdownemphasis]
+ [style=\em]
+
+\definehighlight
+ [markdownstrong]
+ [style=\bf]
+
+\definestructurelevels
+ [markdown]
+ [\v!chapter,
+ \v!section,
+ \v!subsection,
+ \v!subsubsection,
+ \v!subsubsubsection,
+ \v!subsubsubsubsection]
+
+\unexpanded\def\markdownrule
+ {\hairline\par}
+
+\protect
+
+\continueifinputfile{m-markdown.mkiv}
+
+\starttext
+ \startmarkdown
+ % some examples needed
+ \stopmarkdown
+\stoptext
diff --git a/Master/texmf-dist/tex/context/modules/mkiv/m-mathcrap.mkiv b/Master/texmf-dist/tex/context/modules/mkiv/m-mathcrap.mkiv
new file mode 100644
index 00000000000..25efd2d5de3
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkiv/m-mathcrap.mkiv
@@ -0,0 +1,76 @@
+%D \module
+%D [ file=m-mathcrap,
+%D version=2010.05.30,
+%D title=\CONTEXT\ Modules,
+%D subtitle=Math Crap,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+%D This is meant for those who want to use the (incomplete and sort of useless)
+%D unicode superscripts and subscripts. We should look ahead and collapse them
+%D but I will only implement that in calcmath when the need is there. Now the
+%D spacing can be somewhat non optimal but probably that does not matter here.
+%D
+%D \startbuffer
+%D $a₀₁₂₃₄₅₆₇₈₉₋₌₊$
+%D \stopbuffer
+%D
+%D \typebuffer \blank \getbuffer \blank
+
+\unprotect
+
+\unexpanded\def\mathunicodesupercrap#1{\mathortext{{\normalsuperscript{#1}}}{\high{#1}}}
+\unexpanded\def\mathunicodesubcrap #1{\mathortext{{\normalsubscript {#1}}}{\low {#1}}}
+
+\ifdefined\installanddefineactivecharacter\else
+
+ \def\installanddefineactivecharacter #1 #2% we need this as command
+ {\normalexpanded{\noexpand\installactivecharacter \utfchar{#1} }%
+ \defineactivecharacter #1 {#2}}
+
+\fi
+
+\installanddefineactivecharacter "2070 {\mathunicodesupercrap 0}
+\installanddefineactivecharacter "00B9 {\mathunicodesupercrap 1}
+\installanddefineactivecharacter "00B2 {\mathunicodesupercrap 2}
+\installanddefineactivecharacter "00B3 {\mathunicodesupercrap 3}
+\installanddefineactivecharacter "2074 {\mathunicodesupercrap 4}
+\installanddefineactivecharacter "2075 {\mathunicodesupercrap 5}
+\installanddefineactivecharacter "2076 {\mathunicodesupercrap 6}
+\installanddefineactivecharacter "2077 {\mathunicodesupercrap 7}
+\installanddefineactivecharacter "2078 {\mathunicodesupercrap 8}
+\installanddefineactivecharacter "2079 {\mathunicodesupercrap 9}
+\installanddefineactivecharacter "207A {\mathunicodesupercrap +}
+\installanddefineactivecharacter "207B {\mathunicodesupercrap -}
+\installanddefineactivecharacter "207C {\mathunicodesupercrap =}
+\installanddefineactivecharacter "207D {\mathunicodesupercrap (}
+\installanddefineactivecharacter "207E {\mathunicodesupercrap )}
+\installanddefineactivecharacter "207F {\mathunicodesupercrap n}
+
+\installanddefineactivecharacter "2080 {\mathunicodesubcrap 0}
+\installanddefineactivecharacter "2081 {\mathunicodesubcrap 1}
+\installanddefineactivecharacter "2082 {\mathunicodesubcrap 2}
+\installanddefineactivecharacter "2083 {\mathunicodesubcrap 3}
+\installanddefineactivecharacter "2084 {\mathunicodesubcrap 4}
+\installanddefineactivecharacter "2085 {\mathunicodesubcrap 5}
+\installanddefineactivecharacter "2086 {\mathunicodesubcrap 6}
+\installanddefineactivecharacter "2087 {\mathunicodesubcrap 7}
+\installanddefineactivecharacter "2088 {\mathunicodesubcrap 8}
+\installanddefineactivecharacter "2089 {\mathunicodesubcrap 9}
+\installanddefineactivecharacter "208A {\mathunicodesubcrap +}
+\installanddefineactivecharacter "208B {\mathunicodesubcrap -}
+\installanddefineactivecharacter "208C {\mathunicodesubcrap =}
+\installanddefineactivecharacter "208D {\mathunicodesubcrap (}
+\installanddefineactivecharacter "208E {\mathunicodesubcrap )}
+\installanddefineactivecharacter "2090 {\mathunicodesubcrap A}
+\installanddefineactivecharacter "2091 {\mathunicodesubcrap E}
+\installanddefineactivecharacter "2092 {\mathunicodesubcrap O}
+\installanddefineactivecharacter "2093 {\mathunicodesubcrap X}
+%installanddefineactivecharacter "2094 {\mathunicodesubcrap ?} % SCHWAA
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/modules/mkiv/m-matrix.mkiv b/Master/texmf-dist/tex/context/modules/mkiv/m-matrix.mkiv
new file mode 100644
index 00000000000..ccb376e39c7
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkiv/m-matrix.mkiv
@@ -0,0 +1,495 @@
+%D \module
+%D [ file=m-matrix,
+%D version=2014.11.04, % already a year older
+%D title=\CONTEXT\ Extra Modules,
+%D subtitle=Matrices,
+%D author={Jeong Dalyoung \& Hans Hagen},
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+%D This code is based on a post by Dalyoung on the context list. After that
+%D we turned it into a module and improved the code a bit. Feel free to ask
+%D us for more. Once we're satisfied, a more general helper l-matrix could
+%D be made. Dalyoung does the clever bits, and Hans only cleanes up and
+%D optimizes a bit.
+
+% \registerctxluafile{l-matrix}{1.001} % not yet
+
+\startmodule[matrix]
+
+\startluacode
+
+local settings_to_hash = utilities.parsers.settings_to_hash
+local formatters = string.formatters
+local copy = table.copy
+local insert = table.insert
+local remove = table.remove
+
+local matrix = { }
+moduledata.matrix = matrix
+
+local f_matrix_slot = formatters["%s_{%s%s}"]
+
+function matrix.symbolic(sym, x, y, nx ,ny) -- symMatrix("a", "m", "n")
+ local nx = nx or 2
+ local ny = ny or nx
+ local function filled(i,y)
+ local mrow = { }
+ for j=1,nx do
+ mrow[#mrow+1] = f_matrix_slot(sym,i,j)
+ end
+ mrow[#mrow+1] = "\\cdots"
+ mrow[#mrow+1] = f_matrix_slot(sym,i,y)
+ return mrow
+ end
+ local function dummy()
+ local mrow = { }
+ for j=1,nx do
+ mrow[#mrow+1] = "\\vdots"
+ end
+ mrow[#mrow+1] = "\\ddots"
+ mrow[#mrow+1] = "\\vdots"
+ return mrow
+ end
+ --
+ local mm = { }
+ for i=1,ny do
+ mm[i] = filled(i,y)
+ end
+ mm[#mm+1] = dummy()
+ mm[#mm+1] = filled(x,y)
+ return mm
+end
+
+-- todo: define a matrix at the tex end so that we have more control
+
+local fences_p = {
+ left = "\\left(\\,",
+ right = "\\,\\right)",
+}
+
+local fences_b = {
+ left = "\\left[\\,",
+ right = "\\,\\right]",
+}
+
+function matrix.typeset(m,options)
+ local options = settings_to_hash(options or "")
+ context.startmatrix(options.determinant and fences_b or fences_p)
+ for i=1, #m do
+ local mi = m[i]
+ for j=1,#mi do
+ context.NC(mi[j])
+ end
+ context.NR()
+ end
+ context.stopmatrix()
+end
+
+-- interchange two rows (i-th, j-th)
+
+function matrix.swap(t,i,j)
+ t[i], t[j] = t[j], t[i]
+end
+
+-- replace i-th row with factor * (i-th row)
+
+function matrix.multiply(m,i,factor)
+ local mi = m[i]
+ for k=1,#mi do
+ mi[k] = factor * mi[k]
+ end
+ return m
+end
+
+-- scalar product "factor * m"
+
+function matrix.scalar(m, factor)
+ for i=1,#m do
+ local mi = m[i]
+ for j=1,#mi do
+ mi[j] = factor * mi[j]
+ end
+ end
+ return m
+end
+
+-- replace i-th row with i-th row + factor * (j-th row)
+
+function matrix.sumrow(m,i,j,factor)
+ local mi = m[i]
+ local mj = m[j]
+ for k=1,#mi do
+ mi[k] = mi[k] + factor * mj[k]
+ end
+end
+
+-- transpose of a matrix
+
+function matrix.transpose(m)
+ local t = { }
+ for j=1,#m[1] do
+ local r = { }
+ for i=1,#m do
+ r[i] = m[i][j]
+ end
+ t[j] = r
+ end
+ return t
+end
+
+-- inner product of two vectors
+
+function matrix.inner(u,v)
+ local nu = #u
+ if nu == 0 then
+ return 0
+ end
+ local nv = #v
+ if nv ~= nu then
+ return 0
+ end
+ local result = 0
+ for i=1,nu do
+ result = result + u[i] * v[i]
+ end
+ return result
+end
+
+-- product of two matrices
+
+function matrix.product(m1,m2)
+ local product = { }
+ if #m1[1] == #m2 then
+ for i=1,#m1 do
+ local m1i = m1[i]
+ local mrow = { }
+ for j=1,#m2[1] do
+ local temp = 0
+ for k=1,#m1[1] do
+ temp = temp + m1i[k] * m2[k][j]
+ end
+ mrow[j] = temp
+ end
+ product[i] = mrow
+ end
+ end
+ return product
+end
+
+local function uppertri(m,sign)
+ local temp = copy(m)
+ for i=1,#temp-1 do
+ local pivot = temp[i][i]
+ if pivot == 0 then
+ local pRow = i +1
+ while temp[pRow][i] == 0 do
+ pRow = pRow + 1
+ if pRow > #temp then -- if there is no nonzero number
+ return temp
+ end
+ end
+ temp[i], temp[pRow] = temp[pRow], temp[i]
+ if sign then
+ sign = -sign
+ end
+ end
+ local mi = temp[i]
+ for k=i+1, #temp do
+ local factor = -temp[k][i]/mi[i]
+ local mk = temp[k]
+ for l=i,#mk do
+ mk[l] = mk[l] + factor * mi[l]
+ end
+ end
+ end
+ if sign then
+ return temp, sign
+ else
+ return temp
+ end
+end
+
+matrix.uppertri = uppertri
+
+function matrix.determinant(m)
+ if #m == #m[1] then
+ local d = 1
+ local t, s = uppertri(m,1)
+ for i=1,#t do
+ d = d * t[i][i]
+ end
+ return s*d
+ else
+ return 0
+ end
+end
+
+local function rowechelon(m,r)
+ local temp = copy(m)
+ local pRow = 1
+ local pCol = 1
+ while pRow <= #temp do
+ local pivot = temp[pRow][pCol]
+ if pivot == 0 then
+ local i = pRow
+ local n = #temp
+ while temp[i][pCol] == 0 do
+ i = i + 1
+ if i > n then
+ -- no nonzero number in a column
+ pCol = pCol + 1
+ if pCol > #temp[pRow] then
+ -- there is no nonzero number in a row
+ return temp
+ end
+ i = pRow
+ end
+ end
+ temp[pRow], temp[i] = temp[i], temp[pRow]
+ end
+ local row = temp[pRow]
+ pivot = row[pCol]
+ for l=pCol,#row do
+ row[l] = row[l]/pivot
+ end
+
+ if r == 1 then
+ -- make the "reduced row echelon form"
+ local row = temp[pRow]
+ for k=1,pRow-1 do
+ local current = temp[k]
+ local factor = -current[pCol]
+ local mk = current
+ for l=pCol,#mk do
+ mk[l] = mk[l] + factor * row[l]
+ end
+ end
+ end
+ -- just make the row echelon form
+ local row = temp[pRow]
+ for k=pRow+1, #temp do
+ local current = temp[k]
+ local factor = -current[pCol]
+ local mk = current
+ for l=pCol,#mk do
+ mk[l] = mk[l] + factor * row[l]
+ end
+ end
+ pRow = pRow + 1
+ pCol = pCol + 1
+
+ if pRow > #temp or pCol > #temp[1] then
+ pRow = #temp + 1
+ end
+ end
+ return temp
+end
+
+matrix.rowechelon = rowechelon
+matrix.rowEchelon = rowechelon
+
+-- solve the linear equation m X = c
+
+local function solve(m,c)
+ local n = #m
+ if n ~= #c then
+ return copy(m)
+ end
+ local newm = copy(m)
+ local temp = copy(c)
+ for i=1,n do
+ insert(newm[i],temp[i])
+ end
+ return rowechelon(newm,1)
+end
+
+matrix.solve = solve
+
+-- find the inverse matrix of m
+
+local function inverse(m)
+ local n = #m
+ local temp = copy(m)
+ if n ~= #m[1] then
+ return temp
+ end
+ for i=1,n do
+ for j=1,n do
+ insert(temp[i],j == i and 1 or 0)
+ end
+ end
+ temp = rowechelon(temp,1)
+ for i=1,n do
+ for j=1,n do
+ remove(temp[i], 1)
+ end
+ end
+ return temp
+end
+
+matrix.inverse = inverse
+
+\stopluacode
+
+\stopmodule
+
+\unexpanded\def\ctxmodulematrix#1{\ctxlua{moduledata.matrix.#1}}
+
+\continueifinputfile{m-matrix.mkiv}
+
+\starttext
+
+\startluacode
+document.DemoMatrixA = {
+ { 0, 2, 4, -4, 1 },
+ { 0, 0, 2, 3, 4 },
+ { 2, 2, -6, 2, 4 },
+ { 2, 0, -6, 9, 7 },
+ { 2, 3, 4, 5, 6 },
+ { 6, 6, -6, 6, 6 },
+}
+
+document.DemoMatrixB = {
+ { 0, 2, 4, -4, 1 },
+ { 0, 0, 2, 3, 4 },
+ { 2, 2, -6, 2, 4 },
+ { 2, 0, -6, 9, 7 },
+ { 2, 2, -6, 2, 4 },
+ { 2, 2, -6, 2, 4 },
+}
+\stopluacode
+
+\startsubject[title={A symbolic matrix}]
+
+\ctxmodulematrix{typeset(moduledata.matrix.symbolic("a", "m", "n"))}
+\ctxmodulematrix{typeset(moduledata.matrix.symbolic("a", "m", "n", 4, 8))}
+
+\stopsubject
+
+\startsubject[title={Swap two rows (2 and 4)}]
+
+\startluacode
+moduledata.matrix.typeset(document.DemoMatrixA)
+context.blank()
+moduledata.matrix.swap(document.DemoMatrixA, 2, 4)
+context.blank()
+moduledata.matrix.typeset(document.DemoMatrixA)
+\stopluacode
+
+\stopsubject
+
+\startsubject[title={Multiply $3 \times r_2$}]
+
+\startluacode
+moduledata.matrix.typeset(document.DemoMatrixA)
+context.blank()
+moduledata.matrix.typeset(moduledata.matrix.multiply(document.DemoMatrixA, 2, 3))
+\stopluacode
+
+\stopsubject
+
+\startsubject[title={Row 2 + $3 \times r_4$}]
+
+\startluacode
+moduledata.matrix.typeset(document.DemoMatrixA)
+context.blank()
+moduledata.matrix.sumrow(document.DemoMatrixA, 2, 3, 4)
+context.blank()
+moduledata.matrix.typeset(document.DemoMatrixA)
+\stopluacode
+
+\stopsubject
+
+\startsubject[title={Transpose a matrix}]
+
+\startluacode
+moduledata.matrix.typeset(document.DemoMatrixA)
+context.blank()
+moduledata.matrix.typeset(moduledata.matrix.transpose(document.DemoMatrixA))
+\stopluacode
+
+\stopsubject
+
+\startsubject[title={The inner product of two vectors}]
+
+\startluacode
+context(moduledata.matrix.inner({ 1, 2, 3 }, { 3, 1, 2 }))
+context.blank()
+context(moduledata.matrix.inner({ 1, 2, 3 }, { 3, 1, 2, 4 }))
+\stopluacode
+
+\startsubject[title={The product of two matrices}]
+
+\startluacode
+moduledata.matrix.typeset(document.DemoMatrixA)
+context.blank()
+moduledata.matrix.typeset(moduledata.matrix.product(document.DemoMatrixA,document.DemoMatrixA))
+\stopluacode
+
+\stopsubject
+
+\startsubject[title={An Upper Triangular Matrix}]
+
+\ctxmodulematrix{typeset(moduledata.matrix.uppertri(document.DemoMatrixB))}
+
+\startsubject[title={A determinant}]
+
+\startluacode
+local m = {
+ { 1, 2, 4 },
+ { 0, 0, 2 },
+ { 2, 2, -6 },
+}
+context(moduledata.matrix.determinant(m))
+\stopluacode
+
+\stopsubject
+
+\startsubject[title={Row echelon form}]
+
+\startluacode
+local m = {
+ { 1, 3, -2, 0, 2, 0, 0 },
+ { 2, 6, -5, -2, 4, -3, -1 },
+ { 0, 0, 5, 10, 0, 15, 5 },
+ { 2, 6, 0, 8, 4, 18, 6 },
+}
+
+moduledata.matrix.typeset(m)
+moduledata.matrix.typeset(moduledata.matrix.rowechelon(m,1))
+\stopluacode
+
+\stopsubject
+
+\startsubject[title={Solving linear equation}]
+
+\startluacode
+local m = {
+ { 1, 3, -2, 0 },
+ { 2, 0, 1, 2 },
+ { 6, -5, -2, 4 },
+ { -3, -1, 5, 10 },
+}
+
+local c = { 5, 2, 6, 8 }
+
+moduledata.matrix.typeset(moduledata.matrix.solve(m,c))
+\stopluacode
+
+\stopsubject
+
+\startsubject[title={Inverse matrix}]
+
+\startcombination[2*1]
+ {\ctxlua{moduledata.matrix.typeset { { 1, 1, 1 }, { 0, 2, 3 }, { 3, 2, 1 } }}} {}
+ {\ctxlua{moduledata.matrix.typeset(moduledata.matrix.inverse { { 1, 1, 1 }, { 0, 2, 3 }, { 3, 2, 1 } })}} {}
+\stopcombination
+
+\stopsubject
+
+\stoptext
diff --git a/Master/texmf-dist/tex/context/modules/mkiv/m-mkii.mkiv b/Master/texmf-dist/tex/context/modules/mkiv/m-mkii.mkiv
new file mode 100644
index 00000000000..dcfd29d2092
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkiv/m-mkii.mkiv
@@ -0,0 +1,21 @@
+% todo
+
+\unprotect
+
+\writestatus\m!system{loading some mkii compatibility hacks}
+
+% Compatibility for font-ini
+
+\let\normalxi=\xi
+
+\definebodyfontswitch [xii] [\!!twelvepoint]
+\definebodyfontswitch [xi] [\!!elevenpoint]
+\definebodyfontswitch [x] [\!!tenpoint]
+\definebodyfontswitch [ix] [\!!ninepoint]
+\definebodyfontswitch [viii] [\!!eightpoint]
+\definebodyfontswitch [vii] [\!!sevenpoint]
+\definebodyfontswitch [vi] [\!!sixpoint]
+
+\unexpanded\def\xi{\ifmmode\normalxi\else\elevenpoint\fi}
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/modules/mkiv/m-mkivhacks.mkiv b/Master/texmf-dist/tex/context/modules/mkiv/m-mkivhacks.mkiv
new file mode 100644
index 00000000000..3ed002e1d50
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkiv/m-mkivhacks.mkiv
@@ -0,0 +1,50 @@
+%D \module
+%D [ file=m-mkivhacks,
+%D version=2008.10.20,
+%D title=\CONTEXT\ Modules,
+%D subtitle=Temporary Compatilibility Hacks,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+%D For Aditya, who needed it for his thesis.
+
+\startluacode
+ -- -- a lot or work
+ --
+ -- mathematics.slots.euler = {
+ -- [0x03B1] = { "mr", 0x0B }, -- alpha
+ -- }
+ --
+ -- mathematics.slots.euler = table.merge(mathematics.slots.traditional,mathematics.slots.euler)
+ --
+ -- versus a quick hack
+
+ document.hacks = document.hacks or { }
+
+ function document.hacks()
+ mathematics.families.lcgreek = mathematics.families.mr
+ mathematics.families.ucgreek = mathematics.families.mr
+ mathematics.families.vargreek = mathematics.families.mr
+
+ mathematics.define(mathematics.slots.euler)
+ end
+\stopluacode
+
+% \usemodule[mkivhacks] \setups{eulermath}
+% \definetypeface[modern][mm][math][euler][default]
+% \usemathcollection[eul]
+% \switchtobodyfont[modern,11pt]
+% \starttext
+% $\alpha$
+% \stoptext
+
+\startsetups eulermath
+ \ctxlua{document.hacks()}
+\stopsetups
+
+\endinput
diff --git a/Master/texmf-dist/tex/context/modules/mkiv/m-morse.mkvi b/Master/texmf-dist/tex/context/modules/mkiv/m-morse.mkvi
new file mode 100644
index 00000000000..a2c20dff745
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkiv/m-morse.mkvi
@@ -0,0 +1,273 @@
+%D \module
+%D [ file=m-morse,
+%D version=2010.12.10,
+%D title=\CONTEXT\ Extra Modules,
+%D subtitle=Morse,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+% todo: act upon the node list
+% make it a buffer operation
+% nice in cld manual
+
+\startluacode
+
+moduledata.morse = moduledata.morse or { }
+local morse = moduledata.morse
+
+local utfcharacters, gsub = string.utfcharacters, string.gsub
+local ucchars, shchars = characters.ucchars, characters.shchars
+
+local codes = {
+
+ ["A"] = "·—",
+ ["B"] = "—···",
+ ["C"] = "—·—·",
+ ["D"] = "—··",
+ ["E"] = "·",
+ ["F"] = "··—·",
+ ["G"] = "——·",
+ ["H"] = "····",
+ ["I"] = "··",
+ ["J"] = "·———",
+ ["K"] = "—·—",
+ ["L"] = "·—··",
+ ["M"] = "——",
+ ["N"] = "—·",
+ ["O"] = "———",
+ ["P"] = "·——·",
+ ["Q"] = "——·—",
+ ["R"] = "·—·",
+ ["S"] = "···",
+ ["T"] = "—",
+ ["U"] = "··—",
+ ["V"] = "···—",
+ ["W"] = "·——",
+ ["X"] = "—··—",
+ ["Y"] = "—·——",
+ ["Z"] = "——··",
+
+ ["0"] = "—————",
+ ["1"] = "·————",
+ ["2"] = "··———",
+ ["3"] = "···——",
+ ["4"] = "····—",
+ ["5"] = "·····",
+ ["6"] = "—····",
+ ["7"] = "——···",
+ ["8"] = "———··",
+ ["9"] = "————·",
+
+ ["."] = "·—·—·—",
+ [","] = "——··——",
+ [":"] = "———···",
+ [";"] = "—·—·—",
+
+ ["?"] = "··——··",
+ ["!"] = "—·—·——",
+
+ ["-"] = "—····—",
+ ["/"] = "—··—· ",
+
+ ["("] = "—·——·",
+ [")"] = "—·——·—",
+
+ ["="] = "—···—",
+ ["@"] = "·——·—·",
+
+ ["'"] = "·————·",
+ ['"'] = "·—··—·",
+
+ ["À"] = "·——·—",
+ ["Å"] = "·——·—",
+ ["Ä"] = "·—·—",
+ ["Æ"] = "·—·—",
+ ["Ç"] = "—·—··",
+ ["É"] = "··—··",
+ ["È"] = "·—··—",
+ ["Ñ"] = "——·——",
+ ["Ö"] = "———·",
+ ["Ø"] = "———·",
+ ["Ü"] = "··——",
+ ["ß"] = "··· ···",
+
+}
+
+morse.codes = codes
+
+local fallbackself = false
+
+local function codefallback(t,k)
+ if k then
+ local u = ucchars[k]
+ local v = rawget(t,u) or rawget(t,shchars[u]) or false
+ t[k] = v
+ return v
+ elseif fallbackself then
+ return k
+ else
+ return false
+ end
+end
+
+table.setmetatableindex(codes,codefallback)
+
+local MorseBetweenWords = context.MorseBetweenWords
+local MorseBetweenCharacters = context.MorseBetweenCharacters
+local MorseLong = context.MorseLong
+local MorseShort = context.MorseShort
+local MorseSpace = context.MorseSpace
+local MorseUnknown = context.MorseUnknown
+
+local function toverbose(str)
+ str = gsub(str,"%s*+%s*","+")
+ str = gsub(str,"%s+"," ")
+ local done = false
+ for m in utfcharacters(str) do
+ if done then
+ MorseBetweenCharacters()
+ end
+ if m == "·" or m == "." then
+ MorseShort()
+ done = true
+ elseif m == "—" or m == "-" then
+ MorseLong()
+ done = true
+ elseif m == " " then
+ if done then
+ MorseBetweenCharacters()
+ end
+ done = false
+ elseif m == "+" then
+ MorseBetweenWords()
+ done = false
+ else
+ MorseUnknown(m)
+ end
+ end
+end
+
+local function toregular(str)
+ local inmorse = false
+ for s in utfcharacters(str) do
+ local m = codes[s]
+ if m then
+ if inmorse then
+ MorseBetweenWords()
+ else
+ inmorse = true
+ end
+ local done = false
+ for m in utfcharacters(m) do
+ if done then
+ MorseBetweenCharacters()
+ else
+ done = true
+ end
+ if m == "·" then
+ MorseShort()
+ elseif m == "—" then
+ MorseLong()
+ elseif m == " " then
+ MorseBetweenCharacters()
+ end
+ end
+ inmorse = true
+ elseif s == "\n" or s == " " then
+ MorseSpace()
+ inmorse = false
+ else
+ if inmorse then
+ MorseBetweenWords()
+ else
+ inmorse = true
+ end
+ MorseUnknown(s)
+ end
+ end
+end
+
+local function tomorse(str,verbose)
+ if verbose then
+ toverbose(str)
+ else
+ toregular(str)
+ end
+end
+
+morse.tomorse = tomorse
+
+function morse.filetomorse(name,verbose)
+ tomorse(resolvers.loadtexfile(name),verbose)
+end
+
+function morse.showtable()
+ context.starttabulate { "|l|l|" } -- { "|l|l|l|" }
+ for k, v in table.sortedpairs(codes) do
+ context.NC() context(k)
+ -- context.NC() context(v)
+ context.NC() tomorse(v,true)
+ context.NC() context.NR()
+ end
+ context.stoptabulate()
+end
+
+\stopluacode
+
+\unprotect
+
+% todo: \setupmorse, but probably it's not worth the trouble.
+
+\def\MorseWidth {0.4em}
+\def\MorseHeight {0.2em}
+%def\MorseShort {\dontleavehmode\blackrule[\c!height=\MorseHeight,\c!width=\dimexpr\MorseWidth]}
+%def\MorseLong {\dontleavehmode\blackrule[\c!height=\MorseHeight,\c!width=3\dimexpr\MorseWidth]}
+\def\MorseShort {\dontleavehmode\vrule\!!width \dimexpr\MorseWidth\!!height\MorseHeight\!!depth\zeropoint\relax}
+\def\MorseLong {\dontleavehmode\vrule\!!width3\dimexpr\MorseWidth\!!height\MorseHeight\!!depth\zeropoint\relax}
+\def\MorseBetweenCharacters {\kern\MorseWidth}
+\def\MorseBetweenWords {\hskip3\dimexpr\MorseWidth\relax}
+\def\MorseSpace {\hskip7\dimexpr\MorseWidth\relax}
+\def\MorseUnknown #text{[\detokenize{#text}]}
+
+\unexpanded\def\MorseCode #text{\ctxlua{moduledata.morse.tomorse(\!!bs#text\!!es,true)}}
+\unexpanded\def\MorseString #text{\ctxlua{moduledata.morse.tomorse(\!!bs#text\!!es)}}
+\unexpanded\def\MorseFile #text{\ctxlua{moduledata.morse.filetomorse("#text")}}
+\unexpanded\def\MorseTable {\ctxlua{moduledata.morse.showtable()}}
+
+\let\Morse \MorseString
+
+%def\MorseShort {·}
+%def\MorseLong {—}
+
+\protect
+
+\continueifinputfile{m-morse.mkvi}
+
+\starttext
+
+\MorseTable
+
+\startlines
+\MorseCode{—·—· ——— —· — · —··— —+—— —·— ·· ···—}
+\MorseCode{—·—· ——— —· — · —··— — + —— —·— ·· ···—}
+\Morse{ÀÁÂÃÄÅàáâãäå}
+\Morse{ÆÇæç}
+\Morse{ÈÉÊËèéêë}
+\Morse{ÌÍÎÏìíîï}
+\Morse{Ññ}
+\Morse{ÒÓÔÕÖòóôõö}
+\Morse{Øø}
+\Morse{ÙÚÛÜùúû}
+\Morse{Ýýÿ}
+\Morse{ß}
+\Morse{Ţţ}
+\stoplines
+
+\Morse{A B C D E F G H I J K L M N O P Q R S T U V W X Y Z}
+
+\stoptext
diff --git a/Master/texmf-dist/tex/context/modules/mkiv/m-narrowtt.mkiv b/Master/texmf-dist/tex/context/modules/mkiv/m-narrowtt.mkiv
new file mode 100644
index 00000000000..7d497a02f18
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkiv/m-narrowtt.mkiv
@@ -0,0 +1,39 @@
+%D \module
+%D [ file=m-narrowtt,
+%D version=2005.09.08,
+%D title=\CONTEXT\ Modules,
+%D subtitle=Narrow Verbatim,
+%D author={Hans Hagen \& Ton Otten},
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+%D Test file
+%D
+%D \starttyping
+%D \startTEX
+%D \usemodule[narrowtt]
+%D \starttext
+%D \starttyping
+%D Test test test.
+%D \stoptyping
+%D test \type {test} test \type{test} test
+%D \starttyping
+%D Test test test.
+%D \stoptyping
+%D \stoptext
+%D \stopTEX
+
+\unprotect
+
+\definetypeface
+ [narrowtt] [tt]
+ [mono] [modern-condensed] [\s!default] [\s!features=\s!none]
+
+\definetyping[n\v!typing] \setuptyping[n\v!typing][style=\narrowtt]
+\definetype [n\v!type] \setuptype [n\v!type] [style=\narrowtt]
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/modules/mkiv/m-nodechart.lua b/Master/texmf-dist/tex/context/modules/mkiv/m-nodechart.lua
new file mode 100644
index 00000000000..da80faed9ec
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkiv/m-nodechart.lua
@@ -0,0 +1,175 @@
+if not modules then modules = { } end modules ['m-nodechart'] = {
+ version = 1.001,
+ comment = "companion to m-nodechart.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+local format = string.format
+local points = number.nopts
+local ptfactor = number.dimenfactors.pt
+
+local nodecodes = nodes.nodecodes
+local kerncodes = nodes.kerncodes
+local penaltycodes = nodes.penaltycodes
+local gluecodes = nodes.gluecodes
+local whatsitcodes = nodes.whatsitcodes
+
+moduledata.charts = moduledata.charts or { }
+moduledata.charts.nodes = moduledata.charts.nodes or { }
+
+local formatters = { }
+
+-- subtype font char lang left right uchyph components xoffset yoffset width height depth
+
+function formatters.glyph(n,comment)
+ return format("\\doFLOWglyphnode{%s}{%s}{%s}{%s}{U+%05X}",comment,n.subtype,n.font,n.char,n.char)
+end
+
+-- pre post replace
+
+function formatters.disc(n,comment)
+ return format("\\doFLOWdiscnode{%s}{%s}",comment,n.subtype)
+end
+
+-- subtype kern
+
+function formatters.kern(n,comment)
+ -- return format("\\doFLOWkernnode{%s}{%s}{%s}",comment,kerncodes[n.subtype],points(n.kern))
+ return format("\\doFLOWkernnode{%s}{%s}{%.4f}",comment,kerncodes[n.subtype],n.kern*ptfactor)
+end
+
+-- subtype penalty
+
+function formatters.penalty(n,comment)
+ return format("\\doFLOWpenaltynode{%s}{%s}{%s}",comment,"penalty",n.penalty)
+end
+
+-- subtype width leader spec (stretch shrink ...
+
+function formatters.glue(n,comment)
+ return format("\\doFLOWgluenode{%s}{%s}{%.4f}{%.4f}{%.4f}",comment,gluecodes[n.subtype],n.width*ptfactor,n.stretch*ptfactor,n.shrink*ptfactor)
+end
+
+-- subtype width leader spec (stretch shrink ...
+
+function formatters.whatsit(n,comment)
+ return whatsitcodes[n.id] or "unknown whatsit"
+end
+
+function formatters.dir(n,comment)
+ return format("\\doFLOWdirnode{%s}{%s}{%s}",comment,"dir",n.dir)
+end
+
+function formatters.localpar(n,comment)
+ return format("\\doFLOWdirnode{%s}{%s}{%s}",comment,"localpar",n.dir)
+end
+
+-- I will make a dedicated set of shapes for this.
+
+local shapes = {
+ glyph = "procedure",
+ disc = "procedure",
+ kern = "action",
+ penalty = "action",
+ glue = "action",
+}
+
+local function flow_nodes_to_chart(specification)
+ local head = specification.head
+ local box = specification.box
+ local comment = specification.comment or ""
+ local x = specification.x or 1
+ local y = specification.y or 0
+ --
+ if box then
+ box = tex.getbox(tonumber(box))
+ head = box and box.list
+ end
+ --
+ local current = head
+ --
+ while current do
+ local nodecode = nodecodes[current.id]
+ local formatter = formatters[nodecode]
+ local shape = shapes[nodecode]
+ y = y + 1
+ local next = current.next
+ commands.flow_start_cell { shape = { framecolor = "nodechart:" .. nodecode } }
+ commands.flow_set_name(tostring(current))
+ commands.flow_set_location(x,y)
+ if shape then
+ commands.flow_set_shape(shape)
+ end
+ if formatter then
+ commands.flow_set_text("node",formatter(current,comment))
+ else
+ commands.flow_set_text("node",nodecode)
+ end
+ if next then
+ commands.flow_set_connection("bt","",tostring(next))
+ end
+ if nodecode == "glyph" then
+ local components = current.components
+ if components then
+ commands.flow_set_connection("rl","",tostring(components))
+ commands.flow_stop_cell()
+ n = flow_nodes_to_chart { head = components, comment = "component",x = x+2, y = y-1 }
+ else
+ commands.flow_stop_cell()
+ end
+ elseif nodecode == "disc" then
+ local pre = current.pre
+ local pos = current.post
+ local rep = current.replace
+ if pre and not rep and not rep then
+ if pre then
+ commands.flow_set_connection("rl","",tostring(pre))
+ end
+ commands.flow_stop_cell()
+ if pre then
+ n = flow_nodes_to_chart { head = pre, comment = "prebreak", x = x+1, y = y-1 }
+ end
+ else
+ if pre then
+ commands.flow_set_connection("+rl","",tostring(pre))
+ end
+ if rep then
+ commands.flow_set_connection("rl","",tostring(rep))
+ end
+ if pos then
+ commands.flow_set_connection("-rl","",tostring(pos))
+ end
+ commands.flow_stop_cell()
+ if pre then
+ n = flow_nodes_to_chart{ head = pre, comment = "prebreak", x = x+1, y = y-2 }
+ end
+ if rep then
+ n = flow_nodes_to_chart{ head = rep, comment = "replacement", x = x+1, y = y-1 }
+ end
+ if pos then
+ n = flow_nodes_to_chart{ head = pos, comment = "postbreak", x = x+1, y = y }
+ end
+ end
+ elseif nodecode == "hlist" then
+ local list = current.list
+ if list then
+ commands.flow_set_connection("rl","",tostring(list))
+ commands.flow_stop_cell()
+ n = flow_nodes_to_chart { head = list, comment = "list", x = x+2, y = y-1 }
+ else
+ commands.flow_stop_cell()
+ end
+ else
+ commands.flow_stop_cell()
+ end
+ current = next
+ end
+end
+
+function moduledata.charts.nodes.chart(specification)
+ commands.flow_start_chart(specification.name)
+ flow_nodes_to_chart(specification)
+ commands.flow_stop_chart()
+end
diff --git a/Master/texmf-dist/tex/context/modules/mkiv/m-nodechart.mkvi b/Master/texmf-dist/tex/context/modules/mkiv/m-nodechart.mkvi
new file mode 100644
index 00000000000..c9d9858506c
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkiv/m-nodechart.mkvi
@@ -0,0 +1,125 @@
+%D \module
+%D [ file=m-nodechart,
+%D version=2011.11.11, % nos sure when it started, needed for fonts-mkiv
+%D title=\CONTEXT\ Modules,
+%D subtitle=Node Visualization,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\registerctxluafile{m-nodechart}{1.001}
+
+\usemodule[chart]
+
+\unprotect
+
+\def\enspaceminus{\hskip.5em minus .25em\relax}
+
+\starttexdefinition unexpanded doFLOWglyphnode #comment #subtype #font #char #unicode
+ \dontleavehmode\hbox{\bf\setstrut\strut \doifsomething{#comment}{#comment\enspaceminus:\enspaceminus}glyph #subtype}
+ \vss
+ \dontleavehmode\hbox{\tx\setstrut\strut font\enspaceminus#font:\enspace#unicode:\enspaceminus\setfontofid{#font}\char#char}
+\stoptexdefinition
+
+\starttexdefinition unexpanded doFLOWdiscnode #comment #subtype
+ \dontleavehmode\hbox{\bf\setstrut\strut disc}
+ \vss
+ \dontleavehmode\hbox{\tx\setstrut\strut}
+\stoptexdefinition
+
+\starttexdefinition unexpanded doFLOWkernnode #comment #subtype #kern
+ \dontleavehmode\hbox{\bf\setstrut\strut#subtype}
+ \vss
+ \dontleavehmode\hbox{\tx\setstrut\strut#kern}
+\stoptexdefinition
+
+\starttexdefinition unexpanded doFLOWpenaltynode #comment #subtype #penalty
+ \dontleavehmode\hbox{\bf\setstrut\strut#subtype}
+ \vss
+ \dontleavehmode\hbox{\tx\setstrut\strut#penalty}
+\stoptexdefinition
+
+\starttexdefinition unexpanded doFLOWgluenode #comment #subtype #width #shrink #stretch
+ \dontleavehmode\hbox{\bf\setstrut\strut#subtype}
+ \vss
+ \dontleavehmode\hbox{\tx\setstrut\strut#width\enspaceminus-\enspaceminus#shrink\enspaceminus+\enspaceminus#stretch}
+\stoptexdefinition
+
+\starttexdefinition unexpanded doFLOWdirnode #comment #subtype #direction
+ \dontleavehmode\hbox{\bf\setstrut\strut#subtype}
+ \vss
+ \dontleavehmode\hbox{\tx\setstrut\strut#direction}
+\stoptexdefinition
+
+\defineframed
+ [flowcell:node]
+ [flowcell:base]
+ [\c!top=\vss,
+ \c!bottom=\vss,
+ \c!align=\v!middle,
+ \c!foregroundstyle=\tt]
+
+% this is a temporary interface ... we will have instances and optional settings
+
+\unexpanded\def\boxtoFLOWchart[#name]#box%
+ {\ctxlua{moduledata.charts.nodes.chart {
+ name = "#name",
+ box = \number#box,
+ }}}
+
+\unexpanded\def\nextboxtoFLOWchart[#name]%
+ {\dowithnextbox{\boxtoFLOWchart[#name]\nextbox}}
+
+\unexpanded\def\hboxtoFLOWchart[#name]%
+ {\nextboxtoFLOWchart[#name]\hbox}
+
+\unexpanded\def\vboxtoFLOWchart[#name]%
+ {\nextboxtoFLOWchart[#name]\vbox}
+
+\protect
+
+\continueifinputfile{m-nodechart.mkvi}
+
+\definecolor[nodechart:glyph][darkred]
+
+\setupbodyfont[dejavu,10pt]
+
+\starttext
+
+\startTEXpage[offset=10pt]
+
+ \hboxtoFLOWchart[dummy]{an affil\discretionary{-}{-}{!}iation}
+
+ \FLOWchart[dummy][width=14em,height=3em,dx=1em,dy=.75em,hcompact=yes]
+
+\stopTEXpage
+
+\startTEXpage[offset=10pt]
+
+ \hboxtoFLOWchart[dummy]{an affiliation}
+
+ \FLOWchart[dummy][width=14em,height=3em,dx=.5em,dy=.75em,hcompact=yes]
+
+\stopTEXpage
+
+\startTEXpage[offset=10pt]
+
+ \hboxtoFLOWchart[dummy]{\nl effe fijn fietsen}
+
+ \FLOWchart[dummy][width=14em,height=3em,dx=.5em,dy=.75em,hcompact=yes]
+
+\stopTEXpage
+
+\startTEXpage[offset=10pt]
+
+ \hboxtoFLOWchart[dummy]{\righttoleft t\kern 1pt est}
+
+ \FLOWchart[dummy][width=14em,height=3em,dx=.5em,dy=.75em,hcompact=yes]
+
+\stopTEXpage
+
+\stoptext
diff --git a/Master/texmf-dist/tex/context/modules/mkiv/m-ntb-to-xtb.mkiv b/Master/texmf-dist/tex/context/modules/mkiv/m-ntb-to-xtb.mkiv
new file mode 100644
index 00000000000..55b4ab25926
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkiv/m-ntb-to-xtb.mkiv
@@ -0,0 +1,5 @@
+\loadmkvifile{tabl-xnt}
+
+\mapTABLEtoxtable
+
+\endinput
diff --git a/Master/texmf-dist/tex/context/modules/mkiv/m-obsolete.mkiv b/Master/texmf-dist/tex/context/modules/mkiv/m-obsolete.mkiv
new file mode 100644
index 00000000000..2d4518181e6
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkiv/m-obsolete.mkiv
@@ -0,0 +1,5 @@
+\unprotect
+
+\writestatus\m!system{skipping obsolete module}
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/modules/mkiv/m-oldfun.mkiv b/Master/texmf-dist/tex/context/modules/mkiv/m-oldfun.mkiv
new file mode 100644
index 00000000000..3f2ec0263ed
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkiv/m-oldfun.mkiv
@@ -0,0 +1,714 @@
+%D \module
+%D [ file=m-oldfun, % was: supp-fun
+%D version=1995.10.10,
+%D title=\CONTEXT\ Support Macros,
+%D subtitle=Fun Stuff,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\unprotect
+
+%D Beware, these macros wil be replaced and at some point this
+%D module will not be preloaded any more.
+
+%D This module implements some typographics tricks that can
+%D be fun when designing document layouts. The examples use
+%D macros that are typical to \CONTEXT, but non \CONTEXT\
+%D users can use the drop caps and first line treatment
+%D macros without problems. This module will be extended
+%D when the need for more of such tricks arises.
+
+\writestatus{loading}{ConTeXt Support Macros / Fun Stuff}
+
+%D \macros
+%D {DroppedCaps, DroppedString, DroppedIndent, DroppedLines}
+%D
+%D \startbuffer
+%D \DroppedCaps
+%D {\color[green]} {SerifBold}
+%D {\the\dimexpr2.2\baselineskip} {2pt} {\the\baselineskip} {2}
+%D Let's start
+%D \stopbuffer
+%D
+%D \getbuffer with dropped caps, those blown up first
+%D characters of a paragraph. It's hard to implement a general
+%D mechanism that suits all situations, but dropped caps are so
+%D seldomly used that we can permit ourselves a rather user
+%D unfriendly implementation.
+%D
+%D \typebuffer
+%D
+%D As we will see, there are 7 different settings involved. The
+%D first argument takes a command that is used to do whatever
+%D fancy things we want to do, but normally this one will be
+%D empty. The second argument takes the font. Because we're
+%D dealing with something very typographic, there is no real
+%D reason to adopt complicated font switching schemes, a mere
+%D name will do. Font encodings can bring no harm, because the
+%D alphanumeric characters are nearly always located at their
+%D natural position in the encoding vector.
+%D
+%D \startbuffer
+%D \DroppedCaps
+%D {\color[red]} {SerifBold}
+%D {\the\baselineskip} {0pt} {0pt} {1}
+%D This simple
+%D \stopbuffer
+%D
+%D \getbuffer case shows us what happens when we apply minimal
+%D values. Here we used:
+%D
+%D \typebuffer
+%D
+%D \startbuffer
+%D \DroppedCaps
+%D {\color[red]} {SerifBold}
+%D {\the\dimexpr2\baselineskip} {0pt} {\the\baselineskip} {2}
+%D Is this ugly
+%D \stopbuffer
+%D
+%D \getbuffer example the third argument tells
+%D this macro that we want a dropped capital scaled to the
+%D baseline distance. The two zero point arguments are the
+%D horizontal and vertical offsets and the last arguments
+%D determines the hanging indentation. In this paragraph we
+%D set the height to two times the baselinedistance and use
+%D two hanging lines:
+%D
+%D \typebuffer
+%D
+%D Here, the first character is moved down one baseline. Here
+%D we also see why the horizontal offset is important. The
+%D first example (showing the~L) sets this to a few points and
+%D also used a slightly larger height.
+%D
+%D Of course common users (typist) are not supposed to see this
+%D kind of fuzzy definitions, but fortunately \TEX\ permits us
+%D to hide them in macros. Using a macro also enables us to
+%D garantee consistency throughout the document:
+%D
+%D \startbuffer
+%D \def\MyDroppedCaps%
+%D {\DroppedCaps
+%D {\color[green]} {SerifBold}
+%D {\the\dimexpr5\baselineskip} {3pt} {\the\dimexpr3\baselineskip} {4}}
+%D
+%D \MyDroppedCaps The implementation
+%D \stopbuffer
+%D
+%D \typebuffer
+%D
+%D \getbuffer of the general macro is rather simple and only
+%D depends on the arguments given and the dimensions of the
+%D strut box. We explicitly load the font, which is no problem
+%D because \TEX\ does not load a font twice. We could have
+%D combined some arguments, like the height, vertical offset
+%D and the number of lines, but the current implementation
+%D proved to be the most flexible. One should be aware of the
+%D fact that the offsets depend on the design of the glyphs
+%D used.
+
+\let\DroppedIndent\!!zeropoint \def\DroppedLines{0}
+
+\def\DroppedString{ABCDEFGHIJKLMNOPQRSTUVWXYZ}
+
+\let\globaldropcaps\global % will be an option, but on by default
+
+\unexpanded\def\localdropcaps{\let\globaldropcaps\relax}
+
+\chardef\DroppedStatus = 0 % 0=done 1=starting 2=doing 3=error
+\chardef\DropMode = 0 % 1 == marginhang
+
+\ifx\keeplinestogether\undefined
+ \let\keeplinestogether\gobbleoneargument
+\fi
+
+\unexpanded\def\DroppedCaps#1#2#3#4#5#6#7% does not yet handle accented chars
+ {\defconvertedargument\asciia{#7}%
+ \defconvertedcommand \asciib{\DroppedString}%
+ \doifelseinstring\asciia\asciib
+ {\noindentation
+ \dontleavehmode
+ \checkindentation % redo this one
+ %\ifhmode\hskip-\parindent\fi % sensitive for context mechanism
+ \keeplinestogether{#6}%
+ \setbox0\hbox{\definedfont[#2 at #3]#1{#7}\hskip#4}%
+ \ifdim\dp0>\strutdp % one of those Q's , will be option
+ \setbox2\hbox{\raise\dp0\hbox{\lower\strutdp\copy0}}%
+ \ht2\ht0
+ \dp0\strutdp
+ \setbox0\box2
+ \fi
+ \setbox0\hbox
+ {\ifnum\DropMode=\plusone
+ \hskip-\wd0\wd0\zeropoint
+ \fi
+ \lower#5\box0}%
+ \ht0\strutht
+ \dp0\strutdp
+ \ifnum\DropMode=\plusone
+ \globaldropcaps\let\DroppedIndent\!!zeropoint
+ \globaldropcaps\edef\DroppedLines{\number\maxdimen}%
+ \globaldropcaps\chardef\DroppedStatus\plusthree
+ \else
+ \globaldropcaps\edef\DroppedIndent{\the\wd0}%
+ \globaldropcaps\edef\DroppedLines {\number#6}%
+ \globaldropcaps\chardef\DroppedStatus\plustwo
+ \globaldropcaps\hangindent\DroppedIndent
+ \globaldropcaps\hangafter-\DroppedLines
+% \noindent
+ \noindentation
+ \checkindentation % redo this one
+ \hskip-\DroppedIndent
+ \fi
+ \vbox{\forgetall\box0}%
+ \nobreak
+ \let\next\ignorespaces} % Could be a one character word !
+ {\globaldropcaps\let\DroppedIndent\!!zeropoint
+ \globaldropcaps\edef\DroppedLines{\number\maxdimen}%
+ \globaldropcaps\chardef\DroppedStatus\plusthree
+ \def\next{#7}}%
+ \let\globaldropcaps\global
+ \next}
+
+%D Before we go to the next topic, we summarize this command:
+%D
+%D \starttyping
+%D \DroppedCaps
+%D {command} {font}
+%D {height} {hoffset} {voffset} {lines}
+%D \stoptyping
+%D
+%D Sometimes you need to make sure that the global settings are
+%D kept local, as in:
+%D
+% %D \startbuffer
+% %D \defineparagraphs[SomePar][n=2,rule=on]
+% %D \setupparagraphs [SomePar][1][width=.5\textwidth]
+% %D \setupparagraphs [SomePar][2][width=.5\textwidth]
+%D \startbuffer
+%D \defineparagraphs[SomePar][n=2,rule=on]
+%D \setupparagraphs [SomePar][1][width=.5\textwidth]
+%D \setupparagraphs [SomePar][2][width=.5\textwidth]
+%D
+%D \startSomePar
+%D \localdropcaps\NiceDroppedCaps{}{cmr12}{0pt}{2}Here we need
+%D to explicitly keep the hanging indentation local, like it or
+%D not.
+%D \SomePar
+%D \localdropcaps\NiceDroppedCaps{}{cmr12}{0pt}{2}Here we need
+%D to explicitly keep the hanging indentation local, like it or
+%D not.
+%D \stopSomePar
+%D \stopbuffer
+%D
+%D \typebuffer \getbuffer
+
+%D \macros
+%D {AutoDroppedCaps, CheckDroppedCaps}
+%D
+%D {\em To be documented.}
+
+% example usage
+%
+% \def\bpar{\ifvmode\CheckDroppedCaps\fi}
+% \def\epar{\ifhmode\par\fi\CheckDroppedCaps}
+
+\newcount\lastprevgraf
+\newcount\droppedlines
+
+\unexpanded\def\CheckDroppedCaps
+ {\global\lastprevgraf\prevgraf}
+
+\unexpanded\def\AutoDroppedCaps % will be proper core stuff since it
+ {\globaldropcaps\chardef\DroppedStatus\plusone
+ \global\lastprevgraf\zerocount
+ \global\droppedlines\zerocount
+ \EveryPar{\doAutoDroppedCaps}}
+
+\let\AutoDroppedNext\relax
+
+\ifx\AutoDroppedCapsCommand\undefined
+ \unexpanded\def\AutoDroppedCapsCommand{\NiceDroppedCaps{}{SerifBold}{.125em}{3}}
+\fi
+
+\unexpanded\def\doAutoDroppedCaps
+ {\ifcase\DroppedStatus % done
+ \let\next\relax
+ \or % starting
+ % \ifnum\lastprevgraf>0 % tricky, probably a wrong par
+ % \globaldropcaps\chardef\DroppedStatus=3 % and inhibits dropped
+ % \let\next\relax % caps after titles and more than once
+ % \else % so let's nill this rubishly code fragment
+ \let\next\AutoDroppedCapsCommand
+ % \fi % and hope for the best
+ \or % doing
+ \global\advance\droppedlines \lastprevgraf
+ \ifnum\droppedlines=\zerocount
+ \globaldropcaps\chardef\DroppedStatus\zerocount
+ \let\next\relax
+ \else\ifnum\droppedlines>\zerocount
+ \ifnum\droppedlines<\DroppedLines\relax
+ \globaldropcaps\hangindent\DroppedIndent
+ \globaldropcaps\hangafter-\DroppedLines
+ \globaldropcaps\advance\hangafter \droppedlines
+ \hskip-\parindent % brrr
+ \let\next\AutoDroppedNext
+ \else
+ \globaldropcaps\chardef\DroppedStatus\zerocount
+ \let\next\relax
+ \fi
+ \else
+ \globaldropcaps\chardef\DroppedStatus\zerocount
+ \let\next\relax
+ \fi\fi
+ \or % error
+ \globaldropcaps\chardef\DroppedStatus\zerocount
+ \let\next\relax
+ \fi
+ \next}
+
+%D \macros
+%D {LineDroppedCaps, NiceDroppedCaps}
+%D
+%D To save definitions, we also provide:
+%D
+%D \starttyping
+%D \LineDroppedCaps {command} {font} {hoffset} {lines}
+%D \NiceDroppedCaps {command} {font} {hoffset} {lines}
+%D \stoptyping
+%D
+%D The first command scales the font to the exact height, while
+%D the second command scales the font to a nice 2.5 times the
+%D line height, a value that gives a pleasant grayness.
+
+\unexpanded\def\DoLineDroppedCaps#1#2#3#4#5% compensation command font offset lines
+ {\scratchcounter#5%
+ \advance\scratchcounter \minusone
+ \scratchdimen\scratchcounter\baselineskip
+ \advance\scratchdimen #1%
+ \NormalizeFontHeight\DummyFont{W}\scratchdimen{#3}%
+ \DroppedCaps{#2}{#3}\TheNormalizedFontSize{#4}
+ {\scratchcounter\baselineskip}{#5}}
+
+\unexpanded\def\LineDroppedCaps% command font offset lines
+ {\DoLineDroppedCaps{\strutht}}
+
+\unexpanded\def\NiceDroppedCaps% command font offset lines
+ {\DoLineDroppedCaps{.5\baselineskip}}
+
+%D \macros
+%D {TreatFirstLine}
+%D
+%D \startbuffer
+%D \TreatFirstLine {\sc} {} {} {}
+%D Instead of limiting its action to one token, the next macro
+%D treats the whole first line. This paragraph was typeset by
+%D saying:
+%D \stopbuffer
+%D
+%D \getbuffer
+%D
+%D \typebuffer
+%D
+%D \startbuffer
+%D \TreatFirstLine {\startcolor[red]\bf} {\stopcolor} {} {}
+%D The combined color and font effect is also possible,
+%D although one must be careful in using macros that accumulate
+%D grouping, but the commands used here are pretty save in that
+%D respect.
+%D \stopbuffer
+%D
+%D \getbuffer
+%D
+%D \typebuffer
+%D
+%D Before we explain the third and fourth argument, we show the
+%D implementation. Those who know a bit about the way \TEX\
+%D treats tokens, will probably see in one glance that this
+%D alternative works all right for most text||only situations
+%D in which there is enough text available for the first line,
+%D but that more complicated things will blow. One has to live
+%D with that. A workaround is rather trivial but obscures the
+%D principles used.
+
+\unexpanded\def\TreatFirstLine#1#2#3#4% before, after, first, next
+ {\leavevmode
+ \bgroup
+ \forgetall
+ \bgroup
+ #1%
+ \setbox0\emptybox
+ \setbox2\emptybox
+ \def\grabfirstline##1 %
+ {\setbox2\hbox
+ {\ifvoid0
+ {#3{\ignorespaces##1}}%
+ \else
+ \unhcopy0\ {#4{##1}}%
+ \fi}%
+ \ifdim\wd2=\zeropoint
+ \setbox0\emptybox
+ \setbox2\emptybox
+ \@EA\grabfirstline
+ \else\ifdim\wd2>\hsize
+ \hbox to \hsize{\strut\unhbox0}#2\egroup
+ \break##1\
+ \egroup
+ \else
+ \setbox0\box2
+ \@EAEAEA\grabfirstline
+ \fi\fi}%
+ \grabfirstline}
+
+%D \startbuffer
+%D \gdef\FunnyCommand
+%D {\getrandomfloat\FunnyR{0}{1}%
+%D \getrandomfloat\FunnyG{0}{1}%
+%D \getrandomfloat\FunnyB{0}{1}%
+%D \definecolor[FunnyColor][r=\FunnyR,g=\FunnyG,b=\FunnyB]%
+%D \color[FunnyColor]}
+%D
+%D %\TreatFirstLine {\bf} {} {\FunnyCommand} {\FunnyCommand}
+%D The third and fourth argument can be used to gain special
+%D effects on the individual words. Of course one needs ...
+%D \stopbuffer
+%D
+%D \getbuffer
+%D to know a bit more about the macro package used to get real
+%D nice effects, but this example probably demonstrates the
+%D principles well.
+%D
+%D \typebuffer
+%D
+%D Like in dropped caps case, one can hide such treatments in a
+%D macro, like:
+%D
+%D \starttyping
+%D \def\MyTreatFirstLine%
+%D {\TreatFirstLine{\bf}{}{\FunnyCommand}{\FunnyCommand}}
+%D \stoptyping
+
+%D \macros
+%D {reshapebox}
+%D
+%D \startbuffer
+%D \beginofshapebox
+%D When using \CONTEXT, one can also apply this funny command
+%D to whole lines by using the reshape mechanism. Describing
+%D this interesting mechanism falls outside the scope of this
+%D module, so we only show the trick. This is an example of
+%D low level \CONTEXT\ functionality: it's all there, and it's
+%D stable, but not entirely meant for novice users.
+%D \endofshapebox
+%D
+%D \reshapebox{\FunnyCommand{\box\shapebox}} \flushshapebox
+%D \stopbuffer
+%D
+%D \getbuffer
+%D
+%D \typebuffer
+%D
+%D This mechanism permits hyphenation and therefore gives
+%D better results than the previously discussed macro
+%D \type{\TreatFirstLine}.
+
+%D \macros
+%D {TreatFirstCharacter}
+%D
+%D \startbuffer
+%D \TreatFirstCharacter{\bf\color[green]} Just to be
+%D \stopbuffer
+%D
+%D \getbuffer complete we also offer a very simple one
+%D character alternative, that is not that hard to understand:
+
+\unexpanded\def\TreatFirstCharacter#1#2% command, character
+ {{#1{#2}}}
+
+%D A previous paragraph started with:
+%D
+%D \typebuffer
+
+%D \macros
+%D {StackCharacters}
+%D
+%D The next hack deals with vertical stacking.
+
+\unexpanded\def\StackCharacters#1#2#3#4% sequence vsize vskip command
+ {\vbox #2
+ {\forgetall
+ \baselineskip\zeropoint
+ \def\StackCharacter##1{#4{##1}\cr\noalign{#3}}%
+ \halign
+ {\hss##\hss#\cr
+ \handletokens#1\with\StackCharacter\cr}}}
+
+%D \startbuffer
+%D \StackCharacters{CONTEXT}{}{\vskip.2ex}{\FunnyCommand}
+%D \stopbuffer
+%D
+%D Such a stack looks like:
+%D
+%D \startlinecorrection
+%D \hbox to \hsize
+%D {$\hss\bfd
+%D \vcenter{\StackCharacters{TEX} {}{\vskip.2ex}{\FunnyCommand}}%
+%D \hss
+%D \vcenter{\StackCharacters{CON} {}{\vskip.2ex}{\FunnyCommand}}
+%D \hss
+%D \vcenter{\StackCharacters{TEXT} {}{\vskip.2ex}{\FunnyCommand}}
+%D \hss
+%D \vcenter{\StackCharacters{CONTEXT}{}{\vskip.2ex}{\FunnyCommand}}
+%D \hss$}
+%D \stoplinecorrection
+%D
+%D and is typeset by saying:
+%D
+%D \typebuffer
+%D
+%D An alternative would have been
+%D
+%D \starttyping
+%D \StackCharacters {CONTEXT} {to 5cm} {\vfill} {\FunnyCommand}
+%D \stoptyping
+
+%D \macros
+%D {processtokens}
+%D
+%D At a lower level horizontal and vertical manipulations are
+%D already supported by:
+%D
+%D \starttyping
+%D \processtokens {begin} {between} {end} {space} {text}
+%D \stoptyping
+%D
+%D \startbuffer[a]
+%D \processtokens
+%D {\hbox to .5\hsize\bgroup} {\hfill}
+%D {\egroup} {\space} {LET'S HAVE}
+%D \stopbuffer
+%D
+%D \startbuffer[b]
+%D \processtokens
+%D {\vbox\bgroup\raggedcenter\hsize1em}
+%D {\vskip.25ex} {\egroup} {\strut} {FUN}
+%D \stopbuffer
+%D
+%D This macro is able to typeset:
+%D
+%D \leavevmode\hbox to \hsize
+%D {$\hfil\hfil
+%D \vcenter{\bf\getbuffer[a]}%
+%D \hfil
+%D \vcenter{\bfd\getbuffer[b]}%
+%D \hfil\hfil$}
+%D
+%D which was specified as:
+%D
+%D \typebuffer[a]
+%D \typebuffer[b]
+
+%D \macros
+%D {NormalizeFontHeight, NormalizeFontWidth,
+%D TheNormalizedFontSize}
+%D
+%D Next we introduce some font manipulation macros. When we
+%D want to typeset some text spread in a well defined area, it
+%D can be considered bad practice to manipulate character and
+%D word spacing. In such situations the next few macros can be
+%D of help:
+%D
+%D \starttyping
+%D \NormalizeFontHeight \name {sample text} {height} {font}
+%D \NormalizeFontWidth \name {sample text} {width} {font}
+%D \stoptyping
+%D
+%D These are implemented using an auxilliary macro:
+
+\unexpanded\def\NormalizeFontHeight{\NormalizeFontSize\ht}
+\unexpanded\def\NormalizeFontWidth {\NormalizeFontSize\wd}
+
+\unexpanded\def\NormalizeFontSize#1#2#3#4#5%
+ {\bgroup
+ \dimen0=#4% #4 can be \ht0 or so
+ \setbox0\hbox{\definedfont[#5 at 5pt]#3}% 10pt
+ \ifdim\wd0>\zeropoint
+ \dimen2=#10 % #1 is \wd or \ht
+ \dimen4=\maxdimen % 10000pt
+ \divide\dimen4 \dimen2
+ \divide\dimen0 1638 % 1000
+ \dimen0=\number\dimen4\dimen0
+ \divide \dimen0 \plustwo % ...
+ \xdef\TheNormalizedFontSize{\the\dimen0}%
+ \else
+ \dimen0\bodyfontsize
+ \fi
+ \normalexpanded{\egroup\def\noexpand#2{\definedfont[#5 at \the\dimen0]}}}
+
+%D Afterwards, we have access to the calculated size by:
+
+\let\TheNormalizedFontSize\!!zeropoint
+
+%D Extra:
+
+\unexpanded\def\WidthSpanningText#1#2#3% text width font
+ {\hbox{\NormalizeFontWidth\temp{#1}{#2}{#3}\temp\the\everydefinedfont#1}}
+
+%D Consider for instance:
+%D
+%D \startbuffer
+%D \NormalizeFontHeight \tmp {X} {2\baselineskip} {cmr10}
+%D
+%D {\tmp To Be Or Not To Be}
+%D \stopbuffer
+%D
+%D \typebuffer
+%D
+%D This shows up as (we also show the baselines):
+%D
+%D {\showbaselines\getbuffer}
+%D
+%D The horizontal counterpart is:
+%D
+%D \startbuffer
+%D \NormalizeFontWidth \tmp {This Line Fits} {\hsize} {cmr10}
+%D
+%D \hbox{\tmp This Line Fits}
+%D \stopbuffer
+%D
+%D \typebuffer
+%D
+%D The calculated font scale is avaliable in the macro
+%D \type{\NormalizedFontSize}.
+%D
+%D \startlinecorrection
+%D \ruledhbox{\getbuffer}
+%D \stoplinecorrection
+%D
+%D One can of course combine these macros with the ones
+%D described earlier, like in:
+%D
+%D \starttyping
+%D \NormalizeFontHeight {text} \DroppedFont {2\baselineskip} {cmbx12}
+%D
+%D \def\NicelyDroppedCaps
+%D {\DroppedCaps
+%D {\color[green]}
+%D {\DroppedFont}
+%D {2pt}
+%D {\baselineskip}
+%D {2}}
+%D \stoptyping
+%D
+%D It's up to the reader to test this one.
+
+\unexpanded\def\FirstNCharacters#1#2% \FirstNCharacters{3}{fr{\"o}beln}
+ {\bgroup
+ \scratchcounter\zerocount
+ \def\docommand##1%
+ {\ifnum\scratchcounter=#1\else
+ ##1\relax % catches ##1 = \"e and alike
+ \advance\scratchcounter\plusone
+ \fi}
+ \handletokens#2\with\docommand
+ \egroup}
+
+%D \macros
+%D {FittingText}
+%D
+%D First used in Pascal (demo-bbv):
+%D
+%D \startbuffer
+%D \ruledvbox{\FittingText{3cm}{1cm}{Serif}{24pt}{1pt}{1}
+%D {\veryraggedright
+%D \hangindent1em\hangafter1\relax
+%D \begstrut \dorecurse{8}{Bram Marta }\unskip \endstrut}}
+%D
+%D \ruledvbox{\FittingText{3cm}{1cm}{Serif}{24pt}{1pt}{1}
+%D {\raggedleft\begstrut Bram\\Marta \unskip\endstrut}}
+%D \stopbuffer
+%D
+%D \typebuffer
+%D
+%D \startlinecorrection
+%D \getbuffer
+%D \stoplinecorrection
+
+% #1 width #2 height #3 font #4 size #5 step #6 interlinie #7 text
+
+\unexpanded\def\FittingText#1#2#3#4#5#6#7%
+ {\bgroup
+ \forgetall
+ \dontcomplain
+ \setuptolerance[\v!verytolerant]% == \tolerance4500
+ \hsize#1%
+ \def\\{\softbreak}%
+ \!!heighta#4%
+ \!!heightb#2%
+ \doloop
+ {\ifdim\!!heighta>\onepoint
+ \expanded{\definefont[\s!dummy][#3 at \the\!!heighta][\c!interlinespace=#6]}%
+ \getvalue\s!dummy
+ \setbox\scratchbox\vbox{#7\endgraf}%
+ \ifdim\ht\scratchbox>\!!heightb
+ \advance\!!heighta-#5%
+ \else
+ \beginshapebox
+ \unvcopy\scratchbox
+ \endshapebox
+ \global\dimen1\hsize
+ \reshapebox
+ {\setbox\shapebox\hbox{\unhbox\shapebox}%
+ \ifdim\wd\shapebox>\dimen1
+ \global\dimen1\wd\shapebox
+ \fi}%
+ \ifdim\dimen1>\hsize
+ \advance\!!heighta-#5%
+ \else
+ \exitloop
+ \fi
+ \fi
+ \else
+ \exitloop
+ \fi}%
+ %\writestatus{\strippedcsname\FittingText}{height: \the\!!heighta}%
+ \unvbox\scratchbox
+ \egroup}
+
+% \font width gap font spec text
+
+\unexpanded\def\NormalizeFontWidthSpread#1#2#3#4#5#6%
+ {\global\setfalse\NFSpread
+ \scratchdimen#3%
+ \scratchdimen-.5\scratchdimen
+ \advance\scratchdimen#2\relax
+ \NormalizeFontWidth
+ #1%
+ {\def\+{\global\settrue\NFSpread\gobbleuntil\relax}%
+ \def\\{\gobbleuntil\relax}% newline
+ \setupspacing
+ #6\relax}%
+ {\scratchdimen}%
+ {#4}%
+ \ifconditional\NFSpread
+ % de gap valt in de binding
+ \else
+ \definefont[\strippedcsname#1][#4 #5]%
+ \fi}
+
+\unexpanded\def\SpreadGapText#1#2%
+ {{\def\+{\kern#1}#2}}
+
+\unexpanded\def\GapText#1#2#3#4#5% width distance font spec title
+ {\bgroup
+ \NormalizeFontWidthSpread\DummyFont{#1}{#2}{#3}{#4}{#5}%
+ \DummyFont\setupspacing\SpreadGapText{#2}{#5}\endgraf
+ \egroup}
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/modules/mkiv/m-oldnum.mkiv b/Master/texmf-dist/tex/context/modules/mkiv/m-oldnum.mkiv
new file mode 100644
index 00000000000..382c56eb674
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkiv/m-oldnum.mkiv
@@ -0,0 +1,416 @@
+%D \module
+%D [ file=m-oldnum, % was: supp-num
+%D version=1998.05.15,
+%D title=\CONTEXT\ Support Macros,
+%D subtitle=Numbers,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+% See end for transition to mkiv.
+
+\writestatus{loading}{ConTeXt Support Macros / Numbers}
+
+\unprotect
+
+%D \macros
+%D {digits, setdigitmode, setdigitsign}
+%D
+%D Depending on the digit mode the command \type {\digits}
+%D normalizes number patterns depending on the language set.
+%D
+%D \starttyping
+%D This will never be a \digits{1.000.000} seller.
+%D \stoptyping
+%D
+%D or
+%D
+%D \starttyping
+%D I will never grow longer than \digits 1.86 \Meter.
+%D \stoptyping
+%D
+%D The different modes are shown in:
+%D
+%D \startbuffer
+%D \setdigitmode 1 \digits 12.345,90 \digits 12.345.000 \digits 1,23
+%D \setdigitmode 2 \digits 12.345,90 \digits 12.345.000 \digits 1,23
+%D \setdigitmode 3 \digits 12.345,90 \digits 12.345.000 \digits 1,23
+%D \setdigitmode 4 \digits 12.345,90 \digits 12.345.000 \digits 1,23
+%D \setdigitmode 5 \digits 12.345,90 \digits 12.345.000 \digits 1,23
+%D \setdigitmode 6 \digits 12.345,90 \digits 12.345.000 \digits 1,23
+%D \stopbuffer
+%D
+%D \typebuffer
+%
+% This is typset as:
+%
+% \startlines
+% \getbuffer
+% \stoplines
+%D
+%D The sign can be typeset as is or within the space of a
+%D digit.
+%D
+%D \startbuffer
+%D \setdigitsign 0 \digits +12.345,90
+%D \setdigitsign 1 \digits +12.345,90
+%D \setdigitsign 2 \digits +12.345,90
+%D \setdigitsign 3 \digits +12.345,90
+%D \stopbuffer
+%D
+%D \typebuffer
+%D
+% This is typset as:
+%
+% \startlines
+% \getbuffer
+% \stoplines
+
+\chardef\digitoutputmode=1 % 0..6
+\chardef\digitsignmode =0 % 0..3
+
+\unexpanded\def\setdigitmode{\chardef\digitoutputmode}
+\unexpanded\def\setdigitsign{\chardef\digitsignmode}
+
+%D The digit modes are:
+%D
+%D \startitemize[packed]
+%D \item periods \& comma
+%D \item commas \& period
+%D \item thinmuskips \& comma
+%D \item thinmuskips \& period
+%D \item thickmuskips \& comma
+%D \item thickmuskips \& period
+%D \stopitemize
+
+\let\collecteddigits \empty \chardef\digitinputmode =1
+\let\saveddigits \empty \chardef\skipdigit =0
+\let\savedpowerdigits\empty \chardef\powerdigits =0
+
+%D The first stage of the \type {\digit} macro takes care of
+%D the grouped call, the other branch handles the fuzzy
+%D delimited calls.
+
+\ifdefined\mbox \else \let\mbox\hbox \fi
+
+\unexpanded\def\digits
+ {\bgroup
+ \let~@%
+ \doifelsenextbgroup\dodigits{\doifelsenextchar\normalmathshift\domathdigits\grabdigit}}
+
+\def\dodigits#1%
+ {\grabdigit#1\relax}
+
+\def\domathdigits$#1$%
+ {\mbox{\grabdigit#1\relax}} % adding $ $ goes wrong in tabulate
+
+\def\grabdigit
+ {\futurelet\next\scandigit}
+
+%D Watch the test for \type {\nextobeyedline}, because the
+%D endofline token can be \type {\def'd}, not \type {\let}'d,
+%D we need to do an indirect test (see \type {verb-ini.tex})
+%D for details. (This probably needs an update.)
+
+\ifx\normalmathshift\undefined \let\normalmathshift=$ \fi
+
+\unexpanded\def\scandigit
+ {\ifx\next\blankspace
+ \let\next\handledigits
+ \else\ifx\next\nextobeyedline % the indirect one
+ \let\next\handledigits
+ \else\ifx\next\bgroup
+ \let\next\handledigits
+ \else\ifx\next\egroup
+ \let\next\handledigits
+ \else\ifx\next\normalmathshift
+ \let\next\handledigits
+ \else
+ \let\next\collectdigit
+ \fi\fi\fi\fi\fi
+ \next}
+
+%D We store the power||of||ten (to be signaled by \type {^},
+%D \type {e} or~\type {E}) in a seperate macro so that we can
+%D typeset it in superscript. The space placeholders are
+%D replaced by a \type {@}.
+
+\unexpanded\def\savedigit#1#2%
+ {\edef#1{#1\saveddigits#2}\let\saveddigits\empty}
+
+\unexpanded\def\collectdigit#1%
+ {\ifx#1~%
+ \savedigit\collecteddigits @%
+ \else\if#1_% tricky as can be several catcodes ... will become lua code anyway
+ \savedigit\collecteddigits @%
+ \else\if\noexpand#1\relax
+ \let\grabdigit\handledigits
+ \else\ifcase\powerdigits
+ \if#1E%
+ \chardef\powerdigits\plusone
+ \else\if#1e%
+ \chardef\powerdigits\plusone
+ \else\if#1^%
+ \chardef\powerdigits\plusone
+ \else
+ \savedigit\collecteddigits#1%
+ %\doifelsenumber{#1}
+ % {\savedigit\collecteddigits#1}
+ % {\def\saveddigits{#1}}%
+ \fi\fi\fi
+ \else
+ \savedigit\savedpowerdigits#1%
+ %\doifelsenumber{#1}
+ % {\savedigit\savedpowerdigits#1}
+ % {\def\saveddigits{#1}}%
+ \fi\fi\fi\fi
+ \grabdigit}
+
+\let\handlemathdigits\firstofoneargument
+\let\handletextdigits\mathematics
+
+\unexpanded\def\handledigits
+ {%\ifcase\powerdigits
+ % \edef\collecteddigits{\collecteddigits\saveddigits}%
+ %\else
+ % \edef\savedpowerdigits{\savedpowerdigits\saveddigits}%
+ %\fi
+ \ifmmode
+ \handlemathdigits{\dohandledigits}%
+ \else
+ \dontleavehmode\hbox{\handletextdigits{\dohandledigits}}%
+ \fi
+ \egroup}
+
+%D Although we could do with one pass, a second pass for
+%D handling the stored sequence is more readable.
+
+\ifnum\texengine=\luatexengine
+
+ \def\dohandledigits
+ {\mathcode`\,="002C \mathcode`\.="002E % pretty hard coded
+ \expandafter\handletokens\collecteddigits\with\scandigits
+ \ifcase\powerdigits\else\digitpowerseparator^{\savedpowerdigits}\fi}
+
+ \chardef\mathaxisfontid\zerocount
+
+\else
+
+ \def\dohandledigits
+ {\mathcode`\,="013B \mathcode`\.="013A % pretty hard coded
+ \expandafter\handletokens\collecteddigits\with\scandigits
+ \ifcase\powerdigits\else\digitpowerseparator^{\savedpowerdigits}\fi}
+
+ \chardef\mathaxisfontid\plustwo
+
+\fi
+
+\def\doscandigit#1%
+ {\ifcase\skipdigit\@EA\hbox\else\@EA\hphantom\fi\bgroup
+ \mathematics % brr, needed because of stored punctuation
+ {\ifnum\digitinputmode=#1\relax
+ \ifcase\digitoutputmode
+ \or .%
+ \or ,%
+ \or \mskip\thinmuskip
+ \or \mskip\thinmuskip
+ \or \mskip\thickmuskip
+ \or \mskip\thickmuskip
+ \fi
+ \else
+ \ifodd\digitoutputmode,\else.\fi
+ \fi}%
+ \egroup}
+
+%D The signs can be made smaller and sqeezed into the width
+%D of a digit. Watch the \type {\mathaxisheight} trickery (this
+%D font related register stored the math axis).
+
+% 0,=
+% 0,== second = results in delta(00,=)
+% 0,- is invalid, should be =
+% 0,-- is invalid, should be ==
+
+\unexpanded\def\digitzeroamount
+ {\digitsgn\zeroamount
+ \def\digitzeroamount
+ {\hphantom
+ {00\setbox\scratchbox\hbox{$\zeroamount$}%
+ \hskip-\wd\scratchbox}%
+ \let\digitzeroamount\empty}}
+
+\unexpanded\def\scandigits#1%
+ {\if#1.\digitsep1\else
+ \if#1,\digitsep2\else
+ \if#1@\digitnop \else
+ \if#1_\digitnop \else
+ \if#1/\digitsgn{\hphantom{+}}\chardef\skipdigit0\else
+ \if#1-\ifcase\skipdigit\digitsgn-\else
+ \box\digitsepbox\digitzeroamount \fi\chardef\skipdigit0\else
+ \if#1+\digitsgn+\chardef\skipdigit0\else
+ \if#1=\box\digitsepbox\digitzeroamount \chardef\skipdigit0\else
+ \if#1s\digitsgn{\hphantom{\positive}}\chardef\skipdigit0\else
+ \if#1p\digitsgn\positive\chardef\skipdigit0\else
+ \if#1m\digitsgn\negative\chardef\skipdigit0\else
+ \if#1n\digitsgn\negative\chardef\skipdigit0\else
+ \box\digitsepbox #1\chardef\skipdigit0\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi}
+
+\newbox\digitsepbox \chardef\autodigitmode=1
+
+\unexpanded\def\digitsep#1%
+ {\ifcase\autodigitmode
+ \doscandigit#1%
+ \else
+ \setbox\digitsepbox\hbox{\doscandigit#1}%
+ \fi
+ \chardef\skipdigit0\relax}
+
+% strange, does not work
+%
+% \def\digitnop
+% {\hphantom{\box\digitsepbox}%
+% \hphantom{0}\chardef\skipdigit1\relax}
+%
+% while this works
+
+\unexpanded\def\digitnop
+ {\hbox{\hphantom{\box\digitsepbox}}%
+ \hphantom{0}\chardef\skipdigit1\relax}
+
+% but this doesn't
+%
+% \def\digitnop
+% {\hphantom{\box\digitsepbox0}%
+% \chardef\skipdigit1\relax}
+
+\unexpanded\def\digitsgn#1%
+ {\ifcase\digitsignmode#1\else
+ \hbox
+ {\setbox\scratchbox\hbox{0}%
+ \scratchdimen\mathaxisheight\textfont\mathaxisfontid
+ \def\digitsgn##1##2%
+ {\advance\scratchdimen-\mathaxisheight##1\mathaxisfontid
+ \raise\scratchdimen
+ \hbox to \wd\scratchbox{\hss$##2#1$\hss}}%
+ \ifcase\digitsignmode\or
+ \digitsgn\textfont \textstyle \or
+ \digitsgn\scriptfont \scriptstyle \or
+ \digitsgn\scriptscriptfont\scriptscriptstyle\fi}%
+ \fi}
+
+\ifx\undefined\zeroamount \def\zeroamount{-} \fi
+\ifx\undefined\positive \def\positive {+} \fi
+\ifx\undefined\negative \def\negative {-} \fi
+
+%D The digit parser handles a bunch of special characters as
+%D well as different formats. We strongly suggest you to use
+%D the grouped call.
+%D
+%D \starttabulate[|l|l|l|]
+%D \NC \type{.} \NC , . \NC comma or period \NC \NR
+%D \NC \type{,} \NC , . \NC comma or period \NC \NR
+%D \NC \type{@} \NC \NC invisible space \NC \NR
+%D \NC \type{_} \NC \NC invisible space \NC \NR
+%D \NC \type{/} \NC \NC invisible sign \NC \NR
+%D \NC \type{-} \NC $-$ \NC minus sign \NC \NR
+%D \NC \type{+} \NC $+$ \NC plus sign \NC \NR
+%D \NC \type{s} \NC \NC invisible high sign \NC \NR
+%D \NC \type{p} \NC $\positive$ \NC high plus sign \NC \NR
+%D \NC \type{m} \NC $\negative$ \NC high minus sign \NC \NR
+%D \NC \type{n} \NC $\negative$ \NC high minus (negative) sign \NC \NR
+%D \NC \type{=} \NC $\zeroamount$ \NC zero padding \NC \NR
+%D \stoptabulate
+%D
+%D These triggers are used in the following examples.
+%D
+%D \startbuffer
+%D \digits 12
+%D \digits{~~~.~~~.~~~.68.712,34}
+%D \digits ~~~.~~~.~~~.68.712,34
+%D \digits ___.___.111.68.712,34
+%D \digits 111.111.111.68.712,34
+%D \digits 12.345,90
+%D \digits 12.345.000
+%D \digits 12,34
+%D \digits{392.857.230.68.712,34}
+%D {\digits1234}
+%D \digits{1234}
+%D \digits 1234\relax
+%D $\digits 123.222,00$
+%D \digits 123.222,00
+%D \digits 123.222,==
+%D \digits 123.222,00^10
+%D \digits 123.222,00e10
+%D \digits /123.222,00e-12
+%D \digits -123.222,00e-12
+%D \digits +123.222,00e-12
+%D \digits n123.222,00e-12
+%D \digits s123.222,00e-12
+%D \digits p123.222,00e-12
+%D \stopbuffer
+%D
+%D \typebuffer
+%
+% \startlines
+% \getbuffer
+% \stoplines
+
+%D \macros
+%D {Digits}
+%D
+%D We also permit:
+
+\let\Digits\digits
+
+%D These macros are complicated by the fact that we also
+%D have to support cases like:
+%D
+%D \starttyping
+%D {\digits1234}
+%D \digits{1234}
+%D \digits 1234\whatever
+%D $\digits 123.222,00$
+%D \digits 123.222,00.
+%D \stoptyping
+%D
+%D The latter case shows us that trailing non digits are to
+%D be passed untreated.
+%D
+%D Another interesting case is:
+%D
+%D \starttyping
+%D \digits 123.222,00^10
+%D \stoptyping
+%D
+%D The separator is defined as:
+
+% \def\digitpowerseparator%
+% {\cdot10} % {\times10}
+
+\def\digitpowerseparator
+ {\ifx\collecteddigits\empty\else\cdot\fi10}
+
+%D \macros
+%D {digittemplate}
+%D
+%D Users can specify the way they enter those digits by saying
+%D something like:
+%D
+%D \starttyping
+%D \digittemplate 12.000.000,00 % \digittemplate .,
+%D \stoptyping
+
+\unexpanded\def\digittemplate #1 %
+ {\chardef\digitinputmode\zerocount
+ \handletokens#1\with\scandigittemplate}
+
+\unexpanded\def\scandigittemplate#1%
+ {\if #1.\ifcase\digitinputmode\chardef\digitinputmode\plusone \fi% period
+ \else\if#1,\ifcase\digitinputmode\chardef\digitinputmode\plustwo \fi% comma
+ \fi\fi}
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/modules/mkiv/m-pictex.mkiv b/Master/texmf-dist/tex/context/modules/mkiv/m-pictex.mkiv
new file mode 100644
index 00000000000..73aad3f57df
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkiv/m-pictex.mkiv
@@ -0,0 +1,46 @@
+%D \module
+%D [ file=m-pictex,
+%D version=1997.01.15,
+%D title=\CONTEXT\ Extra Modules,
+%D subtitle=\PICTEX\ Loading Macros,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+%D Just in case someone still uses \PICTEX:
+
+\ifdefined\beginpicture \else
+
+ \ifdefined\grid \else
+ \let\normalgrid\grid
+ \fi
+
+ \ifdefined\axis \else
+ \let\normalaxis\axis
+ \fi
+
+ \ifdefined\fiverm \else
+ \font\fiverm=cmr5
+ \fi
+
+ \input prepictex.tex \relax
+ \input pictex.tex \relax
+ \input postpictex.tex \relax
+
+ \ifdefined\normalgrid
+ \let\pictexgrid\grid
+ \let\grid\normalgrid
+ \fi
+
+ \ifdefined\normalaxis
+ \let\pictexaxis\axis
+ \let\axis\normalaxis
+ \fi
+
+\fi
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/modules/mkiv/m-pipemode.mkiv b/Master/texmf-dist/tex/context/modules/mkiv/m-pipemode.mkiv
new file mode 100644
index 00000000000..e96394c431e
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkiv/m-pipemode.mkiv
@@ -0,0 +1,7 @@
+% For Mojca: context --global m-pipemode.mkiv
+
+\disabledirectives[system.errorcontext]
+
+\starttext
+
+\let\stoptext\relax
diff --git a/Master/texmf-dist/tex/context/modules/mkiv/m-pstricks.lua b/Master/texmf-dist/tex/context/modules/mkiv/m-pstricks.lua
new file mode 100644
index 00000000000..b151e313ac8
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkiv/m-pstricks.lua
@@ -0,0 +1,74 @@
+if not modules then modules = { } end modules ['m-pstricks'] = {
+ version = 1.001,
+ comment = "companion to m-pstricks.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+-- The following will be done when I need ps tricks figures
+-- in large quantities:
+--
+-- + hash graphics and only process them once
+-- + save md5 checksums in tuc file
+--
+-- It's no big deal but has a low priority.
+
+local format, lower, concat, gmatch = string.format, string.lower, table.concat, string.gmatch
+local variables = interfaces.variables
+
+moduledata.pstricks = moduledata.pstricks or { }
+
+local report_pstricks = logs.reporter("pstricks")
+
+local template = [[
+\starttext
+ \pushcatcodetable
+ \setcatcodetable\texcatcodes
+ \usemodule[pstric]
+ %s
+ \popcatcodetable
+ \startTEXpage
+ \hbox\bgroup
+ \ignorespaces
+ %s
+ \removeunwantedspaces
+ \egroup
+ \obeydepth %% temp hack as we need to figure this out
+ \stopTEXpage
+\stoptext
+]]
+
+local loaded = { }
+local graphics = 0
+
+function moduledata.pstricks.usemodule(names)
+ for name in gmatch(names,"([^%s,]+)") do
+ loaded[#loaded+1] = format([[\readfile{%s}{}{}]],name)
+ end
+end
+
+function moduledata.pstricks.process(n)
+ graphics = graphics + 1
+ local name = format("%s-pstricks-%04i",tex.jobname,graphics)
+ local data = buffers.collectcontent("def-"..n)
+ local tmpfile = name .. ".tmp"
+ local epsfile = name .. ".ps"
+ local pdffile = name .. ".pdf"
+ local loaded = concat(loaded,"\n")
+ os.remove(epsfile)
+ os.remove(pdffile)
+ io.savedata(tmpfile,format(template,loaded,data))
+ os.execute(format("mtxrun --script texexec %s --once --dvips",tmpfile))
+ if lfs.isfile(epsfile) then
+ os.execute(format("ps2pdf %s %s",epsfile,pdffile))
+ -- todo: direct call but not now
+ if lfs.isfile(pdffile) then
+ context.externalfigure( { pdffile }, { object = variables.no } )
+ else
+ report_pstricks("run failed, no pdf file")
+ end
+ else
+ report_pstricks("run failed, no ps file")
+ end
+end
diff --git a/Master/texmf-dist/tex/context/modules/mkiv/m-pstricks.mkiv b/Master/texmf-dist/tex/context/modules/mkiv/m-pstricks.mkiv
new file mode 100644
index 00000000000..421607aafe9
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkiv/m-pstricks.mkiv
@@ -0,0 +1,65 @@
+%D \module
+%D [ file=m-pstricks,
+%D version=2010.03.14,
+%D title=\CONTEXT\ Extra Modules,
+%D subtitle=\PSTRICKS\ Connections,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\registerctxluafile{m-pstricks}{}
+
+\unprotect
+
+% best we can make a special colors module
+%
+% \let\@unused\plussixteen
+% \let\alloc@ \gobblefivearguments
+%
+% \def\loadpstrickscolors#1%
+% {\pushmacro\dodefinecolor
+% \pushmacro\dodefinepalet
+% \pushmacro\dodefinecolorgroup
+% \def\dodefinecolor[##1][##2]%
+% {\doifassignmentelse{##2}
+% {\getparameters[pstricks][r=0,g=0,b=0,##2]%
+% \expanded{\newrgbcolor{##1}{{\pstricksr} {\pstricksg} {\pstricksb}}}}%
+% {}}%
+% \def\dodefinepalet [##1][##2]{}%
+% \def\dodefinecolorgroup[##1][##2][##3]{}%
+% \writestatus{pstricks}{loading colors from #1}%
+% \input #1 \relax
+% \popmacro\dodefinecolorgroup
+% \popmacro\dodefinepalet
+% \popmacro\dodefinecolor}
+%
+% \input multido \relax
+% \input pstricks \relax
+% \input pst-plot \relax
+%
+% \loadpstrickscolors{colo-rgb}
+
+\definebuffer[PSTRICKS]
+
+\unexpanded\def\processPSTRICKS {\ctxlua{moduledata.pstricks.process(\thebuffernumber{PSTRICKS})}}
+\unexpanded\def\usePSTRICKSmodule[#1]{\ctxlua{moduledata.pstricks.usemodule("#1")}}
+\unexpanded\def\setPSTRICKS #1{\setbuffer[def-\thebuffernumber{PSTRICKS}]#1\endbuffer}
+
+\let\stopPSTRICKS\processPSTRICKS
+
+%D \starttyping
+%D \usemodule[pstricks]
+%D \usePSTRICKSmodule[pst-barcode]
+%D
+%D \startPSTRICKS
+%D \pspicture(-4mm,-1mm)(38mm,26mm)
+%D \psbarcode{9781860742712}{includetext guardwhitespace}{ean13}%
+%D \endpspicture
+%D \stopPSTRICKS
+%D \stoptyping
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/modules/mkiv/m-punk.mkiv b/Master/texmf-dist/tex/context/modules/mkiv/m-punk.mkiv
new file mode 100644
index 00000000000..331e90d2e99
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkiv/m-punk.mkiv
@@ -0,0 +1,257 @@
+%D \module
+%D [ file=m-punk,
+%D version=2008.04.15,
+%D title=\CONTEXT\ Modules,
+%D subtitle=Punk Support,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\ifx\luaversion\undefined \endinput \fi
+
+% At some point the font generation code will move into the
+% ConTeXt MkIV kernel.
+
+\startluacode
+local concat = table.concat
+local chardata = characters.data
+local fontdata = fonts.hashes.identifiers
+
+fonts.mp = fonts.mp or { }
+
+fonts.mp.version = fonts.mp.version or 1.15
+fonts.mp.inline = true
+fonts.mp.cache = containers.define("fonts", "mp", fonts.mp.version, true)
+
+metapost.characters = metapost.characters or { }
+
+-- todo: use table share as in otf
+
+local characters, descriptions = { }, { }
+local factor, l, n, w, h, d, total, variants = 100, { }, 0, 0, 0, 0, 0, 0, true
+
+-- A next version of mplib will provide the tfm font information which
+-- gives better glyph dimensions, plus additional kerning information.
+
+local flusher = {
+ startfigure = function(chrnum,llx,lly,urx,ury)
+ l, n = { }, chrnum
+ w, h, d = urx - llx, ury, -lly
+ total = total + 1
+ inline = fonts.mp.inline
+ end,
+ flushfigure = function(t)
+ for i=1, #t do
+ l[#l+1] = t[i]
+ end
+ end,
+ stopfigure = function()
+ local cd = chardata[n]
+ if inline then
+ descriptions[n] = {
+ -- unicode = n,
+ name = cd and cd.adobename,
+ width = w*100,
+ height = h*100,
+ depth = d*100,
+ boundingbox = { 0, -d, w, h },
+ }
+ characters[n] = {
+ commands = { -- todo: xforms, should happen in backend
+ { "special", "pdf: " .. concat(l," ") },
+ }
+ }
+ else
+ descriptions[n] = {
+ -- unicode = n,
+ name = cd and cd.adobename,
+ width = w*100,
+ height = h*100,
+ depth = d*100,
+ boundingbox = { 0, -d, w, h },
+ }
+ characters[n] = {
+ commands = {
+ { "image", { stream = concat(l," "), bbox = { 0, -d*65536, w*65536, h*65536 } } },
+ }
+ }
+ end
+ end
+}
+
+metapost.characters.instances = metapost.characters.instances or 10
+
+function metapost.characters.process(mpxformat, name, instances, scalefactor)
+ statistics.starttiming(metapost.characters)
+ scalefactor = scalefactor or 1
+ instances = instances or metapost.characters.instances or 10
+ local fontname = file.removesuffix(file.basename(name))
+ local hash = file.robustname(string.format("%s %05i %03i", fontname, scalefactor*1000, instances))
+ local lists = containers.read(fonts.mp.cache, hash)
+ if not lists then
+ statistics.starttiming(flusher)
+ -- we can use a format per font
+ local data = io.loaddata(resolvers.findfile(name))
+ metapost.reset(mpxformat)
+ metapost.setoutercolor(2) -- no outer color and no reset either
+ lists = { }
+ for i=1,instances do
+ characters = { }
+ descriptions = { }
+ metapost.process(
+ mpxformat,
+ {
+ "randomseed := " .. i*10 .. ";",
+ "scale_factor := " .. scalefactor .. " ;",
+ data
+ },
+ false,
+ flusher,
+ false,
+ false,
+ "all"
+ )
+ lists[i] = {
+ characters = characters,
+ descriptions = descriptions,
+ parameters = {
+ designsize = 655360,
+ slant = 0,
+ space = 333 * scalefactor,
+ space_stretch = 166.5 * scalefactor,
+ space_shrink = 111 * scalefactor,
+ x_height = 431 * scalefactor,
+ quad = 1000 * scalefactor,
+ extra_space = 0,
+ },
+ properties = {
+ name = string.format("%s-%03i",hash,i),
+ virtualized = true,
+ spacer = "space",
+ }
+ }
+ end
+ metapost.reset(mpxformat) -- saves memory
+ lists = containers.write(fonts.mp.cache, hash, lists)
+ statistics.stoptiming(flusher)
+ end
+ variants = variants + #lists
+ statistics.stoptiming(metapost.characters)
+ return lists
+end
+
+function fonts.handlers.vf.combiner.commands.metafont(g,v)
+ local size = g.specification.size
+ local data = metapost.characters.process(v[2],v[3],v[4],size/655360)
+ local list, t = { }, { }
+ for d=1,#data do
+ t = data[d]
+ t = fonts.constructors.scale(t, -1000)
+ local id = font.nextid()
+ t.fonts = { { id = id } }
+ fontdata[id] = t
+ fonts.handlers.vf.helpers.composecharacters(t)
+ list[d] = font.define(t)
+ end
+ for k, v in next, t do
+ g[k] = v -- kind of replace, when not present, make nil
+ end
+ g.properties.virtualized = true
+ g.variants = list
+end
+
+fonts.definers.methods.install( "punk", {
+ { "metafont", "mfplain", "punkfont.mp", 10 },
+} )
+fonts.definers.methods.install( "punkbold", {
+ { "metafont", "mfplain", "punkfont-bold.mp", 10 },
+} )
+fonts.definers.methods.install( "punkslanted", {
+ { "metafont", "mfplain", "punkfont-slanted.mp", 10 },
+} )
+fonts.definers.methods.install( "punkboldslanted", {
+ { "metafont", "mfplain", "punkfont-boldslanted.mp", 10 },
+} )
+
+-- typesetters.cases.register("RandomPunk", function(current)
+-- local used = fontdata[current].variants
+-- if used then
+-- local f = math.random(1,#used)
+-- current.font = used[f]
+-- return current, true
+-- else
+-- return current, false
+-- end
+-- end)
+
+local getfont = nodes.nuts.getfont
+local setfield = nodes.nuts.setfield
+local random = math.random
+
+typesetters.cases.register("RandomPunk", function(start)
+ local used = fontdata[getfont(start)].variants
+ if used then
+ local f = random(1,#used)
+ setfield(start,"font",used[f])
+ return start, true
+ else
+ return start, false
+ end
+end)
+
+metapost.characters.flusher = flusher
+
+statistics.register("metapost font generation", function()
+ local time = statistics.elapsedtime(flusher)
+ if total > 0 then
+ return string.format("%i glyphs, %.3f seconds runtime, %i glyphs/second", total, time, total/time)
+ else
+ return string.format("%i glyphs, %.3f seconds runtime", total, time)
+ end
+end)
+
+statistics.register("metapost font loading",function()
+ local time = statistics.elapsedtime(metapost.characters)
+ if variants > 0 then
+ return string.format("%.3f seconds, %i instances, %0.3f instances/second", time, variants, variants/time)
+ else
+ return string.format("%.3f seconds, %i instances", time, variants)
+ end
+end)
+\stopluacode
+
+\unexpanded\def\EnableRandomPunk {\setcharactercasing[RandomPunk]}
+\unexpanded\def\RandomPunk {\groupedcommand\EnableRandomPunk\donothing}
+\unexpanded\def\StartRandomPunk {\begingroup\EnableRandomPunk}
+\unexpanded\def\StopRandomPunk {\endgroup}
+
+\starttypescript [serif] [punk]
+ \definefontsynonym [Serif] [demo@punk]
+ \definefontsynonym [SerifBold] [demobold@punkbold]
+ \definefontsynonym [SerifSlanted] [demoslanted@punkslanted]
+ \definefontsynonym [SerifBoldSlanted] [demoboldslanted@punkboldslanted]
+ \definefontsynonym [SerifItalic] [SerifSlanted]
+ \definefontsynonym [SerifBoldItalic] [SerifBoldSlanted]
+\stoptypescript
+
+\starttypescript [punk]
+ \definetypeface [punk] [rm] [serif] [punk] [default]
+\stoptypescript
+
+\endinput
+
+\usetypescript[punk]
+
+\setupbodyfont[punk,14pt]
+
+\starttext
+ \definedfont[demo@punk at 10pt]hello world\par
+ \definedfont[demo@punk at 12pt]hello world\par
+ \definedfont[demo@punk at 16pt]hello world\par
+ \definedfont[demo@punk at 20pt]hello world\par
+\stoptext
+
diff --git a/Master/texmf-dist/tex/context/modules/mkiv/m-scite.mkiv b/Master/texmf-dist/tex/context/modules/mkiv/m-scite.mkiv
new file mode 100644
index 00000000000..71f31becef3
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkiv/m-scite.mkiv
@@ -0,0 +1,289 @@
+%D \module
+%D [ file=m-scite,
+%D version=2014.04.28,
+%D title=\CONTEXT\ Extra Modules,
+%D subtitle=\SCITE\ lexers,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+% We can simplify the scite lexers, as long as we're able to return the
+% lexed result table and provide alexer module with the functions that
+% the lexer expects (so I need to decipher the cxx file).
+%
+% lexer._TOKENSTYLES : table
+% lexer._CHILDREN : flag
+% lexer._EXTRASTYLES : table
+% lexer._GRAMMAR : flag
+%
+% lexers.load : function
+% lexers.lex : function
+%
+% And some properties that map styles onto scintilla styling. I get the
+% impression that we end up with something simpler, a hybrid between the
+% scite lexing and the current context way, so we get an intermediate
+% step, with some penalty for context, but at least I don't have to
+% maintain two sets (three sets as we also have a line based series).
+
+% TODO: as these files are in tds we can locate them and set the lexer root
+% to that one. Currently we're on: we're on context/documents.
+
+% TODO: tab
+
+% This is an experiment: eventually we need to hook it into the verbatim code
+% and deal with widow lines and so.
+
+\startluacode
+
+-- todo: merge with collapse
+-- todo: prehash whitespaces
+
+-- todo: hook into the pretty print code
+-- todo: a simple catcode regime with only \ { }
+
+local gsub, sub, find = string.gsub, string.sub, string.find
+local concat = table.concat
+local formatters = string.formatters
+local lpegmatch = lpeg.match
+local setmetatableindex = table.setmetatableindex
+
+local scite = require("util-sci")
+buffers.scite = scite
+
+-- context output:
+
+local f_def_color = formatters["\\definecolor[slxc%s][h=%s%s%s]%%"]
+local f_fore_none = formatters["\\def\\slx%s#1{{\\slxc%s#1}}%%"]
+local f_fore_bold = formatters["\\def\\slx%s#1{{\\slxc%s\\bf#1}}%%"]
+local f_none_bold = formatters["\\def\\slx%s#1{{\\bf#1}}%%"]
+local f_none_none = formatters["\\def\\slx%s#1{{#1}}%%"]
+local f_texstyled = formatters["\\slx%s{%s}"]
+
+local f_mapping = [[
+\let\string\slxL\string\letterleftbrace
+\let\string\slxR\string\letterrightbrace
+\let\string\slxM\string\letterdollar
+\let\string\slxV\string\letterbar
+\let\string\slxU\string\letterhat
+\let\string\slxD\string\letterunderscore
+\let\string\slxH\string\letterhash
+\let\string\slxB\string\letterbackslash
+\let\string\slxP\string\letterpercent
+\let\string\slxT\string\lettertilde
+\let\string\slxS\string\fixedspace
+%]]
+
+local replacer = lpeg.replacer {
+ ["{"] = "\\slxL ",
+ ["}"] = "\\slxR ",
+ ["$"] = "\\slxM ",
+ ["^"] = "\\slxU ",
+ ["_"] = "\\slxD ",
+ ["|"] = "\\slxV ",
+ ["#"] = "\\slxH ",
+ ["\\"] = "\\slxB ",
+ ["%"] = "\\slxP ",
+ ["~"] = "\\slxT ",
+ [" "] = "\\slxS ",
+}
+
+local colors = nil
+
+local function exportcolors()
+ if not colors then
+ scite.loadscitelexer()
+ local function black(f)
+ return (f[1] == f[2]) and (f[2] == f[3]) and (f[3] == '00')
+ end
+ local result, r = { f_mapping }, 1
+ for k, v in table.sortedhash(lexer.context.styles) do
+ local fore = v.fore
+ if fore and not black(fore) then
+ r = r + 1
+ result[r] = f_def_color(k,fore[1],fore[2],fore[3])
+ end
+ end
+ r = r + 1
+ result[r] = "%"
+ for k, v in table.sortedhash(lexer.context.styles) do
+ local bold = v.bold
+ local fore = v.fore
+ r = r + 1
+ if fore and not black(fore) then
+ if bold then
+ result[r] = f_fore_bold(k,k)
+ else
+ result[r] = f_fore_none(k,k)
+ end
+ else
+ if bold then
+ result[r] = f_none_bold(k)
+ else
+ result[r] = f_none_none(k)
+ end
+ end
+ end
+ colors = concat(result,"\n")
+ end
+ return colors
+end
+
+local function exportwhites()
+ return setmetatableindex(function(t,k)
+ local v = find(k,"white") and true or false
+ t[k] = v
+ return v
+ end)
+end
+
+local function exportstyled(lexer,text)
+ local result = lexer.lex(lexer,text,0)
+ local start = 1
+ local whites = exportwhites()
+ local buffer = { }
+ for i=1,#result,2 do
+ local style = result[i]
+ local position = result[i+1]
+ local txt = sub(text,start,position-1)
+ txt = lpegmatch(replacer,txt)
+ if whites[style] then
+ buffer[#buffer+1] = txt
+ else
+ buffer[#buffer+1] = f_texstyled(style,txt)
+ end
+ start = position
+ end
+ buffer = concat(buffer)
+ return buffer
+end
+
+function scite.installcommands()
+ context(exportcolors())
+end
+
+local function lexdata(data,lexname)
+ buffers.assign("lex",exportstyled(scite.loadedlexers[lexname],data or ""))
+end
+
+scite.lexdata = lexdata
+
+function scite.lexbuffer(name,lexname)
+ lexdata(buffers.getcontent(name) or "",lexname or "tex")
+end
+
+function scite.lexfile(filename,lexname)
+ lexdata(io.loaddata(filename) or "",lexname or file.suffix(filename))
+end
+
+-- html output
+
+\stopluacode
+
+% This is a preliminary interface.
+
+\unprotect
+
+\unexpanded\def\installscitecommands
+ {\ctxlua{buffers.scite.installcommands()}%
+ \let\installscitecommands\relax}
+
+\unexpanded\def\startscite
+ {\begingroup
+ \dosingleempty\buff_scite_start}
+
+\def\buff_scite_start[#1]%
+ {\edef\currentscitelexer{#1}%
+ \dostartbuffer[@scite@][startscite][stopscite]}
+
+\unexpanded\def\stopscite
+ {\scitebuffer[\ifx\currentscitelexer\empty tex\else\currentscitelexer\fi][@scite@]%
+ \endgroup}
+
+\unexpanded\def\scitefile
+ {\dosingleargument\module_scite_file}
+
+\unexpanded\def\module_scite_file[#1]%
+ {\start
+ \ctxlua{buffers.scite.lexfile("#1")}%
+ \installscitecommands
+ \tt
+ \dontcomplain
+ \startcontextcode
+ \startlines
+ \getbuffer[lex]%
+ \stoplines
+ \stopcontextcode
+ \stop}
+
+\unexpanded\def\scitebuffer
+ {\dodoubleargument\module_scite_buffer}
+
+\unexpanded\def\module_scite_buffer[#1][#2]%
+ {\start
+ \ifsecondargument
+ \ctxlua{buffers.scite.lexbuffer("#2","#1")}%
+ \else
+ \ctxlua{buffers.scite.lexbuffer("#1","tex")}%
+ \fi
+ \installscitecommands
+ \tt
+ \dontcomplain
+ \setcatcodetable\ctxcatcodes % needed in xml
+ \startlines
+ \getbuffer[lex]%
+ \stoplines
+ \stop}
+
+\protect
+
+\continueifinputfile{m-scite.mkiv}
+
+\setupbodyfont[dejavu,8pt]
+
+\setuplayout
+ [width=middle,
+ height=middle,
+ header=1cm,
+ footer=1cm,
+ topspace=1cm,
+ bottomspace=1cm,
+ backspace=1cm]
+
+\startbuffer[demo]
+\startsubsubject[title={oeps}]
+
+\startMPcode
+ draw fullcircle
+ scaled 2cm
+ withpen pencircle scaled 1mm
+ withcolor .5green;
+ draw textext (
+ lua (
+ "local function f(s) return string.upper(s) end mp.quoted(f('foo'))"
+ )
+ ) withcolor .5red ;
+\stopMPcode
+
+\startluacode
+ context("foo")
+\stopluacode
+
+\stopsubsubject
+\stopbuffer
+
+\starttext
+
+% \scitefile[../lexers/scite-context-lexer.lua] \page
+% \scitefile[t:/manuals/about/about-metafun.tex] \page
+% \scitefile[t:/sources/strc-sec.mkiv] \page
+% \scitefile[e:/tmp/mp.w] \page
+% \scitefile[t:/manuals/hybrid/tugboat.bib] \page
+\scitefile[e:/tmp/test.bib] \page
+
+% \getbuffer[demo] \scitebuffer[demo]
+
+\stoptext
diff --git a/Master/texmf-dist/tex/context/modules/mkiv/m-spreadsheet.lua b/Master/texmf-dist/tex/context/modules/mkiv/m-spreadsheet.lua
new file mode 100644
index 00000000000..1b3c5cb34f5
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkiv/m-spreadsheet.lua
@@ -0,0 +1,332 @@
+if not modules then modules = { } end modules ['m-spreadsheet'] = {
+ version = 1.001,
+ comment = "companion to m-spreadsheet.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+local byte, format, gsub, find = string.byte, string.format, string.gsub, string.find
+local R, P, S, C, V, Cs, Cc, Ct, Cg, Cf, Carg = lpeg.R, lpeg.P, lpeg.S, lpeg.C, lpeg.V, lpeg.Cs, lpeg.Cc, lpeg.Ct, lpeg.Cg, lpeg.Cf, lpeg.Carg
+local lpegmatch, patterns = lpeg.match, lpeg.patterns
+local setmetatable, loadstring, next, tostring, tonumber,rawget = setmetatable, loadstring, next, tostring, tonumber, rawget
+local formatters = string.formatters
+
+local context = context
+
+local splitthousands = utilities.parsers.splitthousands
+local variables = interfaces.variables
+
+local v_yes = variables.yes
+
+moduledata = moduledata or { }
+
+local spreadsheets = { }
+moduledata.spreadsheets = spreadsheets
+
+local data = {
+ -- nothing yet
+}
+
+local settings = {
+ period = ".",
+ comma = ",",
+}
+
+spreadsheets.data = data
+spreadsheets.settings = settings
+
+local defaultname = "default"
+local stack = { }
+local current = defaultname
+
+local d_mt ; d_mt = {
+ __index = function(t,k)
+ local v = { }
+ setmetatable(v,d_mt)
+ t[k] = v
+ return v
+ end,
+}
+
+local s_mt ; s_mt = {
+ __index = function(t,k)
+ local v = settings[k]
+ t[k] = v
+ return v
+ end,
+}
+
+function spreadsheets.setup(t)
+ for k, v in next, t do
+ settings[k] = v
+ end
+end
+
+local function emptydata(name,settings)
+ local data = { }
+ local specifications = { }
+ local settings = settings or { }
+ setmetatable(data,d_mt)
+ setmetatable(specifications,d_mt)
+ setmetatable(settings,s_mt)
+ return {
+ name = name,
+ data = data,
+ maxcol = 0,
+ maxrow = 0,
+ settings = settings,
+ temp = { }, -- for local usage
+ specifications = specifications,
+ }
+end
+
+function spreadsheets.reset(name)
+ if not name or name == "" then name = defaultname end
+ data[name] = emptydata(name,data[name] and data[name].settings)
+end
+
+function spreadsheets.start(name,s)
+ if not name or name == "" then
+ name = defaultname
+ end
+ if not s then
+ s = { }
+ end
+ table.insert(stack,current)
+ current = name
+ if data[current] then
+ setmetatable(s,s_mt)
+ data[current].settings = s
+ else
+ data[current] = emptydata(name,s)
+ end
+end
+
+function spreadsheets.stop()
+ current = table.remove(stack)
+end
+
+spreadsheets.reset()
+
+local offset = byte("A") - 1
+
+local function assign(s,n)
+ return formatters["moduledata.spreadsheets.data['%s'].data[%s]"](n,byte(s)-offset)
+end
+
+function datacell(a,b,...)
+ local n = 0
+ if b then
+ local t = { a, b, ... }
+ for i=1,#t do
+ n = n * (i-1) * 26 + byte(t[i]) - offset
+ end
+ else
+ n = byte(a) - offset
+ end
+ return formatters["dat[%s]"](n)
+end
+
+local function checktemplate(s)
+ if find(s,"%",1,true) then
+ -- normal template
+ return s
+ elseif find(s,"@",1,true) then
+ -- tex specific template
+ return gsub(s,"@","%%")
+ else
+ -- tex specific quick template
+ return "%" .. s
+ end
+end
+
+local quoted = Cs(patterns.unquoted)
+local spaces = patterns.whitespace^0
+local cell = C(R("AZ"))^1 / datacell * (Cc("[") * (R("09")^1) * Cc("]") + #P(1))
+
+-- A nasty aspect of lpeg: Cf ( spaces * Cc("") * { "start" ... this will create a table that will
+-- be reused, so we accumulate!
+
+local pattern = Cf ( spaces * Ct("") * { "start",
+ start = V("value") + V("set") + V("format") + V("string") + V("code"),
+ value = Cg(P([[=]]) * spaces * Cc("kind") * Cc("value")) * V("code"),
+ set = Cg(P([[!]]) * spaces * Cc("kind") * Cc("set")) * V("code"),
+ format = Cg(P([[@]]) * spaces * Cc("kind") * Cc("format")) * spaces * Cg(Cc("template") * Cs(quoted/checktemplate)) * V("code"),
+ string = Cg(#S([["']]) * Cc("kind") * Cc("string")) * Cg(Cc("content") * quoted),
+ code = spaces * Cg(Cc("code") * Cs((cell + P(1))^0)),
+}, rawset)
+
+local functions = { }
+spreadsheets.functions = functions
+
+function functions._s_(row,col,c,f,t)
+ local r = 0
+ if f and t then -- f..t
+ -- ok
+ elseif f then -- 1..f
+ f, t = 1, f
+ else
+ f, t = 1, row - 1
+ end
+ for i=f,t do
+ local ci = c[i]
+ if type(ci) == "number" then
+ r = r + ci
+ end
+ end
+ return r
+end
+
+functions.fmt = string.tformat
+
+local f_code = formatters [ [[
+ local _m_ = moduledata.spreadsheets
+ local dat = _m_.data['%s'].data
+ local tmp = _m_.temp
+ local fnc = _m_.functions
+ local row = %s
+ local col = %s
+ function fnc.sum(...) return fnc._s_(row,col,...) end
+ local sum = fnc.sum
+ local fmt = fnc.fmt
+ return %s
+]] ]
+
+-- to be considered: a weak cache
+
+local function propername(name)
+ if name ~= "" then
+ return name
+ elseif current ~= "" then
+ return current
+ else
+ return defaultname
+ end
+end
+
+-- if name == "" then name = current if name == "" then name = defaultname end end
+
+local function execute(name,r,c,str)
+ if str ~= "" then
+ local d = data[name]
+ if c > d.maxcol then
+ d.maxcol = c
+ end
+ if r > d.maxrow then
+ d.maxrow = r
+ end
+ local specification = lpegmatch(pattern,str,1,name)
+ d.specifications[c][r] = specification
+ local kind = specification.kind
+ if kind == "string" then
+ return specification.content or ""
+ else
+ local code = specification.code
+ if code and code ~= "" then
+ code = f_code(name,r,c,code or "")
+ local result = loadstring(code) -- utilities.lua.strippedloadstring(code,true) -- when tracing
+ result = result and result()
+ if type(result) == "function" then
+ result = result()
+ end
+ if type(result) == "number" then
+ d.data[c][r] = result
+ end
+ if not result then
+ -- nothing
+ elseif kind == "set" then
+ -- no return
+ elseif kind == "format" then
+ return formatters[specification.template](result)
+ else
+ return result
+ end
+ end
+ end
+ end
+end
+
+function spreadsheets.set(name,r,c,str)
+ name = propername(name)
+ execute(name,r,c,str)
+end
+
+function spreadsheets.get(name,r,c,str)
+ name = propername(name)
+ local dname = data[name]
+ if not dname then
+ -- nothing
+ elseif not str or str == "" then
+ context(dname.data[c][r] or 0)
+ else
+ local result = execute(name,r,c,str)
+ if result then
+-- if type(result) == "number" then
+-- dname.data[c][r] = result
+-- result = tostring(result)
+-- end
+ local settings = dname.settings
+ local split = settings.split
+ local period = settings.period
+ local comma = settings.comma
+ if split == v_yes then
+ result = splitthousands(result)
+ end
+ if period == "" then period = nil end
+ if comma == "" then comma = nil end
+ result = gsub(result,".",{ ["."] = period, [","] = comma })
+ context(result)
+ end
+ end
+end
+
+function spreadsheets.doifelsecell(name,r,c)
+ name = propername(name)
+ local d = data[name]
+ local d = d and d.data
+ local r = d and rawget(d,r)
+ local c = r and rawget(r,c)
+ commands.doifelse(c)
+end
+
+local function simplify(name)
+ name = propername(name)
+ local data = data[name]
+ if data then
+ data = data.data
+ local temp = { }
+ for k, v in next, data do
+ local t = { }
+ temp[k] = t
+ for kk, vv in next, v do
+ if type(vv) == "function" then
+ t[kk] = ""
+ else
+ t[kk] = vv
+ end
+ end
+ end
+ return temp
+ end
+end
+
+local function serialize(name)
+ local s = simplify(name)
+ if s then
+ return table.serialize(s,name)
+ else
+ return formatters[""](name)
+ end
+end
+
+spreadsheets.simplify = simplify
+spreadsheets.serialize = serialize
+
+function spreadsheets.inspect(name)
+ inspect(serialize(name))
+end
+
+function spreadsheets.tocontext(name)
+ context.tocontext(simplify(name))
+end
diff --git a/Master/texmf-dist/tex/context/modules/mkiv/m-spreadsheet.mkiv b/Master/texmf-dist/tex/context/modules/mkiv/m-spreadsheet.mkiv
new file mode 100644
index 00000000000..914a2b57a9e
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkiv/m-spreadsheet.mkiv
@@ -0,0 +1,221 @@
+%D \module
+%D [ file=m-spreadsheet,
+%D version=2011.02.21,
+%D title=\CONTEXT\ Extra Modules,
+%D subtitle=Spreadsheets,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+%D This is an experimental follow up on discussion on the mailing list.
+
+\registerctxluafile{m-spreadsheet}{1.001}
+
+\unprotect
+
+% todo: get(...) set(..) ctx(...)
+
+\installcorenamespace{spreadsheet}
+
+\installcommandhandler \??spreadsheet {spreadsheet} \??spreadsheet
+
+\appendtoks
+ \ctxlua{moduledata.spreadsheets.setup{ % global !
+ period = \!!bs\spreadsheetparameter\c!period\!!es,
+ comma = \!!bs\spreadsheetparameter\c!comma\!!es,
+ split = \!!bs\spreadsheetparameter\c!split\!!es,
+ }}%
+\to \everysetupspreadsheet
+
+\setupspreadsheet
+ [%\c!comma=,
+ %\c!period=,
+ \c!split=\v!no]
+
+\unexpanded\def\resetspreadsheet
+ {\dosingleempty\module_spreadsheet_reset}
+
+\unexpanded\def\module_spreadsheet_reset[#1]%
+ {\ctxlua{moduledata.spreadsheets.reset("#1")}}
+
+\unexpanded\def\startspreadsheet
+ {\dosingleempty\module_spreadsheet_start}
+
+\unexpanded\def\module_spreadsheet_start[#1]%
+ {\pushmacro\currentspreadsheet
+ \edef\currentspreadsheet{#1}%
+ \checkspreadsheetparent
+ \edef\m_spreadsheet_period{\spreadsheetparameter\c!period}%
+ \edef\m_spreadsheet_comma {\spreadsheetparameter\c!comma}%
+ \ctxlua{moduledata.spreadsheets.start("#1", {
+ period = \!!bs\detokenize\expandafter{\m_spreadsheet_period}\!!es,
+ comma = \!!bs\detokenize\expandafter{\m_spreadsheet_comma}\!!es,
+ split = \!!bs\spreadsheetparameter\c!split\!!es,
+ })}}
+
+\unexpanded\def\stopspreadsheet
+ {\ctxlua{moduledata.spreadsheets.stop()}%
+ \popmacro\currentspreadsheet}
+
+\unexpanded\def\showspreadsheet
+ {\dosingleempty\module_spreadsheet_show}
+
+\unexpanded\def\module_spreadsheet_show[#1]%
+ {\ctxlua{moduledata.spreadsheets.tocontext("#1")}}
+
+\unexpanded\def\inspectspreadsheet
+ {\dosingleempty\module_spreadsheet_inspect}
+
+\unexpanded\def\module_spreadsheet_inspect[#1]%
+ {\ctxlua{moduledata.spreadsheets.inspect("#1")}}
+
+\unexpanded\def\setspreadsheet
+ {\dosingleempty\module_spreadsheet_set}
+
+\unexpanded\def\module_spreadsheet_set[#1]#2#3#4%
+ {\ctxlua{moduledata.spreadsheets.set("#1",\number#2,\number#3,"#4")}}
+
+\unexpanded\def\getspreadsheet
+ {\dosingleempty\module_spreadsheet_get}
+
+\unexpanded\def\module_spreadsheet_get[#1]#2#3#4%
+ {\ctxlua{moduledata.spreadsheets.get("#1",\number#2,\number#3,"#4")}}
+
+\unexpanded\def\doifelsespreadsheetcell
+ {\dosingleempty\module_spreadsheet_doifelse_cell}
+
+\let\doifspreadsheetcellelse\doifelsespreadsheetcell
+
+\unexpanded\def\module_spreadsheet_doifelse_cell[#1]#2#3%
+ {\ctxlua{moduledata.spreadsheets.doifelsecell("#1",\number#2,\number#3)}}
+
+\ifdefined\tblrow
+
+ \def\TABLEsetspreadsheet#1{\ctxlua{moduledata.spreadsheets.set("",\number\tblrow+1,\number\tblcol,\!!bs#1\!!es)}}
+ \def\TABLEgetspreadsheet#1{\ctxlua{moduledata.spreadsheets.get("",\number\tblrow+1,\number\tblcol,\!!bs#1\!!es)}}
+
+\else
+
+ \def\TABLEsetspreadsheet#1{\ctxlua{moduledata.spreadsheets.set("",\number\c_tabl_ntb_row+1,\number\c_tabl_ntb_col,\!!bs#1\!!es)}}
+ \def\TABLEgetspreadsheet#1{\ctxlua{moduledata.spreadsheets.get("",\number\c_tabl_ntb_row+1,\number\c_tabl_ntb_col,\!!bs#1\!!es)}}
+
+\fi
+
+\appendtoks
+ \module_spreadsheet_reset[\currentspreadsheet]%
+ \let\setspr\TABLEsetspreadsheet
+ \let\getspr\TABLEgetspreadsheet
+\to \everyTABLEpass
+
+\unexpanded\def\startspreadsheettable % quick and dirty
+ {\dodoubleempty\module_spreadsheet_start_table}
+
+\unexpanded\def\module_spreadsheet_start_table[#1][#2]%
+ {\bgroup
+ \let\startrow \module_spreadsheet_row_start
+ \let\stoprow \module_spreadsheet_row_stop
+ \let\startcell\module_spreadsheet_cell_start
+ \let\stopcell \module_spreadsheet_cell_stop
+ \doifelseassignment{#1}
+ {\module_spreadsheet_start
+ \directsetup{spreadsheet:before:\currentspreadsheet}%
+ \bTABLE[\c!align=\v!flushright,#1]}
+ {\module_spreadsheet_start[#1]%
+ \directsetup{spreadsheet:before:\currentspreadsheet}%
+ \bTABLE[\c!align=\v!flushright,#2]}}
+
+\unexpanded\def\stopspreadsheettable
+ {\eTABLE
+ \directsetup{spreadsheet:after:\currentspreadsheet}%
+ \stopspreadsheet
+ \egroup}
+
+\unexpanded\def\module_spreadsheet_row_start{\bTR}
+\unexpanded\def\module_spreadsheet_row_stop {\eTR}
+
+\unexpanded\def\module_spreadsheet_cell_start
+ {\doifelsenextoptional\module_spreadsheet_cell_start_yes\module_spreadsheet_cell_start_nop}
+
+\unexpanded\def\module_spreadsheet_cell_start_yes[#1]#2\stopcell
+ {\bTD[#1]\getspr{#2}\eTD}
+
+\unexpanded\def\module_spreadsheet_cell_start_nop#1\stopcell
+ {\bTD\getspr{#1}\eTD}
+
+\let\module_spreadsheet_cell_stop\relax
+
+\protect
+
+\continueifinputfile{m-spreadsheet.mkiv}
+
+\starttext
+
+\bTABLE[align=middle]
+ \bTR
+ \bTD \getspr{100} \eTD \bTD test \setspr{30} \eTD
+ \eTR
+ \bTR
+ \bTD \getspr{20} \eTD \bTD \getspr{4+3} \eTD
+ \eTR
+ \bTR
+ \bTD \getspr{A[1] + A[2]} \eTD
+ \bTD \getspr{B1 + B2} \eTD
+ \eTR
+ \bTR
+ \bTD[nx=2] \bf \getspr{(A[3] + B[3]) /100} \eTD
+ \eTR
+ \bTR
+ \bTD[nx=2] \bf \getspr{string.format("\letterpercent0.3f",(A[3] + B[3]) /100)} \eTD
+ \eTR
+ \bTR
+ \bTD[nx=2] \bf \getspr{fmt("@0.3f",(sum(A,1,2)) / 10)} \eTD
+ \eTR
+\eTABLE
+
+\setupspreadsheet[mysheet]
+
+\startspreadsheet[mysheet]
+
+\bTABLE[align=middle]
+ \bTR
+ \bTD \getspr{100} \eTD \bTD test \setspr{30} \eTD
+ \eTR
+ \bTR
+ \bTD \getspr{20} \eTD \bTD \getspr{4+3.5} \eTD
+ \eTR
+ \bTR
+ \bTD \getspr{A[1] + A[2]} \eTD
+ \bTD \getspr{B[1] + B[2]} \eTD
+ \eTR
+ \bTR
+ \bTD[nx=2] \bf \getspr{A[3] + B[3]} \eTD
+ \eTR
+\eTABLE
+
+\stopspreadsheet
+
+\blank
+
+\setupspreadsheet[test][period={{\bf\middlered .}},comma={{\bf\middlegreen ,}},split=yes]
+
+\startspreadsheettable[test]
+ \startrow
+ \startcell 123456.78 \stopcell
+ \startcell 1234567.89 \stopcell
+ \startcell A[1] + B[1] \stopcell
+ \stoprow
+\stopspreadsheettable
+
+\blank
+
+% \showspreadsheet
+% \showspreadsheet[mysheet]
+
+\doifelsespreadsheetcell[mysheet]{1}{2}{YES}{NOP}
+\doifelsespreadsheetcell[myshoot]{1}{2}{YES}{NOP}
+
+\stoptext
diff --git a/Master/texmf-dist/tex/context/modules/mkiv/m-sql.mkiv b/Master/texmf-dist/tex/context/modules/mkiv/m-sql.mkiv
new file mode 100644
index 00000000000..f1df2833a00
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkiv/m-sql.mkiv
@@ -0,0 +1,29 @@
+%D \module
+%D [ file=m-sql,
+%D version=2012.07.12,
+%D title=\CONTEXT\ Extra Modules,
+%D subtitle=SQL,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\startmodule[sql]
+
+\registerctxluafile{util-tpl}{}
+\registerctxluafile{util-sql}{}
+
+\setupmodule
+
+\doifsomething {\currentmoduleparameter{method}}{
+ \ctxlua{utilities.sql.setmethod("\currentmoduleparameter{method}")}
+}
+
+\doifsomething {\currentmoduleparameter{server}} {
+ \ctxlua{utilities.sql.setserver("\currentmoduleparameter{server}")}
+}
+
+\stopmodule
diff --git a/Master/texmf-dist/tex/context/modules/mkiv/m-steps.lua b/Master/texmf-dist/tex/context/modules/mkiv/m-steps.lua
new file mode 100644
index 00000000000..8eb4815506e
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkiv/m-steps.lua
@@ -0,0 +1,226 @@
+if not modules then modules = { } end modules ['x-flow'] = {
+ version = 1.001,
+ comment = "companion to m-flow.mkvi",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+-- when we can resolve mpcolor at the lua end we will use metapost.graphic(....) directly
+
+moduledata.steps = moduledata.steps or { }
+
+local variables = interfaces.variables
+
+local trace_charts = false
+
+local defaults = {
+ chart = {
+ dx = 10*65436,
+ dy = 10*65436,
+ },
+ cell = {
+ alternative = 1,
+ offset = 2*65436,
+ rulethickness = 65436,
+ framecolor = "blue",
+ backgroundcolor = "gray",
+ },
+ text = {
+ alternative = 1,
+ offset = 2*65436,
+ distance = 4*65436,
+ rulethickness = 65436,
+ framecolor = "red",
+ backgroundcolor = "gray",
+ },
+ line = {
+ alternative = 1,
+ rulethickness = 65436,
+ height = 30*65436,
+ distance = 10*65436,
+ offset = 5*65436,
+ color = "green",
+ },
+}
+
+-- todo : name (no name then direct)
+-- maybe: includes
+-- maybe: flush ranges
+
+local charts = { }
+local steps = { }
+
+function commands.step_start_chart(name)
+ name = name or ""
+ steps = { }
+ charts[name] = {
+ steps = steps,
+ }
+end
+
+function commands.step_stop_chart()
+end
+
+function commands.step_make_chart(settings)
+ local chartsettings = settings.chart
+ if not chartsettings then
+ print("no chart")
+ return
+ end
+ local chartname = chartsettings.name
+ if not chartname then
+ print("no name given")
+ return
+ end
+ local chart = charts[chartname]
+ if not chart then
+ print("no such chart",chartname)
+ return
+ end
+ local steps = chart.steps or { }
+ --
+ table.setmetatableindex(settings,defaults)
+ --
+ if trace_charts then
+ inspect(steps)
+ end
+ --
+ local textsettings = settings.text
+ local cellsettings = settings.cell
+ local linesettings = settings.line
+ --
+ context.startMPcode()
+ context("if unknown context_cell : input mp-step.mpiv ; fi ;")
+ context("step_begin_chart ;")
+ --
+ if chartsettings.alternative == variables.vertical then
+ context("chart_vertical := true ;")
+ end
+ --
+ context("text_line_color := \\MPcolor{%s} ;", textsettings.framecolor)
+ context("text_line_width := %p ;", textsettings.rulethickness)
+ context("text_fill_color := \\MPcolor{%s} ;", textsettings.backgroundcolor)
+ context("text_offset := %p ;", textsettings.offset)
+ context("text_distance_set := %p ;", textsettings.distance)
+ --
+ context("cell_line_color := \\MPcolor{%s} ;", cellsettings.framecolor)
+ context("cell_line_width := %p ;", cellsettings.rulethickness)
+ context("cell_fill_color := \\MPcolor{%s} ;", cellsettings.backgroundcolor)
+ context("cell_offset := %p ;", cellsettings.offset)
+ context("cell_distance_x := %p ;", cellsettings.dx)
+ context("cell_distance_y := %p ;", cellsettings.dy)
+ --
+ context("line_line_color := \\MPcolor{%s} ;", linesettings.color)
+ context("line_line_width := %p ;", linesettings.rulethickness)
+ context("line_distance := %p ;", linesettings.distance)
+ context("line_offset := %p ;", linesettings.offset)
+ --
+ for i=1,#steps do
+ local step = steps[i]
+ context("step_begin_cell ;")
+ if step.cell_top ~= "" then
+ context('step_cell_top("%s") ;',string.strip(step.cell_top))
+ end
+ if step.cell_bot ~= "" then
+ context('step_cell_bot("%s") ;',string.strip(step.cell_bot))
+ end
+ if step.text_top ~= "" then
+ context('step_text_top("%s") ;',string.strip(step.text_top))
+ end
+ if step.text_mid ~= "" then
+ context('step_text_mid("%s") ;',string.strip(step.text_mid))
+ end
+ if step.text_bot ~= "" then
+ context('step_text_bot("%s") ;',string.strip(step.text_bot))
+ end
+ context("step_end_cell ;")
+ end
+ --
+ context("step_end_chart ;")
+ context.stopMPcode()
+end
+
+function commands.step_cells(top,bot)
+ steps[#steps+1] = {
+ cell_top = top or "",
+ cell_bot = bot or "",
+ text_top = "",
+ text_mid = "",
+ text_bot = "",
+ }
+end
+
+function commands.step_texts(top,bot)
+ if #steps > 0 then
+ steps[#steps].text_top = top or ""
+ steps[#steps].text_bot = bot or ""
+ end
+end
+
+function commands.step_cell(top)
+ steps[#steps+1] = {
+ cell_top = top or "",
+ cell_bot = "",
+ text_top = "",
+ text_mid = "",
+ text_bot = "",
+ }
+end
+
+function commands.step_text(top)
+ if #steps > 0 then
+ steps[#steps].text_top = top or ""
+ end
+end
+
+function commands.step_textset(left,middle,right)
+ if #steps > 0 then
+ steps[#steps].text_top = left or ""
+ steps[#steps].text_mid = middle or ""
+ steps[#steps].text_bot = right or ""
+ end
+end
+
+function commands.step_start_cell()
+ steps[#steps+1] = {
+ cell_top = "",
+ cell_bot = "",
+ text_top = "",
+ text_mid = "",
+ text_bot = "",
+ }
+end
+
+function commands.step_stop_cell()
+end
+
+function commands.step_text_top(str)
+ if #steps > 0 then
+ steps[#steps].text_top = str or ""
+ end
+end
+
+function commands.step_text_mid(str)
+ if #steps > 0 then
+ steps[#steps].text_mid = str or ""
+ end
+end
+
+function commands.step_text_bot(str)
+ if #steps > 0 then
+ steps[#steps].text_bot = str or ""
+ end
+end
+
+function commands.step_cell_top(str)
+ if #steps > 0 then
+ steps[#steps].cell_top = str or ""
+ end
+end
+
+function commands.step_cell_bot(str)
+ if #steps > 0 then
+ steps[#steps].cell_bot = str or ""
+ end
+end
diff --git a/Master/texmf-dist/tex/context/modules/mkiv/m-steps.mkvi b/Master/texmf-dist/tex/context/modules/mkiv/m-steps.mkvi
new file mode 100644
index 00000000000..c9c5a063620
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkiv/m-steps.mkvi
@@ -0,0 +1,382 @@
+%D \module
+%D [ file=m-steps,
+%D version=2011.10.07, % 2001.05.28,
+%D title=\CONTEXT\ Modules,
+%D subtitle=Step Charts \& Tables,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+% multiple texts?
+
+\registerctxluafile{m-steps}{}
+
+\unprotect
+
+\installcorenamespace {stepcharts}
+\installcorenamespace {steptables}
+\installcorenamespace {stepcells}
+\installcorenamespace {steptexts}
+\installcorenamespace {steplines}
+
+\installsimplecommandhandler \??stepcharts {STEPchart} \??stepcharts
+\installsimplecommandhandler \??steptables {STEPtable} \??steptables
+\installsimplecommandhandler \??stepcells {STEPcell} \??stepcells
+\installsimplecommandhandler \??steptexts {STEPtext} \??steptexts
+\installsimplecommandhandler \??steplines {STEPline} \??steplines
+
+\let\setupSTEPcharts\setupSTEPchart
+\let\setupSTEPtables\setupSTEPtable
+\let\setupSTEPcells \setupSTEPcell
+\let\setupSTEPtexts \setupSTEPtext
+\let\setupSTEPlines \setupSTEPline
+
+% numeric text_text_distance ; text_text_distance := 20pt ;
+% numeric step_distance ; step_distance := 20pt ;
+
+\setupSTEPcharts
+ [\c!alternative=\v!horizontal,
+ \c!before=\blank,
+ \c!after=\blank]
+% \c!offset=.15\bodyfontsize
+% \c!height=2ex
+
+% \setupSTEPtables
+% [\c!before=\blank,
+% \c!after=\blank,
+% \c!distance=.25em,
+% \c!voffset=1ex,
+% \c!method=1,
+% \c!width=4em,
+% \c!offset=.15\bodyfontsize]
+
+\setupSTEPcells
+ [\c!alternative=1, % TODO
+% \c!style=,
+% \c!color=,
+ \c!dx=\bodyfontsize,
+ \c!dy=\bodyfontsize,
+ \c!background=\v!color,
+ \c!backgroundcolor=STEPbackgroundcolor,
+ \c!rulethickness=.1\bodyfontsize,
+ \c!framecolor=STEPframecolor,
+ \c!offset=.25\bodyfontsize]
+
+\setupSTEPtexts
+ [\c!alternative=1, % TODO
+% \c!style=\v!smallbodyfont,
+% \c!color=,
+ \c!background=\v!color,
+ \c!backgroundcolor=STEPbackgroundcolor,
+ \c!rulethickness=.1\bodyfontsize,
+ \c!framecolor=STEPframecolor,
+ \c!distance=.5\bodyfontsize,
+ \c!offset=.25\bodyfontsize]
+
+\setupSTEPlines
+ [\c!alternative=1, % TODO
+ \c!rulethickness=.15\bodyfontsize,
+ \c!height=3\bodyfontsize,
+ \c!distance=.5\bodyfontsize,
+ \c!offset=.25\bodyfontsize,
+ \c!color=STEPlinecolor]
+
+\definecolor [STEPlinecolor] [s=.5]
+\definecolor [STEPframecolor] [s=.7]
+\definecolor [STEPbackgroundcolor] [s=.9]
+
+\newtoks\everySTEPchart
+
+\unexpanded\def\startSTEPchart
+ {\begingroup
+ \dodoubleempty\module_steps_start_chart}
+
+\def\module_steps_start_chart[#name][#settings]%
+ {\startnointerference
+ \iffirstargument
+ \doifelseassignment{#name}
+ {\let\currentSTEPchart\empty
+ \xdef\module_steps_flush_chart{\module_steps_chart[][#name]}}
+ {\edef\currentSTEPchart{#name}%
+ \glet\module_steps_flush_chart\relax}% settings are not stored
+ \else
+ \let\currentSTEPchart\empty
+ \gdef\module_steps_flush_chart{\module_steps_chart[][]}%
+ \fi
+ \the\everySTEPchart
+ \ctxcommand{step_start_chart("\currentSTEPchart")}}
+
+\unexpanded\def\stopSTEPchart
+ {\ctxcommand{step_stop_chart()}%
+ \stopnointerference
+ \module_steps_flush_chart
+ \endgroup}
+
+\unexpanded\def\startSTEPtable
+ {\begingroup
+ \setupSTEPchart[\c!alternative=\v!vertical]%
+ \dodoubleempty\module_steps_start_chart}
+
+\let\stopSTEPtable\stopSTEPchart
+
+\let\module_steps_flush_chart\relax
+
+\unexpanded\def\STEPchart
+ {\dodoubleempty\module_steps_chart}
+
+\unexpanded\def\module_steps_chart[#name][#settings]%
+ {\begingroup
+ \setupSTEPchart[#settings]%
+ \ifinsidefloat
+ \makeSTEPchart[#name]%
+ \else
+ \STEPchartparameter\c!before
+ \startbaselinecorrection
+ \setlocalhsize
+ \makeSTEPchart[#name]%
+ \stopbaselinecorrection
+ \STEPchartparameter\c!after
+ \fi
+ \endgroup}
+
+\unexpanded\def\makeSTEPchart[#name]%
+ {\ctxcommand{step_make_chart {
+ chart = {
+ name = "#name",
+ alternative = "\STEPchartparameter\c!alternative",
+ },
+ cell = {
+ alternative = "\STEPcellparameter\c!alternative", % TODO: shapes
+ offset = \number\dimexpr\STEPcellparameter\c!offset,
+ rulethickness = \number\dimexpr\STEPcellparameter\c!rulethickness,
+ framecolor = "\STEPcellparameter\c!framecolor",
+ backgroundcolor = "\STEPcellparameter\c!backgroundcolor",
+ dx = \number\dimexpr\STEPcellparameter\c!dx,
+ dy = \number\dimexpr\STEPcellparameter\c!dy,
+ },
+ text = {
+ alternative = "\STEPtextparameter\c!alternative", % TODO: shapes
+ offset = \number\dimexpr\STEPtextparameter\c!offset,
+ distance = \number\dimexpr\STEPtextparameter\c!distance,
+ rulethickness = \number\dimexpr\STEPtextparameter\c!rulethickness,
+ framecolor = "\STEPtextparameter\c!framecolor",
+ backgroundcolor = "\STEPtextparameter\c!backgroundcolor",
+ },
+ line = {
+ alternative = "\STEPlineparameter\c!alternative", % TODO: dash, arrow
+ rulethickness = \number\dimexpr\STEPlineparameter\c!rulethickness,
+ height = \number\dimexpr\STEPlineparameter\c!height,
+ distance = \number\dimexpr\STEPlineparameter\c!distance,
+ offset = \number\dimexpr\STEPlineparameter\c!offset,
+ color = "\STEPlineparameter\c!color",
+ },
+ }}}
+
+\unexpanded\def\startSTEPcell
+ {\ctxcommand{step_start_cell()}}
+
+\unexpanded\def\stopSTEPcell
+ {\ctxcommand{step_stop_cell()}}
+
+\unexpanded\def\module_steps_cells#top#bot%
+ {\ctxcommand{step_cells(\!!bs\detokenize{#top}\!!es,\!!bs\detokenize{#bot}\!!es)}}
+
+\unexpanded\def\module_steps_texts#top#bot%
+ {\ctxcommand{step_texts(\!!bs\detokenize{#top}\!!es,\!!bs\detokenize{#bot}\!!es)}}
+
+\unexpanded\def\module_steps_cell#str%
+ {\ctxcommand{step_cell(\!!bs\detokenize{#str}\!!es)}}
+
+\unexpanded\def\module_steps_text#str%
+ {\ctxcommand{step_text(\!!bs\detokenize{#str}\!!es)}}
+
+\unexpanded\def\module_steps_textset#left#middle#right%
+ {\ctxcommand{step_textset(\!!bs\detokenize{#left}\!!es,\!!bs\detokenize{#middle}\!!es,\!!bs\detokenize{#right}\!!es)}}
+
+\unexpanded\def\module_steps_toptext#top%
+ {\ctxcommand{step_text_top(\!!bs\detokenize{#top}\!!es)}}
+
+\unexpanded\def\module_steps_bottext#bot%
+ {\ctxcommand{step_text_bot(\!!bs\detokenize{#bot}\!!es)}}
+
+\unexpanded\def\module_steps_topcell#top%
+ {\ctxcommand{step_cell_top(\!!bs\detokenize{#top}\!!es)}}
+
+\unexpanded\def\module_steps_botcell#bot%
+ {\ctxcommand{step_cell_bot(\!!bs\detokenize{#bot}\!!es)}}
+
+\appendtoks
+ \let\cells \module_steps_cells
+ \let\texts \module_steps_texts
+ \let\cell \module_steps_cell
+ \let\text \module_steps_text
+ \let\textset\module_steps_textset
+ \let\toptext\module_steps_toptext
+ \let\bottext\module_steps_bottext
+ \let\topcell\module_steps_topcell
+ \let\botcell\module_steps_botcell
+\to \everySTEPchart
+
+% todo: mapping can be done in lua
+
+\startxmlsetups xml:step:define
+ \xmlsetsetup{#1} {stepchart|steptable} {xml:step:*}
+\stopxmlsetups
+
+\xmlregistersetup{xml:step:define}
+
+\startxmlsetups xml:step:stepchart
+ \startSTEPchart
+ \xmlfilter{#1}{/(cells|texts|stepcell|cell|text)/command(xml:step:*)}
+ \stopSTEPchart
+\stopxmlsetups
+
+\startxmlsetups xml:step:steptable
+ \startSTEPtable
+ \xmlfilter{#1}{/(cells|texts|stepcell|cell|text)/command(xml:step:*)}
+ \stopSTEPtable
+\stopxmlsetups
+
+\startxmlsetups xml:step:cells
+ \cells {\xmltext{#1}{/top}} {\xmltext{#1}{/bot}}
+\stopxmlsetups
+
+\startxmlsetups xml:step:texts
+ \texts {\xmltext{#1}{/top}} {\xmltext{#1}{/bot}}
+\stopxmlsetups
+
+\startxmlsetups xml:step:stepcell
+ \cells {\xmltext{#1}{/topcell}} {\xmltext{#1}{/botcell}}
+ \texts {\xmltext{#1}{/toptext}} {\xmltext{#1}{/bottext}}
+\stopxmlsetups
+
+\startxmlsetups xml:step:cell
+ \cell {\xmlflush{#1}}
+\stopxmlsetups
+
+\startxmlsetups xml:step:text
+ \text {\xmlflush{#1}}
+\stopxmlsetups
+
+\protect
+
+\continueifinputfile{m-steps.mkvi}
+
+\starttext
+
+\startbuffer
+
+ some cell
+ some text
+ some cell
+ some text
+ some cell
+
+\stopbuffer
+
+\typebuffer \processxmlbuffer
+
+
+\startbuffer
+
+ some cell
+ some text
+ some cell
+ some text
+ some cell
+
+\stopbuffer
+
+\typebuffer \processxmlbuffer
+
+\page
+
+\startSTEPchart
+ \cells {A} {B}
+ \cells {one} {five} \texts{$+2$}{$-2$}
+ \cells {two} {four} \texts{$+3$}{$-3$}
+ \cells {three} {three} \texts{$+4$}{$-4$}
+ \cells {four} {two} \texts{$+5$}{$-5$}
+ \cells {five} {one}
+\stopSTEPchart
+
+\startSTEPtable
+ \cell {one} \textset{$x$} {=}{$a+b+c$}
+ \cell {two} \textset{$c+d$}{=}{$y$}
+ \cell {three}
+\stopSTEPtable
+
+
+\page
+
+\startbuffer
+
+ some text some text
+ text text
+ some text some text
+
+\stopbuffer
+
+\processxmlbuffer
+
+\startbuffer
+
+ some text
+ text text
+ some text
+
+\stopbuffer
+
+\processxmlbuffer
+
+\page
+
+\startSTEPchart[second]
+ \startSTEPcell
+ \topcell {A}
+ \botcell {B}
+ \startSTEPcell
+ \topcell {one}
+ \botcell {five}
+ \toptext {$+2$}
+ \bottext {$-2$}
+ \stopSTEPcell
+ \startSTEPcell
+ \topcell {two}
+ \botcell {four}
+ \toptext {$+3$}
+ \bottext {$-3$}
+ \stopSTEPcell
+ \startSTEPcell
+ \topcell {three}
+ \botcell {three}
+ \toptext {$+4$}
+ \bottext {$-4$}
+ \stopSTEPcell
+ \startSTEPcell
+ \topcell {four}
+ \botcell {two}
+ \toptext {$+5$}
+ \bottext {$-5$}
+ \stopSTEPcell
+ \startSTEPcell
+ \topcell {five}
+ \botcell {one}
+ \stopSTEPcell
+\stopSTEPchart
+
+\STEPchart[first][alternative=horizontal]
+\STEPchart[first][alternative=vertical]
+
+\page
+
+\STEPchart[second][alternative=horizontal]
+\STEPchart[second][alternative=vertical]
+
+\page
+
+\stoptext
diff --git a/Master/texmf-dist/tex/context/modules/mkiv/m-subsub.mkiv b/Master/texmf-dist/tex/context/modules/mkiv/m-subsub.mkiv
new file mode 100644
index 00000000000..88be1168000
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkiv/m-subsub.mkiv
@@ -0,0 +1,76 @@
+%D \module
+%D [ file=m-subsub,
+%D version=2000.12.14,
+%D title=\CONTEXT\ Private Modules,
+%D subtitle=More Section Levels,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. This module is not public.
+
+\unprotect
+
+\definesection[\s!section-8]
+\definesection[\s!section-9]
+\definesection[\s!section-10]
+\definesection[\s!section-11]
+\definesection[\s!section-12]
+
+\definehead
+ [\v!subsubsubsubsubsection]
+ [\c!section=\s!section-8,
+ \c!default=\v!subsubsubsubsection]
+
+\definehead
+ [\v!subsubsubsubsubsubsection]
+ [\c!section=\s!section-9,
+ \c!default=\v!subsubsubsubsubsection]
+
+\definehead
+ [\v!subsubsubsubsubsubsubsection]
+ [\c!section=\s!section-10,
+ \c!default=\v!subsubsubsubsubsubsection]
+
+\definehead
+ [\v!subsubsubsubsubsubsubsubsection]
+ [\c!section=\s!section-11,
+ \c!default=\v!subsubsubsubsubsubsubsection]
+
+\definehead
+ [\v!subsubsubsubsubsubsubsubsubsection]
+ [\c!section=\s!section-12,
+ \c!default=\v!subsubsubsubsubsubsubsubsection]
+
+\definehead
+ [\v!subsubsubsubsubsubject]
+ [\c!coupling=\v!subsubsubsubsubsection,
+ \c!default=\v!subsubsubsubsubsection,
+ \c!incrementnumber=\v!no]
+
+\definehead
+ [\v!subsubsubsubsubsubsubject]
+ [\c!coupling=\v!subsubsubsubsubsubsection,
+ \c!default=\v!subsubsubsubsubsubsection,
+ \c!incrementnumber=\v!no]
+
+\definehead
+ [\v!subsubsubsubsubsubsubsubject]
+ [\c!coupling=\v!subsubsubsubsubsubsubsection,
+ \c!default=\v!subsubsubsubsubsubsubsection,
+ \c!incrementnumber=\v!no]
+
+\definehead
+ [\v!subsubsubsubsubsubsubsubsubject]
+ [\c!coupling=\v!subsubsubsubsubsubsubsubsection,
+ \c!default=\v!subsubsubsubsubsubsubsubsection,
+ \c!incrementnumber=\v!no]
+
+\definehead
+ [\v!subsubsubsubsubsubsubsubsubsubject]
+ [\c!coupling=\v!subsubsubsubsubsubsubsubsubsection,
+ \c!default=\v!subsubsubsubsubsubsubsubsubsection,
+ \c!incrementnumber=\v!no]
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/modules/mkiv/m-timing.mkiv b/Master/texmf-dist/tex/context/modules/mkiv/m-timing.mkiv
new file mode 100644
index 00000000000..5502768f697
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkiv/m-timing.mkiv
@@ -0,0 +1,102 @@
+%D \module
+%D [ file=m-timing,
+%D version=2007.12.23,
+%D title=\CONTEXT\ Modules,
+%D subtitle=Timing,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\ifdefined\ShowNamedUsage \endinput \fi
+
+%D Written at the end of 2007, this module is dedicated to Taco. Reaching this
+%D point in \LUATEX\ was a non trivial effort. By visualizing a bit what happens
+%D when pages come out of \LUATEX, you may get an idea what is involved. It took
+%D much time an dedication to reach this point in the development. Add to that
+%D those daily Skype intense discussion, testing and debugging moments. Time flies
+%D but progress is impressive. The motto of this module could be: what you see
+%D is what you get. An there is much more to come \unknown.
+
+% \usemodule[timing]
+% \setupcolors[state=start]
+% \starttext
+% \dorecurse{200}{\input tufte \par} \ShowUsage{}
+% \stoptext
+
+\definecolor[usage:line] [darkred]
+\definecolor[usage:time] [darkblue]
+\definecolor[usage:frame][darkgray]
+
+\ctxloadluafile{trac-tim}{}
+
+\startluacode
+local progress = moduledata.progress
+
+function progress.show(filename,parameters,nodes,other)
+ for n, name in pairs(parameters or progress.parameters()) do
+ context.ShowNamedUsage(filename or progress.defaultfilename,name,other or "")
+ end
+ for n, name in pairs(nodes or progress.nodes(filename)) do
+ context.ShowNamedUsage(filename or progress.defaultfilename,name,other or "")
+ end
+end
+\stopluacode
+
+% \everyfirstshipout
+
+\startnotmode[no-timing]
+ \appendtoks\ctxlua{moduledata.progress.store()}\to\everystarttext
+ \appendtoks\ctxlua{moduledata.progress.store()}\to\everyshipout
+ \ctxlua{luatex.registerstopactions(function() moduledata.progress.save() end)}
+\stopnotmode
+
+\unexpanded\def\ShowNamedUsage#1#2#3%
+ {\setbox\scratchbox\vbox\bgroup
+ \startMPcode
+ begingroup ; save p, q, b, h, w ;
+ path p, q, b ; numeric h, w ;
+ p := \cldcontext{moduledata.progress.path("#1","#2")} ;
+ % p := p shifted -llcorner p ;
+ if bbwidth(p) > 0 :
+ h := 100 ; w := 2 * h ;
+ w := \the\textwidth-3pt ; % correct for pen
+ p := p xstretched w ;
+ b := boundingbox (llcorner p -- llcorner p shifted (w,h)) ;
+ pickup pencircle scaled 3pt ; linecap := butt ;
+ draw b withcolor \MPcolor{usage:frame} ;
+ draw p withcolor \MPcolor{usage:line} ;
+ if ("#3" <> "") and ("#3" <> "#2") :
+ q := \cldcontext{moduledata.progress.path("#1","#3")} ;
+ % q := q shifted -llcorner q ;
+ if bbwidth(q) > 1 :
+ q := q xstretched w ;
+ pickup pencircle scaled 1.5pt ; linecap := butt ;
+ draw q withcolor \MPcolor{usage:time} ;
+ fi ;
+ fi ;
+ fi ;
+ endgroup ;
+ \stopMPcode
+ \egroup
+ \scratchdimen\wd\scratchbox
+ \ifdim\scratchdimen>\zeropoint
+ \startlinecorrection
+ \box\scratchbox \endgraf
+ \hbox to \scratchdimen{\tttf\strut\detokenize{#2}\hss
+ min:\cldcontext{moduledata.progress.bot("#1","\detokenize{#2}")}, %
+ max:\cldcontext{moduledata.progress.top("#1","\detokenize{#2}")}, %
+ pages:\cldcontext{moduledata.progress.pages("#1")}%
+ }%
+ \stoplinecorrection
+ \fi}
+
+\unexpanded\def\LoadUsage #1{\ctxlua{moduledata.progress.convert("#1")}}
+\unexpanded\def\ShowUsage #1{\ctxlua{moduledata.progress.show("#1",nil,nil,"elapsed_time")}}
+\unexpanded\def\ShowMemoryUsage#1{\ctxlua{moduledata.progress.show("#1",nil,{}, "elapsed_time")}}
+\unexpanded\def\ShowNodeUsage #1{\ctxlua{moduledata.progress.show("#1",{},nil, "elapsed_time")}}
+
+\endinput
diff --git a/Master/texmf-dist/tex/context/modules/mkiv/m-trackers.mkiv b/Master/texmf-dist/tex/context/modules/mkiv/m-trackers.mkiv
new file mode 100644
index 00000000000..95c34b16f65
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkiv/m-trackers.mkiv
@@ -0,0 +1,3 @@
+\starttext
+ \showtrackers
+\stoptext
diff --git a/Master/texmf-dist/tex/context/modules/mkiv/m-translate.mkiv b/Master/texmf-dist/tex/context/modules/mkiv/m-translate.mkiv
new file mode 100644
index 00000000000..2e6cbe95088
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkiv/m-translate.mkiv
@@ -0,0 +1,127 @@
+%D \module
+%D [ file=m-translate,
+%D version=2008.10.09,
+%D title=\CONTEXT\ Modules,
+%D subtitle=Translations,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+%D We can make this module more clever (wildcards and such) but since
+%D it's only a demo we stick to the simple case for now. After all, it's
+%D better to fix your source.
+
+\startluacode
+ local translators = { }
+
+ moduledata.translators = translators
+
+ local compiled, list = nil, nil
+
+ -- function translators.register(from,to)
+ -- local l = lpeg.P(from)/to
+ -- if not list then
+ -- list = l
+ -- else
+ -- list = list + l
+ -- end
+ -- compiled = nil
+ -- end
+ --
+ -- function translators.translate(s)
+ -- if list then
+ -- if not compiled then
+ -- compiled = lpeg.Cs((list + lpeg.P(1))^0)
+ -- end
+ -- return compiled:match(s)
+ -- else
+ -- return s
+ -- end
+ -- end
+
+ -- local function prepare()
+
+ function translators.register(from,to)
+ if not list then
+ list = { [from] = to }
+ else
+ list[from] = to
+ end
+ compiled = nil
+ end
+
+ function translators.translate(s)
+ if list then
+ if not compiled then
+ local tree = lpeg.utfchartabletopattern(list)
+ compiled = lpeg.Cs((tree/list + lpeg.patterns.utf8character)^0 * lpeg.P(-1)) -- the P(1) is needed in order to accept non utf
+ end
+ return compiled:match(s)
+ else
+ return s
+ end
+ end
+
+ local textlineactions = resolvers.openers.helpers.textlineactions
+
+ utilities.sequencers.appendaction(textlineactions,"after","moduledata.translators.translate")
+
+ function translators.enable()
+ utilities.sequencers.enableaction(textlineactions,"moduledata.translators.translate")
+ end
+
+ function translators.disable()
+ utilities.sequencers.disableaction(textlineactions,"moduledata.translators.translate")
+ end
+
+ function translators.reset(s)
+ translators.enable()
+ list, compiled = nil, nil
+ end
+
+ translators.disable()
+\stopluacode
+
+\unprotect
+
+\unexpanded\def\translateinput
+ {\dodoubleargument\module_translate_input}
+
+\def\module_translate_input[#1][#2]%
+ {\ctxlua{moduledata.translators.register(\!!bs#1\!!es,\!!bs#2\!!es)}}
+
+\unexpanded\def\resetinputtranslation
+ {\ctxlua{moduledata.translators.reset()}}
+
+\unexpanded\def\enableinputtranslation
+ {\ctxlua{moduledata.translators.enable()}}
+
+\unexpanded\def\disableinputtranslation
+ {\ctxlua{moduledata.translators.disable()}}
+
+\unexpanded\def\readtranslatedfile#1%
+ {\enableinputtranslation
+ \readfile{#1}\donothing\donothing
+ \disableinputtranslation}
+
+\protect
+
+\continueifinputfile{m-translate.mkiv}
+
+\starttext
+
+ \translateinput[Moica][Mojca]
+ % \translateinput[Idris][Idris (aka ادريس)]
+ \translateinput[Idris][Idris (aka )]
+
+ \enableinputtranslation
+
+ Well, it's not that hard to satisfy Idris' and Moicas \TEX\ needs.
+
+ \readtranslatedfile{tufte}
+
+\stoptext
diff --git a/Master/texmf-dist/tex/context/modules/mkiv/m-units.mkiv b/Master/texmf-dist/tex/context/modules/mkiv/m-units.mkiv
new file mode 100644
index 00000000000..f85a8ba8a5e
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkiv/m-units.mkiv
@@ -0,0 +1,914 @@
+%D \module
+%D [ file=m-units,
+%D version=1997.03.19,
+%D title=\CONTEXT\ Extra Modules,
+%D subtitle=Scientific Units,
+%D author={Hans Hagen \& Ton Otten},
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+%D Best use the built in unit handle!
+
+%D Scientific units can be typeset in math mode pretty well,
+%D but occasionally one has to take care of spacing.
+%D Furthermore, entering these units is not that natural as
+%D wanted. Therefore this module presents a more natural way of
+%D doing things, like:
+%D
+%D \starttyping
+%D 1.23 \Cubic \Meter \Per \Second
+%D \stoptyping
+%D
+%D This example shows that we use the order in which we say
+%D things, instead of typeset things. There is a separate
+%D manual for this module.
+
+%D Message number~1 deals with overruling the \type {\Degrees}
+%D macro defined in the core modules. Let's say that this is
+%D an upward compatibility issue.
+
+\startmessages dutch library: units
+ title: eenheden
+ 1: gebruik \string\Degrees\space\string\Celsius\space in plaats van \string\Celsius !
+\stopmessages
+
+\startmessages english library: units
+ title: units
+ 1: use \string\Degrees\space\string\Celsius\space instead of \string\Celsius !
+\stopmessages
+
+\startmessages german library: units
+ title: Einheiten
+ 1: Verwende \string\Degrees\space\string\Celsius\space statt \string\Celsius !
+\stopmessages
+
+\startmessages italian library: units
+ title: unita
+ 1: usare \string\Degrees\space\string\Celsius\space invece di \string\Celsius !
+\stopmessages
+
+\startmessages norwegian library: units
+ title: enheter
+ 1: bruk \string\Degrees\space\string\Celsius\space istedenfor \string\Celsius !
+\stopmessages
+
+\startmessages romanian library: units
+ title: unitati
+ 1: folositi \string\Degrees\space\string\Celsius\space in locul \string\Celsius !
+\stopmessages
+
+\startmessages french library: units
+ title: unitas
+ 1: utilisez \string\Degrees\space\string\Celsius\space A la place de \string\Celsius !
+\stopmessages
+
+\registerctxluafile{x-mathml}{}
+
+\unprotect
+
+\writestatus{\m!units}{The units module is obsolete because functionality is built into the core.}
+
+\let\unit\undefined
+
+\definesynonyms
+ [\v!unit]
+ [\v!units]
+ [\unitmeaning]
+
+\setupsynonyms
+ [\v!unit]
+ [\c!synonymcommand=\dimension]
+
+\startmodule[units]
+
+%D This runtime loadable module implements a way of defining
+%D units. The core macro is \type {\dimension}, a rather clever
+%D one that is able to cooperate with some other dimension
+%D related macros. As said, this module enables user to enter:
+%D
+%D \starttyping
+%D some 10 \Square \Meter \Per \Second or more
+%D \stoptyping
+%D
+%D The units itself are implemented as synonyms.
+%D
+%D \starttyping
+%D \definesynonyms [unit] [units] [\unitmeaning]
+%D \setupsynonyms [unit] [textstyle=\dimension]
+%D \stoptyping
+%D
+%D This definition means that we can ask for the meaning of a
+%D unit using \type {\unitmeaning} and get a list of used
+%D units by saying \type {\placelistofunits}
+%D
+%D We have to use the command \type {\unitmeaning} instead
+%D of \type {\meaning}, simply because the latter is a \TEX\
+%D primitive we don't want to loose. We use the label text
+%D mechanism for translations.
+
+%D \macros
+%D {dimension}
+%D
+%D The core of this module is the low level macro \type
+%D {\dimension}. Before presenting this macro, it's best to
+%D look at some applications, because it's supposed to show
+%D some intelligence that can beter be understood from the
+%D context.
+%D
+%D The next useless examples show some of the cases we want
+%D to handle in a proper way.
+%D
+%D \starttyping
+%D ... 10 \Square \Meter \Per \Volt \
+%D ... 10 \Square \Meter \Volt \
+%D ... 10 \Meter \Volt \
+%D ... 10 \Milli \Square \Meter \Per \Volt \
+%D ... 10 \Square \Milli \Meter \Per \Volt \
+%D ... 10 \Meter \Times \Meter \
+%D ... 10 \Square \Meter \Times \Meter \
+%D ... 10 \Square \Milli \Meter \Times \Meter \
+%D \stoptyping
+
+%D \macros
+%D {mathematicstypeface, dimensiontypeface,
+%D dimensionhalfspace, dimensionbackspace}
+%D
+%D There are some low level constants, that can be changed
+%D when needed. Some day I will write a decent setup command.
+
+\def\mathematicstypeface{\rm}
+\def\dimensiontypeface {\tf}
+
+\def\dimensionhalfspace {\ifmmode\,\else\hskip+.1em\relax\fi}
+\def\dimensionbackspace {\ifmmode\!\else\hskip-.1em\relax\fi}
+
+%D \macros
+%D {smashdimensionpower}
+%D
+%D Sometimes the baseline distance is not enough to provide
+%D for superscripts, so we smash their height by default.
+
+\newif\ifsmashdimensionpower \smashdimensionpowertrue
+
+%D The dimension mechanism uses a lot of signals to keep
+%D track if the current state.
+
+\newsignal\dimensionsignal
+\newsignal\dimensionpowersignal
+\newsignal\dimensionmidfixsignal
+\newsignal\dimensionaddfixsignal
+
+\let\thedimensionprefix = \empty
+\let\thedimensionpower = \empty
+
+%D \macros
+%D {spaceddimensions,textdimensions}
+%D
+%D The actual definition of \type {\dimension} overruled the
+%D one in the core modules. The boolean can be used to
+%D force spacing between units. The rather ugly test prevents
+%D problems with nested dimensions.
+
+\newif\ifspaceddimensions \spaceddimensionsfalse % user switch
+\newif\iftextdimensions \textdimensionsfalse % user switch
+
+%D You can see the consequence of forcing text dimensions
+%D when you compare the following code:
+%D
+%D \starttyping
+%D {\rm test \Square \Meter \Per \Second\ ziezo\Degrees} \par
+%D {\ss test \Square \Meter \Per \Second\ ziezo} \par
+%D {\tt test \Square \Meter \Per \Second\ ziezo}
+%D
+%D \textdimensionstrue
+%D
+%D {\rm test \Square \Meter \Per \Second\ ziezo} \par
+%D {\ss test \Square \Meter \Per \Second\ ziezo} \par
+%D {\tt test \Square \Meter \Per \Second\ ziezo}
+%D \stoptyping
+
+\newif\ifnesteddimension \nesteddimensionfalse % local switch
+
+\def\dodimensionpower#1%
+ {\iftextdimensions\expandafter\high\else\expandafter\normalsuperscript\fi{#1}}
+
+\def\ustartmathmode {\iftextdimensions\else\expandafter\startmathmode \fi}
+\def\ustopmathmode {\iftextdimensions\else\expandafter\stopmathmode \fi}
+\def\umathematicstypeface{\iftextdimensions\else\expandafter\mathematicstypeface\fi}
+
+%D In forced text mode, we ignore spacing in monospaced fonts.
+
+\def\udimensionhalfspace {\dodimensionspace\dimensionhalfspace}
+\def\udimensionbackspace {\dodimensionspace\dimensionbackspace}
+
+\def\dodimensionspace
+ {\iftextdimensions
+ \begingroup
+ \setbox0\hbox{i}%
+ \setbox2\hbox{m}%
+ \ifdim\wd0=\wd2
+ \endgroup
+ \@EAEAEA\gobbleoneargument
+ \else
+ \endgroup
+ \fi
+ \fi}
+
+\unexpanded\def\dimension#1%
+ {\begingroup
+ \global\let\savedthedimensionprefix\thedimensionprefix
+ \global\let\savedthedimensionpower\thedimensionpower
+ \unexpanded\def\dimension##1{\global\nesteddimensiontrue}%
+ \let\dimensionprefix\dimension
+ \let\dimensionmidfix\dimension
+ \let\dimensionsuffix\dimension
+ \let\dimensionpower \dimension
+ \global\nesteddimensionfalse
+ \setbox\scratchbox\hbox{\ustartmathmode#1\ustopmathmode}% pre-roll
+ \global\let\thedimensionprefix\savedthedimensionprefix
+ \global\let\thedimensionpower \savedthedimensionpower
+ \endgroup
+ \ifnesteddimension#1\else\dodimension{#1}\fi}
+
+\def\dodimension#1%
+ {\dontbreakdimension
+ \ifdim\scratchdimen=\zeropoint\relax
+ \ifmmode
+ \udimensionhalfspace
+ \udimensionhalfspace
+ \fi
+ \ustartmathmode\dimensiontypeface
+ \else
+ \ustartmathmode\dimensiontypeface
+ \ifspaceddimensions
+ \ifdim\scratchdimen=\dimensionsignal\relax
+ \udimensionhalfspace
+ \else\ifdim\scratchdimen=\dimensionpowersignal\relax
+ \udimensionhalfspace
+ \fi
+ \fi
+ \fi
+ \fi
+ \umathematicstypeface\thedimensionprefix#1%
+ \ifx\thedimensionpower\empty
+ \else\ifsmashdimensionpower
+ \setbox\scratchbox=\hbox
+ {\iftextdimensions
+ \tx\thedimensionpower
+ \else
+ \normalstartimath
+ \scriptstyle\thedimensionpower
+ \normalstopimath
+ \fi}%
+ \ht\scratchbox=\zeropoint
+ \dodimensionpower{\box\scratchbox}%
+ \else
+ \dodimensionpower{\thedimensionpower}%
+ \fi\fi
+ \ustopmathmode
+ % otherwise nobreak before space in 2 \Milli \Meter\ blabla
+ \doifnotmode{atpragma}{\nobreak}% this was always \nobreak
+ % only test this at pragma
+ \ifx\thedimensionpower\empty
+ \hskip\dimensionsignal
+ \else
+ \hskip\dimensionpowersignal
+ \fi
+ \global\let\thedimensionprefix\empty
+ \global\let\thedimensionpower\empty}
+
+%D \macros
+%D {dontbreakdimension,
+%D dimensionprefix, dimensionaddfix,
+%D dimensionnopfix, dimensionmidfix,
+%D dimensionpower}
+%D
+%D Here are some auxilliary macros.
+
+\def\dontbreakdimension
+ {\scratchdimen\lastskip
+ \unskip
+ \nobreak
+ \hskip\scratchdimen
+ \nobreak}
+
+\def\dimensionprefix#1%
+ {\gdef\thedimensionprefix{#1}}
+
+\def\dimensionaddfix#1%
+ {\unskip
+ %\mathematics{\umathematicstypeface#1}%
+ \ustartmathmode\umathematicstypeface#1\ustopmathmode
+ \nobreak
+ \hskip\dimensionaddfixsignal}
+
+\def\dimensionnopfix#1%
+ {\dontbreakdimension
+ \ifdim\scratchdimen=\dimensionpowersignal\relax
+ \ustartmathmode
+ \else
+ \ustartmathmode
+ \udimensionhalfspace
+ \nobreak
+ \fi
+ \umathematicstypeface#1%
+ \ustopmathmode
+ \nobreak
+ \hskip\dimensionsignal}
+
+\def\dimensionmidfix#1%
+ {\dontbreakdimension
+ \ifdim\scratchdimen=\dimensionpowersignal\relax
+ \ustartmathmode
+ \udimensionbackspace
+ \nobreak
+ \else
+ \ustartmathmode
+ \fi
+ \umathematicstypeface#1%
+ \ustopmathmode
+ \nobreak
+ \hskip\dimensionmidfixsignal}
+
+\def\dimensionpower#1%
+ {\gdef\thedimensionpower{#1}}
+
+%D \macros
+%D {SIunits, noSI, doSI}
+%D
+%D Some low level unit switching macros:
+
+\newif\ifSIunits \SIunitstrue
+
+\def\noSI#1{\begingroup\SIunitsfalse#1\endgroup}
+\def\doSI#1{\begingroup\SIunitstrue #1\endgroup}
+
+%D \macros
+%D {Degrees}
+%D
+%D We can fake the degrees symbol with:
+
+\def\Degrees{\dimensionaddfix{\mathematics{\normalsuperscript\circ}}}
+
+%D \macros
+%D {Unit, NoUnit}
+%D
+%D When a dimension has no leading number, we can use \type
+%D {\Unit}, and when no unit is appended, \type {\NoUnit} is
+%D to be used, just to prevent the prefix migrating to the
+%D next occasion.
+
+\def\Unit {\hskip\dimensionsignal}
+\def\NoUnit {\dimension{}}
+
+%D The mechanism described at the top of this module, depends
+%D on several dimensional components, like prefixes:
+
+\def\Atto {\dimensionprefix{a}}
+\def\Femto {\dimensionprefix{f}}
+\def\Pico {\dimensionprefix{p}}
+\def\Nano {\dimensionprefix{n}}
+\def\Micro {\dimensionprefix{\iftextdimensions u\else\mu\fi}}
+\def\Milli {\dimensionprefix{m}}
+\def\Centi {\dimensionprefix{c}}
+\def\Deci {\dimensionprefix{d}} % 10^{01}
+\def\Hecto {\dimensionprefix{h}} % 10^{02}
+\def\Kilo {\dimensionprefix{k}} % 10^{03}
+\def\Mega {\dimensionprefix{M}} % 10^{06}
+\def\Giga {\dimensionprefix{G}} % 10^{09}
+\def\Tera {\dimensionprefix{T}} % 10^{12}
+\def\Peta {\dimensionprefix{P}} % 10^{15}
+\def\Exa {\dimensionprefix{E}} % 10^{18}
+
+%def\Terra {\dimensionprefix{T}} % for old times sake
+
+\def\Kibi {\dimensionprefix{ki}} % 2^{10}
+\def\Mebi {\dimensionprefix{Mi}} % 2^{20}
+\def\Gibi {\dimensionprefix{Gi}} % 2^{30}
+\def\Tebi {\dimensionprefix{Ti}} % 2^{40}
+\def\Pebi {\dimensionprefix{Pi}} % 2^{50}
+
+%D and binary prefixes:
+
+\def\Kibi {\dimensionprefix{Ki}}
+\def\Mebi {\dimensionprefix{Mi}}
+\def\Gibi {\dimensionprefix{Gi}}
+\def\Tebi {\dimensionprefix{Ti}}
+\def\Pebi {\dimensionprefix{Pi}}
+\def\Exbi {\dimensionprefix{Ei}}
+\def\Zebi {\dimensionprefix{Zi}}
+\def\Yobi {\dimensionprefix{Yi}}
+
+%D and operators:
+
+\def\Times {\dimensionnopfix{\iftextdimensions.\else\cdot\fi}}
+\def\Solidus {\dimensionmidfix{/}}
+\def\Per {\dimensionmidfix{/}}
+\def\OutOf {\dimensionnopfix{:}}
+
+%D and suffixes:
+
+\def\Linear {\dimensionpower{1}}
+\def\Square {\dimensionpower{2}}
+\def\Cubic {\dimensionpower{3}}
+
+\def\Inverse {\dimensionpower{-1}}
+\def\ILinear {\dimensionpower{-1}}
+\def\ISquare {\dimensionpower{-2}}
+\def\ICubic {\dimensionpower{-3}}
+
+%D Apart from these components, the units themselves are
+%D defined using the synonym mechanism. First we define some
+%D length and volume related units.
+
+\getvalue{\v!unit} [Meter] {m} {meter}
+\getvalue{\v!unit} [pMeter] {\Pico \Meter} {picometer}
+\getvalue{\v!unit} [nMeter] {\Nano \Meter} {nanometer}
+\getvalue{\v!unit} [uMeter] {\Micro \Meter} {micrometer}
+\getvalue{\v!unit} [mMeter] {\Milli \Meter} {millimeter}
+\getvalue{\v!unit} [cMeter] {\Centi \Meter} {centimeter}
+\getvalue{\v!unit} [dMeter] {\Deci \Meter} {decimeter}
+\getvalue{\v!unit} [hMeter] {\Hecto \Meter} {hectometer}
+\getvalue{\v!unit} [kMeter] {\Kilo \Meter} {kilometer}
+
+%D After some discussion on the \CONTEXT\ mailing list in
+%D february 2002 it was decided to go from L to l for liters
+%D (Karel Wesselings alternative: \mathematics{\ell}).
+
+\getvalue{\v!unit} [Liter] {l} {liter}
+\getvalue{\v!unit} [mLiter] {\Milli \Liter} {milliliter}
+\getvalue{\v!unit} [cLiter] {\Centi \Liter} {centiliter}
+\getvalue{\v!unit} [dLiter] {\Deci \Liter} {deciliter}
+
+%D Next we define time related units (\type {\ifSI} still dutch only).
+
+\getvalue{\v!unit} [Sec] {s} {\labeltext{u:sec}}
+\getvalue{\v!unit} [fSec] {\Femto \Sec} {\labeltext{u:fsec}}
+\getvalue{\v!unit} [pSec] {\Pico \Sec} {\labeltext{u:psec}}
+\getvalue{\v!unit} [nSec] {\Nano \Sec} {\labeltext{u:nsec}}
+\getvalue{\v!unit} [uSec] {\Micro \Sec} {\labeltext{u:usec}}
+\getvalue{\v!unit} [mSec] {\Milli \Sec} {\labeltext{u:msec}}
+\getvalue{\v!unit} [Year] {\ifSIunits a \else j\fi} {\labeltext{u:year}}
+\getvalue{\v!unit} [Month] {m} {\labeltext{u:month}}
+\getvalue{\v!unit} [Week] {w} {\labeltext{u:week}}
+\getvalue{\v!unit} [Day] {d} {\labeltext{u:day}}
+\getvalue{\v!unit} [Hour] {\ifSIunits h \else u\fi} {\labeltext{u:hour}}
+\getvalue{\v!unit} [Min] {min} {\labeltext{u:min}}
+
+\setuplabeltext
+ [\s!nl]
+ [u:sec=seconde,
+ u:psec=picoseconde,
+ u:fsec=femtoseconde,
+ u:nsec=nanoseconde,
+ u:usec=microseconde,
+ u:msec=milliseconde,
+ u:year=jaar,
+ u:month=maand,
+ u:week=week,
+ u:day=dag,
+ u:hour=uur,
+ u:min=minuten]
+
+\setuplabeltext
+ [\s!en]
+ [u:sec=second,
+ u:fsec=femtosecond,
+ u:psec=picosecond,
+ u:nsec=nanosecond,
+ u:usec=microsecond,
+ u:msec=millisecond,
+ u:year=year,
+ u:month=month,
+ u:week=week,
+ u:day=day,
+ u:hour=hour,
+ u:min=minutes]
+
+\setuplabeltext
+ [\s!de]
+ [u:sec=Sekunde,
+ u:fsec=Femtosekunde,
+ u:psec=Picosekunde,
+ u:nsec=Nanosekunde,
+ u:usec=Microsekunde,
+ u:msec=Millisekunde,
+ u:year=Jahr,
+ u:month=Monat,
+ u:week=Woche,
+ u:day=Tag,
+ u:hour=Stunde,
+ u:min=Minuten]
+
+\setuplabeltext
+ [\s!hr]
+ [u:sec=sekunda,
+ u:fsec=femtosekunda,
+ u:psec=pikosekunda,
+ u:nsec=nanosekunda,
+ u:usec=mikrosekunda,
+ u:msec=milisekunda,
+ u:year=godina,
+ u:month=mjesec,
+ u:week=tjedan,
+ u:day=dan,
+ u:hour=sat,
+ u:min=minuta]
+
+\setuplabeltext
+ [\s!it]
+ [u:sec=secondo,
+ u:fsec=femtosecondo,
+ u:psec=picosecondo,
+ u:nsec=nanosecondo,
+ u:usec=microsecondo,
+ u:msec=millisecondo,
+ u:year=anno,
+ u:month=mese,
+ u:week=settimana,
+ u:day=giorno,
+ u:hour=ora,
+ u:min=minuti]
+
+%D Then we define some angles.
+
+\getvalue{\v!unit} [Rad] {rad} {\labeltext{u:rad}}
+\getvalue{\v!unit} [Deg] {{\mathematics{\normalsuperscript\circ}}} {\labeltext{u:deg}}
+
+\setuplabeltext
+ [\s!nl]
+ [u:rad=hoek radialen,
+ u:deg=hoek graden]
+
+\setuplabeltext
+ [\s!en]
+ [u:rad=angle radians,
+ u:deg=angle degrees]
+
+\setuplabeltext
+ [\s!de]
+ [u:rad=Bogenma\SS,
+ u:deg=Gradma\SS]
+
+\setuplabeltext
+ [\s!hr]
+ [u:rad=radijani,
+ u:deg=kutni stupnjevi]
+
+\setuplabeltext
+ [\s!it]
+ [u:rad=radianti,
+ u:deg=angoli sessagesimali]
+
+%D Rotation and frequency related units are defined by:
+
+\getvalue{\v!unit} [Hertz] {Hz} {Hertz}
+\getvalue{\v!unit} [kHertz] {\Kilo \Hertz} {kilo Hertz}
+\getvalue{\v!unit} [MHertz] {\Mega \Hertz} {mega Hertz}
+\getvalue{\v!unit} [GHertz] {\Giga \Hertz} {giga Hertz}
+\getvalue{\v!unit} [THertz] {\Tera \Hertz} {tera Hertz}
+\getvalue{\v!unit} [mHertz] {\Milli \Hertz} {milli Hertz}
+
+\getvalue{\v!unit} [RevPerSec] {RPS} {\labeltext{u:rps}}
+\getvalue{\v!unit} [RevPerMin] {RPM} {\labeltext{u:rpm}}
+
+\setuplabeltext
+ [\s!nl]
+ [u:rps=omwentelingen per seconde,
+ u:rpm=omwentelingen per minuut]
+
+\setuplabeltext
+ [\s!en]
+ [u:rps=revolutions per second,
+ u:rpm=revolutions per minute]
+
+\setuplabeltext
+ [\s!de]
+ [u:rps=Umdrehungen pro Sekunde,
+ u:rpm=Umdrehungen pro Minute]
+
+\setuplabeltext
+ [\s!hr]
+ [u:rps=okretaji po sekundi,
+ u:rpm=okretaji po minuti]
+
+\setuplabeltext
+ [\s!it]
+ [u:rps=giri al secondo,
+ u:rpm=giri al minuto]
+
+%D Mass and force:
+
+\getvalue{\v!unit} [Gram] {g} {gram}
+\getvalue{\v!unit} [uGram] {\Micro \Gram} {microgram}
+\getvalue{\v!unit} [mGram] {\Milli \Gram} {milligram}
+\getvalue{\v!unit} [kGram] {\Kilo \Gram} {kilogram}
+\getvalue{\v!unit} [Atom] {u} {\labeltext{u:u}}
+
+\getvalue{\v!unit} [Newton] {N} {Newton}
+\getvalue{\v!unit} [kNewton] {\Kilo \Newton} {kilo Newton}
+
+\getvalue{\v!unit} [Pascal] {Pa} {Pascal}
+\getvalue{\v!unit} [mPascal] {\Milli \Pascal} {milli Pascal}
+\getvalue{\v!unit} [kPascal] {\Kilo \Pascal} {kilo Pascal}
+
+\setuplabeltext
+ [\s!nl]
+ [u:u=atomaire massa eenheid]
+
+\setuplabeltext
+ [\s!en]
+ [u:u=atom mass unit]
+
+\setuplabeltext
+ [\s!de]
+ [u:u=Atomare Masseneinheit]
+
+\setuplabeltext
+ [\s!hr]
+ [u:u=unificirana atomska jedinica mase]
+
+\setuplabeltext
+ [\s!it]
+ [u:u=unit\`a di massa atomica]
+
+%D Energy units comes in two alternatives:
+
+\getvalue{\v!unit} [Joule] {J} {Joule}
+\getvalue{\v!unit} [mJoule] {\Milli \Joule} {milli Joule}
+\getvalue{\v!unit} [kJoule] {\Kilo \Joule} {kilo Joule}
+\getvalue{\v!unit} [MJoule] {\Mega \Joule} {mega Joule}
+\getvalue{\v!unit} [GJoule] {\Giga \Joule} {giga Joule}
+
+\getvalue{\v!unit} [Watt] {W} {Watt}
+\getvalue{\v!unit} [mWatt] {\Milli \Watt} {milli Watt}
+\getvalue{\v!unit} [kWatt] {\Kilo \Watt} {kilo Watt}
+\getvalue{\v!unit} [MWatt] {\Mega \Watt} {mega Watt}
+\getvalue{\v!unit} [GWatt] {\Giga \Watt} {giga Watt}
+\getvalue{\v!unit} [TWatt] {\Tera \Watt} {tera Watt}
+
+%D Although Celsius is no longer permitted, we define it by
+%D saying:
+
+\getvalue{\v!unit} [Celsius] {C} {Celsius}
+\getvalue{\v!unit} [Kelvin] {K} {Kelvin}
+\getvalue{\v!unit} [Fahrenheit] {F} {Fahrenheit}
+
+%D Some chemic related units are:
+
+\getvalue{\v!unit} [Mol] {mol} {mol}
+\getvalue{\v!unit} [mMol] {\Milli \Mol} {millimol}
+\getvalue{\v!unit} [kMol] {\Kilo \Mol} {kilomol}
+\getvalue{\v!unit} [Molair] {M} {molair (\Mol \Per \Liter)}
+\getvalue{\v!unit} [Equivalent] {eq} {equivalent}
+\getvalue{\v!unit} [mEquivalent] {\Milli \Equivalent} {milli equivalent}
+
+%D There are quite a lot units related to electricity and
+%D magnetism:
+
+\getvalue{\v!unit} [Farad] {F} {Farad}
+\getvalue{\v!unit} [pFarad] {\Pico \Farad} {pico Farad}
+\getvalue{\v!unit} [nFarad] {\Nano \Farad} {nano Farad}
+\getvalue{\v!unit} [uFarad] {\Micro \Farad} {micro Farad}
+\getvalue{\v!unit} [mFarad] {\Milli \Farad} {milli Farad}
+
+\getvalue{\v!unit} [Ohm] {\Omega} {Ohm}
+\getvalue{\v!unit} [kOhm] {\Kilo \Ohm} {kilo Ohm}
+
+\getvalue{\v!unit} [Siemens] {S} {Siemens}
+
+\getvalue{\v!unit} [Ampere] {A} {Amp\`ere}
+\getvalue{\v!unit} [mAmpere] {\Milli \Ampere} {milli Amp\`ere}
+
+\getvalue{\v!unit} [Coulomb] {C} {Coulomb}
+
+\getvalue{\v!unit} [Volt] {V} {Volt}
+\getvalue{\v!unit} [mVolt] {\Milli \Volt} {milli Volt}
+\getvalue{\v!unit} [kVolt] {\Kilo \Volt} {kilo Volt}
+\getvalue{\v!unit} [eVolt] {eV} {electronvolt}
+\getvalue{\v!unit} [keVolt] {\Kilo \eVolt} {kilo electronvolt}
+\getvalue{\v!unit} [MeVolt] {\Mega \eVolt} {mega electronvolt}
+
+\getvalue{\v!unit} [Tesla] {T} {Tesla}
+
+\getvalue{\v!unit} [VoltAC] {V\normalsubscript{\xbox{ac}}} {\labeltext{u:vac}}
+\getvalue{\v!unit} [VoltDC] {V\normalsubscript{\xbox{dc}}} {\labeltext{u:vdc}}
+
+\setuplabeltext
+ [\s!nl]
+ [u:vac=wisselspanning,
+ u:vdc=gelijkspanning]
+
+\setuplabeltext
+ [\s!en]
+ [u:vac=alternating current,
+ u:vdc=direct current]
+
+\setuplabeltext
+ [\s!de]
+ [u:vac=Wechselspannung,
+ u:vdc=Gleichspannung]
+
+\setuplabeltext
+ [\s!hr]
+ [u:vac=izmjeni\ccaron ni napon,
+ u:vdc=istosmjerni napon]
+
+\setuplabeltext
+ [\s!it]
+ [u:vac=corrente alternata,
+ u:vdc=corrente continua]
+
+%D Network bandwidth is specified in Bits:
+
+\getvalue{\v!unit} [Bit] {bit} {\labeltext{u:bit}}
+\getvalue{\v!unit} [Baud] {Bd} {Baud (Bit/s)}
+
+%D Computer memory size is specified in Bytes:
+
+\getvalue{\v!unit} [Byte] {B} {\labeltext{u:byte}}
+\getvalue{\v!unit} [kByte] {\Kilo \Byte} {kilo Byte}
+\getvalue{\v!unit} [MByte] {\Mega \Byte} {mega Byte}
+\getvalue{\v!unit} [GByte] {\Giga \Byte} {giga Byte}
+\getvalue{\v!unit} [TByte] {\Tera \Byte} {tera Byte}
+
+\setuplabeltext
+ [\s!en]
+ [u:bit=Bit,
+ u:byte=Byte]
+
+\setuplabeltext
+ [\s!hr]
+ [u:bit=bit,
+ u:byte=bajt]
+
+%D Telecommunication call density is specified in Erlangs:
+
+\getvalue{\v!unit} [Erlang] {E} {Erlang}
+
+%D Some radiation related units:
+
+\getvalue{\v!unit} [Bequerel] {Bq} {Bequerel}
+\getvalue{\v!unit} [MBequerel] {\Mega \Bequerel} {Bequerel}
+\getvalue{\v!unit} [Sievert] {Sv} {Sievert}
+\getvalue{\v!unit} [mSievert] {\Milli \Sievert} {milli Sievert}
+
+%D Light:
+
+\getvalue{\v!unit} [Candela] {cd} {Candela}
+
+%D and some sound ones:
+
+\getvalue{\v!unit} [Bell] {B} {Bell}
+\getvalue{\v!unit} [dBell] {\Deci \Bell} {decibel}
+
+%D We also define some non||regular, sometimes even forbidden,
+%D units:
+
+\getvalue{\v!unit} [At] {at} {\labeltext{u:at}}
+\getvalue{\v!unit} [Atm] {atm} {\labeltext{u:atm}}
+\getvalue{\v!unit} [Bar] {bar} {bar (100 \Kilo \Pascal)}
+\getvalue{\v!unit} [EVolt] {eV} {electronvolt}
+\getvalue{\v!unit} [Foot] {ft} {\labeltext{u:ft}}
+\getvalue{\v!unit} [Inch] {inch} {\labeltext{u:inch}}
+\getvalue{\v!unit} [Cal] {cal} {\labeltext{u:cal}}
+\getvalue{\v!unit} [Force] {f} {\labeltext{u:f}}
+\getvalue{\v!unit} [kCal] {\Kilo \Cal} {\labeltext{u:kcal}}
+\getvalue{\v!unit} [Lux] {lux} {lux}
+
+
+\def\xPercent {\dimensionaddfix{\percent }}
+\def\xPromille{\dimensionaddfix{\promille}}
+
+\getvalue{\v!unit} [Percent] {\xPercent } {percent}
+\getvalue{\v!unit} [Permille] {\xPromille} {promille}
+\getvalue{\v!unit} [Promille] {\xPromille} {promille}
+
+%D Some more, thanks to Tobias:
+
+\getvalue{\v!unit} [Gray] {Gr} {Gray}
+\getvalue{\v!unit} [Weber] {Wb} {Weber}
+\getvalue{\v!unit} [Henry] {H} {Henry}
+\getvalue{\v!unit} [Sterant] {sr} {Sterant}
+\getvalue{\v!unit} [Angstrom] {\hbox{\Aring}} {\Aring ngstr\"om}
+\getvalue{\v!unit} [Gauss] {G} {Gauss}
+
+\setuplabeltext
+ [\s!nl]
+ [u:at=technische atmosfeer,
+ u:atm=fysische atmosfeer,
+ u:ft=voet,
+ u:cal=calorie,
+ u:f=kracht (force),
+ u:kcal=kilocalorie]
+
+\setuplabeltext
+ [\s!en]
+ [u:at=technical atmospheric pressure,
+ u:atm=physical atmospheric pressure,
+ u:ft=foot,
+ u:inch=inch,
+ u:cal=calory,
+ u:f=force,
+ u:kcal=kilocalory]
+
+\setuplabeltext
+ [\s!de]
+ [u:at=Technischer atmosph\"arischer Druck,
+ u:atm=physkalischer atmosph\"arischer Druck,
+ u:ft=Fu\SS,
+ u:cal=Kalorien,
+ u:f=Force,
+ u:kcal=Kilokalorien]
+
+\setuplabeltext
+ [\s!hr]
+ [u:at=tehni\ccaron ka atmosfera,
+ u:atm=standardna atmosfera,
+ u:ft=stopa,
+ u:inch=in\ccaron a,
+ u:cal=kalorija,
+ u:f=Force,
+ u:kcal=Kilokalorien]
+
+\setuplabeltext
+ [\s!it]
+ [u:at=pressione atmosferica tecnica,
+ u:atm=pressione atmosfera fisica,
+ u:ft=piede,
+ u:cal=caloria,
+ u:f=forza,
+ u:kcal=chilocaloria]
+
+%D Here are some old ones, still there for compatibility
+%D reasons. These will probably be obsolete in a few years.
+
+\def\MeterTwee {\Square \Meter}
+\def\mMeterTwee {\Square \Milli \Meter}
+\def\cMeterTwee {\Square \Centi \Meter}
+\def\dMeterTwee {\Square \Deci \Meter}
+\def\kMeterTwee {\Square \Kilo \Meter}
+
+\def\MeterDrie {\Cubic \Meter}
+\def\mMeterDrie {\Cubic \Milli \Meter}
+\def\cMeterDrie {\Kubic \Centi \Meter}
+\def\dMeterDrie {\Cubic \Deci \Meter}
+\def\kMeterDrie {\Cubic \Kilo \Meter}
+
+\def\LiterTwee {\Square \Liter}
+\def\SecTwee {\Square \Sec}
+\def\SecMinEen {\Inverse \Sec}
+
+%D To make ourselves happy, we define some dutch specific
+%D units:
+
+\startinterface dutch
+
+ \getvalue{\v!unit} [PaardenKracht] {pk} {paardenkracht}
+ \getvalue{\v!unit} [Duits] {D} {duits}
+ \getvalue{\v!unit} [Kwik] {Hg} {kwikkolom}
+ \getvalue{\v!unit} [Hectare] {ha} {hectare}
+ \getvalue{\v!unit} [kGramForce] {\Kilo \Gram \Force} {kilogramforce}
+ \getvalue{\v!unit} [kWattUur] {\Kilo \Watt \Uur} {kilowattuur}
+ \getvalue{\v!unit} [MeterKwik] {\Meter \Kwik} {meter kwikkolom}
+ \getvalue{\v!unit} [Waterkolom] {WK} {waterkolom}
+ \getvalue{\v!unit} [MeterWater] {\Meter \Waterkolom} {meter waterkolom}
+ \getvalue{\v!unit} [DrogeStof] {ds} {droge stof}
+ \getvalue{\v!unit} [Normaal] {N} {normaal}
+
+ \getvalue{\v!unit} [Ton] {t} {ton}
+ \getvalue{\v!unit} [kTon] {\Kilo \Ton} {kiloton}
+
+ \let \OmwPerSec \RevPerSec
+ \let \OmwPerMin \RevPerMin
+ \let \Graden \Deg
+ \let \PaardeKracht \PaardenKracht
+ \let \Atoom \Atom
+ \let \Heure \Hour
+ \let \Jaar \Year
+ \let \Maand \Month
+ \let \Dag \Day
+ \let \Uur \Hour
+
+\stopinterface
+
+%D Finally we define some equivalents. By using \type {\let}
+%D we can be sure that they don't end up double in the lists of
+%D units.
+
+\let \Second \Sec
+\let \Kubic \Cubic
+\let \IKubic \ICubic
+
+%D Option:
+
+% \def\Micro{\dimensionprefix{\iftextdimensions\mathematics\mu \else\mu \fi}}
+% \def\Times{\dimensionnopfix{\iftextdimensions\mathematics\cdot\else\cdot\fi}}
+
+\stopmodule
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/modules/mkiv/m-visual.mkiv b/Master/texmf-dist/tex/context/modules/mkiv/m-visual.mkiv
new file mode 100644
index 00000000000..01fae49e2b6
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkiv/m-visual.mkiv
@@ -0,0 +1,814 @@
+%D \module
+%D [ file=m-visual,
+%D version=2000.01.10,
+%D title=\CONTEXT\ Extra Modules,
+%D subtitle=Visualization and Faking,
+%D author={Hans Hagen \& Ton Otten},
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\unprotect
+
+%D Much will probably be replaced by \LUA\ based solutions which is
+%D rather trivial and fun doing.
+
+%D This module collect a few more visual debugger features. I
+%D needed them for manuals and styles. The macros are documented
+%D in a my way document.
+
+\definecolor[fakerulecolor] [black]
+\definecolor[fakebaselinecolor] [green]
+\definecolor[fakeparindentcolor][blue]
+
+\newif\iffakebaseline \fakebaselinetrue
+\newif\iffaketrigger \faketriggerfalse
+
+\unexpanded\def\fakerule#1%
+ {\strut
+ \begingroup
+ \directcolored[fakerulecolor]%
+ \iffakebaseline
+ \vrule\s!height1.25\exheight\s!depth-.05\exheight\s!width#1%
+ \kern-#1%
+ \vrule\s!height-.05\exheight\s!depth .25\exheight\s!width#1%
+ \else
+ \vrule\s!height1.25\exheight\s!depth .25\exheight\s!width#1%
+ \fi
+ \endgroup
+ \allowbreak}
+
+\unexpanded\def\dorandomrecurse#1%
+ {\getrandomcount\scratchcounter{1}{#1}%
+ \dorecurse\scratchcounter}
+
+% can be used in hbox, so %'s are really needed
+
+\unexpanded\def\fakelines#1#2% min max / 3 10
+ {\fakeparindent
+ \scratchdimen\hsize
+ \ifindentation
+ \advance\scratchdimen -\parindent
+ \fi
+ \fakerule\scratchdimen\break
+ \getrandomcount\scratchcounter{\ifcase0#1 3\else#1\fi}{\ifcase0#2 10\else#2\fi}%
+ \dorecurse\scratchcounter{\fakerule\hsize}%
+ \getrandomdimen\scratchdimen{.25\hsize}\hsize
+ \fakerule\scratchdimen
+ \par} % indeed
+
+\unexpanded\def\fakewords
+ {\ifvmode\fakeparindent\fi\onlyfakewords}
+
+\definepalet
+ [fakerule]
+ [fr1c=darkred,
+ fr2c=darkgreen,
+ fr3c=darkblue,
+ fr4c=darkyellow,
+ fr5c=darkgray,
+ fr6c=darkmagenta,
+ fr7c=darkcyan,
+ fr8c=darkorange]
+
+\unexpanded\def\onlyfakewords#1#2% min max / 10 40
+ {\getrandomcount\scratchcounter{\ifcase0#1 10\else#1\fi}{\ifcase0#2 40\else#2\fi}%
+ \dofakewords\scratchcounter
+ } % no \par
+
+\unexpanded\def\fakenwords#1#2% words seed
+ {\fakeparindent
+ \getrandomseed\fakedwordseed
+ \setrandomseed{\ifcase0#2 #1\else#2\fi}%
+ \dofakewords{#1}%
+ \setrandomseed\fakedwordseed
+ } % no \par
+
+\def\dofakewords#1%
+ {\bgroup
+ \dorecurse{#1}
+ {\iffaketrigger\signalcharacter\fi % so that e.g. line numbering works
+ \getrandomcount\scratchcounter{1}{5}%
+ \dorecurse\scratchcounter
+ {\getrandomdimen\scratchdimen{.5em}{1.25em}%
+ \fakerule\scratchdimen}%
+ \space}%
+ \removeunwantedspaces
+ \egroup}
+
+\def\doshowfakewords#1%
+ {\bgroup
+ \setuppalet[fakerule]%
+ \definecolor[fakerulecolor]%
+ \dorecurse{#1}
+ {\getrandomcount\scratchcounter{1}{5}%
+ \dorecurse\scratchcounter
+ {\getrandomdimen\scratchdimen{.5em}{1.25em}%
+ \color[fr\recurselevel c]{\fakerule\scratchdimen}}%
+ \space}%
+ \removeunwantedspaces
+ \egroup}
+
+\unexpanded\def\showfakewords
+ {\let\dofakewords\doshowfakewords}
+
+\unexpanded\def\fakeword
+ {\fakewords{1}{1}} % no \plusone
+
+\unexpanded\def\fakeparindent
+ {\noindent
+ \ifindentation
+ \ifx\dofakedroppedcaps\relax
+ {\fakeparindentcolor
+ \vrule
+ \s!height \strutheight % not longer .5ex
+ \s!depth \strutdepth % not longer 0pt
+ \s!width \parindent}%
+ \else
+ \dofakedroppedcaps \let\dofakedroppedcaps\relax
+ \fi
+% \else
+% \dontleavehmode
+ \fi}
+
+\let\dofakedroppedcaps\relax
+
+\unexpanded\def\fakedroppedcaps#1%
+ {\ifnum#1>0
+ \def\dofakedroppedcaps
+ {\setbox\scratchbox\hpack
+ {\setbox\scratchbox\hpack{W}%
+ \scratchdimen#1\lineheight
+ \advance\scratchdimen -\lineheight
+ \advance\scratchdimen \dp\strutbox
+ \vrule
+ \s!width#1\wd\scratchbox
+ \s!height\ht\scratchbox
+ \s!depth\scratchdimen}%
+ \ht\scratchbox\ht\strutbox
+ \dp\scratchbox\dp\strutbox
+ \hangindent\wd\scratchbox
+ \advance\hangindent .5em
+ \wd\scratchbox\hangindent
+ \hangafter-#1\noindent
+ \llap{\fakeparindentcolor\box\scratchbox}}%
+ \fi}
+
+\unexpanded\def\fakefigure
+ {\dodoubleempty\dofakefigure}
+
+\def\dofakefigure[#1][#2]#3#4#5#6% [] [] minwidth maxwidth minheight maxheight
+ {\getvalue{\e!place\v!figure}
+ [#1][#2]%
+ {\freezerandomseed
+ \let\endstrut\relax
+ \let\begstrut\relax
+ \doifelseinset{#1}{\v!left,\v!right}
+ {\fakewords{2}{4}}
+ {\fakewords{4}{10}}}%
+ {\doifinset{#1}{\v!left,\v!right}
+ {\dimen0=.75\dimen0
+ \ifdim\dimen0>.6\hsize \dimen0=.5\hsize\fi
+ \ifdim\dimen0<.3\hsize \dimen0=.3\hsize\fi}%
+ \framed
+ [\c!width=\dimen0,
+ \c!height=\dimen2,
+ \c!frame=\v!off,
+ \c!background=\v!color,
+ \c!backgroundcolor=fakeparindentcolor]
+ {\bf\white#1}}%
+ \defrostrandomseed}
+
+\unexpanded\def\fakeimage#1#2#3#4%
+ {\getrandomdimen{\dimen0}{#1}{#3}%
+ \getrandomdimen{\dimen2}{#2}{#4}%
+ \framed
+ [\c!width=\dimen0,
+ \c!height=\dimen2,
+ \c!frame=\v!off,
+ \c!background=\v!color,
+ \c!backgroundcolor=fakeparindentcolor]
+ {}}
+
+\unexpanded\def\fakeformula
+ {\dimen0\zeropoint
+ \getrandomcount\scratchcounter{3}{6}%
+ \dorecurse\scratchcounter
+ {\getrandomdimen\scratchdimen{0.5em}{1.5em}%
+ \mathord{\red\fakerule\scratchdimen}%
+ \ifnum\recurselevel<\scratchcounter+\fi
+ \advance\scratchdimen\dimen0}%
+ =\mathinner{\red\fakerule\scratchdimen}}
+
+\unexpanded\def\fakespacingformula
+ {\color[fakebaselinecolor]{\ruledbaseline}\fakeformula}
+
+%D test \type{\bodyfontgrid}\space test
+%D test \type{\emexgrid} \space test
+
+\unexpanded\def\smashedgrid
+ {\dosingleempty\dosmashedgrid}
+
+\def\dosmashedgrid[#1]%
+ {\hsmashed
+ {\setbox\scratchbox=\hpack
+ {\basegrid
+ [\c!nx=10,\c!ny=10,\c!dx=1,\c!dy=1,
+ \c!unit=\bodyfontsize,#1]}%
+ \hpack to \zeropoint
+ {\hss\lower.5\ht\scratchbox\box\scratchbox\hss}%
+ \hpack to \zeropoint
+ {\hss
+ \black\vrule\s!width6\linewidth\s!height3\linewidth\s!depth3\linewidth
+ \hss}}}
+
+\unexpanded\def\bodyfontgrid
+ {\hpack
+ {{\linewidth.1pt\yellow\smashedgrid[\c!nx=30,\c!ny=30,\c!scale=.3333]}%
+ {\linewidth.2pt\green \smashedgrid[\c!nx=20,\c!ny=20,\c!scale=.5]}%
+ {\linewidth.3pt\red \smashedgrid[\c!nx=10,\c!ny=10,\c!scale=1]}}}
+
+\unexpanded\def\emexgrid
+ {\hpack
+ {{\linewidth.15pt\green\smashedgrid[\c!nx=20,\c!ny=20,\c!unit=ex]}%
+ {\linewidth.15pt\red \smashedgrid[\c!nx=10,\c!ny=10,\c!unit=em]}}}
+
+%D For Mojca:
+
+\unexpanded\def\simplethesis
+ {\setupsystem[random=1234]
+ \title{\fakewords{3}{4}}
+ \placelist[chapter,section]
+ \dorecurse{6}
+ {\chapter{\fakewords{5}{10}}
+ \dorecurse{5}
+ {\section{\fakewords{2}{5}}
+ \dorecurse{2}
+ {\dorecurse{3}{\fakewords{100}{200}\endgraf}
+ \placefigure{\fakewords{8}{15}}{\fakeimage{5cm}{3cm}{10cm}{5cm}}
+ \dorecurse{2}{\fakewords{100}{200}\endgraf}}}}}
+
+%D Moved code:
+
+%D \module
+%D [ file=trac-vis, % was core-vis,
+%D version=1996.06.01,
+%D title=\CONTEXT\ Tracking Macros,
+%D subtitle=Visualization,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+%D This module adds some more visualization cues to the ones
+%D supplied in the support module.
+%D
+%D %\everypar dual character, \the\everypar and \everypar=
+%D %\hrule cannot be grabbed in advance, switches mode
+%D %\vrule cannot be grabbed in advance, switches mode
+%D %
+%D %\indent only explicit ones
+%D %\noindent only explicit ones
+%D %\par only explicit ones
+%D
+%D %\leftskip only if explicit one
+%D %\rightskip only if explicit one
+
+\writestatus{loading}{ConTeXt Tracking Macros / Visualization}
+
+\unprotect
+
+%D \macros
+%D {indent, noindent, par}
+%D
+%D \TeX\ acts upon paragraphs. In mosts documents paragraphs
+%D are separated by empty lines, which internally are handled as
+%D \type{\par}. Paragraphs can be indented or not, depending on
+%D the setting of \type{\parindent}, the first token of a
+%D paragraph and/or user suppressed or forced indentation.
+%D
+%D Because the actual typesetting is based on both explicit
+%D user and implicit system actions, visualization is only
+%D possible for the user supplied \type{\indent},
+%D \type{\noindent}, and \type{\par}. Other
+%D 'clever' tricks will quite certainly lead to more failures
+%D than successes, so we only support these three explicit
+%D primitives and one macro:
+
+\unexpanded\def\showparagraphcue#1#2#3#4#5%
+ {\bgroup
+ \scratchdimen#1\relax
+ \dontinterfere
+ \dontcomplain
+ %boxrulewidth5\testrulewidth
+ #3#4\relax
+ \setbox\scratchbox\normalhbox to \scratchdimen
+ {#2{\ruledhbox to \scratchdimen
+ {\vrule #5 20\testrulewidth \s!width \zeropoint
+ \normalhss}}}%
+ \smashbox\scratchbox
+ \normalpenalty\plustenthousand
+ \box\scratchbox
+ \egroup}
+
+\unexpanded\def\ruledhanging
+ {\ifdim\hangindent>\zeropoint
+ \ifnum\hangafter<\zerocount
+ \normalhbox
+ {%boxrulewidth5\testrulewidth
+ \setbox\scratchbox\ruledhbox to \hangindent
+ {\scratchdimen\strutht
+ \advance\scratchdimen \strutdp
+ \vrule
+ \s!width \zeropoint
+ \s!height \zeropoint
+ \s!depth -\hangafter\scratchdimen}%
+ \normalhskip-\hangindent
+ \smashbox\scratchbox
+ \raise\strutht\box\scratchbox}%
+ \fi
+ \fi}
+
+\unexpanded\def\ruledparagraphcues
+ {\bgroup
+ \dontcomplain
+ \normalhbox to \zeropoint
+ {\ifdim\leftskip>\zeropoint\relax
+ \showparagraphcue\leftskip\llap\relax\relax\!!depth
+ \normalhskip-\leftskip
+ \fi
+ \ruledhanging
+ \normalhskip\hsize
+ \ifdim\rightskip>\zeropoint\relax
+ \normalhskip-\rightskip
+ \showparagraphcue\rightskip\relax\relax\relax\!!depth
+ \fi}%
+ \egroup}
+
+\unexpanded\def\ruledpar
+ {\relax
+ \ifhmode
+ \showparagraphcue{40\testrulewidth}\relax\rightrulefalse\relax\s!height
+ \fi
+ \normalpar}
+
+\unexpanded\def\rulednoindent
+ {\relax
+ \normalnoindent
+ \ruledparagraphcues
+ \showparagraphcue{40\testrulewidth}\llap\leftrulefalse\relax\s!height}
+
+\unexpanded\def\ruledindent
+ {\relax
+ \normalnoindent
+ \ruledparagraphcues
+ \ifdim\parindent>\zeropoint
+ \showparagraphcue\parindent\relax\relax\relax\s!height
+ \else
+ \showparagraphcue{40\testrulewidth}\llap\relax\relax\s!height
+ \fi
+ \normalhskip\parindent}
+
+\unexpanded\def\dontshowimplicits
+ {\let\noindent \normalnoindent
+ \let\indent \normalindent
+ \let\par \normalpar}
+
+\unexpanded\def\showimplicits
+ {\testrulewidth \defaulttestrulewidth
+ \let\noindent \rulednoindent
+ \let\indent \ruledindent
+ \let\par \ruledpar}
+
+%D The next few||line examples show the four cues. Keep in
+%D mind that we only see them when we explicitly open or close
+%D a paragraph.
+%D
+%D \bgroup
+%D \def\voorbeeld#1%
+%D {#1Visualizing some \TeX\ primitives and Plain \TeX\
+%D macros can be very instructive, at least it is to me.
+%D Here we see {\tt\string#1} and {\tt\string\ruledpar} in
+%D action, while {\tt\string\parindent} equals
+%D {\tt\the\parindent}.\ruledpar}
+%D
+%D \showimplicits
+%D
+%D \voorbeeld \indent
+%D \voorbeeld \noindent
+%D
+%D \parindent=60pt
+%D
+%D \voorbeeld \indent
+%D \voorbeeld \noindent
+%D
+%D \startnarrower
+%D \voorbeeld \indent
+%D \voorbeeld \noindent
+%D \stopnarrower
+%D \egroup
+%D
+%D These examples also demonstrate the visualization of
+%D \type {\leftskip} and \type {\rightskip}. The macro
+%D \type {\nofruledbaselines} determines the number of lines
+%D shown.
+
+\newcounter\ruledbaselines
+
+\def\nofruledbaselines{3}
+
+\unexpanded\def\ruledbaseline
+ {\vrule \s!width \zeropoint
+ \bgroup
+ \dontinterfere
+ \doglobal\increment\ruledbaselines
+ \scratchdimen\nofruledbaselines\baselineskip
+ \setbox\scratchbox\normalvbox to 2\scratchdimen
+ {\leaders
+ \normalhbox
+ {\strut
+ \vrule
+ \s!height \testrulewidth
+ \s!depth \testrulewidth
+ \s!width 120\points}
+ \normalvfill}%
+ \smashbox\scratchbox
+ \advance\scratchdimen \strutheightfactor\baselineskip
+ \setbox\scratchbox\normalhbox
+ {\normalhskip -48\points
+ \normalhbox to 24\points
+ {\normalhss
+ {\ttxx\ruledbaselines}%
+ \normalhskip6\points}%
+ \raise\scratchdimen\box\scratchbox}%
+ \smashbox\scratchbox
+ \box\scratchbox
+ \egroup}
+
+\unexpanded\def\showbaselines
+ {\testrulewidth\defaulttestrulewidth
+ \EveryPar{\ruledbaseline}}
+
+%D \macros
+%D {showpagebuilder}
+%D
+%D The next tracing option probaly is only of use to me and a
+%D few \CONTEXT\ hackers.
+
+\unexpanded\def\showpagebuilder
+ {\EveryPar{\doshowpagebuilder}}
+
+\unexpanded\def\doshowpagebuilder
+ {\strut\llap
+ {\startcolor[blue]\vl
+ \high{\infofont v:\the\vsize }\vl
+ \high{\infofont g:\the\pagegoal }\vl
+ \high{\infofont t:\the\pagetotal}\vl
+ \stopcolor}}
+
+%D \macros
+%D {colormarkbox,rastermarkbox}
+%D
+%D This macro is used in the pagebody routine. No other use
+%D is advocated here.
+%D
+%D \starttyping
+%D \colormarkbox0
+%D \stoptyping
+
+\def\colormarkoffset{\cutmarkoffset}
+\def\colormarklength{\cutmarklength}
+
+\def\dodocolorrangeA#1%
+ {\fastcolored[#1]{\hrule\s!width3em\s!height\scratchdimen\s!depth\zeropoint}}
+
+\def\docolorrangeA#1 #2 %
+ {\vpack
+ {\hsize3em % \scratchdimen
+ \ifcase#1\or
+ \dodocolorrangeA{c=#2}\or
+ \dodocolorrangeA{m=#2}\or
+ \dodocolorrangeA{y=#2}\or
+ \dodocolorrangeA{m=#2,y=#2}\or
+ \dodocolorrangeA{c=#2,y=#2}\or
+ \dodocolorrangeA{c=#2,m=#2}\fi
+ \ifdim\scratchdimen>1ex
+ \vskip-\scratchdimen
+ \vpack to \scratchdimen
+ {\vss\hpack to 3em{\hss#2\hss}\vss}%
+ \fi}}
+
+\def\colorrangeA#1%
+ {\vpack
+ {\startcolor[\s!white]%
+ \scratchdimen\dimexpr(-\colormarklength*4+\tractempheight+\tractempdepth)/21\relax
+ \offinterlineskip
+ \docolorrangeA #1 1.00 \docolorrangeA #1 0.95
+ \docolorrangeA #1 0.75
+ \docolorrangeA #1 0.50
+ \docolorrangeA #1 0.25 \docolorrangeA #1 0.05
+ \docolorrangeA #1 0.00
+ \stopcolor}}
+
+\def\docolorrangeB #1 #2 #3 #4 #5 %
+ {\fastcolored
+ [\c!c=#2,\c!m=#3,\c!y=#4,\c!k=#5]
+ {\vrule\s!width\scratchdimen\s!height\colormarklength\s!depth\zeropoint}%
+ \ifdim\scratchdimen>2em
+ \hskip-\scratchdimen
+ \vpack to \colormarklength
+ {\vss\hpack to \scratchdimen{\hss#1\hss}\vss}%
+ \fi}
+
+\def\colorrangeB
+ {\hpack
+ {\startcolor[\s!white]%
+ \scratchdimen\dimexpr(-\colormarklength*\plustwo+\tractempwidth)/11\relax
+ \docolorrangeB .5~C .5 0 0 0
+ \docolorrangeB .5~M 0 .5 0 0
+ \docolorrangeB .5~Y 0 0 .5 0
+ \docolorrangeB .5~K 0 0 0 .5
+ \docolorrangeB C 1 0 0 0
+ \docolorrangeB G 1 0 1 0
+ \docolorrangeB Y 0 0 1 0
+ \docolorrangeB R 0 1 1 0
+ \docolorrangeB M 0 1 0 0
+ \docolorrangeB B 1 1 0 0
+ \docolorrangeB K 0 0 0 1
+ \stopcolor}}
+
+\def\docolorrangeC#1 %
+ {\fastcolored
+ [\c!s=#1]%
+ {\vrule\s!width\scratchdimen\s!height\colormarklength\s!depth\zeropoint}%
+ \ifdim\scratchdimen>2em
+ \hskip-\scratchdimen
+ \vpack to \colormarklength
+ {\vss\hpack to \scratchdimen{\hss#1\hss}\vss}%
+ \fi}
+
+\def\colorrangeC
+ {\hpack
+ {\startcolor[\s!white]%
+ \scratchdimen\dimexpr(-\colormarklength*2+\tractempwidth)/14\relax
+ \docolorrangeC 1 \docolorrangeC .95
+ \docolorrangeC .9 \docolorrangeC .85
+ \docolorrangeC .8 \docolorrangeC .75
+ \docolorrangeC .7
+ \docolorrangeC .6
+ \docolorrangeC .5
+ \docolorrangeC .4
+ \docolorrangeC .3
+ \docolorrangeC .2
+ \docolorrangeC .1
+ \docolorrangeC 0
+ \stopcolor}}
+
+\def\docolormarkbox#1#2%
+ {\tractempheight\ht#2%
+ \tractempdepth \dp#2%
+ \tractempwidth \wd#2%
+ \setbox#2\hpack
+ {\scratchdimen\dimexpr\colormarklength/2\relax
+ \forgetall
+ \ssxx
+ \setbox\scratchbox\vpack
+ {\offinterlineskip
+ \vskip\dimexpr-\colormarkoffset\scratchdimen-2\scratchdimen\relax
+ \ifcase#1\relax
+ \vskip\dimexpr\colormarklength+\scratchdimen+\tractempheight\relax
+ \else
+ \hpack to \tractempwidth{\hss\hpack{\colorrangeB}\hss}%
+ \vskip\colormarkoffset\scratchdimen
+ \vpack to \tractempheight
+ {\vss
+ \hpack to \tractempwidth
+ {\llap{\colorrangeA1\hskip\colormarkoffset\scratchdimen}\hfill
+ \rlap{\hskip\colormarkoffset\scratchdimen\colorrangeA4}}%
+ \vss
+ \hpack to \tractempwidth
+ {\llap{\colorrangeA2\hskip\colormarkoffset\scratchdimen}\hfill
+ \rlap{\hskip\colormarkoffset\scratchdimen\colorrangeA5}}%
+ \vss
+ \hpack to \tractempwidth
+ {\llap{\colorrangeA3\hskip\colormarkoffset\scratchdimen}\hfill
+ \rlap{\hskip\colormarkoffset\scratchdimen\colorrangeA6}}%
+ \vss}%
+ \fi
+ \vskip\colormarkoffset\scratchdimen
+ \hpack to \tractempwidth
+ {\hss\lower\tractempdepth\hpack{\colorrangeC}\hss}}%
+ \ht\scratchbox\tractempheight
+ \dp\scratchbox\tractempdepth
+ \wd\scratchbox\zeropoint
+ \box\scratchbox
+ \box#2}%
+ \wd#2\tractempwidth
+ \ht#2\tractempheight
+ \dp#2\tractempdepth}
+
+\unexpanded\def\colormarkbox {\docolormarkbox\plusone } % #1
+\unexpanded\def\rastermarkbox{\docolormarkbox\zerocount} % #1
+
+%D \macros
+%D {showwhatsits, dontshowwhatsits}
+%D
+%D \TEX\ has three so called whatsits: \type {\mark}, \type
+%D {\write} and \type {\special}. The first one keeps track of
+%D the current state at page boundaries, the last two are used
+%D to communicate to the outside world. Due to fact that
+%D especially \type {\write} is often used in conjunction with
+%D \type {\edef}, we can only savely support that one in \ETEX.
+%D
+%D \bgroup \showwhatsits \setupcolors[state=start]
+%D
+%D Whatsits show up \color[blue]{in color} and are
+%D characterized bij their first character.\footnote [some note]
+%D {So we may encounter \type {w}, \type {m} and \type{s}.}
+%D They are \writestatus{dummy}{demo}\color[yellow]{stacked}.
+%D
+%D \egroup
+
+\newif\ifimmediatewrite
+
+\let\supernormalmark \normalmark % mark may already been superseded
+\let\supernormalmarks \normalmarks % mark may already been superseded
+
+\unexpanded\def\showwhatsits
+ {\protected\def\normalmark {\visualwhatsit100+m\supernormalmark }%
+ \protected\def\normalmarks{\visualwhatsit100+m\supernormalmarks}%
+ \protected\def\special {\visualwhatsit0100s\normalspecial }%
+ \protected\def\write {\visualwhatsit001-w\normalwrite }%
+ \let\immediate\immediatewhatsit
+ \appendtoks\dontshowwhatsits\to\everystoptext}
+
+\unexpanded\def\immediatewhatsit
+ {\bgroup\futurelet\next\doimmediatewhatsit}
+
+\unexpanded\def\doimmediatewhatsit
+ {\ifx\next\write
+ \egroup\immediatewritetrue
+ \else
+ \egroup\expandafter\normalimmediate
+ \fi}
+
+\unexpanded\def\dontshowwhatsits
+ {\let\immediate \normalimmediate
+ \let\normalmark\supernormalmark
+ \let\special \normalspecial
+ \let\write \normalwrite}
+
+\unexpanded\def\visualwhatsit#1#2#3#4#5%
+ {\bgroup
+ \pushwhatsit
+ \dontinterfere
+ \dontcomplain
+ \dontshowcomposition
+ \dontshowwhatsits
+ \ttx
+ \ifvmode\donetrue\else\donefalse\fi
+ \setbox\scratchbox\hpack
+ {\ifdone
+ \colored[r=#1,g=#2,b=#3]{#5}% temp hack
+ \else
+ \colored[s=0]{#5}% temp hack
+ \fi}%
+ \setbox\scratchbox\hpack
+ {\ifdone
+ \colored[r=#1,g=#2,b=#3]{\vrule\s!width\wd\scratchbox}% temp hack
+ \else
+ \colored[s=0]{\vrule\s!width\wd\scratchbox}% temp hack
+ \fi
+ \hskip-\wd\scratchbox\box\scratchbox}%
+ \scratchdimen1ex
+ \setbox\scratchbox\hpack
+ {\ifdone\hskip\else\raise#4\fi\scratchdimen\box\scratchbox}%
+ \smashbox\scratchbox
+ \ifdone\nointerlineskip\fi
+ \box\scratchbox
+ \ifvmode\nointerlineskip\fi
+ \popwhatsit
+ \egroup
+ \ifimmediatewrite
+ \immediatewritefalse
+ \expandafter\normalimmediate
+ \fi}
+
+\unexpanded\def\pushwhatsit
+ {\ifzeropt\lastskip
+ \ifcase\lastpenalty
+ \ifzeropt\lastkern
+ \ifhmode
+ \let\popwhatsit\relax
+ \else
+ \edef\popwhatsit{\prevdepth\the\prevdepth}%
+ \fi
+ \else
+ \ifhmode
+ \edef\popwhatsit{\kern\the\lastkern}\unkern
+ \else
+ \edef\popwhatsit{\kern\the\lastkern\prevdepth\the\prevdepth}%
+ \kern-\lastkern
+ \fi
+ \fi
+ \else
+ \ifhmode
+ \edef\popwhatsit{\the\lastpenalty}%
+ \unpenalty
+ \else
+ \edef\popwhatsit{\penalty\the\lastpenalty\prevdepth\the\prevdepth}%
+ %\nobreak
+ \fi
+ \fi
+ \else
+ \ifhmode
+ \edef\popwhatsit{\hskip\the\lastskip}\unskip
+ \else
+ \edef\popwhatsit{\vskip\the\lastskip\prevdepth\the\prevdepth}%
+ \vskip-\lastskip
+ \fi
+ \fi}
+
+%D The next macro can be used to keep track of classes of
+%D boxes (handy for development cq.\ tracing).
+
+\def\dodotagbox#1#2#3% can be reimplemented
+ {\def\next##1##2##3##4%
+ {\vpack to \ht#2{##3\hpack to \wd#2{##1#3##2}##4}}%
+ \processaction
+ [#1]
+ [ l=>\next\relax\hfill\vfill\vfill,
+ r=>\next\hfill\relax\vfill\vfill,
+ t=>\next\hfill\hfill\relax\vfill,
+ b=>\next\hfill\hfill\vfill\relax,
+ lt=>\next\relax\hfill\relax\vfill,
+ lb=>\next\relax\hfill\vfill\relax,
+ rt=>\next\hfill\relax\relax\vfill,
+ rb=>\next\hfill\relax\vfill\relax,
+ tl=>\next\relax\hfill\relax\vfill,
+ bl=>\next\relax\hfill\vfill\relax,
+ tr=>\next\hfill\relax\relax\vfill,
+ br=>\next\hfill\relax\vfill\relax,
+ \s!default=>\next\hfill\hfill\vfill\vfill,
+ \s!unknown=>\next\hfill\hfill\vfill\vfill]}
+
+\def\dotagbox[#1]#2%
+ {\bgroup
+ \dowithnextbox
+ {\setbox\scratchbox\flushnextbox
+ \setbox\nextbox\ifhbox\nextbox\hpack\else\vpack\fi
+ \bgroup
+ \startoverlay
+ {\copy\scratchbox}
+ {\dodotagbox{#1}\scratchbox{\framed
+ [\c!background=\v!color,\c!backgroundcolor=\v!gray]{#2}}}
+ \stopoverlay
+ \egroup
+ \nextboxwd\the\wd\scratchbox
+ \nextboxht\the\ht\scratchbox
+ \nextboxdp\the\dp\scratchbox
+ \flushnextbox
+ \egroup}}
+
+\unexpanded\def\tagbox
+ {\dosingleempty\dotagbox}
+
+%D \macros
+%D {coloredhbox,coloredvbox,coloredvtop,
+%D coloredstrut}
+%D
+%D The following visualizations are used in some of the manuals:
+
+\definecolor[boxcolor:ht][r=.5,g=.75,b=.5]
+\definecolor[boxcolor:dp][r=.5,g=.5,b=.75]
+\definecolor[boxcolor:wd][r=.75,g=.5,b=.5]
+\definecolor[strutcolor] [r=.5,g=.25,b=.25]
+
+\unexpanded\def\coloredbox#1%
+ {\dowithnextbox{#1{\hpack
+ {\blackrule[\c!width=\nextboxwd,\c!height=\nextboxht,\c!depth=\zeropoint,\c!color=boxcolor:ht]%
+ \hskip-\nextboxwd
+ \blackrule[\c!width=\nextboxwd,\c!height=\zeropoint,\c!depth=\nextboxdp,\c!color=boxcolor:dp]%
+ \hskip-\nextboxwd
+ \box\nextbox}}}#1}
+
+\unexpanded\def\coloredhbox{\coloredbox\hpack}
+\unexpanded\def\coloredvbox{\coloredbox\vpack}
+\unexpanded\def\coloredvtop{\coloredbox\tpack}
+
+\unexpanded\def\coloredstrut
+ {\color[strutcolor]{\def\strutwidth{2\points}\setstrut\strut}}
+
+\protect
+
+\continueifinputfile{m-visual.mkiv}
+
+\starttext
+ \simplethesis
+\stoptext
diff --git a/Master/texmf-dist/tex/context/modules/mkiv/m-zint.mkiv b/Master/texmf-dist/tex/context/modules/mkiv/m-zint.mkiv
new file mode 100644
index 00000000000..4957c846173
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkiv/m-zint.mkiv
@@ -0,0 +1,112 @@
+%D \module
+%D [ file=m-zint,
+%D version=2010.12.07,
+%D title=\CONTEXT\ Extra Modules,
+%D subtitle=Zint Barcode Generator,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+%D Using \type {zint} seems to be the easiest way to generate
+%D (PDF417) barcodes so therefore we now have this module. There
+%D are proper (also windows) binaries at:
+%D
+%D \starttyping
+%D http://www.zint.org.uk
+%D \stoptyping
+%D
+%D There is a bit more code than needed as we want to be able to
+%D feed names.
+
+\startluacode
+
+moduledata.zint = { }
+
+local format, lower, gsub = string.format, string.lower, string.gsub
+local patterns = lpeg.patterns
+
+local zint = "zint" -- '"c:/program files/zint/zint.exe"'
+local defaultcode = "PDF417"
+
+local whitespace = patterns.whitespace
+local spaces = whitespace^0
+local key = (spaces / "") * patterns.digit^0 * (patterns.colon * spaces / "")
+local value = (whitespace / "" + (1 - key))^1
+local pattern = lpeg.Cf(lpeg.Ct("") * (lpeg.Cg((lpeg.Cs(key) / tonumber) * (lpeg.Cs(value) / lower)) + patterns.anything)^0,rawset)
+
+local reverse
+
+local function cleancode(code)
+ if not code or code == "" then
+ code = defaultcode
+ end
+ return lower(gsub(code," ",""))
+end
+
+local function numberofcode(code)
+ if not reverse then
+ local types = os.resultof(format("%s --types",zint)) or ""
+ local formats = lpeg.match(pattern,types)
+ if not formats or not next(formats) then
+ return code
+ end
+ reverse = table.swapped(formats) or { }
+ end
+ code = cleancode(code)
+ return reverse[code] or code
+end
+
+function moduledata.zint.generate(code,data,suffix,options)
+ if not data or data == "" then
+ data = "unset"
+ end
+ local code = cleancode(code)
+ local base = format("zint-%s-%s",code,md5.hex(data))
+ local name = file.addsuffix(base,suffix or "eps")
+ if not lfs.isfile(name) then
+ local temp = file.addsuffix(base,"tmp")
+ local code = numberofcode(code)
+ logs.simple("using 'zint' to generate '%s'",base)
+ io.savedata(temp,data)
+ os.execute(format('%s --barcode=%s --output="%s" --input="%s" %s',zint,code,name,temp,options or ""))
+ os.remove(temp)
+ end
+ return name
+end
+
+\stopluacode
+
+\unprotect
+
+\unexpanded\def\barcode[#1]% [alternative=,text=]
+ {\bgroup
+ \getdummyparameters
+ [\c!alternative=,\c!text=,#1]%
+ \externalfigure
+ [\cldcontext{moduledata.zint.generate("\dummyparameter\c!alternative",\!!bs\dummyparameter\c!text\!!es)}]%
+ [#1,\c!alternative=,\c!text=]%
+ \egroup}
+
+\protect
+
+\continueifinputfile{m-zint.mkiv}
+
+\starttext
+
+ \externalfigure[\cldcontext{moduledata.zint.generate("PDF417",[[Hans Hagen]])}]
+ \blank
+ \externalfigure[\cldcontext{moduledata.zint.generate("PDF417","Ton Otten")}]
+ \blank
+ \externalfigure[\cldcontext{moduledata.zint.generate("ISBN","9789490688011")}]
+ \blank
+ \barcode[text=Does It Work?,width=\textwidth]
+ \blank
+ \barcode[alternative=isbn,text=9789490688011,width=3cm]
+
+\stoptext
+
+
diff --git a/Master/texmf-dist/tex/context/modules/mkiv/ppchtex.mkiv b/Master/texmf-dist/tex/context/modules/mkiv/ppchtex.mkiv
new file mode 100644
index 00000000000..d1167d4143a
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkiv/ppchtex.mkiv
@@ -0,0 +1,3445 @@
+%D \module
+%D [ file=ppchtex,
+%D version=1997.03.19,
+%D title=\CONTEXT\ Extra Modules,
+%D subtitle=\PPCHTEX\ (Plain Pictex Context cHemie \TEX),
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D suggestions={Tobias Burnus, Dirk Kuypers \& Ton Otten},
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\endinput
+
+% option=test => boxes
+% dummy => file
+% final => file / local run
+%
+% constante van phantom in definitie ONE: \setchemicaltextwidth 300
+%
+% it would be interesting to rewrite this module with todays
+% experiences and new context functionality, maybe ...
+
+% Deze module ondersteunt het zetten van chemische
+% (structuur)formules. Hoewel de macro' zijn afgestemd op
+% CONTEXT, zijn ze ook buiten deze zetomgeving te gebruiken.
+%
+% Dit is, afgezien van updates, de definitieve versie van
+% PPCHTEX. Gebruikersgemak, eenvoud, flexibiliteit, en
+% snelheid zijn inmiddels redelijk geoptimaliseerd. Dit neemt
+% niet weg dat hier en daar nog verbetering mogelijk is. Dit
+% zal dan ook nog gebeuren.
+%
+% Volgende versies zullen tenminste dezelfde functionaliteit
+% hebben. We houden ons natuurlijk het recht voor de kwaliteit
+% van de output te verbeteren. Daarnaast staan nog op het
+% wensenlijstje:
+%
+% - optimaliseren in termen van proces-tijd
+% - aanpassen naamgeving van interne macro's
+% - toevoegen van functionaliteit
+% - in \x!-vorm omzetten van GIVES, TB enz.
+%
+% De mix tussen engels en nederlands lijkt soms verwarrend.
+% Meestal zijn verborgen macro's engels en zichtbare macro's
+% nederlands. Het gebruik van [ ] en { } sluit aan op andere
+% Context-macro's. Hetzelfde geldt voor instellingen en
+% \start-\stop-constructies.
+%
+% De schijnbaar overbodige \bgroup-\egroup constructie
+% garandeert aansluiting bij de Context-macro's voor het
+% plaatsen van figuren, tabellen en andere floats.
+%
+% Binnen Context worden de macro's geladen met
+% \gebruikextras[chemie]. Daarbij wordt een passende melding
+% getoont. Buiten Context genereren we een melding:
+
+\doifundefined{usemodule}
+ {\writestatus{loading}{ConTeXt Chemical Macro's / 1996.3.1}}
+
+% Er kan gebruik worden gemaakt van PiCTeX of PStricks. Een
+% van deze pakketten moet van te voren zijn geladen.
+%
+% \input prepictex.tex (i.g.v. LaTeX)
+% \input pictex.tex
+% \input postpictex.tex (i.g.v. LaTeX)
+%
+% of:
+%
+% \input multido.tex
+% \input pstricks.tex
+% \input pst-plot.tex
+%
+% In \CONTEXT\ kan men de modules m-pictex en m-pstricks
+% gebruiken. De eerste module laad of efficiente wijze PiCTeX
+% en de tweede module koppelt het PSTRICKS kleurmechanisme
+% aan dat van \CONTEXT.
+
+% PSTricks: {-\chemicalangle} instead of {*0}, which produces
+% faulty ps code when \chemicalangle=0
+
+\startcommands dutch english german
+
+ gotochemical: naarchemie gotochemical zurchemie
+ setupchemical: stelchemiein setupchemical stellechemieein
+ startchemical: startchemie startchemical startchemie
+ stopchemical: stopchemie stopchemical stopchemie
+ definechemical: definieerchemie definechemical definierechemie
+ chemical: chemie chemical chemie
+ toptext: boventekst toptext textueber
+ bottext: ondertekst bottext textunter
+ midtext: middentekst midtext textmitte
+
+\stopcommands
+
+\doifundefined{fiverm} % In the more recent LaTeX versions
+ {\font\fiverm=cmr5 } % \fiverm is no longer (pre)defined.
+
+\newconstant\chemicaldrawingmode
+
+\doifelsedefined{beginpicture} % PiCTeX
+ {\doifelsedefined{startMPdrawing}
+ {\chemicaldrawingmode\plustwo } % MetaPost
+ {\chemicaldrawingmode\zerocount}} % raw
+ {\doifelsedefined{psaxes}
+ {\chemicaldrawingmode\plusone } % PSTricks
+ {\chemicaldrawingmode\plusthree}} % unknown
+
+\ifcase\chemicaldrawingmode
+ \writestatus{ppchtex}{using PiCTeX}
+\or
+ \writestatus{ppchtex}{using PSTricks (still experimental)}
+ \writestatus{ppchtex}{automatic sizing not (yet) supported}
+\or
+ \writestatus{ppchtex}{using PiCTeX and MetaPost}
+\else
+ \writestatus{ppchtex}{load PiCTeX (+pre/post) or PSTricks (+pst_plot) first}
+ \bgroup
+ \read16 to \exit
+ \egroup
+ \expandafter\endinput
+\fi
+
+%I n=Chemie
+%I c=\stelchemiein,\chemie
+%I
+%I Chemische formules kunnen worden gezet met behulp van de
+%I onderstaande commando's:
+%I
+%I buiten $ en $$ :
+%I
+%I \chemie[segmenten][symbolen]
+%I
+%I \startchemie[instellingen]
+%I \chemie...
+%I \chemie...
+%I \stopchemie
+%I
+%I en binnen $ en $$:
+%I
+%I \chemie{}{}
+%I
+%I Voor tekst, uitleg en voorbeelde verwijzen we vooralsnog
+%I naar de handleiding.
+%P
+%I Het gedrag van de macro's kan worden ingesteld met:
+%I
+%I \stelchemiein[breedte=,hoogte=,links=,rechts=,boven=,
+%I onder=,korps=,schaal=,status=,assenstelsel=,kader=,
+%I variant=,optie=,formaat=,tekstformaat=,resolutie=,
+%I offset=,letter=]
+%I
+%I Structuren kunnen worden voorgedefinieerd met het commando
+%I
+%I \definieerchemie[naam]{\chemie...}
+
+%S \startsetup
+%S \command
+%S [\!stelchemiein]
+%S \type
+%S [\c!vars!]
+%S \variable
+%S [\c!breedte]
+%S [\c!number!,\v!passend]
+%S [0]
+%S \variable
+%S [\c!hoogte]
+%S [\c!number!,\v!passend]
+%S [0]
+%S \variable
+%S [\c!links]
+%S [\c!number!]
+%S [0]
+%S \variable
+%S [\c!rechts]
+%S [\c!number!]
+%S [0]
+%S \variable
+%S [\c!boven]
+%S [\c!number!]
+%S [0]
+%S \variable
+%S [\c!onder]
+%S [\c!number!]
+%S [0]
+%S \variable
+%S [\c!resolutie]
+%S [\c!number!]
+%S [\outputresolution]
+%S \variable
+%S [\c!korps]
+%S [10pt,11pt,12pt]
+%S [\bodyfontsize]
+%S \variable
+%S [\c!schaal]
+%S [\v!klein,\v!middel,\v!groot]
+%S [\v!middel]
+%S \variable
+%S [\c!formaat]
+%S [\v!klein,\v!middel,\v!groot]
+%S [\v!groot]
+%S \variable
+%S [\c!tekstformaat]
+%S [\v!klein,\v!middel,\v!groot]
+%S [\v!groot]
+%S \variable
+%S [\c!status]
+%S [\v!start,\v!stop]
+%S [\v!start]
+%S \variable
+%S [\c!kader]
+%S [\v!aan,\v!uit]
+%S [\v!uit]
+%S \variable
+%S [\c!assenstelsel]
+%S [\v!aan,\v!uit]
+%S [\v!uit]
+%S \variable
+%S [\c!optie]
+%S [\v!test]
+%S []
+%S \variable
+%S [\c!variant]
+%S [1,2]
+%S [1]
+%S \variable
+%S [\c!offset]
+%S [HIGH,LOW]
+%S [LOW]
+%S \variable
+%S [\c!letter]
+%S [\c!command!]
+%S [\rm]
+%S \stopsetup
+
+%S \startsetup
+%S \command
+%S [\v!startchemie]
+%S \type
+%S [\c!vars!\c!stp!]
+%S \inheritvariable
+%S [\v!stelchemiein]
+%S []
+%S \stopsetup
+
+%S \startsetup
+%S \command
+%S [\v!chemie]
+%S \type
+%S [\c!vals!\c!vals!]
+%S \value
+%S [\c!list!]
+%S []
+%S \value
+%S [\c!list!]
+%S []
+%S \stopsetup
+
+%S \startsetup
+%S \command
+%S [definieerchemie]
+%S \type
+%S [\c!val!\c!arg!]
+%S \value
+%S [\c!text!]
+%S []
+%S \stopsetup
+
+\unprotect
+
+% Om te voorkomen dat sub- en superscripts botsen passen we
+% wat fontdimen's aan (Knuth, The TeXBook, p179). Helaas
+% kunnen deze instellingen niet lokaal worden gehouden door
+% groeperen, vandaar dat een en ander moet worden geset n
+% gereset.
+%
+% Er dient een relatie te worden gelegd met de afmetingen
+% van de letters. In een eerdere versie werden daartoe de
+% \fontdimen's opgehoogd. Omdat dit problemen gaf bij
+% scaled fonts, is bij nader inzien gekozen voor de
+% onderstaande oplossing, waarbij de nieuwe waarden worden
+% afgeleid van de x-height (\fontexheight). De factor 0.70
+% is min of meer experimenteel vastgesteld. Soms worden de
+% regels iets verder uit elkaar gezet. Jammer. Italic fonts
+% hebben grotere cijfers en vallen min of meer uit de boot.
+
+\newif\ifloweredsubscripts % this will be redone in the mkiv ways
+
+\def\setsubscripts
+ {\def\dosetsubscript##1##2##3%
+ {\dimen0=##3\fontexheight##2%
+ \setxvalue{@@\string##1\string##2}{\the##1##2\relax}%
+ ##1##2=\dimen0\relax}%
+ \def\dodosetsubscript##1##2%
+ {\dosetsubscript{##1}{\textfont 2}{##2}%
+ \dosetsubscript{##1}{\scriptfont 2}{##2}%
+ \dosetsubscript{##1}{\scriptscriptfont2}{##2}}%
+ %dodosetsubscript\mathsupnormal {?}%
+ \dodosetsubscript\mathsubnormal {.7}%
+ \dodosetsubscript\mathsubcombined{.7}%
+ \global\loweredsubscriptstrue}
+
+\def\resetsubscripts
+ {\ifloweredsubscripts
+ \def\doresetsubscript##1##2%
+ {\dimen0=\getvalue{@@\string##1\string##2}\relax
+ ##1##2=\dimen0}%
+ \def\dodoresetsubscript##1%
+ {\doresetsubscript{##1}{\textfont2}%
+ \doresetsubscript{##1}{\scriptfont2}%
+ \doresetsubscript{##1}{\scriptscriptfont2}}%
+ %dodoresetsubscript\mathsupnormal
+ \dodoresetsubscript\mathsubnormal
+ \dodoresetsubscript\mathsubcombined
+ \global\loweredsubscriptsfalse
+ \fi}
+
+\ifx\Umathchar\undefined \else
+ % for the moment we nil them, soon we will have a proper
+ % way to deal with this
+ \let\setsubscripts \relax
+ \let\resetsubscripts\relax
+\fi
+
+\def\doresetsubscripts
+ {\resetsubscripts}
+
+\def\sethighsubscripts
+ {\resetsubscripts
+ \let\dosetsubscripts=\relax}
+
+\def\setlowsubscripts
+ {\def\dosetsubscripts{\setsubscripts}}
+
+\setlowsubscripts
+
+\newcount\horchemical % t.z.t. \newcounter
+\newcount\verchemical % t.z.t. \newcounter
+\newcount\txtchemical % t.z.t. \newcounter
+\newcount\levchemical % t.z.t. \newcounter
+
+\newif\ifinchemical \inchemicalfalse
+\newif\iffixedchemical \fixedchemicalfalse
+
+\newbox\chemicalsymbols
+
+% Eigenlijk moeten de constanten en variabelen in cont-nl.tex
+% staan. Dit pakket is echter relatief onafhankelijk van CONTEXT.
+
+\definesystemvariable {chemical}
+
+\definesystemconstant {chemical}
+
+\definesystemconstant {translate}
+\definesystemconstant {distance}
+\definesystemconstant {mirror}
+\definesystemconstant {rotate}
+\definesystemconstant {substitute}
+\definesystemconstant {angle}
+
+\definesystemconstant {executechemical}
+\definesystemconstant {chemicaltextelement}
+\definesystemconstant {chemicallinesegment}
+\definesystemconstant {chemicalcircsegment}
+
+\def\chemicalspace {\quad}
+
+% begin van experiment:
+%
+% De onderstaande twee macro's kunnen worden gebruikt voor
+% bijvoorbeeld een interactiemechanisme.
+%
+% \localgotochemical {verwijzing} {tekst}
+% \localthisischemical {verwijzing}
+
+\def\dowithchemical%
+ {}
+
+\def\localgotochemical#1#2{\gotobox{#2}[#1]}
+\def\localthisischemical#1{\pagereference[#1]}
+
+% eind van experiment
+
+\def\setchemicalmaximum #1
+ {\def\maxchemical{#1}}
+
+\def\doifchemicalnumber#1#2#3%
+ {\doifelsenumber{#1}
+ {\ifnum#1>\maxchemical\relax
+ \writestatus{ppchtex}{number #1 is skipped}%
+ \else
+ #3%
+ \fi}
+ {\unknownchemical{#2}}}%
+
+\newif\ifsmallchemicaltext
+
+\let\@@localchemicalstyle\empty
+
+\unexpanded\def\setupchemicalformat[#1]%
+ {\processaction
+ [\getvalue{#1\c!size}]
+ [ \v!small=>\def\@@localchemicalformat{\scriptscriptstyle},
+ \v!medium=>\def\@@localchemicalformat{\ifsmallchemicaltext\scriptscriptstyle\else\scriptstyle\fi},
+ \v!big=>\def\@@localchemicalformat{\ifsmallchemicaltext\scriptstyle\else\textstyle\fi},
+ \s!unknown=>\def\@@localchemicalformat{\getvalue{#1\c!size}}]%
+ \processaction
+ [\getvalue{#1\c!textsize}]
+ [ \v!small=>\def\@@localchemicalstyle{\scriptscriptstyle},
+ \v!medium=>\def\@@localchemicalstyle{\ifsmallchemicaltext\scriptscriptstyle\else\scriptstyle\fi},
+ \v!big=>\def\@@localchemicalstyle{\ifsmallchemicaltext\scriptstyle\else\textstyle\fi},
+ \s!unknown=>\def\@@localchemicalstyle{\getvalue{#1\c!textsize}}]%
+ \processaction
+ [\getvalue{#1\c!scale}]
+ [ \v!small=>\def\@@localchemicalscale{500},
+ \v!medium=>\def\@@localchemicalscale{625},
+ \v!big=>\def\@@localchemicalscale{750},
+ \s!unknown=>\def\@@localchemicalscale{\getvalue{#1\c!scale}}]}
+
+\def\@@currentchemicalformat
+ {\ifinchemical
+ \@@localchemicalformat
+ \else
+ \@@localchemicalstyle
+ \fi}
+
+\def\dosetupchemical[#1]%
+ {\getparameters[\??chemical\s!chemical][#1]%
+ \doifelse{\@@chemicalchemicaloffset}{LOW}
+ {\setlowsubscripts}
+ {\sethighsubscripts}%
+ \setupchemicalformat[\??chemical\s!chemical]%
+ \ignorespaces}
+
+\unexpanded\def\setupchemical
+ {\dosingleargument\dosetupchemical}
+
+\def\@@dochemicalstyle% % default mapping
+ {\@@chemicalstyle}
+
+\def\@@dochemicalcolor% % no mapping yet
+ {}
+
+\def\@@chemicalstyle % $inner-style$ % (overloaded)
+ {\@@chemicalchemicalstyle} % $$outer-style$$
+
+\def\@@writechemicalstate#1#2%
+ {}
+
+\def\@@beginchemicallocalpicture
+ {\ifcase\chemicaldrawingmode
+ \beginpicture
+ \or
+ \pspicture(0,0)(0,0) % is this permitted ?
+ \or
+ \pushMPdrawing
+ \startMPdrawing
+ %prologues := 1 ;
+ %input mp-tool ;
+ u := 10*\@@chemicalunit;
+ bboxmargin := 0pt ;
+ pickup pencircle scaled 2u ; % ???
+ \stopMPdrawing
+ \beginpicture
+ \fi}
+
+\def\@@endchemicallocalpicture#1#2%
+ {\ifcase\chemicaldrawingmode
+ \endpicture
+ \or
+ \endpspicture
+ \or
+ \resetchemicalcoordinates
+ \setbox2\hbox{\ignoreMPboxdepth\getMPdrawing}%
+ \wd2\zeropoint
+ \ht2\zeropoint
+ \dp2\zeropoint
+ \put {\box2} at 0 0
+ \endpicture
+ \popMPdrawing
+ \fi}
+
+\def\@@beginchemicalpicture#1#2#3#4%
+ {\ifnum\chemicaldrawingmode=1
+ \pspicture(#1,#3)(#2,#4)%
+ \def\account##1##2{}%
+ \psaxes[axesstyle=none,labels=none,ticks=none](#1,#3)(#2,#4)%
+ \else
+ \beginpicture
+ \setplotarea
+ x from {#1} to {#2},
+ y from {#3} to {#4}
+ \iffixedchemical
+ \accountingon
+ \def\account##1##2%
+ {\put {} at {##1} {##2} }%
+ \else
+ \accountingoff
+ \def\account##1##2{}%
+ \fi
+ \fi
+ \ignorespaces}
+
+\def\@@endchemicalpicture%
+ {\ifcase\chemicaldrawingmode
+ \put {\box\chemicalsymbols} at 0 0 % elders
+ \endpicture
+ \or
+ \rput(0,0){\box\chemicalsymbols}%
+ \endpspicture
+ \or
+ \put {\box\chemicalsymbols} at 0 0 % elders
+ \ifMPdrawingdone
+ \resetchemicalcoordinates
+ \setbox2\hbox{\ignoreMPboxdepth\getMPdrawing}%
+ \wd2\zeropoint
+ \ht2\zeropoint
+ \dp2\zeropoint
+ \put {\box2} at 0 0 %
+ \fi
+ \endpicture
+ \fi}
+
+\def\@@setchemicalcoordinatesystem#1%
+ {\edef\@@chemicalunit{#1}%
+ \ifcase\chemicaldrawingmode
+ \setcoordinatesystem units <\@@chemicalunit,\@@chemicalunit> %
+ \or
+ \psset{unit=\@@chemicalunit}%
+ \or
+ \setcoordinatesystem units <\@@chemicalunit,\@@chemicalunit> %
+ \startMPdrawing
+ %input mp-tool ;
+ %prologues := 1 ;
+ u := 10*#1;
+ bboxmargin := 0pt ;
+ pickup pencircle scaled 2u ; % ???
+ \stopMPdrawing
+ \fi}
+
+\ifx\MPdivten\undefined % hack to prevent overflows in mp
+ \def\MPdivten[#1]{\withoutpt\the\dimexpr#1pt/10\relax}
+\fi
+
+\def\@@setchemicalaxis#1#2#3#4%
+ {\ifcase\chemicaldrawingmode
+ \axis
+ bottom shiftedto y=0
+ ticks from {#1} to {#2} by 500 /
+ \axis
+ left shiftedto x=0
+ ticks from {#3} to {#4} by 500 / %
+ \or
+ \psaxes[labels=none,Dx=500,Dy=500](0,0)(#1,#3)(#2,#4)%
+ \or
+ \global\MPdrawingdonetrue
+ % we need to div beforehand because of mp limitations
+ \startMPdrawing
+ x1 := \MPdivten[#1]u ; x2 := \MPdivten[#2]u;
+ y1 := \MPdivten[#3]u ; y2 := \MPdivten[#4]u;
+ draw z1--(x2,y1)--z2--(x1,y2)--cycle ;
+ d := 50u ; dd := 10u ;
+ draw (x1,0)--(x2,0) ;
+ draw (0,y1)--(0,y2) ;
+ for i=d step -d until x1: draw (i,dd)--(i,-dd) ; endfor ;
+ for i=d step d until x2: draw (i,dd)--(i,-dd) ; endfor ;
+ for i=d step -d until y1: draw (-dd,i)--(dd,i) ; endfor ;
+ for i=d step d until y2: draw (-dd,i)--(dd,i) ; endfor ;
+ \stopMPdrawing
+ \fi}
+
+\def\@@setsecondchemicalplotsymbol%
+ {\ifcase\chemicaldrawingmode
+ \!!widtha=50.8mm
+ \divide\!!widtha by \@@chemicalresolution\relax
+ \plotsymbolspacing=\!!widtha
+ \setplotsymbol({\vrule\s!height\!!widtha\s!width\!!widtha})%
+ \fi}
+
+% Something for Dirk:
+
+\newcount \currentchemical
+
+%\newif \ifskipchemical
+
+\def\setchemicaldimensions#1#2#3%
+ {\bgroup
+ \global\advance\currentchemical by 1
+ \dimen0=#1\relax
+ \dimen2=#2\relax
+ \dimen4=#3\relax
+ \setxvalue{chemical::\the\currentchemical}%
+ {\noexpand\docommand{\the\dimen0}{\the\dimen2}{\the\dimen4}}%
+ \egroup}
+
+\ifx\normalchemicalframe\undefined
+ \let\normalchemicalframe\hbox % hook for educational purposes
+\fi
+
+\unexpanded\def\complexstartchemical[#1]%
+ {\copyparameters
+ [\??chemical][\??chemical\s!chemical]
+ [\c!width,\c!height,\c!left,\c!right,\c!top,\c!bottom,
+ \c!bodyfont,\c!size,\c!scale,\c!state,\c!frame,\c!axis,\c!factor,
+ \c!location,\c!option,\c!alternative,\c!resolution,\c!offset,\c!style,
+ \c!color,\c!rulecolor,\c!rulethickness]%
+ \getparameters
+ [\??chemical]
+ [#1]%
+ %
+ \setupchemicalformat[\??chemical]%
+ %
+ \ifnum\chemicaldrawingmode=2
+ \resetMPdrawing
+ \fi
+ %
+ \doif{\@@chemicalalternative}{2}
+ {\@@setsecondchemicalplotsymbol}%
+ %
+ \doif{\@@chemicalaxis}\v!on
+ {\let\chemicalframe\hbox}%
+ %
+ \!!counta=250000
+ \divide\!!counta by \@@localchemicalscale
+ \!!widtha=\@@chemicalbodyfont
+ \divide\!!widtha by \!!counta
+ \@@setchemicalcoordinatesystem{\the\!!widtha}%
+ %
+ % \!!counta = -x \!!countc = -y
+ % \!!countb = +x \!!countd = +y
+ %
+ \def\calculateaxis##1##2##3##4##5%
+ {##1=##3\relax
+ ##2=##4\relax
+ \ifnum##5=0
+ \ifnum##3=0
+ \ifnum##4=0
+ ##1=2000
+ ##2=2000
+ \fi
+ \fi
+ \else
+ \ifnum##3=0
+ \ifnum##4=0
+ ##1=##5\relax
+ \divide##1 by 2
+ ##2=##1\relax
+ \else
+ ##1=##5\relax
+ \advance##1 by -##2\relax
+ \fi
+ \else
+ \ifnum##4=0
+ ##2=##5\relax
+ \advance##2 by -##1\relax
+ \fi
+ \fi
+ \fi}%
+ \fixedchemicalfalse
+ \doif\@@chemicalwidth\v!fit
+ {\edef\@@chemicalwidth
+ {\ifnum\chemicaldrawingmode=1 2000 \else 1 \fi}%
+ \fixedchemicaltrue}%
+ \doif\@@chemicalheight\v!fit
+ {\edef\@@chemicalheight
+ {\ifnum\chemicaldrawingmode=1 2000 \else 1 \fi}%
+ \fixedchemicaltrue}%
+ \doifelse\@@chemicallocation\v!intext
+ {\!!counta=0 \!!countb=0
+ \!!counta=0 \!!countd=0 }
+ {\calculateaxis
+ \!!counta\!!countb
+ \@@chemicalleft\@@chemicalright\@@chemicalwidth
+ \calculateaxis
+ \!!countc\!!countd
+ \@@chemicalbottom\@@chemicaltop\@@chemicalheight}%
+ %
+ \edef\@@chemheight {\the\!!countc}%
+ \edef\@@chemdepth {\the\!!countd}%
+ \edef\@@chemicaltop {\the\!!countc}%
+ \edef\@@chemicalbottom{\the\!!countd}%
+ %
+ \doifelseinset\v!on{\@@chemicalframe,\@@chemicalaxis}
+ {\def\@@chemicalborder{\chemicalframe}}
+ {\def\@@chemicalborder{\normalchemicalframe}}%
+ %
+ \setbox0=\hbox\bgroup % this was a \vbox which took \hsize
+ %
+ \@@beginchemicalpicture
+ {-\the\!!counta}{\the\!!countb}
+ {-\the\!!countc}{\the\!!countd}%
+ \doif{\@@chemicalstate}\v!start
+ {\doif\@@chemicalaxis\v!on
+ {\@@setchemicalaxis
+ {-\the\!!counta}{\the\!!countb}
+ {-\the\!!countc}{\the\!!countd}}}%
+ \doifelse\@@chemicaloption\v!test
+ {\def\@@writechemicalstate##1##2%
+ {\convertargument##2\to\ascii
+ \writestatus{##1}{\ascii}}}
+ {\def\@@writechemicalstate##1##2{}}%
+ \ignorespaces}
+
+\def\dostartchemical%
+ {\catcode`\^=\superscriptcatcode% t.b.v. \enableduplication
+ \catcode`\_=\subscriptcatcode % t.b.v. de zekerheid
+ \begingroup
+ \inchemicaltrue
+ \def\toptext##1{\gdef\thetoptext{##1}\ignorespaces}\toptext{}%
+ \def\bottext##1{\gdef\thebottext{##1}\ignorespaces}\bottext{}%
+ \def\midtext##1{\gdef\themidtext{##1}\ignorespaces}\midtext{}%
+ \def\@@chemicalpostponed{}%
+ \complexorsimpleempty\startchemical}
+
+\unexpanded\def\startchemical
+ {\bgroup % t.b.v. ungrouped floats
+ \dostartchemical}
+
+\unexpanded\def\stopchemical
+ {\checkchemicalpicture
+ \@@endchemicalpicture
+ \egroup
+ \ifnum\chemicaldrawingmode=1
+ \dimen0=\@@chemicalunit
+ \setbox0=\hbox{\lower\@@chemdepth\dimen0\box0}%
+ \ht0=\@@chemheight\dimen0
+ \dp0=\@@chemdepth\dimen0
+ \fi
+ \dimen0=\ht0
+ \advance\dimen0 by \dp0
+ \inchemicalfalse % enables \chemie{} in text
+ \setbox4=\alignedchemical\themidtext
+ \setbox6=\alignedchemical\thetoptext
+ \setbox8=\alignedchemical\thebottext
+ \setbox4=\hbox to \wd0
+ {\strut\hss$\vcenter{\box4}$\hss}%
+ \setbox2=\vbox to \dimen0
+ {\hbox to \wd0{\strut\hss\box6\hss}
+ \vfill
+ \hbox to \wd0{\strut\hss\box8\hss}
+ \vss}% disables the depth
+ \wd0=0pt \wd4=0pt
+ \ht2=\ht0 \dp2=\dp0
+ \ht4=\ht0 \dp4=\dp0
+ \@@chemicalborder{\box0\box4\box2}% text on top of chemicals
+ \endgroup
+ \ignorespaces
+ \egroup} % t.b.v. ungrouped floats
+
+\def\alignedchemical#1%
+ {\vtop
+ {\def\par{\egroup\hbox\bgroup\strut}%
+ \let\\=\par
+ \let\endgraf=\par
+ \hbox\bgroup\strut#1\egroup}}
+
+% \setchemicalcoordinates{#1}{#2}
+%
+% #1: verplaatsing in x-richting
+% #2: verplaatsing in y-richting
+
+\newif\ifchemicaldirection
+
+\def\checkchemicaldirection#1#2%
+ {\ifchemicaldirection
+ \ifnum#1>0 \advance\horchemical -\chemicaldirection \fi
+ \ifnum#1<0 \advance\horchemical +\chemicaldirection \fi
+ \ifnum#2>0 \advance\verchemical -\chemicaldirection \fi
+ \ifnum#2<0 \advance\verchemical +\chemicaldirection \fi
+ \chemicaldirectionfalse
+ \fi}
+
+\def\processchemicaldirection%
+ {\chemicaldirectiontrue\processchemicaltranslate}
+
+\def\setchemicalcoordinates#1#2%
+ {\advance\horchemical #1\relax
+ \advance\verchemical #2\relax
+ \checkchemicaldirection{#1}{#2}%
+ \!!counta=-\horchemical\edef\chemicalxoffset{\the\!!counta}%
+ \!!countb=-\verchemical\edef\chemicalyoffset{\the\!!countb}%
+ \ifnum\chemicaldrawingmode=1
+ % njet
+ \else
+ \setcoordinatesystem point at {\the\horchemical} {\the\verchemical}
+ \fi}
+
+\def\resetchemicalcoordinates
+ {\horchemical=0
+ \verchemical=0
+ \edef\chemicalxoffset{0}%
+ \edef\chemicalyoffset{0}%
+ \ifnum\chemicaldrawingmode=1
+ % njet
+ \else
+ \setcoordinatesystem point at 0 0
+ \fi}
+
+\def\restorechemicalcoordinates
+ {%\writestatus{ppchtex}{restoring \the\horchemical,\the\verchemical}%
+ \edef\chemicalxoffset{\the\horchemical}%
+ \edef\chemicalyoffset{\the\verchemical}%
+ \ifnum\chemicaldrawingmode=1
+ % njet
+ \else
+ \setcoordinatesystem point at {\the\horchemical} {\the\verchemical}
+ \fi}
+
+\def\setchemicaltranslate #1 #2 #3
+ {\setvalue{\s!translate#1}{\setchemicalcoordinates{#2}{#3}}}
+
+\def\processchemicaltranslate#1%
+ {\def\doprocess[##1##2]%
+ {\doifchemicalnumber{##1}{MOV#1}
+ {\ifnum##1=0
+ \def\chemicaloffset{0}% incompatible change
+ \resetchemicalcoordinates
+ \else
+ \getvalue{\s!translate##1}%
+ \dochemicaloffset{##1}%
+ \def\chemicaloffset{0}%
+ \fi}}%
+ \doprocess[#1]}
+
+\def\setchemicaldistance #1
+ {\setvalue{\s!distance1}{\setchemicalcoordinates{-#1}{ 0}}%
+ \setvalue{\s!distance2}{\setchemicalcoordinates{ 0}{ #1}}%
+ \setvalue{\s!distance3}{\setchemicalcoordinates{ #1}{ 0}}%
+ \setvalue{\s!distance4}{\setchemicalcoordinates{ 0}{-#1}}}
+
+\def\setchemicaldirection #1
+ {\def\chemicaldirection{#1}}
+
+\def\processchemicaldistance#1%
+ {\def\doprocess[##1##2]%
+ {\doifchemicalnumber{##1}{ADJ#1}
+ {\ifnum##1=0
+ \resetchemicalcoordinates
+ \else
+ \def\@@chemicalpostponed{\getvalue{\s!distance##1}}%
+ \@@chemicalpostponed
+ \fi}}%
+ \doprocess[#1]}
+
+\def\setchemicalsubstitute #1
+ {\setvalue{\s!substitute1}{\setchemicalcoordinates{-#1}{ 0}}%
+ \setvalue{\s!substitute2}{\setchemicalcoordinates{ 0}{ #1}}%
+ \setvalue{\s!substitute3}{\setchemicalcoordinates{ #1}{ 0}}%
+ \setvalue{\s!substitute4}{\setchemicalcoordinates{ 0}{-#1}}}
+
+\def\processchemicalsubstitute#1%
+ {\def\doprocess[##1##2]%
+ {\doifchemicalnumber{##1}{SUB#1}
+ {\ifnum##1=0
+ \resetchemicalcoordinates
+ \else
+ \def\@@chemicalpostponed{\getvalue{\s!substitute##1}}%
+ \@@chemicalpostponed
+ \fi}}%
+ \doprocess[#1]}
+
+% Het is mogelijk een offset of move meerdere malen uit te
+% voeren, door een nummer voor het commando te plaatsen.
+
+\def\chemicalrepeat {1}
+
+\def\redoprocesschemical[#1#2]%
+ {\doifelseinstring{#1}{0123456789.}
+ {\edef\chemicalrepeat{\chemicalrepeat#1}%
+ \redoprocesschemical[#2]}
+ {\processchemical[#1#2]%
+ \def\chemicalrepeat{1}}}
+
+\def\doprocesschemical[#1#2]#3%
+ {\doifelseinstring{#1}{0123456789.}
+ {\def\chemicalrepeat{#1}%
+ \redoprocesschemical[#2]}
+ {#3}}
+
+% \dochemicaloffset{#1}
+%
+% #1: binding
+
+\def\chemicaloffset{0}
+
+\def\processchemicaloffset#1%
+ {\dimen0=62500 sp % real calc on cardinals, funny number
+ \dimen0=\chemicalrepeat\dimen0
+ \divide\dimen0 by \@@localchemicalscale
+ \!!counta=\dimen0
+ \def\doprocess[##1##2]%
+ {\doifelseinstring{##1}{128}
+ {\edef\chemicaloffset{\the\!!counta}}
+ {\doifelseinstring{##1}{456}
+ {\edef\chemicaloffset{-\the\!!counta}}
+ {\doifelse{##1}{0}
+ {\edef\chemicaloffset{0}}
+ {\unknownchemical{OFF#1}}}}}%
+ \doprocess[#1]}
+
+\def\dochemicaloffset#1%
+ {\ifnum\chemicaloffset=0
+ \def\undochemicaloffset{}%
+ \else
+ \setchemicalcoordinates{-\chemicaloffset}{0}%
+ \def\undochemicaloffset%
+ {\setchemicalcoordinates{\chemicaloffset}{0}%
+ \def\undochemicaloffset{}}%
+ \fi}
+
+\def\processchemicalphantom#1#2%
+ {\setbox0=\hbox
+ {\def\splitoff##1????{##1}%
+ $\@@dochemicalstyle{\@@localchemicalformat\splitoff#2}$}%
+ \dimen0=.25\wd0
+ \divide\dimen0 by \@@localchemicalscale
+ \!!counta=\dimen0
+ \doifelseinstring{#1}{128}
+ {\edef\chemicaloffset{\the\!!counta}}
+ {\doifelseinstring{#1}{456}
+ {\edef\chemicaloffset{-\the\!!counta}}
+ {\doifelse{#1}{0}
+ {\edef\chemicaloffset{0}}
+ {\unknownchemical{OF#1:#2}}}}}
+
+% \dosetchemicalrotation{#1}{#2}
+%
+% #1: cos(phi)
+% #2: sin(phi)
+
+\def\chemicalrotation {1}
+\def\chemicalangle {0}
+\def\chemicalxoffset {0}
+\def\chemicalyoffset {0}
+
+\def\setchemicalmirror#1%
+ {\setvalue{\s!mirror#1}{*}}
+
+\def\resetchemicalmirror#1%
+ {\resetvalue{\s!mirror#1}}
+
+\def\togglechemicalmirror#1%
+ {\doifelse{\getvalue{\s!mirror#1}}{*}
+ {\resetchemicalmirror{#1}}
+ {\setchemicalmirror{#1}}}
+
+\def\setchemicalrotation #1 #2 #3 #4 #5 #6 #7 #8 #9
+ {\setvalue{\s!rotate1.#1}{\dosetchemicalrotation{#2}{#3}}%
+ \setvalue{\s!rotate2.#1}{\dosetchemicalrotation{#4}{#5}}%
+ \setvalue{\s!rotate3.#1}{\dosetchemicalrotation{#6}{#7}}%
+ \setvalue{\s!rotate4.#1}{\dosetchemicalrotation{#8}{#9}}}
+
+\def\setchemicalangle #1 #2 #3 #4 #5
+ {\setvalue{\s!angle1.#1}{\dosetchemicalangle{#2}}%
+ \setvalue{\s!angle2.#1}{\dosetchemicalangle{#3}}%
+ \setvalue{\s!angle3.#1}{\dosetchemicalangle{#4}}%
+ \setvalue{\s!angle4.#1}{\dosetchemicalangle{#5}}}
+
+\def\chemicalrotate[#1]%
+ {\doifelsedefined{\s!mirror#1}
+ {\getvalue{\s!rotate\chemicalrotation.#1\getvalue{\s!mirror#1}}%
+ \getvalue{\s!angle\chemicalrotation.#1\getvalue{\s!mirror#1}}}
+ {\getvalue{\s!rotate\chemicalrotation.#1}%
+ \getvalue{\s!angle\chemicalrotation.#1}}}
+
+\def\dosetchemicalangle#1% zwak zie onder
+ {\def\chemicalangle{#1}}
+
+\def\dosetchemicalrotation#1#2%
+ {\ifnum\chemicaldrawingmode=1
+ % njet
+ \else
+ \startrotation by {#1} {#2} %% \stoprotation (t.b.v. testen)
+ \fi}
+
+\def\doresetchemicalrotation
+ {\ifnum\chemicaldrawingmode=1
+ % njet
+ \else
+ \stoprotation
+ \fi}
+
+\def\processchemicalrotation#1%
+ {\def\doprocess[##1##2]%
+ {\doifelsenumber{##1}
+ {\def\chemicalrotation{##1}}
+ {\unknownchemical{ROT#1}}}%
+ \doprocess[#1]}
+
+% \filtertextelement[#1][#2][#3][#4]
+%
+% #1: volgnummer
+% #2: offset in uitlijningen
+% #3: lijst met uitlijningen -> \chemicalloca
+% #4: lijst met teksten -> \chemicaltext
+
+\def\setchemicallocation#1%
+ {\doifelse{#1}{}
+ {\edef\chemicalloca{c}}
+ {\edef\chemicalloca{#1}}}
+
+\newif\iffixedchemicaltext
+
+\def\filterchemicaltextelement[#1][#2][#3][#4]%
+ {\ifchemicaltextconstant
+ \def\chemicaltext{#4}%
+ \setchemicallocation{}%
+ \else
+ \ifnum#1=0\relax
+ \setchemicallocation{}%
+ \else
+ \iffixedchemicaltext
+ \!!counta#2
+ \else
+ \!!counta=\chemicalrotation
+ \advance\!!counta -1
+ \multiply\!!counta #2
+ \advance\!!counta #1
+ \fi
+ \getfromcommalist[#3][\the\!!counta]%
+ \setchemicallocation\commalistelement
+ \fi
+ \ifchemicalpicture
+ \let\chemicaltext\relax
+ \else
+ \advance\txtchemical 1
+ \getfromcommalist[#4][\txtchemical]%
+ \let\chemicaltext\commalistelement
+ \fi
+ \fi
+ \fixedchemicaltextfalse}
+
+% \putchemicaltext{#1}{#2}
+%
+% #1 : x-coordinaat
+% #2 : y-coordinaat
+%
+% \chemicaltext en \chemicalloca worden met \gettextelement
+% opgehaald uit de tweede set bij \chemie
+%
+% Ten behoeve van testdoeleinden wordt gebruik gemaakt van
+% \chemicalframe in plaats van het meer sjieke, maar tevens
+% meer trage \framed.
+
+\ifx\ruledhbox\undefined
+ \def\chemicalframe#1%
+ {\hbox
+ {\vrule\hskip-.4pt
+ \vbox{\hrule\vskip-.4pt\hbox{#1}\vskip-.4pt\hrule}%
+ \hskip-.4pt\vrule}}
+\else
+ \def\chemicalframe#1%
+ {\ruledhbox{#1}}
+\fi
+
+\def\doputchemicaltext#1 [#2] at #3 #4 %
+ {\ifnum\chemicaldrawingmode=1
+ \rput
+ {-\chemicalangle}(\chemicalxoffset,\chemicalyoffset)%
+ {\expanded{\rput[#2]{\chemicalangle}(#3,#4){#1}}}%
+ \else
+ \put {#1} [#2] at {#3} {#4} %
+ \fi}
+
+\def\dodoifsinglelocation#1#2\\#3%
+ {\ifx#2\relax#3\fi}
+
+\def\doifelsesinglelocation#1%
+ {\expandafter\dodoifsinglelocationelse#1\relax\\}
+
+\let\doifsinglelocationelse\doifelsesinglelocation
+
+\def\putchemicaltext#1#2%
+ {\enablechemicalspecials
+ \ifchemicalpicture
+ \setchemicalpicture{#1}{#2}%
+ \else
+ \doifelse\@@chemicaloption\v!test
+ {\def\@@chemicalframe{\chemicalframe}}
+ {\def\@@chemicalframe{}}%
+ \dosetsubscripts
+ \setbox2=\hbox{\@@dochemicalcolor
+ $\@@dochemicalstyle{\@@localchemicalformat \chemicaltext}$}%
+ \setbox4=\hbox{$\@@dochemicalstyle{\@@localchemicalformat C\normalsubscript2\normapsuperscript2}$}%
+ \setbox6=\hbox{$\@@dochemicalstyle{\@@localchemicalformat O}$}% or C
+ \doresetsubscripts
+ \doifnot\@@chemicallocation\v!intext
+ {\ht2=\ht4
+ \dp2=\dp4}%
+ \setbox2=\hbox{\@@chemicalframe{\box2}}%
+ \ifdim\wd2>\wd6
+ \doifelse{#1}{0}
+ {\doifnot{#2}{0}{\wd2=\wd6}}
+ {%\doifsinglelocation\chemicalloca
+ {\doifinset{\chemicalloca}{t,b}{\wd2=\wd6}}}% common ?
+ \fi
+ \expanded
+ {\doputchemicaltext
+ {\noexpand\dowithchemical{\copy2}} % per se \copy2 i.p.v. \box2
+ [\chemicalloca] at {#1} {#2} }
+ \nomoreaccounting
+ \fi
+ \disablechemicalspecials}
+
+\def\setchemicaltextelement #1 #2 #3
+ {\setvalue{\s!chemicaltextelement#1}{\putchemicaltext{#2}{#3}}}
+
+\def\getchemicalfixedtextelement%
+ {\fixedchemicaltexttrue
+ \getchemicaltextelement}
+
+\def\getchemicaltextelement[#1][#2][#3][#4][#5]%
+ {\filterchemicaltextelement[#2][#3][#4][#5]%
+ \doifelse{#2}{0}
+ {\dochemicaloffset{#2}% % incompatible change
+ \putchemicaltext{0}{0}%
+ \undochemicaloffset} % incompatible change
+ {\chemicalrotate[#2]%
+ \dochemicaloffset{#2}%
+ \def\chemicaltextelementnumber{#2}%
+ \getvalue{\s!chemicaltextelement#1}%
+ \getvalue{\s!chemicaltextelement#11}%
+ \getvalue{\s!chemicaltextelement#12}%
+ \getvalue{\s!chemicaltextelement#13}%
+ \undochemicaloffset}}
+
+\def\processchemicaltextelement#1#2#3#4#5%
+ {\def\doprocess[##1##2##3##4##5]%
+ {\doifelse{##1}{?}
+ {\doprocess[1..\maxchemical ????]}
+ {\doifchemicalnumber{##1}{#1#2}
+ {\doifelse{##2##3}{..}
+ {\doifchemicalnumber{##4}{#1#2}
+ {\getchemicaltextelement[#1][##1][#4][#5][#3]%
+ \doifnot{##1}{##4}
+ {\!!counta=##1\relax
+ \advance\!!counta by 1
+ \edef\nextsegment{\the\!!counta}%
+ \doprocess[\nextsegment..##4##5]}}}
+ {\getchemicaltextelement[#1][##1][#4][#5][#3]%
+ \doifnot{##2}{?}{\doprocess[##2##3##4##5]}}}}}%
+ \doprocess[#2]%
+ \smallchemicaltextfalse}
+
+\def\processchemicalsmalltextelement%
+ {\smallchemicaltexttrue\processchemicaltextelement}
+
+\def\processchemicalsmalltextconstant%
+ {\smallchemicaltexttrue\processchemicaltextconstant}
+
+\def\processchemicalunrotatedtextelement#1#2#3#4#5#6%
+ {\bgroup
+ \xdef\@@xxx{0}%
+ \xdef\@@yyy{0}%
+ \def\putchemicaltext##1##2%
+ {\xdef\@@xxx{##1}%
+ \xdef\@@yyy{##2}}%
+ \getvalue{\s!chemicaltextelement#1}%
+ \egroup
+ \bgroup
+ \def\doputchemicaltext##1 [##2] at ##3 ##4 %
+ {\ifnum\chemicaldrawingmode=1
+ \rput
+ {-\chemicalangle}(\chemicalxoffset,\chemicalyoffset)%
+ {\rput{\chemicalangle}(\@@xxx,\@@yyy){\expanded{\rput[##2](##3,##4){##1}}}}%
+ \else
+ \put
+ {\stoprotation \setcoordinatesystem point at 0 0
+ \expanded{\put {##1} [##2] at {##3} {##4} }}
+ at {\@@xxx} {\@@yyy}
+ \fi}%
+ \processchemicaltextelement{#2}{#3}{#4}{#5}{#6}%
+ \egroup}
+
+\newif\ifchemicaltextconstant
+
+\def\processchemicaltextconstant#1#2#3#4%
+ {\chemicaltextconstanttrue
+ \let\@@oldchemicalframe\@@chemicalframe
+ \let\@@chemicalframe\relax
+ \processchemicaltextelement{#1}{#2}{#3}{#4}{}%
+ \let\@@chemicalframe\@@oldchemicalframe
+ \chemicaltextconstantfalse}
+
+% \plotchemicalline{#1}{#2}{#3}{#4}
+%
+% #1: x-coordinaat beginpunt
+% #2: y-coordinaat beginpunt
+% #3: x-coordinaat eindpunt
+% #4: y-coordinaat eindpunt
+
+\newconstant\chemicallinetype
+
+\def\doplotchemicalline
+ {\!!counte=\!!countc \advance\!!counte by -\!!counta
+ \!!countf=\!!countd \advance\!!countf by -\!!countb
+ \bgroup
+ \ifcase\chemicaldrawingmode
+ \ifcase\chemicallinetype
+ % 0 : normal line
+ \plot {\!!counta} {\!!countb} {\!!countc} {\!!countd} /%
+ \or
+ % 1 : normal arrow
+ \arrow <5pt> [.2,.67] from {\!!counta} {\!!countb} to {\!!countc} {\!!countd}
+ \or
+ % 2 : reverse arrow
+ \arrow <5pt> [.2,.67] from {\!!countc} {\!!countd} to {\!!counta} {\!!countb}
+ \or
+ % 3 : unrotated line
+ \put {\stoprotation \setcoordinatesystem point at 0 0
+ \plot 0 0 {\!!counte} {\!!countf} /}
+ [\chemicallineposition] at {\!!counta} {\!!countb}
+ \else
+ % 4 : dashed line
+ \findlength {\plot {\!!counta} {\!!countb} {\!!countc} {\!!countd} /}%
+ \setdashesnear <2pt> for <\totalarclength>%
+ \plot {\!!counta} {\!!countb} {\!!countc} {\!!countd} /%
+ \fi
+ \or
+ \ifcase\chemicallinetype
+ \rput
+ {-\chemicalangle}(\chemicalxoffset,\chemicalyoffset)%
+ {\psline(\!!counta,\!!countb)(\!!countc,\!!countd)}%
+ \or
+ \rput
+ {-\chemicalangle}(\chemicalxoffset,\chemicalyoffset)%
+ {\psline{->}(\!!counta,\!!countb)(\!!countc,\!!countd)}%
+ \or
+ \rput
+ {-\chemicalangle}(\chemicalxoffset,\chemicalyoffset)%
+ {\psline{<-}(\!!counta,\!!countb)(\!!countc,\!!countd)}%
+ \or
+ \rput
+ {-\chemicalangle}(\chemicalxoffset,\chemicalyoffset)%
+ {\expanded{\rput[\chemicallineposition]{-\chemicalangle}%
+ (\!!counta,\!!countb){\psline(0,0)(\!!counte,\!!countf)}}}%
+ \else
+ \psset{linestyle=dashed}%
+ \rput
+ {-\chemicalangle}(\chemicalxoffset,\chemicalyoffset)%
+ {\psline(\!!counta,\!!countb)(\!!countc,\!!countd)}%
+ \fi
+ \or
+ \global\MPdrawingdonetrue
+ \setchemicalattributes
+ \startMPdrawing
+ x0 := \MPdivten[\chemicalxoffset]u ;
+ y0 := \MPdivten[\chemicalyoffset]u ;
+ x1 := \MPdivten[\the\!!counta]u ;
+ y1 := \MPdivten[\the\!!countb]u ;
+ x2 := \MPdivten[\the\!!countc]u ;
+ y2 := \MPdivten[\the\!!countd]u ;
+ x3 := \MPdivten[\the\!!counte]u ;
+ y3 := \MPdivten[\the\!!countf]u ;
+ \ifcase\chemicallinetype
+ % 0 : normal line
+ draw ((z1--z2) rotatedaround(origin,-\chemicalangle))
+ shifted z0 ;
+ \or
+ % 1 : normal arrow
+ drawarrow ((z1--z2) rotatedaround(origin,-\chemicalangle))
+ shifted z0 ;
+ \or
+ % 2 : reverse arrow
+ drawarrow ((z2--z1) rotatedaround(origin,-\chemicalangle))
+ shifted z0 ;
+ \or
+ % 3 : unrotated line % nog \chemicalineposition: t/b
+ draw (origin--z3)
+ shifted (z1 rotatedaround(origin,-\chemicalangle))
+ shifted z0 ;
+ \else
+ % 4 : dashed line
+ draw ((z1--z2) rotatedaround(origin,-\chemicalangle))
+ shifted z0 dashed dashpattern(on 5.5u off 6u) ;
+ \fi
+ \stopMPdrawing
+ \fi
+ \egroup
+ \account\!!counta\!!countb
+ \account\!!countc\!!countd}
+
+\def\plotchemicalline#1#2#3#4%
+ {\!!counta=#1\!!countb=#2\!!countc=#3\!!countd=#4\relax
+ \doplotchemicalline}
+
+\def\plotchemicalfactorline#1#2#3#4%
+ {\!!counta=#1\!!countb=#2\!!countc=#3\!!countd=#4\relax
+ \ifdim\@@chemicalfactor\onepoint=\onepoint \else
+ \scratchdimen\!!counta\s!sp \multiply\scratchdimen1000 \scratchdimen\@@chemicalfactor\scratchdimen \divide\scratchdimen1000 \!!counta\scratchdimen
+ \scratchdimen\!!countc\s!sp \multiply\scratchdimen1000 \scratchdimen\@@chemicalfactor\scratchdimen \divide\scratchdimen1000 \!!countc\scratchdimen
+ \fi
+ \doplotchemicalline}
+
+\def\plotchemicalzline#1#2#3#4%
+ {\!!counta=#1\!!countb=#2\!!countc=#3\!!countd=#4\relax
+ \ifnum\chemicaldrawingmode=2
+ \global\MPdrawingdonetrue
+ \setchemicalattributes
+ \startMPdrawing
+ x0 := \MPdivten[\chemicalxoffset]u ;
+ y0 := \MPdivten[\chemicalyoffset]u ;
+ x1 := \MPdivten[\the\!!counta]u ;
+ y1 := \MPdivten[\the\!!countb]u ;
+ x2 := \MPdivten[\the\!!countc]u ;
+ y2 := \MPdivten[\the\!!countd]u ;
+ filldraw ((
+ \ifnum\chemicalangle>180
+ z1--z2
+ \else\ifnum\chemicalangle<90
+ z1--(z2 shifted (-2u,+2u))--(z2 shifted (+2u,-2u))
+ \else\ifnum\chemicalangle=90
+ (z1 shifted (-2u,+2u))--(z1 shifted (+2u,-2u))--
+ (z2 shifted (+2u,+2u))--(z2 shifted (-2u,-2u))
+ \else
+ (z1 shifted (+2u,+2u))--(z1 shifted (-2u,-2u))--z2
+ \fi\fi\fi
+ --cycle) rotatedaround(origin,-\chemicalangle)) shifted z0 ;
+ \stopMPdrawing
+ \else
+ \doplotchemicalline
+ \ifnum\chemicalangle>180 \else
+ \ifnum\chemicalangle=90
+ \advance\!!counta by -20 \advance\!!countc by -20
+ \doplotchemicalline
+ \advance\!!counta by 40 \advance\!!countc by 40
+ \else\ifnum\chemicalangle<90
+ \advance\!!countc by -20 \advance\!!countd by +20
+ \doplotchemicalline
+ \advance\!!countc by +40 \advance\!!countd by -40
+ \else
+ \advance\!!counta by 20 \advance\!!countb by 20
+ \doplotchemicalline
+ \advance\!!counta by -40 \advance\!!countb by -40
+ \fi\fi
+ \fi
+ \doplotchemicalline
+ \fi}
+
+\def\plotchemicaldeltaline#1#2#3#4%
+ {\!!counta=#1\!!countb=#2\!!countc=#3\!!countd=#4\relax
+ \ifnum\chemicaldrawingmode=2
+ \global\MPdrawingdonetrue
+ \setchemicalattributes
+ \startMPdrawing
+ x0 := \MPdivten[\chemicalxoffset]u ;
+ y0 := \MPdivten[\chemicalyoffset]u ;
+ x1 := \MPdivten[\the\!!counta]u ;
+ y1 := \MPdivten[\the\!!countb]u ;
+ x2 := \MPdivten[\the\!!countc]u ;
+ y2 := \MPdivten[\the\!!countd]u ;
+ filldraw ((z1--(z2 rotatedaround(z1,5))--(z2 rotatedaround(z1,-5))
+ --cycle) rotatedaround(origin,-\chemicalangle))
+ shifted z0 ;
+ \stopMPdrawing
+ \account{#1}{#2}%
+ \account{#3}{#4}%
+ \else
+ \doplotchemicalline
+ \advance\!!countc by 16 \advance\!!countd by -21
+ \doplotchemicalline
+ \advance\!!countc by -4 \advance\!!countd by 7
+ \doplotchemicalline
+ \advance\!!countc by -4 \advance\!!countd by 7
+ \doplotchemicalline
+ \advance\!!countc by -8 \advance\!!countd by 14
+ \doplotchemicalline
+ \advance\!!countc by -4 \advance\!!countd by 7
+ \doplotchemicalline
+ \advance\!!countc by -4 \advance\!!countd by 7
+ \doplotchemicalline
+ \advance\!!countc by -4 \advance\!!countd by 7
+ \doplotchemicalline
+ \fi}
+
+\def\setchemicallinesegment #1 #2 #3 #4 #5
+ {\setvalue{\s!chemicallinesegment#1}{\plotchemicalline{#2}{#3}{#4}{#5}}}
+
+\def\setchemicalfactorlinesegment #1 #2 #3 #4 #5
+ {\setvalue{\s!chemicallinesegment#1}{\plotchemicalfactorline{#2}{#3}{#4}{#5}}}
+
+\def\getchemicallinesegment[#1][#2]%
+ {\chemicalrotate[#1]%
+ \dochemicaloffset{#1}%
+ \getvalue{\s!chemicallinesegment#2}%
+ \getvalue{\s!chemicallinesegment#21}%
+ \getvalue{\s!chemicallinesegment#22}%
+ \undochemicaloffset}
+
+\def\getprivatechemicallinesegment[#1][#2]%
+ {\chemicalrotate[#1]%
+ \getvalue{\s!chemicallinesegment#2#1}}
+
+\def\doprocesschemicallinesegment#1#2#3#4#5%
+ {\chemicallinetype#1\relax
+ \def\chemicallineposition{#2}%
+ \def\doprocess[##1##2##3##4##5]%
+ {\doifelse{##1}{?}
+ {\doprocess[1..\maxchemical ????]}
+ {\doifchemicalnumber{##1}{#4#5}
+ {\doifelse{##2##3}{..}
+ {\doifchemicalnumber{##4}{#4#5}
+ {#3[##1][#4]%
+ \doifnot{##1}{##4}
+ {\!!counta=##1\relax
+ \advance\!!counta by 1
+ \edef\nextsegment{\the\!!counta}%
+ \doprocess[\nextsegment..##4##5]}}}
+ {#3[##1][#4]%
+ \doifnot{##2}{?}
+ {\doprocess[##2##3##4##5]}}}}}%
+ \doprocess[#5]}
+
+\def\processchemicallinesegment
+ {\doprocesschemicallinesegment0c\getchemicallinesegment}
+
+\def\processchemicalzlinesegment#1#2%
+ {%\doprocesschemicallinesegment0c\getchemicallinesegment{#1}{#2}%
+ \bgroup
+ \def\plotchemicalline{\plotchemicalzline}%
+ \doprocesschemicallinesegment0c\getchemicallinesegment{#1}{#2}%
+ \egroup}
+
+\def\processchemicaldeltalinesegment#1#2%
+ {%\doprocesschemicallinesegment0c\getchemicallinesegment{#1}{#2}%
+ \bgroup
+ \def\plotchemicalline{\plotchemicaldeltaline}%
+ \doprocesschemicallinesegment0c\getchemicallinesegment{#1}{#2}%
+ \egroup}
+
+\def\processprivatechemicallinesegment%
+ {\doprocesschemicallinesegment0c\getprivatechemicallinesegment}
+
+\def\processchemicaldownarrowsegment%
+ {\doprocesschemicallinesegment1c\getchemicallinesegment}
+
+\def\processchemicaluparrowsegment%
+ {\doprocesschemicallinesegment2c\getchemicallinesegment}
+
+\def\processchemicalunrotatedlinesegment#1%
+ {\doprocesschemicallinesegment3{#1}\getchemicallinesegment}
+
+\def\processchemicaldashedlinesegment
+ {\doprocesschemicallinesegment4c\getchemicallinesegment}
+
+\def\plotchemicaldasheddeltaline#1#2#3#4%
+ {\!!counta=#1\!!countb=#2\!!countc=#3\!!countd=#4\relax
+ \ifnum\chemicaldrawingmode=2
+ \global\MPdrawingdonetrue
+ \setchemicalattributes
+ \startMPdrawing
+ x0 := \MPdivten[\chemicalxoffset]u ;
+ y0 := \MPdivten[\chemicalyoffset]u ;
+ x1 := \MPdivten[\the\!!counta]u ;
+ y1 := \MPdivten[\the\!!countb]u ;
+ x2 := \MPdivten[\the\!!countc]u ;
+ y2 := \MPdivten[\the\!!countd]u ;
+ z20 = z2 rotatedaround(z1,+5) ;
+ z21 = z2 rotatedaround(z1,-5) ;
+ draw (z1 rotatedaround(origin,-\chemicalangle)) shifted z0 ;
+ save n ; n := 5 ;
+ for i=1 upto n :
+ draw ((((z20--z21) shifted -z2) shifted (i/n)[z2,z1])
+ rotatedaround(origin,-\chemicalangle)) shifted z0 ;
+ endfor
+ \stopMPdrawing
+ \account{#1}{#2}%
+ \account{#3}{#4}%
+ \else
+ \doplotchemicalline
+ \advance\!!countc by 16 \advance\!!countd by -21
+ \doplotchemicalline
+ \advance\!!countc by -4 \advance\!!countd by 7
+ \doplotchemicalline
+ \advance\!!countc by -4 \advance\!!countd by 7
+ \doplotchemicalline
+ \advance\!!countc by -8 \advance\!!countd by 14
+ \doplotchemicalline
+ \advance\!!countc by -4 \advance\!!countd by 7
+ \doplotchemicalline
+ \advance\!!countc by -4 \advance\!!countd by 7
+ \doplotchemicalline
+ \advance\!!countc by -4 \advance\!!countd by 7
+ \doplotchemicalline
+ \fi}
+
+\def\plotchemicalwavyline#1#2#3#4%
+ {\!!counta=#1\!!countb=#2\!!countc=#3\!!countd=#4\relax
+ \ifnum\chemicaldrawingmode=2
+ \global\MPdrawingdonetrue
+ \setchemicalattributes
+ \startMPdrawing
+ x0 := \MPdivten[\chemicalxoffset]u ;
+ y0 := \MPdivten[\chemicalyoffset]u ;
+ x1 := \MPdivten[\the\!!counta]u ;
+ y1 := \MPdivten[\the\!!countb]u ;
+ x2 := \MPdivten[\the\!!countc]u ;
+ y2 := \MPdivten[\the\!!countd]u ;
+ save d ; pair d ;
+ d := z2 rotatedaround(z1,+5) shifted -z2 ;
+ save n ; n := 4 ;
+ draw ((for i=0 upto n-1 :
+ ((i)/n)[z1,z2] ..
+ ((i+.25)/n)[z1,z2] shifted d ..
+ ((i+.50)/n)[z1,z2] ..
+ ((i+.75)/n)[z1,z2] shifted -d ..
+ endfor
+ z2) rotatedaround(origin,-\chemicalangle)) shifted z0 ;
+ \stopMPdrawing
+ \account{#1}{#2}%
+ \account{#3}{#4}%
+ \else
+ \doplotchemicalline
+ \advance\!!countc by 16 \advance\!!countd by -21
+ \doplotchemicalline
+ \advance\!!countc by -4 \advance\!!countd by 7
+ \doplotchemicalline
+ \advance\!!countc by -4 \advance\!!countd by 7
+ \doplotchemicalline
+ \advance\!!countc by -8 \advance\!!countd by 14
+ \doplotchemicalline
+ \advance\!!countc by -4 \advance\!!countd by 7
+ \doplotchemicalline
+ \advance\!!countc by -4 \advance\!!countd by 7
+ \doplotchemicalline
+ \advance\!!countc by -4 \advance\!!countd by 7
+ \doplotchemicalline
+ \fi}
+
+\def\processchemicaldasheddeltalinesegment#1#2%
+ {\bgroup
+ \def\plotchemicalline{\plotchemicaldasheddeltaline}%
+ \doprocesschemicallinesegment0c\getchemicallinesegment{#1}{#2}%
+ \egroup}
+
+\def\processchemicalwavylinesegment#1#2%
+ {\bgroup
+ \def\plotchemicalline{\plotchemicalwavyline}%
+ \doprocesschemicallinesegment0c\getchemicallinesegment{#1}{#2}%
+ \egroup}
+
+\def\processchemicalopenend#1#2%
+ {\doprocesschemicallinesegment0c\doprocesschemicalopenend{#1}{#2}}
+
+\def\doprocesschemicalopenend[#1][#2]%
+ {\chemicalrotate[#1]%
+ \dochemicaloffset{#1}%
+ \ifcase\chemicaldrawingmode
+ \beginpicture
+ \setquadratic\plot
+ 300 0 400 0
+ 500 0 550 75
+ 600 0 650 -75
+ 700 0 750 75
+ 800 0 850 -75
+ 900 0 950 0
+ 1050 0 /
+ \endpicture
+ \or
+ \rput{-\chemicalangle}(\chemicalxoffset,\chemicalyoffset)%
+ {\psline(300,0)(500,0)%
+ \rput(500,0){\psplot[yunit=75,plotstyle=curve]{0}{720}{x sin}}%
+ \psline(950,0)(1050,0)}%
+ \or
+ \global\MPdrawingdonetrue
+ \setchemicalattributes
+ \startMPdrawing
+ x0 := \MPdivten[\chemicalxoffset]u ;
+ y0 := \MPdivten[\chemicalyoffset]u ;
+ draw
+ (((30.0u,0)--(50.0u,0){up}..(55.0u,7.5u)..
+ (60.0u,0)..(65.0u,-7.5u)..(70.0u,0)..
+ (75.0u,7.5u)..(80.0u,0)..(85.0u,-7.5u)..{up}
+ (90.0u,0)--(105.0u,0)) rotatedaround(origin,-\chemicalangle))
+ shifted z0 ;
+ \stopMPdrawing
+ \fi
+ \undochemicaloffset}
+
+% \plotchemicalcircle{#1}{#2}{#3}{#4}
+%
+% #1: lengte van de boog in graden
+% #2: x-coordinaat eindpunt
+% #3: y-coordinaat eindpunt
+
+\newif\ifchemicaldotted
+
+\def\plotchemicalcircle#1#2#3#4#5#6%
+ {\bgroup
+ \ifcase\chemicaldrawingmode
+ \ifchemicaldotted
+ \findlength{\circulararc {#4} degrees from {#5} {#6} center at {0} {0} }%
+ \divide\totalarclength by 6
+ \def\b{\the\totalarclength}%
+ \divide\totalarclength by 2
+ \def\a{\the\totalarclength}%
+ \setdashpattern <\a,\b,\b,\b,\b,\b,\a>
+ \fi
+ \circulararc {#4} degrees from {#5} {#6} center at {0} {0} %
+ \or
+ \ifchemicaldotted
+ \psset{linestyle=dashed}%
+ \fi
+ \rput
+ {-\chemicalangle}(\chemicalxoffset,\chemicalyoffset)%
+ {\psarc(0,0){#3}{#1}{#2}}%
+ \or
+ \global\MPdrawingdonetrue
+ \setchemicalattributes
+ \startMPdrawing
+ r := \MPdivten[#3]*2u;
+ x0 := \MPdivten[\chemicalxoffset]u ;
+ y0 := \MPdivten[\chemicalyoffset]u ;
+ draw ((subpath (#1/45,#2/45) of (fullcircle scaled (r)))
+ rotatedaround (origin,\chemicalangle+150))
+ shifted z0 \ifchemicaldotted dashed withdots \fi ;
+ \stopMPdrawing
+ \fi
+ \egroup}
+
+\def\setchemicalcircsegment #1 #2 #3 #4 #5 #6 #7
+ {\setvalue{\s!chemicalcircsegment#1}{\plotchemicalcircle{#2}{#3}{#4}{#5}{#6}{#7}}}
+
+\def\getchemicalcircsegment[#1][#2]%
+ {\chemicalrotate[#1]%
+ \getvalue{\s!chemicalcircsegment#2}}
+
+\def\doprocesschemicalcircsegment#1#2%
+ {\def\doprocess[##1##2##3##4##5]%
+ {\doifelse{##1}{?}
+ {\doprocess[1..\maxchemical ????]}
+ {\doifchemicalnumber{##1}{#1#2}
+ {\doifelse{##2##3}{..}
+ {\doifchemicalnumber{##4}{#1#2}
+ {\getchemicalcircsegment[##1][#1]%
+ \doifnot{##1}{##4}
+ {\!!counta=##1\relax
+ \advance\!!counta by 1
+ \edef\nextsegment{\the\!!counta}%
+ \doprocess[\nextsegment..##4##5]}}}
+ {\getchemicalcircsegment[##1][#1]%
+ \doifnot{##2}{?}
+ {\doprocess[##2##3##4##5]}}}}}%
+ \doprocess[#2]}
+
+\def\processchemicalcircsegment%
+ {\chemicaldottedfalse\doprocesschemicalcircsegment}
+
+\def\processchemicaldottsegment%
+ {\chemicaldottedtrue\doprocesschemicalcircsegment}
+
+\let\endchemicalpicture = \relax
+\let\checkchemicalpicture = \relax
+\let\nomoreaccounting = \relax
+
+\newif\ifchemicalpicture
+
+\def\beginchemicalpicture#1% NO PSTRICKS SUPPORT YET
+ {\checkchemicalpicture
+ \bgroup % DOES NOT HANDLE AUTOWIDTH/HEIGHT
+ \chemicalpicturetrue
+ \processchemical[#1]}
+
+\def\setchemicalpicture#1#2%
+ {\chemicalpicturefalse
+ \def\endchemicalpicture%
+ {\@@endchemicallocalpicture{#1}{#2}%
+ \egroup
+ \ifnum\chemicaldrawingmode=1
+ \rput
+ {-\chemicalangle}(\chemicalxoffset,\chemicalyoffset)%
+ {\expanded{\rput[\chemicalloca]{\chemicalangle}(#1,#2){\box\nextbox}}}%
+ \else
+ \expanded{\put{\box\nextbox}[\chemicalloca] at {#1} {#2} }
+ \fi
+ \egroup}%
+ \def\checkchemicalpicture%
+ {\ifx\endchemicalpicture\relax \else
+ \writestatus{ppchtex}{missing end of picture (PE)}%
+ \endchemicalpicture
+ \fi}%
+ \setbox\nextbox=\hbox\bgroup
+ \@@beginchemicallocalpicture
+ % alternatief: gewoon accounting, en zelf l,r afhandelen
+ \ifnum\chemicaldrawingmode=1
+ % njet
+ \else
+ \accountingon
+ \let\nomoreaccounting=\accountingoff
+ \fi}
+
+\def\doskipchemical[#1][#2]%
+ {{\tt[ppchtex]}}
+
+\def\skipchemical%
+ {\dodoubleargument\doskipchemical}
+
+\def\complexchemical% met \expandafter
+ {\ifinchemical
+ \expandafter\dochemical
+ \else
+ \writestatus{ppchtex}{the [][]-alternative is not permitted here}%
+ \expandafter\skipchemical
+ \fi}
+
+\newif\ifinnerchemical
+
+\def\dosimplechemical#1#2#3%
+ {\doifelsedefined{\??chemical\c!location}
+ {\writestatus{ppchtex}{the {}{}-alternative is not permitted here}}
+ {\ifinnerchemical
+ \let\chemicalsign = \chemicalinnersign
+ \let\chemicalmolecule = \chemicalinnermolecule
+ \let\chemicalsinglearrow = \chemicalsingleinnerarrow
+ \let\chemicaldoublearrow = \chemicaldoubleinnerarrow
+ \let\chemicaltwintiparrow = \chemicaltwintipinnerarrow
+ \else
+ \let\chemicalsign = \chemicaloutersign
+ \let\chemicalmolecule = \chemicaloutermolecule
+ \let\chemicalsinglearrow = \chemicalsingleouterarrow
+ \let\chemicaldoublearrow = \chemicaldoubleouterarrow
+ \let\chemicaltwintiparrow = \chemicaltwintipouterarrow
+ \fi
+ \disablechemicalspecials
+ \processallactionsinset
+ [#1]
+ [ HIGH=>\sethighsubscripts,
+ LOW=>\setlowsubscripts,
+ PLUS=>\chemicalsign{+},
+ GIVES=>\chemicalsinglearrow{#2}{#3},
+ EQUILIBRIUM=>\chemicaldoublearrow{#2}{#3},
+ MESOMERIC=>\chemicaltwintiparrow{#2}{#3},
+ SINGLE=>\singlechemicalbond,
+ DOUBLE=>\doublechemicalbond,
+ TRIPLE=>\triplechemicalbond,
+ +=>\chemicalsign{+},
+ ->=>\chemicalsinglearrow{#2}{#3},
+ <->=>\chemicaldoublearrow{#2}{#3},
+ <>=>\chemicaltwintiparrow{#2}{#3},
+ -=>\singlechemicalbond,
+ --=>\doublechemicalbond,
+ ---=>\triplechemicalbond,
+ \s!unknown=>\enablechemicalspecials
+ \chemicalmolecule{\commalistelement}{#2}{#3}]}}
+
+\def\dosimplechemicalA#1#2#3% % evt: {#1,\relax}
+ {\let\chemicalspace=\relax
+ \@EA\dosimplechemical\@EA{\@@chemicalchemicaloffset,#1}{#2}{#3}%
+ \egroup}
+
+\def\dosimplechemicalB#1#2#3%
+ {\dosimplechemical{#1}{#2}{#3}%
+ \egroup}
+
+\def\dosimplechemicalC#1#2#3%
+ {$\simplechemical{#1}{#2}{#3}$%
+ \egroup} % erbij
+
+\def\simplechemical
+ {\ifinner
+ \innerchemicaltrue
+ \else
+ \innerchemicalfalse
+ \fi
+ \bgroup
+ \catcode`\^=\superscriptcatcode % t.b.v. \enableduplication
+ \catcode`\_=\subscriptcatcode % t.b.v. de zekerheid
+ \ifmmode
+ \ifinnerchemical
+ \def\next{\dotriplegroupempty\dosimplechemicalA}%
+ \else
+ \def\next{\dotriplegroupempty\dosimplechemicalB}%
+ \fi
+ \else
+ \def\next{\dotriplegroupempty\dosimplechemicalC}%
+ \fi
+ \next}
+
+\definecomplexorsimple\chemical
+
+\def\dogotochemical#1#2%
+ {\def\dowithchemical% % experiment
+ {\localgotochemical{#1}}% % experiment
+ \chemical} % experiment
+
+\def\gotochemical% % experiment
+ {\dosingleargument\dogotochemical} % experiment
+
+\def\dododochemical#1[#2][#3]% % experiment
+ {\def\simpledododochemical% % experiment
+ {#1[#2][#3]}% % experiment
+ \def\complexdododochemical[##1]% % experiment
+ {\def\dowithchemical% % experiment
+ {\localthisischemical{#2}}% % experiment
+ #1[#3][##1]}% % experiment
+ \complexorsimple\dododochemical} % experiment
+
+\def\dodochemical[#1][#2]%
+ {\ignorespaces
+ \ifinchemical
+ \drawchemical[#1][#2]%
+ \ignorespaces
+ \else
+ \startchemical[\c!location=\v!intext]%
+ \drawchemical[#1][#2]%
+ \expandafter\stopchemical
+ \fi
+ \ignorespaces}
+
+\def\dochemical[#1]%
+ {\def\simpledochemical%
+ {\@@writechemicalstate{ppchtex}{[#1][]}%
+ \dodochemical[#1][]}%
+ %
+ \def\complexdochemical[##1]%
+ {\@@writechemicalstate{ppchtex}{[#1][##1]}%
+ \txtchemical=0%
+ \dodochemical[#1][##1]}%
+ %
+ \def\complexdochemical[##1]% % experiment
+ {\@@writechemicalstate{ppchtex}{[#1][##1]}% % experiment
+ \txtchemical=0% % experiment
+ \dododochemical\dodochemical[#1][##1]}% % experiment
+ %
+ \complexorsimple\dochemical}
+
+% \processlocalchemicals{#1}
+%
+% #1: commando's
+
+\def\dodoprocesschemical#1%
+ {\processchemical[#1????]}
+
+\def\processlocalchemicals#1%
+ {\processcommalist[#1]\dodoprocesschemical}
+
+% \drawchemical[#1][#2]
+%
+% #1: bindingen enz.
+% #2: atomen enz.
+
+\def\localdodochemical[#1][#2]%
+ {\@@writechemicalstate{ppchtex}{[#1][#2]}%
+ %\bgroup % koppelen en afmetingen gaat fout, vandaar:
+ \advance\levchemical 1
+ \letvalue{\??chemical\s!unknown\the\levchemical}\unknownchemical
+ \setevalue{\??chemical\c!text\the\levchemical}{\the\txtchemical}%
+ \txtchemical=0
+ \dodochemical[#1][#2]%
+ % \@EA\txtchemical\@EA\csname\??chemical\c!text\the\levchemical\endcsname
+ \txtchemical\csname\??chemical\c!text\the\levchemical\endcsname
+ \@EA\let\@EA\unknownchemical\csname\??chemical\s!unknown\the\levchemical\endcsname
+ \advance\levchemical -1
+ %\egroup
+ \ignorespaces}
+
+\def\drawchemical[#1][#2]%
+ {\ignorespaces
+ \def\dodochemical[##1][##2]%
+ {\drawchemical[##1][##2]%
+ \ignorespaces}%
+ \def\dochemical[##1]%
+ {\def\simpledochemical%
+ {\@@writechemicalstate{ppchtex}{[##1][#2]}%
+ \dodochemical[##1][#2]%
+ \ignorespaces}%
+ \def\complexdochemical[####1]%
+ {\dododochemical\localdodochemical[##1][####1,#2]}%
+ \complexorsimple\dochemical}%
+ \doif\@@chemicalstate\v!start
+ {\doifelse\chemicalname\s!unknown
+ {\getvalue{\s!executechemical\defaultchemical}[#2]}
+ {\getvalue{\s!executechemical\chemicalname}[#2]}%
+ \def\unknownchemical##1%
+ {\processunknownchemical[##1][#2]}%
+ \processcommalist[\@@chemicaloffset,#1]\dodoprocesschemical}%
+ \ignorespaces}
+
+\unexpanded\def\chemicaloxidation#1#2#3%
+ {\chemicaltop
+ {\ifnum#20=0
+ 0%
+ \else
+ #1\expandafter\uppercase\expandafter{\romannumeral#2}%
+ \fi}
+ {#3}}
+
+\def\chemicaltfraction{\ifinchemical.60\else.8\fi}
+\def\chemicalbfraction{\ifinchemical.45\else.6\fi}
+\def\chemicallfraction{\ifinchemical.1\else.1\fi}
+\def\chemicalrfraction{\ifinchemical.1\else.1\fi}
+
+\def\chemicaltighttext
+ {\def\chemicaltfraction{\ifinchemical.3\else.6\fi}%
+ \def\chemicalbfraction{\ifinchemical.2\else.4\fi}%
+ \def\chemicallfraction{\ifinchemical 0\else 0\fi}%
+ \def\chemicalrfraction{\ifinchemical 0\else 0\fi}}
+
+\def\dochemicaltop#1#2#3#4%
+ {\vbox
+ {\@@dochemicalcolor
+ \baselineskip=\chemicaltfraction\baselineskip \lineskip0pt
+ \halign
+ {#1###2\cr
+ $\@@dochemicalstyle{\scriptscriptstyle#3}$\cr
+ $\@@dochemicalstyle{\@@currentchemicalformat#4}$\cr}}}
+
+\def\dochemicalbottom#1#2#3#4%
+ {\vtop
+ {\@@dochemicalcolor
+ \baselineskip=\chemicalbfraction\baselineskip \lineskip0pt
+ \halign
+ {#1###2\cr
+ $\@@dochemicalstyle{\@@currentchemicalformat#4}$\cr
+ $\@@dochemicalstyle{\scriptscriptstyle#3}$\cr}}}
+
+\def\chemicalleft#1#2%
+ {\hbox
+ {\@@dochemicalcolor
+ $\@@dochemicalstyle{\scriptscriptstyle#1}$%
+ $\@@dochemicalstyle{\@@currentchemicalformat\hskip\chemicallfraction em#2}$}}
+
+\def\chemicalright#1#2%
+ {\hbox
+ {\@@dochemicalcolor
+ $\@@dochemicalstyle{\@@currentchemicalformat#2\hskip\chemicalrfraction em}$%
+ $\@@dochemicalstyle{\scriptscriptstyle#1}$}}
+
+\def\chemicalcentered#1%
+ {\setbox0=\hbox{$\@@dochemicalstyle{\scriptscriptstyle#1}$}%
+ \setbox2=\hbox{$\@@dochemicalstyle{\@@currentchemicalformat C}$}%
+ \dimen0=.5\ht2
+ \advance\dimen0 by -.5\ht0
+ \advance\dimen0 by \dp0
+ \hbox{\@@dochemicalcolor\raise\dimen0\box0}}
+
+\def\chemicalleftcentered#1#2%
+ {\hbox
+ {\@@dochemicalcolor
+ \chemicalcentered{#1}%
+ $\@@dochemicalstyle{\@@currentchemicalformat\hskip\chemicallfraction em#2}$}}
+
+\def\chemicalrightcentered#1#2%
+ {\hbox
+ {\@@dochemicalcolor
+ $\@@dochemicalstyle{\@@currentchemicalformat#2\hskip\chemicalrfraction em}$%
+ \chemicalcentered{#1}}}
+
+\def\chemicaltop {\dochemicaltop \hss \hss }
+\def\chemicallefttop {\dochemicaltop \relax \hss }
+\def\chemicalrighttop {\dochemicaltop \hss \relax}
+\def\chemicalbottom {\dochemicalbottom \hss \hss }
+\def\chemicalleftbottom {\dochemicalbottom \relax \hss }
+\def\chemicalrightbottom {\dochemicalbottom \hss \relax}
+
+\def\chemicaltopleft #1{\chemicalleft {\chemicallefttop {#1}{}}}
+\def\chemicalbottomleft #1{\chemicalleft {\chemicalleftbottom{#1}{}}}
+\def\chemicaltopright #1{\chemicalright{\chemicallefttop {#1}{}}}
+\def\chemicalbottomright#1{\chemicalright{\chemicalleftbottom{#1}{}}}
+
+\def\chemicalsmashedleft#1%
+ {\hbox\bgroup
+ \@@dochemicalcolor
+ \setbox0=\hbox{$\@@dochemicalstyle{\@@currentchemicalformat C}$}%
+ \setbox2=\hbox{$\@@dochemicalstyle{\@@currentchemicalformat#1}$}%
+ \wd2=\wd0
+ \box2
+ \egroup}
+
+\def\chemicalsmashedmiddle#1%
+ {\hbox\bgroup
+ \@@dochemicalcolor
+ \setbox0=\hbox{$\@@dochemicalstyle{\@@currentchemicalformat C}$}%
+ \setbox2=\hbox{$\@@dochemicalstyle{\@@currentchemicalformat#1}$}%
+ \hbox{\hskip-.5\wd2\hskip.5\wd0\box2}
+ \egroup}
+
+\def\chemicalsmashedright#1%
+ {\hbox\bgroup
+ \@@dochemicalcolor
+ \setbox0=\hbox{$\@@dochemicalstyle{\@@currentchemicalformat C}$}%
+ \setbox2=\hbox{$\@@dochemicalstyle{\@@currentchemicalformat#1}$}%
+ \hbox to \wd0{\hskip-\wd2\hskip\wd0\box2}%
+ \egroup}
+
+\def\+{\tabalign} % is \long in Plain
+
+\def\chemicalforever#1#2%
+ {\bgroup
+ \setbox0=\hbox
+ {\@@dochemicalcolor
+ $\@@dochemicalstyle{\scriptscriptstyle\hskip-.15em#2}$}%
+ \wd0=0pt
+ \big#1\normapsubscript{\hskip.1em\box0}%
+ \egroup}
+
+\def\disablechemicalspecials%
+ {\def\+##1{##1}\def\-##1{##1}%
+ \def\[{[}\def\]{]}%
+ \def\1{}\def\2{}\def\3{}\def\4{}\def\5{}\def\6{}\def\7{}%
+ \def\X{}%
+ \def\T{}\def\B{}\def\L{}\def\R{}\def\LC{}\def\RC{}%
+ \def\TL{}\def\BL{}\def\TR{}\def\BR{}%
+ \def\LT{}\def\LB{}\def\RT{}\def\RB{}%
+ \def\SL{}\def\SM{}\def\SR{}}
+
+\def\enablechemicalspecials%
+ {\def\+{\dodoublegroupempty\chemicaloxidation{+}}% {} needed!
+ \def\-{\dodoublegroupempty\chemicaloxidation{-}}% {} needed!
+ \def\[{\dodoublegroupempty\chemicalforever {[}}% {} needed!
+ \def\]{\dodoublegroupempty\chemicalforever {]}}% {} needed!
+ \def\1{\chemicaloxidation\relax1}%
+ \def\2{\chemicaloxidation\relax2}%
+ \def\3{\chemicaloxidation\relax3}%
+ \def\4{\chemicaloxidation\relax4}%
+ \def\5{\chemicaloxidation\relax5}%
+ \def\6{\chemicaloxidation\relax6}%
+ \def\7{\chemicaloxidation\relax7}%
+ \def\X{\chemicaltighttext}%
+ \def\T{\chemicaltop}%
+ \def\B{\chemicalbottom}%
+ \def\L{\chemicalleft}%
+ \def\LC{\chemicalleftcentered}%
+ \def\R{\chemicalright}%
+ \def\RC{\chemicalrightcentered}%
+ \def\TL{\chemicaltopleft}%
+ \def\BL{\chemicalbottomleft}%
+ \def\TR{\chemicaltopright}%
+ \def\BR{\chemicalbottomright}%
+ \def\LT{\chemicallefttop}%
+ \def\LB{\chemicalleftbottom}%
+ \def\RT{\chemicalrighttop}%
+ \def\RB{\chemicalrightbottom}%
+ \def\SL{\chemicalsmashedleft}%
+ \def\SM{\chemicalsmashedmiddle}%
+ \def\SR{\chemicalsmashedright}}
+
+% \reversechemical#1#2#3
+%
+% #1: prefix
+% #2: volgnummer enz
+% #3: tegengestelde volgnummers
+
+\def\reversechemical#1#2#3%
+ {\def\doprocess[##1##2]%
+ {\doifchemicalnumber{##1}{#1#2}%
+ {\getfromcommalist[#3][##1]%
+ \let\reversechemicalaction=\commalistelement
+ \processchemical[#1\reversechemicalaction##2]}}%
+ \doprocess[#2]}
+
+% \processunknownchemical[#1????][#2]
+%
+% #1: bindingen enz.
+% #2: atomen enz.
+
+\def\defaultchemical%
+ {SIX}
+
+\def\processunknownchemical[#1????][#2]%
+ {\processaction
+ [#1]
+ [ SAVE=>\executechemicalSAVE,
+ RESTORE=>\executechemicalRESTORE,
+ HIGH=>\sethighsubscripts,
+ LOW=>\setlowsubscripts,
+ \s!default=>,
+ \s!unknown=>\doifelsedefined{\s!executechemical#1}
+ {\def\chemicalrotation{1}%
+ \def\chemicaloffset{0}%
+ \doifdefined{\s!executechemical#1}
+ {\getvalue{\s!executechemical#1}[#2]}%
+ \@@chemicalpostponed}
+ {\getpredefinedchemical{#1}}]}
+
+\newcount\chemicalstack
+
+\setvalue{\s!chemical\c!x1}{0}
+\setvalue{\s!chemical\c!y1}{0}
+
+\def\executechemicalSAVE
+ {%\writestatus{ppchtex}{saving \the\horchemical,\the\verchemical}%
+ \advance\chemicalstack by 1
+ \letvalue {\s!chemical n\the\chemicalstack}=\chemicalname
+ %\letvalue {\s!chemical p\the\chemicalstack}=\@@chemicalpostponed
+ \setevalue{\s!chemical x\the\chemicalstack}{\the\horchemical}%
+ \setevalue{\s!chemical y\the\chemicalstack}{\the\verchemical}}
+
+\def\restorechemicalvalues#1%
+ {\let\oldprocesschemical=\processchemical
+ \doifdefined{\s!executechemical#1}{\getvalue{\s!executechemical#1}[]}%
+ \let\processchemical=\oldprocesschemical}
+
+\def\executechemicalRESTORE
+ {\ifnum\chemicalstack=0\relax
+ \horchemical=\getvalue{\s!chemical x1}\relax
+ \verchemical=\getvalue{\s!chemical y1}\relax
+ \else
+ \restorechemicalvalues{\getvalue{\s!chemical n\the\chemicalstack}}%
+ %\@EA\let\@EA\@@chemicalpostponed\@EA=\csname\s!chemical p\the\chemicalstack\endcsname
+ \let\@@chemicalpostponed=\relax
+ \horchemical=\getvalue{\s!chemical x\the\chemicalstack}\relax
+ \verchemical=\getvalue{\s!chemical y\the\chemicalstack}\relax
+ \advance\chemicalstack by -1
+ \fi
+ \restorechemicalcoordinates}
+
+% De onderstaande macro's zijn verantwoordelijk voor het zetten
+% van de + en pijlen. De +, en dus ook de pijlen, worden omhoog
+% gehaald. Dit oogt m.i. fraaier.
+
+\def\chemicalinnerclip#1%
+ {{\setbox0=\hbox{#1}\ht0\ht\strutbox\dp0\dp\strutbox\box0}}
+
+\def\chemicalraise#1#2%
+ {\chemicalinnerclip
+ {\setbox0=\hbox{$#1+$}%
+ \raise\dp0\hbox{$#1#2$}}}
+
+\def\chemicalinnersign#1% todo: \@@chemicaltextcolor
+ {\chemicalraise{\@@localchemicalstyle}{#1}}
+
+\def\chemicaloutersign#1%
+ {\chemicalraise{}{\@@dochemicalcolor#1}}
+
+\def\chemicalsingleinnerarrow#1#2%
+ {\chemicalraise{\@@localchemicalstyle}{\longrightarrow}}
+
+\def\chemicaldoubleinnerarrow#1#2% todo: \@@chemicaltextcolor
+ {\chemicalinnerclip
+ {\lower.2ex\hbox
+ {\setbox0=\hbox{$\@@localchemicalstyle\longrightarrow$}%
+ \setbox2=\hbox{$\@@localchemicalstyle\longleftarrow$}%
+ \wd0=0pt\raise\ht0\box0\box2}}}
+
+\def\chemicaltwintipinnerarrow#1#2% todo: \@@chemicaltextcolor
+ {\chemicalinnerclip
+ {\setbox0=\hbox{\chemicalraise{\@@localchemicalstyle}{\longrightarrow}}%
+ \setbox2=\hbox{\chemicalraise{\@@localchemicalstyle}{\longleftarrow}}%
+ \wd0=0pt\box0\box2}}
+
+\def\dochemicalouterarrow#1#2#3%
+ {\bgroup
+ \setbox0=\hbox{$\longrightarrow$}%
+ \setbox2=\hbox{$\@@dochemicalstyle{\scriptstyle\quad#2\quad}$}%
+ \setbox4=\hbox{$\@@dochemicalstyle{\scriptstyle\quad#3\quad}$}%
+ \dimen2=\wd0 % \dimen0 is used elsewhere
+ \ifdim\wd2>\dimen2 \dimen0=\wd2 \fi
+ \ifdim\wd4>\dimen2 \dimen0=\wd4 \fi
+ \chemicaloutermolecule
+ {#1}
+ {\ifdim\ht2>\zeropoint\box2\fi} % expands to \empty in test
+ {\ifdim\ht4>\zeropoint\box4\fi}% % expands to \empty in test
+ \egroup}
+
+\def\chemicalsingleouterarrow
+ {\dochemicalouterarrow
+ {\hbox to \dimen2{\rightarrowfill}}}
+
+\def\chemicaldoubleouterarrow
+ {\dochemicalouterarrow
+ {\lower.5\ht0\vbox
+ {\offinterlineskip
+ \hbox to \dimen2{\rightarrowfill}
+ \hbox to \dimen2{\leftarrowfill}}}}
+
+\def\chemicaltwintipouterarrow
+ {\dochemicalouterarrow
+ {\hbox
+ {\hbox to \dimen2{\rightarrowfill}%
+ \hskip-\dimen2
+ \hbox to \dimen2{\leftarrowfill}}}}
+
+\def\chemicalinnermolecule#1#2#3% no mathop here, can generate space
+ {\chemicalspace % todo: \@@chemicaltextcolor
+ \chemicalinnerclip
+ {\dosetsubscripts
+ $\@@dochemicalstyle{\@@localchemicalstyle\strut#1}$%
+ \doresetsubscripts}%
+ \chemicalspace}
+
+\def\chemicaloutermolecule#1#2#3%
+ {\chemicalspace
+ \bgroup
+ \@@dochemicalcolor
+ \setbox0=\hbox % else the font is reset
+ {\dosetsubscripts
+ \hbox{$\@@dochemicalstyle{\strut#1}$}%
+ \doresetsubscripts}%
+ \mathop{\box0}%
+ \ifthirdargument
+ \doifnot{#2}{}{\normapsuperscript{\@@dochemicalstyle{\strut#2}}}%
+ \doifnot{#3}{}{\normapsubscript {\@@dochemicalstyle{\strut#3}}}%
+ \else
+ \doifnot{#2}{}
+ {\normapsubscript{\@@dochemicalstyle{\strut#2}}}%
+ \fi
+ \egroup
+ \chemicalspace}
+
+\def\chemicalsinglepicturearrow#1%
+ {\lower.5ex\hbox
+ {\@@dochemicalstyle
+ $\chemicalspace
+ \buildrel
+ \@@dochemicalstyle{\scriptstyle\quad#1\quad}%
+ \over{\overrightarrow
+ {\hphantom{\@chemicalstyle{\scriptstyle\quad#1\quad}}}}%
+ \chemicalspace$}}
+
+\def\chemicaldoublepicturearrow#1%
+ {\lower.5ex\hbox
+ {\@@dochemicalstyle
+ $\chemicalspace
+ \buildrel
+ \@@dochemicalstyle{\scriptstyle\quad#1\quad}%
+ \over{\overrightarrow{\overleftarrow
+ {\hphantom{\@@dochemicalstyle{\scriptstyle\quad#1\quad}}}}}%
+ \chemicalspace$}}
+
+% Bij de in-line bindingen wordt gebruik gemaakt van
+% een \hrule. De maatvoering wordt bepaald door een
+% kunstmatige em (\wd0).
+
+\def\somechemicalbond%
+ {\hrule width \wd0 height .4pt}
+
+\def\dochemicalbonds#1#2#3% todo: \@@chemicaltextstyle
+ {{\setbox0=\hbox
+ {${\@@localchemicalstyle M}$}%
+ \vbox to \ht0
+ {\@@dochemicalcolor
+ \hsize\wd0
+ \vskip.1\wd0#1\vfill#2\vfill#3\vskip.1\wd0}}}
+
+\def\singlechemicalbond%
+ {\dochemicalbonds{}{\somechemicalbond}{}}
+
+\def\doublechemicalbond%
+ {\dochemicalbonds{\somechemicalbond}{}{\somechemicalbond}}
+
+\def\triplechemicalbond%
+ {\dochemicalbonds{\somechemicalbond}{\somechemicalbond}{\somechemicalbond}}
+
+% In plaats van \def\naam{\chemie[...]...} kan beter gebruik
+% worden gemaakt van het commando
+%
+% \definieerchemie[naam]{commando's}
+%
+% De naam krijgt, om problemen met bestaande macro's te
+% voorkomen, een prefix. Bij het ophalen van een commando
+% worden beide definities afgehandeld.
+
+\def\dodefinechemical[#1]#2%
+ {\doifdefined{\??chemical#1}
+ {\writestatus{ppchtex}{chemical definition #1 is redefined}}%
+ \setvalue{\??chemical#1}{#2}}
+
+\unexpanded\def\definechemical%
+ {\dosingleargument\dodefinechemical}
+
+\def\getpredefinedchemical#1%
+ {\doifelsedefined{\??chemical#1}
+ {\getvalue{\??chemical#1}}
+ {\doifelsedefined{#1}
+ {\getvalue{#1}}
+ {\writestatus{ppchtex}{unknown chemical definition #1}}}}
+
+% Hieronder zijn de definities van de structuren opgenomen. De
+% naam van de structuur is als volgt opgebouwd:
+%
+% \executechemicalNUMBER[#1]
+%
+% waarbij [#1] betrekking heeft op de tekstelementen van \chemie,
+% de [tweede lijst] dus.
+%
+% De aan \chemie[#1][#2] meegegeven lijst van segmenten wordt
+% deels door de in \execute gedefinieerde macro's afgehandeld,
+% deels door algemene macro's. Segmenten hebben de vorm:
+%
+% [+|-|]identifier[X|XYZ|X..Y]
+%
+% Voorbeelden van segmenten zijn:
+%
+% R1
+% R1..4
+% R135
+% -R1
+% +R35
+
+\setchemicalmaximum 0
+
+\def\processchemical[#1]%
+ {\unknownchemical{#1}}
+
+\def\setchemicalname#1 %
+ {\def\chemicalname{#1}}
+
+\let\chemicalname=\s!unknown
+
+% Vooruitlopend op een gedetailleerde documentatie, zijn hier
+% vast enkele gebruikte afmetingen:
+%
+% lengte radikalen : 500
+% afstand radikalen : 100
+% afstand dubbele radikalen : 260
+% afstand substituenten : +125
+
+
+
+
+\def\executechemicalONE[#1]%
+ {\setchemicalname ONE
+ %
+ \setchemicalmaximum 8
+ \setchemicaldistance 0
+ \setchemicalsubstitute 625
+ \setchemicaldirection 303
+ %
+ \setchemicalrotation 1 1 0 1 0 1 0 1 0
+ \setchemicalrotation 2 0.707 -0.707 0.707 -0.707 0.707 -0.707 0.707 -0.707
+ \setchemicalrotation 3 0 -1 0 -1 0 -1 0 -1
+ \setchemicalrotation 4 -0.707 -0.707 -0.707 -0.707 -0.707 -0.707 -0.707 -0.707
+ \setchemicalrotation 5 -1 0 -1 0 -1 0 -1 0
+ \setchemicalrotation 6 -0.707 0.707 -0.707 0.707 -0.707 0.707 -0.707 0.707
+ \setchemicalrotation 7 0 1 0 1 0 1 0 1
+ \setchemicalrotation 8 0.707 0.707 0.707 0.707 0.707 0.707 0.707 0.707
+ %
+ \setchemicalangle 1 0 90 180 270
+ \setchemicalangle 2 45 135 225 315
+ \setchemicalangle 3 90 180 270 0
+ \setchemicalangle 4 135 225 315 45
+ \setchemicalangle 5 180 270 0 90
+ \setchemicalangle 6 225 315 45 135
+ \setchemicalangle 7 270 0 90 180
+ \setchemicalangle 8 315 45 135 225
+ %
+ \setchemicaltranslate 1 -1000 0
+ \setchemicaltranslate 2 -1000 1000
+ \setchemicaltranslate 3 0 1000
+ \setchemicaltranslate 4 1000 1000
+ \setchemicaltranslate 5 1000 0
+ \setchemicaltranslate 6 1000 -1000
+ \setchemicaltranslate 7 0 -1000
+ \setchemicaltranslate 8 -1000 -1000
+ %
+ \setchemicallinesegment SB 300 0 700 0
+ \setchemicallinesegment DB1 300 50 700 50
+ \setchemicallinesegment DB2 300 -50 700 -50
+ %
+ %setchemicallinesegment EP 200 125 200 -125
+ \setchemicalfactorlinesegment EP 200 125 200 -125
+ %
+ \setchemicaltextelement ES 200 0
+ \setchemicaltextelement ED1 200 50
+ \setchemicaltextelement ED2 200 -50
+ \setchemicaltextelement ET1 200 75
+ \setchemicaltextelement ET2 200 0
+ \setchemicaltextelement ET3 200 -75
+ \setchemicaltextelement HB1 300 0
+ \setchemicaltextelement HB2 475 0
+ \setchemicaltextelement HB3 650 0
+ %
+ \setchemicaltextelement Z 800 0
+ \setchemicaltextelement RZ 950 0
+ \setchemicaltextelement ZN 500 0
+ \setchemicaltextelement ZTN 500 150
+ \setchemicaltextelement ZBN 500 -150
+ %
+ \def\processchemical[##1##2##3##4##5]%
+ {\doprocesschemical[##1##2##3##4##5]
+ {\processaction
+ [##1##2##3##4##5]
+ [ PB:##4##5=>\beginchemicalpicture{##4##5},
+ PE????=>\endchemicalpicture,
+ SUB##4##5=>\processchemicalsubstitute{##4##5},
+ ADJ##4##5=>\processchemicaldistance{##4##5},
+ MOV##4##5=>\processchemicaltranslate{##4##5},
+ DIR##4##5=>\processchemicaldirection{##4##5},
+ OFF##4##5=>\processchemicaloffset{##4##5},
+ CCD##4##5=>\processchemicaldottsegment{CC}{##4##5},
+ LDD##4##5=>\processchemicaldashedlinesegment{DB1}{##4##5}%
+ \processchemicallinesegment{DB2}{##4##5},
+ RDD##4##5=>\processchemicallinesegment{DB1}{##4##5}%
+ \processchemicaldashedlinesegment{DB2}{##4##5},
+ OF##3:##5=>\processchemicalphantom{##3}{##5},
+ OE##3##4##5=>\processchemicalopenend{OE}{##3##4##5},
+ EP##3##4##5=>\processchemicallinesegment{EP}{##3##4##5},
+ ES##3##4##5=>\processchemicaltextconstant{ES}{##3##4##5}{\hbox{$\cdot$}}{0},
+ ED##3##4##5=>\processchemicaltextconstant{ED}{##3##4##5}{\hbox{$\cdot$}}{0},
+ ET##3##4##5=>\processchemicaltextconstant{ET}{##3##4##5}{\hbox{$\cdot$}}{0},
+ HB##3##4##5=>\processchemicaltextconstant{HB}{##3##4##5}{\hbox{$\cdot$}}{0},
+ SB##3##4##5=>\processchemicallinesegment{SB}{##3##4##5},
+ DB##3##4##5=>\processchemicallinesegment{DB}{##3##4##5},
+ SB##3##4##5=>\processchemicallinesegment{SB}{##3##4##5},
+ BB##3##4##5=>\processchemicaldeltalinesegment{SB}{##3##4##5},
+ BD##3##4##5=>\processchemicaldasheddeltalinesegment{SB}{##3##4##5},
+ BW##3##4##5=>\processchemicalwavylinesegment{SB}{##3##4##5},
+ SD##3##4##5=>\processchemicaldashedlinesegment{SB}{##3##4##5},
+ TB##3##4##5=>\processchemicallinesegment{SB}{##3##4##5}%
+ \processchemicallinesegment{DB}{##3##4##5},
+ CZ##3##4##5=>\processchemicaltextelement{RZ}{##3##4##5}{#1}{0}{},
+ ZTN##4##5=>\processchemicalsmalltextconstant{ZTN}{##4##5}{\chemicaltextelementnumber}{0},
+ ZTT##4##5=>\processchemicalsmalltextelement{ZTN}{##4##5}{#1}{0}{},
+ ZBN##4##5=>\processchemicalsmalltextconstant{ZBN}{##4##5}{\chemicaltextelementnumber}{0},
+ ZBT##4##5=>\processchemicalsmalltextelement{ZBN}{##4##5}{#1}{0}{},
+ ZN##3##4##5=>\processchemicaltextconstant{ZN}{##3##4##5}{\chemicaltextelementnumber}{0},
+ ZT##3##4##5=>\processchemicaltextelement{ZN}{##3##4##5}{#1}{0}{},
+ Z##2##3##4##5=>\processchemicaltextelement{Z}{##2##3##4##5}{#1}{0}
+ {l,l,t,r,r,r,b,l},
+ \s!unknown=>\unknownchemical{##1##2##3##4##5}]}}}
+
+\def\executechemicalTHREE[#1]%
+ {\setchemicalname THREE
+ %
+ \setchemicalmaximum 3
+ \setchemicaldistance 289
+ \setchemicalsubstitute 952
+ %
+ \setchemicalrotation 1 1 0 0 -1 -1 0 0 1
+ \setchemicalrotation 2 -0.5 -0.866 -0.866 0.5 0.5 0.866 0.866 -0.5
+ \setchemicalrotation 3 -0.5 0.866 0.866 0.5 0.5 -0.866 -0.866 -0.5
+ %
+ \setchemicalangle 1 0 90 180 270
+ \setchemicalangle 2 120 210 300 30
+ \setchemicalangle 3 240 330 60 150
+ %
+ \setchemicaltranslate 1 -1000 0
+ \setchemicaltranslate 2 0 1000
+ \setchemicaltranslate 3 1000 0
+ \setchemicaltranslate 4 0 -1000
+ %
+ \setchemicallinesegment B 577 0 -289 -500
+ \setchemicallinesegment SB 352 -130 -64 -370
+ \setchemicallinesegment -SB 352 -130 -289 -500
+ \setchemicallinesegment +SB 577 0 -64 -370
+ \setchemicallinesegment DB1 327 -87 -89 -327
+ \setchemicallinesegment DB2 377 -172 -39 -413
+ \setchemicallinesegment R 577 0 1077 0
+ \setchemicallinesegment -R 577 0 1010 250
+ \setchemicallinesegment +R 577 0 1010 -250
+ \setchemicallinesegment ER1 577 50 1077 50
+ \setchemicallinesegment ER2 577 -50 1077 -50
+ \setchemicallinesegment SR 837 0 1077 0
+ \setchemicallinesegment -SR 802 130 1010 250
+ \setchemicallinesegment +SR 802 -130 1010 -250
+ \setchemicallinesegment DR1 837 50 1077 50
+ \setchemicallinesegment DR2 837 -50 1077 -50
+ %
+ \setchemicaltextelement Z 577 0
+ \setchemicaltextelement RZ 1177 0
+ \setchemicaltextelement -RZ 1097 300
+ \setchemicaltextelement +RZ 1097 -300
+ \setchemicaltextelement CRZ 1077 0
+ %
+ \def\processchemical[##1##2##3##4]%
+ {\processaction
+ [##1##2##3##4]
+ [ ROT##4=>\processchemicalrotation{##4},
+ MOV##4=>\processchemicaltranslate{##4},
+ SUB##4=>\processchemicalsubstitute{##4},
+ ADJ##4=>\processchemicaldistance{##4},
+ -RZ##4=>\processchemicaltextelement{-RZ}{##4}{#1}{3}
+ {l,t,r, l,r,l, r,b,l, r,l,r},
+ +RZ##4=>\processchemicaltextelement{+RZ}{##4}{#1}{3}
+ {l,r,b, r,r,l, r,l,t, l,l,r},
+ -SB##4=>\processchemicallinesegment{-SB}{##4},
+ +SB##4=>\processchemicallinesegment{+SB}{##4},
+ -SR##4=>\processchemicallinesegment{-SR}{##4},
+ +SR##4=>\processchemicallinesegment{+SR}{##4},
+ CRZ##4=>\processchemicaltextelement{CRZ}{##4}{#1}{0}
+ {},
+ DB##3##4=>\processchemicallinesegment{DB}{##3##4},
+ DR##3##4=>\processchemicallinesegment{DR}{##3##4},
+ RZ##3##4=>\processchemicaltextelement{RZ}{##3##4}{#1}{3}
+ {l,r,r, t,r,l, r,l,l, b,l,r},
+ ER##3##4=>\processchemicallinesegment{ER}{##3##4},
+ SB##3##4=>\processchemicallinesegment{SB}{##3##4},
+ SR##3##4=>\processchemicallinesegment{SR}{##3##4},
+ -R##3##4=>\processchemicallinesegment{-R}{##3##4},
+ +R##3##4=>\processchemicallinesegment{+R}{##3##4},
+ B##2##3##4=>\processchemicallinesegment{B}{##2##3##4},
+ R##2##3##4=>\processchemicallinesegment{R}{##2##3##4},
+ Z##2##3##4=>\processchemicaltextelement{Z}{##2##3##4}{#1}{0}{},
+ \s!unknown=>\unknownchemical{##1##2##3##4}]}}
+
+\def\executechemicalFOUR[#1]%
+ {\setchemicalname FOUR
+ %
+ \setchemicalmaximum 4
+ \setchemicaldistance 500
+ \setchemicalsubstitute 0
+ %
+ \setchemicalrotation 1 1 0 0 -1 -1 0 0 1
+ \setchemicalrotation 2 0 -1 -1 0 0 1 1 0
+ \setchemicalrotation 3 -1 0 0 1 1 0 0 -1
+ \setchemicalrotation 4 0 1 1 0 0 -1 -1 0
+ %
+ \setchemicalangle 1 0 90 180 270
+ \setchemicalangle 2 90 180 270 0
+ \setchemicalangle 3 180 270 0 90
+ \setchemicalangle 4 270 0 90 180
+ %
+ \setchemicaltranslate 1 -1000 0
+ \setchemicaltranslate 2 0 1000
+ \setchemicaltranslate 3 1000 0
+ \setchemicaltranslate 4 0 -1000
+ %
+ \setchemicallinesegment B 500 500 500 -500
+ \setchemicallinesegment SB 500 240 500 -240
+ \setchemicallinesegment -SB 500 240 500 -500
+ \setchemicallinesegment +SB 500 500 500 -240
+ \setchemicallinesegment DB1 450 240 450 -240
+ \setchemicallinesegment DB2 550 240 550 -240
+ \setchemicallinesegment EB 360 300 360 -300
+ \setchemicallinesegment R 500 500 854 854
+ \setchemicallinesegment -R 500 500 500 1000
+ \setchemicallinesegment +R 500 500 1000 500
+ \setchemicallinesegment ER1 465 535 819 889
+ \setchemicallinesegment ER2 535 465 889 819
+ \setchemicallinesegment SR 684 684 854 854
+ \setchemicallinesegment -SR 500 760 500 1000
+ \setchemicallinesegment +SR 760 500 1000 500
+ \setchemicallinesegment DR1 649 719 819 889
+ \setchemicallinesegment DR2 719 649 889 819
+ %
+ \setchemicaltextelement Z 500 500
+ \setchemicaltextelement RZ 925 925
+ \setchemicaltextelement -RZ 500 1100
+ \setchemicaltextelement +RZ 1100 500
+ \setchemicaltextelement CRZ 1038 1038
+ %
+ \setchemicaltextelement ZN 350 350
+ %
+ \def\processchemical[##1##2##3##4]%
+ {\processaction
+ [##1##2##3##4]
+ [ PB:##4=>\beginchemicalpicture{##4},
+ PE????=>\endchemicalpicture,
+ ROT##4=>\processchemicalrotation{##4},
+ SUB##4=>\processchemicalsubstitute{##4},
+ ADJ##4=>\processchemicaldistance{##4},
+ MOV##4=>\processchemicaltranslate{##4},
+ -RZ##4=>\processchemicaltextelement{-RZ}{##4}{#1}{4}
+ {b,l,t,r, l,t,r,b, t,r,b,l, r,b,l,t},
+ +RZ##4=>\processchemicaltextelement{+RZ}{##4}{#1}{4}
+ {l,t,r,b, t,r,b,l, r,b,l,t, b,l,t,r},
+ -SB##4=>\processchemicallinesegment{-SB}{##4},
+ +SB##4=>\processchemicallinesegment{+SB}{##4},
+ -SR##4=>\processchemicallinesegment{-SR}{##4},
+ +SR##4=>\processchemicallinesegment{+SR}{##4},
+ CRZ##4=>\processchemicaltextelement{CRZ}{##4}{#1}{0}{},
+ ZN##3##4=>\processchemicaltextconstant{ZN}{##3##4}{\chemicaltextelementnumber}{0},
+ ZT##3##4=>\processchemicaltextelement{ZN}{##3##4}{#1}{0}{},
+ DB##3##4=>\processchemicallinesegment{DB}{##3##4},
+ DR##3##4=>\processchemicallinesegment{DR}{##3##4},
+ EB##3##4=>\processchemicallinesegment{EB}{##3##4},
+ ER##3##4=>\processchemicallinesegment{ER}{##3##4},
+ RZ##3##4=>\processchemicaltextelement{RZ}{##3##4}{#1}{4}
+ {lb,lt,rt,rb, lt,rt,rb,lb, rt,rb,lb,lt, rb,lb,lt,rt},
+ SB##3##4=>\processchemicallinesegment{SB}{##3##4},
+ SR##3##4=>\processchemicallinesegment{SR}{##3##4},
+ -R##3##4=>\processchemicallinesegment{-R}{##3##4},
+ +R##3##4=>\processchemicallinesegment{+R}{##3##4},
+ B##2##3##4=>\processchemicallinesegment{B}{##2##3##4},
+ R##2##3##4=>\processchemicallinesegment{R}{##2##3##4},
+ Z##2##3##4=>\processchemicaltextelement{Z}{##2##3##4}{#1}{0}{},
+ \s!unknown=>\unknownchemical{##1##2##3##4}]}}
+
+\def\executechemicalFIVE[#1]%
+ {\setchemicalname FIVE
+ %
+ \setchemicalmaximum 5
+ \setchemicaldistance 688
+ \setchemicalsubstitute 1226
+ %
+ \setchemicalrotation 1 1 0 0 -1 -1 0 0 1
+ \setchemicalrotation 2 0.309 -0.951 -0.951 -0.309 -0.309 0.940 0.951 0.309
+ \setchemicalrotation 3 -0.809 -0.588 -0.588 0.809 0.809 0.588 0.588 -0.809
+ \setchemicalrotation 4 -0.809 0.588 0.588 0.809 0.809 -0.588 -0.588 -0.809
+ \setchemicalrotation 5 0.309 0.951 0.951 -0.309 -0.309 -0.951 -0.951 0.309
+ %
+ \setchemicalangle 1 0 90 180 270
+ \setchemicalangle 2 72 162 252 342
+ \setchemicalangle 3 144 234 324 54
+ \setchemicalangle 4 216 306 36 126
+ \setchemicalangle 5 288 18 108 198
+ %
+ \setchemicaltranslate 1 -1376 0
+ \setchemicaltranslate 2 -425 1304
+ \setchemicaltranslate 3 1113 809
+ \setchemicaltranslate 4 1113 -809
+ \setchemicaltranslate 5 -425 -1304
+ %
+ \setchemicallinesegment A 1188 500 1188 -500
+ \setchemicallinesegment B 688 500 688 -500
+ \setchemicallinesegment S -263 808 688 -500
+ \setchemicallinesegment SS -116 606 541 -298
+ \setchemicallinesegment -SS -263 808 541 -298
+ \setchemicallinesegment +SS -116 606 688 -500
+ \setchemicallinesegment SB 688 240 688 -240
+ \setchemicallinesegment -SB 688 240 688 -500
+ \setchemicallinesegment +SB 688 500 688 -240
+ \setchemicallinesegment DB1 638 240 638 -240
+ \setchemicallinesegment DB2 738 240 738 -240
+ \setchemicallinesegment EB 548 340 548 -340
+ \setchemicallinesegment R 688 500 1093 794
+ \setchemicallinesegment -R 688 500 688 1000
+ \setchemicallinesegment +R 688 500 1163 345
+ \setchemicallinesegment ER1 659 540 1064 834
+ \setchemicallinesegment ER2 727 460 1122 754
+ \setchemicallinesegment SR 898 653 1093 794
+ \setchemicallinesegment -SR 688 760 688 1000
+ \setchemicallinesegment +SR 935 420 1163 345
+ \setchemicallinesegment DR1 869 693 1064 834
+ \setchemicallinesegment DR2 927 613 1122 754
+ %
+ \setchemicaltextelement Z 688 500
+ \setchemicaltextelement RZ 1188 863
+ \setchemicaltextelement -RZ 688 1100
+ \setchemicaltextelement +RZ 1258 315
+ \setchemicaltextelement CRZ 1323 947
+ %
+ \setchemicalcircsegment C -36 36 590 72 475 -345
+ \setchemicalcircsegment CC -72 0 590 72 182 -561
+ %
+ \setchemicaltextelement ZN 468 350
+ \setchemicaltextelement RN 860 625 % 1.25 Z
+ \setchemicaltextelement RTN 785 728 % .12 / 103 75
+ \setchemicaltextelement RBN 935 522
+ %
+ \def\processchemical[##1##2##3##4]%
+ {\processaction
+ [##1##2##3##4]
+ [ FRONT????=>{\executechemicalFIVEFRONT[#1]},
+ PB:##4=>\beginchemicalpicture{##4},
+ PE????=>\endchemicalpicture,
+ ROT##4=>\processchemicalrotation{##4},
+ SUB##4=>\processchemicalsubstitute{##4},
+ ADJ##4=>\processchemicaldistance{##4},
+ MOV##4=>\processchemicaltranslate{##4},
+ -RZ##4=>\processchemicaltextelement{-RZ}{##4}{#1}{5}
+ {b,l,t,r,r, l,t,r,r,l, t,r,r,l,l, r,b,l,t,r},
+ +RZ##4=>\processchemicaltextelement{+RZ}{##4}{#1}{5}
+ {l,t,r,r,b, t,r,r,l,l, r,r,l,l,r, b,l,l,r,r},
+ -SB##4=>\processchemicallinesegment{-SB}{##4},
+ +SB##4=>\processchemicallinesegment{+SB}{##4},
+ -SR##4=>\processchemicallinesegment{-SR}{##4},
+ +SR##4=>\processchemicallinesegment{+SR}{##4},
+ -RD##4=>\processchemicaldashedlinesegment{-R}{##4},
+ +RD##4=>\processchemicaldashedlinesegment{+R}{##4},
+ -RB##4=>\processchemicaldeltalinesegment{-R}{##4},
+ +RB##4=>\processchemicaldeltalinesegment{+R}{##4},
+ CRZ##4=>\processchemicaltextelement{CRZ}{##4}{#1}{0}{},
+ RTN##4=>\processchemicaltextconstant{RTN}{##4}{\chemicaltextelementnumber}{0},
+ RTT##4=>\processchemicaltextelement{RTN}{##4}{#1}{0}{},
+ RBN##4=>\processchemicaltextconstant{RBN}{##4}{\chemicaltextelementnumber}{0},
+ RBT##4=>\processchemicaltextelement{RBN}{##4}{#1}{0}{},
+ -SS##4=>\processchemicallinesegment{-SS}{##4},
+ +SS##4=>\processchemicallinesegment{+SS}{##4},
+ CCD##4=>\processchemicaldottsegment{CC}{##4},
+ SS##3##4=>\processchemicallinesegment{SS}{##3##4},
+ RD##3##4=>\processchemicaldashedlinesegment{R}{##3##4},
+ RB##3##4=>\processchemicaldeltalinesegment{R}{##3##4},
+ ZN##3##4=>\processchemicaltextconstant{ZN}{##3##4}{\chemicaltextelementnumber}{0},
+ ZT##3##4=>\processchemicaltextelement{ZN}{##3##4}{#1}{0}{},
+ RN##3##4=>\processchemicaltextconstant{RN}{##3##4}{\chemicaltextelementnumber}{0},
+ RT##3##4=>\processchemicaltextelement{RN}{##3##4}{#1}{0}{},
+ AU##3##4=>\processchemicaluparrowsegment{A}{##3##4},
+ AD##3##4=>\processchemicaldownarrowsegment{A}{##3##4},
+ CC##3##4=>\processchemicalcircsegment{CC}{##3##4},
+ CD##3##4=>\processchemicaldottsegment{C}{##3##4},
+ DB##3##4=>\processchemicallinesegment{DB}{##3##4},
+ DR##3##4=>\processchemicallinesegment{DR}{##3##4},
+ EB##3##4=>\processchemicallinesegment{EB}{##3##4},
+ ER##3##4=>\processchemicallinesegment{ER}{##3##4},
+ RZ##3##4=>\processchemicaltextelement{RZ}{##3##4}{#1}{5}
+ {l,l,r,r,r, l,r,r,b,l, r,r,b,l,t, r,l,l,t,r},
+ SB##3##4=>\processchemicallinesegment{SB}{##3##4},
+ SR##3##4=>\processchemicallinesegment{SR}{##3##4},
+ -R##3##4=>\processchemicallinesegment{-R}{##3##4},
+ +R##3##4=>\processchemicallinesegment{+R}{##3##4},
+ B##2##3##4=>\processchemicallinesegment{B}{##2##3##4},
+ C##2##3##4=>\processchemicalcircsegment{C}{##2##3##4},
+ R##2##3##4=>\processchemicallinesegment{R}{##2##3##4},
+ S##2##3##4=>\processchemicallinesegment{S}{##2##3##4},
+ Z##2##3##4=>\processchemicaltextelement{Z}{##2##3##4}{#1}{0}{},
+ \s!unknown=>\unknownchemical{##1##2##3##4}]}}
+
+\def\executechemicalSIX[#1]%
+ {\setchemicalname SIX
+ %
+ \setchemicalmaximum 6
+ \setchemicalsubstitute 1375
+ \setchemicaldistance 866
+ %
+ \setchemicalrotation 1 1 0 0 -1 -1 0 0 1
+ \setchemicalrotation 2 0.5 -0.866 -0.866 -0.5 -0.5 0.866 0.866 0.5
+ \setchemicalrotation 3 -0.5 -0.866 -0.866 0.5 0.5 0.866 0.866 -0.5
+ \setchemicalrotation 4 -1 0 0 1 1 0 0 -1
+ \setchemicalrotation 5 -0.5 0.866 0.866 0.5 0.5 -0.866 -0.866 -0.5
+ \setchemicalrotation 6 0.5 0.866 0.866 -0.5 -0.5 -0.866 -0.866 0.5
+ %
+ \setchemicalangle 1 0 90 180 270
+ \setchemicalangle 2 60 150 240 330
+ \setchemicalangle 3 120 210 300 30
+ \setchemicalangle 4 180 270 0 90
+ \setchemicalangle 5 240 330 60 150
+ \setchemicalangle 6 300 30 120 210
+ %
+ \setchemicaltranslate 1 -1732 0
+ \setchemicaltranslate 2 -866 1500
+ \setchemicaltranslate 3 866 1500
+ \setchemicaltranslate 4 1732 0
+ \setchemicaltranslate 5 866 -1500
+ \setchemicaltranslate 6 -866 -1500
+ %
+ \setchemicallinesegment A 1386 500 1386 -500
+ \setchemicallinesegment S 0 1000 866 -500
+ \setchemicallinesegment SS 125 783 741 -283
+ \setchemicallinesegment -SS 0 1000 741 -283
+ \setchemicallinesegment +SS 125 783 866 -500
+ \setchemicallinesegment B 866 500 866 -500
+ \setchemicallinesegment SB 866 240 866 -240
+ \setchemicallinesegment -SB 866 240 866 -500
+ \setchemicallinesegment +SB 866 500 866 -240
+ \setchemicallinesegment DB1 816 240 816 -240
+ \setchemicallinesegment DB2 916 240 916 -240
+ \setchemicallinesegment EB 726 340 726 -340
+ \setchemicallinesegment R 866 500 1299 750
+ \setchemicallinesegment -R 866 500 866 1000
+ \setchemicallinesegment +R 866 500 1299 250
+ \setchemicallinesegment ER1 841 543 1274 793
+ \setchemicallinesegment ER2 891 457 1324 707
+ \setchemicallinesegment SR 1091 630 1299 750
+ \setchemicallinesegment -SR 866 740 866 1000
+ \setchemicallinesegment +SR 1091 370 1299 250
+ \setchemicallinesegment DR1 1066 673 1274 793
+ \setchemicallinesegment DR2 1116 588 1324 707
+ \setchemicallinesegment MID1 0 1000 -150 200
+ \setchemicallinesegment MID2 0 -1000 -150 -200
+ \setchemicallinesegment MIDS1 0 1000 -180 0
+ \setchemicallinesegment MIDS2 0 -1000 -180 0
+ %
+ \setchemicalcircsegment C -30 30 700 60 600 -346
+ \setchemicalcircsegment CC -60 0 700 60 350 -606
+ %
+ \setchemicaltextelement Z 866 500
+ \setchemicaltextelement RZ 1386 800
+ \setchemicaltextelement -RZ 866 1100
+ \setchemicaltextelement +RZ 1386 200
+ \setchemicaltextelement CRZ 1524 880
+ \setchemicaltextelement MIDZ -150 0
+ %
+ \setchemicaltextelement ZN 589 350
+ \setchemicaltextelement RN 1083 625 % 1.25 Z
+ \setchemicaltextelement RTN 1008 755 % .12 / 130 75
+ \setchemicaltextelement RBN 1158 495
+ %
+ \def\processchemical[##1##2##3##4##5]%
+ {\processaction
+ [##1##2##3##4##5]
+ [ FRONT????=>{\executechemicalSIXFRONT[#1]},
+ MID????=>\processchemicallinesegment{MID}{1????},
+ MIDS????=>\processchemicallinesegment{MIDS}{1????},
+ MIDZ????=>\processchemicaltextelement{MIDZ}{1????}{#1}{0}{},
+ PB:##4##5=>\beginchemicalpicture{##4##5},
+ PE????=>\endchemicalpicture,
+ ROT##4##5=>\processchemicalrotation{##4##5},
+ SUB##4##5=>\processchemicalsubstitute{##4##5},
+ ADJ##4##5=>\processchemicaldistance{##4##5},
+ MOV##4##5=>\processchemicaltranslate{##4##5},
+ -RZ##4##5=>\processchemicaltextelement{-RZ}{##4##5}{#1}{6}
+ {b,l,l,t,r,r, l,l,r,r,r,l, t,r,r,b,l,l, r,r,l,l,l,r},
+ +RZ##4##5=>\processchemicaltextelement{+RZ}{##4##5}{#1}{6}
+ {l,t,r,r,b,l, r,r,r,l,l,l, r,b,l,l,t,r, l,l,l,r,r,r},
+ -SB##4##5=>\processchemicallinesegment{-SB}{##4##5},
+ +SB##4##5=>\processchemicallinesegment{+SB}{##4##5},
+ -SR##4##5=>\processchemicallinesegment{-SR}{##4##5},
+ +SR##4##5=>\processchemicallinesegment{+SR}{##4##5},
+ -RD##4##5=>\processchemicaldashedlinesegment{-R}{##4##5},
+ +RD##4##5=>\processchemicaldashedlinesegment{+R}{##4##5},
+ -RB##4##5=>\processchemicaldeltalinesegment{-R}{##4##5},
+ +RB##4##5=>\processchemicaldeltalinesegment{+R}{##4##5},
+ CRZ##4##5=>\processchemicaltextelement{CRZ}{##4##5}{#1}{0}{},
+ -SS##4##5=>\processchemicallinesegment{-SS}{##4##5},
+ +SS##4##5=>\processchemicallinesegment{+SS}{##4##5},
+ CCD##4##5=>\processchemicaldottsegment{CC}{##4##5},
+RTN##4##5=>\processchemicaltextconstant{RTN}{##4##5}{\chemicaltextelementnumber}{0},
+RTT##4##5=>\processchemicaltextelement{RTN}{##4##5}{#1}{0}{},
+RBN##4##5=>\processchemicaltextconstant{RBN}{##4##5}{\chemicaltextelementnumber}{0},
+RBT##4##5=>\processchemicaltextelement{RBN}{##4##5}{#1}{0}{},
+ SS##3##4##5=>\processchemicallinesegment{SS}{##3##4##5},
+ RD##3##4##5=>\processchemicaldashedlinesegment{R}{##3##4##5},
+ RB##3##4##5=>\processchemicaldeltalinesegment{R}{##3##4##5},
+ ZN##3##4##5=>\processchemicaltextconstant{ZN}{##3##4##5}{\chemicaltextelementnumber}{0},
+ ZT##3##4##5=>\processchemicaltextelement{ZN}{##3##4##5}{#1}{0}{},
+RN##3##4##5=>\processchemicaltextconstant{RN}{##3##4##5}{\chemicaltextelementnumber}{0},
+RT##3##4##5=>\processchemicaltextelement{RN}{##3##4##5}{#1}{0}{},
+ AU##3##4##5=>\processchemicaluparrowsegment{A}{##3##4##5},
+ AD##3##4##5=>\processchemicaldownarrowsegment{A}{##3##4##5},
+ CD##3##4##5=>\processchemicaldottsegment{C}{##3##4##5},
+ CC##3##4##5=>\processchemicalcircsegment{CC}{##3##4##5},
+ DB##3##4##5=>\processchemicallinesegment{DB}{##3##4##5},
+ EB##3##4##5=>\processchemicallinesegment{EB}{##3##4##5},
+ ER##3##4##5=>\processchemicallinesegment{ER}{##3##4##5},
+ RZ##3##4##5=>\processchemicaltextelement{RZ}{##3##4##5}{#1}{6}
+ {l,l,t,r,r,b, l,r,r,r,l,l, r,r,b,l,l,t, r,l,l,l,r,r},
+ SB##3##4##5=>\processchemicallinesegment{SB}{##3##4##5},
+ SR##3##4##5=>\processchemicallinesegment{SR}{##3##4##5},
+ DR##3##4##5=>\processchemicallinesegment{DR}{##3##4##5},
+ -R##3##4##5=>\processchemicallinesegment{-R}{##3##4##5},
+ +R##3##4##5=>\processchemicallinesegment{+R}{##3##4##5},
+ B##2##3##4##5=>\processchemicallinesegment{B}{##2##3##4##5},
+ C##2##3##4##5=>\processchemicalcircsegment{C}{##2##3##4##5},
+ R##2##3##4##5=>\processchemicallinesegment{R}{##2##3##4##5},
+ S##2##3##4##5=>\processchemicallinesegment{S}{##2##3##4##5},
+ Z##2##3##4##5=>\processchemicaltextelement{Z}{##2##3##4##5}{#1}{0}{},
+ \s!unknown=>\unknownchemical{##1##2##3##4##5}]}}
+
+\def\executechemicalSEVEN[#1]% incomplete !
+ {\setchemicalname SEVEN
+ %
+ \setchemicalmaximum 7
+ \setchemicalsubstitute -
+ \setchemicaldistance 1038
+ %
+ \setchemicalrotation 1 .623 .782 - - - - - -
+ \setchemicalrotation 2 -.223 .975 - - - - - -
+ \setchemicalrotation 3 -.901 .434 - - - - - -
+ \setchemicalrotation 4 -.901 -.434 - - - - - -
+ \setchemicalrotation 5 -.223 -.975 - - - - - -
+ \setchemicalrotation 6 .623 -.782 - - - - - -
+ \setchemicalrotation 7 1 0 - - - - - -
+ %
+ \setchemicalangle 1 0 - - -
+ \setchemicalangle 2 51.429 - - -
+ \setchemicalangle 3 102.857 - - -
+ \setchemicalangle 4 154.286 - - -
+ \setchemicalangle 5 205.714 - - -
+ \setchemicalangle 6 257.143 - - -
+ \setchemicalangle 7 308.571 - - -
+ %
+ \setchemicaltranslate 1 - -
+ \setchemicaltranslate 2 - -
+ \setchemicaltranslate 3 - -
+ \setchemicaltranslate 4 - -
+ \setchemicaltranslate 5 - -
+ \setchemicaltranslate 6 - -
+ \setchemicaltranslate 7 - -
+ %
+ \setchemicallinesegment B 1038 500 1038 -500
+ \setchemicallinesegment SB 1038 240 1038 -240
+ \setchemicallinesegment -SB 1038 240 1038 -500
+ \setchemicallinesegment +SB 1038 500 1038 -240
+ %
+ \setchemicaltextelement Z 1038 500
+ %
+ \def\processchemical[##1##2##3##4##5]%
+ {\processaction
+ [##1##2##3##4##5]
+ [ PB:##4##5=>\beginchemicalpicture{##4##5},
+ PE????=>\endchemicalpicture,
+ %ROT##4##5=>\processchemicalrotation{##4},
+ %SUB##4##5=>\processchemicalsubstitute{##4##5},
+ %ADJ##4##5=>\processchemicaldistance{##4##5},
+ %MOV##4##5=>\processchemicaltranslate{##4##5},
+ -SB##4##5=>\processchemicallinesegment{-SB}{##4##5},
+ +SB##4##5=>\processchemicallinesegment{+SB}{##4##5},
+ SB##3##4##5=>\processchemicallinesegment{SB}{##3##4##5},
+ B##2##3##4##5=>\processchemicallinesegment{B}{##2##3##4##5},
+ Z##2##3##4##5=>\processchemicaltextelement{Z}{##2##3##4##5}{#1}{0}{},
+ \s!unknown=>\unknownchemical{##1##2##3##4##5}]}}
+
+\def\executechemicalEIGHT[#1]% incomplete !
+ {\setchemicalname EIGHT
+ %
+ \setchemicalmaximum 8
+ %\setchemicalsubstitute 1307
+ \setchemicaldistance 1207
+ %
+ \setchemicalrotation 1 .707 .707 - - - - - -
+ \setchemicalrotation 2 0 1 - - - - - -
+ \setchemicalrotation 3 -.707 .707 - - - - - -
+ \setchemicalrotation 4 -1 0 - - - - - -
+ \setchemicalrotation 5 -.707 -.707 - - - - - -
+ \setchemicalrotation 6 0 -1 - - - - - -
+ \setchemicalrotation 7 .707 -.707 - - - - - -
+ \setchemicalrotation 8 1 0 - - - - - -
+ %
+ \setchemicalangle 1 45 - - -
+ \setchemicalangle 2 90 - - -
+ \setchemicalangle 3 135 - - -
+ \setchemicalangle 4 180 - - -
+ \setchemicalangle 5 225 - - -
+ \setchemicalangle 6 270 - - -
+ \setchemicalangle 7 315 - - -
+ \setchemicalangle 8 0 - - -
+ %
+ \setchemicaltranslate 1 -2414 0
+ \setchemicaltranslate 2 -1706 1706
+ \setchemicaltranslate 3 0 2414
+ \setchemicaltranslate 4 1706 1706
+ \setchemicaltranslate 5 2414 0
+ \setchemicaltranslate 6 1706 -1706
+ \setchemicaltranslate 7 0 -2414
+ \setchemicaltranslate 8 -1706 -1706
+ %
+ \setchemicallinesegment B 1207 500 1207 -500
+ \setchemicallinesegment SB 1207 240 1207 -240
+ \setchemicallinesegment -SB 1207 240 1207 -500
+ \setchemicallinesegment +SB 1207 500 1207 -240
+ %
+ \setchemicaltextelement Z 1207 500
+ %
+ \def\processchemical[##1##2##3##4##5]%
+ {\processaction
+ [##1##2##3##4##5]
+ [ PB:##4##5=>\beginchemicalpicture{##4##5},
+ PE????=>\endchemicalpicture,
+ %SUB##4##5=>\processchemicalsubstitute{##4##5},
+ ADJ##4##5=>\processchemicaldistance{##4##5},
+ MOV##4##5=>\processchemicaltranslate{##4##5},
+ -SB##4##5=>\processchemicallinesegment{-SB}{##4##5},
+ +SB##4##5=>\processchemicallinesegment{+SB}{##4##5},
+ SB##3##4##5=>\processchemicallinesegment{SB}{##3##4##5},
+ B##2##3##4##5=>\processchemicallinesegment{B}{##2##3##4##5},
+ Z##2##3##4##5=>\processchemicaltextelement{Z}{##2##3##4##5}{#1}{0}{},
+ \s!unknown=>\unknownchemical{##1##2##3##4##5}]}}
+
+\def\executechemicalFIVEFRONT[#1]%
+ {\executechemicalFIVE[]%
+ %
+ \setchemicalname FIVEFRONT
+ %
+ \setchemicallinesegment -R 688 500 688 100
+ \setchemicallinesegment +R 688 500 688 900
+ %
+ \setchemicaltextelement -RZ 0 -1300
+ \setchemicaltextelement +RZ 0 1300
+ %
+ \def\processchemical[##1##2##3##4]%
+ {\def\chemicalrotation{2}%
+ \processaction
+ [##1##2##3##4]
+ [ -RZ##4=>\processchemicalunrotatedtextelement{Z}{-RZ}{##4}{#1}{5}
+ {,,,,, t,t,t,t,t},
+ +RZ##4=>\processchemicalunrotatedtextelement{Z}{+RZ}{##4}{#1}{5}
+ {,,,,, b,b,b,b,b},
+ -SB##4=>\processchemicallinesegment{-SB}{##4},
+ +SB##4=>\processchemicallinesegment{+SB}{##4},
+ SB##3##4=>\processchemicallinesegment{SB}{##3##4},
+ -R##3##4=>\processchemicalunrotatedlinesegment{t}{-R}{##3##4},
+ +R##3##4=>\processchemicalunrotatedlinesegment{b}{+R}{##3##4},
+ BB##3##4=>\processchemicalzlinesegment{B}{##3##4},
+ R##2##3##4=>\processchemicalunrotatedlinesegment{t}{-R}{##2##3##4}%
+ \processchemicalunrotatedlinesegment{b}{+R}{##2##3##4},
+ B##2##3##4=>\processchemicallinesegment{B}{##2##3##4},
+ Z##2##3##4=>\processchemicaltextelement{Z}{##2##3##4}{#1}{0}{},
+ \s!unknown=>\unknownchemical{##1##2##3##4}]}}
+
+\def\executechemicalSIXFRONT[#1]%
+ {\executechemicalSIX[]%
+ %
+ \setchemicalname SIXFRONT
+ %
+ \setchemicallinesegment -R 866 500 866 100
+ \setchemicallinesegment +R 866 500 866 900
+ %
+ \setchemicaltextelement -RZ 0 -1300
+ \setchemicaltextelement +RZ 0 1300
+ %
+ \def\processchemical[##1##2##3##4]%
+ {\def\chemicalrotation{2}%
+ \processaction
+ [##1##2##3##4]
+ [ -RZ##4=>\processchemicalunrotatedtextelement{Z}{-RZ}{##4}{#1}{6}
+ {,,,,,, t,t,t,t,t,t},
+ +RZ##4=>\processchemicalunrotatedtextelement{Z}{+RZ}{##4}{#1}{6}
+ {,,,,,, b,b,b,b,b,b},
+ -SB##4=>\processchemicallinesegment{-SB}{##4},
+ +SB##4=>\processchemicallinesegment{+SB}{##4},
+ SB##3##4=>\processchemicallinesegment{SB}{##3##4},
+ -R##3##4=>\processchemicalunrotatedlinesegment{t}{-R}{##3##4},
+ +R##3##4=>\processchemicalunrotatedlinesegment{b}{+R}{##3##4},
+ BB##3##4=>\processchemicalzlinesegment{B}{##3##4},
+ R##2##3##4=>\processchemicalunrotatedlinesegment{t}{-R}{##2##3##4}%
+ \processchemicalunrotatedlinesegment{b}{+R}{##2##3##4},
+ B##2##3##4=>\processchemicallinesegment{B}{##2##3##4},
+ Z##2##3##4=>\processchemicaltextelement{Z}{##2##3##4}{#1}{0}{},
+ \s!unknown=>\unknownchemical{##1##2##3##4}]}}
+
+% 1 : 0
+% 2 : -115
+% 3* : -195
+% 3 : -165
+% 4 : -245
+
+\def\executechemicalCARBON[#1]%
+ {\setchemicalname CARBON
+ %
+ \setchemicalmaximum 4
+ \setchemicaldistance 0
+ \setchemicalsubstitute 0
+ %
+ \setchemicalrotation 1 1 0 0 -1 -1 0 0 1
+ \setchemicalrotation 2 -0.423 -0.906 -0.906 0.423 0.423 0.906 0.906 -0.423
+ \setchemicalrotation 3 -0.966 -0.259 -0.259 0.966 0.966 0.259 0.259 -0.966
+ \setchemicalrotation 3* -0.966 0.259 0.259 0.966 0.966 -0.259 -0.259 -0.966
+ \setchemicalrotation 4 -0.423 0.906 0.906 0.423 0.423 -0.906 -0.906 -0.423
+ %
+ \setchemicalangle 1 0 90 180 270
+ \setchemicalangle 2 115 205 295 25
+ \setchemicalangle 3 165 255 345 75
+ \setchemicalangle 3* 195 285 15 105
+ \setchemicalangle 4 245 335 65 155
+ %
+ \setchemicaltranslate 1 -1500 0
+ \setchemicaltranslate 2 0 1500
+ \setchemicaltranslate 3 1500 0
+ \setchemicaltranslate 4 0 -1500
+ %
+ \setchemicallinesegment B1 500 0 1000 0
+ \setchemicallinesegment B2 300 0 1000 0
+ \setchemicallinesegment B3 500 0 1000 0
+ \setchemicallinesegment B4 300 0 1000 0
+ %
+ \setchemicaltextelement Z 1100 0
+ %
+ \setchemicalcircsegment C 0 360 500 360 0 -500
+ %
+ \def\processchemical[##1##2##3##4##5]%
+ {\processaction
+ [##1##2##3##4##5]
+ [ MIR????=>\setchemicalmirror{3},
+ -MIR????=>\resetchemicalmirror{3},
+ *MIR????=>\togglechemicalmirror{3},
+ CB????=>\processlocalchemicals{B,C,Z},
+ C????=>\processchemicalcircsegment{C}{1????},
+ -ROT##5=>\reversechemical{ROT}{##5}{3,4,1,2},
+ ROT##4##5=>\processchemicalrotation{##4##5},
+ MOV##4##5=>\processchemicaltranslate{##4##5},
+ CB##3##4##5=>\processlocalchemicals
+ {ROT##3,C,B,Z2..4,
+ MOV##3,*MIR,-ROT##3,C,B,Z2..4},
+ B##2##3##4##5=>\processprivatechemicallinesegment{B}{##2##3##4##5},
+ Z##2##3##4##5=>\processchemicaltextelement{Z}{##2##3##4##5}{#1}{4}
+ {l,t,r,b, t,r,b,l, r,b,l,t, b,l,t,r},
+ \s!unknown=>\unknownchemical{##1##2##3##4##5}]}}
+
+% 1: 45 2: -90 3: -225
+% 4: -45 5: -135 6: -270
+
+\newif\ifNEWMANstagger \NEWMANstaggertrue
+
+\def\executechemicalNEWMANSTAGGER%
+ {\NEWMANstaggertrue\executechemicalNEWMAN}
+
+\def\executechemicalNEWMANECLIPSE%
+ {\NEWMANstaggerfalse\executechemicalNEWMAN}
+
+\def\executechemicalNEWMAN[#1]%
+ {\setchemicalname NEWMAN
+ %
+ \setchemicalmaximum 6
+ \setchemicaldistance 0
+ \setchemicalsubstitute 0
+ %
+ \ifNEWMANstagger
+ \setchemicalrotation 1 0.707 0.707 0.707 -0.707 -0.707 -0.707 -0.707 0.707
+ \setchemicalrotation 2 0 -1 -1 0 0 1 1 0
+ \setchemicalrotation 3 -0.707 0.707 0.707 0.707 0.707 -0.707 -0.707 -0.707
+ \else
+ \setchemicalrotation 1 .866 -.5 -.5 -.866 -.866 .5 .5 .866
+ \setchemicalrotation 2 -.259 .966 .966 .259 .259 -.966 -.966 -.259
+ \setchemicalrotation 3 -.5 -.866 -.866 .5 .5 .866 .866 -.5
+ \fi
+ \setchemicalrotation 4 0.707 -0.707 -0.707 -0.707 -0.707 0.707 0.707 0.707
+ \setchemicalrotation 5 -0.707 -0.707 -0.707 0.707 0.707 0.707 0.707 -0.707
+ \setchemicalrotation 6 0 1 1 0 0 -1 -1 0
+ %
+ \ifNEWMANstagger
+ \setchemicalangle 1 315 45 135 225
+ \setchemicalangle 2 90 180 270 0
+ \setchemicalangle 3 225 315 45 135
+ \else
+ \setchemicalangle 1 30 120 210 300
+ \setchemicalangle 2 255 345 75 165
+ \setchemicalangle 3 120 210 300 30
+ \fi
+ \setchemicalangle 4 45 135 225 315
+ \setchemicalangle 5 135 225 315 45
+ \setchemicalangle 6 270 0 90 180
+ %
+ \setchemicaltranslate 1 -1500 0
+ \setchemicaltranslate 2 0 1500
+ \setchemicaltranslate 3 1500 0
+ \setchemicaltranslate 4 0 -1500
+ %
+ \setchemicallinesegment B1 0 0 1000 0
+ \setchemicallinesegment B2 0 0 1000 0
+ \setchemicallinesegment B3 0 0 1000 0
+ \setchemicallinesegment B4 500 0 1000 0
+ \setchemicallinesegment B5 500 0 1000 0
+ \setchemicallinesegment B6 500 0 1000 0
+ %
+ \setchemicaltextelement Z 1100 0
+ %
+ \setchemicalcircsegment C 0 360 500 360 0 -500
+ %
+ \def\processchemical[##1##2##3##4]%
+ {\processaction
+ [##1##2##3##4]
+ [STAGGER????=>{\executechemicalNEWMANSTAGGER[#1]},
+ ECLIPSE????=>{\executechemicalNEWMANECLIPSE[#1]},
+ B????=>\processlocalchemicals{B1..6},
+ CB????=>\processlocalchemicals{B1..6,C,Z1..6},
+ C????=>\processchemicalcircsegment{C}{1????},
+ ROT##4=>\processchemicalrotation{##4},
+ MOV##4=>\processchemicaltranslate{##4},
+ B##2##3##4=>\processprivatechemicallinesegment{B}{##2##3##4},
+ Z##2##3##4=>\ifNEWMANstagger
+ \processchemicaltextelement{Z}{##2##3##4}{#1}{6}
+ {l,t,r,l,r,b, l,r,l,r,r,l, r,b,l,r,l,t, r,l,r,l,l,r}%
+ \else
+ \processchemicaltextelement{Z}{##2##3##4}{#1}{6}
+ {l,r,t,t,r,b, t,b,r,r,b,l, r,l,b,b,l,t, b,t,l,l,t,r}%
+ \fi,
+ \s!unknown=>\unknownchemical{##1##2##3##4}]}}
+
+\def\executechemicalCHAIR[#1]% smaller
+ {\setchemicalname CHAIR
+ %
+ \setchemicalmaximum 6
+ %
+ \setchemicallinesegment B1 1600 800 2800 -800
+ \setchemicallinesegment B2 2800 -800 800 0
+ \setchemicallinesegment B3 800 0 -1600 -800
+ \setchemicallinesegment B4 -1600 -800 -2800 800
+ \setchemicallinesegment B5 -2800 800 -800 0
+ \setchemicallinesegment B6 -800 0 1600 800
+ %
+ \setchemicallinesegment +R1 1600 800 1600 1600
+ \setchemicallinesegment +R2 2800 -800 2800 -1600
+ \setchemicallinesegment +R3 800 0 800 800
+ \setchemicallinesegment +R4 -1600 -800 -1600 -1600
+ \setchemicallinesegment +R5 -2800 800 -2800 1600
+ \setchemicallinesegment +R6 -800 0 -800 -800
+ %
+ \setchemicallinesegment -R1 1600 800 2350 522 % 750 278
+ \setchemicallinesegment -R2 2800 -800 3493 -400
+ \setchemicallinesegment -R3 800 0 1329 -600 % 528 600
+ \setchemicallinesegment -R4 -1600 -800 -2350 -522 % 750 278
+ \setchemicallinesegment -R5 -2800 800 -3493 400
+ \setchemicallinesegment -R6 -800 0 -1329 600 % 528 600
+ %
+ \setchemicaltextelement +RZ1 1600 1800
+ \setchemicaltextelement +RZ2 2800 -1800
+ \setchemicaltextelement +RZ3 800 1000
+ \setchemicaltextelement +RZ4 -1600 -1800
+ \setchemicaltextelement +RZ5 -2800 1800
+ \setchemicaltextelement +RZ6 -800 -1000
+ %
+ \setchemicaltextelement -RZ1 2538 453 % 200 lang
+ \setchemicaltextelement -RZ2 3666 -300
+ \setchemicaltextelement -RZ3 1460 -750
+ \setchemicaltextelement -RZ4 -2538 -453
+ \setchemicaltextelement -RZ5 -3666 300
+ \setchemicaltextelement -RZ6 -1460 750
+ %
+ \def\processchemical[##1##2##3##4##5]%
+ {\def\chemicalrotation{1}%
+ \processaction
+ [##1##2##3##4##5]
+ [ B????=>\processlocalchemicals{B1,B2,B3,B4,B5,B6},
+ -R????=>\processlocalchemicals{-R1,-R2,-R3,-R4,-R5,-R6},
+ +R????=>\processlocalchemicals{+R1,+R2,+R3,+R4,+R5,+R6},
+ B##2????=>{\getchemicallinesegment[0][B##2]},
+ -RZ##4????=>{\getchemicalfixedtextelement[-RZ##4][1][##4][l,l,tc,r,r,bc][#1]},
+ +RZ##4????=>{\getchemicalfixedtextelement[+RZ##4][1][##4][c][#1]},
+ -R##3????=>{\getchemicallinesegment[0][-R##3]},
+ +R##3????=>{\getchemicallinesegment[0][+R##3]},
+ \s!unknown=>\unknownchemical{##1##2##3##4##5}]}}
+
+\def\executechemicalarrow#1#2[#3]%
+ {\dogetcommalistelement1\from#3\to\toptext
+ \dogetcommalistelement2\from#3\to\bottext
+ \def\dochemicaltext##1%
+ {\dosetsubscripts%
+ $\@@dochemicalstyle{\@@localchemicalformat\strut##1}$%
+ \doresetsubscripts}%
+ \doifelse\@@chemicallocation\v!intext
+ {#1{\dochemicaltext\toptext}}%
+ {\setbox\chemicalsymbols=\hbox
+ {\box\chemicalsymbols
+ \vbox{\halign{##\cr
+ \hbox to 3em{\hss\dochemicaltext{\toptext}\hss}\cr
+ #2%
+ \hbox to 3em{\hss\dochemicaltext{\bottext}\hss}\cr}}}}}
+
+\def\executechemicalGIVES
+ {\executechemicalarrow
+ {\chemicalsinglepicturearrow}% nodig
+ {\rightarrowfill\cr}}
+
+\def\executechemicalEQUILIBRIUM
+ {\executechemicalarrow
+ {\chemicaldoublepicturearrow}% nodig
+ {\rightarrowfill\cr\leftarrowfill\cr}}
+
+\def\executechemicalMESOMERIC
+ {\executechemicalarrow
+ {\chemicalsinglepicturearrow}% nodig
+ {$\leftarrow\hskip-1em$\rightarrowfill\cr}}
+
+\def\executechemicalsign#1[#2]%
+ {\doifelse\@@chemicallocation\v!intext
+ {\dosetsubscripts
+ $\@@dochemicalstyle{\@@localchemicalformat#1}$%
+ \doresetsubscripts}
+ {\setbox\chemicalsymbols\hbox
+ {\box\chemicalsymbols
+ \dosetsubscripts
+ $\@@dochemicalstyle{\@@localchemicalformat#1}$%
+ \doresetsubscripts}}}
+
+\def\executechemicalPLUS
+ {\executechemicalsign{+}}
+
+\def\executechemicalMINUS
+ {\executechemicalsign{-}}
+
+\def\executechemicalEQUAL
+ {\executechemicalsign{=}}
+
+\def\executechemicalSPACE[#1]%
+ {\doifnot\@@chemicallocation\v!intext
+ {\setbox\chemicalsymbols\hbox
+ {\box\chemicalsymbols
+ \quad}}}
+
+\def\executechemicalCHEM[#1]%
+ {\doifnot\@@chemicallocation\v!intext
+ {\setbox\chemicalsymbols\hbox
+ {\box\chemicalsymbols
+ $\@@dochemicalstyle{\@@localchemicalformat#1}$}}}
+
+\def\executechemicalTEXT[#1]%
+ {\doifnot\@@chemicallocation\v!intext
+ {\setbox\chemicalsymbols\hbox
+ {\box\chemicalsymbols#1}}}
+
+%\def\executechemicalLOW[#1]%
+% {\setlowsubscripts}
+%
+%\def\executechemicalHIGH[#1]%
+% {\sethighsubscripts}
+
+\def\putchemicalrule#1#2#3#4%
+ {\ifcase\chemicaldrawingmode
+ \putrule from {#1} {#2} to {#3} {#4}
+ \or
+ \psline(#1,#2)(#3,#4)%
+ \or
+ \bgroup
+ \!!counta=#1\!!countb=#2\!!countc=#3\!!countd=#4\relax
+ \global\MPdrawingdonetrue
+ \setchemicalattributes
+ \startMPdrawing
+ x1 := \MPdivten[\the\!!counta]u ;
+ y1 := \MPdivten[\the\!!countb]u ;
+ x2 := \MPdivten[\the\!!countc]u ;
+ y2 := \MPdivten[\the\!!countd]u ;
+ draw z1--z2 ;
+ \stopMPdrawing
+ \egroup
+ \fi}
+
+\def\executechemicalcomplex#1%
+ {\bgroup
+ \putchemicalrule {0} {-\@@chemicalbottom} {0} {\@@chemicaltop}%
+ \putchemicalrule {0} {\@@chemicaltop} {#1150} {\@@chemicaltop}%
+ \putchemicalrule {0} {-\@@chemicalbottom} {#1150} {-\@@chemicalbottom}%
+ \egroup}
+
+\def\executechemicalOPENCOMPLEX[#1]%
+ {\executechemicalcomplex+\ignorespaces
+ \executechemicalSPACE[]}
+
+\def\executechemicalCLOSECOMPLEX[#1]%
+ {\executechemicalSPACE[]%
+ \executechemicalcomplex-\ignorespaces}
+
+% nog niet door midden as!
+
+\def\executechemicalverticalsymbol#1#2%
+ {\executechemicalTEXT
+ [$\left#1\relax
+ \dimen0=\@@chemicalunit
+ \scratchcounter=\@@chemicaltop
+ \advance\scratchcounter by \@@chemicalbottom
+ \dimen0=\scratchcounter\dimen0
+ \vcenter to \dimen0{}
+ \dimen2=\@@chemicalunit
+ \dimen2=\@@chemicalright\dimen0
+ \vcenter{\leftskip1em\hsize\dimen2\relax\strut#2\strut}%
+ \right.$]}%
+
+\def\executechemicalUPARROW[#1]%
+ {\executechemicalverticalsymbol\uparrow{#1}}
+
+\def\executechemicalDOWNARROW[#1]%
+ {\executechemicalverticalsymbol\downarrow{#1}}
+
+\def\executechemicalUPDOWNARROW[#1]%
+ {\executechemicalverticalsymbol\updownarrow{#1}}
+
+\let\setchemicalattributes\relax
+
+\setupchemical
+ [\c!width=0,
+ \c!height=0,
+ \c!left=0,
+ \c!right=0,
+ \c!top=0,
+ \c!bottom=0,
+ \c!bodyfont=\the\bodyfontsize,
+ \c!resolution=\outputresolution,
+ \c!scale=\v!medium,
+ \c!size=\v!medium,
+ \c!textsize=\v!big,
+ \c!frame=\v!off,
+ \c!axis=\v!off,
+ \c!state=\v!start,
+ \c!style=\rm,
+ \c!location=,
+ \c!option=,
+ \c!offset=LOW,
+ \c!alternative=1,
+ \c!color=,
+ \c!rulethickness=,
+ \c!rulecolor=,
+ \c!factor=1]
+
+% Tijdelijk plaatsen we deze extra macro's hier.
+%
+% mathontop: \mtop {} {}
+% textontop: \ttop {} {}
+
+\def\putontop#1#2%
+ {\vbox
+ {\halign
+ {\strut\hss##\hss\cr
+ #1\cr
+ #2\cr}}}
+
+\def\ttop#1#2%
+ {\putontop{\tx#1}{#2}}
+
+\def\mtop#1#2%
+ {\vbox
+ {\offinterlineskip
+ \halign
+ {\hss##\hss\cr
+ $\scriptscriptstyle#1$\cr
+ \noalign{\vskip.5ex}%
+ $#2$\cr}}}
+
+\def\ctop#1#2%
+ {\vbox
+ {\offinterlineskip
+ \halign
+ {\hss##\hss\cr
+ $\@@dochemicalstyle{\@@localchemicalformat\scriptscriptstyle#1}$\cr
+ \noalign{\vskip.5ex}%
+ $\@@dochemicalstyle{\@@localchemicalformat#2}$\cr}}}
+
+%D Here are a couple of goodies:
+%D
+%D \startitemize
+%D \item styles hooked into \CONTEXT\ style mechanism
+%D \item support for color and rulethickness (mp mode only)
+%D \item position tracking
+%D \stopitemize
+
+\let\@@chemicalrulecolor\empty
+\let\@@chemicalcolor \empty
+
+\def\setchemicalattributes
+ {\scratchdimen\@@chemicalrulethickness
+ \def\chemicalattributes
+ {withpen pencircle scaled \the\scratchdimen\space
+ withcolor }%
+ \doifelsenothing\@@chemicalrulecolor
+ {\edef\chemicalattributes{\chemicalattributes black}}
+ {\edef\chemicalattributes{\chemicalattributes \MPcolor{\@@chemicalrulecolor}}}%
+ \startMPdrawing
+ drawoptions (\chemicalattributes) ;
+ \stopMPdrawing}
+
+\unexpanded\def\@@dochemicalcolor
+ {\dousecolorparameter\@@chemicalcolor}
+
+\unexpanded\def\@@dochemicalstyle
+ {\dousestyleparameter\@@chemicalstyle}
+
+\setupchemical
+ [\c!rulethickness=\linewidth,
+ \c!rulecolor=,
+ \c!color=]
+
+\def\cpos#1#2%
+ {\iftrialtypesetting
+ #2%
+ \else
+ \bgroup
+ \globalpushmacro\dowithchemical
+ \gdef\dowithchemical##1{\hpos{#1}{##1}\globalpopmacro\dowithchemical}%
+ #2%
+ \egroup
+ \fi}
+
+\protect \endinput
+
+% \startchemical[axis=on,frame=yes]
+% \chemical[SIX,ROT2,B,R36,RZ6][CH_3]
+% \chemical[PB:RZ3,ONE,Z05,SB5,EP37,PE][O,H]
+% \stopchemical
+
+% \startchemical[size=big,scale=small,axis=on,frame=yes,factor=1.5]
+% \chemical[SIX,ROT2,B,R36,RZ6][CH_3]
+% \chemical[PB:RZ3,ONE,Z05,SB5,EP37,PE][O,H]
+% \stopchemical
+
+% \startchemical[size=big,scale=medium,axis=on,frame=yes,factor=1.5]
+% \chemical[SIX,ROT2,B,R36,RZ6][CH_3]
+% \chemical[PB:RZ3,ONE,Z05,SB5,EP37,PE][O,H]
+% \stopchemical
+
+% \startchemical[size=big,scale=big,axis=on,frame=yes,factor=1.5]
+% \chemical[SIX,ROT2,B,R36,RZ6][CH_3]
+% \chemical[PB:RZ3,ONE,Z05,SB5,EP37,PE][O,H]
+% \stopchemical
diff --git a/Master/texmf-dist/tex/context/modules/mkiv/s-art-01.mkiv b/Master/texmf-dist/tex/context/modules/mkiv/s-art-01.mkiv
new file mode 100644
index 00000000000..601ee1adc80
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkiv/s-art-01.mkiv
@@ -0,0 +1,62 @@
+\unprotect
+
+\startmodule[art-01]
+
+\definemeasure [article:margin] [\paperheight/20] % was 15, see xtables-mkiv for results
+\definemeasure [overview:margin] [\paperheight/30]
+
+\definelayout
+ [article]
+ [\c!topspace=\measure{article:margin},
+ \c!bottomspace=\measure{article:margin},
+ \c!backspace=\measure{article:margin},
+ \c!header=\measure{article:margin},
+ \c!footer=0pt,
+ \c!width=\v!middle,
+ \c!height=\v!middle]
+
+
+\definelayout
+ [overview]
+ [\c!topspace=\measure{overview:margin},
+ \c!bottomspace=\measure{overview:margin},
+ \c!backspace=\measure{overview:margin},
+ \c!header=\measure{overview:margin},
+ \c!footer=0pt,
+ \c!width=\v!middle,
+ \c!height=\v!middle]
+
+\setuplayout
+ [article]
+
+\setupbodyfont
+ [dejavu,10pt] % 12pt is just to large and we use this for all kind of demos
+
+\setupwhitespace
+ [\v!big]
+
+\setuphead
+ [\v!chapter]
+ [\c!style=\bfc,
+ \c!headerstate=\v!high,
+ \c!interaction=\v!all]
+
+\setuphead
+ [\v!section]
+ [\c!style=\bfb]
+
+\setuphead
+ [\v!subsection]
+ [\c!style=\bfa]
+
+\setuphead
+ [\v!subsubsection]
+ [\c!style=\bf,
+ \c!after=]
+
+\setuplist
+ [\c!interaction=\v!all]
+
+\protect
+
+\stopmodule
diff --git a/Master/texmf-dist/tex/context/modules/mkiv/s-def-01.mkiv b/Master/texmf-dist/tex/context/modules/mkiv/s-def-01.mkiv
new file mode 100644
index 00000000000..49e585bd018
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkiv/s-def-01.mkiv
@@ -0,0 +1,10 @@
+% yes or no
+
+\unprotect
+
+\startsetups defaults:frontpart:pagenumbers:roman
+ \defineconversionset[\c!frontpart:\c!pagenumber][][romannumerals]
+ \setupuserpagenumber[\c!way=\v!by\v!block]
+\stopsetups
+
+\protect
diff --git a/Master/texmf-dist/tex/context/modules/mkiv/s-figures-names.mkiv b/Master/texmf-dist/tex/context/modules/mkiv/s-figures-names.mkiv
new file mode 100644
index 00000000000..a2782efc95d
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkiv/s-figures-names.mkiv
@@ -0,0 +1,99 @@
+%D \module
+%D [ file=s-figures-names.mkiv,
+%D version=2017.07.17,
+%D title=\CONTEXT\ Style File,
+%D subtitle=Show Figure Names,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+%D Normally this module will be run someplace at the end of a document in some kind of tracing
+%D mode. We could hook it into \type {\stoptext} but better leave it up to the user. Loading
+%D this module upfront will not show anything useful. The main reason for making this module
+%D was that we wanted to report weird figurenames: spaces, multiple hyphens in a row, mixed
+%D hyphens and underscores, inconsistently mixed upper and lowercase, etc.
+%D
+%D If you only want info in the logfile, you can use:
+%D
+%D \starttyping
+%D \enabletrackers[graphics.lognames]
+%D \stoptyping
+%D
+%D This directive is persistent and can be issued any time before the end of the run.
+
+\startmodule[figures-names]
+
+\startluacode
+
+local context = context
+local ctx_NC = context.NC
+local ctx_NR = context.NR
+local ctx_red = context.red
+local ctx_starttabulate = context.starttabulate
+local ctx_stoptabulate = context.stoptabulate
+local ctx_hyphenatedname = context.hyphenatedfilename
+
+trackers.enable("graphics.lognames")
+
+context.start()
+
+ context.switchtobodyfont { "tt,small" }
+
+ local template = { "|Bl|p|" }
+
+ for _, data in table.sortedhash(figures.found) do
+ ctx_starttabulate(template)
+ local badname = data.badname
+ local found = data.found
+ ctx_NC()
+ context("asked name")
+ ctx_NC()
+ if badname then
+ ctx_red()
+ end
+ context(data.askedname)
+ ctx_NC() ctx_NR()
+ if found then
+ ctx_NC()
+ context("format")
+ ctx_NC()
+ context(data.format)
+ ctx_NC() ctx_NR()
+ ctx_NC()
+ context("found file")
+ ctx_NC()
+ ctx_hyphenatedname(data.foundname)
+ -- context(data.foundname)
+ ctx_NC() ctx_NR()
+ ctx_NC()
+ context("used file")
+ ctx_NC()
+ ctx_hyphenatedname(data.fullname)
+ -- context(data.fullname)
+ ctx_NC() ctx_NR()
+ if badname then
+ ctx_NC()
+ context("comment")
+ ctx_NC()
+ context("bad name")
+ ctx_NC() ctx_NR()
+ end
+ else
+ ctx_NC()
+ context("comment")
+ ctx_NC()
+ context(data.comment or "not found")
+ ctx_NC() ctx_NR()
+ end
+ ctx_stoptabulate()
+ end
+
+context.stop()
+
+\stopluacode
+
+\stopmodule
diff --git a/Master/texmf-dist/tex/context/modules/mkiv/s-fnt-10.mkiv b/Master/texmf-dist/tex/context/modules/mkiv/s-fnt-10.mkiv
new file mode 100644
index 00000000000..731c4be392f
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkiv/s-fnt-10.mkiv
@@ -0,0 +1,169 @@
+%D \module
+%D [ file=s-fnt-01,
+%D version=2006.10.10, % guess
+%D title=\CONTEXT\ Style File,
+%D subtitle=Listing Glyphs in Large Fonts,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+% sort of obsolete
+
+\startluacode
+local fontdata = fonts.hashes.identifiers
+
+-- function fonts.tracers.show_all()
+-- local tfmdata = fontdata[font.current()]
+-- if tfmdata and tfmdata.shared then
+-- local NC, NR, char = context.NC, context.NR, context.char
+-- context.starttabulate { "|l|r|c|" }
+-- for unicode, description in fonts.iterators.characters(tfmdata) do
+-- NC() context(description.name) NC() context(unicode) NC() char(unicode) NC() NR()
+-- end
+-- context.stoptabulate()
+-- end
+-- end
+
+local context = context
+local escaped = context.escaped
+
+function fonts.tracers.show_all()
+ local tfmdata = fontdata[font.current()]
+ if tfmdata then
+ local NC, NR, HL, char, bold, tttf = context.NC, context.NR, context.HL, context.char, context.bold, context.tttf
+ local descriptions = tfmdata.descriptions or { }
+ local data = characters.data
+ -- context.setuptabulate { header = "repeat" }
+ context.starttabulatehead()
+ NC() bold("unicode")
+ NC() bold("visual")
+ NC() bold("index")
+ NC() bold("glyph")
+ NC() bold("adobe")
+ NC() bold("context")
+ NC() NR()
+ context.stoptabulatehead()
+ context.starttabulate { "|l|c|l|p|p|p|" }
+ for unicode, chr in fonts.iterators.characters(tfmdata) do
+ local des, dat = descriptions[unicode], data[unicode]
+ local index = chr.index or 0
+ local cname = (dat and dat.contextname) or ""
+ local aname = (dat and dat.adobename) or ""
+ local gname = (des and des.name) or ""
+ local mname = dat and dat.mathname
+ if type(mname) ~= "string" then
+ mname = ""
+ end
+ local mspec = dat and dat.mathspec
+ if mspec then
+ for m=1,#mspec do
+ local n = mspec[m].name
+ if n then
+ if mname == "" then
+ mname = n
+ else
+ mname = mname .. " " .. n
+ end
+ end
+ end
+ end
+ if mname ~= "" then
+ mname = "m: " .. mname
+ if cname ~= "" then
+ cname = cname .. " " .. mname
+ else
+ cname = mname
+ end
+ end
+ NC() tttf() context("U+%05X",unicode)
+ NC() char(unicode)
+ NC() tttf() context("%05X",index)
+ NC() if gname ~= "" then tttf() escaped(gname) end
+ NC() if aname ~= "" then tttf() context(aname) end
+ NC() if cname ~= "" then tttf() context(cname) end
+ NC() NR()
+ end
+ context.stoptabulate()
+ else
+ context("problems")
+ end
+end
+
+function fonts.tracers.show_glyphs()
+ local tfmdata = fontdata[font.current()]
+ if tfmdata then
+ for unicode, chr in fonts.iterators.characters(tfmdata) do
+ context.showglyph(unicode)
+ end
+ end
+end
+\stopluacode
+
+\unexpanded\def\ShowCompleteFont#1#2#3%
+ {\bgroup
+ \page
+ \font\TestFont=#1 at #2
+ \setuplayout[style=\TestFont]
+ \setupheadertexts[]
+ \setupfootertexts[#1 -- \pagenumber]
+ \setupfootertexts[pagenumber]
+ \setuplayout[width=middle,height=middle,topspace=1cm,backspace=1cm]
+ \TestFont
+ \nonknuthmode
+ \startcolumns[n=#3]
+ \TestFont
+ \ctxlua { fonts.tracers.show_all() }
+ \stopcolumns
+ \page
+ \egroup}
+
+\unexpanded\def\ShowAllGlyphs#1#2#3%
+ {\bgroup
+ \page
+ \def\showglyph##1{\dontleavehmode\strut\char##1\relax\par}
+ \font\TestFontA=#1 at 12pt
+ \font\TestFontB=#1 at #2
+ \setuplayout[style=\TestFontA]
+ \setupheadertexts[]
+ \setupfootertexts[#1\space\endash\space\pagenumber]
+ \setuplayout[width=middle,height=middle,topspace=1cm,backspace=1cm,header=1cm,footer=2cm]
+ \TestFontB \setupinterlinespace[line=1.2\dimexpr#2\relax] \raggedcenter
+ \nonknuthmode
+ \startcolumns[n=#3]
+ \TestFontB
+ \ctxlua { fonts.tracers.show_glyphs() }
+ \stopcolumns
+ \page
+ \egroup}
+
+\continueifinputfile{s-fnt-10.mkiv}
+
+\starttext
+
+% \ShowCompleteFont{name:dejavusansmono}{10pt}{1}
+% \ShowCompleteFont{name:dejavuserif}{10pt}{2}
+% \ShowCompleteFont{name:officinasansbookitcregular}{10pt}{2}
+% \ShowCompleteFont{name:officinaserifbookitcregular}{10pt}{2}
+% \ShowCompleteFont{name:serpentineserifeflight}{10pt}{2}
+\ShowCompleteFont{name:lmroman10-regular}{10pt}{1}
+% \ShowCompleteFont{name:lmtypewriter10-regular}{10pt}{2}
+% \ShowCompleteFont{lt55485}{10pt}{2}
+% \ShowCompleteFont{lmr10}{10pt}{2}
+% \ShowCompleteFont{lbr}{10pt}{2}
+% \ShowCompleteFont{name:Cambria}{10pt}{2}
+% \ShowCompleteFont{name:CambriaMath}{10pt}{2}
+% \ShowCompleteFont{name:texgyrepagella-regular}{10pt}{2}
+% \ShowCompleteFont{name:texgyrechorus-mediumitalic}{10pt}{2}
+% \ShowAllGlyphs {name:texgyrepagella-regular} {48pt}{2}
+% \ShowAllGlyphs {name:texgyrechorus-mediumitalic}{48pt}{2}
+% \ShowCompleteFont{name:euler10-regular}{10pt}{2}
+
+% \ShowCompleteFont{name:palatinosansinformalcombold}{20pt}{2}
+% \ShowCompleteFont{name:palatinonovaregular}{11pt}{2}
+% \ShowCompleteFont{pirat.ttf}{12pt}{1}
+
+\stoptext
diff --git a/Master/texmf-dist/tex/context/modules/mkiv/s-fnt-20.mkiv b/Master/texmf-dist/tex/context/modules/mkiv/s-fnt-20.mkiv
new file mode 100644
index 00000000000..5840430990f
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkiv/s-fnt-20.mkiv
@@ -0,0 +1,161 @@
+%D \module
+%D [ file=s-fnt-20,
+%D version=2009.01.10,
+%D title=\CONTEXT\ Style File,
+%D subtitle=Tracing Feature Application (1),
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+%D This file is used by Idris and me in the process of getting the
+%D best arabic fonts getting rendered best. As such it might change.
+
+% \setvariables
+% [otftracker]
+% [title=Reverse Chaining,
+% figure=test-003-volt.pdf,
+% font=husayni,
+% sample={ببب بببب ببببب بببببب}]
+
+\def\checkedotftrackerfeature #1{otftracker-\ifnum\featureattribute{otftracker-#1}=\zerocount default\else#1\fi}
+\def\checkedotftrackerdirection#1{\csname otftracker-direction-\ifcsname otftracker-direction-#1\endcsname#1\else default\fi\endcsname}
+
+% we can consider adding a dir key to features
+
+\definefontfeature
+ [otftracker-default]
+ [default]
+ [mode=node]
+
+\definefontfeature
+ [otftracker-arabtype]
+ [mode=node,analyze=yes,
+ language=dflt,script=arab,ccmp=yes,
+ init=yes,medi=yes,fina=yes,isol=yes,
+ liga=yes,dlig=yes,rlig=yes,clig=yes,
+ mark=yes,mkmk=yes,kern=yes,curs=yes]
+
+% \definefontfeature
+% [otftracker-husayni]
+% [analyze=yes,mode=node,
+% language=dflt,script=arab,ccmp=yes,
+% init=yes,medi=yes,fina=yes,isol=yes,
+% calt=yes,
+% mark=yes,mkmk=yes,kern=yes,curs=yes]
+
+\definefontfeature
+ [otftracker-husayni]
+ [analyze=yes,mode=node,
+ language=dflt,script=arab,
+ init=yes,medi=yes,fina=yes,
+ rlig=yes,
+ ccmp=yes,
+ ss01=yes, % full Allah, Muhammad, Allahumma
+ ss05=yes, % full Jiim stacking
+ ss09=yes, % full Haa stacking
+ ss10=yes, % partial dipped Miim
+ ss13=yes, % full stacked Miim
+ ss15=yes, % full stacked Laam-on-Miim
+ ss17=yes, % full stacked Ayn-on-Miim
+ ss19=yes, % LM_im
+ ss24=yes, % BX specials
+ ss25=yes, % LH_im specials
+ ss26=yes, % full Yaa.final specials
+ ss27=yes, % partial thin Miim.final
+ ss31=yes, % partial Raa.final contexts
+ ss34=yes, % partial Raa.final contexts
+ ss35=yes, % full Kaaf contexts
+ ss36=yes, % full Laam contexts
+ ss37=yes, % Miim-Miim contexts
+ ss38=yes, % fancy thin Haa.medial-Miim.final
+ ss39=yes, % high and low Baa strings
+ ss40=yes, % diagonal entry
+ ss41=yes, % initial alternates
+ mark=yes,mkmk=yes,kern=yes,curs=yes]
+
+\definefontfeature
+ [otftracker-simplenaskhi]
+ [analyze=yes,mode=node,
+ language=dflt,script=arab,
+ init=yes,medi=yes,fina=yes,calt=yes,
+ rlig=yes,liga=yes,dlig=yes,
+ mark=yes,mkmk=yes,kern=yes,curs=yes]
+
+\setvalue{otftracker-direction-arabtype}{r2l}
+\setvalue{otftracker-direction-husayni}{r2l}
+\setvalue{otftracker-direction-simplenaskhi}{r2l}
+\setvalue{otftracker-direction-default}{}
+
+\setvariables
+ [otftracker]
+ [font=Serif,
+ features=\checkedotftrackerfeature{\getvariable{otftracker}{font}},
+ direction=\checkedotftrackerdirection{\getvariable{otftracker}{font}},
+ size=48pt,
+ figure=,
+ title=Feature Check,
+ sample=no sample,
+ set=\setups{otftracker}]
+
+\setuplayout
+ [topspace=1.5cm,
+ backspace=1.5cm,
+ width=middle,
+ height=middle,
+ header=1.5cm,
+ footer=1.5cm]
+
+\setuphead
+ [chapter]
+ [header=high,
+ number=no]
+
+\setupfootertexts
+ [chapter]
+
+\setupalign
+ [flushleft]
+
+\setupcolors
+ [state=start]
+
+\startsetups otftracker
+ \setupbodyfont[tt,10pt]
+ \starttext
+ \normalexpanded{\startchapter[title={\getvariable{otftracker}{title}}]}
+ \doifsomething {\getvariable{otftracker}{figure}} {
+ \startlinecorrection
+ \externalfigure[\getvariable{otftracker}{figure}][maxwidth=\hsize,frame=on]
+ \stoplinecorrection
+ }
+ \showotfcomposition
+ {\getvariable{otftracker}{font}*\getvariable{otftracker}{features} at \getvariable{otftracker}{size}}
+ {\getvariable{otftracker}{direction}}
+ {\getvariable{otftracker}{sample}}
+ \stopchapter
+ \stoptext
+\stopsetups
+
+\continueifinputfile{s-fnt-20.mkiv}
+
+\usemodule[art-01]
+
+\setupbodyfont
+% [cambria]
+ [dejavu]
+
+\starttext
+
+\setvariables
+ [otftracker]
+ [font=Serif,
+ size=48pt,
+ figure=,
+ title=Feature Check,
+ sample={affiliation}]
+
+\stoptext
diff --git a/Master/texmf-dist/tex/context/modules/mkiv/s-fnt-21.mkiv b/Master/texmf-dist/tex/context/modules/mkiv/s-fnt-21.mkiv
new file mode 100644
index 00000000000..10d5a462394
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkiv/s-fnt-21.mkiv
@@ -0,0 +1,64 @@
+%D \module
+%D [ file=s-fnt-20,
+%D version=2009.01.10,
+%D title=\CONTEXT\ Style File,
+%D subtitle=Tracing Feature Application (2),
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+%D This module is related to:
+
+\usemodule[fnt-20]
+
+\setvariables
+ [otftracker]
+ [set=\setups{araball}]
+
+\startsetups araball
+ \begingroup
+ \setupcolors[state=start]%
+ \enabletrackers[otf.analyzing]% beware, kind of global
+ \ruledhbox \bgroup
+ \definedfont[\getvariable{otftracker}{font}*\getvariable{otftracker}{features} at \getvariable{otftracker}{size}]%
+ \ifnum\getvariable{otftracker}{direction}<0 \textdir TRT\else\ifnum\getvariable{otftracker}{direction}>0 \textdir TLT\fi\fi\relax
+ \getvariable{otftracker}{sample}%
+ \egroup
+ \disabletrackers[otf.analyzing]%
+ \endgroup
+\stopsetups
+
+\unexpanded\def\ShowOtfTrackerSample#1%
+ {\doiffile{#1}
+ {\blank
+ \startlinecorrection
+ \vbox \bgroup
+ \forgetall
+ \setbox\scratchbox\hbox{\component #1 \relax}
+ \hbox{\copy\scratchbox\quad\lower\dp\scratchbox\hbox{\ruledhbox{\externalfigure[#1-volt.pdf][height=\htdp\scratchbox]}}}
+ \hbox{\strut\tttf#1}%
+ \egroup
+ \stoplinecorrection
+ \blank}}
+
+\endinput
+
+% \usemodule[fnt-21]
+%
+% \starttext
+%
+% \setvariables
+% [otftracker]
+% [direction=-1,
+% sample=لا,
+% title=Test,
+% font=file:arabtype,
+% % font=file:husayni,
+% % font=file:scheherazaderegot,
+% features=arabic]
+%
+% \stoptext
diff --git a/Master/texmf-dist/tex/context/modules/mkiv/s-fnt-24.mkiv b/Master/texmf-dist/tex/context/modules/mkiv/s-fnt-24.mkiv
new file mode 100644
index 00000000000..2e6b9a59187
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkiv/s-fnt-24.mkiv
@@ -0,0 +1,83 @@
+%D \module
+%D [ file=s-fnt-24,
+%D version=2009.02.06,
+%D title=\CONTEXT\ Style File,
+%D subtitle=CJK Glyph Combination Testing,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\unprotect
+
+\def\ShowChineseCombiChar#1#2#3#4%
+ {\blank[small]
+ \dontleavehmode
+ \hbox\bgroup
+ \dontcomplain
+ \setstrut
+ \hbox to 7em{\ruledhbox{\char#1}\hskip.25em\type{+}\hskip.25em\ruledhbox{\char#2}\hskip.25em\type{=}\hskip.25em\ruledhbox{\char#1\char#2}\hss}\relax
+ \ruledvtop{\hsize1em\char#1\char#2}\relax
+ \hskip2em
+ \ruledvtop{\hsize.625em\char#1\char#2}\relax
+ \hskip2em
+ \ruledvtop{\hsize1.5em\char#1\char#2}\relax
+ \hskip2em
+ \type{#3 + #4}\relax
+ \egroup
+ \blank[small]}
+
+\startluacode
+local example = {
+ korean = 0x0AC00,
+ chinese = 0x04E55,
+ full_width_open = 0x03008,
+ full_width_close = 0x03009,
+ half_width_open = 0x02018,
+ half_width_close = 0x02019,
+ hyphen = 0x02026,
+ non_starter = 0x03005,
+ other = 0x0004D, -- M
+}
+
+function fonts.analyzers.cjktest(first,second)
+ for k, v in next, example do
+ if (not first or first == "") or first == k then
+ for kk, vv in next, example do
+ if (not second or second == "") or second == kk then
+ context.ShowChineseCombiChar(v,vv,k,kk)
+ end
+ end
+ end
+ end
+end
+\stopluacode
+
+\unexpanded\def\ShowCombinationsKorean
+ {\dodoubleempty\doShowCombinationsKorean}
+
+\def\doShowCombinationsKorean[#1][#2]%
+ {\startpacked
+ \setscript[hangul]
+ \setupcolors[\c!state=\v!start]
+ \enabletrackers[cjk.analyzing]
+ \ctxlua{fonts.analyzers.cjktest("#1","#2")}\par % !
+ \disabletrackers[cjk.analyzing]
+ \stoppacked}
+
+\unexpanded\def\ShowCombinationsChinese
+ {\dodoubleempty\doShowCombinationsChinese}
+
+\def\doShowCombinationsChinese[#1][#2]%
+ {\startpacked
+ \setscript[hanzi]
+ \setupcolors[\c!state=\v!start]
+ \enabletrackers[cjk.analyzing]
+ \ctxlua{fonts.analyzers.cjktest("#1","#2")}\par % !
+ \disabletrackers[cjk.analyzing]
+ \stoppacked}
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/modules/mkiv/s-fonts-charts.mkiv b/Master/texmf-dist/tex/context/modules/mkiv/s-fonts-charts.mkiv
new file mode 100644
index 00000000000..e94b52a2e76
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkiv/s-fonts-charts.mkiv
@@ -0,0 +1,204 @@
+%D \module
+%D [ file=s-fonts-charts,
+%D version=2015.08.08,
+%D title=\CONTEXT\ Style File,
+%D subtitle=Show Fonts Charts,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+% begin info
+%
+% title : show unicode blocks
+%
+% comment : show charts of a given fgont
+%
+% end info
+
+\startmodule[fonts-charts]
+
+% \registerctxluafile{s-fonts-charts}{}
+\starttexdefinition unexpanded FontChartSetSlot #1#2
+ \dontleavehmode
+ \setbox\scratchbox\vbox to 1cm \bgroup
+ \vss
+ \hbox to 1cm \bgroup
+ \infofont \hss\raise.25mm\hbox{#2}\hss
+ \egroup
+ \egroup
+ \wd\scratchbox0mm
+ \ht\scratchbox5mm
+ \dp\scratchbox5mm
+ \box\scratchbox
+ \setbox\scratchbox\ruledhbox to 1cm \bgroup
+ \hss\char#1\hss
+ \egroup
+ \ht\scratchbox5mm
+ \dp\scratchbox5mm
+ \box\scratchbox
+\stoptexdefinition
+
+\starttexdefinition unexpanded FontChartNoSlot
+ \dontleavehmode
+ \setbox\scratchbox\hbox to 1cm \bgroup
+ % empty
+ \egroup
+ \ht\scratchbox5mm
+ \dp\scratchbox5mm
+ \box\scratchbox
+\stoptexdefinition
+
+\starttexdefinition unexpanded FontChartSetLegend #1
+ \dontleavehmode
+ \setbox\scratchbox\hbox to 1cm \bgroup
+ \infofont\hss#1\hss
+ \egroup
+ \ht\scratchbox5mm
+ \dp\scratchbox5mm
+ \box\scratchbox
+\stoptexdefinition
+
+\starttexdefinition unexpanded FontChartSetCaption #1#2
+ \dontleavehmode
+ \setbox\scratchbox\hbox to 16cm \bgroup
+ \infofontbold\hskip1cm#1: #2\hss
+ \egroup
+ \ht\scratchbox7.5mm
+ \dp\scratchbox2.5mm
+ \box\scratchbox
+\stoptexdefinition
+
+\starttexdefinition unexpanded FontChartGap
+ \kern .5mm
+\stoptexdefinition
+
+\startluacode
+ local div, mod = math.div, math.mod
+ local formatters = string.formatters
+
+ moduledata.fonts = moduledata.fonts or { }
+ moduledata.fonts.charts = moduledata.fonts.charts or { }
+
+ function moduledata.fonts.charts.show(settings)
+
+ local settings = utilities.parsers.settings_to_hash(settings)
+
+ local filename = settings.filename or ""
+ local fontid = true
+ local newpage = settings.page == interfaces.variables.yes
+
+ if filename ~= "" then
+ fontid = fonts.definers.internal({ name = filename, size = "10pt" },"chartfont")
+ end
+
+ local ranges = { }
+ local data = fonts.hashes.identifiers[fontid]
+ local private = fonts.constructors.privateoffset
+ local chars = data.characters
+
+ for u in table.sortedhash(chars) do
+ if u >= private then
+ break
+ else
+ ranges[div(u,0xFF)] = true
+ end
+ end
+
+ local ctx_setlegend = context.FontChartSetLegend
+ local ctx_noslot = context.FontChartNoSlot
+ local ctx_setslot = context.FontChartSetSlot
+ local ctx_setcaption = context.FontChartSetCaption
+ local ctx_par = context.par
+ local ctx_gap = context.FontChartGap
+
+ for r in table.sortedhash(ranges) do
+ if newpage then
+ context.page()
+ end
+ context.startframed { offset = "overlay", frame = "off", align = "normal" }
+ if filename ~= "" then
+ context.chartfont()
+ end
+ context.dontcomplain()
+ context.offinterlineskip()
+ ctx_noslot()
+ for i=0,0xF do
+ ctx_setlegend(formatters["%03X"](r*0x10+i))
+ end
+ r = r * 0xFF
+ ctx_par()
+ for i=0,0xF do
+ ctx_setlegend(formatters["%0X"](i))
+ ctx_gap()
+ for j=0,0xF do
+ local u = r + i*0x10 + j
+ local d = chars[u]
+ if d then
+ ctx_setslot(u,formatters["%04X"](u))
+ else
+ ctx_noslot()
+ end
+ if j ~= 0xF then
+ ctx_gap()
+ end
+ end
+ ctx_par()
+ ctx_gap()
+ end
+ ctx_setcaption(formatters["%04X-%04X"](r,r+0xFF),file.basename(data.properties.filename))
+ ctx_par()
+ context.stopframed()
+ if newpage then
+ context.page()
+ end
+ end
+ end
+\stopluacode
+
+\installmodulecommandluasingle \showfontchart {moduledata.fonts.charts.show}
+
+\stopmodule
+
+\continueifinputfile{s-fonts-charts.mkiv}
+
+\usemodule[art-01]
+
+\starttext
+
+ \showfontchart[filename=LucidaBrightOT.otf,page=yes]
+ \showfontchart[filename=LucidaBrightOT-Demi.otf,page=yes]
+ \showfontchart[filename=LucidaBrightOT-DemiItalic.otf,page=yes]
+ \showfontchart[filename=LucidaBrightOT-Italic.otf,page=yes]
+
+ \showfontchart[filename=LucidaSansOT.otf,page=yes]
+ \showfontchart[filename=LucidaSansOT-Demi.otf,page=yes]
+ \showfontchart[filename=LucidaSansOT-DemiItalic.otf,page=yes]
+ \showfontchart[filename=LucidaSansOT-Italic.otf,page=yes]
+
+ \showfontchart[filename=LucidaSansTypewriterOT.otf,page=yes]
+ \showfontchart[filename=LucidaSansTypewriterOT-Bold.otf,page=yes]
+ \showfontchart[filename=LucidaSansTypewriterOT-BoldOblique.otf,page=yes]
+ \showfontchart[filename=LucidaSansTypewriterOT-Oblique.otf,page=yes]
+
+ \showfontchart[filename=LucidaConsoleDK.otf,page=yes]
+ \showfontchart[filename=LucidaConsoleDK-Bold.otf,page=yes]
+ \showfontchart[filename=LucidaConsoleDK-BoldItalic.otf,page=yes]
+ \showfontchart[filename=LucidaConsoleDK-Italic.otf,page=yes]
+
+ \showfontchart[filename=LucidaGrandeMonoDK.otf,page=yes]
+ \showfontchart[filename=LucidaGrandeMonoDK-Bold.otf,page=yes]
+ \showfontchart[filename=LucidaGrandeMonoDK-BoldItalic.otf,page=yes]
+ \showfontchart[filename=LucidaGrandeMonoDK-Italic.otf,page=yes]
+
+ \showfontchart[filename=LucidaBrightMathOT.otf,page=yes]
+ \showfontchart[filename=LucidaBrightMathOT-Demi.otf,page=yes]
+
+ \showfontchart[filename=LucidaBlackletterOT.otf,page=yes]
+ \showfontchart[filename=LucidaCalligraphyOT.otf,page=yes]
+ \showfontchart[filename=LucidaHandwritingOT.otf,page=yes]
+
+\stoptext
diff --git a/Master/texmf-dist/tex/context/modules/mkiv/s-fonts-coverage.lua b/Master/texmf-dist/tex/context/modules/mkiv/s-fonts-coverage.lua
new file mode 100644
index 00000000000..dd772d5f09b
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkiv/s-fonts-coverage.lua
@@ -0,0 +1,123 @@
+if not modules then modules = { } end modules ['s-fonts-coverage'] = {
+ version = 1.001,
+ comment = "companion to s-fonts-coverage.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+moduledata.fonts = moduledata.fonts or { }
+moduledata.fonts.coverage = moduledata.fonts.coverage or { }
+
+local upper, format = string.upper, string.format
+local lpegmatch = lpeg.match
+local concat = table.concat
+
+local context = context
+local NC, NR, HL = context.NC, context.NR, context.HL
+local char, bold, getvalue = context.char, context.bold, context.getvalue
+
+local chardata = characters.data
+
+function moduledata.fonts.coverage.showcomparison(specification)
+
+ specification = interfaces.checkedspecification(specification)
+
+ local fontfiles = utilities.parsers.settings_to_array(specification.list or "")
+ local pattern = upper(specification.pattern or "")
+
+ local present = { }
+ local names = { }
+ local files = { }
+ local chars = { }
+
+ if not pattern then
+ -- skip
+ elseif pattern == "" then
+ pattern = nil
+ elseif tonumber(pattern) then
+ pattern = tonumber(pattern)
+ else
+ pattern = lpeg.oneof(utilities.parsers.settings_to_array(pattern))
+ pattern = (1-pattern)^0 * pattern
+ end
+
+ for i=1,#fontfiles do
+ local fontname = format("testfont-%s",i)
+ local fontfile = fontfiles[i]
+ local fontsize = tex.dimen.bodyfontsize
+ local id, fontdata = fonts.definers.define {
+ name = fontfile,
+ size = fontsize,
+ cs = fontname,
+ }
+ if id and fontdata then
+ for k, v in next, fontdata.characters do
+ present[k] = true
+ end
+ names[#names+1] = fontname
+ files[#files+1] = fontfile
+ chars[#names] = fontdata.characters
+ end
+ end
+
+ local t = { }
+
+ context.starttabulate { "|Tr" .. string.rep("|l",#names) .. "|" }
+ for i=1,#files do
+ local file = files[i]
+ t[#t+1] = i .. "=" .. file
+ NC()
+ context(i)
+ NC()
+ context(file)
+ NC()
+ NR()
+ end
+ context.stoptabulate()
+
+ context.setupfootertexts {
+ table.concat(t," ")
+ }
+
+ context.starttabulate { "|Tl" .. string.rep("|c",#names) .. "|Tl|" }
+ NC()
+ bold("unicode")
+ NC()
+ for i=1,#names do
+ bold(i)
+ NC()
+ end
+ bold("description")
+ NC()
+ NR()
+ HL()
+ for k, v in table.sortedpairs(present) do
+ if k <= 0 then
+ -- ignore
+ elseif k >= 0x110000 then
+ logs.report("warning","weird character %U",k)
+ else
+ local description = chardata[k].description
+ if not pattern or (pattern == k) or (description and lpegmatch(pattern,description)) then
+ NC()
+ context("%05X",k)
+ NC()
+ for i=1,#names do
+ getvalue(names[i])
+ if chars[i][k] then
+ char(k)
+ else
+ -- missing
+ end
+ NC()
+ end
+ context(description)
+ NC()
+ NR()
+ end
+ end
+ end
+ context.stoptabulate()
+
+end
diff --git a/Master/texmf-dist/tex/context/modules/mkiv/s-fonts-coverage.mkiv b/Master/texmf-dist/tex/context/modules/mkiv/s-fonts-coverage.mkiv
new file mode 100644
index 00000000000..c09d943bcca
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkiv/s-fonts-coverage.mkiv
@@ -0,0 +1,131 @@
+%D \module
+%D [ file=s-fonts-coverage, % s-fnt-31
+%D version=2011.01.02,
+%D title=\CONTEXT\ Style File,
+%D subtitle=Show Fonts Coverage,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+% begin info
+%
+% title : compare glyphs in fonts
+%
+% comment : show glyphs in several fonts alongside in order to to compare coverage
+% status : experimental, used for luatex testing
+%
+% end info
+
+\startmodule[fonts-coverage]
+
+\registerctxluafile{s-fonts-coverage}{}
+
+\installmodulecommandluasingle \showfontcomparison {moduledata.fonts.coverage.showcomparison}
+
+\stopmodule
+
+\continueifinputfile{s-fonts-coverage.mkiv}
+
+\usemodule[art-01]
+
+\starttext
+
+ \showfontcomparison
+ [list={texgyrepagella-regular.otf,texgyretermes-regular.otf,texgyrebonum-regular.otf},
+ pattern=ogonek]
+
+ \page
+
+ % $e=mc²$ ${}²$ $²$ $x²ᶞ$ $x⁽²⁺²⁼²⁺²⁾$ $x²⁺²⁼²⁺²$ $x₅²$ $x²₅²$
+
+ % \startluacode
+ % moduledata.fonts.coverage.showcomparison {
+ % list = {
+ % "texgyrepagella-math.otf",
+ % "texgyretermes-math.otf",
+ % "texgyrebonum-math.otf",
+ % }
+ % }
+ % \stopluacode
+
+ % \startluacode
+ % moduledata.fonts.coverage.showcomparison {
+ % list = "pirat.ttf",
+ % }
+ % \stopluacode
+
+ % \startluacode
+ % moduledata.fonts.coverage.showcomparison {
+ % list = {
+ % "lucidabrightot.otf",
+ % "cambria.ttf",
+ % "iwona-regular.otf",
+ % "texgyrepagella-regular.otf",
+ % "texgyretermes-regular.otf",
+ % "texgyrebonum-regular.otf",
+ % "antpolt-regular.otf",
+ % },
+ % pattern = "OGONEK"
+ % }
+ % \stopluacode
+
+ % \loadfontgoodies[lucida-math]
+ % \loadfontgoodies[lm-math]
+ %
+ % \startluacode
+ % moduledata.fonts.coverage.showcomparison {
+ % list = {
+ % "LucidaBrightRegular.ttf",
+ % "LucidaBrightOne@lucida-math",
+ % "cambria.ttc(Cambria Math)",
+ % "xits-math.otf",
+ % "LMMath10-Regular@lmroman10-math",
+ % },
+ % }
+ % \stopluacode
+
+ % \loadfontgoodies[px-math]
+ % \loadfontgoodies[lm-math]
+ %
+ % \startluacode
+ % moduledata.fonts.coverage.showcomparison {
+ % list = {
+ % "cambria.ttc(Cambria Math)",
+ % "xits-math.otf",
+ % -- "stixmath-regular.otf",
+ % "latinmodern-math.otf",
+ % -- "lucidabrightmathot.otf",
+ % -- "lucidabrightmathot-demi.otf",
+ % "texgyrepagella-math.otf",
+ % "texgyretermes-math.otf",
+ % "texgyrebonum-math.otf",
+ % -- "LMMath10-Regular@lmroman10-math",
+ % -- "pxmath@px-math",
+ % -- "txmath@tx-math",
+ % },
+ % }
+ % \stopluacode
+
+ % \startluacode
+ % moduledata.fonts.coverage.showcomparison {
+ % list = {
+ % "dejavuserif.ttf",
+ % "dejavusans.ttf",
+ % "dejavusansmono.ttf",
+ % "lucidabrightot.otf",
+ % "cambria.ttf",
+ % "iwona-regular.otf",
+ % "texgyrepagella-regular.otf",
+ % "texgyretermes-regular.otf",
+ % "texgyrebonum-regular.otf",
+ % "antpolt-regular.otf",
+ % },
+ % pattern = "CELSIUS,FAHRENHEIT"
+ % }
+ % \stopluacode
+
+\stoptext
diff --git a/Master/texmf-dist/tex/context/modules/mkiv/s-fonts-features.lua b/Master/texmf-dist/tex/context/modules/mkiv/s-fonts-features.lua
new file mode 100644
index 00000000000..0a7cf8b132c
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkiv/s-fonts-features.lua
@@ -0,0 +1,161 @@
+if not modules then modules = { } end modules ['s-fonts-features'] = {
+ version = 1.001,
+ comment = "companion to s-fonts-features.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+moduledata.fonts = moduledata.fonts or { }
+moduledata.fonts.features = moduledata.fonts.features or { }
+
+-- for the moment only otf
+
+local sortedhash = table.sortedhash
+
+local NC, NR, bold = context.NC, context.NR, context.bold
+
+function moduledata.fonts.features.showused(specification)
+
+ specification = interfaces.checkedspecification(specification)
+
+ -- local list = utilities.parsers.settings_to_set(specification.list or "all")
+
+ context.starttabulate { "|T|T|T|T|T|" }
+
+ context.HL()
+
+ NC() bold("feature")
+ NC()
+ NC() bold("description")
+ NC() bold("value")
+ NC() bold("internal")
+ NC() NR()
+
+ context.HL()
+
+ local usedfeatures = fonts.handlers.otf.statistics.usedfeatures
+ local features = fonts.handlers.otf.tables.features
+ local descriptions = fonts.handlers.otf.features.descriptions
+
+ for feature, keys in sortedhash(usedfeatures) do
+ -- if list.all or (list.otf and rawget(features,feature)) or (list.extra and rawget(descriptions,feature)) then
+ local done = false
+ for k, v in sortedhash(keys) do
+ if done then
+ NC()
+ NC()
+ NC()
+ elseif rawget(descriptions,feature) then
+ NC() context(feature)
+ NC() context("+") -- extra
+ NC() context(descriptions[feature])
+ done = true
+ elseif rawget(features,feature) then
+ NC() context(feature)
+ NC() -- otf
+ NC() context(features[feature])
+ done = true
+ else
+ NC() context(feature)
+ NC() context("-") -- unknown
+ NC()
+ done = true
+ end
+ NC() context(k)
+ NC() context(tostring(v))
+ NC() NR()
+ end
+ -- end
+ end
+
+ context.HL()
+
+ context.stoptabulate()
+
+end
+
+local function collectkerns(tfmdata,feature)
+ local combinations = { }
+ local resources = tfmdata.resources
+ local characters = tfmdata.characters
+ local sequences = resources.sequences
+ local lookuphash = resources.lookuphash
+ local feature = feature or "kern"
+ if sequences then
+ for i=1,#sequences do
+ local sequence = sequences[i]
+ if sequence.features and sequence.features[feature] then
+ local lookuplist = sequence.subtables
+ if lookuplist then
+ for l=1,#lookuplist do
+ local lookupname = lookuplist[l]
+ local lookupdata = lookuphash[lookupname]
+ for unicode, data in next, lookupdata do
+ local kerns = combinations[unicode]
+ if not kerns then
+ kerns = { }
+ combinations[unicode] = kerns
+ end
+ for otherunicode, kern in next, data do
+ if not kerns[otherunicode] and kern ~= 0 then
+ kerns[otherunicode] = kern
+ end
+ end
+ end
+ end
+ end
+ end
+ end
+ end
+ return combinations
+end
+
+local showkernpair = context.showkernpair
+
+function moduledata.fonts.features.showbasekerns(specification)
+ -- assumes that the font is loaded in base mode
+ specification = interfaces.checkedspecification(specification)
+ local id, cs = fonts.definers.internal(specification,"")
+ local tfmdata = fonts.hashes.identifiers[id]
+ local done = false
+ for unicode, character in sortedhash(tfmdata.characters) do
+ local kerns = character.kerns
+ if kerns then
+ context.par()
+ for othercode, kern in sortedhash(kerns) do
+ showkernpair(unicode,kern,othercode)
+ end
+ context.par()
+ done = true
+ end
+ end
+ if not done then
+ context("no kern pairs found")
+ context.par()
+ end
+end
+
+function moduledata.fonts.features.showallkerns(specification)
+ specification = interfaces.checkedspecification(specification)
+ local id, cs = fonts.definers.internal(specification,"")
+ local tfmdata = fonts.hashes.identifiers[id]
+ local allkerns = collectkerns(tfmdata)
+ local characters = tfmdata.characters
+ if next(allkerns) then
+ for first, pairs in sortedhash(allkerns) do
+ context.par()
+ for second, kern in sortedhash(pairs) do
+ -- local kerns = characters[first].kerns
+ -- if not kerns and pairs[second] then
+ -- -- weird
+ -- end
+ showkernpair(first,kern,second,0)
+ end
+ context.par()
+ end
+ else
+ context("no kern pairs found")
+ context.par()
+ end
+end
diff --git a/Master/texmf-dist/tex/context/modules/mkiv/s-fonts-features.mkiv b/Master/texmf-dist/tex/context/modules/mkiv/s-fonts-features.mkiv
new file mode 100644
index 00000000000..b81b53a7176
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkiv/s-fonts-features.mkiv
@@ -0,0 +1,82 @@
+%D \module
+%D [ file=s-fonts-features, % was s-fnt-41, s-fnt-27
+%D version=2012.11.27, % 2010.02.22
+%D title=\CONTEXT\ Style File,
+%D subtitle=Features,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\startmodule[fonts-features]
+
+\registerctxluafile{s-fonts-features}{}
+
+\installmodulecommandluasingle \showusedfeatures {moduledata.fonts.features.showused}
+\installmodulecommandluasingle \showallkerns {moduledata.fonts.features.showallkerns}
+\installmodulecommandluasingle \showbasekerns {moduledata.fonts.features.showbasekerns}
+
+\def\kernpairheight{\strutheight}
+\def\kernpairdepth {\strutdepth}
+\def\kernpairwidth {\onepoint}
+
+\unexpanded\def\showkernpair#1#2#3% first second kern
+ {\dontleavehmode
+ \hbox \bgroup
+ \scratchdimen#2\scaledpoint
+ \kern\fontcharwd\font#1\relax
+ \ifdim\scratchdimen>\zeropoint
+ \bgroup
+ \darkgreen
+ \vrule width \scratchdimen height \kernpairheight depth \kernpairdepth
+ \egroup
+ \kern-\scratchdimen
+ \else\ifdim\scratchdimen<\zeropoint
+ \kern\scratchdimen
+ \bgroup
+ \darkred
+ \vrule width -\scratchdimen height \kernpairheight depth \kernpairdepth
+ \egroup
+ \else
+ \kern-.5\dimexpr\kernpairwidth\relax
+ \bgroup
+ \darkblue
+ \vrule width \kernpairwidth height \kernpairheight depth \kernpairdepth
+ \egroup
+ \kern-.5\dimexpr\kernpairwidth\relax
+ \fi\fi
+ \kern-\fontcharwd\font#1\relax
+ \char#1\relax
+ \char#3\relax
+ \egroup
+ \space}
+
+\stopmodule
+
+\continueifinputfile{s-fonts-features.mkiv}
+
+\usemodule
+ [art-01]
+
+\starttext
+
+ \showusedfeatures \page
+
+ \definefontfeature[default-base][default][mode=base]
+
+ \start
+ \definedfont[Serif*default-base]
+ \showbasekerns
+ \page
+ \stop
+
+ \start
+ \bf
+ \showallkerns
+ \page
+ \stop
+
+\stoptext
diff --git a/Master/texmf-dist/tex/context/modules/mkiv/s-fonts-goodies.lua b/Master/texmf-dist/tex/context/modules/mkiv/s-fonts-goodies.lua
new file mode 100644
index 00000000000..381fc45eabf
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkiv/s-fonts-goodies.lua
@@ -0,0 +1,117 @@
+if not modules then modules = { } end modules['s-fonts-goodies'] = {
+ version = 1.001,
+ comment = "companion to s-fonts-goodies.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+moduledata.fonts = moduledata.fonts or { }
+moduledata.fonts.goodies = moduledata.fonts.goodies or { }
+
+local NC, NR, HL = context.NC, context.NR, context.HL
+
+local function initialized(specification)
+ specification = interfaces.checkedspecification(specification)
+ local name = specification.name
+ if name then
+ local goodies = fonts.goodies.load(name)
+ if goodies then
+ return specification, goodies
+ end
+ end
+end
+
+function moduledata.fonts.goodies.showstylistics(specification)
+ local specification, goodies = initialized(specification)
+ if goodies then
+ local stylistics = goodies.stylistics
+ if stylistics then
+ context.starttabulate { "|Tl|Tpl|" }
+ HL()
+ NC() context.bold("feature")
+ NC() context.bold("meaning")
+ NC() NR()
+ HL()
+ for feature, meaning in table.sortedpairs(stylistics) do
+ NC() context(feature)
+ NC() context(string.lower(meaning))
+ NC() NR()
+ end
+ HL()
+ context.stoptabulate()
+ end
+ end
+end
+
+function moduledata.fonts.goodies.showfeaturesets(specification)
+ local specification, goodies = initialized(specification)
+ if goodies then
+ local featuresets = goodies.featuresets
+ if featuresets then
+ context.starttabulate { "|Tl|Tpl|" }
+ HL()
+ NC() context.bold("featureset")
+ NC() context.bold("definitions")
+ NC() NR()
+ HL()
+ for featureset, definitions in table.sortedpairs(featuresets) do
+ NC() context.type(featureset) NC()
+ for k, v in table.sortedpairs(definitions) do
+ context("%s=%S",k,v)
+ context.quad()
+ end
+ NC() NR()
+ end
+ HL()
+ context.stoptabulate()
+ end
+ end
+end
+
+function moduledata.fonts.goodies.showcolorschemes(specification)
+ local specification, goodies = initialized(specification)
+ if goodies then
+ local colorschemes = goodies.colorschemes
+ if colorschemes then
+ context.starttabulate { "|Tl|Tpl|" }
+ HL()
+ NC() context.bold("colorscheme")
+ NC() context.bold("numbers")
+ NC() NR()
+ HL()
+ for colorscheme, numbers in table.sortedpairs(colorschemes) do
+ NC() context.type(colorscheme) NC()
+ for i=1,#numbers do
+ context(i)
+ context.quad()
+ end
+ NC() NR()
+ end
+ HL()
+ context.stoptabulate()
+ end
+ end
+end
+
+function moduledata.fonts.goodies.showfiles(specification)
+ local specification, goodies = initialized(specification)
+ if goodies then
+ local files = goodies.files
+ if files and files.list then
+ for filename, specification in table.sortedpairs(files.list) do
+ context.start()
+ context.dontleavehmode()
+ context.definedfont{ filename .. "*default" }
+ context("%s-%s-%s-%s-%s",
+ specification.name or files.name,
+ specification.weight or "normal",
+ specification.style or "normal",
+ specification.width or "normal",
+ specification.variant or "normal")
+ context.par()
+ context.stop()
+ end
+ end
+ end
+end
diff --git a/Master/texmf-dist/tex/context/modules/mkiv/s-fonts-goodies.mkiv b/Master/texmf-dist/tex/context/modules/mkiv/s-fonts-goodies.mkiv
new file mode 100644
index 00000000000..e596507afa9
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkiv/s-fonts-goodies.mkiv
@@ -0,0 +1,37 @@
+%D \module
+%D [ file=s-fonts-goodies, % s-fnt-26, s-fnt-28
+%D version=2009.10.26,
+%D title=\CONTEXT\ Style File,
+%D subtitle=Goodies Tables,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+%D More tables will follow here as we have many more goodies by now.
+
+\startmodule[fonts-goodies]
+
+\registerctxluafile{s-fonts-goodies}{}
+
+\installmodulecommandluasingle \showfontgoodiesstylistics {moduledata.fonts.goodies.showstylistics}
+\installmodulecommandluasingle \showfontgoodiesfeaturesets {moduledata.fonts.goodies.showfeaturesets}
+\installmodulecommandluasingle \showfontgoodiescolorschemes {moduledata.fonts.goodies.showcolorschemes}
+\installmodulecommandluasingle \showfontgoodiesfiles {moduledata.fonts.goodies.showfiles}
+
+\stopmodule
+
+\continueifinputfile{s-fonts-goodies.mkiv}
+
+\starttext
+
+ \showfontgoodiesstylistics [name=husayni] \page
+ \showfontgoodiesfeaturesets [name=husayni] \page
+ \showfontgoodiescolorschemes[name=husayni] \page
+
+ \showfontgoodiesfiles [name=antykwapoltawskiego] \page
+
+\stoptext
diff --git a/Master/texmf-dist/tex/context/modules/mkiv/s-fonts-ligatures.mkiv b/Master/texmf-dist/tex/context/modules/mkiv/s-fonts-ligatures.mkiv
new file mode 100644
index 00000000000..fc49ec5c58b
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkiv/s-fonts-ligatures.mkiv
@@ -0,0 +1,209 @@
+%D \module
+%D [ file=s-fonts-ligatures,
+%D version=2014.12.14,
+%D title=\CONTEXT\ Style File,
+%D subtitle=Show Fonts Ligatures,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+% begin info
+%
+% title : show some ligature building in fonts
+%
+% comment : we trace some ligatures that have rather different implementations in fontss
+% status : experimental, used for luatex testing
+%
+% end info
+
+\definefontfeature
+ [otfligaturetest]
+ [analyze=off,
+ ccmp=yes, % brill uses that .. not really ligatures !
+ %clig=yes,
+ script=latn,
+ language=dflt]
+
+\hyphenation{xf-fi-a}
+\hyphenation{xff-i-b}
+\hyphenation{xffi-c}
+\hyphenation{xffid}
+
+\registerhyphenationexception[xf-fi-a]
+\registerhyphenationexception[xff-i-b]
+\registerhyphenationexception[xffi-c]
+\registerhyphenationexception[xffid]
+
+\starttexdefinition showotfligaturescaption #1
+ \bTD [align={flushleft,lohi},nx=3]
+ \nohyphens
+ \ttbf
+ #1
+ \eTD
+\stoptexdefinition
+
+\starttexdefinition showotfligatureslegend #1
+ \bTD [width=6em,align={flushleft,lohi}]
+ \nohyphens \ttxx original
+ \eTD
+ \bTD [width=6em,align={flushleft,lohi}]
+ \nohyphens \ttxx expanded
+ \eTD
+ \bTD [width=6em,align={flushleft,lohi}]
+ \nohyphens \ttxx traditional
+ \eTD
+\stoptexdefinition
+
+\starttexdefinition showotfligaturesline #1#2
+ \bTD[toffset=.5ex,frame=off]
+ \starthyphenation[#1]
+ \LigatureFont
+ \showfontkerns
+ \showdiscretionaries
+ \begstrut#2\endstrut
+ \par
+ \stophyphenation
+ \eTD
+\stoptexdefinition
+
+\def\showotfligaturescells{3}
+%def\showotfligaturesnx {12}
+%def\showotfligatureswidth{18em}
+\def\showotfligaturesnx {\the\numexpr 4*\showotfligaturescells}
+\def\showotfligatureswidth{\the\dimexpr6em*\showotfligaturescells}
+
+\starttexdefinition showotfligaturesbanner #1
+ \bTR[frame=off]
+ \bTD [nx=\showotfligaturesnx,xwidth=\showotfligatureswidth,align={middle,lohi},height=4ex]
+ \tttf #1
+ \eTD
+ \eTR
+\stoptexdefinition
+
+\starttexdefinition showotfligaturescaptions #1
+ \bTR[height=3ex,align={middle,lohi},bottomframe=off]
+ \processcommalist[#1]\showotfligaturescaption
+ \eTR
+ \bTR[height=3ex,align={middle,lohi},topframe=off]
+ \processcommalist[#1]\showotfligatureslegend
+ \eTR
+\stoptexdefinition
+
+\starttexdefinition showotfligatureslineset #1
+ \showotfligaturesline{original} {#1}
+ \showotfligaturesline{expanded} {#1}
+ \showotfligaturesline{traditional}{#1}
+\stoptexdefinition
+
+
+\starttexdefinition showotfligaturesparagraphset #1
+ \showotfligatureslineset {
+ \hsize \zeropoint
+ \lefthyphenmin \plustwo
+ \righthyphenmin\plustwo
+ #1
+ }
+\stoptexdefinition
+
+\starttexdefinition showotfligaturesextremeset #1
+ \showotfligatureslineset {
+ \hsize \zeropoint
+ \lefthyphenmin \plusone
+ \righthyphenmin\plusone
+ #1
+ }
+\stoptexdefinition
+
+\starttexdefinition showotfligatureslines #1
+ \bTR[height=4ex,bottomframe=off]
+ \processcommalist[#1]\showotfligatureslineset
+ \eTR
+\stoptexdefinition
+
+\starttexdefinition showotfligaturesparagraphs #1
+ \bTR[topframe=off]
+ \processcommalist[#1]\showotfligaturesparagraphset
+ \eTR
+\stoptexdefinition
+
+\starttexdefinition showotfligaturesextremes #1
+ \bTR[topframe=off]
+ \processcommalist[#1]\showotfligaturesextremeset
+ \eTR
+\stoptexdefinition
+
+\starttexdefinition showotfligaturesdefaults
+ \bTR
+ \bTD [nx=\showotfligaturesnx,xwidth=\showotfligatureswidth,align=middle,height=4ex,frame=off]
+ \start \LigatureFont fb \stop \quad
+ \start \LigatureFont ff \stop \quad
+ \start \LigatureFont fi \stop \quad
+ \start \LigatureFont fk \stop \quad
+ \start \LigatureFont fl \stop \quad
+ \start \LigatureFont ft \stop \quad
+ \start \LigatureFont ffb \stop \quad
+ \start \LigatureFont fff \stop \quad
+ \start \LigatureFont ffi \stop \quad
+ \start \LigatureFont ffl \stop \quad
+ \start \LigatureFont ffk \stop \quad
+ \start \LigatureFont fft \stop
+ \eTD
+ \eTR
+\stoptexdefinition
+
+\starttexdefinition showotfligaturesexample #1#2
+ \ctxlua{document.currentdiscexpansion = fonts.getdiscexpansion()}%
+ \showotfligaturescaptions {#1}
+ \showotfligatureslines {#2}
+ \showotfligaturesparagraphs{#2}
+ \showotfligaturesextremes {#2}
+ \ctxlua{fonts.setdiscexpansion(document.currentdiscexpansion)}%
+\stoptexdefinition
+
+% todo: n -> and split in lua
+
+\starttexdefinition showotfligaturesexamples
+ \showotfligaturesexample
+ {leafing,baffling,efficient,shifffahrt}
+ {leafing,baffling,efficient,shifffahrt}
+ \showotfligaturesexample
+ {offbeat,effect,ef-fective,ef\-fective}
+ {offbeat,effect,ef-fective,ef\-fective}
+ \showotfligaturesexample
+ {xf+fi+a,xff+i+b,xffi+c,xffid}
+ {xffia, xffib, xffic, xffid}
+\stoptexdefinition
+
+\starttexdefinition showotfligatures [#1]
+ \begingroup
+ \getdummyparameters[font=Regular,features=default,#1]
+ \definefont[LigatureFont][\dummyparameter{font}*\dummyparameter{features},otfligaturetest ht 2ex]
+ \bTABLE[leftframe=off,rightframe=off]
+ \showotfligaturesbanner{\dummyparameter{font} * \dummyparameter{features}}
+ \showotfligaturesdefaults
+ \showotfligaturesexamples
+ \eTABLE
+ \endgroup
+\stoptexdefinition
+
+\continueifinputfile{s-fonts-ligatures.mkiv}
+
+\starttext
+
+ \definefontfeature[fonttest][default] [mode=node,language=dflt,script=latn,ccmp=yes,liga=yes,kern=yes,mark=yes,mkmk=yes]
+ \definefontfeature[capstest][smallcaps][mode=node,language=dflt,script=latn,ccmp=yes,liga=yes,kern=yes,mark=yes,mkmk=yes]
+
+ \startTEXpage[offset=10pt] \showotfligatures[font=lmroman10-regular.otf, features=fonttest] \stopTEXpage
+ \startTEXpage[offset=10pt] \showotfligatures[font=dejavu-serif.ttf, features=fonttest] \stopTEXpage
+ \startTEXpage[offset=10pt] \showotfligatures[font=minionpro.otf, features=fonttest] \stopTEXpage
+ \startTEXpage[offset=10pt] \showotfligatures[font=minionpro.otf, features=capstest] \stopTEXpage
+ \startTEXpage[offset=10pt] \showotfligatures[font=brill.otf, features=fonttest] \stopTEXpage
+ \startTEXpage[offset=10pt] \showotfligatures[font=gentiumplus-r.ttf, features=fonttest] \stopTEXpage
+ \startTEXpage[offset=10pt] \showotfligatures[font=cambria, features=fonttest] \stopTEXpage
+ \startTEXpage[offset=10pt] \showotfligatures[font=ebgaramond12-regular.otf,features=fonttest] \stopTEXpage
+
+\stoptext
diff --git a/Master/texmf-dist/tex/context/modules/mkiv/s-fonts-missing.lua b/Master/texmf-dist/tex/context/modules/mkiv/s-fonts-missing.lua
new file mode 100644
index 00000000000..9a75676a908
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkiv/s-fonts-missing.lua
@@ -0,0 +1,91 @@
+if not modules then modules = { } end modules ['s-fonts-missing'] = {
+ version = 1.001,
+ comment = "companion to s-fonts-missing.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+moduledata.fonts = moduledata.fonts or { }
+moduledata.fonts.missing = moduledata.fonts.missing or { }
+
+local function legend(id)
+ local c = fonts.hashes.identifiers[id]
+ local privates = c.properties.privates
+ if privates then
+ local categories = table.swapped(fonts.loggers.category_to_placeholder)
+ context.starttabulate { "|c|l|" }
+ context.HL()
+ context.NC()
+ context.bold("symbol")
+ context.NC()
+ context.bold("name")
+ context.NC()
+ context.NR()
+ context.HL()
+ for k, v in table.sortedhash(privates) do
+ local tag = characters.categorytags[categories[k]]
+ if tag and tag ~= "" then
+ context.NC()
+ context.dontleavehmode()
+ context.char(v)
+ context.NC()
+ context(k)
+ context.NC()
+ context.NR()
+ end
+ end
+ context.HL()
+ context.stoptabulate()
+ end
+end
+
+function moduledata.fonts.missing.showlegend(specification)
+ specification = interfaces.checkedspecification(specification)
+ context.begingroup()
+ context.definedfont { "Mono*missing" } -- otherwise no privates added
+ context(function() legend(specification.id or font.current()) end)
+ context.endgroup()
+end
+
+local function missings()
+ local collected = fonts.checkers.getmissing()
+ for filename, list in table.sortedhash(collected) do
+ if #list > 0 then
+ context.starttabulate { "|l|l|" }
+ context.NC()
+ context.bold("filename")
+ context.NC()
+ context(file.basename(filename))
+ context.NC()
+ context.NR()
+ context.NC()
+ context.bold("missing")
+ context.NC()
+ context(#list)
+ context.NC()
+ context.NR()
+ context.stoptabulate()
+ context.starttabulate { "|l|c|l|" }
+ for i=1,#list do
+ local u = list[i]
+ context.NC()
+ context("%U",u)
+ context.NC()
+ context.char(u)
+ context.NC()
+ context(characters.data[u].description)
+ context.NC()
+ context.NR()
+ end
+ context.stoptabulate()
+ end
+ end
+end
+
+function moduledata.fonts.missing.showcharacters(specification)
+ context.begingroup()
+ context.definedfont { "Mono*missing" } -- otherwise no privates added
+ context(function() missings() end)
+ context.endgroup()
+end
diff --git a/Master/texmf-dist/tex/context/modules/mkiv/s-fonts-missing.mkiv b/Master/texmf-dist/tex/context/modules/mkiv/s-fonts-missing.mkiv
new file mode 100644
index 00000000000..c566f4995d3
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkiv/s-fonts-missing.mkiv
@@ -0,0 +1,56 @@
+%D \module
+%D [ file=s-fonts-missing,
+%D version=2011.10.30,
+%D title=\CONTEXT\ Style File,
+%D subtitle=Some Missing Character Info,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\startmodule[fonts-missing]
+
+\registerctxluafile{s-fonts-missing}{}
+
+\installmodulecommandluasingle \showmissingcharacterslegend {moduledata.fonts.missing.showlegend}
+\installmodulecommandluasingle \showmissingcharacters {moduledata.fonts.missing.showcharacters}
+
+\stopmodule
+
+\continueifinputfile{s-fonts-missing.mkiv}
+
+% the sooner, the more efficient, see log for details
+
+\enabletrackers[fonts.missing=replace]
+
+% \definefontfeature[default][default][missing=yes] % automatically when enabled
+
+\starttext
+
+ \page legend: \blank
+
+ \showmissingcharacterslegend
+
+ \page sample: \blank
+
+ ½ ⅓ ¼ ⅕ ⅙ ⅛ {\bf ½ ⅓ ¼ ⅕ ⅙ ⅛} \blank
+
+ \startluacode
+ for i=1,1000 do
+ local c = characters.data[i]
+ if c then
+ context.char(c.unicodeslot)
+ context.space()
+ end
+ end
+ \stopluacode
+
+ \page characters: \blank
+
+ \showmissingcharacters
+
+\stoptext
+
diff --git a/Master/texmf-dist/tex/context/modules/mkiv/s-fonts-shapes.lua b/Master/texmf-dist/tex/context/modules/mkiv/s-fonts-shapes.lua
new file mode 100644
index 00000000000..8f872e4bcc5
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkiv/s-fonts-shapes.lua
@@ -0,0 +1,326 @@
+if not modules then modules = { } end modules['s-fonts-shapes'] = {
+ version = 1.001,
+ comment = "companion to s-fonts-shapes.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+moduledata.fonts = moduledata.fonts or { }
+moduledata.fonts.shapes = moduledata.fonts.shapes or { }
+
+local fontdata = fonts.hashes.identifiers
+
+local context = context
+local NC, NR = context.NC, context.NR
+local space, dontleavehmode, glyph, getvalue = context.space, context.dontleavehmode, context.glyph, context.getvalue
+local formatters = string.formatters
+
+function char(id,k)
+ dontleavehmode()
+ glyph(id,k)
+end
+
+local function special(id,specials)
+ if specials and #specials > 1 then
+ context("%s:",specials[1])
+ if #specials > 5 then
+ space() char(id,specials[2])
+ space() char(id,specials[3])
+ space() context("...")
+ space() char(id,specials[#specials-1])
+ space() char(id,specials[#specials])
+ else
+ for i=2,#specials do
+ space() char(id,specials[i])
+ end
+ end
+ end
+end
+
+function moduledata.fonts.shapes.showlist(specification) -- todo: ranges
+ specification = interfaces.checkedspecification(specification)
+ local id, cs = fonts.definers.internal(specification,"")
+ local chrs = fontdata[id].characters
+ context.begingroup()
+ context.tt()
+ context.starttabulate { "|l|c|c|c|c|l|l|" }
+ context.FL()
+ NC() context.bold("unicode")
+ NC() context.bold("glyph")
+ NC() context.bold("shape")
+ NC() context.bold("lower")
+ NC() context.bold("upper")
+ NC() context.bold("specials")
+ NC() context.bold("description")
+ NC() NR()
+ context.TL()
+ for k, v in next, characters.data do
+ if chrs[k] then
+ NC() context("0x%05X",k)
+ NC() char(id,k) -- getvalue(cs) context.char(k)
+ NC() char(id,v.shcode)
+ NC() char(id,v.lccode or k)
+ NC() char(id,v.uccode or k)
+ NC() special(id,v.specials)
+ NC() context.tx(v.description)
+ NC() NR()
+ end
+ end
+ context.stoptabulate()
+ context.endgroup()
+end
+
+function moduledata.fonts.shapes.showlist(specification) -- todo: ranges
+ specification = interfaces.checkedspecification(specification)
+ local id, cs = fonts.definers.internal(specification,"")
+ local chrs = fontdata[id].characters
+ context.begingroup()
+ context.tt()
+ context.starttabulate { "|l|c|c|c|c|l|l|" }
+ context.FL()
+ NC() context.bold("unicode")
+ NC() context.bold("glyph")
+ NC() context.bold("shape")
+ NC() context.bold("lower")
+ NC() context.bold("upper")
+ NC() context.bold("specials")
+ NC() context.bold("description")
+ NC() NR()
+ context.TL()
+ for k, v in next, characters.data do
+ if chrs[k] then
+ NC() context("0x%05X",k)
+ NC() char(id,k)
+ NC() char(id,v.shcode)
+ NC() char(id,v.lccode or k)
+ NC() char(id,v.uccode or k)
+ NC() special(id,v.specials)
+ NC() context.tx(v.description)
+ NC() NR()
+ end
+ end
+ context.stoptabulate()
+ context.endgroup()
+end
+
+local descriptions = nil
+local characters = nil
+
+local function showglyphshape(specification)
+ specification = interfaces.checkedspecification(specification)
+ local id, cs = fonts.definers.internal(specification,"")
+ local tfmdata = fontdata[id]
+ local charnum = tonumber(specification.character)
+ if not charnum then
+ charnum = fonts.helpers.nametoslot(n)
+ end
+ context.start()
+ context.dontleavehmode()
+ context.obeyMPboxdepth()
+ local characters = tfmdata.characters
+ local descriptions = tfmdata.descriptions
+ local parameters = tfmdata.parameters
+ local c = characters[charnum]
+ local d = descriptions[charnum]
+ if d then
+ local factor = (parameters.size/parameters.units)*((7200/7227)/65536)
+ local llx, lly, urx, ury = unpack(d.boundingbox)
+ llx, lly, urx, ury = llx*factor, lly*factor, urx*factor, ury*factor
+ local width, italic = (d.width or 0)*factor, (d.italic or 0)*factor
+ local top_accent, bot_accent = (d.top_accent or 0)*factor, (d.bot_accent or 0)*factor
+ local anchors, math = d.anchors, d.math
+ context.startMPcode()
+ context("numeric lw ; lw := .125bp ;")
+ context("pickup pencircle scaled lw ;")
+ context('picture p ; p := image(draw textext.drt("\\getuvalue{%s}\\gray\\char%s");); draw p ;',cs,charnum)
+ context('draw (%s,%s)--(%s,%s)--(%s,%s)--(%s,%s)--cycle withcolor green ;',llx,lly,urx,lly,urx,ury,llx,ury)
+ context('draw (%s,%s)--(%s,%s) withcolor green ;',llx,0,urx,0)
+ context('draw boundingbox p withcolor .2white withpen pencircle scaled .065bp ;')
+ context("defaultscale := 0.05 ; ")
+ -- inefficient but non critical
+ local function slant_1(v,dx,dy,txt,xsign,ysign,loc,labloc)
+ if #v > 0 then
+ local l = { }
+ for kk, vv in ipairs(v) do
+ local h, k = vv.height, vv.kern
+ if h and k then
+ l[#l+1] = formatters["((%s,%s) shifted (%s,%s))"](xsign*k*factor,ysign*h*factor,dx,dy)
+ end
+ end
+ context("draw ((%s,%s) shifted (%s,%s))--%s dashed (evenly scaled 1/16) withcolor .5white;", xsign*v[1].kern*factor,lly,dx,dy,l[1])
+ context("draw laddered (%s) withcolor .5white ;",table.concat(l,".."))
+ context("draw ((%s,%s) shifted (%s,%s))--%s dashed (evenly scaled 1/16) withcolor .5white;", xsign*v[#v].kern*factor,ury,dx,dy,l[#l])
+ for k, v in ipairs(l) do
+ context("draw %s withcolor blue withpen pencircle scaled 2lw ;",v)
+ end
+ end
+ end
+ local function slant_2(v,dx,dy,txt,xsign,ysign,loc,labloc)
+ if #v > 0 then
+ local l = { }
+ for kk, vv in ipairs(v) do
+ local h, k = vv.height, vv.kern
+ if h and k then
+ l[#l+1] = formatters["((%s,%s) shifted (%s,%s))"](xsign*k*factor,ysign*h*factor,dx,dy)
+ end
+ end
+ if loc == "top" then
+ context('label.%s("\\type{%s}",%s shifted (0,-1bp)) ;',loc,txt,l[#l])
+ else
+ context('label.%s("\\type{%s}",%s shifted (0,2bp)) ;',loc,txt,l[1])
+ end
+ for kk, vv in ipairs(v) do
+ local h, k = vv.height, vv.kern
+ if h and k then
+ context('label.top("(%s,%s)",%s shifted (0,-2bp));',k,h,l[kk])
+ end
+ end
+ end
+ end
+ if math then
+ local kerns = math.kerns
+ if kerns then
+ for _, slant in ipairs { slant_1, slant_2 } do
+ for k,v in pairs(kerns) do
+ if k == "top_right" then
+ slant(v,width+italic,0,k,1,1,"top","ulft")
+ elseif k == "bottom_right" then
+ slant(v,width,0,k,1,1,"bot","lrt")
+ elseif k == "top_left" then
+ slant(v,0,0,k,-1,1,"top","ulft")
+ elseif k == "bottom_left" then
+ slant(v,0,0,k,-1,1,"bot","lrt")
+ end
+ end
+ end
+ end
+ end
+ local function show(x,y,txt)
+ local xx, yy = x*factor, y*factor
+ context("draw (%s,%s) withcolor blue withpen pencircle scaled 2lw ;",xx,yy)
+ context('label.top("\\type{%s}",(%s,%s-2bp)) ;',txt,xx,yy)
+ context('label.bot("(%s,%s)",(%s,%s+2bp)) ;',x,y,xx,yy)
+ end
+ if anchors then
+ local a = anchors.baselig
+ if a then
+ for k, v in pairs(a) do
+ for kk, vv in ipairs(v) do
+ show(vv[1],vv[2],k .. ":" .. kk)
+ end
+ end
+ end
+ local a = anchors.mark
+ if a then
+ for k, v in pairs(a) do
+ show(v[1],v[2],k)
+ end
+ end
+ local a = anchors.basechar
+ if a then
+ for k, v in pairs(a) do
+ show(v[1],v[2],k)
+ end
+ end
+ local ba = anchors.centry
+ if a then
+ for k, v in pairs(a) do
+ show(v[1],v[2],k)
+ end
+ end
+ local a = anchors.cexit
+ if a then
+ for k, v in pairs(a) do
+ show(v[1],v[2],k)
+ end
+ end
+ end
+ if italic ~= 0 then
+ context('draw (%s,%s-1bp)--(%s,%s-0.5bp) withcolor blue ;',width,ury,width,ury)
+ context('draw (%s,%s-1bp)--(%s,%s-0.5bp) withcolor blue ;',width+italic,ury,width+italic,ury)
+ context('draw (%s,%s-1bp)--(%s,%s-1bp) withcolor blue ;',width,ury,width+italic,ury)
+ context('label.lft("\\type{%s}",(%s+2bp,%s-1bp));',"italic",width,ury)
+ context('label.rt("%s",(%s-2bp,%s-1bp));',d.italic,width+italic,ury)
+ end
+ if top_accent ~= 0 then
+ context('draw (%s,%s+1bp)--(%s,%s-1bp) withcolor blue;',top_accent,ury,top_accent,ury)
+ context('label.bot("\\type{%s}",(%s,%s+1bp));',"top_accent",top_accent,ury)
+ context('label.top("%s",(%s,%s-1bp));',d.top_accent,top_accent,ury)
+ end
+ if bot_accent ~= 0 then
+ context('draw (%s,%s+1bp)--(%s,%s-1bp) withcolor blue;',bot_accent,lly,bot_accent,lly)
+ context('label.top("\\type{%s}",(%s,%s-1bp));',"bot_accent",top_accent,ury)
+ context('label.bot("%s",(%s,%s+1bp));',d.bot_accent,bot_accent,lly)
+ end
+ context('draw origin withcolor red withpen pencircle scaled 2lw;')
+ context("setbounds currentpicture to boundingbox currentpicture enlarged 1bp ;")
+ context("currentpicture := currentpicture scaled 8 ;")
+ context.stopMPcode()
+ -- elseif c then
+ -- lastdata, lastunicode = nil, nil
+ -- local factor = (7200/7227)/65536
+ -- context.startMPcode()
+ -- context("pickup pencircle scaled .25bp ; ")
+ -- context('picture p ; p := image(draw textext.drt("\\gray\\char%s");); draw p ;',charnum)
+ -- context('draw boundingbox p withcolor .2white withpen pencircle scaled .065bp ;')
+ -- context("defaultscale := 0.05 ; ")
+ -- local italic, top_accent, bot_accent = (c.italic or 0)*factor, (c.top_accent or 0)*factor, (c.bot_accent or 0)*factor
+ -- local width, height, depth = (c.width or 0)*factor, (c.height or 0)*factor, (c.depth or 0)*factor
+ -- local ury = height
+ -- if italic ~= 0 then
+ -- context('draw (%s,%s-1bp)--(%s,%s-0.5bp) withcolor blue;',width,ury,width,ury)
+ -- context('draw (%s,%s-1bp)--(%s,%s-0.5bp) withcolor blue;',width+italic,ury,width+italic,ury)
+ -- context('draw (%s,%s-1bp)--(%s,%s-1bp) withcolor blue;',width,ury,width+italic,height)
+ -- context('label.lft("\\type{%s}",(%s+2bp,%s-1bp));',"italic",width,height)
+ -- context('label.rt("%6.3f bp",(%s-2bp,%s-1bp));',italic,width+italic,height)
+ -- end
+ -- if top_accent ~= 0 then
+ -- context('draw (%s,%s+1bp)--(%s,%s-1bp) withcolor blue;',top_accent,ury,top_accent,height)
+ -- context('label.bot("\\type{%s}",(%s,%s+1bp));',"top_accent",top_accent,height)
+ -- context('label.top("%6.3f bp",(%s,%s-1bp));',top_accent,top_accent,height)
+ -- end
+ -- if bot_accent ~= 0 then
+ -- context('draw (%s,%s+1bp)--(%s,%s-1bp) withcolor blue;',bot_accent,lly,bot_accent,height)
+ -- context('label.top("\\type{%s}",(%s,%s-1bp));',"bot_accent",top_accent,height)
+ -- context('label.bot("%6.3f bp",(%s,%s+1bp));',bot_accent,bot_accent,height)
+ -- end
+ -- context('draw origin withcolor red withpen pencircle scaled 1bp;')
+ -- context("setbounds currentpicture to boundingbox currentpicture enlarged 1bp ;")
+ -- context("currentpicture := currentpicture scaled 8 ;")
+ -- context.stopMPcode()
+ else
+ lastdata, lastunicode = nil, nil
+ context("no such shape: 0x%05X",charnum)
+ end
+ context.stop()
+end
+
+moduledata.fonts.shapes.showglyphshape = showglyphshape
+
+function moduledata.fonts.shapes.showallglypshapes(specification)
+ specification = interfaces.checkedspecification(specification)
+ local id, cs = fonts.definers.internal(specification,"")
+ local descriptions = fontdata[id].descriptions
+ for unicode, description in fonts.iterators.descriptions(tfmdata) do
+ if unicode >= 0x110000 then
+ break
+ end
+ context.modulefontsstartshowglyphshape(unicode,description.name or "",description.index or 0)
+ showglyphshape { number = id, character = unicode }
+ context.modulefontsstopshowglyphshape()
+ end
+end
+
+function moduledata.fonts.shapes.showlastglyphshapefield(unicode,name)
+ if not descriptions then
+ -- bad news
+ elseif name == "unicode" then
+ context("U+%05X",descriptions.unicode)
+ else
+ local d = descriptions[name]
+ if d then
+ context(d)
+ end
+ end
+end
diff --git a/Master/texmf-dist/tex/context/modules/mkiv/s-fonts-shapes.mkiv b/Master/texmf-dist/tex/context/modules/mkiv/s-fonts-shapes.mkiv
new file mode 100644
index 00000000000..c1e9d61d2d6
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkiv/s-fonts-shapes.mkiv
@@ -0,0 +1,115 @@
+%D \module
+%D [ file=s-fonts-shapes, % s-fnt-29,
+%D version=2010.09.27,
+%D title=\CONTEXT\ Style File,
+%D subtitle=Tracing Shapes,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\startmodule[fonts-shapes]
+
+\registerctxluafile{s-fonts-shapes}{}
+
+\installmodulecommandluasingle \showfontshapes {moduledata.fonts.shapes.showlist}
+\installmodulecommandluasingle \showglyphshape {moduledata.fonts.shapes.showglypshape}
+\installmodulecommandluatwo \showlastglyphshapefield {moduledata.fonts.shapes.showlastglyphshapefield}
+\installmodulecommandluasingle \showallglyphshapes {moduledata.fonts.shapes.showallglypshapes}
+
+\let\modulefontsstartshowglyphshape\gobblethreearguments
+\let\modulefontsstopshowglyphshape \relax
+
+\unprotect
+
+\startsetups module:showallglyphshapes:start
+
+ \unexpanded\def\modulefontsstartshowglyphshape##1##2##3{
+ \startTEXpage[\c!offset=\exheight]
+ \edef\lastshownglyphshapefieldunicode{##1}%
+ \edef\lastshownglyphshapefieldname {##2}%
+ \edef\lastshownglyphshapefieldindex {##3}%
+ \raggedcenter
+ }
+
+ \unexpanded\def\modulefontsstopshowglyphshape {
+ \par
+ \doifsomething {\lastshownglyphshapefieldunicode} {
+ \begingroup
+ \dontleavehmode
+ \tttf
+ \setstrut
+ \strut
+ 0x\uchexnumbers\lastshownglyphshapefieldunicode
+ \space:\space
+ \lastshownglyphshapefieldname
+ \space:\space
+ \lastshownglyphshapefieldindex
+ \par
+ \endgroup
+ }
+ \stopTEXpage
+ }
+
+\stopsetups
+
+\protect
+
+% downward compatibility:
+
+\unexpanded\def\ShowGlyphShape#1#2#3% name size glyph
+ {\ctxlua{moduledata.fonts.shapes.showglyphshape { name = "#1", size = "#2", character = "#3" } }}
+
+\stopmodule
+
+\continueifinputfile{s-fonts-shapes.mkiv}
+
+\setupbodyfont[dejavu,9pt]
+
+\setuplayout
+ [backspace=1cm,
+ topspace=1cm,
+ footer=1cm,
+ header=0cm,
+ height=middle,
+ width=middle]
+
+\setupfootertexts
+ []
+ [\saveddefinedfontname\quad\pagenumber]
+
+\starttext
+
+% \savedefinedfont[Bold*default]
+% \showfontshapes[number=\saveddefinedfontid]
+% \page
+
+% \showfontshapes[name=BoldItalic*default]
+% \page
+
+ % \startTEXpage \ShowGlyphShape{simplenaskhi}{100bp}{0x62A} \stopTEXpage
+ % \startTEXpage \ShowGlyphShape{simplenaskhi}{100bp}{0x2004} \stopTEXpage
+ % \startTEXpage \ShowGlyphShape{simplenaskhi}{100bp}{0xF0299} \stopTEXpage
+ % \startTEXpage \ShowGlyphShape{simplenaskhi}{100bp}{NameMe.1190} \stopTEXpage
+
+% \startTEXpage[offset=0pt]\ShowGlyphShape{name:cambria-math}{20bp}{0x00066}\stopTEXpage
+% \startTEXpage[offset=0pt]\ShowGlyphShape{name:cambria-math}{20bp}{0x1D453}\stopTEXpage
+% \startTEXpage[offset=0pt]\ShowGlyphShape{name:cambria-math}{20bp}{0x1D43F}\stopTEXpage
+% \startTEXpage[offset=0pt]\ShowGlyphShape{name:cambria-math}{50bp}{0x1D444}\stopTEXpage
+% \startTEXpage[offset=0pt]\ShowGlyphShape{name:cambria-math}{50bp}{0x1D447}\stopTEXpage
+% \startTEXpage[offset=0pt]\ShowGlyphShape{name:cambria-math}{50bp}{0x02112}\stopTEXpage
+% \startTEXpage[offset=0pt]\ShowGlyphShape{name:cambria-math}{50bp}{0x1D432}\stopTEXpage
+% \startTEXpage[offset=0pt]\ShowGlyphShape{name:cambria-math}{50bp}{0x1D43D}\stopTEXpage
+% \startTEXpage[offset=0pt]\ShowGlyphShape{name:cambria-math}{50bp}{0x1D44A}\stopTEXpage
+% \startTEXpage[offset=0pt]\ShowGlyphShape{name:cambria-math}{50bp}{0x1D45D}\stopTEXpage
+% \page
+
+ % \showallglyphshapes[name=name:cambria-math,size=100bp]
+% \showallglyphshapes[name=name:dejavuserif,size=100bp]
+
+\showallglyphshapes[name=file:brill.otf,size=100bp]
+
+\stoptext
diff --git a/Master/texmf-dist/tex/context/modules/mkiv/s-fonts-system.lua b/Master/texmf-dist/tex/context/modules/mkiv/s-fonts-system.lua
new file mode 100644
index 00000000000..5b58a4a533f
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkiv/s-fonts-system.lua
@@ -0,0 +1,69 @@
+if not modules then modules = { } end modules ['s-fonts-system'] = {
+ version = 1.001,
+ comment = "companion to s-fonts-system.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+-- ["zapfinoforteltpro"]={
+-- ["designsize"]=0,
+-- ["filename"]="zapfinoforteltpro.otf",
+-- ["fontname"]="zapfinoforteltpro",
+-- ["fontweight"]="regular",
+-- ["family"]="zapfinoforteltpro",
+-- ["subfamily"]="regular",
+-- ["familyname"]="zapfinoforteltpro",
+-- ["subfamilyname"]="regular",
+-- ["format"]="otf",
+-- ["fullname"]="zapfinoforteltpro",
+-- ["maxsize"]=0,
+-- ["minsize"]=0,
+-- ["modification"]=1105543074,
+-- ["rawname"]="ZapfinoForteLTPro",
+-- ["style"]="normal",
+-- ["variant"]="normal",
+-- ["weight"]="normal",
+-- ["width"]="normal",
+-- }
+
+moduledata.fonts = moduledata.fonts or { }
+moduledata.fonts.system = moduledata.fonts.system or { }
+
+local lower = string.lower
+
+local context = context
+local NC, NR, HL = context.NC, context.NR, context.HL
+local bold = context.bold
+
+function moduledata.fonts.system.showinstalled(specification)
+ specification = interfaces.checkedspecification(specification)
+ local pattern = lower(specification.pattern or "")
+ local list = fonts.names.list(pattern,false,true)
+ if list then
+ local files = { }
+ for k, v in next, list do
+ files[file.basename(string.lower(v.filename))] = v
+ end
+ context.starttabulate { "|Tl|Tl|Tl|Tl|Tl|Tl|" }
+ HL()
+ NC() bold("filename")
+ NC() bold("fontname")
+ NC() bold("subfamily")
+ NC() bold("variant")
+ NC() bold("weight")
+ NC() bold("width")
+ NC() NR()
+ HL()
+ for filename, data in table.sortedpairs(files) do
+ NC() context(filename)
+ NC() context(data.fontname)
+ NC() context(data.subfamily)
+ NC() context(data.variant)
+ NC() context(data.weight)
+ NC() context(data.width)
+ NC() NR()
+ end
+ context.stoptabulate()
+ end
+end
diff --git a/Master/texmf-dist/tex/context/modules/mkiv/s-fonts-system.mkiv b/Master/texmf-dist/tex/context/modules/mkiv/s-fonts-system.mkiv
new file mode 100644
index 00000000000..6d9082a6bdc
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkiv/s-fonts-system.mkiv
@@ -0,0 +1,39 @@
+%D \module
+%D [ file=s-fonts0system, % s-fnt-11,
+%D version=2006.02.01, % or so
+%D title=\CONTEXT\ Style File,
+%D subtitle=Listing Installed Fonts,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+%D This code usd to be in the kernel but since it's hardly used
+%D it's now a module.
+%D
+%D \starttyping
+%D \showinstalledfonts[pattern={officinasans.*}]
+%D \showinstalledfonts[pattern={officinaserif.*}]
+%D \showinstalledfonts[pattern={officina.*itc.*}]
+%D \stoptyping
+
+\startmodule[fonts-system]
+
+\registerctxluafile{s-fonts-system}{}
+
+\installmodulecommandluasingle \showinstalledfonts {moduledata.fonts.system.showinstalled}
+
+\stopmodule
+
+\continueifinputfile{s-fonts-system.mkiv}
+
+\usemodule[art-01] \setuplayout[overview] \setupbodyfont[7pt]
+
+\starttext
+
+ \showinstalledfonts
+
+\stoptext
diff --git a/Master/texmf-dist/tex/context/modules/mkiv/s-fonts-tables.lua b/Master/texmf-dist/tex/context/modules/mkiv/s-fonts-tables.lua
new file mode 100644
index 00000000000..c32f4628c17
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkiv/s-fonts-tables.lua
@@ -0,0 +1,363 @@
+if not modules then modules = { } end modules ['s-fonts-tables'] = {
+ version = 1.001,
+ comment = "companion to s-fonts-tables.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+moduledata.fonts = moduledata.fonts or { }
+moduledata.fonts.tables = moduledata.fonts.tables or { }
+
+local setmetatableindex = table.setmetatableindex
+local sortedhash = table.sortedhash
+local sortedkeys = table.sortedkeys
+local format = string.format
+local concat = table.concat
+
+local tabletracers = moduledata.fonts.tables
+
+local context = context
+
+local digits = {
+ dflt = {
+ dflt = "1234567890 1/2",
+ },
+ arab = {
+ dflt = "",
+ },
+ latn = {
+ dflt = "1234567890 1/2",
+ }
+}
+
+local punctuation = {
+ dflt = {
+ dflt = ". , : ; ? ! ‹ › « »",
+ },
+}
+
+local symbols = {
+ dflt = {
+ dflt = "@ # $ % & * () [] {} <> + - = / |",
+ },
+}
+
+local LATN = "abcdefghijklmnopqrstuvwxyz"
+
+local uppercase = {
+ latn = {
+ dflt = LATN,
+ fra = LATN .. " ÀÁÂÈÉÊÒÓÔÙÚÛÆÇ",
+ },
+ grek = {
+ dftl = "ΑΒΓΔΕΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩ",
+ },
+ cyrl= {
+ dflt = "АБВГДЕЖЗИІЙКЛМНОПРСТУФХЦЧШЩЪЫЬѢЭЮЯѲ"
+ },
+}
+
+local latn = "abcdefghijklmnopqrstuvwxyz"
+
+local lowercase = {
+ latn = {
+ dftl = latn,
+ nld = latn .. " ïèéë",
+ deu = latn .. " äöüß",
+ fra = latn .. " àáâèéêòóôùúûæç",
+ },
+ grek = {
+ dftl = "αβγδεηθικλμνξοπρστυφχψω",
+ },
+ cyrl= {
+ dflt = "абвгдежзиійклмнопрстуфхцчшщъыьѣэюяѳ"
+ },
+ arab = {
+ dflt = "ابجدهوزحطيكلمنسعفصقرشتثخذضظغ"
+ },
+}
+
+local samples = {
+ digits = digits,
+ punctuation = punctuation,
+ symbols = symbols,
+ uppercase = uppercase,
+ lowercase = lowercase,
+}
+
+tabletracers.samples = samples
+
+setmetatableindex(uppercase, function(t,k) return rawget(t,"latn") end)
+setmetatableindex(lowercase, function(t,k) return rawget(t,"latn") end)
+setmetatableindex(digits, function(t,k) return rawget(t,"dflt") end)
+setmetatableindex(symbols, function(t,k) return rawget(t,"dflt") end)
+setmetatableindex(punctuation, function(t,k) return rawget(t,"dflt") end)
+
+setmetatableindex(uppercase.latn, function(t,k) return rawget(t,"dflt") end)
+setmetatableindex(uppercase.grek, function(t,k) return rawget(t,"dflt") end)
+setmetatableindex(uppercase.cyrl, function(t,k) return rawget(t,"dflt") end)
+
+setmetatableindex(lowercase.latn, function(t,k) return rawget(t,"dflt") end)
+setmetatableindex(lowercase.grek, function(t,k) return rawget(t,"dflt") end)
+setmetatableindex(lowercase.cyrl, function(t,k) return rawget(t,"dflt") end)
+
+setmetatableindex(digits.dflt, function(t,k) return rawget(t,"dflt") end)
+setmetatableindex(symbols.dflt, function(t,k) return rawget(t,"dflt") end)
+setmetatableindex(punctuation.dflt, function(t,k) return rawget(t,"dflt") end)
+
+local function typesettable(t,keys,synonyms,nesting,prefix)
+ if t then
+ if not prefix then
+ context.starttabulate { "|Tl|Tl|Tl|" }
+ end
+ for k, v in sortedhash(keys) do
+ if k == "synonyms" then
+ elseif type(v) ~= "table" then
+ context.NC()
+ if prefix then
+ context("%s.%s",prefix,k)
+ else
+ context(k)
+ end
+ context.NC()
+ local tk = t[k]
+ if v == "boolean" then
+ context(tostring(tk or false))
+ elseif not tk then
+ context("")
+ elseif v == "filename" then
+ context(file.basename(tk))
+ elseif v == "basepoints" then
+ context("%sbp",tk)
+ elseif v == "scaledpoints" then
+ context("%p",tk)
+ elseif v == "table" then
+ context("
")
+ else -- if v == "integerscale" then
+ context(tostring(tk))
+ end
+ context.NC()
+ local synonym = (not prefix and synonyms[k]) or (prefix and synonyms[format("%s.%s",prefix,k)])
+ if synonym then
+ context(format("(%s)",concat(synonym," ")))
+ end
+ context.NC()
+ context.NR()
+ elseif nesting == false then
+ context("
")
+ else -- true or nil
+ typesettable(t[k],v,synonyms,nesting,k)
+ end
+ end
+ if not prefix then
+ context.stoptabulate()
+ end
+ end
+end
+
+local function typeset(t,keys,nesting,prefix)
+ local synonyms = keys.synonyms or { }
+ local collected = { }
+ for k, v in next, synonyms do
+ local c = collected[v]
+ if not c then
+ c = { }
+ collected[v] = c
+ end
+ c[#c+1] = k
+ end
+ for k, v in next, collected do
+ table.sort(v)
+ end
+ typesettable(t,keys,collected,nesting,prefix)
+end
+
+tabletracers.typeset = typeset
+
+function tabletracers.showproperties(nesting)
+ local tfmdata = fonts.hashes.identifiers[font.current()]
+ typeset(tfmdata.properties,fonts.constructors.keys.properties,nesting)
+end
+
+function tabletracers.showparameters(nesting)
+ local tfmdata = fonts.hashes.identifiers[font.current()]
+ typeset(tfmdata.parameters,fonts.constructors.keys.parameters,nesting)
+end
+
+function tabletracers.showpositionings()
+ local tfmdata = fonts.hashes.resources[font.current()]
+ local resources = tfmdata.resources
+ if resources then
+ local features = resources.features
+ if features then
+ local gpos = features.gpos
+ if gpos and next(gpos) then
+ context.starttabulate { "|Tl|Tl|Tlp|" }
+ for feature, scripts in sortedhash(gpos) do
+ for script, languages in sortedhash(scripts) do
+ context.NC()
+ context(feature)
+ context.NC()
+ context(script)
+ context.NC()
+ context(concat(sortedkeys(languages)," "))
+ context.NC()
+ context.NR()
+ end
+ end
+ context.stoptabulate()
+ else
+ context("no entries")
+ context.par()
+ end
+ end
+ end
+end
+
+local dynamics = true
+
+function tabletracers.showsubstitutions()
+ local tfmdata = fonts.hashes.identifiers[font.current()]
+ local resources = tfmdata.resources
+ if resources then
+ local features = resources.features
+ if features then
+ local gsub = features.gsub
+ if gsub then
+ local makes_sense = { }
+ for feature, scripts in sortedhash(gsub) do
+ for script, languages in sortedhash(scripts) do
+ for language in sortedhash(languages) do
+ local tag = format("dummy-%s-%s-%s",feature,script,language)
+ local fnt = format("file:%s*%s",file.basename(tfmdata.properties.filename),tag)
+ context.definefontfeature (
+ { tag },
+ {
+ mode = "node",
+ script = script,
+ language = language,
+ [feature] = "yes"
+ }
+ )
+ if not dynamics then
+ context.definefont( { fnt }, { fnt } )
+ end
+ makes_sense[#makes_sense+1] = {
+ feature = feature,
+ tag = tag,
+ script = script,
+ language = language,
+ fontname = fnt,
+ }
+ end
+ end
+ end
+ if #makes_sense > 0 then
+ context.starttabulate { "|Tl|Tl|Tl|p|" }
+ for i=1,#makes_sense do
+ local data = makes_sense[i]
+ local script = data.script
+ local language = data.language
+ context.NC()
+ context(data.feature)
+ context.NC()
+ context(script)
+ context.NC()
+ context(language)
+ context.NC()
+ if not dynamics then
+ context.startfont { data.fontname }
+ else
+ context.addff(data.tag)
+ end
+ context.verbatim(samples.lowercase [script][language]) context.par()
+ context.verbatim(samples.uppercase [script][language]) context.par()
+ context.verbatim(samples.digits [script][language]) context.par()
+ context.verbatim(samples.punctuation[script][language]) context.quad()
+ context.verbatim(samples.symbols [script][language])
+ if not dynamics then
+ context.stopfont()
+ end
+ context.NC()
+ context.NR()
+ end
+ context.stoptabulate()
+ else
+ context("no entries")
+ context.par()
+ end
+ end
+ end
+ end
+end
+
+function tabletracers.showunicodevariants()
+
+ local variants = fonts.hashes.variants[true]
+
+ if variants then
+ context.starttabulate { "|c|c|c|c|c|c|c|" }
+ for selector, unicodes in sortedhash(variants) do
+ local done = false
+ for unicode, variant in sortedhash(unicodes) do
+ context.NC()
+ if not done then
+ context("%U",selector)
+ done = true
+ end
+ context.NC()
+ context("%U",unicode)
+ context.NC()
+ context("%c",unicode)
+ context.NC()
+ context("%U",variant)
+ context.NC()
+ context("%c",variant)
+ context.NC()
+ context("%c%c",unicode,selector)
+ context.NC()
+ context.startoverlay()
+ context("{\\color[trace:r]{%c}}{\\color[trace:ds]{%c}}",unicode,variant)
+ context.stopoverlay()
+ context.NC()
+ context.NR()
+ end
+ end
+ context.stoptabulate()
+ end
+
+end
+function tabletracers.showall(specification) -- not interfaced
+
+ specification = interfaces.checkedspecification(specification)
+
+ if specification.title then
+ context.starttitle { title = specification.title }
+ end
+
+ context.startsubject { title = "Properties" }
+ tabletracers.showproperties()
+ context.stopsubject()
+
+ context.startsubject { title = "Parameters" }
+ tabletracers.showparameters()
+ context.stopsubject()
+
+ context.startsubject { title = "Positioning features" }
+ tabletracers.showpositionings()
+ context.stopsubject()
+
+ context.startsubject { title = "Substitution features" }
+ tabletracers.showsubstitutions()
+ context.stopsubject()
+
+ context.startsubject { title = "Unicode variants" }
+ tabletracers.showunicodevariants()
+ context.stopsubject()
+
+ if title then
+ context.stoptitle()
+ end
+
+end
diff --git a/Master/texmf-dist/tex/context/modules/mkiv/s-fonts-tables.mkiv b/Master/texmf-dist/tex/context/modules/mkiv/s-fonts-tables.mkiv
new file mode 100644
index 00000000000..64fe76f0e4b
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkiv/s-fonts-tables.mkiv
@@ -0,0 +1,38 @@
+%D \module
+%D [ file=s-fonts-tables,
+%D version=2011.10.10,
+%D title=\CONTEXT\ Style File,
+%D subtitle=Basic Font Data Tables,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+% todo: make a mtxrun --script font option
+
+\startmodule[fonts-tables]
+
+\registerctxluafile{s-fonts-tables}{}
+
+\installmodulecommandluasingle \showfonttables {moduledata.fonts.tables.showall}
+\installmodulecommandluasingle \showfontproperties {moduledata.fonts.tables.showproperties}
+\installmodulecommandluasingle \showfontparameters {moduledata.fonts.tables.showparameters}
+\installmodulecommandluasingle \showfontpositionings {moduledata.fonts.tables.showpositionings}
+\installmodulecommandluasingle \showfontsubstitutions {moduledata.fonts.tables.showsubstitutions}
+\installmodulecommandluasingle \showfontunicodevariants{moduledata.fonts.tables.showunicodevariants}
+
+\stopmodule
+
+\continueifinputfile{s-fonts-tables.mkiv}
+
+\usemodule[art-01]
+
+\setupbodyfont
+ [cambria]
+
+\starttext
+ \showfonttables[title=Cambria]
+\stoptext
diff --git a/Master/texmf-dist/tex/context/modules/mkiv/s-fonts-vectors.lua b/Master/texmf-dist/tex/context/modules/mkiv/s-fonts-vectors.lua
new file mode 100644
index 00000000000..af8042f8458
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkiv/s-fonts-vectors.lua
@@ -0,0 +1,104 @@
+if not modules then modules = { } end modules ['s-fonts-vectors'] = {
+ version = 1.001,
+ comment = "companion to s-fonts-vectors.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+moduledata.fonts = moduledata.fonts or { }
+moduledata.fonts.protrusions = moduledata.fonts.protrusions or { }
+moduledata.fonts.expansions = moduledata.fonts.expansions or { }
+
+local NC, NR = context.NC, context.NR
+
+local classes = fonts.protrusions.classes
+local vectors = fonts.protrusions.vectors
+
+function moduledata.fonts.protrusions.showvector(specification)
+ specification = interfaces.checkedspecification(specification)
+ local vector = vectors[specification.name or "?"]
+ if vector then
+ context.blank()
+ context.startcolumns { n = specification.columns or 3, balance="yes" }
+ context.starttabulate { "|T||cw(.5em)||" }
+ for unicode, values in table.sortedhash(vector) do
+ NC() context("%U",unicode)
+ NC() context("%.02f",values[1])
+ NC() context("%c",unicode)
+ NC() context("%.02f",values[2])
+ NC() NR()
+ end
+ context.stoptabulate()
+ context.stopcolumns()
+ context.blank()
+ end
+end
+
+function moduledata.fonts.protrusions.showclass(specification)
+ specification = interfaces.checkedspecification(specification)
+ local class = specification.name and classes[specification.name]
+ local classes = class and { class} or classes
+ context.starttabulate { "|l|l|r|r|r|" }
+ NC() context.bold("name")
+ NC() context.bold("vector")
+ NC() context.bold("factor")
+ NC() context.bold("left")
+ NC() context.bold("right")
+ NC() NR()
+ for name, class in table.sortedhash(classes) do
+ NC() context(name)
+ NC() context(class.vector)
+ NC() context("%.02f",class.factor)
+ NC() context("%.02f",class.left)
+ NC() context("%.02f",class.right)
+ NC() NR()
+ end
+ context.stoptabulate()
+end
+
+local classes = fonts.expansions.classes
+local vectors = fonts.expansions.vectors
+
+function moduledata.fonts.expansions.showvector(specification)
+ specification = interfaces.checkedspecification(specification)
+ local vector = vectors[specification.name or "?"]
+ if vector then
+ context.blank()
+ context.startcolumns { n = specification.columns or 3, balance="yes" }
+ context.starttabulate { "|T|cw(.5em)||" }
+ for unicode, value in table.sortedhash(vector) do
+ NC() context("%U",unicode)
+ NC() context("%c",unicode)
+ NC() context("%.02f",value)
+ NC() NR()
+ end
+ context.stoptabulate()
+ context.stopcolumns()
+ context.blank()
+ end
+end
+
+function moduledata.fonts.expansions.showclass(specification)
+ specification = interfaces.checkedspecification(specification)
+ local class = specification.name and classes[specification.name]
+ local classes = class and { class} or classes
+ context.starttabulate { "|l|l|r|r|r|" }
+ NC() context.bold("name")
+ NC() context.bold("vector")
+ NC() context.bold("step")
+ NC() context.bold("factor")
+ NC() context.bold("stretch")
+ NC() context.bold("shrink")
+ NC() NR()
+ for name, class in table.sortedhash(classes) do
+ NC() context(name)
+ NC() context(class.vector)
+ NC() context("%.02f",class.step)
+ NC() context("%.02f",class.factor)
+ NC() context("% 2i",class.stretch)
+ NC() context("% 2i",class.shrink)
+ NC() NR()
+ end
+ context.stoptabulate()
+end
diff --git a/Master/texmf-dist/tex/context/modules/mkiv/s-fonts-vectors.mkiv b/Master/texmf-dist/tex/context/modules/mkiv/s-fonts-vectors.mkiv
new file mode 100644
index 00000000000..2605fe96403
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkiv/s-fonts-vectors.mkiv
@@ -0,0 +1,72 @@
+%D \module
+%D [ file=s-fonts-vectors, % was s-fnt-51,
+%D version=2012.11.27,
+%D title=\CONTEXT\ Style File,
+%D subtitle=Protrusion and Expansion,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+%D This code is used in the \MKIV\ fonts manual.
+
+\startmodule[fonts-vectors]
+
+\registerctxluafile{s-fonts-vectors}{}
+
+\installmodulecommandluasingle \showprotrusionclass {moduledata.fonts.protrusions.showclass}
+\installmodulecommandluasingle \showprotrusionvector {moduledata.fonts.protrusions.showvector}
+\installmodulecommandluasingle \showexpansionclass {moduledata.fonts.expansions.showclass}
+\installmodulecommandluasingle \showexpansionvector {moduledata.fonts.expansions.showvector}
+
+\stopmodule
+
+\continueifinputfile{s-fonts-vectors.mkiv}
+
+\usemodule[art-01]
+
+\starttext
+
+ \startsubject[title=protrusion]
+
+ \startsubsubject[title=class]
+ \showprotrusionclass
+ \stopsubsubject
+
+ \startsubsubject[title=vector pure]
+ \showprotrusionvector[name=pure]
+ \stopsubsubject
+
+ \startsubsubject[title=vector punctuation]
+ \showprotrusionvector[name=punctuation]
+ \stopsubsubject
+
+ \startsubsubject[title=vector alpha]
+ \showprotrusionvector[name=alpha]
+ \stopsubsubject
+
+ \startsubsubject[title=vector quality]
+ \showprotrusionvector[name=quality]
+ \stopsubsubject
+
+ \stopsubject
+
+ \page
+
+ \startsubject[title=expansion]
+
+ \startsubsubject[title=class]
+ \showprotrusionclass
+ \stopsubsubject
+
+ \startsubsubject[title=vector quality]
+ \showprotrusionvector[name=quality]
+ \stopsubsubject
+
+ \stopsubject
+
+\stoptext
+
diff --git a/Master/texmf-dist/tex/context/modules/mkiv/s-inf-01.mkvi b/Master/texmf-dist/tex/context/modules/mkiv/s-inf-01.mkvi
new file mode 100644
index 00000000000..2c0c1681e12
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkiv/s-inf-01.mkvi
@@ -0,0 +1,260 @@
+%D \module
+%D [ file=s-inf-01,
+%D version=2009.07.09,
+%D title=\CONTEXT\ Style File,
+%D subtitle=Information 1 (\MKII/\MKIV\ usage),
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+%D Some day I will generalize this table mechanism. This list is only
+%D right when run in the minimals as my machine might have more files.
+%D
+%D Als, the remaining tex code can proably be lua also which is more
+%D consistent.
+%D
+%D \starttyping
+%D context auto:s-inf-01
+%D context auto:s-inf-01 --basepath=t:/texmf/tex/context/base
+%D \stoptyping
+
+% \enabletrackers[context.*]
+
+\startluacode
+ local format, gsub, find, match = string.format, string.gsub, string.find, string.match
+
+ local list, size, comp, used, nope = { }, { }, { }, { mkii = { }, mkiv = { }, mkvi = { } }, { 0, 0, 0, 0, 0 }
+
+ local omit = {
+ "char%-def%.lua",
+ "mult%-def%.lua", "mult%-..%.mkii", "mult%-m..%.mkii",
+ }
+ local skip = {
+ "prag%-.*%.tex", "docs%-.*.tex", "list%-.*%.tex", "test%-.*%.tex", "demo%-.*%.tex",
+ "opti%-.*%.tex", "chrt%-.*%.tex", ".*%-old", ".*%-obs", ".*%-tst", "supp%-.*%.tex",
+ "colo%-pan.tex", ".*test.*"
+ }
+ local types = {
+ "tex", "mkii", "mkiv", "mkvi", "lua"
+ }
+ local patterns = {
+ "^([a-z][a-z][a-z][a-z])%-[a-z0-9%-]+%.[a-z]+",
+ "^([xms])%-[a-z0-9%-]+%.[a-z]+",
+ }
+
+ local function collect(list,suffix,n)
+ local path = document.arguments.basepath or file.dirname(resolvers.find_file("context.mkiv"),".")
+ local pattern = path .. "/*." .. suffix .. "$" -- avoid bla.tex~
+ local texfiles = dir.glob(pattern)
+ for i=1,#texfiles do
+ local name = texfiles[i]
+ local base = file.basename(name)
+ for p=1,#patterns do
+ local category = match(base,patterns[p])
+ if category and lfs.isfile(name) then
+ local okay = true
+ for s=1,#skip do
+ if find(base,skip[s]) then
+ okay = false
+ break
+ end
+ end
+ if okay then
+ local lm, sm, cm = list[category], size[category], comp[category]
+ if not lm then
+ lm, sm, cm = { 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0 }
+ list[category], size[category], comp[category] = lm, sm, cm
+ end
+ lm[n] = lm[n] + 1
+ local done = true
+ for o=1,#omit do
+ if find(base,omit[o]) then
+ done = false
+ break
+ end
+ end
+ local data = io.loaddata(name)
+ if data then
+ if suffix == "lua" then
+ data = gsub(data,"%-%-%[%[.-%]%]%-%-","")
+ data = gsub(data,"%-%-.-[\n\r]","")
+ else
+ data = gsub(data,"%%.-[\n\r]","")
+ end
+ data = gsub(data,"%s","")
+ else
+ logs.report("error","unknown file %a",name)
+ data = ""
+ end
+ sm[n+5] = sm[n+5] + #data
+ if done then
+ sm[n] = sm[n] + #data
+ else
+ cm[n] = cm[n] + 1
+ end
+ end
+ end
+ end
+ end
+ end
+
+ local function prepare(what)
+ if next(list) then
+ -- already loaded
+ else
+ for i=1,#types do
+ collect(list,types[i],i)
+ end
+ for category in next, list do
+ pattern ="{"..category.."%-"
+ for suffix, t in next, used do
+ local data = io.loaddata(resolvers.find_file("context."..suffix))
+ if data and find(data,pattern) then
+ t[category] = true
+ end
+ end
+ end
+ end
+ local max, what = 0, (what == "size" and size) or list
+ for k, v in table.sortedpairs(what) do
+ for i=1,5 do if v[i] > max then max = v[i] end end
+ end
+ return max, what, function(n) return (max == 0 and 0) or (n == 0 and 0) or n/max end
+ end
+
+ local f_norm = string.formatters["%0.3f"]
+
+ function document.context_state_1(what)
+ local max, what, norm = prepare(what)
+ context.starttabulate { "|Tl|T|T|T|T|T|" }
+ context.NC()
+ context(category)
+ context.NC()
+ for i=1,#types do
+ local n, m = 0, 0
+ for k, v in next, list do
+ local nn, mm = what[k][i], what[k][i+5]
+ n = n + nn
+ m = m + (mm or nn)
+ end
+ context.Top(types[i],norm(max),n,m)
+ context.NC()
+ end
+ context.NC()
+ context.NR()
+ context.HL()
+ for k, v in table.sortedpairs(what) do
+ local c = what == size and comp[k] or nope
+ context.NC()
+ context("%s~%s~~%s~~%s",
+ (used.mkii[k] and "ii") or "~~",
+ (used.mkiv[k] and "iv") or "~~",
+ (used.mkvi[k] and "vi") or "~~",
+ k
+ )
+ -- context("%s\\enspace %s\\quad %s\\quad %s",
+ -- (used.mkii[k] and "ii") or "\\quad",
+ -- (used.mkiv[k] and "iv") or "\\quad",
+ -- (used.mkvi[k] and "vi") or "\\quad",
+ -- k
+ -- )
+ context.NC()
+ for i=1,#types do
+ context.Bar(types[i],v[i],c[i],f_norm(norm(v[i])))
+ context.NC()
+ end
+ context.NR()
+ end
+ context.stoptabulate()
+ end
+
+ function document.context_state_2(what)
+ local max, what, norm = prepare(what)
+ for k, v in table.sortedpairs(what) do
+ local c = (what == size and comp[k]) or nope
+ context.StartUp(k)
+ for i=1,#types do
+ context.Up(types[i],f_norm(norm(v[i])))
+ end
+ context.StopUp()
+ end
+ end
+
+\stopluacode
+
+\definecolor[bar:tex] [middlegreen]
+\definecolor[bar:mkii][middleblue]
+\definecolor[bar:mkiv][middlered]
+\definecolor[bar:mkvi][middleyellow]
+\definecolor[bar:lua] [middlegray]
+
+\newcount\UpCounter
+
+\starttexdefinition Top #what#fraction#total#bigones
+ \hbox to 5em{\hss#total}%
+ \enspace
+ \hbox {#what\ifnum#total=#bigones\else~#bigones\rlap{~+}\fi\hss}%
+\stoptexdefinition
+
+\starttexdefinition Bar #color#size#nobigones#fraction
+ \ifcase#size\else
+ \hbox to 5em{\hss\ifcase#nobigones\else\llap{-~}\fi#size}%
+ \enspace
+ \blackrule[color=bar:#color,width=#fraction\dimexpr 20em\relax,height=.8\strutht]%
+ \fi
+\stoptexdefinition
+
+\starttexdefinition StartUp #name
+ \def\UpName{#name}%
+ \dontleavehmode\framed[frame=off,align={middle,low},height=18em]\bgroup
+\stoptexdefinition
+
+\starttexdefinition StopUp
+ \par\nointerlineskip\blackrule[height=1pt,width=5em,depth=0pt,color=darkgray]
+ \par\tttf\strut\UpName\par
+ \egroup
+ \ifnum\UpCounter=17
+ \par \UpCounter\zerocount
+ \else
+ \kern1em \advance\UpCounter\plusone
+ \fi
+\stoptexdefinition
+
+\starttexdefinition Up #color#width
+ \scratchdimen#width\dimexpr 16em\relax
+ \ifdim\scratchdimen=\zeropoint
+ \kern1em
+ \else
+ \ifdim\scratchdimen<\onepoint \scratchdimen\onepoint \fi
+ \blackrule[color=bar:#color,height=\scratchdimen,width=1em]%
+ \fi
+\stoptexdefinition
+
+\starttexdefinition Show #title#how#what
+ \startTEXpage[offset=1em,width=fit]
+ \hbox{\tttf\strut\currentdate~-~#title}
+ \par
+ \ctxlua{document.context_state_\number#how("#what")}
+ \stopTEXpage
+\stoptexdefinition
+
+% \continueifinputfile{s-inf-01.mkvi}
+
+\starttext
+ \Show
+ {The number of files used in ConTeXt (base modules and styles).}
+ {1}{number}
+ \Show
+ {The size of (core) files used in ConTeXt (- indicates exclusion of large data files; + indicates inclusion of large data files; comment and spaces removed.)}
+ {1}{size}
+ \Show
+ {The relative number of files used in ConTeXt (tex, mkii, mkiv, mkvi, lua).}
+ {2}{number}
+ \Show
+ {The relative size of files used in ConTeXt (tex, mkii, mkiv, mkvi, lua).}
+ {2}{size}
+\stoptext
diff --git a/Master/texmf-dist/tex/context/modules/mkiv/s-inf-02.mkiv b/Master/texmf-dist/tex/context/modules/mkiv/s-inf-02.mkiv
new file mode 100644
index 00000000000..cf8d572bca2
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkiv/s-inf-02.mkiv
@@ -0,0 +1,27 @@
+%D \module
+%D [ file=s-inf-02,
+%D version=2009.11.25,
+%D title=\CONTEXT\ Style File,
+%D subtitle=Information 2 (filenames),
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\starttext
+
+\starttabulate [|T|T|]
+ \NC \type{\jobname} \NC \jobname \NC \NR
+ \NC \type{\jobfilename} \NC \jobfilename \NC \NR
+ \NC \type{\jobfilesuffix} \NC \jobfilesuffix \NC \NR
+ \NC \type{\inputfilename} \NC \inputfilename \NC \NR
+ \NC \type{\inputfilebarename} \NC \inputfilebarename \NC \NR
+ \NC \type{\inputfilesuffix} \NC \inputfilesuffix \NC \NR
+ \NC \type{\outputfilename} \NC \outputfilename \NC \NR
+ \NC \type{\operatingsystem} \NC \operatingsystem \NC \NR
+\stoptabulate
+
+\stoptext
diff --git a/Master/texmf-dist/tex/context/modules/mkiv/s-inf-03.mkiv b/Master/texmf-dist/tex/context/modules/mkiv/s-inf-03.mkiv
new file mode 100644
index 00000000000..a253bed773c
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkiv/s-inf-03.mkiv
@@ -0,0 +1,372 @@
+% \nopdfcompression
+
+% \starttext
+% There is a loop somewhere ... todo.
+% \stoptext
+
+\enablemode[tablet] % whatever that means
+
+\setupbodyfont[dejavu]
+
+\doifelsemode {tablet} {
+
+ \setuppapersize
+ [S6,landscape]
+ [S6,landscape]
+
+ \definefont
+ [TitlePageFont]
+ [MonoBold at 15pt]
+
+ \setupbodyfont
+ [tt,8pt]
+
+} {
+
+ \definefont
+ [TitlePageFont]
+ [MonoBold at 18pt]
+
+ \setupbodyfont
+ [tt]
+
+}
+
+\setuplayout
+ [header=0cm,
+ footer=1cm,
+ backspace=.5cm,
+ topspace=.5cm,
+ width=middle,
+ height=middle]
+
+\setuphead
+ [title]
+ [style=\ttc,
+ interaction=reference]
+
+\definehead
+ [xtitle]
+ [title]
+
+\setuphead
+ [xtitle]
+ [color=darkgreen]
+
+\setupfootertexts
+ [\llap{\goto{\hbox to 5cm{\hss previous}}[previouspage]}%
+ \quad\pagenumber\quad
+ \rlap{\goto{\hbox to 5cm{next\hss}}[nextpage]}]
+
+\setupinteraction
+ [state=start,
+ style=,
+ color=,
+ title={ConTeXt MkIV},
+ subtitle={Lua modules and functions},
+ author={Hans Hagen - automatically generated},
+ contrastcolor=]
+
+\setupinteractionscreen
+ [option=bookmark]
+
+\placebookmarks
+ [title,xtitle]
+ [force=yes]
+
+\definecolor[darkyellow][r=.5,g=.5,b=0]
+\definecolor[darkgray] [s=.15]
+
+\nonknuthmode
+
+\starttext
+
+\startbuffer
+\startluacode
+local basiclua = libraries.basiclua
+local basictex = libraries.basictex
+local extratex = libraries.extratex
+local extralua = libraries.extralua
+local obsolete = libraries.obsolete
+
+local find = string.find
+local color, gotolocation = context.color, context["goto"]
+
+for k, v in table.sortedpairs(_G) do
+ if obsolete[k] or find(k,"_") or k == "arg" or k == "utf" then
+ --
+ elseif basiclua[k] then
+ gotolocation(function() color( { "darkred" }, k) end, { k } )
+ elseif extralua[k] then
+ gotolocation(function() color( { "darkgreen" }, k) end, { k } )
+ elseif basictex[k] then
+ gotolocation(function() color( { "darkblue" }, k) end, { k } )
+ elseif extratex[k] then
+ gotolocation(function() color( { "darkyellow" }, k) end, { k } )
+ elseif type(v) == "table" then
+ gotolocation(function() color( { "white" }, k) end, { k } )
+ end
+ context(" ")
+end
+\stopluacode
+\stopbuffer
+
+\setupbackgrounds
+ [page]
+ [background=color,
+ backgroundcolor=darkgray,
+ backgroundoffset=2mm]
+
+\startpagemakeup
+ \vfill
+ \pagereference[global]
+ \startnarrower[10mm]
+ \setupalign[nothyhenated,middle,broad]
+ \TitlePageFont \setupinterlinespace
+ \getbuffer % luabuffer
+ \par
+ \stopnarrower
+ \vfill
+ \vfill
+ \hskip10mm\scale[width=\dimexpr\paperwidth-20mm\relax]{\ttbf\white\ConTeXt\ MkIV}
+ \par
+ % \hskip10mm\scale[width=\dimexpr\paperwidth-20mm\relax]{\white \strut Lua infrastructure \emdash\ \currentdate}
+ \vfill
+\stoppagemakeup
+
+\setupbackgrounds
+ [page]
+ [background=]
+
+\startluacode
+local builtin = libraries.builtin
+local globals = libraries.globals
+local basiclua = libraries.basiclua
+local basictex = libraries.basictex
+local extratex = libraries.extratex
+local extralua = libraries.extralua
+local obsolete = libraries.obsolete
+
+local sortedkeys = table.sortedkeys
+local mark = storage.mark
+local marked = storage.marked
+local gsub = string.gsub
+local sub = string.sub
+local byte = string.byte
+local upper = string.upper
+
+local skipglobal = table.tohash {
+ "_G", "_M", "_ENV", "",
+ "context", "modules", "global", "arg", "utf", 1,
+ "_ptbs_", "_pcol_", "_plib_", "_clib_", "_tlib_",
+ "kpse", "commands",
+}
+
+local skipkeys = table.tohash {
+ "_pcol_", "_plib_", "_clib_", "_tlib_", "_bpnf_", "_ptbs_",
+ "_cldf_", "_cldn_", "_cldo_",
+ "_clmb_", "_clme_", "_clmm_", "_clmn_", "_clma_", "_clmh_",
+ "_G", "_M", "_ENV", "",
+ -- "global", "shortcuts",
+ "_VERSION", "_COPYRIGHT", "_DESCRIPTION", "_NAME", "_PACKAGE", "__unload",
+}
+
+local sameglobal = {
+ ["global"] = "_G",
+ -- ["commands"] = "cs", -- already gone
+}
+
+-- -- -- -- -- -- -- -- -- -- -- -- --
+-- this should be done internally
+-- -- -- -- -- -- -- -- -- -- -- -- --
+
+for k,v in next, modules do
+ mark(v)
+end
+
+mark(document.arguments)
+mark(environment.arguments)
+mark(environment.engineflags)
+mark(characters.data)
+
+-- -- -- -- -- -- -- -- -- -- -- -- --
+-- -- -- -- -- -- -- -- -- -- -- -- --
+
+local variant = 1 -- all parents
+local variant = 2 -- parent name too
+local variant = 3 -- no parents
+
+local done = { }
+
+local function childtables(key,tab,handler,depth)
+ depth = depth or 1
+ local keys = sortedkeys(tab) -- no sorted_pairs
+ for i=1,#keys do
+ local k = keys[i]
+-- if k ~= "_G" and k ~= "_M" and type(k) == "string" then
+ if not skipkeys[k] and type(k) == "string" then
+ local v = tab[k]
+ local t = type(v)
+ local s = k
+ if variant ~= 3 then
+ s = key and (key .. "." .. s) or s
+ end
+ if t == "table" then
+ if marked(v) then
+ t = "data"
+ handler(s,t,depth)
+ else
+if done[v] then
+ -- logs.report("inf-03","key %a in %a already done",k,v)
+else
+ done[v] = true
+ handler(s,t,depth)
+ if variant == 3 then
+ childtables(false,v,handler,depth+1)
+ elseif variant == 2 then
+ childtables(k,v,handler,depth+1)
+ else
+ childtables(s,v,handler,depth+1)
+ end
+ end
+end
+ else
+ handler(s,t,depth)
+ end
+ end
+ end
+end
+
+local NC, NR = context.NC, context.NR
+local overstrike, rlap, bf = context.overstrike, context.rlap, context.bf
+local color, gotolocation = context.color, context["goto"]
+
+local function cleanup(s)
+ return "\\char" ..byte(s) .. " "
+end
+
+local function handler(k,t,depth)
+ k = gsub(k,"([~#$%%^&{}\\|])",cleanup)
+ NC() rlap("\\quad\\tx\\kern" .. (depth or 0).. "em" .. upper(sub(t,1,1)) .. " ".. k) NC() NC() NR()
+end
+
+local function show(title,subtitle,alias,builtin,t,lib,libcolor,glo,glocolor,mark,obsolete)
+ -- todo: table as argument
+-- print(title,subtitle,alias,builtin,t,lib,libcolor,glo,glocolor,mark,obsolete)
+ local keys = sortedkeys(t) -- no sorted_pairs
+ if #keys > 0 then
+ local fulltitle = title
+ if subtitle and subtitle ~= "" then
+ fulltitle = fulltitle .. " (" .. subtitle .. ")"
+ end
+ if alias and alias ~= "" then
+ fulltitle = fulltitle .. " (alias: " .. alias .. ")"
+ end
+ if builtin then
+ context.startxtitle { reference = title, title = fulltitle, backreference = "global" }
+ else
+ context.starttitle { reference = title, title = fulltitle, backreference = "global" }
+ end
+ context.startcolumns { n = 2 }
+ context.starttabulate { "|||" }
+ local t_obsolete = t.obsolete
+ if type(t_obsolete) ~= "table" then
+ t_obsolete = nil
+ end
+ for i=1,#keys do
+ local k = keys[i]
+ local v = t[k]
+ if k and k ~= "obsolete" and not skipkeys[k] and (not obsolete or not obsolete[k]) then
+ local inlib = lib and lib[k]
+ local inglo = glo and glo[k]
+ local t = type(v)
+ local kstr, tstr = k, t
+ local obs = t_obsolete and t_obsolete[k]
+ if obs then
+ tstr = function() overstrike(t) end
+ kstr = function() overstrike(k) end
+ end
+ local marked = marked(v)
+ if marked then
+ tstr = "data table"
+ end
+ if t == "table" then
+ local m = getmetatable(v)
+ if m and m.__call then
+ tstr = "function"
+ end
+ end
+ if not mark then
+ --
+ elseif inlib and tostring(inlib) ~= tostring(v) then
+ tstr = "overloaded ".. tstr
+ elseif inglo and tostring(inglo) ~= tostring(v) then
+ tstr = "overloaded ".. tstr
+ end
+ NC() bf()
+ if inlib then
+ if not mark and t == "table" then
+ gotolocation(function() color( { libcolor }, kstr) end, { k } )
+ else
+ color( { libcolor }, kstr)
+ end
+ elseif inglo then
+ if not mark and t == "table" then
+ gotolocation(function() color( { glocolor }, kstr) end, { k } )
+ else
+ color( { glocolor }, kstr)
+ end
+ else
+ if not mark and t == "table" then
+ gotolocation(k, { kstr } )
+ else
+ context(kstr)
+ end
+ end
+ NC()
+ if inlib then
+ color( { libcolor }, tstr)
+ elseif inglo then
+ color( { glocolor }, tstr)
+ else
+ context(tstr)
+ end
+ NC() NR()
+ if mark and t == "table" and title ~= "libraries" and title ~= "package" and not marked then
+ childtables(false,v,handler) -- (k,v,handler)
+ end
+ end
+ end
+ context.stoptabulate()
+ context.stopcolumns()
+ if builtin then
+ context.stopxtitle()
+ else
+ context.stoptitle()
+ end
+ end
+end
+
+show("global","",sameglobal.global,false,_G,builtin,"darkgreen",globals,"darkblue",false,obsolete)
+
+-- inspect(table.sortedkeys(context))
+
+for k, v in table.sortedpairs(_G) do
+ if not skipglobal[k] and not obsolete[k] and type(v) == "table" and not marked(v) then
+
+ -- local mt = getmetatable(v)
+ -- print("!!!!!!!!!!",k,v,mt,mt and mt.__index)
+
+ if basiclua[k] then show(k,"basic lua",sameglobal[k],basiclua[k],v,builtin[k],"darkred", false,false,true)
+ elseif extralua[k] then show(k,"extra lua",sameglobal[k],extralua[k],v,builtin[k],"darkred", false,false,true)
+ elseif basictex[k] then show(k,"basic tex",sameglobal[k],basictex[k],v,builtin[k],"darkred", false,false,true)
+ elseif extratex[k] then show(k,"extra tex",sameglobal[k],extratex[k],v,builtin[k],"darkred", false,false,true)
+ else
+ show(k,"context", sameglobal[k],false, v,builtin[k],"darkyellow",false,false,true)
+ end
+ end
+end
+
+\stopluacode
+
+\stoptext
diff --git a/Master/texmf-dist/tex/context/modules/mkiv/s-inf-04.mkiv b/Master/texmf-dist/tex/context/modules/mkiv/s-inf-04.mkiv
new file mode 100644
index 00000000000..862bed72f29
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkiv/s-inf-04.mkiv
@@ -0,0 +1,48 @@
+\usemodule[art-01]
+
+\setupbodyfont[10pt]
+
+\starttext
+
+ \startluacode
+
+ context.subject("Configuration files")
+
+ local configurations = resolvers.instance.specification
+
+ context.starttabulate { "|Tl|Tl|" }
+ for i=1,#configurations do
+ context.NC()
+ context(i)
+ context.NC()
+ context.verbatim(resolvers.resolve(configurations[i]))
+ context.NC()
+ context.NR()
+ end
+ context.stoptabulate()
+
+ local list = resolvers.expandedpathfromlist(resolvers.splitpath(resolvers.luacnfspec))
+
+ context.subject("Configuration paths")
+
+ -- context.verbatim(resolvers.luacnfspec)
+
+ context.starttabulate { "|Tl|Tl|" }
+ for i=1,#list do
+ local li = resolvers.resolve(list[i])
+ context.NC()
+ if lfs.isdir(li) then
+ context("-")
+ else
+ context("+")
+ end
+ context.NC()
+ context.verbatim(li)
+ context.NC()
+ context.NR()
+ end
+ context.stoptabulate()
+
+ \stopluacode
+
+\stoptext
diff --git a/Master/texmf-dist/tex/context/modules/mkiv/s-languages-counters.lua b/Master/texmf-dist/tex/context/modules/mkiv/s-languages-counters.lua
new file mode 100644
index 00000000000..45d68be8dfd
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkiv/s-languages-counters.lua
@@ -0,0 +1,52 @@
+if not modules then modules = { } end modules ['s-languages-counters'] = {
+ version = 1.001,
+ comment = "companion to s-languages-counters.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+moduledata.languages = moduledata.languages or { }
+moduledata.languages.counters = moduledata.languages.counters or { }
+
+local data = converters.verbose.data
+
+function moduledata.languages.counters.showverbose(specification)
+ specification = interfaces.checkedspecification(specification)
+ local list = utilities.parsers.settings_to_array(specification.language or "")
+ if #list == 0 then
+ return
+ end
+ local used = { }
+ local words = { }
+ for i=1,#list do
+ local ai = list[i]
+ local di = data[ai]
+ if di and di.words then
+ used[#used+1] = ai
+ table.merge(words,di.words)
+ end
+ end
+ context.starttabulate { string.rep("|l",#used) .. "|r|" }
+ context.HL()
+ context.NC()
+ for i=1,#used do
+ context.bold(used[i])
+ context.NC()
+ end
+ context.bold("number")
+ context.NC()
+ context.NR()
+ context.HL()
+ for k, v in table.sortedhash(words) do
+ context.NC()
+ for i=1,#used do
+ context(data[used[i]].words[k] or "")
+ context.NC()
+ end
+ context(k)
+ context.NC()
+ context.NR()
+ end
+ context.stoptabulate()
+end
diff --git a/Master/texmf-dist/tex/context/modules/mkiv/s-languages-counters.mkiv b/Master/texmf-dist/tex/context/modules/mkiv/s-languages-counters.mkiv
new file mode 100644
index 00000000000..fa938d65a87
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkiv/s-languages-counters.mkiv
@@ -0,0 +1,30 @@
+%D \module
+%D [ file=s-languages-counters, % s-lan-05,
+%D version=2011.05.01, % older
+%D title=\CONTEXT\ Style File,
+%D subtitle=Language Counters,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\startmodule[languages-counters]
+
+\registerctxluafile{s-languages-counters}{}
+
+\installmodulecommandluasingle \showverbosecounters {moduledata.languages.counters.showverbose}
+
+\stopmodule
+
+\continueifinputfile{s-languages-counters.mkiv}
+
+\usemodule[art-01]
+
+\starttext
+
+ \showverbosecounters[language={en,es}]
+
+\stoptext
diff --git a/Master/texmf-dist/tex/context/modules/mkiv/s-languages-frequencies.lua b/Master/texmf-dist/tex/context/modules/mkiv/s-languages-frequencies.lua
new file mode 100644
index 00000000000..16213a41271
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkiv/s-languages-frequencies.lua
@@ -0,0 +1,33 @@
+if not modules then modules = { } end modules ['s-languages-frequencies'] = {
+ version = 1.001,
+ comment = "companion to s-languages-frequencies.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+moduledata.languages = moduledata.languages or { }
+moduledata.languages.frequencies = moduledata.languages.frequencies or { }
+
+function moduledata.languages.frequencies.showlist(specification)
+ specification = interfaces.checkedspecification(specification)
+ local t = languages.frequencies.getdata(specification.language or languages.current())
+ context.starttabulate { "|lT|cw(2em)|r|" }
+ context.NC()
+ context.formatted.rlap("%s: %p",t.language,languages.frequencies.averagecharwidth(t.language))
+ context.NC()
+ context.NC()
+ context.NR()
+ context.HL()
+ for k, v in table.sortedhash(t.frequencies) do
+ context.NC()
+ context("%U",k)
+ context.NC()
+ context("%c",k)
+ context.NC()
+ context("%0.3f",v)
+ context.NC()
+ context.NR()
+ end
+ context.stoptabulate()
+end
diff --git a/Master/texmf-dist/tex/context/modules/mkiv/s-languages-frequencies.mkiv b/Master/texmf-dist/tex/context/modules/mkiv/s-languages-frequencies.mkiv
new file mode 100644
index 00000000000..01a1f5682e2
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkiv/s-languages-frequencies.mkiv
@@ -0,0 +1,38 @@
+%D \module
+%D [ file=s-languages-frequencies, % s-lan-06,
+%D version=2013.03.22,
+%D title=\CONTEXT\ Style File,
+%D subtitle=Language Frequencies,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\startmodule[languages-frequencies]
+
+\registerctxluafile{s-languages-frequencies}{}
+
+\installmodulecommandluasingle \showfrequencies {moduledata.languages.frequencies.showlist}
+
+\stopmodule
+
+\continueifinputfile{s-languages-frequencies.mkiv}
+
+\usemodule[art-01]
+
+\starttext
+
+ \hsize65\averagecharwidth \the\hsize: \input ward \par
+
+ \showfrequencies \page
+
+ \mainlanguage[de]
+
+ \hsize65\averagecharwidth \the\hsize: \input ward \par
+
+ \showfrequencies \page
+
+\stoptext
diff --git a/Master/texmf-dist/tex/context/modules/mkiv/s-languages-hyphenation.lua b/Master/texmf-dist/tex/context/modules/mkiv/s-languages-hyphenation.lua
new file mode 100644
index 00000000000..c5a4f91f1e9
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkiv/s-languages-hyphenation.lua
@@ -0,0 +1,135 @@
+if not modules then modules = { } end modules ['s-languages-hyphenation'] = {
+ version = 1.001,
+ comment = "companion to s-languages-hyphenation.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+moduledata.languages = moduledata.languages or { }
+moduledata.languages.hyphenation = moduledata.languages.hyphenation or { }
+
+local a_colormodel = attributes.private('colormodel')
+
+local nodecodes = nodes.nodecodes
+local nodepool = nodes.pool
+local disc_code = nodecodes.disc
+local glyph_code = nodecodes.glyph
+local emwidths = fonts.hashes.emwidths
+local exheights = fonts.hashes.exheights
+local newkern = nodepool.kern
+local newrule = nodepool.rule
+local newglue = nodepool.glue
+
+local insert_node_after = node.insert_after
+local traverse_by_id = node.traverse_id
+local hyphenate = languages.hyphenators.handler -- lang.hyphenate
+local find_tail = node.tail
+local remove_node = nodes.remove
+
+local tracers = nodes.tracers
+local colortracers = tracers and tracers.colors
+local setnodecolor = colortracers.set
+
+local function identify(head,marked)
+ local current, prev = head, nil
+ while current do
+ local id = current.id
+ local next = current.next
+ if id == disc_code then
+ if prev and next then -- and next.id == glyph_code then -- catch other usage of disc
+ marked[#marked+1] = prev
+ end
+ elseif id == glyph_code then
+ prev = current
+ end
+ current = next
+ end
+end
+
+local function strip(head,marked)
+ for i=1,#marked do
+ local prev = marked[i]
+ remove_node(head,prev.next,true)
+ end
+end
+
+local function mark(head,marked,w,h,d,how)
+ for i=1,#marked do
+ local prev = marked[i]
+ local font = prev.font
+ local em = emwidths[font]
+ local ex = exheights[font]
+ local width = w*em
+ local rule = newrule(width,h*ex,d*ex)
+ head, prev = insert_node_after(head,prev,newkern(-width/2))
+ head, prev = insert_node_after(head,prev,rule)
+ head, prev = insert_node_after(head,prev,newkern(-width/2))
+ head, prev = insert_node_after(head,prev,newglue(0))
+ setnodecolor(rule,how,prev[a_colormodel])
+ end
+end
+
+local langs, tags, noflanguages = { }, { }, 0
+
+local colorbytag = false
+
+function moduledata.languages.hyphenation.showhyphens(head)
+ if noflanguages > 0 then
+ local marked = { }
+ for i=1,noflanguages do
+ local m = { }
+ local l = langs[i]
+ marked[i] = m
+ for n in traverse_by_id(glyph_code,head) do
+ n.lang = l
+ end
+ languages.hyphenators.methods.original(head)
+ identify(head,m)
+ strip(head,m)
+ end
+ for i=noflanguages,1,-1 do
+ local l = noflanguages - i + 1
+ mark(head,marked[i],1/16,l/2,l/4,"hyphenation:"..(colorbytag and tags[i] or i))
+ end
+ return head, true
+ else
+ return head, false
+ end
+end
+
+local savedlanguage
+
+function moduledata.languages.hyphenation.startcomparepatterns(list)
+ if list and list ~= "" then
+ tags = utilities.parsers.settings_to_array(list)
+ end
+ savedlanguage = tex.language
+ tex.language = 0
+ noflanguages = #tags
+ for i=1,noflanguages do
+ langs[i] = tags[i] and languages.getnumber(tags[i])
+ end
+ nodes.tasks.enableaction("processors","moduledata.languages.hyphenation.showhyphens")
+end
+
+function moduledata.languages.hyphenation.stopcomparepatterns()
+ noflanguages = 0
+ tex.language = savedlanguage or tex.language
+ nodes.tasks.disableaction("processors","moduledata.languages.hyphenation.showhyphens")
+end
+
+function moduledata.languages.hyphenation.showcomparelegend(list)
+ if list and list ~= "" then
+ tags = utilities.parsers.settings_to_array(list)
+ end
+ for i=1,#tags do
+ if i > 1 then
+ context.enspace()
+ end
+ context.color( { "hyphenation:"..(colorbytag and tags[i] or i) }, tags[i])
+ end
+end
+
+nodes.tasks.appendaction("processors","before","moduledata.languages.hyphenation.showhyphens")
+nodes.tasks.disableaction("processors","moduledata.languages.hyphenation.showhyphens")
diff --git a/Master/texmf-dist/tex/context/modules/mkiv/s-languages-hyphenation.mkiv b/Master/texmf-dist/tex/context/modules/mkiv/s-languages-hyphenation.mkiv
new file mode 100644
index 00000000000..6662dbf2f32
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkiv/s-languages-hyphenation.mkiv
@@ -0,0 +1,77 @@
+%D \module
+%D [ file=s-languages-hyphenation, % s-lan-04,
+%D version=2011.05.01,
+%D title=\CONTEXT\ Style File,
+%D subtitle=Language Hyphenation,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+%D For Mojca.
+
+\startmodule[languages-hyphenation]
+
+\registerctxluafile{s-languages-hyphenation}{}
+
+\unprotect
+
+\unexpanded\def\startcomparepatterns
+ {\dosingleempty\module_languages_hyphenation_start}
+
+\unexpanded\def\module_languages_hyphenation_start[#1]%
+ {\begingroup
+ \par
+ % \language\zerocount
+ % \setupalign[\v!nothyphenated]%
+ \ctxlua{moduledata.languages.hyphenation.startcomparepatterns("#1")}}
+
+\unexpanded\def\stopcomparepatterns
+ {\par
+ \ctxlua{moduledata.languages.hyphenation.stopcomparepatterns()}%
+ \endgroup}
+
+\installmodulecommandluasingle \showcomparepatternslegend {moduledata.languages.hyphenation.showcomparelegend}
+
+\protect
+
+\definecolor[hyphenation:1] [r=.8]
+\definecolor[hyphenation:2] [g=.8]
+\definecolor[hyphenation:3] [b=.8]
+\definecolor[hyphenation:4] [r=.4,g=.4]
+
+\definecolor[hyphenation:en] [hyphenation:1]
+\definecolor[hyphenation:de] [hyphenation:2]
+\definecolor[hyphenation:nl] [hyphenation:3]
+\definecolor[hyphenation:fr] [hyphenation:4]
+
+\stopmodule
+
+\continueifinputfile{s-languages-hyphenation.mkiv}
+
+\usemodule[art-01]
+
+\starttext
+
+\def|#1|{-}
+
+ \startsubject{Normal text}
+ \input tufte
+ \stopsubject
+
+ \startsubject{Compare hyphenation points of \showcomparepatternslegend[en,de]}
+ \startcomparepatterns
+ \input tufte \quad (\showcomparepatternslegend)
+ \stopcomparepatterns
+ \stopsubject
+
+ \startsubject{Compare hyphenation points}
+ \startcomparepatterns[de,nl,en,fr]
+ \input tufte \quad (\showcomparepatternslegend)
+ \stopcomparepatterns
+ \stopsubject
+
+\stoptext
diff --git a/Master/texmf-dist/tex/context/modules/mkiv/s-languages-sorting.lua b/Master/texmf-dist/tex/context/modules/mkiv/s-languages-sorting.lua
new file mode 100644
index 00000000000..82a0827bbd2
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkiv/s-languages-sorting.lua
@@ -0,0 +1,118 @@
+if not modules then modules = { } end modules ['s-languages-system'] = {
+ version = 1.001,
+ comment = "companion to s-languages-system.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+moduledata.languages = moduledata.languages or { }
+moduledata.languages.sorting = moduledata.languages.sorting or { }
+
+local formatters = string.formatters
+local utfbyte, utfcharacters = utf.byte, utf.characters
+local sortedpairs = table.sortedpairs
+
+local definitions = sorters.definitions
+local constants = sorters.constants
+local replacementoffset = constants.replacementoffset
+
+local currentfont = font.current
+local fontchars = fonts.hashes.characters
+
+local c_darkblue = { "darkblue" }
+local c_darkred = { "darkred" }
+local f_chr = formatters["\\tttf%H"]
+
+local function chr(str,done)
+ if done then
+ context.space()
+ end
+ local c = fontchars[currentfont()]
+ for s in utfcharacters(str) do
+ local u = utfbyte(s)
+ if c[u] then
+ context(s)
+ elseif u > replacementoffset then
+ context.color(c_darkblue, f_chr(u))
+ else
+ context.color(c_darkred, f_chr(u))
+ end
+ end
+ return true
+end
+
+local function map(a,b,done)
+ if done then
+ context.space()
+ end
+ -- context.tttf()
+ chr(a)
+ context("=")
+ chr(b)
+ return true
+end
+
+local function nop()
+ -- context.tttf()
+ context("none")
+end
+
+local function key(data,field)
+ context.NC()
+ context(field)
+ context.NC()
+ context(data[field])
+ context.NC()
+ context.NR()
+end
+
+function moduledata.languages.sorting.showinstalled(tag)
+ if not tag or tag == "" or tag == interfaces.variables.all then
+ for tag, data in sortedpairs(definitions) do
+ moduledata.languages.sorting.showinstalled (tag)
+ end
+ else
+ sorters.update() -- syncs data
+ local data = definitions[tag]
+ if data then
+ context.starttabulate { "|lB|pl|" }
+ key(data,"language")
+ key(data,"parent")
+ key(data,"method")
+ context.NC()
+ context("replacements")
+ context.NC()
+ local replacements = data.replacements
+ if #replacements == 0 then
+ nop()
+ else
+ for i=1,#replacements do
+ local r = replacements[i]
+ map(r[1],r[2],i > 1)
+ end
+ end
+ context.NC()
+ context.NR()
+ context.NC()
+ context("order")
+ context.NC()
+ local orders = data.orders
+ for i=1,#orders do
+ chr(orders[i],i > 1)
+ end
+ context.NC()
+ context.NR()
+ context.NC()
+ context("entries")
+ context.NC()
+ local done = false
+ for k, e in sortedpairs(data.entries) do
+ done = map(k,e,done)
+ end
+ context.NC()
+ context.NR()
+ context.stoptabulate()
+ end
+ end
+end
diff --git a/Master/texmf-dist/tex/context/modules/mkiv/s-languages-sorting.mkiv b/Master/texmf-dist/tex/context/modules/mkiv/s-languages-sorting.mkiv
new file mode 100644
index 00000000000..67acda6f972
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkiv/s-languages-sorting.mkiv
@@ -0,0 +1,30 @@
+%D \module
+%D [ file=s-languages-sorting, % s-lan-02.mkiv
+%D version=2010.09.21,
+%D title=\CONTEXT\ Style File,
+%D subtitle=Language Sorting,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\startmodule[languages-sorting]
+
+\registerctxluafile{s-languages-sorting}{}
+
+\installmodulecommandluasingle \showinstalledsorting {moduledata.languages.sorting.showinstalled}
+
+\stopmodule
+
+\continueifinputfile{s-languages-sorting.mkiv}
+
+\usemodule[art-01]
+
+\starttext
+
+ \showinstalledsorting
+
+\stoptext
diff --git a/Master/texmf-dist/tex/context/modules/mkiv/s-languages-system.lua b/Master/texmf-dist/tex/context/modules/mkiv/s-languages-system.lua
new file mode 100644
index 00000000000..3b422db9f2e
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkiv/s-languages-system.lua
@@ -0,0 +1,62 @@
+if not modules then modules = { } end modules ['s-languages-system'] = {
+ version = 1.001,
+ comment = "companion to s-languages-system.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+moduledata.languages = moduledata.languages or { }
+moduledata.languages.system = moduledata.languages.system or { }
+
+local NC, NR, HL = context.NC, context.NR, context.HL
+local sortedhash = table.sortedhash
+local registered = languages.registered
+local context = context
+local ctx_NC = context.NC
+local ctx_NR = context.NR
+local ctx_bold = context.bold
+
+function moduledata.languages.system.loadinstalled()
+ context.start()
+ for k, v in table.sortedhash(registered) do
+ context.language{ k }
+ end
+ context.stop()
+end
+
+function moduledata.languages.system.showinstalled()
+ --
+ context.starttabulate { "|l|r|l|l|p(7em)|r|p|" }
+ context.FL()
+ ctx_NC() ctx_bold("tag")
+ ctx_NC() ctx_bold("n")
+ ctx_NC() ctx_bold("parent")
+ ctx_NC() ctx_bold("file")
+ ctx_NC() ctx_bold("synonyms")
+ ctx_NC() ctx_bold("patterns")
+ ctx_NC() ctx_bold("characters")
+ ctx_NC() ctx_NR()
+ context.FL()
+ for k, v in sortedhash(registered) do
+ local parent = v.parent
+ local resources = v.resources
+ local patterns = resources and resources.patterns
+ ctx_NC() context(k)
+ ctx_NC() context(v.number)
+ ctx_NC() context(v.parent)
+ ctx_NC() context(v.patterns)
+ ctx_NC() for k, v in sortedhash(v.synonyms) do context("%s\\par",k) end
+ if patterns then
+ ctx_NC() context(patterns.n)
+ ctx_NC() context("% t",utf.split(patterns.characters))
+ else
+ ctx_NC()
+ ctx_NC()
+ end
+ ctx_NC() ctx_NR()
+ end
+ context.LL()
+ context.stoptabulate()
+ --
+end
diff --git a/Master/texmf-dist/tex/context/modules/mkiv/s-languages-system.mkiv b/Master/texmf-dist/tex/context/modules/mkiv/s-languages-system.mkiv
new file mode 100644
index 00000000000..22991f264f8
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkiv/s-languages-system.mkiv
@@ -0,0 +1,32 @@
+%D \module
+%D [ file=s-languages-system, % moved from local s-lan-01
+%D version=2013.05.19,
+%D title=\CONTEXT\ Style File,
+%D subtitle=Installed Languages,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\startmodule[languages-system]
+
+\registerctxluafile{s-languages-system}{}
+
+\installmodulecommandluasingle \showinstalledlanguages {moduledata.languages.system.showinstalled}
+\installmodulecommandluasingle \loadinstalledlanguages {moduledata.languages.system.loadinstalled}
+
+\stopmodule
+
+\continueifinputfile{s-languages-system.mkiv}
+
+\usemodule[art-01]
+
+\starttext
+
+ \loadinstalledlanguages
+ \showinstalledlanguages
+
+\stoptext
diff --git a/Master/texmf-dist/tex/context/modules/mkiv/s-languages-words.lua b/Master/texmf-dist/tex/context/modules/mkiv/s-languages-words.lua
new file mode 100644
index 00000000000..ea7aee87bcd
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkiv/s-languages-words.lua
@@ -0,0 +1,32 @@
+if not modules then modules = { } end modules ['s-languages-words'] = {
+ version = 1.001,
+ comment = "companion to s-languages-words.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+moduledata.languages = moduledata.languages or { }
+moduledata.languages.words = moduledata.languages.words or { }
+
+function moduledata.languages.words.showwords(specification)
+ local filename = specification.filename or file.addsuffix(tex.jobname,"words")
+ if lfs.isfile(filename) then
+ local w = dofile(filename)
+ if w then
+ -- table.print(w)
+ for cname, category in table.sortedpairs(w.categories) do
+ for lname, language in table.sortedpairs(category.languages) do
+ context.bold(string.format("category: %s, language: %s, total: %s, unique: %s:",
+ cname, lname, language.total or 0, language.unique or 0)
+ )
+ for word, n in table.sortedpairs(language.list) do
+ context(" %s (%s)",word,n)
+ end
+ context.par()
+ end
+ end
+ end
+ end
+end
+
diff --git a/Master/texmf-dist/tex/context/modules/mkiv/s-languages-words.mkiv b/Master/texmf-dist/tex/context/modules/mkiv/s-languages-words.mkiv
new file mode 100644
index 00000000000..4e350bf34d2
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkiv/s-languages-words.mkiv
@@ -0,0 +1,22 @@
+%D \module
+%D [ file=s-languages-words,
+%D version=2010.10.21,
+%D title=\CONTEXT\ Style File,
+%D subtitle=Language Environment 3,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+%D This is used in the test suite.
+
+\startmodule[languages-words]
+
+\registerctxluafile{s-languages-words}{}
+
+\installmodulecommandluasingle \showwords {moduledata.languages.words.showwords}
+
+\stopmodule
diff --git a/Master/texmf-dist/tex/context/modules/mkiv/s-lingual-de.mkiv b/Master/texmf-dist/tex/context/modules/mkiv/s-lingual-de.mkiv
new file mode 100644
index 00000000000..d5436e1e2f0
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkiv/s-lingual-de.mkiv
@@ -0,0 +1,49 @@
+%D \module
+%D [ file=s-lingual-de,
+%D version=2016.04.17,
+%D title=\CONTEXT\ Linguistic File,
+%D subtitle=German TWeaks,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\startluacode
+ fonts.handlers.otf.addfeature {
+ name = "sz",
+ type = "multiple",
+ data = {
+ ["ẞ"] = { "S", "S" }
+ }
+ }
+\stopluacode
+
+\definefontfeature[sz][sz=yes]
+
+\unexpanded\def\enableuppercasesharps {\overloaduppercase{0xDF}{0x1E9E}}
+\unexpanded\def\disableuppercasesharps{\overloaduppercase{0xDF}{0x53,0x53}}
+
+\installtexdirective
+ {fonts.uppercasesharps}
+ \enableuppercasesharps
+ \disableuppercasesharps
+
+\continueifinputfile{s-lingual-de.mkiv}
+
+\setupbodyfont[libertine]
+
+\starttext
+ \def\TestString{Buße Busse BUẞE BUSSE \WORD{Buße Busse}}
+ %\definefontfeature[default][default][sz=yes]
+ \dorecurse{5} {
+ \disableuppercasesharps
+ \TestString\par
+ \enableuppercasesharps
+ \TestString\par
+ {\addfeature{sz}\TestString}\par
+ }
+\stoptext
+
diff --git a/Master/texmf-dist/tex/context/modules/mkiv/s-map-10.mkiv b/Master/texmf-dist/tex/context/modules/mkiv/s-map-10.mkiv
new file mode 100644
index 00000000000..c7541babc81
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkiv/s-map-10.mkiv
@@ -0,0 +1,494 @@
+%D \module
+%D [file=s-map-10.mkiv,
+%D version=2012.06.06,
+%D title=\CONTEXT\ Style File,
+%D subtitle=\MAPS\ journal style,
+%D author={Hans Hagen, Taco Hoekwater and Siep Kroonenberg},
+%D date=\currentdate,
+%D copyright=NTG/MAPS]
+
+% This module implements the MAPS style for use with the Context
+% macro package. The original MAPS layout was designed and
+% implemented in LaTeX by Taco Hoekwater and Siep Kroonenberg.
+
+% - three layouts:
+% 1. two columns
+% 2. one column, with wide outer margins (option onecolumn)
+% 3. one column, with wide left margin (option asym)
+% - font sizes deviate from TeX's usual geometric progression
+% - use of sans-serif for headers and various details
+% - option realfonts uses Linux Libertine, Euler Math and Inconsolata.
+% This is used for final typesetting.
+% The default font setup, intended for authors, uses Computer
+% Modern Math instead of Euler Math (which is still in beta),
+% and LM Mono instead of Inconsolata.
+
+% A mode nosubsub defines only two levels of sectioning. If you
+% don't need more and use the two-column layout, then this option
+% will probably improve the looks of your paper.
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+\newif\ifMapsInColumns
+\doifmode{asym}{\enablemode[onecolumn]} % implies onecolumn
+\doifnotmode{onecolumn}{\MapsInColumnstrue}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%% fonts
+
+%%%%%%%%% first, font sizes
+\definebodyfontenvironment [7pt][% LaTeX: scriptsize
+ interlinespace=8pt,
+ big=8pt,
+ small=6pt%
+]
+
+\definebodyfontenvironment [8pt][% LaTeX: footnotesize
+ interlinespace=9pt,
+ big=9pt,
+ small=7pt,
+ x=6pt%
+]
+
+\definebodyfontenvironment [9pt][% LaTeX: small
+ interlinespace=10pt,
+ big=10pt,
+ small=8pt,%
+ x=7pt,%
+ script=6pt%
+]
+
+\definebodyfontenvironment [10pt][% LaTeX: normalsize
+ interlinespace=11pt,
+ big=11pt,
+ a=11pt,
+ small=9pt,%
+ x=8pt,%
+ script=7pt%
+]
+
+\definebodyfontenvironment [11pt][% LaTeX: large
+ interlinespace=11pt,
+ big=11pt,
+ small=10pt,%
+ x=9pt,%
+ script=8pt%
+]
+
+\definebodyfontenvironment [14pt][%
+ interlinespace=14pt,
+ big=18pt,
+ small=11pt,
+ x=10pt%
+]
+
+\definebodyfontenvironment [18pt][%
+ interlinespace=18pt,
+ big=24pt,
+ small=14pt,
+ x=10pt%
+]
+
+\definebodyfontenvironment [24pt][%
+ interlinespace=24pt,
+ big=24pt,
+ small=18pt,
+ x=11pt%
+]
+
+%%% font families
+
+\starttypescript [maps]
+\definetypeface [maps] [rm] [serif] [modern] [default] [rscale=0.95]
+\definetypeface [maps] [mm] [math] [modern] [latin-modern]
+\definetypeface [maps] [tt] [mono] [modern] [default] [rscale=0.90]
+\definetypeface [maps] [ss] [sans] [modern] [default] [rscale=0.95]
+\stoptypescript
+
+\startmode[realfonts]
+\usetypescriptfile[type-libertine]
+
+\usetypescriptfile[type-inconsolata]
+
+\starttypescript [maps]
+\definetypeface [maps] [rm] [serif] [libertine] [default]
+\definetypeface [maps] [mm] [math] [euler] [default] [rscale=0.9]
+\definetypeface [maps] [tt] [mono] [inconsolata] [default] [rscale=0.92]
+\definetypeface [maps] [ss] [sans] [modern] [default] [rscale=0.95]
+\stoptypescript
+\stopmode
+
+\setupbodyfont[maps,10pt,rm]
+
+% activate protruding
+\setupinterlinespace[line=11pt]
+
+\setupfontsynonym[handling=pure]
+
+\setupalign[hanging]
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%% additional general typographic details
+
+\setupindenting [yes,next,11pt] % indenting after enumerations etc.
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%% 3 versions of layout with matching headers
+
+\definepapersize
+ [maps]
+ [width=21cm,height=26.5cm]
+
+\setuppapersize
+ [maps][maps]
+
+\setuplayout[
+ [topspace=40pt,
+ height=688pt,
+ header=33pt,
+ margin=106pt,
+ leftmargindistance=11pt,
+ rightmargindistance=11pt]
+
+\setupblank[5.5pt]
+
+\setuppagenumbering [location=]
+
+\definetyping [widetyping]
+
+\setupheader [style=\ss]
+\setupfooter [style=\ss]
+
+\def\AuHead{\MapsRunningAuthor}
+\def\TiHead{\ifnum\pageno=\MapsPage \relax \MapsRunningAuthor \else \MapsRunningTitle\fi}
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%% sectioning
+
+\setupheads[sectionnumber=no, align=right]
+
+\def\hfonti{\ssbfa}
+\def\hfontii{\ssbf}
+\def\hfontiii{\rm\it}
+
+\doifelsemode{nosubsub}{%
+\setuphead [section][%
+ style=\hfontii,
+ before={\blank[line]},
+ after={}%
+]
+\setuphead [subsection][%
+ style=\hfontiii,
+ alternative=text,
+ distance=6pt,
+ before={\blank[halfline]}%
+]}{%
+\setuphead [section][%
+ style=\hfonti,
+ before={\blank[line]},
+ after={\blank[halfline]}%
+]
+\setuphead [subsection][%
+ style=\hfontii,
+ before={\blank[halfline]},
+ after={}%
+]
+\setuphead [subsubsection][%
+ style=\hfontiii,
+ distance=6pt,
+ alternative=text,
+ before={\blank[halfline]}%
+]}
+
+\doifelsemode{nosubsub}{%
+\setuphead [subject][%
+ style=\hfontii,
+ before={\blank[halfline]},
+ after={}%
+]
+\setuphead [subsubject][%
+ style=\hfontiii,
+ alternative=text,
+ before={\blank[halfline]}%
+]}{%
+\setuphead [subject][%
+ style=\hfonti,
+ before={\blank},
+ after={\blank[halfline]}%
+]
+\setuphead [subsubject][%
+ style=\hfontii,
+ before={\blank[halfline]},
+ after={}%
+]
+\setuphead [subsubsubject][%
+ style=\hfontiii,
+ alternative=text,
+ before={\blank[halfline]}%
+]}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%% floats
+
+\setupfloats [location=center, before={\ss}]
+\setupcaptions [headstyle={\ssbf},style={\ssx},
+ suffix=.,distance=6pt,
+ inbetween={\blank[halfline]}]
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%% various document elements
+
+\definesymbol [1][\getnamedglyphdirect{file:stmary10}{boxempty}]
+
+\setupitemize[1][packed]
+
+\setupitemize [each][%
+ indentnext=no,
+ align=right,
+ width=1em,
+ distance=0pt%
+]
+
+% an outer form of itemize that does not indent
+% the paragraph.
+
+\definecomplexorsimpleempty\startouteritemize
+\def\complexstartouteritemize[#1]{\begingroup
+ \startitemize[width=1sp,#1]
+ \let\doitem\item
+ \def\item{\doitem[]\hbox{}\kern12pt\rightskip=0pt}%
+}
+
+\def\stopouteritemize{\stopitemize\endgroup}
+
+
+\setupenumerations [indentnext=no]
+
+\setupdescriptions [indentnext=no]
+
+\unexpanded\def\smalltyping{%
+ \switchtobodyfont[tt]%
+ \parindent=0pt
+}
+
+% typing:
+% - prettyverbatim is NOT the default
+% - smaller size
+
+\unexpanded\def
+ \XeTeX{X\lower.5ex\hbox{\kern-.1em\mirror{E}}\kern-.1667em\TeX}
+
+\setuptyping [%
+ style={\smalltyping},
+ option=none,
+ indentnext=no%
+]
+
+\def\footnum#1{#1.}
+
+\setupnotation
+ [footnote]
+ [alternative=serried,
+ before=,
+ after=,
+ location=none,
+ width=\textwidth,
+ before={\blank},
+ numbercommand=,
+ command=\footnum,
+ distance=0.5em]
+
+\setuptabulate
+ [before=\blank,
+ inner=\ss,
+ after=\blank]
+
+\def\startIntroEntry#1%
+ {\startlinecorrection
+ \bgroup
+ \setupalign[right]
+ \setuptolerance[verytolerant]
+ \setupindenting[no]
+ \noindent
+ \switchtobodyfont[9pt]%
+ \setuplocalinterlinespace[line=10pt]%
+ %\hyphenpenalty10000
+ \parfillskip 0pt plus 1fill
+ \rightskip6pt plus 1fill
+ \ss
+ \bgroup\bf #1\par\egroup
+ \ignorespaces }
+
+\def\stopIntroEntry
+ {\par\egroup \stoplinecorrection
+ \blank[line] }
+
+\def\defineIntroEntry[#1][#2][#3]%
+ {\setvalue{start#1}{\startIntroEntry{#2}}%
+ \setvalue {stop#1}{\stopIntroEntry#3}}
+
+\defineIntroEntry[Keywords][Keywords][]
+\defineIntroEntry[Abstract][Abstract][]
+
+% article parameters (other fields and defaults)
+\def\MapsBibData[#1]%
+ {\getparameters [Maps]
+ [SubTitle=,
+ RunningAuthor=,
+ RunningTitle=,
+ Email=,
+ Address=,
+ Page=1,
+ Title=,
+ Author=,
+ Period=,
+ Number=,
+ Year=,
+ #1]%
+ \doifnothing{\MapsPeriod}{%
+ \ifnum \normalmonth<6 \gdef\MapsPeriod{VOORJAAR}\else \gdef\MapsPeriod{NAJAAR}\fi}
+ \doifelseinstring{oorjaar}{\MapsPeriod}{\gdef\MapsPeriod{VOORJAAR}}{}%
+ \doifelseinstring{pring}{\MapsPeriod}{\gdef\MapsPeriod{VOORJAAR}}{}%
+ \doifelseinstring{ajaar}{\MapsPeriod}{\gdef\MapsPeriod{NAJAAR}}{}%
+ \doifelseinstring{utumn}{\MapsPeriod}{\gdef\MapsPeriod{NAJAAR}}{}%
+ \doifnothing{\MapsYear}{\gdef\MapsYear{\the\year}}%
+ \doifnothing{\MapsNumber}{%
+ \ifnum \normalmonth<6
+ \xdef\MapsNumber{\the\numexpr (\the\year-1990)*2\relax}%
+ \else
+ \xdef\MapsNumber{\the\numexpr (\the\year-1990)*2+1\relax}%
+ \fi }%
+ \doifnothing\MapsRunningAuthor
+ {\global\let\MapsRunningAuthor\MapsAuthor}%
+ \doifnothing\MapsRunningTitle
+ {\global\let\MapsRunningTitle\MapsTitle}}%
+
+\def\dostartArticle[#1]{%
+ \MapsBibData[#1]
+ \pageno=\MapsPage
+ \setupuserpagenumber[start=\MapsPage]
+ \startbaselinecorrection
+ \bgroup
+ \hsize = 457pt
+ \let\\\crlf
+ \blank[35pt,force]
+ \switchtobodyfont[24pt]
+ \setupalign[right]
+ {\noindent\bf\MapsTitle\par}
+ \ifx\MapsSubTitle\empty
+ \blank[30pt]
+ \else
+ \bgroup
+ \blank[12pt]
+ \switchtobodyfont[18pt]\noindent \it
+ \advance \rightskip 0pt plus 2em
+ \MapsSubTitle\par
+ \egroup
+ \blank[30pt]
+ \fi
+ \egroup
+ \setupalign[width]
+ \switchtobodyfont[rm,10pt]
+ \stopbaselinecorrection
+ \ifMapsInColumns
+ \startcolumns\hyphenpenalty1000
+ \else
+ \clubpenalty10000
+ \widowpenalty10000
+ \fi
+}
+
+\def\startArticle{\dosingleempty\dostartArticle}
+
+\def\signArticle{%
+ \blank\let\\\crlf
+ \noindent\switchtobodyfont[ss,9pt]%
+ \MapsAuthor
+ \doifsomething{\MapsAddress}{\\\MapsAddress}%
+ \doifsomething{\MapsEmail}{\\\MapsEmail}%
+ \switchtobodyfont[10pt]%
+ \def\signArticle{}%
+}
+
+\def\stopArticle{%
+ \par\signArticle
+ \ifMapsInColumns \stopcolumns \fi
+ \page
+}
+
+\installpagebreakmethod{last}{}
+
+%%% `logos' %%%%%%%%%%%%%%%%%%%%%%%%%%
+
+\unexpanded\def\LaTeX % requested by erik frambach
+ {{\setbox\scratchbox\hbox{L}%
+ \scratchdimen\ht\scratchbox
+ \setbox\scratchbox\hbox{\switchtobodyfont[script]A}%
+ L\kern-.55\wd\scratchbox
+ \raise\scratchdimen\hbox{\lower\ht\scratchbox\copy\scratchbox}%
+ \kern-.2\wd\scratchbox\TeX}}
+
+
+\def\CONTEXT{Con{\TeX}t}
+\def\ConTeXt{Con{\TeX}t}
+\def\METAFONT{Metafont}
+\def\METAPOST{MetaPost}
+\def\POSTSCRIPT{PostScript}
+
+\def\acro#1{{\switchtobodyfont[9pt]#1}}
+
+
+%%%%%%%%%%%
+
+\doifelsemode{onecolumn}{%
+ \setuplayout[width=340pt]
+ \doifelsemode{asym}{% one col, asymmetric
+ \setuplayout[backspace=187.3pt]%
+ \setuptyping [widetyping][oddmargin=-117pt]
+ \setuppagenumbering [alternative={singlesided,doublesided}]
+ \setupheadertexts
+ [{\hbox{}\hskip-117pt\TiHead}]
+ [{\cap{\MapsPeriod\ \MapsYear}\quad\bf \pagenumber\hskip-30pt\hbox{}}]
+ [{\hbox{}\hskip-147pt{\bf \pagenumber}\quad \cap {maps\ \MapsNumber}}]
+ [\AuHead]
+ \setupfootertexts
+ }{% one col, symmetric
+ \setuplayout[backspace=70.3pt]
+ \setuppagenumbering [alternative=doublesided]
+ \setuptyping[blank=halfline]
+ \setupheadertexts
+ [\TiHead]
+ [{\cap{\MapsPeriod\ \MapsYear}\quad\bf \pagenumber\hskip-147pt\hbox{}}]
+ [{\hbox{}\hskip-147pt{\bf \pagenumber}\quad \cap {maps\ \MapsNumber}}]
+ [\AuHead]
+ \setupfootertexts
+}}{% two col
+ \setuplayout[width=457pt]
+ \setupcolumns[n=2,tolerance=verytolerant,distance=11pt]
+ \setuplayout[backspace=70.3pt,grid=yes]
+ \setuppagenumbering [alternative=doublesided]
+ \setuptyping[blank=halfline]
+ \setupheadertexts
+ [\TiHead]
+ [{\cap{\MapsPeriod\ \MapsYear}\quad\bf \pagenumber\hskip-30pt\hbox{}}]
+ [{\hbox{}\hskip-30pt{\bf \pagenumber}\quad \cap {maps\ \MapsNumber}}]
+ [\AuHead]
+ \setupfootertexts
+}
+
+\def\fulltextwidth{457pt}
+
+\def\startdescription
+ {\blank
+ \bgroup
+ \def\sym##1{\par\noindent\hbox{\bf\kern -16pt ##1}\hskip 12pt}
+ \startnarrower[left]
+ }
+\def\stopdescription
+ {\par \stopnarrower \egroup \blank \noindentation }
+
+\frenchspacing
+\setuptolerance[tolerant]
+
+\endinput
diff --git a/Master/texmf-dist/tex/context/modules/mkiv/s-math-characters.lua b/Master/texmf-dist/tex/context/modules/mkiv/s-math-characters.lua
new file mode 100644
index 00000000000..8ff3a8660df
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkiv/s-math-characters.lua
@@ -0,0 +1,242 @@
+if not modules then modules = { } end modules['s-math-characters'] = {
+ version = 1.001,
+ comment = "companion to s-math-characters.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+-- This is one of the oldest cld files but I'm not going to clean it up.
+
+moduledata.math = moduledata.math or { }
+moduledata.math.characters = moduledata.math.characters or { }
+
+local concat = table.concat
+local lower = string.lower
+local utfchar = utf.char
+local round = math.round
+
+local fontdata = fonts.hashes.identifiers
+local chardata = characters.data
+local blocks = characters.blocks
+
+local no_description = "no description, private to font"
+
+local limited = true
+local fillinthegaps = true
+local upperlimit = 0x0007F
+local upperlimit = 0xF0000
+
+local f_unicode = string.formatters["%U"]
+local f_slot = string.formatters["%s/%0X"]
+
+function moduledata.math.characters.showlist(specification)
+ specification = interfaces.checkedspecification(specification)
+ local id = specification.number -- or specification.id
+ local list = specification.list
+ local showvirtual = specification.virtual == "all"
+ local check = specification.check == "yes"
+ if not id then
+ id = font.current()
+ end
+ if list == "" then
+ list = nil
+ end
+ local tfmdata = fontdata[id]
+ local characters = tfmdata.characters
+ local descriptions = tfmdata.descriptions
+ local resources = tfmdata.resources
+ local lookuptypes = resources.lookuptypes
+ local virtual = tfmdata.properties.virtualized
+ local names = { }
+ local gaps = mathematics.gaps
+ local sorted = { }
+ if type(list) == "string" then
+ sorted = utilities.parsers.settings_to_array(list)
+ elseif type(list) == "table" then
+ sorted = list
+ elseif fillinthegaps then
+ sorted = table.keys(characters)
+ for k, v in next, gaps do
+ if characters[v] then
+ sorted[#sorted+1] = k
+ end
+ end
+ table.sort(sorted)
+ else
+ sorted = table.sortedkeys(characters)
+ end
+ if virtual then
+ for k, v in ipairs(tfmdata.fonts) do
+ local id = v.id
+ local name = fontdata[id].properties.name
+ names[k] = (name and file.basename(name)) or id
+ end
+ end
+ if check then
+ for k, v in table.sortedhash(blocks) do
+ if v.math then
+ local first = v.first
+ local last = v.last
+ local f, l = 0, 0
+ if first and last then
+ for unicode=first,last do
+ local code = gaps[unicode] or unicode
+ local char = characters[code]
+ if char and not (char.commands and not showvirtual) then
+ f = unicode
+ break
+ end
+ end
+ for unicode=last,first,-1 do
+ local code = gaps[unicode] or unicode
+ local char = characters[code]
+ if char and not (char.commands and not showvirtual) then
+ l = unicode
+ break
+ end
+ end
+ context.showmathcharacterssetrange(k,f,l)
+ end
+ end
+ end
+ else
+ context.showmathcharactersstart()
+ for _, unicode in next, sorted do
+ if not limited or unicode < upperlimit then
+ local code = gaps[unicode] or unicode
+ local char = characters[code]
+ local desc = descriptions[code]
+ local info = chardata[code]
+ if char then
+ local commands = char.commands
+ if commands and not showvirtual then
+ -- skip
+ else
+ local next_sizes = char.next
+ local v_variants = char.vert_variants
+ local h_variants = char.horiz_variants
+ local slookups = desc and desc.slookups
+ local mlookups = desc and desc.mlookups
+ local mathclass = info.mathclass
+ local mathspec = info.mathspec
+ local mathsymbol = info.mathsymbol
+ local description = info.description or no_description
+ context.showmathcharactersstartentry()
+ context.showmathcharactersreference(f_unicode(unicode))
+ context.showmathcharactersentryhexdectit(f_unicode(code),code,lower(description))
+ context.showmathcharactersentrywdhtdpic(round(char.width or 0),round(char.height or 0),round(char.depth or 0),round(char.italic or 0))
+ if virtual and commands then
+ local t = { }
+ for i=1,#commands do
+ local ci = commands[i]
+ if ci[1] == "slot" then
+ local fnt, idx = ci[2], ci[3]
+ t[#t+1] = f_slot(names[fnt] or fnt,idx)
+ end
+ end
+ if #t > 0 then
+ context.showmathcharactersentryresource(concat(t,", "))
+ end
+ end
+ if mathclass or mathspec then
+ context.showmathcharactersstartentryclassspec()
+ if mathclass then
+ context.showmathcharactersentryclassname(mathclass,info.mathname or "no name")
+ end
+ if mathspec then
+ for i=1,#mathspec do
+ local mi = mathspec[i]
+ context.showmathcharactersentryclassname(mi.class,mi.name or "no name")
+ end
+ end
+ context.showmathcharactersstopentryclassspec()
+ end
+ if mathsymbol then
+ context.showmathcharactersentrysymbol(f_unicode(mathsymbol),mathsymbol)
+ end
+ if next_sizes then
+ local n, done = 0, { }
+ context.showmathcharactersstartnext()
+ while next_sizes do
+ n = n + 1
+ if done[next_sizes] then
+ context.showmathcharactersnextcycle(n)
+ break
+ else
+ done[next_sizes] = true
+ context.showmathcharactersnextentry(n,f_unicode(next_sizes),next_sizes)
+ next_sizes = characters[next_sizes]
+ v_variants = next_sizes.vert_variants or v_variants
+ h_variants = next_sizes.horiz_variants or h_variants
+ if next_sizes then
+ next_sizes = next_sizes.next
+ end
+ end
+ end
+ context.showmathcharactersstopnext()
+ if h_variants or v_variants then
+ context.showmathcharactersbetweennextandvariants()
+ end
+ end
+ if h_variants then
+ context.showmathcharactersstarthvariants()
+ for i=1,#h_variants do -- we might go top-down in the original
+ local vi = h_variants[i]
+ context.showmathcharactershvariantsentry(i,f_unicode(vi.glyph),vi.glyph)
+ end
+ context.showmathcharactersstophvariants()
+ elseif v_variants then
+ context.showmathcharactersstartvvariants()
+ for i=1,#v_variants do
+ local vi = v_variants[#v_variants-i+1]
+ context.showmathcharactersvvariantsentry(i,f_unicode(vi.glyph),vi.glyph)
+ end
+ context.showmathcharactersstopvvariants()
+ end
+ if slookups or mlookups then
+ local variants = { }
+ if slookups then
+ for lookupname, lookupdata in next, slookups do
+ local lookuptype = lookuptypes[lookupname]
+ if lookuptype == "substitution" then
+ variants[lookupdata] = "sub"
+ elseif lookuptype == "alternate" then
+ for i=1,#lookupdata do
+ variants[lookupdata[i]] = "alt"
+ end
+ end
+ end
+ end
+ if mlookups then
+ for lookupname, lookuplist in next, mlookups do
+ local lookuptype = lookuptypes[lookupname]
+ for i=1,#lookuplist do
+ local lookupdata = lookuplist[i]
+ local lookuptype = lookuptypes[lookupname]
+ if lookuptype == "substitution" then
+ variants[lookupdata] = "sub"
+ elseif lookuptype == "alternate" then
+ for i=1,#lookupdata do
+ variants[lookupdata[i]] = "alt"
+ end
+ end
+ end
+ end
+ end
+ context.showmathcharactersstartlookupvariants()
+ local i = 0
+ for variant, lookuptype in table.sortedpairs(variants) do
+ i = i + 1
+ context.showmathcharacterslookupvariant(i,f_unicode(variant),variant,lookuptype)
+ end
+ context.showmathcharactersstoplookupvariants()
+ end
+ context.showmathcharactersstopentry()
+ end
+ end
+ end
+ end
+ context.showmathcharactersstop()
+ end
+end
diff --git a/Master/texmf-dist/tex/context/modules/mkiv/s-math-characters.mkiv b/Master/texmf-dist/tex/context/modules/mkiv/s-math-characters.mkiv
new file mode 100644
index 00000000000..3b273cb6c21
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkiv/s-math-characters.mkiv
@@ -0,0 +1,193 @@
+%D \module
+%D [ file=s-math-characters.mkiv, % was: s-fnt-25 and later s-mat-10
+%D version=2009.01.25,
+%D title=\CONTEXT\ Style File,
+%D subtitle=Math Glyph Checking,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\startmodule[math-characters]
+
+\registerctxluafile{s-math-characters}{}
+
+% context --jit --global --bodyfont=cambria --result=math-characters-cambria s-math-characters.mkiv
+% context --jit --global --bodyfont=modern --result=math-characters-modern s-math-characters.mkiv
+
+\startsetups s-math-characters:reset
+
+ \let\showmathcharactersstart \relax
+ \let\showmathcharactersstop \relax
+ \let\showmathcharactersreference \gobbleoneargument
+ \let\showmathcharactersstartentry \relax
+ \let\showmathcharactersstopentry \relax
+ \let\showmathcharactersentryhexdectit \gobblethreearguments
+ \let\showmathcharactersentrywdhtdpic \gobblefourarguments
+ \let\showmathcharactersentryresource \gobbleoneargument
+ \let\showmathcharactersstartnext \relax
+ \let\showmathcharactersnextentry \gobblethreearguments
+ \let\showmathcharactersnextcycle \gobbleonearguments
+ \let\showmathcharactersstopnext \relax
+ \let\showmathcharactersstarthvariants \relax
+ \let\showmathcharactershvariantsentry \gobblethreearguments
+ \let\showmathcharactersstophvariants \relax
+ \let\showmathcharactersstartvvariants \showmathcharactersstarthvariants
+ \let\showmathcharactersvvariantsentry \showmathcharactershvariantsentry
+ \let\showmathcharactersstopvvariants \showmathcharactersstophvariants
+ \let\showmathcharactersbetweennextandvariants\relax
+ \let\showmathcharactersstartentryclassspec \relax
+ \let\showmathcharactersstopentryclassspec \relax
+ \let\showmathcharactersentryclassname \gobbletwoarguments
+ \let\showmathcharactersentrysymbol \gobbletwoarguments
+ \let\showmathcharactersstartlookupvariants \relax
+ \let\showmathcharacterslookupvariant \gobblefourarguments
+ \let\showmathcharactersstoplookupvariants \relax
+ \let\showmathcharacterssetrange \gobblethreearguments
+
+\stopsetups
+
+\directsetup{s-math-characters:reset}
+
+\startsetups s-math-characters:default
+
+ \directsetup{s-math-characters:reset}
+
+ \unexpanded\def\showmathcharactersstartentry {\blank\begingroup\raggedright}
+ \unexpanded\def\showmathcharactersstopentry {\endgroup\blank}
+
+ \def\showmathcharactersentryhexdectit##1##2##3%
+ {##1:\space{\char##2}\space\ruledhbox{\char##2}\space##3\par
+ \advance\leftskip\emwidth\relax}
+
+ \def\showmathcharactersentrywdhtdpic##1##2##3##4%
+ {width:\space##1,\space height:\space##2,\space depth:\space##3,\space italic:\space##4\par}
+
+ \def\showmathcharactersentryresource##1%
+ {virtual:\space##1\par}
+
+ \def\showmathcharactersstartnext
+ {\par\begingroup\hangindent\emwidth\hangafter-\plushundred\hskip-\emwidth
+ next:\space}
+
+ \def\showmathcharactersnextentry##1##2##3%
+ {\ifnum##1>\plusone \space=>\space\fi##2~\ruledhbox{\char##3}}
+
+ \def\showmathcharactersnextcycle##1%
+ {\ifnum##1>\plusone \space=>\space\fi cycle}
+
+ \def\showmathcharactersstopnext
+ {\par\endgroup}
+
+ \def\showmathcharactersstarthvariants
+ {\par\begingroup\hangindent\emwidth\hangafter-\plushundred\hskip-\emwidth
+ variants:\space}
+
+ \def\showmathcharactershvariantsentry##1##2##3%
+ {\ifnum##1>\plusone \space=>\space\fi##2~\ruledhbox{\char##3}}
+
+ \def\showmathcharactersstophvariants
+ {\par\endgroup}
+
+ \let\showmathcharactersstartvvariants\showmathcharactersstarthvariants
+ \let\showmathcharactersvvariantsentry\showmathcharactershvariantsentry
+ \let\showmathcharactersstopvvariants \showmathcharactersstophvariants
+
+ \def\showmathcharactersbetweennextandvariants
+ {}% \space=>\space}
+
+ \def\showmathcharactersentryclassname##1##2%
+ {mathclass:\space##1,\space mathname:\space##2\par}
+
+ \def\showmathcharactersentrysymbol##1##2%
+ {mathsymbol:\space##1~\ruledhbox{\char##2}\par}
+
+ \def\showmathcharactersstartlookupvariants
+ {\par\begingroup\hangindent\emwidth\hangafter-\plushundred\hskip-\emwidth
+ lookupvariants:\space}
+
+ \def\showmathcharacterslookupvariant##1##2##3##4%
+ {\ifnum##1>\plusone,\space\fi##2:~{\char##3}\space(##4)}
+
+ \def\showmathcharactersstoplookupvariants
+ {\par\endgroup}
+
+\stopsetups
+
+\unprotect
+
+\unexpanded\def\enableshowmathfontvirtual
+ {\ctxlua{fonts.constructors.autocleanup=false}}
+
+\unexpanded\def\showmathfontcharacters
+ {\dosingleempty\module_math_characters_show}
+
+\def\module_math_characters_show[#1]%
+ {\begingroup
+ \getdummyparameters
+ [\c!bodyfont=,
+ \c!list=,
+ \c!check=,
+ \c!alternative=default,
+ \c!option=\v!all,
+ #1]%
+ \directsetup{s-math-characters:\dummyparameter\c!alternative}%
+ \doifelsenothing{\dummyparameter\c!bodyfont}
+ {\definedfont[MathRoman*math-text]}
+ {\definedfont[\dummyparameter\c!bodyfont]}%
+ \dontcomplain
+ \ctxlua{moduledata.math.characters.showlist {
+ number = false,
+ check = "\dummyparameter\c!check",
+ list = "\dummyparameter\c!list",
+ option = "\dummyparameter\c!option",
+ }}%
+ \endgroup}
+
+\protect
+
+\stopmodule
+
+\continueifinputfile{s-math-characters.mkiv}
+
+\setuplayout
+ [width=middle,
+ height=middle,
+ topspace=15mm,
+ backspace=15mm,
+ bottomspace=15mm,
+ header=1cm,
+ headerdistance=0.5cm,
+ footer=0pt]
+
+\starttext
+
+ \doifelse {\getdocumentargument{bodyfont}} {} {
+
+ \setupbodyfont[cambria, 12pt]
+ % \setupbodyfont[modern, 12pt]
+ % \setupbodyfont[lmvirtual, 12pt]
+ % \setupbodyfont[pxvirtual, 12pt]
+ % \setupbodyfont[txvirtual, 12pt]
+ % \setupbodyfont[palatino, 10pt]
+ % \setupbodyfont[mathtimes, 12pt]
+ % \setupbodyfont[stix, 12pt]
+ % \setupbodyfont[xits, 12pt]
+ % \setupbodyfont[lucida, 12pt]
+ % \setupbodyfont[lucidanova,12pt]
+ % \setupbodyfont[pagella, 12pt]
+ % \setupbodyfont[bonum, 12pt]
+
+ } {
+
+ \normalexpanded{\setupbodyfont[\getdocumentargument{bodyfont},12pt]}
+
+ }
+
+ \showmathfontcharacters
+
+\stoptext
+
diff --git a/Master/texmf-dist/tex/context/modules/mkiv/s-math-coverage.lua b/Master/texmf-dist/tex/context/modules/mkiv/s-math-coverage.lua
new file mode 100644
index 00000000000..3c6080dc36e
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkiv/s-math-coverage.lua
@@ -0,0 +1,197 @@
+if not modules then modules = { } end modules ['s-math-coverage'] = {
+ version = 1.001,
+ comment = "companion to s-math-coverage.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+local utfchar, utfbyte = utf.char, utf.byte
+local formatters, lower = string.formatters, string.lower
+local concat = table.concat
+local sortedhash = table.sortedhash
+
+moduledata.math = moduledata.math or { }
+moduledata.math.coverage = moduledata.math.coverage or { }
+
+local context = context
+
+local ctx_NC = context.NC
+local ctx_NR = context.NR
+local ctx_HL = context.HL
+
+local ctx_startmixedcolumns = context.startmixedcolumns
+local ctx_stopmixedcolumns = context.stopmixedcolumns
+local ctx_setupalign = context.setupalign
+local ctx_starttabulate = context.starttabulate
+local ctx_stoptabulate = context.stoptabulate
+local ctx_rawmathematics = context.formatted.rawmathematics
+local ctx_mathematics = context.formatted.mathematics
+local ctx_startimath = context.startimath
+local ctx_stopimath = context.stopimath
+local ctx_setmathattribute = context.setmathattribute
+local ctx_underbar = context.underbar
+local ctx_getglyph = context.getglyph
+
+local styles = mathematics.styles
+local alternatives = mathematics.alternatives
+local charactersets = mathematics.charactersets
+
+local getboth = mathematics.getboth
+local remapalphabets = mathematics.remapalphabets
+
+local chardata = characters.data
+local superscripts = characters.superscripts
+local subscripts = characters.subscripts
+
+context.writestatus("math coverage","underline: not remapped")
+
+function moduledata.math.coverage.showalphabets()
+ ctx_starttabulate { "|lT|l|Tl|" }
+ for i=1,#styles do
+ local style = styles[i]
+ for i=1,#alternatives do
+ local alternative = alternatives[i]
+ for _, alphabet in sortedhash(charactersets) do
+ ctx_NC()
+ if i == 1 then
+ context("%s %s",style,alternative)
+ end
+ ctx_NC()
+ ctx_startimath()
+ ctx_setmathattribute(style,alternative)
+ for i=1,#alphabet do
+ local letter = alphabet[i]
+ local id = getboth(style,alternative)
+ local unicode = remapalphabets(letter,id)
+ if not unicode then
+ ctx_underbar(utfchar(letter))
+ elseif unicode == letter then
+ context(utfchar(unicode))
+ else
+ context(utfchar(unicode))
+ end
+ end
+ ctx_stopimath()
+ ctx_NC()
+ local first = alphabet[1]
+ local last = alphabet[#alphabet]
+ local id = getboth(style,alternative)
+ local f_unicode = remapalphabets(first,id) or utfbyte(first)
+ local l_unicode = remapalphabets(last,id) or utfbyte(last)
+ context("%05X - %05X",f_unicode,l_unicode)
+ ctx_NC()
+ ctx_NR()
+ end
+ end
+ end
+ ctx_stoptabulate()
+end
+
+function moduledata.math.coverage.showcharacters()
+ ctx_startmixedcolumns { balance = "yes" }
+ ctx_setupalign { "nothyphenated" }
+ ctx_starttabulate { "|T|i2|Tpl|" }
+ for u, d in sortedhash(chardata) do
+ local mathclass = d.mathclass
+ local mathspec = d.mathspec
+ if mathclass or mathspec then
+ ctx_NC()
+ context("%05X",u)
+ ctx_NC()
+ ctx_getglyph("MathRoman",u)
+ ctx_NC()
+ if mathspec then
+ local t = { }
+ for i=1,#mathspec do
+ t[mathspec[i].class] = true
+ end
+ t = table.sortedkeys(t)
+ context("% t",t)
+ else
+ context(mathclass)
+ end
+ ctx_NC()
+ ctx_NR()
+ end
+ end
+ ctx_stoptabulate()
+ ctx_stopmixedcolumns()
+end
+
+-- This is a somewhat tricky table as we need to bypass the math machinery.
+
+function moduledata.math.coverage.showscripts()
+ ctx_starttabulate { "|cT|c|cT|c|c|c|l|" }
+ for k, v in sortedhash(table.merged(superscripts,subscripts)) do
+ local ck = utfchar(k)
+ local cv = utfchar(v)
+ local ss = superscripts[k] and "^" or "_"
+ ctx_NC() context("%05X",k)
+ ctx_NC() context(ck)
+ ctx_NC() context("%05X",v)
+ ctx_NC() context(cv)
+ ctx_NC() ctx_rawmathematics("x%s = x%s%s",ck,ss,cv)
+ ctx_NC() ctx_mathematics("x%s = x%s%s",ck,ss,cv)
+ ctx_NC() context(lower(chardata[k].description))
+ ctx_NC() ctx_NR()
+ end
+ ctx_stoptabulate()
+end
+
+-- Handy too.
+
+function moduledata.math.coverage.showbold()
+ ctx_starttabulate { "|lT|cm|lT|cm|lT|" }
+ for k, v in sortedhash(mathematics.boldmap) do
+ ctx_NC() context("%U",k)
+ ctx_NC() context("%c",k)
+ ctx_NC() context("%U",v)
+ ctx_NC() context("%c",v)
+ ctx_NC() context(chardata[k].description)
+ ctx_NC() ctx_NR()
+ end
+ ctx_stoptabulate()
+end
+
+-- function moduledata.math.coverage.showentities()
+-- ctx_startmixedcolumns { balance = "yes" }
+-- ctx_starttabulate { "|Tl|c|Tl|" }
+-- for k, v in sortedhash(characters.entities) do
+-- local b = utf.byte(v)
+-- local d = chardata[b]
+-- local m = d.mathname
+-- local c = d.contextname
+-- local s = ((m and "\\"..m) or (c and "\\".. c) or v) .. "{}{}{}"
+-- ctx_NC()
+-- context("%U",b)
+-- ctx_NC()
+-- ctx_mathematics(s)
+-- ctx_NC()
+-- context(k)
+-- ctx_NC()
+-- ctx_NR()
+-- end
+-- ctx_stoptabulate()
+-- ctx_stopmixedcolumns()
+-- end
+
+function moduledata.math.coverage.showentities()
+ ctx_startmixedcolumns { balance = "yes" }
+ ctx_starttabulate { "|T||T|T|" }
+ for k, v in sortedhash(characters.entities) do
+ local d = chardata[v]
+ if d then
+ local m = d.mathclass or d.mathspec
+ local u = d.unicodeslot
+ ctx_NC() context(m and "m" or "t")
+ ctx_NC() ctx_getglyph("MathRoman",u)
+ ctx_NC() context("%05X",u)
+ ctx_NC() context(k)
+ ctx_NC() ctx_NR()
+ end
+ end
+ ctx_stoptabulate()
+ ctx_stopmixedcolumns()
+end
+
diff --git a/Master/texmf-dist/tex/context/modules/mkiv/s-math-coverage.mkiv b/Master/texmf-dist/tex/context/modules/mkiv/s-math-coverage.mkiv
new file mode 100644
index 00000000000..e318c9effdd
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkiv/s-math-coverage.mkiv
@@ -0,0 +1,38 @@
+%D \module
+%D [ file=s-math-coverage, % s-fnt-33, s-fnt-32
+%D version=2011.05.10, % and older
+%D title=\CONTEXT\ Style File,
+%D subtitle=Show Math Coverage,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\startmodule[math-coverage]
+
+\registerctxluafile{s-math-coverage}{}
+
+\installmodulecommandluasingle \showmathalphabets {moduledata.math.coverage.showalphabets}
+\installmodulecommandluasingle \showmathcharacters{moduledata.math.coverage.showcharacters}
+\installmodulecommandluasingle \showmathscripts {moduledata.math.coverage.showscripts}
+\installmodulecommandluasingle \showmathbold {moduledata.math.coverage.showbold}
+\installmodulecommandluasingle \showmathentities {moduledata.math.coverage.showentities}
+
+\stopmodule
+
+\continueifinputfile{s-math-coverage.mkiv}
+
+\usemodule[art-01]
+
+\starttext
+
+ \showmathalphabets \page
+ \showmathcharacters \page
+ \showmathscripts \page
+ \showmathbold \page
+ \showmathentities \page
+
+\stoptext
diff --git a/Master/texmf-dist/tex/context/modules/mkiv/s-math-extensibles.mkiv b/Master/texmf-dist/tex/context/modules/mkiv/s-math-extensibles.mkiv
new file mode 100644
index 00000000000..f9ff8547ae1
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkiv/s-math-extensibles.mkiv
@@ -0,0 +1,145 @@
+%D \module
+%D [ file=s-math-extensibles.mkiv,
+%D version=2013.02.03,
+%D title=\CONTEXT\ Style File,
+%D subtitle=Math Stackers Checking,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+%D This module provides a macro that will typeset a table of (horizontal)
+%D extensibles including some tracing. You can set up the \type {demo}
+%D stacker category to tweak things.
+%D
+%D \starttyping
+%D \showmathextensibles[alternative=a|b]
+%D \stoptyping
+
+\startmodule[math-extensibles]
+
+\unprotect
+
+\definemathstackers
+ [demo]
+ [math]
+ [\c!offset=\v!max]
+
+\installcorenamespace{modulemathextensibles}
+\installcorenamespace{modulemathextensiblesalternative}
+
+\installdirectsetuphandler \??modulemathextensibles {modulemathextensibles}
+
+\setupmodulemathextensibles
+ [\c!alternative=\v!a]
+
+\unexpanded\def\showmathextensibles
+ {\dosingleempty\module_math_extensibles_show_all}
+
+\def\module_math_extensibles_show_all[#1]%
+ {\begingroup
+ \setupcurrentmodulemathextensibles[#1]%
+ \expandnamespacevalue\??modulemathextensiblesalternative\c!alternative\v!a
+ \endgroup}
+
+\def\modulemathextensiblesalternativea#1#2#3%
+ {\NC U+#1
+ \NC \filledhboxm{\math{\char"#1}}
+ \NC \hbox{\math{\mathextensible[demo]{"#1}{top}{bottom}}}
+ \NC \hbox{\math{\mathextensible[demo]{"#1}{}{bottom}}}
+ \NC \hbox{\math{\mathextensible[demo]{"#1}{top}{}}}
+ \NC \nohyphens \veryraggedright #2
+ \NC\NR}
+
+\setvalue{\??modulemathextensiblesalternative\v!a}%
+ {\enabletrackers[math.stackers.texts]
+ \starttabulate[|Tl|l|l|l|l|Tp|]
+ \ctxlua { moduledata.math.extensibles.show {
+ command = "modulemathextensiblesalternativea",
+ } }
+ \stoptabulate
+ \disabletrackers[math.stackers.texts]}
+
+\def\modulemathextensiblesalternativeb#1#2#3%
+ {\NC U+#1
+ \NC \math{\char"#1}
+ \NC \nohyphens \veryraggedright #3
+ \NC \NR}
+
+\setvalue{\??modulemathextensiblesalternative\v!b}%
+ {\enabletrackers[math.stackers.texts]
+ \starttabulate[|Tl|l|Tp|]
+ \ctxlua { moduledata.math.extensibles.show {
+ command = "modulemathextensiblesalternativeb",
+ sparse = true,
+ } }
+ \stoptabulate
+ \disabletrackers[math.stackers.texts]}
+
+\startluacode
+ moduledata.math = moduledata.math or { }
+ moduledata.math.extensibles = moduledata.math.extensibles or { }
+
+ function moduledata.math.extensibles.show(settings)
+ local command = settings.command
+ local sparse = settings.sparse
+ for k, v in table.sortedhash(characters.data) do
+ local mathextensible = v.mathextensible
+ if mathextensible == "r" or mathextensible == "l" or mathextensible == "h" then
+ local names = { }
+ local mathname = v.mathname
+ if mathname then
+ names[#names+1] = v.mathclass .. ":" .. mathname
+ end
+ local mathspec = v.mathspec
+ if mathspec then
+ for i=1,#mathspec do
+ local v = mathspec[i]
+ names[#names+1] = v.class .. ":" .. v.name
+ end
+ end
+ local mathfiller = v.mathfiller
+ if mathfiller then
+ names[#names+1] = "filler:" .. mathfiller
+ end
+ if not sparse or #names > 0 then
+ context[command](string.format("%04X",k),v.description,table.concat(names," "))
+ end
+ end
+ end
+ end
+\stopluacode
+
+\protect
+
+\stopmodule
+
+\continueifinputfile{s-math-extensibles.mkiv}
+
+\setuplayout
+ [width=middle,
+ height=middle,
+ footer=0cm,
+ backspace=1.5cm,
+ topspace=1.5cm]
+
+\setuphead[chapter][style=\bfc]
+\setuphead[section][style=\bfa]
+
+\starttext
+
+ \dowith {a,b} {
+
+ \page \title {Latin Modern} \showmathextensibles[alternative=#1]
+ \page \setupbodyfont[pagella] \title {Pagella} \showmathextensibles[alternative=#1]
+ \page \setupbodyfont[termes] \title {Termes} \showmathextensibles[alternative=#1]
+ \page \setupbodyfont[dejavu] \title {Xits} \showmathextensibles[alternative=#1]
+ \page \setupbodyfont[cambria] \title {Cambria} \showmathextensibles[alternative=#1]
+ \page \setupbodyfont[lucidaot] \title {Lucida} \showmathextensibles[alternative=#1]
+
+ }
+
+\stoptext
diff --git a/Master/texmf-dist/tex/context/modules/mkiv/s-math-parameters.lua b/Master/texmf-dist/tex/context/modules/mkiv/s-math-parameters.lua
new file mode 100644
index 00000000000..8e8c15a2d37
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkiv/s-math-parameters.lua
@@ -0,0 +1,135 @@
+if not modules then modules = { } end modules ['s-math-coverage'] = {
+ version = 1.001,
+ comment = "companion to s-math-coverage.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+moduledata.math = moduledata.math or { }
+moduledata.math.parameters = moduledata.math.parameters or { }
+
+local tables = utilities.tables.definedtable("math","tracing","spacing","tables")
+
+tables.styleaxis = {
+ "ord", "op", "bin", "rel", "open", "close", "punct", "inner",
+}
+
+tables.parameters = {
+ "quad", "axis", "operatorsize",
+ "overbarkern", "overbarrule", "overbarvgap",
+ "underbarkern", "underbarrule", "underbarvgap",
+ "radicalkern", "radicalrule", "radicalvgap",
+ "radicaldegreebefore", "radicaldegreeafter", "radicaldegreeraise",
+ "stackvgap", "stacknumup", "stackdenomdown",
+ "fractionrule", "fractionnumvgap", "fractionnumup",
+ "fractiondenomvgap", "fractiondenomdown", "fractiondelsize",
+ "limitabovevgap", "limitabovebgap", "limitabovekern",
+ "limitbelowvgap", "limitbelowbgap", "limitbelowkern",
+ "underdelimitervgap", "underdelimiterbgap",
+ "overdelimitervgap", "overdelimiterbgap",
+ "subshiftdrop", "supshiftdrop", "subshiftdown",
+ "subsupshiftdown", "subtopmax", "supshiftup",
+ "supbottommin", "supsubbottommax", "subsupvgap",
+ "spaceafterscript", "connectoroverlapmin",
+}
+
+tables.styles = {
+ "display",
+ "text",
+ "script",
+ "scriptscript",
+}
+
+function tables.stripmu(str)
+ str = string.gsub(str,"mu","")
+ str = string.gsub(str," ","")
+ str = string.gsub(str,"plus","+")
+ str = string.gsub(str,"minus","-")
+ return str
+end
+
+function tables.strippt(old)
+ local new = string.gsub(old,"pt","")
+ if new ~= old then
+ new = string.format("%0.4f",tonumber(new))
+ end
+ return new
+end
+
+function moduledata.math.parameters.showspacing()
+
+ local styles = tables.styles
+ local styleaxis = tables.styleaxis
+
+ context.starttabulate { "|Tl|Tl|" .. string.rep("Tc|",(#styles*2)) }
+ context.HL()
+ context.NC()
+ context.NC()
+ context.NC()
+ for i=1,#styles do
+ context.bold(styles[i])
+ context.NC()
+ context.bold("(cramped)")
+ context.NC()
+ end
+ context.NR()
+ context.HL()
+ for i=1,#styleaxis do
+ -- print(key,tex.getmath(key,"text"))
+ local one = styleaxis[i]
+ for j=1,#styleaxis do
+ local two = styleaxis[j]
+ context.NC()
+ if j == 1 then
+ context.bold(one)
+ end
+ context.NC()
+ context.bold(two)
+ context.NC()
+ for i=1,#styles do
+ context("\\ctxlua{context(math.tracing.spacing.tables.stripmu('\\the\\Umath%s%sspacing\\%sstyle'))}",one,two,styles[i])
+ context.NC()
+ context("\\ctxlua{context(math.tracing.spacing.tables.stripmu('\\the\\Umath%s%sspacing\\cramped%sstyle'))}",one,two,styles[i])
+ context.NC()
+ end
+ context.NR()
+ end
+ end
+ context.stoptabulate()
+end
+
+function moduledata.math.parameters.showparameters()
+
+ local styles = tables.styles
+ local parameters = tables.parameters
+
+ context.starttabulate { "|l|" .. string.rep("Tc|",(#styles*2)) }
+ context.HL()
+ context.NC()
+ context.NC()
+ for i=1,#styles do
+ context.bold(styles[i])
+ context.NC()
+ context.bold("(cramped)")
+ context.NC()
+ end
+ context.NR()
+ context.HL()
+ for i=1,#parameters do
+ local parameter = parameters[i]
+ -- print(parameter,tex.getmath(parameter,"text"))
+ context.NC()
+ context.type(parameter)
+ context.NC()
+ for i=1,#styles do
+ context("\\ctxlua{context(math.tracing.spacing.tables.strippt('\\the\\Umath%s\\%sstyle'))}",parameter,styles[i])
+ context.NC()
+ context("\\ctxlua{context(math.tracing.spacing.tables.strippt('\\the\\Umath%s\\cramped%sstyle'))}",parameter,styles[i])
+ context.NC()
+ end
+ context.NR()
+ end
+ context.stoptabulate()
+
+end
diff --git a/Master/texmf-dist/tex/context/modules/mkiv/s-math-parameters.mkiv b/Master/texmf-dist/tex/context/modules/mkiv/s-math-parameters.mkiv
new file mode 100644
index 00000000000..f2fde5d8384
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkiv/s-math-parameters.mkiv
@@ -0,0 +1,41 @@
+%D \module
+%D [ file=s-math-parameters.mkiv,
+%D version=2012.12.05,
+%D title=\CONTEXT\ Style File,
+%D subtitle=Show Math Parameters,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\startmodule[math-parameters]
+
+\registerctxluafile{s-math-parameters}{}
+
+\installmodulecommandluasingle \showmathspacing {moduledata.math.parameters.showspacing}
+\installmodulecommandluasingle \showmathparameters {moduledata.math.parameters.showparameters}
+
+\stopmodule
+
+\continueifinputfile{s-math-parameters.mkiv}
+
+\setuplayout
+ [width=middle,
+ height=middle,
+ backspace=1cm,
+ topspace=1cm,
+ footer=0pt,
+ header=0pt]
+
+\setupbodyfont
+ [dejavu,8pt]
+
+\starttext
+
+ \showmathspacing \page
+ \showmathparameters \page
+
+\stoptext
diff --git a/Master/texmf-dist/tex/context/modules/mkiv/s-math-repertoire.mkiv b/Master/texmf-dist/tex/context/modules/mkiv/s-math-repertoire.mkiv
new file mode 100644
index 00000000000..230eb513ebe
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkiv/s-math-repertoire.mkiv
@@ -0,0 +1,487 @@
+%D \module
+%D [ file=s-math-parameters.mkiv, % was s-mat-12.mkiv
+%D version=2012.06.06, % whatever, probably a bit earlier
+%D title=\CONTEXT\ Style File,
+%D subtitle=Show Math Character Repertoire,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\usemodule[s][math-characters]
+
+% context --jit --global --bodyfont=lucidanova --result=math-repertoire-lucidanova s-math-repertoire.mkiv
+% context --jit --global --bodyfont=cambria --result=math-repertoire-cambria s-math-repertoire.mkiv
+% context --jit --global --bodyfont=xits --result=math-repertoire-xits s-math-repertoire.mkiv
+% context --jit --global --bodyfont=modern --result=math-repertoire-modern s-math-repertoire.mkiv
+% context --jit --global --bodyfont=pagella --result=math-repertoire-pagella s-math-repertoire.mkiv
+% context --jit --global --bodyfont=termes --result=math-repertoire-termes s-math-repertoire.mkiv
+% context --jit --global --bodyfont=bonum --result=math-repertoire-bonum s-math-repertoire.mkiv
+
+\startmodule[math-repertoire]
+
+% layout
+
+\definecolor[backgroundcolor] [r=.6,g=.6]
+\definecolor[backgroundcolorx][r=.6]
+\definecolor[backgroundcolory][g=.6]
+\definecolor[baselinecolor] [a=1,t=.5,s=.6]
+\definecolor[charactercolor] [b=.6]
+\definecolor[pagecolor] [s=.1]
+\definecolor[nonecolor] [s=.5]
+\definecolor[textcolor] [s=.9]
+
+% \setuppapersize[HD]
+%
+% \setuplayout
+% [page]
+
+\setuppapersize
+ [HD+]
+
+\setuplayout
+ [backspace=0pt,
+ topspace=0pt,
+ bottomspace=120pt, %1200-1080
+ bottom=24pt,
+ bottomdistance=5mm,
+ header=0pt,
+ footer=0pt,
+ width=middle,
+ height=middle]
+
+\definelayer
+ [page]
+
+\setuplayer
+ [page]
+ [width=\textwidth,
+ height=\textheight]
+
+\setupbackgrounds
+ [page]
+ [background=color,
+ backgroundcolor=pagecolor]
+
+\setupbackgrounds
+ [text][text]
+ [bottomframe=on,
+ framecolor=textcolor,
+ rulethickness=0.025ex]
+
+\setupmakeup
+ [standard]
+ [pagestate=start]
+
+\setupinteraction
+ [state=start,
+ menu=on]
+
+\defineinteractionmenu
+ [ALPHABETS]
+ [bottom]
+
+\defineinteractionmenu
+ [alphabets]
+ [bottom]
+
+\defineinteractionmenu
+ [symbols]
+ [bottom]
+
+\setupinteractionmenu
+ [bottom]
+ [before=\vfill,
+ after=\vfill,
+ left=\hfill,
+ right=\hfill,
+ style=\tt\bf,
+ distance=0pt,
+ color=textcolor,
+ contrastcolor=nonecolor]
+
+\def\showmathcharacterssetrange#1#2#3%
+ {\writestatus{range}{#1: \unihex{#2} - \unihex{#3}}%
+ \ifcase#2\relax
+ \definereference[#1][notpresent]%
+ \else\ifcase#3\relax
+ \definereference[#1][notpresent]%
+ \else
+ \normalexpanded{\definereference[#1][\unihex{#2}]}%
+ \fi\fi}
+
+\startinteractionmenu[bottom]
+ \startgot [firstpage] first \stopgot \quad
+ \startgot [deltapage(-100)] -100 \stopgot \quad
+ \startgot [deltapage(-10)] -10 \stopgot \quad
+ \startgot [previouspage] previous \stopgot \quad
+ \startgot [nextpage] next \stopgot \quad
+ \startgot [deltapage(+10)] +10 \stopgot \quad
+ \startgot [deltapage(+100)] +100 \stopgot \quad
+ \startgot [lastpage] last \stopgot
+\stopinteractionmenu
+
+\startinteractionmenu[ALPHABETS]
+ \startgot [U+00041] NORMAL \stopgot \quad
+ \startgot [U+1D400] BOLD \stopgot \quad
+ \startgot [U+1D434] ITALIC \stopgot \quad
+ \startgot [U+1D468] BOLDITALIC \stopgot \quad
+ \startgot [U+1D49C] SCRIPT \stopgot \quad
+ \startgot [U+1D4D0] BOLDSCRIPT \stopgot \quad
+ \startgot [U+1D504] FRAKTUR \stopgot \quad
+ \startgot [U+1D538] DOUBLESTRUCK \stopgot \quad
+ \startgot [U+1D56C] BOLDFRAKTUR \stopgot \quad
+ \startgot [U+1D5A0] SS NORMAL \stopgot \quad
+ \startgot [U+1D5D4] SS BOLD \stopgot \quad
+ \startgot [U+1D608] SS ITALIC \stopgot \quad
+ \startgot [U+1D63C] SS BOLDITALIC \stopgot \quad
+ \startgot [U+1D670] MONOSPACE \stopgot \quad
+ \startgot [U+00391] GRK NORMAL \stopgot \quad
+ \startgot [U+1D6A8] GRK BOLD \stopgot \quad
+ \startgot [U+1D6E2] GRK ITALIC \stopgot \quad
+ \startgot [U+1D71C] GRK BOLDITALIC \stopgot \quad
+ \startgot [U+1D756] GRK SS BOLD \stopgot \quad
+ \startgot [U+1D790] GRK SS BOLDITALIC \stopgot
+\stopinteractionmenu
+
+\startinteractionmenu[alphabets]
+ \startgot [U+00061] normal \stopgot \quad
+ \startgot [U+1D41A] bold \stopgot \quad
+ \startgot [U+1D44E] italic \stopgot \quad
+ \startgot [U+1D482] bolditalic \stopgot \quad
+ \startgot [U+1D4B6] script \stopgot \quad
+ \startgot [U+1D4EA] boldscript \stopgot \quad
+ \startgot [U+1D51E] fraktur \stopgot \quad
+ \startgot [U+1D552] doublestruck \stopgot \quad
+ \startgot [U+1D586] boldfraktur \stopgot \quad
+ \startgot [U+1D5BA] ss normal \stopgot \quad
+ \startgot [U+1D5EE] ss bold \stopgot \quad
+ \startgot [U+1D622] ss italic \stopgot \quad
+ \startgot [U+1D656] ss bolditalic \stopgot \quad
+ \startgot [U+1D68A] monospace \stopgot \quad
+ \startgot [U+003B1] grk normal \stopgot \quad
+ \startgot [U+1D6C2] grk bold \stopgot \quad
+ \startgot [U+1D6FC] grk italic \stopgot \quad
+ \startgot [U+1D736] grk bolditalic \stopgot \quad
+ \startgot [U+1D770] grk ss bold \stopgot \quad
+ \startgot [U+1D7AA] grk ss bolditalic \stopgot
+\stopinteractionmenu
+
+% \startinteractionmenu[symbols]
+% \startgot [U+00030] dig normal \stopgot \quad
+% \startgot [U+1D7CE] dig bold \stopgot \quad
+% \startgot [U+1D7D8] dig doublestruck \stopgot \quad
+% \startgot [U+1D7E2] dig ss normal \stopgot \quad
+% \startgot [U+1D7EC] dig ss bold \stopgot \quad
+% \startgot [U+1D7F6] dig monospace \stopgot \quad
+% \startgot [U+02200] operators \stopgot \quad
+% \startgot [U+02701] symbols a \stopgot \quad
+% \startgot [U+02901] symbols b \stopgot \quad
+% \startgot [U+02A00] supplemental \stopgot \quad
+% \startgot [U+027F0] arrows a \stopgot \quad
+% \startgot [U+02900] arrows b \stopgot \quad
+% \startgot [U+1F800] arrows c \stopgot
+% \stopinteractionmenu
+
+\startinteractionmenu[symbols]
+ \startgot [U+00030] dig normal \stopgot \quad
+ \startgot [U+1D7CE] dig bold \stopgot \quad
+ \startgot [U+1D7D8] dig doublestruck \stopgot \quad
+ \startgot [U+1D7E2] dig ss normal \stopgot \quad
+ \startgot [U+1D7EC] dig ss bold \stopgot \quad
+ \startgot [U+1D7F6] dig monospace \stopgot \quad
+ \startgot [U+02200] operators \stopgot \quad
+ \startgot [miscellaneousmathematicalsymbolsa] symbols a \stopgot \quad
+ \startgot [miscellaneousmathematicalsymbolsb] symbols b \stopgot \quad
+ \startgot [supplementalmathematicaloperators] supplemental \stopgot \quad
+ \startgot [supplementalarrowsa] arrows a \stopgot \quad
+ \startgot [supplementalarrowsb] arrows b \stopgot \quad
+ \startgot [supplementalarrowsc] arrows c \stopgot \quad
+ \removeunwantedspaces
+\stopinteractionmenu
+
+\defineframed
+ [somedata]
+ [background=color,
+ backgroundcolor=textcolor,
+ %framecolor=charactercolor,
+ %rulethickness=1pt,
+ frame=off,
+ offset=1ex]
+
+% helpers
+
+\unexpanded\def\showmathcharacterstxt#1%
+ {{\tttf#1}}
+
+\unexpanded\def\showmathcharacterschr#1#2%
+ {\iffontchar\font#2\relax
+ \scale
+ [sx=#1,sy=#1]
+ {\dontleavehmode
+ \begingroup
+ \setbox\scratchbox\hbox{\charactercolor\char#2}%
+ \scratchdimen\wd\scratchbox
+ \ifdim\scratchdimen>\zeropoint
+ \backgroundline[backgroundcolor]{\box\scratchbox}%
+ \else\ifdim\scratchdimen<\zeropoint
+ \scratchdimen-\scratchdimen
+ \setbox\scratchbox\hbox to \scratchdimen{\hss\charactercolor\char#2}%
+ \backgroundline[backgroundcolorx]{\box\scratchbox}%
+ \else
+ \setbox\scratchbox\hbox to 1em{\hss\charactercolor\char#2}%
+ \scratchdimen\wd\scratchbox
+ \backgroundline[backgroundcolory]{\box\scratchbox}%
+ \fi\fi
+ \hskip-\scratchdimen
+ \baselinecolor\vrule width \scratchdimen height .05ex depth .05ex
+ \endgroup}%
+ \fi}
+
+\unexpanded\def\showmathcharactersmth#1#2%
+ {\setbox\scratchbox\hbox{\showmathcharacterschr{#1}{#2}}%
+ \ht\scratchbox\strutht
+ \dp\scratchbox\strutdp
+ \box\scratchbox}
+
+\let\showmathcharactersbodyfonts\empty
+
+\unexpanded\def\showmathcharactersbodyfontentry#1#2%
+ {\somedata
+ [align={none,middle},background=,height=5cm]
+ {\begingroup
+ \switchtobodyfont[#2,12pt]%
+ \definedfont[MathRoman*math-text]%
+ \showmathcharactersmth{10}{#1}%
+ \endgroup
+ \vfilll
+ \doifelsemode{crosslink}
+ {\goto{\strut\textcolor\showmathcharacterstxt{#2}}[#2::#1]}%
+ {\strut\textcolor\showmathcharacterstxt{#2}}}%
+ \hskip1ex}
+
+\unexpanded\def\showmathcharacterssetbodyfonts#1%
+ {\edef\showmathcharactersbodyfonts{#1}%
+ \def\doshowmathcharacterssetbodyfonts##1{\setupbodyfont[##1,12pt]}%
+ \processcommacommand[\showmathcharactersbodyfonts]\doshowmathcharacterssetbodyfonts}
+
+\unexpanded\def\showmathcharactersbodyfontschars#1%
+ {\processcommacommand[\showmathcharactersbodyfonts]{\showmathcharactersbodyfontentry{#1}}}
+
+% main
+
+\unexpanded\def\showmathcharactersstart
+ {\starttext
+ \startstandardmakeup % we use baselinecolor so that we have a transparency on page 1
+ \setupalign[middle]
+ \vfil
+ \dontleavehmode \scale[height=.3\textheight]{\strut\color[textcolor]{\fontclass}}
+ \vfil
+ \dontleavehmode \scale[height=.1\textheight]{\strut\color[baselinecolor]{\currentdate}}
+ \vfil
+ \vfil
+ \stopstandardmakeup}
+
+\unexpanded\def\showmathcharactersstop
+ {\stoptext}
+
+% entry
+
+\unexpanded\def\showmathcharactersstartentry
+ {\startstandardmakeup}
+
+\unexpanded\def\showmathcharactersstopentry
+ {\tightlayer[page]
+ \stopstandardmakeup}
+
+\unexpanded\def\showmathcharactersreference#1%
+ {\setlayer[page]{\pagereference[#1]}}
+
+\unexpanded\def\showmathcharactersentryhexdectit#1#2#3%
+ {\setlayer
+ [page]
+ [preset=middletop,voffset=5mm]
+ {\somedata[height=1cm]{\showmathcharacterstxt{#1}}}
+ \setlayer
+ [page]
+ [preset=middle,y=2cm]
+ {\showmathcharactersmth{25}{#2}}
+ \setlayer
+ [page]
+ [preset=righttop,offset=5mm]
+ {\somedata[height=1cm]{\showmathcharacterstxt{#3}}}
+ \doifsomething\showmathcharactersbodyfonts
+ {\setlayer
+ [page]
+ [preset=middlebottom,voffset=5mm]
+ {\showmathcharactersbodyfontschars{#2}}}}
+
+% dimensions
+
+\unexpanded\def\showmathcharactersentrywdhtdpic#1#2#3#4%
+ {\setlayer
+ [page]
+ [preset=leftbottom,offset=5mm]
+ {\somedata[align=normal,width=5cm]
+ {\strut width \hfill \the\dimexpr#1sp\par
+ \strut height\hfill \the\dimexpr#2sp\par
+ \strut depth \hfill \the\dimexpr#3sp\par
+ \strut italic\hfill \the\dimexpr#4sp}}}
+
+\unexpanded\def\showmathcharactersentryresource#1%
+ {} % {virtual: #1\par}
+
+% next
+
+\unexpanded\def\showmathcharactersstartnext
+ {\setlayer
+ [page]
+ [preset=middleleft,hoffset=5mm]
+ \bgroup\vbox\bgroup}
+
+\unexpanded\def\showmathcharactersstopnext
+ {\egroup\egroup}
+
+\unexpanded\def\showmathcharactersnextentry#1#2#3%
+ {\ifnum#1>1 \vskip1ex \fi
+ \dontleavehmode\somedata
+ [align=normal,width=4cm]
+ {\strut\showmathcharacterstxt{#2}\hfill\showmathcharacterschr{2}{#3}}\par}
+
+\unexpanded\def\showmathcharactersnextcycle#1%
+ {\ifnum#1>1 \vskip1ex \fi
+ \dontleavehmode\somedata
+ [align=normal,width=4cm]
+ {\strut\showmathcharacterstxt{cycle}}\par}
+
+% variants
+
+\unexpanded\def\showmathcharactersstartvvariants
+ {\setlayer
+ [page]
+ [preset=lefttop,offset=5mm]
+ \bgroup\vbox\bgroup}
+
+\unexpanded\def\showmathcharactersstarthvariants
+ {\setlayer
+ [page]
+ [preset=lefttop,offset=5mm]
+ \bgroup\hbox\bgroup}
+
+\unexpanded\def\showmathcharactersvvariantsentry#1#2#3%
+ {\ifnum#1>1 \vskip1ex \fi
+ \dontleavehmode\somedata
+ [align=middle,width=4cm]
+ {\strut\showmathcharacterstxt{#2}\hfilll\showmathcharacterschr{2}{#3}}}
+
+\unexpanded\def\showmathcharactershvariantsentry#1#2#3%
+ {\ifnum#1>1 \hskip1ex \else \dontleavehmode \fi
+ \somedata
+ [align={none,middle},height=2cm]
+ {\strut\showmathcharacterstxt{#2}\vfilll\showmathcharacterschr{2}{#3}}}
+
+\unexpanded\def\showmathcharactersstopvvariants
+ {\egroup\egroup}
+
+\unexpanded\def\showmathcharactersstophvariants
+ {\egroup\egroup}
+
+\unexpanded\def\showmathcharactersbetweennextandvariants
+ {}
+
+% classes
+
+\unexpanded\def\showmathcharactersstartentryclassspec
+ {\setlayer
+ [page]
+ [preset=rightbottom,offset=5mm]
+ \bgroup\somedata[align=normal,width=8cm]\bgroup}
+
+\unexpanded\def\showmathcharactersstopentryclassspec
+ {\egroup\egroup}
+
+\unexpanded\def\showmathcharactersentryclassname#1#2%
+ {\strut{\showmathcharacterstxt#1}\hfill\showmathcharacterstxt{#2}\par}
+
+% symbols
+
+\unexpanded\def\showmathcharactersentrysymbol#1#2%
+ {\setlayer
+ [page]
+ [preset=leftbottom,hoffset=5mm,voffset=50mm]
+ {\somedata
+ [align=normal,width=5cm]
+ {\showmathcharacterstxt{#1}\hfill\showmathcharacterschr{4}{#2}}}}
+
+% alternates
+
+\unexpanded\def\showmathcharactersstartlookupvariants
+ {\setlayer
+ [page]
+ [preset=middleright,hoffset=5mm]
+ \bgroup\vbox\bgroup}
+
+\unexpanded\def\showmathcharactersstoplookupvariants
+ {\egroup\egroup}
+
+\unexpanded\def\showmathcharacterslookupvariant#1#2#3#4%
+ {\ifnum#1>1 \vskip1ex \fi
+ \somedata
+ [align=normal,width=7cm]
+ {\showmathcharacterstxt{#4:} \showmathcharacterstxt{#2}\hfill\showmathcharacterschr{4}{#3}}}
+
+% main
+
+% this is a one-run style so we can forget about an alternative
+% just assume that the previous definitions are global
+
+\unprotect
+
+\unexpanded\def\showmathfontrepertoire
+ {\dosingleempty\module_math_repertoire_show}
+
+\def\module_math_repertoire_show[#1]%
+ {\showmathfontcharacters[alternative=,option=,check=yes,#1]
+ \showmathfontcharacters[alternative=,option=,#1]}
+
+\protect
+
+\stopmodule
+
+\continueifinputfile{s-math-repertoire.mkiv}
+
+\showmathcharacterssetbodyfonts{lucidaot,cambria,xits,modern,pagella,termes,bonum,schola,dejavu}
+
+\starttext
+
+ \doifelse {\getdocumentargument{bodyfont}} {} {
+
+ % \setupbodyfont[cambria, 12pt]
+ % \setupbodyfont[modern, 12pt]
+ % \setupbodyfont[lmvirtual, 12pt]
+ % \setupbodyfont[pxvirtual, 12pt]
+ % \setupbodyfont[txvirtual, 12pt]
+ % \setupbodyfont[palatino, 10pt]
+ % \setupbodyfont[mathtimes, 12pt]
+ % \setupbodyfont[stix, 12pt]
+ % \setupbodyfont[xits, 12pt]
+ % \setupbodyfont[lucida, 12pt]
+ % \setupbodyfont[lucidaot, 12pt]
+ % \setupbodyfont[pagella, 12pt]
+ % \setupbodyfont[bonum, 12pt]
+ % \setupbodyfont[schola, 12pt]
+ \setupbodyfont[dejavu, 12pt]
+
+ } {
+
+ \normalexpanded{\setupbodyfont[\getdocumentargument{bodyfont},12pt]}
+
+ }
+
+ \showmathfontrepertoire
+
+\stoptext
+
diff --git a/Master/texmf-dist/tex/context/modules/mkiv/s-mod-00.mkiv b/Master/texmf-dist/tex/context/modules/mkiv/s-mod-00.mkiv
new file mode 100644
index 00000000000..7af56dc2de9
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkiv/s-mod-00.mkiv
@@ -0,0 +1,24 @@
+%D \module
+%D [ file=s-mod-00,
+%D version=very-old,
+%D title=\CONTEXT\ Style File,
+%D subtitle=Documentation Base Environment,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\unprotect
+
+\startmode[nocode]
+
+ % \definieerbuffer[definition] % ignore
+
+ \def\startdefinition#1\stopdefinition{}
+
+\stopmode
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/modules/mkiv/s-mod-01.mkiv b/Master/texmf-dist/tex/context/modules/mkiv/s-mod-01.mkiv
new file mode 100644
index 00000000000..6946bef691c
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkiv/s-mod-01.mkiv
@@ -0,0 +1,390 @@
+%D \module
+%D [ file=s-mod-01,
+%D version=very-old,
+%D title=\CONTEXT\ Style File,
+%D subtitle=Module Documentation,
+%D author={Hans Hagen \& Luigi Scarso},
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\unprotect
+
+%D Usage:
+%D
+%D \starttyping
+%D context --ctx=s-mod somefile.mkiv
+%D \stoptyping
+%D
+%D In due time there will be a \type {mtx-context-module} as well.
+%D
+%D Luigi Scarso coordinates the processing of modules so best contact
+%D him when you run into problems. Bugs in this style can be sent to
+%D Hans.
+
+\usemodule
+ [abr-00]
+
+\setvariables
+ [document]
+ [ file=\jobname,
+ type=unknown,
+ version={\currentdate[\v!year,{.},\v!month,{.},\v!day]},
+ system=\CONTEXT,
+ title=Unknown Title,
+ subtitle=,
+ author=Unknown Author,
+ date=\currentdate,
+ copyright=Unknown Copyright,
+ suggestions=]
+
+\let\module\setupdocument
+
+\definepalet [module:unknown] [localone=black,localtwo=white]
+
+\definepalet [module:tex] [localone=blue,localtwo=green]
+\definepalet [module:mkii] [localone=blue,localtwo=green]
+\definepalet [module:mkiv] [localone=blue,localtwo=green]
+\definepalet [module:mkvi] [localone=blue,localtwo=green]
+
+\definepalet [module:lua] [localone=red,localtwo=green]
+\definepalet [module:cld] [localone=red,localtwo=green]
+
+\definepalet [module:mp] [localone=red,localtwo=blue]
+\definepalet [module:mpii] [localone=red,localtwo=blue]
+\definepalet [module:mpiv] [localone=red,localtwo=blue]
+\definepalet [module:metapost][localone=red,localtwo=blue]
+
+\setuppalet
+ [module:unknown]
+
+\startuseMPgraphic{page}
+
+ StartPage ;
+
+ color local_white ; local_white := .8white ;
+ color local_one ; local_one := \MPcolor{localone} randomized (.6,.8) ;
+ color local_two ; local_two := \MPcolor{localtwo} randomized (.3,.4) ;
+
+ color local_one ; local_one := .75[\MPcolor{localone},white] ;
+ color local_two ; local_two := .75[\MPcolor{localtwo},white] ;
+
+ numeric width ; width := bbwidth Page ;
+ numeric height ; height := bbheight Page ;
+
+ u := width/400 ;
+
+ def a_module (expr dx, dy) =
+ picture p ; p := image (
+ ddy := 0 ; sx := 60u ;
+ for i=1 upto (4 randomized 2) :
+ sy := 7u randomized 3u ;
+ fill unitsquare xyscaled(sx,sy) shifted (0,ddy) withcolor local_two ;
+ ddy := ddy + sy + 4u ;
+ endfor ;
+ ) ;
+ p := p shifted (dx,dy) shifted - center p ;
+ fill boundingbox p enlarged 8u withcolor local_white ;
+ fill boundingbox p enlarged 4u withcolor local_one ;
+ draw p ;
+ enddef ;
+
+ set_grid(width, height, width/15, height/15) ;
+
+ forever:
+ if new_on_grid(uniformdeviate width,uniformdeviate height):
+ a_module(dx,dy) ;
+ fi ;
+ exitif grid_full ;
+ endfor ;
+
+ picture p ;
+
+ draw image (
+ draw anchored.urt(textext("\bf\strut\documentvariable{system}") ysized 5.0cm,urcorner Page shifted (-1cm,- 1cm)) ;
+ draw anchored.urt(textext("\bf\strut\documentvariable{title}") ysized 1.5cm,urcorner Page shifted (-1cm,- 8cm)) ;
+ draw anchored.urt(textext("\bf\strut\documentvariable{subtitle}") ysized 1.5cm,urcorner Page shifted (-1cm,-10cm)) ;
+ draw anchored.urt(textext("\bf\strut\documentvariable{author}") ysized 1.5cm,lrcorner Page shifted (-1cm, 5cm)) ;
+ draw anchored.urt(textext("\bf\strut\currentdate") ysized 1.5cm,lrcorner Page shifted (-1cm, 3cm)) ;
+ ) withcolor .25white ;
+
+ StopPage ;
+
+\stopuseMPgraphic
+
+\startsetups[document:start]
+
+ \setuppalet
+ [module:\documentvariable{type}]
+
+ \startTEXpage
+ \useMPgraphic{page}
+ \stopTEXpage
+
+ \page[right]
+
+\stopsetups
+
+\startsetups[document:stop]
+
+ \page
+
+ \placeregister
+ [\v!index]
+ [\c!balance=\v!yes,
+ \c!indicator=\v!no,
+ \c!criterium=\v!text]
+
+\stopsetups
+
+% In order to be able to typeset this one too, we need to avoid
+% direct backslashed names.
+
+\starttexdefinition startmoduledocumentation
+ \starttext
+ \page
+ \begingroup
+ \startdocument
+\stoptexdefinition
+
+\starttexdefinition stopmoduledocumentation
+ \stopdocument
+ \page
+ \endgroup
+ \stoptext
+\stoptexdefinition
+
+\starttexdefinition startdocumentation
+ \par
+ \bgroup
+\stoptexdefinition
+
+\starttexdefinition stopdocumentation
+ \par
+ \egroup
+\stoptexdefinition
+
+\definetyping
+ [definition]
+
+\starttexdefinition startcompressdefinitions
+ \blank
+ \begingroup
+ \setuptyping[definition][bodyfont=small]
+\stoptexdefinition
+
+\starttexdefinition stopcompressdefinitions
+ \blank
+ \endgroup
+\stoptexdefinition
+
+\definetyping [PL] [\c!option=PL]
+\definetyping [JV] [\c!option=JV]
+\definetyping [MP] [\c!option=MP]
+\definetyping [TEX] [\c!option=TEX]
+\definetyping [LUA] [\c!option=LUA]
+
+\setuptyping [\v!typing] [\c!margin=\v!standard]
+\setuptyping [\v!file] [\c!margin=\v!standard]
+\setuptyping [definition] [\c!margin=0pt,\c!numbering=\v!line,\c!continue=\v!yes] % this continue wins
+
+\setuplinenumbering
+ [definition]
+ [\c!style=\ttx,
+ \c!distance=\leftmargindistance,
+ \c!align=\v!flushright]
+
+% This will be cleaned up.
+
+\unexpanded\def\domodulemarginstuff#1#2%
+ {\marginstuff
+ {\ifx#1\relax
+ \index{#2}%
+ \else
+ \index{#1{#2}}%
+ \fi
+ #1{\doboundtext{#2}{\leftmarginwidth}{..}}}}
+
+\unexpanded\def\modulemarginstuff#1#2% to be renamed
+ {\processcommalist[#2]{\domodulemarginstuff#1}}
+
+\definemargindata
+ [marginstuff]
+ [left]
+ [stack=yes,
+ hoffset=2em,
+ style=\ttxx]
+
+\unexpanded\def\macros {\modulemarginstuff\tex }
+\unexpanded\def\extras {\modulemarginstuff\relax}
+\unexpanded\def\elements{\modulemarginstuff\someelement}
+
+\unexpanded\def\someelement#1{\type{<#1>}}
+
+% [index]{command}
+
+% \macros{a,b}
+% \macros{a,b}{b}
+% \macros[a]{a,b}{b}
+
+% weg ermee (indeed):
+%
+% \defineparagraphs [interface] [\c!n=2]
+% \setupparagraphs [interface] [1] [\c!width=4cm]
+
+\starttexdefinition startexample
+ \par
+ \startnarrower
+\stoptexdefinition
+
+\starttexdefinition stopexample
+ \stopnarrower
+\stoptexdefinition
+
+%D Command references:
+
+\usemodule[int-load] \loadsetups
+
+\let\showsetup\setup
+
+\setupframedtexts
+ [setuptext]
+ [\c!background=\v!screen,
+ \c!frame=\v!off]
+
+% style (we use dejavu as it supports more characters)
+
+\switchtobodyfont
+ [dejavu-condensed,10pt] % preload
+
+\setupbodyfont
+ [dejavu,10pt] % main font
+
+\mainlanguage
+ [en]
+
+\setuptyping
+ [\v!typing]
+ [\c!bodyfont=dejavu-condensed]
+
+\setupwhitespace
+ [\v!big]
+
+\setuptolerance
+ [\v!verytolerant,\v!stretch]
+
+\setuplayout
+ [\c!backspace=3.5cm,
+ \c!leftmargin=1.75cm,
+ \c!rightmargin=0cm,
+ \c!margindistance=.5cm,
+ \c!leftedgedistance=.25cm,
+ \c!rightedgedistance=.5cm,
+ \c!edge=1.5cm,
+ \c!width=15.55333cm, % 13.998cm at 9pt => 15.55333 at 10pt
+ \c!topspace=2cm,
+ \c!header=1.25cm,
+ \c!footer=1.25cm,
+ \c!height=middle,
+ \c!style=\ss]
+
+\setuppagenumbering
+ [\c!location=]
+
+\setuppagenumbering
+ [\c!alternative={\v!doublesided,\v!singlesided}]
+
+\setupfootertexts
+ [\v!edge]
+ [][\pagenumber]
+
+\setupfootertexts
+ [\v!margin]
+ [\filename{\documentvariable{file}}][]
+ [\filename{\documentvariable{file}}][]
+
+\setupfootertexts
+ [\v!text]
+ [\CONTEXT]
+ [\documentvariable{title}]
+
+\setupheadertexts
+ [\v!text]
+ []
+ [\documentvariable{subtitle}]
+
+\setupinmargin
+ [\c!location=\v!left]
+
+\setupheads
+ [\c!alternative=\v!inmargin]
+
+\setuphead
+ [\v!chapter]
+ [\c!style=\bfc,
+ \c!page=\v!right,
+ \c!header=\v!empty]
+
+\setuphead
+ [\v!section]
+ [\c!style=\bfb,
+ \c!page=\v!right]
+
+\setuphead
+ [\v!subsection]
+ [\c!style=\bfa]
+
+\setuplist
+ [\v!chapter]
+ [\c!style=\v!bold,
+ \c!after=\blank]
+
+\setupcombinedlist
+ [\v!content]
+ [\c!width=3em,
+ \c!aligntitle=\v!yes]
+
+\setupregister
+ [\v!index]
+ [\c!balance=\v!yes,
+ \c!indicator=\v!no]
+
+\setupinteraction
+ [\c!state=\v!start,
+ \c!color=,
+ \c!contrastcolor=,
+ \c!style=]
+
+% modes
+
+\doifmode {nocolor} {
+
+ \setupcolors
+ [\c!conversion=\v!always]
+
+}
+
+\doifmode {singlesided} {
+
+ \setuppagenumbering
+ [\c!alternative=\v!singlesided]
+
+ \setupfootertexts
+ [\v!margin]
+ [\filename{\documentvariable{file}}][]
+
+}
+
+% bonus
+
+\usemodule
+ [abr-02]
+
+% another one
+
+\dontcomplain
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/modules/mkiv/s-mod-02.mkiv b/Master/texmf-dist/tex/context/modules/mkiv/s-mod-02.mkiv
new file mode 100644
index 00000000000..37e3d2f143e
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkiv/s-mod-02.mkiv
@@ -0,0 +1,24 @@
+%D \module
+%D [ file=s-mod-02,
+%D version=very-old,
+%D title=\CONTEXT\ Style File,
+%D subtitle=Documentation Screen Environment,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\unprotect
+
+\startmode[nocode]
+
+ % \definieerbuffer[definition] % ignore
+
+ \def\startdefinition#1\stopdefinition{}
+
+\stopmode
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/modules/mkiv/s-pages-statistics.mkiv b/Master/texmf-dist/tex/context/modules/mkiv/s-pages-statistics.mkiv
new file mode 100644
index 00000000000..375dd9949f2
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkiv/s-pages-statistics.mkiv
@@ -0,0 +1,134 @@
+%D \module
+%D [ file=s-pages-statistics, % s-otr-01,
+%D version=2012.02.02,
+%D title=\CONTEXT\ Style File,
+%D subtitle=Page Statistics,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\unprotect
+
+\defineframed
+ [otrstatistics]
+ [\c!offset=\bodyfontsize,
+ \c!background=\v!color,
+ \c!strut=\v!no,
+ \c!backgroundcolor=white,
+ \c!frame=\v!off,
+ \c!align=\v!middle]
+
+\definecombination
+ [otrstatistics]
+ [\c!nx=2,
+ \c!ny=2,
+ \c!location=\v!top]
+
+% expansion is neeed because tabulate sets some penalties
+
+\startsetups system:page:otr:statistics
+ \normalexpanded {
+ \startcombination[otrstatistics] {
+ \otrstatistics {
+ \starttabulate[|Tw(10em)|Trw(8em)|]
+ \NC \string\textwidth \NC \the\textwidth \NC \NR
+ \NC \string\textheight \NC \the\textheight \NC \NR
+ \NC \string\lineheight \NC \the\lineheight \NC \NR
+ \NC \string\strutheight \NC \strutheight \NC \NR
+ \NC \string\strutdepth \NC \strutdepth \NC \NR
+ % \NC \string\vsize \NC \the\vsize \NC \NR
+ \NC \string\topskip \NC \the\topskip \NC \NR
+ \stoptabulate
+ }
+ } {}
+ {
+ \otrstatistics {
+ \starttabulate[|Tw(10em)|Trw(8em)|]
+ \NC \string\pagegoal \NC \the\pagegoal \NC \NR
+ \NC \string\pagetotal \NC \the\pagetotal \NC \NR
+ \NC \string\pagedepth \NC \the\pagedepth \NC \NR
+ \NC \string\pageshrink \NC \the\pageshrink \NC \NR
+ \NC \string\pagestretch \NC \the\pagestretch \NC \NR
+ \NC \string\pagefilstretch \NC \the\pagefilstretch \NC \NR
+ \NC \string\pagefillstretch \NC \the\pagefillstretch \NC \NR
+ \NC \string\pagefilllstretch \NC \the\pagefilllstretch \NC \NR
+ \stoptabulate
+ }
+ } {}
+ {
+ \otrstatistics {
+ \starttabulate[|Tw(10em)|Trw(8em)|]
+ \NC \string\widowpenalty \NC \the\widowpenalty \NC \NR
+ \NC \string\clubpenalty \NC \the\clubpenalty \NC \NR
+ \NC \string\displaywidowpenalty \NC \the\displaywidowpenalty \NC \NR
+ \NC \string\brokenpenalty \NC \the\brokenpenalty \NC \NR
+ \NC \string\interlinepenalty \NC \the\interlinepenalty \NC \NR
+ \stoptabulate
+ }
+ } {}
+ {
+ \otrstatistics[\c!foregroundcolor=darkred] {
+ \starttabulate[|Tw(10em)|Trw(8em)|]
+ \NC page \NC \the\realpageno \NC \NR
+ \NC delta \NC \the\dimexpr\pagegoal-\pagetotal\relax \NC \NR
+ \stoptabulate
+ }
+ } {}
+ \stopcombination
+ }
+\stopsetups
+
+\defineoverlay
+ [system:page:otr:statistics]
+ [{\framed
+ [\c!offset=\bodyfontsize,
+ \c!background=\v!color,
+ \c!strut=\v!no,
+ %\c!frame=\v!off,
+ \c!framecolor=white,
+ \c!frameoffset=\onepoint,
+ \c!rulethickness=2\onepoint,
+ \c!backgroundcolor=darkblue,
+ \c!align=\v!middle]
+ {\forgetall
+ \insidefloattrue
+ \setups{system:page:otr:statistics}}}]
+
+\unexpanded\def\page_one_command_package_show_state_indeed
+ {\scratchheight\ht\b_page_one_contents
+ \scratchdepth \dp\b_page_one_contents
+ \setbox\b_page_one_contents\vbox\framed
+ [\c!offset=\v!overlay,
+ \c!framecolor=darkred,
+ \c!rulethickness=\onepoint,
+ \c!background={\v!foreground,system:page:otr:statistics}]
+ {\lower\scratchdepth\box\b_page_one_contents}%
+ \ht\b_page_one_contents\scratchheight
+ \dp\b_page_one_contents\scratchdepth}
+
+\let\page_one_command_package_show_state\relax
+
+\unexpanded\def\showpageproperties
+ {\let\page_one_command_package_show_state\page_one_command_package_show_state_indeed}
+
+\protect
+
+\continueifinputfile{s-pages-statistics.mkiv}
+
+\setupbodyfont[dejavu,11pt] \dontcomplain \showpageproperties
+
+\starttext
+
+\dorecurse {100} { \input tufte
+
+ \startitemize[packed,intro]
+ \startitem test \stopitem \startitem test \stopitem
+ \startitem test \stopitem \startitem test \stopitem
+ \stopitemize
+}
+
+\stoptext
diff --git a/Master/texmf-dist/tex/context/modules/mkiv/s-physics-units.mkiv b/Master/texmf-dist/tex/context/modules/mkiv/s-physics-units.mkiv
new file mode 100644
index 00000000000..50adc801431
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkiv/s-physics-units.mkiv
@@ -0,0 +1,30 @@
+%D \module
+%D [ file=s-physics-units, % s-phy-01,
+%D version=2011-11-24,
+%D title=\CONTEXT\ Modules,
+%D subtitle=Physics Units,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\startmodule[physics-units]
+
+\registerctxluafile{s-physics-units}{}
+
+\installmodulecommandluasingle \showunits {moduledata.physics.units.showlist}
+
+\stopmodule
+
+\continueifinputfile{s-physics-units.mkiv}
+
+\usemodule[art-01]
+
+\starttext
+
+ \showunits
+
+\stoptext
diff --git a/Master/texmf-dist/tex/context/modules/mkiv/s-pre-17.mkiv b/Master/texmf-dist/tex/context/modules/mkiv/s-pre-17.mkiv
new file mode 100644
index 00000000000..9c46b4ed7a4
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkiv/s-pre-17.mkiv
@@ -0,0 +1,408 @@
+%D \module
+%D [ file=s-pre-17,
+%D version=1999.08.20,
+%D title=\CONTEXT\ Style File,
+%D subtitle=Presentation Environment 17,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\setupbodyfont
+ [dejavu,11pt,ss]
+
+\setupsystem
+ [random=medium]
+
+\setupbackgrounds
+ [state=repeat]
+
+\setupbackgrounds
+ [page]
+ [background={page,forward}]
+
+\setupbackgrounds
+ [text][text]
+ [background=blowdown]
+
+\setupinteraction
+ [state=start,
+% click=off,
+ color=TitleColor,
+ contrastcolor=TitleColor]
+
+\setupinteractionscreen
+ [option=max]
+
+\setuptolerance
+ [verytolerant,stretch]
+
+\definecolor [BackColor] [s=.30]
+\definecolor [PageColor] [g=1]
+\definecolor [FrameColor] [r=1]
+\definecolor [TitleColor] [y=1]
+\definecolor [ArrowColor] [b=1]
+
+\defineoverlay [title] [\useMPgraphic{title}]
+\defineoverlay [page] [\useMPgraphic{page}]
+\defineoverlay [blowup] [{\hboxreference[whatever:\CurrentBlaBla]{\overlaybutton{whatever:\CurrentBlaBla}}}]
+\defineoverlay [blowdown] [{\hboxreference[page:\realfolio]{\overlaybutton{page:\realfolio}}}]
+\defineoverlay [forward] [\overlaybutton{forward}]
+
+\startMPinclusions
+ input "mp-abck.mpiv" ;
+\stopMPinclusions
+
+\startMPpositiongraphic{mppos:connection}
+ path pa, pb, pc ; pair ca, cb ;
+ initialize_box(\MPpos{\MPvar{self}}) ; pa := pxy ; ca := cxy ;
+ initialize_box(\MPpos{\MPvar{prev}}) ; pb := pxy ; cb := cxy ;
+ pickup pencircle scaled .5pt ;
+ pa := pa enlarged 10pt ;
+ pb := pb enlarged 10pt ;
+ for i=1 upto 10 :
+ draw pa randomized 20pt withcolor \MPcolor{FrameColor} ;
+ endfor ;
+ if \MPp{\MPvar{prev}} > 0 :
+ pair a, b, c, d ;
+ for i=1 upto 25 :
+ a := .5[ulcorner pa,urcorner pa] randomized (10pt,10pt) ;
+ b := .5[llcorner pb,lrcorner pb] randomized (20pt,10pt) ;
+ c := .5[a,b] rotatedaround(a,-25) randomized (5pt,5pt) ;
+ d := .5[a,b] rotatedaround(a,+25) randomized (5pt,5pt) ;
+ draw (a--b) withcolor \MPcolor{ArrowColor} ;
+ draw (d--a--c) withcolor \MPcolor{ArrowColor} ;
+ endfor ;
+ fi ;
+ anchor_box(\MPanchor{\MPvar{self}}) ;
+\stopMPpositiongraphic
+
+\startuseMPgraphic{title}
+ pickup pencircle scaled .5pt ;
+ for i=1 upto 10 :
+ draw fullsquare
+ xyscaled(OverlayWidth,OverlayHeight)
+ enlarged 10pt randomized 20pt
+ withcolor \MPcolor{TitleColor} ;
+ endfor ;
+\stopuseMPgraphic
+
+\startuseMPgraphic{page}
+ StartPage ;
+ pickup pencircle scaled .5pt ;
+ fill Page withcolor \MPcolor{BackColor} ;
+ for i=1 upto 20 :
+ draw Page enlarged -50pt randomized 50pt withcolor \MPcolor{PageColor} ;
+ endfor ;
+ StopPage ;
+\stopuseMPgraphic
+
+\newcounter\CurrentBlaBla
+
+\defineframedtext
+ [ZoomText]
+ [before=,
+ after=,
+ width=fit,
+ align=flushleft,
+ frame=off,
+ foregroundcolor=white]
+
+\starttexdefinition StartText
+ \begingroup
+ \getrandomdimen\scratchdimen{250pt}{350pt}
+ \edef\TextWidth{\the\scratchdimen}
+ \setbox\scratchbox\hbox\bgroup
+ \hsize\TextWidth
+ \ZoomText\bgroup
+\stoptexdefinition
+
+\starttexdefinition StartTextSimple
+ \begingroup
+ \setbox\scratchbox\hbox\bgroup
+ \framed [
+ frame=off,
+ foregroundcolor=white
+ ]
+ \bgroup
+\stoptexdefinition
+
+\starttexdefinition StopTextSimple
+ \StopText
+\stoptexdefinition
+
+\starttexdefinition StopText
+ \egroup
+ \egroup
+ \doglobal\increment\CurrentBlaBla
+ \let\PrevBlaBla\CurrentBlaBla \doglobal\decrement\PrevBlaBla
+ \let\NextBlaBla\CurrentBlaBla \doglobal\increment\NextBlaBla
+ \setMPpositiongraphic {
+ connection:\CurrentBlaBla
+ }{
+ mppos:connection
+ }{
+ seed=\CurrentBlaBla,
+ prev=connection:\PrevBlaBla,
+ next=connection:\NextBlaBla
+ }
+ \hbox to 600pt \bgroup
+ \setupinteraction[focus=fitr]
+ \getrandomdimen\scratchdimen{50pt}{75pt}
+ \hskip0pt plus \scratchdimen minus \scratchdimen
+ \hpos {
+ connection:\CurrentBlaBla
+ }{
+ \framed [
+ frame=off,
+ offset=overlay,
+ backgroundoffset=50pt,
+ background=blowup
+ ] {
+ \box\scratchbox
+ }
+ }
+ \getrandomdimen\scratchdimen{50pt}{75pt}
+ \hskip0pt plus \scratchdimen minus \scratchdimen
+ \egroup
+ \getrandomdimen\scratchdimen{75pt}{125pt}
+ \vskip\scratchdimen
+ \endgroup
+\stoptexdefinition
+
+\dontcomplain
+
+\disablemode[SpreadPage]
+
+\starttexdefinition StartPage #1
+ \doglobal\increment(\CurrentBlaBla,100)%
+ \setvariables[StartPage][title={#1}]
+ \setbox\scratchbox\hbox\bgroup
+ \valign\bgroup
+ \ignorespaces
+ \alignmark\alignmark
+ \vss
+ \cr
+\stoptexdefinition
+
+\starttexdefinition StopPage
+ \cr
+ \egroup
+ \egroup
+ \setbox\scratchbox\vbox\bgroup
+ \vskip100pt
+ \doifelsemode {SpreadPage} {
+ \hbox spread 200pt
+ } {
+ \hbox to \wd\scratchbox
+ }
+ \bgroup
+ \setupinteraction[focus=fitr]
+ \hss
+ \switchtobodyfont[big]%
+ \bfd
+ \doglobal\increment\CurrentBlaBla
+ \setupinterlinespace
+ \hpos {
+ title:\realfolio
+ }{
+ \framed [
+ frame=off,
+ offset=overlay,
+ backgroundoffset=50pt,
+ background=blowup
+ ] {
+ \framed [
+ frame=off,
+ align=middle,
+ foregroundcolor=white,
+ background=title
+ ] {
+ \getvariable{StartPage}{title}
+ }
+ }
+ }
+ \hss
+ \egroup
+ \vskip100pt
+ \box\scratchbox
+ \egroup
+ \normalexpanded {
+ \definepapersize [
+ MasterPage
+ ] [
+ width=\the\dimexpr\wd\scratchbox+100pt\relax,
+ height=\the\dimexpr\ht\scratchbox+\dp\scratchbox+100pt\relax
+ ]
+ }
+ \setuppapersize
+ [MasterPage]
+ [MasterPage]
+ \setuplayout [
+ topspace=25pt,
+ backspace=25pt,
+ width=middle,
+ header=0pt,
+ footer=0pt,
+ height=middle
+ ]
+ \centerbox {
+ \box\scratchbox
+ }
+ \page
+\stoptexdefinition
+
+\starttexdefinition StartTopic #1
+ \removeunwantedspaces
+ \cr
+ \doglobal\increment(\CurrentBlaBla,100)%
+ \vbox\bgroup
+ \vskip100pt
+ \bgroup
+ \definecolor[FrameColor][TitleColor]
+ \switchtobodyfont[big]
+ \bfd
+ \setupinterlinespace
+ \StartTextSimple
+ \ignorespaces
+ #1
+ \removeunwantedspaces
+ \StopTextSimple
+ \vskip25pt
+ \egroup
+\stoptexdefinition
+
+\starttexdefinition StopTopic
+ \vskip-\lastskip
+ \vskip100pt
+ \egroup
+ \ignorespaces
+\stoptexdefinition
+
+\starttexdefinition TitlePage #1
+ \begingroup
+ \def\\{\vskip1ex\bfc\def\\{\vskip1ex\bfb}}
+ \enablemode[SpreadPage]
+ \StartPage{#1}
+ \StopPage
+ \endgroup
+\stoptexdefinition
+
+\continueifinputfile{s-pre-17.mkiv}
+
+\starttext
+
+\nopdfcompression
+
+\TitlePage{About Text\\Today's Talk\\Hans Hagen}
+
+\StartPage{The First Page}
+
+ \StartTopic{Some Text}
+ \StartText \input tufte \StopText
+ \StartText \input knuth \StopText
+ \StartText \input zapf \StopText
+ \StartText \input knuth \StopText
+ \StopTopic
+
+ \StartTopic{Another Text}
+ \StartText \input tufte \StopText
+ \StartText \input zapf \StopText
+ \StartText \input knuth \StopText
+ \StopTopic
+
+ \StartTopic{Some More Text}
+ \StartText \input tufte \StopText
+ \StartText \input knuth \StopText
+ \StartText \input zapf \StopText
+ \StartText \input tufte \StopText
+ \StopTopic
+
+ \StartTopic{Some Text Again}
+ \StartText \input tufte \StopText
+ \StartText \input zapf \StopText
+ \StartText \input knuth \StopText
+ \StartText \input tufte \StopText
+ \StopTopic
+
+\StopPage
+
+\StartPage{The Second Page}
+
+ \StartTopic{Some Text}
+ \StartText \input tufte \StopText
+ \StartText \input knuth \StopText
+ \StartText \input zapf \StopText
+ \StartText \input tufte \StopText
+ \StartText \input knuth \StopText
+ \StartText \input zapf \StopText
+ \StopTopic
+
+ \StartTopic{Another Text}
+ \StartText \input tufte \StopText
+ \StartText \input knuth \StopText
+ \StartText \input zapf \StopText
+ \StopTopic
+
+ \StartTopic{Some Nice Text}
+ \StartText \input tufte \StopText
+ \StartText \input knuth \StopText
+ \StartText \input zapf \StopText
+ \StartText \input tufte \StopText
+ \StartText \input tufte \StopText
+ \StopTopic
+
+ \StartTopic{Some Funny Text}
+ \StartText \input tufte \StopText
+ \StartText \input knuth \StopText
+ \StopTopic
+
+ \StartTopic{Quite Some Text}
+ \StartText \input tufte \StopText
+ \StartText \input knuth \StopText
+ \StartText \input zapf \StopText
+ \StartText \input tufte \StopText
+ \StartText \input knuth \StopText
+ \StartText \input zapf \StopText
+ \StartText \input tufte \StopText
+ \StartText \input knuth \StopText
+ \StartText \input zapf \StopText
+ \StopTopic
+
+ \StartTopic{Even More Text}
+ \StartText \input knuth \StopText
+ \StartText \input zapf \StopText
+ \StartText \input tufte \StopText
+ \StartText \input knuth \StopText
+ \StartText \input zapf \StopText
+ \StopTopic
+
+\StopPage
+
+\StartPage{The Third Page}
+
+ \StartTopic{Some Short Text}
+ \StartText \input tufte \StopText
+ \StartText \input knuth \StopText
+ \StartText \input zapf \StopText
+ \StopTopic
+
+ \StartTopic{Some Minimal Text}
+ \StartText \input tufte \StopText
+ \StartText \input zapf \StopText
+ \StopTopic
+
+ \StartTopic{Some More Text}
+ \StartText \input tufte \StopText
+ \StartText \input knuth \StopText
+ \StartText \input zapf \StopText
+ \StartText \input tufte \StopText
+ \StartText \input tufte \StopText
+ \StopTopic
+
+\StopPage
+
+\stoptext
diff --git a/Master/texmf-dist/tex/context/modules/mkiv/s-pre-30.mkiv b/Master/texmf-dist/tex/context/modules/mkiv/s-pre-30.mkiv
new file mode 100644
index 00000000000..1be85d02b1c
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkiv/s-pre-30.mkiv
@@ -0,0 +1,257 @@
+%D \module
+%D [ file=s-pre-30,
+%D version=2006.04.25,
+%D title=\CONTEXT\ Style File,
+%D subtitle=Presentation Environment 30,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\usemodule[streams]
+
+\setuppapersize
+ [S6] [S6]
+
+\setupbodyfont
+ [12pt,tt]
+
+\definemeasure[bleed][6pt]
+
+\definecolor[maincolor-3][r=.5,g=.2,b=.2]
+\definecolor[maincolor-1][r=.2,g=.5,b=.2]
+\definecolor[maincolor-2][r=.2,g=.2,b=.5]
+
+\definecolor[pagecolor] [s=.5]
+\definecolor[resultcolor][s=1,t=.85,a=1]
+\definecolor[maincolor] [maincolor-3]
+
+\definecolorgroup
+ [maingroup]
+ [.5:.2:.2,
+ .2:.5:.2,
+ .2:.2:.5]
+
+\definecolorgroup
+ [resultgroup]
+ [1:.85:.85,
+ .85:1:.85,
+ .85:.85:1]
+
+\def\CurrentColor{1}
+
+\definecolor[maincolor] [maingroup:\CurrentColor]
+\definecolor[resultcolor][resultgroup:\CurrentColor]
+
+\def\NextColor{\ifnum\CurrentColor=3 \def\CurrentColor{1}\else\doglobal\increment\CurrentColor\fi}
+
+\setuplayout
+ [backspace=\measure{bleed},
+ topspace=30pt,
+ bottomdistance=\measure{bleed},
+ bottom=\dimexpr30pt-\measure{bleed}\relax,
+ header=0pt,
+ footer=0pt,
+ topdistance=\measure{bleed},
+ top=\dimexpr30pt-\measure{bleed}\relax,
+ width=middle,
+ height=middle]
+
+\setuptop
+ [before=\vfill,
+ after=\vfill,
+ strut=yes]
+
+\setupbackgrounds
+ [text]
+ [backgroundoffset=\measure{bleed},
+ background=color,
+ backgroundcolor=maincolor]
+
+\setupbackgrounds
+ [page]
+ [background=color,
+ backgroundcolor=pagecolor]
+
+\setupcolors
+ [state=start,
+ textcolor=white]
+
+\setuphead
+ [chapter]
+ [style=\ttd]
+
+\setuphead
+ [section]
+ [style=\ttd]
+
+\defineviewerlayer
+ [result]
+ [state=stop]
+
+\definelayer
+ [result]
+
+\setuplayer
+ [result]
+ [width=\textwidth,
+ height=\textheight]
+
+\setupbackgrounds
+ [text]
+ [background={color,toggle,foreground,result}]
+
+\setupinteraction
+ [state=start,
+ click=no,
+ menu=on,
+ color=white,
+ contrastcolor=white,
+ closepageaction=HideLayer{result},
+ openpageaction=HideLayer{result}]
+
+% We add a dummy color switch so that each page has at least one
+% transparency; else acrobat will render the pages differently
+% bug in 6 and 7).
+
+\startinteractionmenu[bottom]
+% \color[resultcolor]{ }%
+ \hfill
+ \got [content] content \\
+ \got [previouspage] previous \\
+ \got [nextpage] next \\
+ \got [ToggleLayer{result}] result \\
+ \got [CloseDocument] close \\
+\stopinteractionmenu
+
+\setuphead
+ [section]
+ [placehead=no,
+ incrementnumber=list]
+
+\setuplist
+ [section]
+ [alternative=f]
+
+\defineoverlay
+ [toggle]
+ [\overlaybutton{ToggleLayer{result}}]
+
+\definestreamlayer
+ [resultstream]
+
+\startsetups streamlayer:resultstream:flush
+ \setlayer
+ [result]
+ [preset=middlebottom,
+ hoffset=\measure{bleed},
+% voffset=-\measure{bleed}]
+ voffset=\measure{bleed}]
+ {\startviewerlayer[result]%
+% \framed
+% [offset=overlay,
+% frame=off,
+% background=color,
+% backgroundoffset=1\dimexpr\measure{bleed}\relax,
+% backgroundcolor=maincolor]
+ {\framed
+ [offset=overlay,
+ frame=off,
+ foregroundcolor=maincolor,
+ background=color,
+ backgroundoffset=1\dimexpr\measure{bleed}\relax,
+ backgroundcolor=resultcolor]
+ {\tightlayer[\currentstreamlayer]}}
+ \stopviewerlayer}
+\stopsetups
+
+\startsetups show-definition
+ \subject{definition}
+ \typebuffer
+ \getbuffer
+ \page
+\stopsetups
+
+\startsetups show-result
+ \startstreamlayer[resultstream]
+ \subject{result}
+ \getbuffer
+ \stopstreamlayer
+ \placestreamlayer[resultstream]
+ \page
+\stopsetups
+
+\startsetups show-usage
+ \subject{usage}
+ \typebuffer
+ \startstreamlayer[resultstream]
+ \subject{result}
+ \getbuffer
+ \stopstreamlayer
+ \placestreamlayer[resultstream]
+ \page
+\stopsetups
+
+\startsetups show-usage-lines
+ \subject{usage}
+ \typebuffer
+ \startstreamlayer[resultstream]
+ \subject{result}
+ \startlines
+ \getbuffer
+ \stoplines
+ \stopstreamlayer
+ \placestreamlayer[resultstream]
+ \page
+\stopsetups
+
+\startsetups show-contents
+ \startcolumns[n=3]
+ \placelist[section][criterium=text]
+ \stopcolumns
+ \pagereference[content]
+ \page
+ \NextColor
+\stopsetups
+
+\def\TitlePage#1%
+ {\title{#1}
+ \setups{show-contents}}
+
+\def\StartSample#1%
+ {\starttext
+ \page
+ \section{#1}
+ \setuptoptexts[][\processedfile\enspace:\enspace\lowercase{#1}]}
+
+\def\StopSample
+ {\page
+ \setuptoptexts[][]
+ \stoptext
+ \NextColor}
+
+\endinput
+
+\usemodule[pre-30]
+
+% \TitlePage{Howling to the moon}
+
+\StartSample{Basics}
+
+\startbuffer
+\lua{a = 1.5 ; b = 1.8 ; c = a*b ; context(c) ;}
+
+\startlua
+ a = 1
+ b = 2
+ c = a*b
+ context(c)
+\stoplua
+\stopbuffer
+
+\setups{show-usage}
+
+\StopSample
diff --git a/Master/texmf-dist/tex/context/modules/mkiv/s-pre-60.mkiv b/Master/texmf-dist/tex/context/modules/mkiv/s-pre-60.mkiv
new file mode 100644
index 00000000000..70f8978b02c
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkiv/s-pre-60.mkiv
@@ -0,0 +1,212 @@
+%D \module
+%D [ file=s-pre-60,
+%D version=2004.03.15,
+%D title=\CONTEXT\ Style File,
+%D subtitle=Presentation Environment 60,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+% use lua instead of global mess
+
+\unprotect
+
+\startmode[paper,print]
+ \let\StartSteps\relax
+ \let\StopSteps \relax
+ \let\FlushStep \relax
+ \let\ResetStep \relax
+ \let\StartBusy \relax
+ \let\StopBusy \relax
+ \endinput
+\stopmode
+
+\newcount\c_module_pre_steps_current
+\newcount\c_module_pre_steps_maximum
+\newcount\c_module_pre_steps_nesting_step
+\newcount\c_module_pre_steps_nesting_steps
+\newcount\c_module_pre_steps_nesting_busy
+
+\def\StepCounter {\the\c_module_pre_steps_current}
+\def\StepMaximum {\the\c_module_pre_steps_maximum}
+\def\StepLayer {step:\the\c_module_pre_steps_current}
+\def\NextStepLayer {step:\the\numexpr\c_module_pre_steps_current+\plusone\relax}
+\def\FirstStepLayer{step:1}
+
+\useJSscripts[stp]
+
+\startsetups[set-stepper]
+
+ \ifnum\getvariable{stepper}{nofsteps}>\c_module_pre_steps_maximum
+
+ \dostepwiserecurse {\numexpr\c_module_pre_steps_maximum+\plusone\relax} {\getvariable{stepper}{nofsteps}} {1} {
+ \doifnotmode{nosteps,nostep} {
+ \expanded{\defineviewerlayer[step:\recurselevel][state=stop,scope=global]}
+ }
+ }
+
+ \global\c_module_pre_steps_maximum\getvariable{stepper}{nofsteps}\relax
+
+ \fi
+
+\stopsetups
+
+\setvariables
+ [stepper]
+ [set=\setups{set-stepper},
+ nofsteps=50]
+
+\defineviewerlayer[step:busy][state=start]
+
+\definereference [SetupStepper] [JS(SetupStepper{step,\StepMaximum})]
+\definereference [ResetStepper] [JS(ResetStepper)]
+\definereference [CheckStepper] [JS(CheckStepper{\StepCounter})]
+\definereference [InvokeStepper] [JS(InvokeStepper)]
+
+% todo: roll back blank
+
+\unexpanded\def\ResetStep
+ {\iftrialtypesetting\else
+ \global\c_module_pre_steps_current\zerocount
+ \fi}
+
+\unexpanded\def\NextStep
+ {\iftrialtypesetting\else
+ \global\advance\c_module_pre_steps_current\plusone
+ \fi}
+
+\unexpanded\def\PrevStep
+ {\iftrialtypesetting\else
+ \global\advance\c_module_pre_steps_current\minusone
+ \fi}
+
+\unexpanded\def\FlushStep
+ {\iftrialtypesetting\else
+ \StopStep
+ \NextStep
+ \StartStep
+ \fi}
+
+\unexpanded\def\StartStep
+ {\iftrialtypesetting\else
+ \global\advance\c_module_pre_steps_nesting_step\plusone
+ \ifcase\c_module_pre_steps_nesting_step\or
+ \startviewerlayer[\StepLayer]%
+ \fi
+ \fi
+ \ignorespaces}
+
+\unexpanded\def\StopStep
+ {\removeunwantedspaces
+ \iftrialtypesetting\else
+ \ifcase\c_module_pre_steps_nesting_step\or
+ \stopviewerlayer
+ \fi
+ \global\advance\c_module_pre_steps_nesting_step\minusone
+ \fi}
+
+\unexpanded\def\StartSteps
+ {\iftrialtypesetting\else
+ \global\advance\c_module_pre_steps_nesting_steps\plusone
+ \ifcase\c_module_pre_steps_nesting_steps\or
+ \ResetStep
+ \NextStep
+ \StartStep
+ \fi
+ \fi}
+
+\unexpanded\def\StopSteps
+ {\iftrialtypesetting\else
+ \ifcase\c_module_pre_steps_nesting_steps\or
+ \StopStep
+ \PrevStep
+ \fi
+ \global\advance\c_module_pre_steps_nesting_steps\minusone
+ \fi}
+
+\unexpanded\def\StartBusy
+ {\iftrialtypesetting\else
+ \global\advance\c_module_pre_steps_nesting_busy\plusone
+ \ifcase\c_module_pre_steps_nesting_busy\or
+ \startviewerlayer[step:busy]
+ \fi
+ \fi
+ \ignorespaces}
+
+\unexpanded\def\StopBusy
+ {\removeunwantedspaces
+ \iftrialtypesetting\else
+ \ifcase\c_module_pre_steps_nesting_busy\or
+ \stopviewerlayer
+ \fi
+ \global\advance\c_module_pre_steps_nesting_busy\minusone
+ \fi}
+
+%D Handy:
+
+\unexpanded\def\StartLocalSteps
+ {\ResetStep}
+
+\unexpanded\def\StopLocalSteps
+ {}
+
+\unexpanded\def\StartLocalStep
+ {\NextStep
+ \StartStep}
+
+\unexpanded\def\StopLocalStep
+ {\StopStep}
+
+\appendtoks
+ \ResetStep
+\to \everyaftershipout
+
+\setupinteraction
+ [%openaction=SetupStepper,
+ closeaction=ResetStepper,
+ openpageaction=CheckStepper,
+ closepageaction=ResetStepper]
+
+\defineoverlay[invoke][\overlaybutton{InvokeStepper}]
+
+\setupbackgrounds
+ [text]
+ [background=invoke]
+
+% bonus
+
+\useMPlibrary[nav]
+
+\definepalet
+ [navplus]
+ [attach=interactioncolor,
+ comment=interactioncolor]
+
+\setupcomment
+ [symbol={comment-normal,comment-down},
+ textlayer=\StepLayer,
+ option=buffer,
+ height=\textheight,
+ width=\textwidth,
+ margin=0pt]
+
+\setupattachments
+ [symbol={attach-normal,attach-down},
+ textlayer=\StepLayer]
+
+%D used as (given some definitions):
+%D
+%D \starttyping
+%D \StartLocalSteps
+%D \startcombination[both]
+%D {\StartLocalStep\placestreamlayer[left]\StopLocalStep} {}
+%D {\StartLocalStep\placestreamlayer[right]\StopLocalStep} {}
+%D \stopcombination
+%D \StopLocalSteps
+%D \stoptyping
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/modules/mkiv/s-pre-69.mkiv b/Master/texmf-dist/tex/context/modules/mkiv/s-pre-69.mkiv
new file mode 100644
index 00000000000..cc6af9ad38f
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkiv/s-pre-69.mkiv
@@ -0,0 +1,336 @@
+%D \module
+%D [ file=s-pre-69,
+%D version=2010.04.28,
+%D title=\CONTEXT\ Style File,
+%D subtitle=Presentation Environment 69,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\setuppapersize[S6][S6]
+\setuppapersize[SM][SM]
+
+\usemodule
+ [abr-01,pre-60]
+
+\setupinteraction
+ [state=start,
+ contrastcolor=white,
+ color=white,
+ click=no]
+
+\setuplayout
+ [location=middle,
+ topspace=60pt,
+ bottomspace=80pt,
+ backspace=80pt,
+ header=0pt,
+ footer=0pt,
+ width=middle,
+ height=middle]
+
+\setupcolors
+ [textcolor=white]
+
+\setupbodyfont[euler]
+
+\definecolor[maincolor] [blue]
+\definecolor[extracolor][green]
+
+% \definecolor[maincolor] [red]
+% \definecolor[extracolor][blue]
+
+\startMPinitializations
+ if unknown MyColor[1] :
+ color MyColor[] ;
+ MyColor[1] := transparent(1,.25,\MPcolor{maincolor}) ;
+ MyColor[2] := transparent(1,.25,\MPcolor{extracolor}) ;
+
+ picture MySoFar ; MySoFar := nullpicture ;
+ path MyLastOne ; MyLastOne := origin -- cycle ;
+ color MyPageColor ; MyPageColor := MyColor[1] ;
+ path MyLeftSteps, MyRightSteps ;
+ boolean MyPageDone ; MyPageDone := false ;
+
+ vardef MySmallShape(expr parent) =
+ path p ; p := boundingbox parent ;
+ p := boundingbox parent ;
+ numeric w, h ; w := bbwidth(p) ; h := bbheight(p) ;
+ urcorner p shifted (-uniformdeviate w/4,0) --
+ lrcorner p shifted (0,uniformdeviate h/4) --
+ llcorner p shifted (uniformdeviate w/4,0) --
+ ulcorner p shifted (0,-uniformdeviate h/4) -- cycle
+ enddef ;
+
+ vardef MyShape(expr parent) =
+ path p ; p := boundingbox parent ;
+ if MyPageDone :
+ MyPageDone := false ;
+ urcorner p shifted (-EmWidth + -uniformdeviate CutSpace/2,0) --
+ lrcorner p shifted (0,EmWidth + uniformdeviate BottomSpace/2) --
+ llcorner p shifted (EmWidth + uniformdeviate BackSpace/2,0) --
+ ulcorner p shifted (0,-EmWidth + -uniformdeviate TopSpace/2) -- cycle
+ else :
+ MyPageDone := true ;
+ urcorner p shifted (0,-EmWidth + -uniformdeviate TopSpace/2) --
+ lrcorner p shifted (-EmWidth + -uniformdeviate CutSpace/2,0) --
+ llcorner p shifted (0,EmWidth + uniformdeviate BottomSpace/2) --
+ ulcorner p shifted (EmWidth + uniformdeviate BackSpace/2,0) -- cycle
+ fi
+ enddef ;
+
+ vardef MyMakeOne =
+ MyLastOne := MyShape(Page) ;
+ enddef ;
+
+ vardef MyAddOne =
+ addto MySoFar also image(fill MyLastOne withcolor MyPageColor ; ) ;
+ enddef ;
+
+ vardef MyDrawOne =
+ fill MyLastOne withcolor black ;
+ fill MyLastOne withcolor MyPageColor ;
+ enddef ;
+
+ vardef MyDrawPage =
+ draw MySoFar ;
+ enddef ;
+
+ vardef MySetSteps =
+ path l, r ; numeric s ; path ll[], rr[] ; path t ;
+ l := point 2 of MyLastOne -- point 3 of MyLastOne ;
+ r := point 0 of MyLastOne -- point 1 of MyLastOne ;
+ t := topboundary Field[Text][Text] rightenlarged TextWidth leftenlarged TextWidth ;
+ s := bbheight(Field[Text][Text])/LineHeight + 2 ;
+ t := t shifted (0,-TopSkip) ;
+ for i=1 upto s :
+ ll[i] := t intersectionpoint l ;
+ rr[i] := t intersectionpoint r ;
+ t := t shifted (0,-LineHeight) ;
+ endfor ;
+ MyLeftSteps := for i=1 upto s : ll[i] -- endfor cycle ;
+ MyRightSteps := for i=1 upto s : rr[i] -- endfor cycle ;
+ enddef ;
+
+ vardef MyDrawText(expr txt) =
+ pair a ; a := (point 1 of MyLastOne) - (point 2 of MyLastOne) ;
+ picture p ; p := txt ;
+ p := p
+ shifted (-EmWidth,EmWidth)
+ shifted ulcorner txt
+ shifted point 1 of MyLastOne ;
+ p := p rotatedaround(lrcorner p, radian * tan(ypart a/xpart a)) ;
+ setbounds p to origin -- cycle ;
+ draw p ;
+ enddef ;
+
+ vardef MyDrawTitle(expr txt) =
+ % pair a ; a := (point 2 of MyLastOne) - (point 3 of MyLastOne) ;
+ pair a ; a := (point 3 of MyLastOne) - (point 4 of MyLastOne) ;
+ picture p ;
+ if bbheight(txt) > bbwidth(txt) :
+ p := txt ysized(0.8*TextHeight) ;
+ else :
+ p := txt xsized(0.8*TextWidth) ;
+ fi ;
+ numeric d ; d := arclength(point 2 of MyLastOne -- point 3 of MyLastOne) - bbheight(p) ;
+ p := p
+ shifted (BackSpace,-d/2)
+ shifted -ulcorner p
+ shifted point 3 of MyLastOne ;
+ % p := p rotatedaround(ulcorner p, - radian * tan(xpart a/ypart a)) ;
+ % p := p rotatedaround(ulcorner p, radian * tan(ypart a/xpart a)) ;
+ setbounds p to origin -- cycle ;
+ draw p ;
+ enddef ;
+
+ vardef MyDrawSteps =
+ s := bbheight(Field[Text][Text])/LineHeight + 2 ;
+ for i=1 upto s :
+ draw ll[i] withpen pencircle scaled 1mm ;
+ draw rr[i] withpen pencircle scaled 1mm ;
+ draw ll[i] -- rr[i] ;
+ endfor ;
+ draw Field[Text][Text] ;
+ enddef ;
+
+ fi ;
+\stopMPinitializations
+
+\startuseMPgraphic{initialization}
+ StartPage ;
+ MySoFar := image(fill Page enlarged 12pt withcolor MyPageColor) ;
+ MyMakeOne ;
+ MySetSteps ;
+ StopPage ;
+\stopuseMPgraphic
+
+\appendtoks
+ \startnointerference
+ \useMPgraphic{initialization}
+ \stopnointerference
+\to \everystarttext
+
+\startuseMPgraphic{page}
+ StartPage ;
+ MyDrawPage ;
+ MyDrawOne ;
+ MySetSteps ;
+ MyDrawTitle(textext("\getvariable{document}{title}")) ;
+ MyDrawText(textext("\getvariable{document}{topic}")) ;
+ %
+ % we have multiple runs when we have text
+ %
+% MyDrawSteps ;
+% MyMakeOne ;
+% MySetSteps ;
+ StopPage ;
+\stopuseMPgraphic
+
+\appendtoks
+ \startnointerference
+ \startMPcode
+ MyAddOne ;
+ MyMakeOne ;
+ MySetSteps ;
+ \stopMPcode
+ \stopnointerference
+\to \everyshipout
+
+\defineoverlay[page][\useMPgraphic{page}]
+
+\startuseMPgraphic{symbol}
+ color cc ; cc := MyColor[2] ;
+ path p ; p := MySmallShape(unitsquare scaled (.6*LineHeight)) ;
+ fill p withcolor white ;
+ fill p withcolor cc ;
+\stopuseMPgraphic
+
+\definesymbol[mysymbol][\struttedbox{\useMPgraphic{symbol}}]
+
+\setupitemgroup[itemize][1][symbol=mysymbol]
+
+\setupbackgrounds
+ [page]
+ [background=page]
+
+\startluacode
+ local texdimen = tex.dimen
+ function document.SetParShape()
+ local leftpath = metapost.getclippath("metafun","metafun","clip currentpicture to MyLeftSteps ;")
+ local rightpath = metapost.getclippath("metafun","metafun","clip currentpicture to MyRightSteps ;")
+ local shape = { }
+ for i=1,#leftpath do
+ local left = leftpath[i].x_coord
+ local right = rightpath[i].x_coord
+ local hsize = right - left - (texdimen.backspace + texdimen.cutspace)*number.dimenfactors.bp
+ shape[#shape+1] = string.format("%sbp %sbp",left,hsize)
+ end
+ -- print(table.serialize(shape))
+ -- context.parshape(string.format("%s %s ",#shape,table.concat(shape," ")))
+ context("\\parshape %s %s ",#shape,table.concat(shape," "))
+ end
+\stopluacode
+
+\nopenalties \dontcomplain
+
+\setupwhitespace[none]
+
+\def\StartText#1#2%
+ {\starttext
+ \setvariable{document}{title}{\framed[frame=off,offset=0pt,align=flushleft,foregroundstyle=\tfd\setupinterlinespace]{\begstrut#1\endstrut}}
+ \setvariable{document}{topic}{\tfb#2}
+ \startstandardmakeup
+ % dummy page
+ \stopstandardmakeup
+ \setvariable{document}{title}{}
+ \setvariable{document}{topic}{}}
+
+\def\StopText
+ {\stoptext}
+
+\def\StartItems#1%
+ {\setvariable{document}{topic}{\tfb#1}
+ \startstandardmakeup[top=,bottom=\vss]
+ \startelement[items][title={#1}]%
+ \ctxlua{document.SetParShape()}
+ \StartSteps}
+
+\def\StopItems
+ {\StopSteps
+ \stopelement
+ \stopstandardmakeup}
+
+\def\StartItem
+ {\dontleavehmode
+ \startelement[item]%
+ \llap{\symbol[mysymbol]\quad}% graphic
+ \ignorespaces}
+
+\def\StopItem
+ {\removeunwantedspaces
+ \nobreak
+ \crlf
+ \stopelement
+ \crlf
+ \FlushStep}
+
+\def\ShapeParagraph
+ {\ctxlua{document.SetParShape()}}
+
+% no parshape yet
+
+\def\StartParagraphs#1%
+ {\setvariable{document}{topic}{\tfb#1}
+ \startstandardmakeup[top=,bottom=\vss]
+ %\ctxlua{document.SetParShape()}
+ \startelement[paragraphs]%
+ \StartSteps}
+
+\def\StopParagraphs
+ {\StopSteps
+ \stopelement
+ \stopstandardmakeup}
+
+\def\StartParagraph
+ {\startelement[paragraph]}
+
+\def\StopParagraph
+ {\par
+ \stopelement
+ \FlushStep}
+
+% experiment .. likely to change
+
+\setelementexporttag[items] [nature][display]
+\setelementexporttag[item] [nature][mixed]
+\setelementexporttag[paragraphs][nature][display]
+\setelementexporttag[paragraph] [nature][mixed]
+
+\continueifinputfile{s-pre-69.mkiv}
+
+% finetuning: \StartText{\TEX\ and Reality\vskip2exClashing Mindsets?\vskip1ex}{Bacho\TEX, May 1, 2010}
+
+\StartText{Just\\A Demo}{Bacho\TEX, May 1, 2010}
+
+\StartItems{Quote from Tufte and Ward}
+ \StartItem
+ \input tufte
+ \StopItem
+ \StartItem
+ \input ward
+ \StopItem
+\StopItems
+
+% \dorecurse{20}{
+% \ctxlua{document.SetParShape()}
+% \input tufte
+% \page
+% }
+
+\StopText
+
diff --git a/Master/texmf-dist/tex/context/modules/mkiv/s-pre-70.mkiv b/Master/texmf-dist/tex/context/modules/mkiv/s-pre-70.mkiv
new file mode 100644
index 00000000000..2c8bb2d2648
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkiv/s-pre-70.mkiv
@@ -0,0 +1,176 @@
+%D \module
+%D [ file=s-pre-70,
+%D version=2008.04.15,
+%D title=\CONTEXT\ Style File,
+%D subtitle=Presentation Environment 70,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+%D At the cost of more runtime and a larger output file, we
+%D turn on randomization. The instances are cached in the
+%D MkIV cache, so successive runs use the same shapes.
+
+% \usemodule[punk] \usetypescript[punk] \setupbodyfont[punk,20pt]
+%
+% \EnableRandomPunk
+
+\setupbodyfont[punknova,20pt] % we now use the opentype variant
+
+%D We use the regular screen size paper and layout setup.
+
+\setuppapersize
+ [S6][S6]
+
+\setuplayout
+ [topspace=30pt,
+ backspace=30pt,
+ width=middle,
+ height=fit,
+ header=0pt,
+ footer=0pt,
+ bottomdistance=24pt,
+ bottom=30pt,
+ bottom=18pt,
+ top=0pt]
+
+\setupinterlinespace
+ [top=height,
+ line=1.25\bodyfontsize]
+
+\setupcolors
+ [state=start,
+ textcolor=white]
+
+\setupinteraction
+ [state=start,
+ %click=off,
+ menu=on]
+
+%D We predefine a few palets. Of course you can define more.
+
+\definecolor[punkblue] [r=.4,b=.8,g=.4]
+\definecolor[punkgreen] [r=.4,b=.4,g=.8]
+\definecolor[punkred] [r=.8,b=.4,g=.4]
+\definecolor[punkyellow][r=.6,g=.6,b=.2]
+
+\definepalet [punk-one] [textcolor=punkblue,pagecolor=punkgreen]
+\definepalet [punk-two] [textcolor=punkred,pagecolor=punkyellow]
+\definepalet [punk-three] [textcolor=punkblue,pagecolor=punkyellow]
+\definepalet [punk-one-reverse] [textcolor=punkgreen,pagecolor=punkblue]
+\definepalet [punk-two-reverse] [textcolor=punkyellow,pagecolor=punkred]
+\definepalet [punk-three-reverse] [textcolor=punkyellow,pagecolor=punkblue]
+
+\setuppalet[punk-one]
+
+%D We use a few backgrounds. The hyperlink that invokes the
+%D stepper is hooked into the text background.
+
+\definelayer
+ [page]
+ [width=\paperwidth,
+ height=\paperheight]
+
+\setupbackgrounds
+ [page]
+ [background={color,page},
+ backgroundcolor=pagecolor,
+ setups=pagestuff]
+
+\setupbackgrounds
+ [text]
+ [background={color,invoke},
+ backgroundoffset=12pt,
+ backgroundcolor=textcolor]
+
+%D We need different symbols for itemized lists.
+
+\definesymbol[1][\hbox{\lower1ex\hbox{*}}]
+\definesymbol[2][\endash]
+\definesymbol[3][\letterhash]
+\definesymbol[3][>]
+
+%D We don't want these reversed clicked areas in Acrobat.
+
+\setupinteraction
+ [click=no,
+ color=white, % pagecolor,
+ contrastcolor=white] % pagecolor,
+
+%D We define a rather simple navigational panel at the
+%D bottom
+
+\setupinteractionmenu
+ [bottom]
+ [color=white, % pagecolor,
+ contrastcolor=white, % pagecolor,
+ background=color,
+ backgroundcolor=textcolor,
+ frame=off,
+ height=24pt,
+ left=\hfill,
+ middle=\hskip12pt]
+
+\setupsubpagenumber
+ [state=start]
+
+\startinteractionmenu[bottom]
+ \starttxt
+ \interactionbar
+ [alternative=d,
+ symbol=yes,
+ color=white,
+ contrastcolor=textcolor]
+ \stoptxt
+ \hfilll
+ \startbut [previouspage] < < < \stopbut
+ \startbut [nextpage] > > > \stopbut
+\stopinteractionmenu
+
+%D Instead of the normal symbols we use more punky ones.
+
+\startsymbolset [punk]
+ \definesymbol[previous] [\string<\string<]
+ \definesymbol[somewhere] [\string^\string^]
+ \definesymbol[next] [\string>\string>]
+\stopsymbolset
+
+\setupinteraction[symbolset=punk]
+
+%D Because the font is rather large, we use less whitespace.
+
+\setuphead
+ [chapter]
+ [after={\blank[big]}]
+
+%D Run this file with the command: \type {context --mode=demo s-pre-70}
+%D in order to get an example.
+
+\continueifinputfile{s-pre-70.mkiv}
+
+\usemodule[pre-60] % use the stepper
+
+\starttext
+
+\title {Punk for dummies}
+
+\dorecurse{10} {
+
+ \title{Just a few dummy pages}
+
+ \StartSteps
+ \startitemize[packed]
+ \startitem bla \FlushStep \stopitem
+ \startitem bla bla \FlushStep \stopitem
+ \startitem bla bla bla \FlushStep \stopitem
+ \startitem bla bla bla bla \FlushStep \stopitem
+ \stopitemize
+ \StopSteps
+
+}
+
+\stoptext
diff --git a/Master/texmf-dist/tex/context/modules/mkiv/s-pre-71.lua b/Master/texmf-dist/tex/context/modules/mkiv/s-pre-71.lua
new file mode 100644
index 00000000000..bfa45a70578
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkiv/s-pre-71.lua
@@ -0,0 +1,63 @@
+if not modules then modules = { } end modules ['steps'] = {
+ version = 1.001,
+ comment = "companion to steps.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+moduledata.steps = moduledata.steps or { }
+local steps = moduledata.steps
+
+local locations = {
+ 'lefttop',
+ 'middletop',
+ 'righttop',
+ 'middleleft',
+ 'middle',
+ 'middleright',
+ 'leftbottom',
+ 'middlebottom',
+ 'rightbottom',
+}
+
+local done, current, previous, n
+
+function steps.reset_locations()
+ done, current, previous, n = table.tohash(locations,false), 0, 0, 0
+end
+
+function steps.next_location(loc)
+ previous = current
+ n = n + 1
+ loc = loc and loc ~= "" and tonumber(loc)
+ while true do
+ current = loc or math.random(1,#locations)
+ if not done[current] then
+ done[current] = true
+ break
+ end
+ end
+end
+
+function steps.current_location()
+ context(locations[current] or "")
+end
+
+function steps.previous_location()
+ context(locations[previous] or "")
+end
+
+function steps.current_n()
+ context(current)
+end
+
+function steps.previous_n()
+ context(previous)
+end
+
+function steps.step()
+ context(n)
+end
+
+steps.reset_locations()
diff --git a/Master/texmf-dist/tex/context/modules/mkiv/s-pre-71.mkiv b/Master/texmf-dist/tex/context/modules/mkiv/s-pre-71.mkiv
new file mode 100644
index 00000000000..38dae61dfa5
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkiv/s-pre-71.mkiv
@@ -0,0 +1,170 @@
+% engine=luatex
+
+%D \module
+%D [ file=s-pre-71,
+%D version=2008.08.05,
+%D title=\CONTEXT\ Style File,
+%D subtitle=Presentation Environment 71,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+%D I might improve this module so consider it experimental.
+
+% \enablemode[numbers]
+% \enablemode[paper]
+
+\usemodule[pre-60,abr-02]
+
+\registerctxluafile{s-pre-71}{}
+
+\setupinteraction[state=start,click=off]
+
+\definepapersize[wide][width=900pt,height=600pt]
+
+\setuppapersize[wide][wide]
+
+\setuplayout[page]
+
+% \setupbodyfont[15pt]
+
+\usetypescriptfile[type-hgz]
+\usetypescript[palatino-informal]
+\setupbodyfont[palatino-informal,15pt]
+
+\setupsorting[logo][style=]
+
+\startnotmode[paper]
+ \setupbackgrounds[page][background=color,backgroundcolor=black]
+\stopnotmode
+
+\TransparencyHack
+
+\definelayer[page][width=\paperwidth,height=\paperheight]
+
+\definecolor[TopicColor-1][r=.3,g=.4,b=.5]
+\definecolor[TopicColor-2][r=.3,g=.5,b=.4]
+\definecolor[TopicColor-3][r=.4,g=.3,b=.5]
+\definecolor[TopicColor-4][r=.4,g=.5,b=.3]
+\definecolor[TopicColor-5][r=.5,g=.3,b=.4]
+\definecolor[TopicColor-6][r=.5,g=.4,b=.3]
+\definecolor[TopicColor-7][r=.35,g=.35,b=.6]
+\definecolor[TopicColor-8][r=.6,g=.35,b=.35]
+\definecolor[TopicColor-9][r=.35,g=.6,b=.35]
+
+\definecolor[TopicColor-0][t=.5,a=1,s=.5]
+\definecolor[TopicColor] [s=1]
+
+\setupcolors[state=start]
+\setupcolors[textcolor=TopicColor]
+
+\def\StartTopics
+ {\startstandardmakeup
+ \ctxlua{moduledata.steps.reset_locations()}
+ \doifnotmode{paper}{\StartLocalSteps}}
+
+\def\StopTopics
+ {\doifnotmode{paper}{\StopLocalSteps}
+ \flushlayer[page]
+ \stopstandardmakeup}
+
+\def\StartTopic
+ {\dosingleempty\doStartTopic}
+
+\def\doStartTopic[#1]%
+ {\doifnotmode{paper}{\NextStep}
+ \ctxlua{moduledata.steps.next_location("#1")}
+ \startnotmode[paper]
+ \doifnothing{#1}
+ {\ifcase\ctxlua{moduledata.steps.previous_n()}\else
+ \setlayer
+ [page]
+ [preset=\ctxlua{moduledata.steps.previous_location()}]
+ \bgroup
+ \doifnotmode{paper}{\startviewerlayer[\StepLayer]}%
+ \framed
+ [offset=20pt,
+ strut=no,
+ align=normal,
+ frame=off,
+ height=\dimexpr\paperheight/3\relax,
+ width=\dimexpr\paperwidth/3\relax,
+ background=color,
+ backgroundcolor=TopicColor-0]
+ {}%
+ \doifnotmode{paper}{\stopviewerlayer}%
+ \egroup
+ \fi}
+ \stopnotmode
+ \setlayer
+ [page]
+ [preset=\ctxlua{moduledata.steps.current_location()}]
+ \bgroup
+ \doifnotmode{paper}{\startviewerlayer[\StepLayer]}%
+ \framed
+ [offset=20pt,
+ strut=no,
+ align=\expdoifelse{#1}{}{normal}{middle,lohi},
+ align=\expdoifelse{#1}{}{flushleft,verytolerant}{middle,lohi},
+ frame=off,
+ height=\dimexpr\paperheight/3\relax,
+ width=\dimexpr\paperwidth/3\relax,
+ background=color,
+ backgroundcolor=TopicColor-\ctxlua{moduledata.steps.current_n()}]
+ \bgroup
+ \ignorespaces}
+
+\def\StopTopic
+ {\removeunwantedspaces
+ \egroup
+ \doifnotmode{paper}{\stopviewerlayer}%
+ \egroup
+ \startmode[numbers]
+ \setlayerframed
+ [page]
+ [preset=\ctxlua{moduledata.steps.current_location()}]
+ [height=\dimexpr\paperheight/3\relax,
+ width=\dimexpr\paperwidth/3\relax,
+ frame=off,
+ foregroundstyle=\bfa,
+ align={flushright,low}]
+ {\doifnotmode{paper}{\startviewerlayer[\StepLayer]}%
+ \ctxlua{moduledata.steps.step()}\kern\strutdepth
+ \doifnotmode{paper}{\stopviewerlayer}}
+ \stopmode}
+
+\logo [METAPOST] {MetaPost}
+
+\definefont[TitleFont][SansBold at 60pt]
+\definefont[TempFont] [SansBold at 12pt]
+
+\let\StartText\starttext
+\let\StopText \stoptext
+
+\continueifinputfile{s-pre-71.mkiv}
+
+\starttext
+
+\StartTopics
+ \StartTopic[1] A \StopTopic
+ \StartTopic[5] B \StopTopic
+ \StartTopic[9] C \StopTopic
+\StopTopics
+
+\StartTopics
+ \StartTopic A \StopTopic
+ \StartTopic B \StopTopic
+ \StartTopic C \StopTopic
+ \StartTopic D \StopTopic
+ \StartTopic E \StopTopic
+ \StartTopic F \StopTopic
+ \StartTopic G \StopTopic
+ \StartTopic H \StopTopic
+ \StartTopic I \StopTopic
+\StopTopics
+
+\stoptext
diff --git a/Master/texmf-dist/tex/context/modules/mkiv/s-present-tiles.mkiv b/Master/texmf-dist/tex/context/modules/mkiv/s-present-tiles.mkiv
new file mode 100644
index 00000000000..b68a34ef42b
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkiv/s-present-tiles.mkiv
@@ -0,0 +1,318 @@
+%D \module
+%D [ file=s-present-tiles, % was s-pre-41
+%D version=2013.03.24,
+%D title=\CONTEXT\ Style File,
+%D subtitle=Presentation Environment Tiles,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+%D The Bacho\TeX\ 2013 style.
+
+\setupbodyfont[pagella,14.4pt]
+
+\setuppapersize[S6][S6]
+
+\definecolor[primarycolor] [.50(darkblue,darkgreen)]
+\definecolor[secondarycolor][.25(darkblue,darkyellow)]
+\definecolor[mixedcolor] [s=.35]
+
+\setupcolors
+ [textcolor=white]
+
+\setupalign
+ [flushleft,nothyphenated]
+
+\definemeasure[layoutunit][\dimexpr\paperheight/25]
+
+\setuplayout
+ [backspace=\measured{layoutunit},
+ topspace=\measured{layoutunit},
+ width=middle,
+ height=middle,
+ header=0pt,
+ footer=0pt]
+
+\definelayout
+ [content]
+ [backspace=.5\measured{layoutunit},
+ topspace=.5\measured{layoutunit}]
+
+\definemeasure [topiclistwidth] [
+ (\textwidth+\backspace)/
+ \ifcase\numexpr\structurelistsize\relax 1 % 0
+ \or1\or1\or1\or2\or1\or3\or3\or3\or3 % 1 - 9
+ \or3\or3\or3\or3\or3\or3\or4 % 10 - 16
+ \or4\or4\or4\or4\or % 17 - 20
+ \else5 % 21 - 25
+ \fi
+ -\backspace
+]
+
+\definemeasure [topiclistheight] [
+ (\textheight+\topspace)/
+ \ifcase\numexpr\structurelistsize\relax 1 % 0
+ \or1\or2\or3\or2\or5\or2\or3\or3\or3 % 1 - 9
+ \or4\or4\or4\or4\or4\or4\or4 % 10 - 16
+ \or5\or5\or5\or5\or5 % 17 - 20
+ \else5 % 21 - 25
+ \fi
+ -\topspace
+]
+
+\definemeasure [topiclistfontsize] [
+ \ifcase\numexpr\structurelistsize\relax 2.5 % 0
+ \or1.4\or1.4\or1.4\or1.4\or1.4\or1.4\or1.4\or1.4\or1.4 % 1 - 9
+ \or1.3\or1.3\or1.3\or1.3\or1.3\or1.3\or1.3 % 10 - 16
+ \or1.2\or1.2\or1.2\or1.2\or1.2 % 17 - 20
+ \else1 % 21 - 25
+ \fi
+ \bodyfontsize
+]
+
+\definemeasure [topiclistfont] [\measured{topiclistfontsize}]
+\definemeasure [topictitlefont] [1.2\measured{layoutunit}]
+\definemeasure [titlepagefont] [2\measured{layoutunit}]
+
+\predefinefont[MyTopicTitleFont][SerifBold*default at \measure{topictitlefont}]
+\predefinefont[MyTopicListFont] [SerifBold*default at \measure{topiclistfont}]
+
+\defineframed
+ [topiclistentry]
+ [width=\measure{topiclistwidth},
+ height=\measure{topiclistheight},
+ background=color,
+ frame=off,
+ foregroundstyle=MyTopicListFont,
+ backgroundcolor=primarycolor,
+ foregroundcolor=white]
+
+\setupwhitespace
+ [big]
+
+\setupblank
+ [big]
+
+\setupinteraction
+ [state=start,
+ color=,
+ contrastcolor=,
+ click=off]
+
+\definemakeup
+ [topic]
+ [standard]
+ [top=,bottom=]
+
+\definemakeup
+ [content]
+ [standard]
+ [top=,bottom=]
+
+\startsetups[topic:start]
+ \starttopicmakeup
+\stopsetups
+
+\startsetups[topic:stop]
+ \vfill
+ \stoptopicmakeup
+\stopsetups
+
+\definehead
+ [topic]
+ [chapter]
+ [before=,
+ style=MyTopicTitleFont,
+ page=,
+ number=off,
+ interaction=list,
+ beforesection=\directsetup{topic:start},
+ aftersection=\directsetup{topic:stop}]
+
+\setuplist
+ [topic]
+ [alternative=topic,
+ interaction=all]
+
+\definelistalternative
+ [topic]
+ [alternative=horizontal,
+ renderingsetup=topic:list]
+
+\startsetups[topic:list]
+ \dontleavehmode
+ \startcurrentlistentrywrapper
+ \topiclistentry{\currentlistentrytitle}
+ \stopcurrentlistentrywrapper
+ \blankspace
+\stopsetups
+
+\defineoverlay[nextpage][\overlaybutton{nextpage}]
+\defineoverlay[prevpage][\overlaybutton{prevpage}]
+\defineoverlay[menupage][\overlaybutton{menupage}]
+\defineoverlay[homepage][\overlaybutton{homepage}]
+
+\setupbackgrounds
+ [text]
+ [backgroundoffset=.5\measured{layoutunit}]
+
+% begin of buttons
+
+\defineframed
+ [bb]
+ [width=\dimexpr\overlaywidth/10,
+ height=\dimexpr\overlayheight/10,
+ background=color,
+ foregroundstyle=\bfa,
+ frame=off]
+
+\defineframed[nb] [bb] [empty=yes]
+\defineframed[rb] [bb] [backgroundcolor=white,foregroundcolor=secondarycolor]
+\defineframed[db] [bb] [backgroundcolor=mixedcolor,foregroundcolor=white]
+
+\definepushbutton [prev]
+\definepushbutton [next]
+\definepushbutton [menu]
+\definepushbutton [home]
+
+\definepushsymbol [prev] [n] [\nb{prev}]
+\definepushsymbol [prev] [r] [\rb{prev}]
+\definepushsymbol [prev] [d] [\db{prev}]
+
+\definepushsymbol [next] [n] [\nb{next}]
+\definepushsymbol [next] [r] [\rb{next}]
+\definepushsymbol [next] [d] [\db{next}]
+
+\definepushsymbol [menu] [n] [\nb{menu}]
+\definepushsymbol [menu] [r] [\rb{menu}]
+\definepushsymbol [menu] [d] [\db{menu}]
+
+\definepushsymbol [home] [n] [\nb{home}]
+\definepushsymbol [home] [r] [\rb{home}]
+\definepushsymbol [home] [d] [\db{home}]
+
+\definelayer
+ [buttons]
+ [width=\dimexpr\textwidth+\measured{layoutunit}\relax,
+ height=\dimexpr\textheight+\measured{layoutunit}\relax] % a setups
+
+\startsetups [document:buttons]
+
+ \setlayer
+ [buttons]
+ [preset=leftbottom,offset=-.25\measured{layoutunit}]
+ {\pushbutton[prev][previouspage]}
+
+ \setlayer
+ [buttons]
+ [preset=rightbottom,offset=-.25\measured{layoutunit}]
+ {\pushbutton[next][nextpage]}
+
+ \setlayer
+ [buttons]
+ [preset=lefttop,offset=-.25\measured{layoutunit}]
+ {\pushbutton[home][homepage]}
+
+ \setlayer
+ [buttons]
+ [preset=righttop,offset=-.25\measured{layoutunit}]
+ {\pushbutton[menu][menupage]}
+
+\stopsetups
+
+\defineoverlay[setbuttons][\directsetup{document:buttons}]
+
+% end of buttons
+
+\defineframed
+ [conclusion]
+ [location=low,
+ width=max,
+ align={flushleft,lohi},
+ background=color,
+ backgroundcolor=white,
+ foregroundcolor=secondarycolor]
+
+\startsetups [document:titlepage]
+
+ \definebodyfontenvironment
+ [\measure{titlepagefont}]
+
+ \setupbackgrounds
+ [page]
+ [background={color,menupage},
+ backgroundcolor=secondarycolor]
+
+ \setupbackgrounds
+ [text]
+ [background={color,menupage},
+ backgroundcolor=secondarycolor]
+
+ \starttopicmakeup[reference=homepage]
+
+ \switchtobodyfont[\measure{titlepagefont}]
+
+ \let\\=\crlf
+
+ \startalignment[flushleft]
+ \bf
+ \setupinterlinespace
+ \begstrut\getvariable{document}{title}\endstrut\par
+ \stopalignment
+
+ \vfill
+
+ \startalignment[flushright]
+ \bf
+ \setupinterlinespace
+ \begstrut\getvariable{document}{subtitle}\endstrut\par
+ \stopalignment
+
+ \stoptopicmakeup
+
+ \setupbackgrounds
+ [page]
+ [background={color,homepage},
+ backgroundcolor=secondarycolor]
+
+ \setupbackgrounds
+ [text]
+ [background={color,menupage},
+ backgroundcolor=secondarycolor]
+
+ \startcontentmakeup[reference=menupage]
+
+ \setupalign[tolerant,stretch,paragraph]
+ \flexiblebaselines
+ \placelist[topic][criterium=text]
+
+ \stopcontentmakeup
+
+ \setupbackgrounds
+ [page]
+ % [background={color,menupage},
+ [background={color,invoke},
+ backgroundcolor=primarycolor]
+
+ \setupbackgrounds
+ [text]
+ % [background={color,nextpage,setbuttons,buttons},
+ [background={color,setbuttons,buttons},
+ backgroundcolor=secondarycolor]
+
+\stopsetups
+
+\setupdocument
+ [before=\directsetup{document:titlepage}]
+
+\continueifinputfile{s-present-tiles.mkiv}
+
+\startdocument[title=Whatever We\\Want Here,subtitle=Whatever We\\Want There]
+
+ \dorecurse{12}{\starttopic[title=Topic #1]\input tufte \stoptopic}
+
+\stopdocument
diff --git a/Master/texmf-dist/tex/context/modules/mkiv/s-references-show.mkiv b/Master/texmf-dist/tex/context/modules/mkiv/s-references-show.mkiv
new file mode 100644
index 00000000000..72cccce54f1
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkiv/s-references-show.mkiv
@@ -0,0 +1,132 @@
+%D \module
+%D [ file=s-references-show.mkiv,
+%D version=2015.04.13,
+%D title=\CONTEXT\ Style File,
+%D subtitle=Reference Checking,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\startmodule[references-show]
+
+\unprotect
+
+% \enabletrackers[nodes.references,nodes.destinations] % also shows areas
+
+\enabletrackers[nodes.references.show,nodes.destinations.show]
+
+\enablehiddenbackground % trick
+
+\edef\hiddenbackgroundlist{\hiddenbackgroundlist,trace-references}
+
+\defineoverlay
+ [trace-references]
+ [\directsetup{trace:references:onpage}]
+
+\startluacode
+ local pagelist = structures.references.tracedpages
+
+ function commands.getreferencesonpage(n)
+ n = tonumber(n)
+ if n then
+ local pagedata = pagelist[n]
+ if pagedata then
+ context("%s references",#pagedata)
+ context.blank()
+ for i=1,#pagedata do
+ local details = pagedata[i]
+ local prefix = details[1]
+ local reference = details[2]
+ -- local internal = details[3]
+ -- context("%04i = %s : %s",internal,prefix == "" and "-" or prefix,reference)
+ context("%s : %s",prefix == "" and "-" or prefix,reference)
+ context.par()
+ end
+ else
+ context("no references")
+ end
+ else
+ context("no valid page")
+ end
+ end
+
+\stopluacode
+
+\definecolor
+ [trace:references:onpage]
+ [b=.5,a=1,t=.25]
+
+\defineframed
+ [trace:references:onpage]
+ [\c!offset=2\exheight,
+ %\c!foregroundstyle=\infofont,
+ \c!frame=\v!off,
+ \c!background=\v!color,
+ \c!backgroundcolor=trace:references:onpage,
+ \c!align=\v!normal]
+
+\startsetups trace:references:onpage
+ \vbox to \vsize \bgroup
+ \infofont
+ \vskip\dimexpr-\topspace-\headerheight+2\exheight\relax
+ \hbox to \hsize \bgroup
+ \doifoddpageelse\hss{\hskip\dimexpr-\cutspace+2\exheight\relax}%
+ \directlocalframed [
+ trace:references:onpage
+ ] {
+ \ctxcommand{getreferencesonpage(\the\realpageno)}
+ }
+ \doifoddpageelse{\hskip\dimexpr-\cutspace+2\exheight\relax}\hss
+ \egroup
+ \vss
+ \egroup
+\stopsetups
+
+\protect
+
+\continueifinputfile{s-references-show.mkiv}
+
+\usemodule[art-01]
+
+\setupinteraction
+ [state=start]
+
+\setuppagenumbering
+ [alternative=doublesided]
+
+\starttext
+
+\title {Contents}
+
+\placelist[chapter]
+
+\setupreferenceprefix[zero]
+
+\chapter[crap]{foo}
+
+\setupreferenceprefix[one]
+
+test \pagereference[whatever]
+
+\dorecurse{5}{
+ \placefigure
+ [here][bar 1.#1]
+ {xx}{\framed{xx #1}}
+}
+
+\setupreferenceprefix[two]
+
+\dorecurse{5}{
+ \placefigure
+ [here][bar 2.#1]
+ {xx}{\framed{xx #1}}
+}
+
+\in{checked}[bar 1.1]
+\in{checked}[bar 2.1]
+
+\stoptext
diff --git a/Master/texmf-dist/tex/context/modules/mkiv/s-reg-01.mkiv b/Master/texmf-dist/tex/context/modules/mkiv/s-reg-01.mkiv
new file mode 100644
index 00000000000..36434c30c19
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkiv/s-reg-01.mkiv
@@ -0,0 +1,60 @@
+%D \module
+%D [ file=s-reg-01,
+%D version=2005.04.25,
+%D title=\CONTEXT\ Style File,
+%D subtitle=Extra Regime Support,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+%D \macros
+%D {showregime}
+%D
+%D This code is moved from the kernel to here. (We could make it
+%D auto-loadable).
+
+\startluacode
+--[[ldx--
+
The following code is rather specific.
+--ldx]]--
+
+function regimes.show(regime)
+ regime = regimes.synonyms[regime] or regime
+ local r = regimes.data[regime]
+ if r then
+ local chardata = characters.data
+ context.starttabulate { "|rT|T|rT|lT|lT|lT|" }
+ for k, v in ipairs(r) do
+ local chr = chardata[v]
+ if chr then
+ context.NC() context(k)
+ context.NC() context.getvalue(chr.contextname])
+ context.NC() context("%U+05X",v)
+ context.NC() context(chr.contextname)
+ context.NC() context(chr.category)
+ context.NC() context(chr.description)
+ context.NC() context.NR()
+ else
+ -- can't happen
+ end
+ end
+ context.stoptabulate()
+ else
+ context("unknown regime %s",regime)
+ end
+end
+\stopluacode
+
+\unprotect
+
+\def\showregime
+ {\dosingleempty\doshowregime}
+
+\def\doshowregime[#1]%
+ {\ctxlua{regimes.show("#1")}}
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/modules/mkiv/s-setups-missing.mkiv b/Master/texmf-dist/tex/context/modules/mkiv/s-setups-missing.mkiv
new file mode 100644
index 00000000000..53037a78db4
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkiv/s-setups-missing.mkiv
@@ -0,0 +1,118 @@
+% show missing translations
+
+\startluacode
+function interfaces.show_missing(whatinterfaces)
+ whatinterfaces = whatinterfaces or interfaces.interfaces
+ local list = dofile(resolvers.find_file("mult-def.lua"))
+ local NC, NR, HL = context.NC, context.NR, context.HL
+ for k,v in table.sortedhash(list) do
+ context.title(k)
+ context.starttabulate { string.rep("|",#whatinterfaces+1) }
+ for i=1,#whatinterfaces do
+ NC()
+ context(whatinterfaces[i])
+ end
+ NC() NR() HL()
+ for kk, vv in next, v do
+ if not string.find(kk,"subsub") then
+ local okay = true
+ for i=1,#whatinterfaces do
+ local int = whatinterfaces[i]
+ local str = vv[int]
+ if not str or (int ~= "en" and str == vv.en) then
+ okay = false
+ break
+ end
+ end
+ if not okay then
+ for i=1,#whatinterfaces do
+ local int = whatinterfaces[i]
+ local str = vv[int]
+ context.NC()
+ if not str then
+ -- nothing
+ elseif int == "en" then
+ context.color( { "darkgreen" }, str )
+ elseif str == vv.en then
+ context.color( { "darkred" }, str )
+ elseif int == "pe" then
+ context("\\righttoleft " .. str)
+ else
+ context(str)
+ end
+ end
+ NC() NR()
+ end
+ end
+ end
+ context.stoptabulate()
+ end
+end
+
+function interfaces.show_missing_messages(whatinterfaces)
+ whatinterfaces = whatinterfaces or interfaces.interfaces
+ local list = dofile(resolvers.find_file("mult-mes.lua"))
+ local NC, NR, HL = context.NC, context.NR, context.HL
+ for k,v in table.sortedhash(list) do
+ context.title("message: " .. k)
+ context.starttabulate { "|l|" .. string.rep("pl|",#whatinterfaces) }
+ NC()
+ for i=1,#whatinterfaces do
+ NC()
+ context(whatinterfaces[i])
+ end
+ NC() NR() HL()
+ local sorted = table.sortedkeys(v)
+ for i=1,#sorted do
+ local kk = sorted[i]
+ local vv = v[kk]
+ if kk ~= "files" then
+ local okay = true
+ for i=1,#whatinterfaces do
+ local int = whatinterfaces[i]
+ local str = vv[int]
+ if not str or (int ~= "en" and str == vv.en) then
+ okay = false
+ break
+ end
+ end
+ if not okay then
+ context.NC()
+ context(kk)
+ for i=1,#whatinterfaces do
+ local int = whatinterfaces[i]
+ local str = vv[int]
+ NC()
+ if not str then
+ -- nothing
+ elseif int == "en" then
+ context.color( { "darkgreen" }, str )
+ elseif str == vv.en then
+ context.color( { "darkred" }, str )
+ elseif int == "pe" then
+ context("\\righttoleft " .. str)
+ else
+ context(str)
+ end
+ end
+ NC() NR()
+ end
+ end
+ end
+ context.stoptabulate()
+ end
+end
+\stopluacode
+
+\starttext
+
+\setupbodyfont[dejavu,7pt,tt]
+\setuppapersize[A4,landscape][A4,landscape]
+\setuplayout[backspace=.5cm,width=middle,topspace=.5cm,height=middle,header=1cm,footer=0cm]
+
+\startluacode
+ interfaces.show_missing() -- { "en","nl" }
+ interfaces.show_missing_messages() -- { "en","nl" }
+\stopluacode
+
+\stoptext
diff --git a/Master/texmf-dist/tex/context/modules/mkiv/s-sql-tables.lua b/Master/texmf-dist/tex/context/modules/mkiv/s-sql-tables.lua
new file mode 100644
index 00000000000..43410354134
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkiv/s-sql-tables.lua
@@ -0,0 +1,152 @@
+if not modules then modules = { } end modules ['s-languages-counters'] = {
+ version = 1.001,
+ comment = "companion to s-languages-counters.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+require("util-tpl")
+require("util-sql")
+require("util-sql-tracers")
+
+moduledata = moduledata or { }
+moduledata.sql = moduledata.sql or { }
+moduledata.sql.tables = moduledata.sql.tables or { }
+
+local context = context
+
+function moduledata.sql.showfields(specification) -- not that sql specific
+ local data = specification.data
+ if data and #data > 0 then
+ local keys = specification.order or table.sortedkeys(data[1])
+ local align = specification.align
+ local template = "|"
+ if type(align) == "table" then
+ for i=1,#keys do
+ template = template .. (align[keys[i]] or "c") .. "|"
+ end
+ else
+ template = template .. string.rep((align or "c").. "|",#keys)
+ end
+ context.starttabulate { template }
+ context.NC()
+ for i=1,#keys do
+ context(keys[i])
+ context.NC()
+ end
+ context.NR()
+ context.HL()
+ for i=specification.first or 1,specification.last or #data do
+ local d = data[i]
+ context.NC()
+ for i=1,#keys do
+ context(d[keys[i]])
+ context.NC()
+ end
+ context.NR()
+ end
+ context.stoptabulate()
+ end
+end
+
+function moduledata.sql.validpresets(presets)
+ local okay = true
+ if presets.database == "" then
+ context("No database given.")
+ context.blank()
+ okay = false
+ end
+ if presets.password == "" then
+ context("No password given")
+ context.blank()
+ okay = false
+ end
+ return okay
+end
+
+function moduledata.sql.tables.showdefined(presets) -- key=value string | { presets = "name" } | { presets }
+
+ if type(presets) == "string" then
+ local specification = interfaces.checkedspecification(presets)
+ if specification.presets then
+ presets = table.load(specification.presets) or { }
+ end
+ end
+
+ if type(presets.presets) == "string" then
+ presets = table.load(presets.presets) or { }
+ end
+
+ if not moduledata.sql.validpresets(presets) then
+ return
+ end
+
+ local sql_tables = utilities.sql.tracers.gettables(presets)
+
+ context.starttitle { title = presets.database }
+
+ for name, fields in table.sortedhash(sql_tables) do
+
+ context.startsubject { title = name }
+
+ context.starttabulate { format = "|l|l|l|l|l|p|" }
+ context.FL()
+ context.NC() context.bold("field")
+ context.NC() context.bold("type")
+ context.NC() context.bold("default")
+ context.NC() context.bold("null")
+ context.NC() context.bold("key")
+ context.NC() context.bold("extra")
+ context.NC() context.NR()
+ context.TL()
+ for i=1,#fields do
+ local field = fields[i]
+ context.NC() context(field.field)
+ context.NC() context(field.type)
+ context.NC() context(field.default)
+ context.NC() context(field.null)
+ context.NC() context(field.key)
+ context.NC() context(field.extra)
+ context.NC() context.NR()
+ end
+ context.LL()
+ context.stoptabulate()
+
+ context.stopsubject()
+ end
+
+ context.stoptitle()
+
+end
+
+function moduledata.sql.tables.showconstants(list)
+
+ context.starttitle { title = "Constants" }
+
+ for name, fields in table.sortedhash(list) do
+
+ if type(fields) == "table" and #fields > 0 then
+
+ context.startsubject { title = name }
+
+ context.starttabulate { format = "|l|l|" }
+ for i=0,#fields do
+ local field = fields[i]
+ if field then
+ context.NC() context(i)
+ context.NC() context(field)
+ context.NC() context.NR()
+ end
+ end
+ context.stoptabulate()
+
+ context.stopsubject()
+
+ end
+
+ end
+
+ context.stoptitle()
+
+end
diff --git a/Master/texmf-dist/tex/context/modules/mkiv/s-sql-tables.mkiv b/Master/texmf-dist/tex/context/modules/mkiv/s-sql-tables.mkiv
new file mode 100644
index 00000000000..4c8bcddac50
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkiv/s-sql-tables.mkiv
@@ -0,0 +1,30 @@
+%D \module
+%D [ file=s-sql-tables,
+%D version=2012.07.12,
+%D title=\CONTEXT\ Extra Modules,
+%D subtitle=SQL,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\startmodule[sql-tables]
+
+\registerctxluafile{s-sql-tables}{}
+
+\doifsomething {\currentmoduleparameter{method}}{
+ \ctxlua{utilities.sql.setmethod("\currentmoduleparameter{method}")}
+}
+
+\doifsomething {\currentmoduleparameter{server}} {
+ \ctxlua{utilities.sql.setserver("\currentmoduleparameter{server}")}
+}
+
+\installmodulecommandluasingle \showdefinedsqltables {moduledata.sql.tables.showdefined}
+
+\stopmodule
+
+
diff --git a/Master/texmf-dist/tex/context/modules/mkiv/s-structure-sections.mkiv b/Master/texmf-dist/tex/context/modules/mkiv/s-structure-sections.mkiv
new file mode 100644
index 00000000000..daaab5abcd0
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkiv/s-structure-sections.mkiv
@@ -0,0 +1,80 @@
+%D \module
+%D [ file=s-structure-sections,
+%D version=2015.02.02,
+%D title=\CONTEXT\ Style File,
+%D subtitle=Show Structure Sections,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\unprotect
+
+\startluacode
+ local context = context
+ local ctx_NC, ctx_NR = context.NC, context.NR
+ local ctx_bold = context.bold
+
+ structures.tracers = structures.tracers or { }
+
+ function structures.tracers.showsections()
+
+ local list = structures.sections.registered
+ local keys = table.keys(list)
+ table.sort(keys,function(a,b)
+ local la, lb = list[a].level, list[b].level
+ if la == lb then
+ return a < b
+ else
+ return la < lb
+ end
+ end)
+ context.start()
+ context.switchtobodyfont { "tt" }
+ context.starttabulate { "||c||||" }
+ context.FL()
+ ctx_NC() ctx_bold("name")
+ ctx_NC() ctx_bold("level")
+ ctx_NC() ctx_bold("parent")
+ ctx_NC() ctx_bold("section")
+ ctx_NC() ctx_bold("coupling")
+ ctx_NC() context.NR()
+ context.ML()
+ for i=1,#keys do
+ local k = keys[i]
+ local v = list[k]
+ ctx_NC() ctx_bold(k)
+ ctx_NC() context(v.level)
+ ctx_NC() context(v.parent)
+ ctx_NC() context(v.section)
+ ctx_NC() context(v.coupling)
+ ctx_NC() context.NR()
+ end
+ context.LL()
+ context.stoptabulate()
+ context.stop()
+
+ end
+\stopluacode
+
+
+\starttexdefinition showstructuresections
+
+ % no settings yet
+
+ \ctxlua{structures.tracers.showsections()}
+
+\stoptexdefinition
+
+\protect
+
+\continueifinputfile{s-structure-sections.mkiv}
+
+\starttext
+
+ \showstructuresections
+
+\stoptext
diff --git a/Master/texmf-dist/tex/context/modules/mkiv/s-syntax.mkiv b/Master/texmf-dist/tex/context/modules/mkiv/s-syntax.mkiv
new file mode 100644
index 00000000000..96312f77179
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkiv/s-syntax.mkiv
@@ -0,0 +1,96 @@
+%D \module
+%D [ file=s-syntax, % was: s-syn-01,
+%D version=0000.00.00,
+%D title=\CONTEXT\ Style File,
+%D subtitle=Preliminary Syntax Stuff,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+%D This is needed for the \METAFUN\ manual: quite old code that I would do
+%D differently nowadays.
+
+\unprotect
+
+\unexpanded\def\module_syntax_Indent #1{\ifvmode\noindent\hbox to 2em{\hss#1}\else#1\fi}
+\unexpanded\def\module_syntax_Sugar #1{\removeunwantedspaces\kern.25em{#1}\kern.25em\ignorespaces}
+\unexpanded\def\module_syntax_Something #1{\Sugar{\mathematics{\langle\hbox{#1}\rangle}}}
+\unexpanded\def\module_syntax_Lbrace {\Sugar{\tttf\leftargument}}
+\unexpanded\def\module_syntax_Rbrace {\Sugar{\tttf\rightargument}}
+\unexpanded\def\module_syntax_Lparent {\Sugar{\tttf(}}
+\unexpanded\def\module_syntax_Rparent {\Sugar{\tttf)}}
+\unexpanded\def\module_syntax_Lbracket {\Sugar{\tttf[}}
+\unexpanded\def\module_syntax_Rbracket {\Sugar{\tttf]}}
+\unexpanded\def\module_syntax_Or {\Sugar{\mathematics{\vert}}}
+\unexpanded\def\module_syntax_Optional #1{\Sugar{\mathematics{[\hbox{#1}]}}}
+\unexpanded\def\module_syntax_Means {\Sugar{\mathematics{\rightarrow}}}
+\unexpanded\def\module_syntax_Tex #1{\Sugar{\type{#1}}}
+\unexpanded\def\module_syntax_Literal #1{\Sugar{\type{#1}}}
+\unexpanded\def\module_syntax_Syntax #1{\strut\kern-.25em{#1}\kern-.25em}
+\unexpanded\def\module_syntax_Next {\crlf\hbox to 2em{}\nobreak}
+\unexpanded\def\module_syntax_Whatever #1{\Sugar{\mathematics{(\hbox{#1})}}}
+\unexpanded\def\module_syntax_Quote #1{\Sugar{\quote{#1}}}
+\unexpanded\def\module_syntax_Or {\Sugar{\module_syntax_Indent{\mathematics{\vert}}}}
+\unexpanded\def\module_syntax_Means {\Sugar{\module_syntax_Indent{\mathematics{\rightarrow}}}}
+\unexpanded\def\module_syntax_FlaggedLiteral #1{\color[darkred]{\module_syntax_Literal{#1}}}
+\unexpanded\def\module_syntax_FlaggedSomething#1{\module_syntax_Something{\color[darkred]{#1}}}
+
+\unexpanded\def\StartSyntax
+ {\startlines
+ % formatters
+ \let\Indent \module_syntax_Indent
+ \let\Sugar \module_syntax_Sugar
+ \let\Something \module_syntax_Something
+ \let\Lbrace \module_syntax_Lbrace
+ \let\Rbrace \module_syntax_Rbrace
+ \let\Lparent \module_syntax_Lparent
+ \let\Rparent \module_syntax_Rparent
+ \let\Lbracket \module_syntax_Lbracket
+ \let\Rbracket \module_syntax_Rbracket
+ \let\Or \module_syntax_Or
+ \let\Optional \module_syntax_Optional
+ \let\Means \module_syntax_Means
+ \let\Tex \module_syntax_Tex
+ \let\Literal \module_syntax_Literal
+ \let\Syntax \module_syntax_Syntax
+ \let\Next \module_syntax_Next
+ \let\Whatever \module_syntax_Whatever
+ \let\Quote \module_syntax_Quote
+ \let\Or \module_syntax_Or
+ \let\Means \module_syntax_Means
+ \let\FlaggedLiteral \module_syntax_FlaggedLiteral
+ \let\FlaggedSomething\module_syntax_FlaggedSomething
+ % shortcuts
+ \let\FL \module_syntax_FlaggedLiteral
+ \let\FS \module_syntax_FlaggedSomething
+ \let\L \module_syntax_Literal
+ \let\S \module_syntax_Something
+ \let\M \module_syntax_Means
+ \let\O \module_syntax_Or
+ \let\Q \module_syntax_Quote
+ \let\LB \module_syntax_Lbrace
+ \let\RB \module_syntax_Rbrace
+ \let\LP \module_syntax_Lparent
+ \let\RP \module_syntax_Rparent
+ \let\LS \module_syntax_Lbracket
+ \let\RS \module_syntax_Rbracket
+ \let\{ \module_syntax_Lbrace
+ \let\} \module_syntax_Rbrace
+ \let\( \module_syntax_Lparent
+ \let\) \module_syntax_Rparent
+ \let\[ \module_syntax_Lbracket
+ \let\] \module_syntax_Rbracket
+ % precaution
+ \catcode`\#\othercatcode}
+
+\unexpanded\def\StopSyntax
+ {\stoplines}
+
+\unexpanded\def\SyntaxCommand#1%
+ {\csname module_syntax_#1\endcsname}
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/modules/mkiv/s-tugboat-columns.mkiv b/Master/texmf-dist/tex/context/modules/mkiv/s-tugboat-columns.mkiv
new file mode 100644
index 00000000000..f8cace1e98e
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkiv/s-tugboat-columns.mkiv
@@ -0,0 +1,556 @@
+%D \module
+%D [ file=t-tugboat
+%D version=$Id: t-tugboat.tex 91 2011-08-14 16:48:04Z karl $
+%D title=\CONTEXT\ Style File,
+%D subtitle=\TUGBOAT\ base style,
+%D author={Hans Hagen, Aditya Mahajan, \unknown},
+%D date=\currentdate,
+%D copyright=Public Domain]
+
+%D This file is derived t-tugboat by Aditya Mahajan which in turn is derived
+%D from older files. Here we use columnsets.
+
+\usemodule[newcolumnsets]
+
+%D We store the information about the article in variables.
+
+
+\setvariables
+ [tugboat]
+ [type=article,
+ %
+ year=1900,
+ volume=0,
+ number=0,
+ page=1001,
+ %
+ title=ConTeXt style for TUGboat,
+ subtitle=,
+ keywords=,
+ author=T. Boat,
+ address={Harbour Master KB \\ Harbour St. 1 \\ 8061GH Hasselt NL},
+ email={tugboat@tug.org}]
+
+%D \TUGBOAT\ uses slightly different interline space than the default. So we change
+%D the interline space.
+
+\definebodyfontenvironment [8pt] [interlinespace=9.5pt, big=9pt, small=7pt]
+\definebodyfontenvironment [9pt] [interlinespace=11pt, big=10pt, small=8pt]
+\definebodyfontenvironment [10pt] [interlinespace=12pt, big=12pt, small=9pt]
+\definebodyfontenvironment [12pt] [interlinespace=14pt, big=14.4pt,small=10pt]
+\definebodyfontenvironment [14.4pt] [interlinespace=18pt, big=14.4pt,small=12pt]
+
+%D We us e italic rather than slanted for emphasis.
+
+\setupbodyfontenvironment
+ [default]
+ [em=italic]
+
+%D \TUGBOAT\ uses Computer Modern fonts, and \CONTEXT\ uses Latin Modern by default.
+%D So, we just specify the font size.
+
+\setupbodyfont
+ [10pt]
+
+%D We break after these chars in urls, not before.
+
+\sethyphenatedurlafter /
+\sethyphenatedurlafter .
+\sethyphenatedurlafter _
+
+%D The original layout used in the \LATEX\ style for \TUGBOAT\ is a bit ambiguous.
+%D It uses low|-|level \TEX\ syntax, rather than changing the layout in a human
+%D understandable way (for example, by using the \mono{geometry} package. I have
+%D tried to translate it to \CONTEXT\ as far as I understand.
+
+\setuppapersize
+ [letter]
+ [letter]
+
+\setuplayout
+ [topspace=3.8pc,% was 3.5pc
+ header=1pc,
+ headerdistance=1.5pc,
+ height=middle,
+ footerdistance=2pc,
+ footer=1pc,
+ bottomspace=3pc,
+ %
+ backspace=6pc,
+ width=middle,
+ cutspace=6pc,
+ %
+ margin=4pc,
+ margindistance=1pc]
+
+\setupcolumnset
+ [distance=1.5pc]
+
+\setuppagenumbering
+ [location=,
+ alternative=doublesided]
+
+%D In \TUGBOAT\ different articles are glued together to form the final journal, so
+%D we do not want each article to occupy even number of pages.
+
+\installpagebreakhandler {last} {}
+
+%D We use automatic indentation control, that is: no indentation after titles and
+%D skips.
+
+\setupindenting
+ [20pt,yes]
+
+%D We do not want indentation after lists.
+
+\setupenumerations [indentnext=no]
+\setupdescriptions [indentnext=no]
+
+%D And these. We typeset itemizations ragged right.
+
+\setupitemgroup
+ [itemize]
+ [indentnext=no,
+ align=right]
+
+%D We align them at the paragraph indentation and pack them by default.
+
+\setupitemgroup
+ [itemize]
+ [each]
+ [margin=1pc,
+ width=1em,
+ distance=0pt]
+
+\setupitemgroup
+ [itemize]
+ [1]
+ [packed]
+
+%D We follow the \TUGBOAT\ style for sections. I do not know if \type {align=right}
+%D also disables hyphenation. Lets wait and see on this. Rest all is straight
+%D forward. It took me a while to realize that in \LATEX\ \type {\@startsection} the
+%D absolute value of before skip (fourth argument) is important and not the sign.
+
+\setuphead
+ [section,subsection,subsubsection,
+ subject,subsubject,subsubsubject]
+ [style=bold,
+ align=right,
+ before={\blank[8pt]},
+ after={\blank[4pt]}]
+
+%D We define a logical skip. This is equal to the \tex{topsep} in the normal style,
+%D and most environments should have this skip.
+
+\definevspacingamount[tugsmallamount] [3pt plus 1pt minus 1pt][.5\lineheight]
+\definevspacingamount[tugmediumamount][9pt plus 3pt minus 3pt][.5\lineheight]
+\definevspacingamount[tuglargeamount] [10pt plus 4pt minus 4pt][\lineheight]
+
+\defineblank[tugblank] [tugsmallamount]
+\defineblank[tugsmall] [tugsmallamount]
+\defineblank[tugmedium][tugmediumamount]
+\defineblank[tuglarge] [tuglargeamount]
+\defineblank[tughalf] [halfline]
+
+\setupblank
+ [tugblank]
+
+\setupitemize
+ [1]
+ [before={\blank[tugblank]},
+ after={\blank[tugblank]},
+ inbetween={\blank[tugblank]}]
+
+\setuplines
+ [before={\blank[tugblank]},
+ after={\blank[tugblank]},
+ inbetween={\blank[tugblank]}]
+
+%D \TUGBOAT\ uses a smaller font size for verbatim typesetting.
+
+\setuptyping
+ [option=none,
+ before={\blank[tugblank]\switchtobodyfont[small]},
+ after={\blank[tugblank]}]
+
+%D Not entirely a la \TUGBOAT:
+
+\unexpanded\def\MyFootNoteRule
+ {\hrule width 5pc height .4pt depth 0pt\relax \kern \strutdepth}
+
+\setupfootnotes
+ [bodyfont=8pt,
+ location=columns,
+ rule=on,
+ rulecommand=\MyFootNoteRule]
+
+\setupnotations
+ [location=joinedup,
+ width=fit,
+ headstyle=normal,
+ distance=.5em]
+
+%D We define a standard description and enumeration environment.
+
+\definedescription
+ [description]
+ [location=hanging,
+ width=broad,
+ before={\blank[tugblank]},
+ after={\blank[tugblank]}]
+
+\defineenumeration
+ [enumeration]
+ [location=hanging,
+ width=broad,
+ before={\blank[tugblank]},
+ after={\blank[tugblank]}]
+
+%D The bib does not handle urls nicely. So we provide a stop gap solution.
+
+\definereferenceformat
+ [cite]
+ [left={[},
+ right={]}]
+
+\defineitemgroup
+ [bibliography]
+ [levels=1]
+
+\setupitemgroup
+ [bibliography]
+ [symbol=n,
+ left={[},
+ right={]},
+ width=1.5em,
+ stopper=,
+ itemalign=flushright,
+ inbetween={\blank[small]}]
+
+%D Instead of color, we use weighted gray scales:
+
+\setupcolors
+ [conversion=always]
+
+%D English it is.
+
+\mainlanguage
+ [en]
+
+%D We define some logical skips
+
+\defineblank [tugbefore] [big]
+\defineblank [tuginbetween][big]
+\defineblank [tugafter] [tugbefore]
+
+%D Some real macros:
+
+\unexpanded\def\StartAbstract
+ {\dostartbuffer[abstract][StartAbstract][StopAbstract]}
+
+\startsetups tugboat:abstract:setup
+
+ \setuptolerance
+ [horizontal, tolerant]
+
+ \setupnarrower
+ [before={\blank[tughalf]},
+ after={\blank[tuglarge]},
+ middle=4.875pc]
+
+\stopsetups
+
+%D Headers and footers are different for normal issues and proceedings.
+
+\startsetups tugboat:banner:text:article
+
+% {\sl TUGboat},\space
+% Volume \getvariable{tugboat}{volume}\space
+% (\getvariable{tugboat}{year}),\space
+% No.\space\getvariable{tugboat}{number}
+
+\stopsetups
+
+\def\postissno{Proceedings of the \tubyear\ Annual Meeting}
+
+\startsetups tugboat:banner:text:proceedings
+
+ \setups[tugboat:banner:text:article]
+ \thinspace\emdash\thinspace
+ \postissno
+
+\stopsetups
+
+\startsetups tugboat:banner:setup:article
+
+ \setupheadertexts
+ [\setups{tugboat:banner:text:article}]
+ [pagenumber]
+
+% There are no footers in regular articles
+%
+% \setupfootertexts
+% [][\getvariable{tugboat}{author}]
+% [\getvariable{tugboat}{title}][]
+
+\stopsetups
+
+\startsetups tugboat:banner:setup:proceedings
+
+ \setupheadertexts
+ [][\getvariable{tugboat}{title}]
+ [\getvariable{tugboat}{author}][]
+
+ \setupfootertexts
+ [\setups{tugboat:banner:text:proceedings}]
+ [pagenumber]
+
+\stopsetups
+
+%D Article is default so,
+
+\setups[tugboat:banner:setup:article]
+
+%D It all starts here:
+
+\unexpanded\def\StartArticle{\directsetup{tugboat:\getvariable{tugboat}{type}:start}}
+\unexpanded\def\StopArticle {\directsetup{tugboat:article:stop}}
+
+\startsetups tugboat:introduction:article
+
+ \start
+ \unexpanded\def\\{\unskip\space\&\space\ignorespaces}
+ \hbox{\indent\getvariable{tugboat}{author}}
+ \par
+ \stop
+
+\stopsetups
+
+\startsetups tugboat:introduction:proceedings
+
+ \blank[20pt]
+
+ \start
+ \switchtobodyfont[12pt]
+ \def\\{\unskip\space\&\space\ignorespaces}
+ \getvariable{tugboat}{author}
+ \par
+ \stop
+
+ \start
+ \switchtobodyfont[9pt]
+ \unexpanded\def\\{\unskip,\space\ignorespaces}
+ \getvariable{tugboat}{address}
+ \par
+ \start
+ \tt
+ \getvariable{tugboat}{email}
+ \stop
+ \par
+ \stop
+
+\stopsetups
+
+\startsetups tugboat:columns:presets
+
+ % balancing data (heights)
+
+\stopsetups
+
+\startsetups tugboat:article:start
+
+ \starttext
+
+ \setups{tugboat:columns:presets}
+
+ \setups{tugboat:banner:setup:\getvariable{tugboat}{type}}
+
+ \startcolumnset
+
+ \setupheadertexts
+ [\setups{tugboat:banner:text:article}]
+ [pagenumber]
+
+ \setuppagenumber
+ [number=\getvariable{tugboat}{page}]
+
+ \snaptogrid \vbox \bgroup
+ \forgetall
+ \hrule height .6pt
+ \blank[halfline]
+ \start
+ \let\\=\par
+ \start
+ \bf
+ \getvariable{tugboat}{title}
+ \stop
+ \par
+ \blank[halfline]
+ \hskip20pt\getvariable{tugboat}{author}
+ \stop
+
+ \blank[line]
+
+ \doiftext {\getbuffer[abstract]} {
+ \let\\=\endgraf
+ \setups[tugboat:abstract:setup]
+ \startsubject[title={Abstract}]
+ \getbuffer[abstract]
+ \stopsubject
+ }
+ \egroup
+
+\stopsetups
+
+\startsetups tugboat:proceedings:start
+
+ \starttext
+
+ \setups{tugboat:banner:setup:\getvariable{tugboat}{type}}
+
+ \setupheader
+ [state=empty]
+
+ \setuppagenumber
+ [number=\getvariable{tugboat}{page}]
+
+ \snaptogrid \vbox \bgroup
+
+ \forgetall
+
+ \start
+ \switchtobodyfont[14.4pt]
+ \let\\=\par
+ \getvariable{tugboat}{title}
+ \par
+ \stop
+
+ \setups{tugboat:introduction:\getvariable{tugboat}{type}}
+
+ \blank[tugmedium]
+
+ \let\\=\par
+
+ \setups[tugboat:abstract:setup]
+
+ \midaligned{\bf Abstract}
+
+ \startnarrower[middle]
+ \getbuffer[abstract]
+ \stopnarrower
+
+ \egroup
+
+ \startcolumnset
+
+\stopsetups
+
+\def\signaturewidth{13pc}
+
+\startsetups tugboat:affiliation:article
+
+ \blank[line]
+
+ \snaptogrid \vbox \bgroup
+
+ \forgetall
+
+ \leftskip=\dimexpr\textwidth-\signaturewidth\relax
+
+ \let\\=\par
+
+ \dontleavehmode\llap {
+ $\diamond$\enspace
+ }
+ \getvariable{tugboat}{author}
+ \par
+
+ \getvariable{tugboat}{address}
+ \par
+
+ {\tt\getvariable{tugboat}{email}}
+
+ \egroup
+
+\stopsetups
+
+\startsetups tugboat:affiliation:proceedings
+
+ % nothing fancy at the end
+
+\stopsetups
+
+\startsetups tugboat:article:stop
+
+ \setups{tugboat:affiliation:\getvariable{tugboat}{type}}
+
+ \blank[line]
+
+ \startpacked
+ \placenote[endnotes]
+ \stoppacked
+
+ \stopcolumnset
+
+ \page
+
+ \stoptext
+
+\stopsetups
+
+%D Normal word spacing, really?
+
+\setuptolerance
+ [strict]
+
+%D Use this in documents:
+
+% \setuptolerance
+% [verytolerant,stretch]
+
+%D Logos, abbreviations (load a local file if needed).
+
+\usemodule[abr-03]
+
+% \unexpanded\def\Dash {\unskip\thinspace\emdash\thinspace\ignorespaces}
+% \unexpanded\def\slash{/\penalty\zerocount\hskip\zeropoint\relax} % |/|
+
+%D Language stuff.
+
+\hyphenation{Post-Script data-base data-bases}
+
+\setuplanguage
+ [lefthyphenmin=2,
+ rightthyphenmin=3]
+
+%D A hack to read tugboat.dates settings.
+
+\newcount\issueseqno
+
+\def\tubyear{1234}
+\def\tubvol {5}
+\def\tubnum {6}
+
+\def\issyear #1.{\def\tubyear{#1}}
+\def\vol #1, #2.{\def\tubvol {#1}%
+ \def\tubnum {#2}}
+
+%D Good bye.
+
+\continueifinputfile{s-tugboat-columns.mkiv}
+
+\StartArticle
+
+ \StartAbstract
+ \input bryson
+ \StopAbstract
+
+ \dorecurse{30}{\input ward \par} \page
+
+ \startitemize
+ \startitem \input ward \stopitem
+ \startitem \input ward \stopitem
+ \stopitemize
+
+\StopArticle
diff --git a/Master/texmf-dist/tex/context/modules/mkiv/s-typesetting-kerning.mkiv b/Master/texmf-dist/tex/context/modules/mkiv/s-typesetting-kerning.mkiv
new file mode 100644
index 00000000000..48d81ce3602
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkiv/s-typesetting-kerning.mkiv
@@ -0,0 +1,209 @@
+%D \module
+%D [ file=s-typesetting-kerning,
+%D version=2014.12.14,
+%D title=\CONTEXT\ Style File,
+%D subtitle=Show Character Kerning,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\unprotect
+
+\definecharacterkerning
+ [typesetting-kerning-demo]
+ [factor=.5]
+
+\startbuffer[showcharacterkerning:boxes]
+ \starttextrule{boxes}
+ \showfontkerns
+ \dontcomplain
+ \startlines
+ test \hbox{!} test
+ test\hbox{!} test
+ test \hbox{!}test
+ test:$x$ test
+ \setcharacterkerning[typesetting-kerning-demo]
+ test \hbox{!} test
+ test\hbox{!} test
+ test \hbox{!}test
+ test:$x$ test
+ \stoplines
+ \stoptextrule
+\stopbuffer
+
+\startbuffer[showcharacterkerning:ligatures]
+ \starttextrule{ligatures}
+ \dontcomplain
+ \startlines
+ effe flink effectief efficient fietsen
+ \blank
+ \setcharacterkerning[typesetting-kerning-demo]
+ effe flink effectief efficient fietsen
+ \blank \hsize\zeropoint
+ effe
+ flink
+ effectief
+ efficient
+ fietsen
+ \stoplines
+ \stoptextrule
+\stopbuffer
+
+\startbuffer[showcharacterkerning:discretionaries]
+ \starttextrule{discretionary}
+ \dontcomplain
+ \startlines
+ \hbox{\samplediscretionary}
+ \hbox{xxx\samplediscretionary}
+ \hbox{\samplediscretionary xxx}
+ \hbox{xxx\samplediscretionary xxx}
+ \blank
+ \setcharacterkerning[typesetting-kerning-demo]
+ \hbox{\samplediscretionary}
+ \hbox{xxx\samplediscretionary}
+ \hbox{\samplediscretionary xxx}
+ \hbox{xxx\samplediscretionary xxx}
+ \blank \hsize\zeropoint
+ \samplediscretionary
+ xxx\samplediscretionary
+ \samplediscretionary xxx
+ xxx\samplediscretionary xxx
+ \stoplines
+ \stoptextrule
+\stopbuffer
+
+\startbuffer[showcharacterkerning:explicits]
+ \starttextrule{explicits}
+ \exhyphenchar \hyphenasciicode
+ \preexhyphenchar \lessthanasciicode
+ \postexhyphenchar\morethanasciicode
+ \def\TestDisc
+ {\discretionary
+ {\kern\emwidth<}%
+ {>\kern\emwidth}%
+ {\kern\emwidth=\kern\emwidth}%
+ }
+ \dontcomplain
+ \startlines
+ \hbox{super-charged}
+ \hbox{super\-charged}
+ \hbox{super\TestDisc charged}
+ \hbox{super\discretionary{[}{]}{[]}charged}
+ \blank
+ \setcharacterkerning[typesetting-kerning-demo]
+ \hbox{super-charged}
+ \hbox{super\-charged}
+ \hbox{super\TestDisc charged}
+ \hbox{super\discretionary{[}{]}{[]}charged}
+ \blank \hsize\zeropoint
+ super-charged
+ super\-charged
+ super\TestDisc charged
+ super\discretionary{[}{]}{[]}charged
+ \stoplines
+ \stoptextrule
+\stopbuffer
+
+\starttexdefinition unexpanded showcharacterkerning
+ \getbuffer[showcharacterkerning:boxes]
+ \getbuffer[showcharacterkerning:ligatures]
+ \getbuffer[showcharacterkerning:discretionaries]
+ \getbuffer[showcharacterkerning:explicits]
+\stoptexdefinition
+
+
+\starttexdefinition showcharacterkerningstepscompared #1
+ \definecharacterkerning[crap][factor=\KerningStepFactor]%
+ \setbox0=\ruledhbox{\color[color-1]{#1}\hss}
+ \setbox2=\ruledhbox{\setcharacterkerning[crap]\color[color-2]{#1}}
+ \setbox4=\ruledhbox{\setcharacterkerning[crap]\showfontkerns\showglyphs#1}
+ \xdef\KerningStepPercentage{\ctxlua{context("\letterpercent 0.2f",(1-\number\wd0/\number\wd2)*100)}}
+ \scratchwidth\wd0
+ \vtop\bgroup
+ \hbox{\box0\hskip-\scratchwidth\box2}
+ \par
+ \box4
+ \egroup
+\stoptexdefinition
+
+\starttexdefinition showcharacterkerningsteps [#1]
+
+ \start
+
+ \getdummyparameters
+ [\s!font=Regular,
+ \c!sample={Wat een bende, rommelen met het font design!},
+ \c!text={rommelen},
+ \c!first=00,
+ \c!last=95,
+ \c!step=05,
+ \c!option=, % \v!page
+ #1]
+
+ \doif{\dummyparameter\c!option}\v!page {
+ \startTEXpage[\c!offset=1ex]
+ }
+
+ \definecolor[color-1][r=1,t=.5,a=1]
+ \definecolor[color-2][b=1,t=.5,a=1]
+
+ \definedfont[\dummyparameter\s!font*default sa 1]
+
+ \doif {\dummyparameter\c!option}\v!page {
+ \begingroup
+ \tttf \dummyparameter\s!font\space @ default
+ \endgroup
+ \blank
+ }
+
+ \starttabulate[|cT|l|cT|l|cT|]
+
+ \NC \tt\bf factor \NC \tt\bf sample \NC \tt\bf \letterpercent \NC \tt\bf text \NC \tt\bf \letterpercent \NC \NR \HL
+
+ \dostepwiserecurse {\dummyparameter\c!first} {\dummyparameter\c!last} {\dummyparameter\c!step} {
+ \NC
+ \xdef\KerningStepFactor{\ctxlua{context("\letterpercent 0.3f",####1/1000)}}
+ \KerningStepFactor
+ \NC
+ \showcharacterkerningstepscompared{\dummyparameter\c!sample}
+ \NC
+ \KerningStepPercentage
+ \NC
+ \showcharacterkerningstepscompared{\dummyparameter\c!text}
+ \NC
+ \KerningStepPercentage
+ \NC \NR
+ }
+
+ \stoptabulate
+
+ \doif{\dummyparameter\c!option}\v!page {
+ \stopTEXpage
+ }
+
+ \stop
+
+\stoptexdefinition
+
+\protect
+
+\continueifinputfile{s-typesetting-kerning.mkiv}
+
+\starttext
+
+ % \showcharacterkerning
+
+ \showcharacterkerningsteps[font=file:FuturaStd-Book.otf,option=page]
+ \showcharacterkerningsteps[font=file:FuturaStd-Medium.otf,option=page]
+ \showcharacterkerningsteps[font=file:FuturaStd-Bold.otf,option=page]
+ \showcharacterkerningsteps[font=file:FuturaStd-heavy.otf,option=page]
+
+\stoptext
+
+% {\hsize1mm efficient\discretionary{\kern1pt!\kern1pt}{\kern1pt!\kern1pt}{\kern1pt!\kern1pt}efficient\par}
+% {\hsize1mm\definedfont[Regular]\setcharacterkerning[typesetting-kerning-demo]efficient\-efficient\par}
+
diff --git a/Master/texmf-dist/tex/context/modules/mkiv/s-xml-analyzers.lua b/Master/texmf-dist/tex/context/modules/mkiv/s-xml-analyzers.lua
new file mode 100644
index 00000000000..9de6471d148
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkiv/s-xml-analyzers.lua
@@ -0,0 +1,172 @@
+if not modules then modules = { } end modules ['s-xml-analyzers'] = {
+ version = 1.001,
+ comment = "companion to s-xml-analyzers.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+moduledata.xml = moduledata.xml or { }
+moduledata.xml.analyzers = moduledata.xml.analyzers or { }
+
+local next, type = next, type
+local utfvalues = string.utfvalues
+local context = context
+local NC, NR, HL, FL, LL, SL, TB = context.NC, context.NR, context.HL, context.TB, context.FL, context.LL, context.SL
+local sortedhash, sortedkeys, concat, sequenced = table.sortedhash, table.sortedkeys, table.concat, table.sequenced
+
+local chardata = characters.data
+
+local tags = { }
+local char = { }
+local attr = { }
+local name = nil
+
+local function analyze(filename)
+
+ if type(filename) == "string" then
+ filename = { filename }
+ end
+
+ table.sort(filename)
+
+ local hash = concat(filename,"|")
+
+ if hash == name then
+ return
+ end
+
+ name = hash
+ tags = { }
+ char = { }
+ attr = { }
+
+ table.setmetatableindex(tags,function(t,k)
+ local v = {
+ n = 0,
+ attributes = { },
+ children = { },
+ }
+ t[k] = v
+ return v
+ end)
+
+ table.setmetatableindex(char,function(t,k)
+ t[k] = 0
+ return 0
+ end)
+
+ table.setmetatableindex(attr,function(t,k)
+ char[k] = char[k] or 0
+ t[k] = 0
+ return 0
+ end)
+
+ local function collect(e,parent)
+ local dt = e.dt
+ if e.special then
+ if dt then
+ for i=1,#dt do
+ local d = dt[i]
+ if type(d) == "table" then
+ collect(d,tg)
+ end
+ end
+ end
+ else
+ local at = e.at
+ local tg = e.tg
+ local tag = tags[tg]
+ tag.n = tag.n + 1
+ if at then
+ local attributes = tag.attributes
+ for k, v in next, at do
+ local a = attributes[k]
+ if a then
+ a[v] = (a[v] or 0) + 1
+ else
+ attributes[k] = { [v] = 1 }
+ end
+ for s in utfvalues(v) do
+ attr[s] = attr[s] + 1
+ end
+ end
+ end
+ if parent then
+ local children = tags[parent].children
+ children[tg] = (children[tg] or 0) + 1
+ end
+ if dt then
+ for i=1,#dt do
+ local d = dt[i]
+ if type(d) == "table" then
+ collect(d,tg)
+ else
+ for s in utfvalues(d) do
+ char[s] = char[s] + 1
+ end
+ end
+ end
+ end
+ end
+ end
+
+ for i=1,#filename do
+ collect(xml.load(filename[i]))
+ end
+
+ table.setmetatableindex(tags,nil)
+ table.setmetatableindex(char,nil)
+ table.setmetatableindex(attr,nil)
+
+end
+
+moduledata.xml.analyzers.maxnofattributes = 100
+
+function moduledata.xml.analyzers.structure(filename)
+ analyze(filename)
+ local done = false
+ local maxnofattributes = tonumber(moduledata.xml.analyzers.maxnofattributes) or 100
+ context.starttabulate { "|l|pA{nothyphenated,flushleft,verytolerant,stretch,broad}|" }
+ for name, data in table.sortedhash(tags) do
+ if done then
+ context.TB()
+ else
+ done = true
+ end
+ local children = data.children
+ local attributes = data.attributes
+ NC() context.bold("element") NC() context.darkred(name) NC() NR()
+ NC() context.bold("frequency") NC() context(data.n) NC() NR()
+ if next(children) then
+ NC() context.bold("children") NC() context.puretext(sequenced(children)) NC() NR()
+ end
+ if next(attributes) then
+ NC() context.bold("attributes") NC() context.puretext.darkgreen(concat(sortedkeys(attributes)," ")) NC() NR()
+ for attribute, values in sortedhash(attributes) do
+ local n = table.count(values)
+ if attribute == "id" or attribute == "xml:id" or n > maxnofattributes then
+ NC() context(attribute) NC() context("%s different values",n) NC() NR()
+ else
+ NC() context(attribute) NC() context.puretext(sequenced(values)) NC() NR()
+ end
+ end
+ end
+ end
+ context.stoptabulate()
+end
+
+function moduledata.xml.analyzers.characters(filename)
+ analyze(filename)
+ context.starttabulate { "|r|r|l|c|l|" }
+ for c, n in table.sortedhash(char) do
+ NC() context.darkred("%s",n)
+ NC() context.darkgreen("%s",attr[c])
+ NC() context("%U",c)
+ NC() context.char(c)
+ NC() context("%s",chardata[c].description)
+ NC() NR()
+ end
+ context.stoptabulate()
+end
+
diff --git a/Master/texmf-dist/tex/context/modules/mkiv/s-xml-analyzers.mkiv b/Master/texmf-dist/tex/context/modules/mkiv/s-xml-analyzers.mkiv
new file mode 100644
index 00000000000..ed033bcfadf
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkiv/s-xml-analyzers.mkiv
@@ -0,0 +1,37 @@
+%D \module
+%D [ file=s-xml-analyzers,
+%D version=2013.05.28,
+%D title=\CONTEXT\ Style File,
+%D subtitle=Analyze XML Content,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\startmodule[xml-analyzers]
+
+\registerctxluafile{s-xml-analyzers}{}
+
+\installmodulecommandluasingle \showxmlstructure {moduledata.xml.analyzers.structure}
+\installmodulecommandluasingle \showxmlcharacters {moduledata.xml.analyzers.characters}
+
+\stopmodule
+
+\continueifinputfile{s-xml-analyzers.mkiv}
+
+\usemodule[art-01]
+
+\setupbodyfont[tt,10pt]
+
+\edef\FileName{\cldcontext{resolvers.findfile("music-collection.xml")}}
+
+\setupheadertexts[\FileName\space\emdash\space\pagenumber]
+
+\starttext
+
+ \showxmlcharacters[\FileName]
+
+\stoptext
diff --git a/Master/texmf-dist/tex/context/modules/mkiv/s-youless.mkiv b/Master/texmf-dist/tex/context/modules/mkiv/s-youless.mkiv
new file mode 100644
index 00000000000..e15973b9c63
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkiv/s-youless.mkiv
@@ -0,0 +1,171 @@
+%D \module
+%D [ file=s-youless,
+%D version=2013.11.12,
+%D title=\CONTEXT\ Style File,
+%D subtitle=Youless Graphics,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+%D This is experimental code. When I have collected enough data I will make the
+%D graphics nicer and provide some more.
+%D
+%D The Jouless can serve web pages but there is not much detail in them. They also are
+%D somewhat bad \HTML, like unquoted attributes and so. We don't need this anyway as we
+%D can also fetch data directly. The data is collected using a dedicated helper script
+%D (of course we could just call it as module too). The data is fetched from the Jouless
+%D device using queries (currently we use json, but a more direct parsing of data might
+%D be more efficient). The data is converted into a proper \LUA\ table and saved (merged).
+
+% in cronjob on one of the servers:
+%
+% mtxrun --script youless --collect --host=192.168.2.50 --watt youless-watt.lua
+% mtxrun --script youless --collect --host=192.168.2.50 --kwk youless-kwh.lua
+
+\startluacode
+
+ require("util-you")
+
+ moduledata.youless = { }
+
+ function moduledata.youless.kwh(specification)
+ -- todo
+ end
+
+ function moduledata.youless.watt(specification)
+
+ local year = tonumber(specification.year) or os.today().year
+ local data = table.load(specification.filename or "youless-watt.lua")
+
+ if not data or data.variant ~= "watt" then
+ context("invalid variant")
+ return
+ end
+
+ utilities.youless.analyze(data)
+
+ -- for the moment no specific font scaling
+
+ local years = data.years
+
+ if not years then
+ context("no years")
+ return
+ end
+
+ for y=year,year do
+
+ local year = years[y]
+ local scale = 20
+ local mark = 3
+ local maxwatt = specification.maxwatt or year.maxwatt
+
+ for m=1,12 do
+ local month = year.months[m]
+ if month then
+ context.startMPpage { offset = "10pt" }
+ context("linecap := butt; pickup pencircle scaled .5")
+
+ for i=0,(math.div(maxwatt,1000)+1)*1000,100 do
+ context("draw (%s,%s) -- (%s,%s) withcolor .6white ;",0,i/scale,31 * 24,i/scale)
+ end
+
+ context("draw (0,%s) -- (31 * 24,%s) dashed dashpattern(on 6 off 6) withcolor darkgreen withpen pencircle scaled 1 ;",year.watt /scale,year.watt /scale)
+ context("draw (0,%s) -- (31 * 24,%s) dashed dashpattern(off 6 on 6) withcolor darkred withpen pencircle scaled 1 ;",month.watt/scale,month.watt/scale)
+
+ local days = month.days
+ if days then
+ local nd = os.nofdays(y,m)
+ for d=1,nd do
+ local day = days[d]
+ local xoffset = (d-1) * 24
+ local wd = os.weekday(d,m,y)
+ local weekend = wd == 1 or wd == 7
+ if not weekend then
+ -- okay
+ elseif mark == 1 then
+ context("draw (%s,%s) -- (%s,%s) ; ",xoffset, -17.5,xoffset, -32.5)
+ context("draw (%s,%s) -- (%s,%s) ; ",xoffset+24,-17.5,xoffset+24,-32.5)
+ elseif mark == 2 then
+ context("draw (%s,%s) -- (%s,%s) ; ",xoffset, -17.5,xoffset+24,-17.5)
+ context("draw (%s,%s) -- (%s,%s) ; ",xoffset, -32.5,xoffset+24,-32.5)
+ elseif mark == 3 then
+ context("draw unitsquare xysized (%s,%s) shifted (%s,%s) ; ",24,15,xoffset,-32.5)
+ end
+ context([[draw textext("%s") shifted (%s,%s) ; ]],d,xoffset + 12,-25)
+ if day then
+ for h=0,23 do
+ local hours = day.hours
+ if hours then
+ local hour = hours[h]
+ if hour then
+ local dx = xoffset + h
+ local dy = hour.watt/scale
+ local dm = hour.maxwatt/scale
+ context("draw (%s,%s) -- (%s,%s) withcolor %s ; ",dx, 0,dx,dy,weekend and "darkmagenta" or "darkblue")
+ context("draw (%s,%s) -- (%s,%s) withcolor %s ; ",dx,dy,dx,dm,"darkgray")
+ end
+ end
+ end
+ end
+ end
+ for d=0,30 do
+ local xoffset = d * 24
+ context("draw (%s,%s) -- (%s,%s) withcolor darkgray ; ",xoffset+ 0,0,xoffset+ 0,-10)
+ context("draw (%s,%s) -- (%s,%s) withcolor darkgray ; ",xoffset+ 6,0,xoffset+ 6,-2.5)
+ context("draw (%s,%s) -- (%s,%s) withcolor darkgray ; ",xoffset+12,0,xoffset+12,-5)
+ context("draw (%s,%s) -- (%s,%s) withcolor darkgray ; ",xoffset+18,0,xoffset+18,-2.5)
+ end
+ local xoffset = 31 * 24
+ context("draw (%s,%s) -- (%s,%s) withcolor darkgray ; ",xoffset,0,xoffset,-10)
+ end
+
+ local max = (math.div(maxwatt,1000)+1)
+
+ for i=0,max*1000,1000 do
+ context([[draw textext.lft("%s") shifted (%s,%s) ; ]],i,-10,i/scale)
+ context("draw (%s,%s) -- (%s,%s) withcolor .2white ;",0,i/scale,31 * 24,i/scale)
+ end
+
+ context([[draw textext("\strut\month{%s}\enspace%s") shifted (%s,%s) ; ]],m, y, 31 * 24 / 2, -50)
+ context([[draw textext.lft("watt") shifted (%s,%s) ; ]],-10,-25)
+
+ context.stopMPpage()
+ else
+ -- maybe placeholder
+ end
+ end
+
+ end
+
+ end
+
+\stopluacode
+
+\continueifinputfile{s-youless.mkiv}
+
+\setupbodyfont[dejavu] % smaller sizes also look ok
+
+% printer (oce) : > 3000 W startup (900 W idle, 2000 W printing)
+% coffeemaker : 1500 W when heating
+
+% baseline day : 2250 W (servers, airco, workstations, routers, switches, heating, etc)
+% baseline night : 1750 W
+
+\starttext
+
+ \startluacode
+
+ -- os.execute([[mtxrun --script youless --collect --watt "c:/data/system/youless/data/youless-watt.lua"]])
+ -- os.execute([[mtxrun --script youless --collect --watt --nobackup "c:/data/system/youless/data/youless-watt.lua"]])
+ -- moduledata.youless.watt { year = 2013, filename = "c:/data/system/youless/data/youless-watt.lua" }
+
+ moduledata.youless.watt { year = 2013, filename = "youless-watt.lua" }
+
+ \stopluacode
+
+\stoptext
diff --git a/Master/texmf-dist/tex/context/modules/mkiv/x-asciimath.lua b/Master/texmf-dist/tex/context/modules/mkiv/x-asciimath.lua
new file mode 100644
index 00000000000..e0a4a714b03
--- /dev/null
+++ b/Master/texmf-dist/tex/context/modules/mkiv/x-asciimath.lua
@@ -0,0 +1,2209 @@
+if not modules then modules = { } end modules ['x-asciimath'] = {
+ version = 1.001,
+ comment = "companion to x-asciimath.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+--[[ldx--
+
Some backgrounds are discussed in x-asciimath.mkiv. This is a third version. I first
+tried a to make a proper expression parser but it's not that easy. First we have to avoid left
+recursion, which is not that trivial (maybe a future version of lpeg will provide that), and
+second there is not really a syntax but a mix of expressions and sequences with some fuzzy logic
+applied. Most problematic are fractions and we also need to handle incomplete expressions. So,
+instead we (sort of) tokenize the string and then do some passes over the result. Yes, it's real
+ugly and unsatisfying code mess down here. Don't take this as an example.