summaryrefslogtreecommitdiff
path: root/tex/context/modules/mkiv/x-math-svg.mkvi
blob: 4645f75d8056cb5ce935eb883887d6a6eae461b4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
%D \module
%D   [       file=x-math-svg,
%D        version=2014.09.19,
%D          title=\CONTEXT\ XML Modules,
%D       subtitle=\MATHML\ to \SVG,
%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 XML Macros / MathML to SVG Converter}

\usemodule[x][mathml]

\registerctxluafile{x-math-svg}{}

\starttexdefinition MakeSVGMath #index#page#mode
    \setbox\scratchbox\hbox\bgroup
        \xmlprocessbuffer{main}{math-#page}{}
    \egroup
    \ctxlua {
        moduledata.svgmath.register(#index, #page, {
            mode   = "#mode",
            width  = \number\wd\scratchbox,
            height = \number\ht\scratchbox,
            depth  = \number\dp\scratchbox,
        } )
    }
    \startTEXpage
        \box\scratchbox
    \stopTEXpage
\stoptexdefinition

\starttexdefinition ReuseSVGMath #index#page
    \ctxlua {
        moduledata.svgmath.register(#index,#page)
    }
\stoptexdefinition

% assume the same font .. what to do with size

\startluacode

    local svgstyle = document.arguments.svgstyle or ""

    if type(svgstyle) == "string" and svgstyle ~= "" then
        context.environment { svgstyle }
    else
        context.setupbodyfont { "pagella" }
    end

\stopluacode

% \continueifinputfile{x-math-svg.mkvi}

\starttext

    \startluacode
        moduledata.svgmath.process(environment.arguments.inputfile)
    \stopluacode

\stoptext