math-inc.mkiv /size: 2064 b    last modification: 2020-07-01 14:35
1%D \module
2%D   [       file=math-inc,
3%D        version=2018.06.23,
4%D          title=\CONTEXT\ Math Macros,
5%D       subtitle=XML inclusion,
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 Math Macros / XML inclusion}
15
16\registerctxluafile{math-inc}{}
17
18%D I had some doubt about including this in \CONTEXT\ but it might serve some users
19%D anyway. It's always the question to what extent one can be really roundtrip. I
20%D might improve it when I need it.
21
22% Talking about creating from a source ... June Lee's transcription of
23% Close to You by Jacob Collier is an amazing example:
24%
25% https://www.youtube.com/watch?v=hdBVN-HMuqI
26
27\unprotect
28
29\definesymbol[mmlattachment][{\infofont\darkred  mml}]
30\definesymbol[mmlcomment]   [{\infofont\darkblue mml}]
31
32\unexpanded\def\lxml_add_mml_blob#1#2%
33  {\relax
34   \clf_xmlformulatobuffer\number\c_strc_formulas_n{temp-xml-export}%
35   #2%
36     [\c!symbol=#1,%
37      \c!space=\v!yes,%
38      \c!buffer=temp-xml-export,%
39      \c!name={formula-\number\c_strc_formulas_n.xml}]%
40   \relax}
41
42\unexpanded\def\xmlattachmml
43  {\iftrialtypesetting \else \ifexporting \iflocation
44     \dostarttagged\t!ignore\empty
45       \lxml_add_mml_blob{mmlattachment}\attachment
46     \dostoptagged
47   \fi \fi \fi}
48
49\unexpanded\def\xmlcommentmml
50  {\iftrialtypesetting \else \ifexporting \iflocation
51     \dostarttagged\t!ignore\empty
52       \lxml_add_mml_blob{mmlcomment}\comment
53     \dostoptagged
54   \fi \fi \fi}
55
56%D This kind of feature creep is not yet configurable, nor documented.
57
58\unexpanded\def\xmladdmmlsource
59  {\iftrialtypesetting \else \ifexporting \iflocation
60     \dostarttagged\t!ignore\empty
61     \inleftmargin{%
62       \lxml_add_mml_blob{mmlattachment}\attachment
63       \quad
64       \lxml_add_mml_blob{mmlcomment}\comment
65     }%
66     \dostoptagged
67   \fi \fi \fi}
68
69\protect \endinput
70