[NTG-context] Minimal code for exporting custom tags
Aditya Mahajan
adityam at umich.edu
Tue May 19 07:45:42 CEST 2020
On Mon, 18 May 2020, Aditya Mahajan wrote:
>> Thanks! This also helped me find the documentation in hybrid.pdf.
Also epub-mkiv.pdf. Not sure why I didn't think of looking there.
> How do I pass options so that the export is
>
> <mycommand name=whatever>...</mycommand>
>
> (or some variant of that). I thought that
>
> \startelement[mycommand][name=whatever]
>
> should work (there are some such examples in the texmf tree), but it does
> not.
epub-mkiv.pdf states that I need `\setupexport[properties=yes]`, but that doesn't work either:
```
\setupbackend[export=xml]
\setupexport [properties=my]
\setelementbackendtag[mycommand]
\setelementnature [mycommand][mixed]
\starttext
\startsection[title={Sample document}]
\startparagraph
This is a paragraph
\stopparagraph
\startelement[mycommand][name=whatever]
This is mycommand
\stopelement
\stopsection
\stoptext
```
gives
```
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!--
input filename : test-tag
processing date : 2020-05-19T01:34:41-04:00
context version : 2020.05.09 15:37
exporter version : 0.35
-->
<!-- This export file is used for filtering runtime only! -->
<document context="2020.05.09 15:37" date="2020-05-19T01:34:41-04:00" file="test-tag" language="en" version="0.35" xmlns:m="http://www.w3.org/1998/Math/MathML">
<metadata>
</metadata>
<section detail="section" chain="section" implicit="1" level="3">
<sectioncaption>
<sectionnumber>1</sectionnumber>
<sectiontitle>Sample document</sectiontitle>
</sectioncaption>
<sectioncontent>
<paragraph>This is a paragraph</paragraph>
<mycommand>This is mycommand</mycommand>
</sectioncontent>
</section>
</document>
```
What am I still missing?
On a different note, I didn't realize that interfaces.implement could create macros which could be used like this:
```
\unexpanded\def\dostartexport
{%\glet\dostartexport\relax
\let\currentexport\empty
\clf_setupexport
align {\exportparameter\c!align}%
bodyfont \dimexpr\exportparameter\c!bodyfont\relax
width \dimexpr\exportparameter\c!width\relax
properties {\exportparameter\c!properties}%
hyphen {\exportparameter\c!hyphen}%
title {\exportparameter\c!title}%
subtitle {\exportparameter\c!subtitle}%
author {\exportparameter\c!author}%
firstpage {\exportparameter\c!firstpage}%
lastpage {\exportparameter\c!lastpage}%
svgstyle {\exportparameter\c!svgstyle}%
cssfile {\exportparameter\c!cssfile}%
file {\exportparameter\c!file}%
export {\backendparameter\c!export}%
\relax}
```
This nicely gets around TeX's limitation of 9 arguments!
Aditya
More information about the ntg-context
mailing list