summaryrefslogtreecommitdiff
path: root/tex/context/base/mkxl/math-inc.mkxl
blob: 4db75e37e1112f357468eda9e0c5922c53260a10 (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
66
67
68
69
%D \module
%D   [       file=math-inc,
%D        version=2018.06.23,
%D          title=\CONTEXT\ Math Macros,
%D       subtitle=XML inclusion,
%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 Math Macros / XML inclusion}

\registerctxluafile{math-inc}{}

%D I had some doubt about including this in \CONTEXT\ but it might serve some users
%D anyway. It's always the question to what extent one can be really roundtrip. I
%D might improve it when I need it.

% Talking about creating from a source ... June Lee's transcription of
% Close to You by Jacob Collier is an amazing example:
%
% https://www.youtube.com/watch?v=hdBVN-HMuqI

\unprotect

\definesymbol[mmlattachment][{\infofont\darkred  mml}]
\definesymbol[mmlcomment]   [{\infofont\darkblue mml}]

\permanent\protected\def\lxml_add_mml_blob#1#2%
  {\relax
   \clf_xmlformulatobuffer\number\c_strc_formulas_n{temp-xml-export}%
   #2%
     [\c!symbol=#1,%
      \c!space=\v!yes,%
      \c!buffer=temp-xml-export,%
      \c!name={formula-\number\c_strc_formulas_n.xml}]%
   \relax}

\permanent\protected\def\xmlattachmml
  {\iftrialtypesetting\orelse\ifexporting\iflocation
     \dostarttagged\t!ignore\empty
       \lxml_add_mml_blob{mmlattachment}\attachment
     \dostoptagged
   \fi\fi}

\permanent\protected\def\xmlcommentmml
  {\iftrialtypesetting\orelse\ifexporting\iflocation
     \dostarttagged\t!ignore\empty
       \lxml_add_mml_blob{mmlcomment}\comment
     \dostoptagged
   \fi\fi}

%D This kind of feature creep is not yet configurable, nor documented.

\permanent\protected\def\xmladdmmlsource
  {\iftrialtypesetting\orelse\ifexporting\iflocation
     \dostarttagged\t!ignore\empty
     \inleftmargin{%
       \lxml_add_mml_blob{mmlattachment}\attachment
       \quad
       \lxml_add_mml_blob{mmlcomment}\comment
     }%
     \dostoptagged
   \fi\fi}

\protect \endinput