1LaTeXML::Post::MathML(3U)ser Contributed Perl DocumentatiLoanTeXML::Post::MathML(3)
2
3
4
6 "LaTeXML::Post::MathML" - Post-Processing modules for converting math
7 to MathML.
8
10 "LaTeXML::Post::MathML" is the abstract base class for the MathML
11 Postprocessor; "LaTeXML::Post::MathML::Presentation" and
12 "LaTeXML::Post::MathML::Content" convert XMath to either Presentation
13 or Content MathML, or with that format as the principle branch for
14 Parallel markup.
15
17 The conversion is carried out primarly by a tree walk of the "XMath"
18 expression; appropriate handlers are selected and called depending on
19 the operators and forms encountered. Handlers can be defined on
20 applications of operators, or on tokens; when a token is applied, it's
21 application handler takes precedence over it's token handler
22
23 "DefMathML($key,$presentation,$content);"
24 Defines presentation and content handlers for $key. $key is of the
25 form "TYPE:ROLE:MEANING", where
26
27 TYPE : is one either C<Token> or C<Apply> (or C<Hint> ?)
28 ROLE : is a grammatical role (on XMath tokens)
29 MEANING : is the meaning attribute (on XMath tokens)
30
31 Any of these can be "?" to match any role or meaning; matches of both
32 are preferred, then match of meaning or role, or neither.
33
34 The subroutine handlers for presentation and content are given by
35 $presentation and $content, respectively. Either can be "undef", in
36 which case some other matching handler will be invoked.
37
38 For "Token" handlers, the arguments passed are the token node; for
39 "Apply" handler, the arguments passed are the operator node and any
40 arguments.
41
42 However, it looks like some "TOKEN" handlers are being defined to take
43 "$content,%attributes" being the string content of the token, and the
44 token's attributes!
45
46 Presentation Conversion Utilties
47 "$mmlpost->pmml_top($node,$style);"
48 This is the top-level converter applied to an "XMath" node. It
49 establishes a local context for font, style, size, etc. It
50 generally does the bulk of the work for a PresentationMathML's
51 "translateNode", although the latter wraps the actual "m:math"
52 element around it. ("style" is display or text).
53
54 "pmml($node)", "pmml_smaller($node)", "pmml_scriptsizsize($node)"
55 Converts the "XMath" $node to Presentation MathML. The latter two
56 are used when the context calls for smaller (eg. fraction parts) or
57 scriptsize (eg sub or superscript) size or style, so that the size
58 encoded within $node will be properly accounted for.
59
60 "pmml_mi($node,%attributes)", "pmml_mn($node,%attributes)",
61 "pmml_mo($node,%attributes)"
62 These are "Token" handlers, to create "m:mi", "m:mn" and "m:mo"
63 elements, respectively. When called as a handler, they will be
64 supplied only with an "XMath" node (typically an "XMTok"). For
65 convenient reuse, these functions may also be called on a 'virtual'
66 token: with $node being a string (that would have been the text
67 content of the "XMTok"), and the %attributes that would have been
68 the token's attributes.
69
70 "pmml_infix($op,@args)", "pmml_script($op,@args)",
71 "pmml_bigop($op,@args)"
72 These are "Apply" handlers, for handling general infix, sub or
73 superscript, or bigop (eg. summations) constructs. They are called
74 with the operator token, followed by the arguments; all are "XMath"
75 elements.
76
77 "pmml_row(@items)"
78 This wraps an "m:mrow" around the already converted @items if
79 neeed; That is, if there is only a single item it is returned
80 without the "m:mrow".
81
82 "pmml_unrow($pmml)"
83 This perverse utility takes something that has already been
84 converted to Presentation MathML. If the argument is an "m:mrow",
85 it returns a list of the mathml elements within that row, otherwise
86 it returns a list containing the single element $pmml.
87
88 "pmml_parenthesize($item,$open,$close)"
89 This utility parenthesizes the (already converted MathML) $item
90 with the string delimiters $open and $close. These are converted
91 to an "m:mrow" with "m:mo" for the fences, unless the "usemfenced"
92 switch is set, in which case "m:mfenced" is used.
93
94 "pmml_punctuate($separators,@items) "
95 This utility creates an "m:mrow" by interjecting the punctuation
96 between suceessive items in the list of already converted @items.
97 If there are more than one character in $separators the first is
98 used between the first pair, the next between the next pair; if the
99 separators is exhausted, the last is repeated between remaining
100 pairs. $separators defaults to (repeated) comma.
101
102 Content Conversion Utilties
103 "$mmlpost-"cmml_top($node); >
104 This is the top-level converter applied to an "XMath" node. It
105 establishes a local context for font, style, size, etc (were it
106 needed). It generally does the bulk of the work for a
107 ContentMathML's "translateNode", although the latter wraps the
108 actual "m:math" element around it.
109
110 "cmml($node)"
111 Converts the "XMath" $node to Content MathML.
112
113 "cmml_ci($token)"
114 Converts the "XMath" token to an "m:ci". (This may evolve to
115 generate a "m:csymbol", under appropriate circumstances)
116
117 "cmml_decoratedSymbol($item)"
118 Similar to "cmml_ci", but used when an operator is itself,
119 apparently, an application. This converts $item to Presentation
120 MathML to use for the content of the "m:ci".
121
122 "cmml_not($arg)"
123 Construct the not of the argument $arg.
124
125 "cmml_synth_not($op,@args)"
126 Synthesize an operator by applying "m:not" to another operator
127 ($op) applied to its @args ("XMath" elements that will be converted
128 to Content MathML). This is useful to define a handler for, eg.,
129 c<not-approximately-equals> in terms of c<m:approx>.
130
131 "cmml_synth_complement($op,@args)"
132 Synthesize an operator by applying a complementary operator ($op)
133 to the reverse of its @args ("XMath" elements that will be
134 converted to Content MathML). This is useful to define a handler
135 for, eg. "superset-of-or-equals" using "m:subset".
136
137 "cmml_or_compose($operators,@args)"
138 Synthesize an operator that stands for the "or" of several other
139 operators (eg. c<less-than-or-similar-to-or-approximately-equals>)
140 by composing it of the "m:or" of applying each of "m:less" and
141 "m:approx" to the arguments. The first operator is applied to the
142 converted arguments, while the rest are applied to "m:share"
143 elements referring to the previous ones.
144
145 "cmml_share($node)"
146 Converts the "XMath" $node to Content MathML, after assuring that
147 it has an id, so that it can be shared.
148
149 "cmml_shared($node)"
150 Generates a "m:share" element referting to $node, which should have
151 an id (such as after calling "cmml_share").
152
154 We should probably formalize the idea of a Math Processor as an
155 abstract class, but let this description provide a starting overview.
156 A MathProcessor follows the API of "LaTeXML::Post" processors, by
157 handling "process", which invokes "processNode" on all "Math" nodes;
158 That latter inserts the result of either "translateNode" or
159 "translateParallel", applied to the "XMath" representation, into the
160 "Math" node.
161
162 Parallel translation is done whenever additional MathProcessors have
163 been specified, via the "setParallel" method; these are simply other
164 MathProcessors following the same API.
165
166
167
168perl v5.28.1 2018-07-08 LaTeXML::Post::MathML(3)