x-math-svg.mkvi /size: 1598 b    last modification: 2020-07-01 14:35
1%D \module
2%D   [       file=x-math-svg,
3%D        version=2014.09.19,
4%D          title=\CONTEXT\ XML Modules,
5%D       subtitle=\MATHML\ to \SVG,
6%D         author=Hans Hagen,
7%D           date=\currentdate,
8%D      copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
9%C
10%C This module is part of the \CONTEXT\ macro||package and is
11%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
12%C details.
13
14\writestatus{loading}{ConTeXt XML Macros / MathML to SVG Converter}
15
16\usemodule[x][mathml]
17
18\registerctxluafile{x-math-svg}{}
19
20\starttexdefinition MakeSVGMath #index#page#mode
21    \setbox\scratchbox\hbox\bgroup
22        \xmlprocessbuffer{main}{math-#page}{}
23    \egroup
24    \ctxlua {
25        moduledata.svgmath.register(#index, #page, {
26            mode   = "#mode",
27            width  = \number\wd\scratchbox,
28            height = \number\ht\scratchbox,
29            depth  = \number\dp\scratchbox,
30        } )
31    }
32    \startTEXpage
33        \box\scratchbox
34    \stopTEXpage
35\stoptexdefinition
36
37\starttexdefinition ReuseSVGMath #index#page
38    \ctxlua {
39        moduledata.svgmath.register(#index,#page)
40    }
41\stoptexdefinition
42
43% assume the same font .. what to do with size
44
45\startluacode
46
47    local svgstyle = document.arguments.svgstyle or ""
48
49    if type(svgstyle) == "string" and svgstyle ~= "" then
50        context.environment { svgstyle }
51    else
52        context.setupbodyfont { "pagella" }
53    end
54
55\stopluacode
56
57% \continueifinputfile{x-math-svg.mkvi}
58
59\starttext
60
61    \startluacode
62        moduledata.svgmath.process(environment.arguments.inputfile)
63    \stopluacode
64
65\stoptext
66