Links
- Homepage
- https://wiki.contextgarden.net/
- XML manual?
- https://www.pragma-ade.nl/general/manuals/xml-mkiv.pdf
Nix
Nix package is texliveConTeXt
XML
ConTeXt looks interesting because it can do XML typesetting (see https://wiki.contextgarden.net/XML). I’m kinda having trouble with WeasyPrint (see my WeasyPrint notes), so I thought I’d try ConTeXt.
You really should look at the PDF manuals instead of looking for web pages on documentation. Dealing with XML in ConTeXt MkIV has way more info on \xmlfilter
than the wiki.
\startxmlsetups xml:presets:all
\xmlsetsetup {#1} {*} {xml:*}
\xmlsetsetup{#1}
{div[@aria-hidden='true']}
{xml:ariahidden:div}
\xmlsetsetup{#1}
{span[@aria-hidden='true']}
{xml:ariahidden:span}
\xmlsetsetup{#1}
{span[@class='citation']}
{xml:span:citation}
\stopxmlsetups
\xmlregistersetup{xml:presets:all}
\setupexternalfigures[location={local,default}]
\startxmlsetups xml:html
\mainlanguage[\xmlatt{#1}{lang}]
\xmlflush{#1}
\stopxmlsetups
\startxmlsetups xml:body
\xmlflush{#1}
\stopxmlsetups
\startxmlsetups xml:main
\xmlflush{#1}
\stopxmlsetups
\startxmlsetups xml:section
\startchapter[title=\xmltext{#1}{h2}]
\xmlflush{#1}
\stopchapter
\stopxmlsetups
\startxmlsetups xml:h3
\startsection[title=\xmltext{#1}{.}]
\stopsection
\stopxmlsetups
\startxmlsetups xml:p
\startparagraph
\xmlflush{#1}
\stopparagraph
\stopxmlsetups
\startxmlsetups xml:span
\xmlflush{#1}
\stopxmlsetups
\startxmlsetups xml:ol
\xmlflush{#1}
\stopxmlsetups
\startxmlsetups xml:li
\xmlflush{#1}
\stopxmlsetups
\startxmlsetups xml:div
\xmlflush{#1}
\stopxmlsetups
\startxmlsetups xml:a
\xmlflush{#1}
\stopxmlsetups
\startxmlsetups xml:span:citation
\bgroup\sc\xmlflush{#1}\egroup
\stopxmlsetups
\startxmlsetups xml:figcaption
\xmlflush{#1}
\stopxmlsetups
\startxmlsetups xml:fig-title
\xmlflush{#1}
\stopxmlsetups
\startxmlsetups xml:figure
\placefigure{\xmltext{#1}{figcaption/fig-title}}{\externalfigure[\xmlattribute{#1}{img}{src}]}
\stopxmlsetups
context --environment=environment.tex source.xml
It seems to be important for the source.xml
to have an .xml
extension.
If you have a .xhtml
extension, it doesn’t seem to work.
Mapping a command on matching nodes
Use \xmlfilter
.
(Dunno where documentation or code is.)
\startxmlsetups xml:figure
\placefigure[][\xmlatt{#1}{id}]{\xmltext{#1}{figcaption/fig-title}}{\xmlfilter{#1}{/img/command(xml:img)}}
\stopxmlsetups
\startxmlsetups xml:img
\externalfigure[\xmlatt{#1}{src}]
\stopxmlsetups