asciimath 1.0.9 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. checksums.yaml +5 -5
  2. data/AST.adoc +457 -0
  3. data/CHANGELOG.adoc +12 -0
  4. data/Gemfile.lock +39 -0
  5. data/README.adoc +27 -3
  6. data/asciimath.gemspec +9 -5
  7. data/lib/asciimath.rb +5 -4
  8. data/lib/asciimath/ast.rb +456 -0
  9. data/lib/asciimath/cli.rb +4 -1
  10. data/lib/asciimath/color_table.rb +21 -0
  11. data/lib/asciimath/html.rb +126 -111
  12. data/lib/asciimath/latex.rb +386 -0
  13. data/lib/asciimath/markup.rb +478 -0
  14. data/lib/asciimath/mathml.rb +189 -87
  15. data/lib/asciimath/parser.rb +498 -343
  16. data/lib/asciimath/symbol_table.rb +25 -0
  17. data/lib/asciimath/version.rb +1 -1
  18. data/spec/ast.rb +144 -0
  19. data/spec/parser_spec.rb +592 -165
  20. data/spec/schema/mathml2/common/common-attribs.xsd +41 -0
  21. data/spec/schema/mathml2/common/math.xsd +126 -0
  22. data/spec/schema/mathml2/common/xlink-href.xsd +20 -0
  23. data/spec/schema/mathml2/content/arith.xsd +90 -0
  24. data/spec/schema/mathml2/content/calculus.xsd +146 -0
  25. data/spec/schema/mathml2/content/common-attrib.xsd +30 -0
  26. data/spec/schema/mathml2/content/constants.xsd +83 -0
  27. data/spec/schema/mathml2/content/constructs.xsd +260 -0
  28. data/spec/schema/mathml2/content/elementary-functions.xsd +117 -0
  29. data/spec/schema/mathml2/content/functions.xsd +73 -0
  30. data/spec/schema/mathml2/content/linear-algebra.xsd +173 -0
  31. data/spec/schema/mathml2/content/logic.xsd +53 -0
  32. data/spec/schema/mathml2/content/relations.xsd +55 -0
  33. data/spec/schema/mathml2/content/semantics.xsd +85 -0
  34. data/spec/schema/mathml2/content/sets.xsd +236 -0
  35. data/spec/schema/mathml2/content/statistics.xsd +136 -0
  36. data/spec/schema/mathml2/content/tokens.xsd +120 -0
  37. data/spec/schema/mathml2/content/vector-calculus.xsd +88 -0
  38. data/spec/schema/mathml2/mathml2.xsd +59 -0
  39. data/spec/schema/mathml2/presentation/action.xsd +44 -0
  40. data/spec/schema/mathml2/presentation/characters.xsd +37 -0
  41. data/spec/schema/mathml2/presentation/common-attribs.xsd +113 -0
  42. data/spec/schema/mathml2/presentation/common-types.xsd +103 -0
  43. data/spec/schema/mathml2/presentation/error.xsd +40 -0
  44. data/spec/schema/mathml2/presentation/layout.xsd +195 -0
  45. data/spec/schema/mathml2/presentation/scripts.xsd +186 -0
  46. data/spec/schema/mathml2/presentation/space.xsd +52 -0
  47. data/spec/schema/mathml2/presentation/style.xsd +69 -0
  48. data/spec/schema/mathml2/presentation/table.xsd +216 -0
  49. data/spec/schema/mathml2/presentation/tokens.xsd +124 -0
  50. data/spec/schema/mathml3/mathml3-common.xsd +99 -0
  51. data/spec/schema/mathml3/mathml3-content.xsd +684 -0
  52. data/spec/schema/mathml3/mathml3-presentation.xsd +2151 -0
  53. data/spec/schema/mathml3/mathml3-strict-content.xsd +186 -0
  54. data/spec/schema/mathml3/mathml3.xsd +9 -0
  55. metadata +102 -10
  56. data/.gitignore +0 -16
  57. data/.travis.yml +0 -18
@@ -0,0 +1,136 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+
3
+ <xs:schema
4
+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
5
+ xmlns="http://www.w3.org/1998/Math/MathML"
6
+ targetNamespace="http://www.w3.org/1998/Math/MathML"
7
+ elementFormDefault="qualified"
8
+ >
9
+
10
+ <xs:annotation>
11
+ <xs:documentation>
12
+ This is an XML Schema module for the statistical operators of content MathML.
13
+ Author: St&#233;phane Dalmas, INRIA.
14
+ </xs:documentation>
15
+ </xs:annotation>
16
+
17
+ <!-- "mean" -->
18
+
19
+ <xs:attributeGroup name="mean.attlist">
20
+ <xs:attributeGroup ref="Definition.attrib"/>
21
+ <xs:attributeGroup ref="Common.attrib"/>
22
+ </xs:attributeGroup>
23
+
24
+ <xs:complexType name="mean.type">
25
+ <xs:attributeGroup ref="mean.attlist"/>
26
+ </xs:complexType>
27
+
28
+ <xs:element name="mean" type="mean.type"/>
29
+
30
+ <!-- "sdev" -->
31
+
32
+ <xs:attributeGroup name="sdev.attlist">
33
+ <xs:attributeGroup ref="Definition.attrib"/>
34
+ <xs:attributeGroup ref="Common.attrib"/>
35
+ </xs:attributeGroup>
36
+
37
+ <xs:complexType name="sdev.type">
38
+ <xs:attributeGroup ref="sdev.attlist"/>
39
+ </xs:complexType>
40
+
41
+ <xs:element name="sdev" type="sdev.type"/>
42
+
43
+ <!-- "variance" -->
44
+
45
+ <xs:attributeGroup name="variance.attlist">
46
+ <xs:attributeGroup ref="Definition.attrib"/>
47
+ <xs:attributeGroup ref="Common.attrib"/>
48
+ </xs:attributeGroup>
49
+
50
+ <xs:complexType name="variance.type">
51
+ <xs:attributeGroup ref="variance.attlist"/>
52
+ </xs:complexType>
53
+
54
+ <xs:element name="variance" type="variance.type"/>
55
+
56
+ <!-- "median" -->
57
+
58
+ <xs:attributeGroup name="median.attlist">
59
+ <xs:attributeGroup ref="Definition.attrib"/>
60
+ <xs:attributeGroup ref="Common.attrib"/>
61
+ </xs:attributeGroup>
62
+
63
+ <xs:complexType name="median.type">
64
+ <xs:attributeGroup ref="median.attlist"/>
65
+ </xs:complexType>
66
+
67
+ <xs:element name="median" type="median.type"/>
68
+
69
+ <!-- "mode" -->
70
+
71
+ <xs:attributeGroup name="mode.attlist">
72
+ <xs:attributeGroup ref="Definition.attrib"/>
73
+ <xs:attributeGroup ref="Common.attrib"/>
74
+ </xs:attributeGroup>
75
+
76
+ <xs:complexType name="mode.type">
77
+ <xs:attributeGroup ref="mode.attlist"/>
78
+ </xs:complexType>
79
+
80
+ <xs:element name="mode" type="mode.type"/>
81
+
82
+ <!-- "moment" -->
83
+
84
+ <xs:attributeGroup name="moment.attlist">
85
+ <xs:attributeGroup ref="Definition.attrib"/>
86
+ <xs:attributeGroup ref="Common.attrib"/>
87
+ </xs:attributeGroup>
88
+
89
+ <xs:complexType name="moment.type">
90
+ <xs:attributeGroup ref="moment.attlist"/>
91
+ </xs:complexType>
92
+
93
+ <xs:element name="moment" type="moment.type"/>
94
+
95
+ <!-- "momentabout" -->
96
+
97
+ <xs:attributeGroup name="momentabout.attlist">
98
+ <xs:attributeGroup ref="Definition.attrib"/>
99
+ <xs:attributeGroup ref="Common.attrib"/>
100
+ </xs:attributeGroup>
101
+
102
+ <xs:group name="momentabout.content">
103
+ <xs:sequence>
104
+ <xs:group ref="Content-expr.class"/>
105
+ </xs:sequence>
106
+ </xs:group>
107
+
108
+ <xs:complexType name="momentabout.type">
109
+ <xs:group ref="momentabout.content" minOccurs="1" maxOccurs="unbounded"/>
110
+ <xs:attributeGroup ref="momentabout.attlist"/>
111
+ </xs:complexType>
112
+
113
+ <xs:element name="momentabout" type="momentabout.type"/>
114
+
115
+ <!-- And the group of everything -->
116
+
117
+ <xs:group name="Content-statistics.class">
118
+ <xs:choice>
119
+ <xs:element ref="mean"/>
120
+ <xs:element ref="sdev"/>
121
+ <xs:element ref="variance"/>
122
+ <xs:element ref="median"/>
123
+ <xs:element ref="mode"/>
124
+ <xs:element ref="moment"/>
125
+ <xs:element ref="momentabout"/>
126
+ </xs:choice>
127
+ </xs:group>
128
+
129
+
130
+ </xs:schema>
131
+ <!--
132
+ Copyright &#251; 2002 World Wide Web Consortium, (Massachusetts Institute
133
+ of Technology, Institut National de Recherche en Informatique et en
134
+ Automatique, Keio University). All Rights Reserved. See
135
+ http://www.w3.org/Consortium/Legal/.
136
+ -->
@@ -0,0 +1,120 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+
3
+ <xs:schema
4
+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
5
+ xmlns="http://www.w3.org/1998/Math/MathML"
6
+ targetNamespace="http://www.w3.org/1998/Math/MathML"
7
+ elementFormDefault="qualified"
8
+ >
9
+
10
+ <xs:annotation>
11
+ <xs:documentation>
12
+ This is the XML schema module for the token elements of the
13
+ content part of MathML.
14
+ Author: St&#233;phane Dalmas, INRIA.
15
+ </xs:documentation>
16
+ </xs:annotation>
17
+
18
+ <!-- common content for the token elements -->
19
+
20
+ <xs:group name="Content-token.content">
21
+ <xs:sequence>
22
+ <xs:group ref="Presentation-expr.class"/>
23
+ </xs:sequence>
24
+ </xs:group>
25
+
26
+ <!-- "cn" -->
27
+
28
+ <xs:attributeGroup name="cn.attlist">
29
+ <xs:attribute name="base">
30
+ <xs:simpleType>
31
+ <xs:restriction base="xs:positiveInteger">
32
+ <xs:minInclusive value="2"/>
33
+ <xs:maxInclusive value="36"/>
34
+ </xs:restriction>
35
+ </xs:simpleType>
36
+ </xs:attribute>
37
+ <xs:attribute name="type">
38
+ <xs:simpleType>
39
+ <xs:restriction base="xs:NMTOKEN">
40
+ <xs:enumeration value="e-notation"/>
41
+ <xs:enumeration value="integer"/>
42
+ <xs:enumeration value="rational"/>
43
+ <xs:enumeration value="real"/>
44
+ <xs:enumeration value="complex-cartesian"/>
45
+ <xs:enumeration value="complex-polar"/>
46
+ <xs:enumeration value="constant"/>
47
+ </xs:restriction>
48
+ </xs:simpleType>
49
+ </xs:attribute>
50
+ <xs:attributeGroup ref="Definition.attrib"/>
51
+ <xs:attributeGroup ref="Common.attrib"/>
52
+ </xs:attributeGroup>
53
+
54
+ <!-- the content of "cn" may have <sep> elements in it -->
55
+
56
+ <xs:complexType name="sep.type">
57
+ </xs:complexType>
58
+
59
+ <xs:element name="sep" type="sep.type"/>
60
+
61
+ <xs:group name="cn.content">
62
+ <xs:choice>
63
+ <xs:group ref="Presentation-expr.class"/>
64
+ <xs:element ref="sep"/>
65
+ </xs:choice>
66
+ </xs:group>
67
+
68
+ <xs:complexType name="cn.type" mixed="true">
69
+ <xs:group ref="cn.content" minOccurs="0" maxOccurs="unbounded"/>
70
+ <xs:attributeGroup ref="cn.attlist"/>
71
+ </xs:complexType>
72
+
73
+ <xs:element name="cn" type="cn.type"/>
74
+
75
+ <!-- "ci" -->
76
+
77
+ <xs:attributeGroup name="ci.attlist">
78
+ <xs:attribute name="type" type="xs:string"/>
79
+ <xs:attributeGroup ref="Definition.attrib"/>
80
+ <xs:attributeGroup ref="Common.attrib"/>
81
+ </xs:attributeGroup>
82
+
83
+ <xs:complexType name="ci.type" mixed="true">
84
+ <xs:group ref="Content-token.content" minOccurs="0"/>
85
+ <xs:attributeGroup ref="ci.attlist"/>
86
+ </xs:complexType>
87
+
88
+ <xs:element name="ci" type="ci.type"/>
89
+
90
+ <!-- "csymbol" -->
91
+
92
+ <xs:attributeGroup name="csymbol.attlist">
93
+ <xs:attributeGroup ref="Definition.attrib"/>
94
+ <xs:attributeGroup ref="Common.attrib"/>
95
+ </xs:attributeGroup>
96
+
97
+ <xs:complexType name="csymbol.type" mixed="true">
98
+ <xs:group ref="Content-token.content" minOccurs="0"/>
99
+ <xs:attributeGroup ref="csymbol.attlist"/>
100
+ </xs:complexType>
101
+
102
+ <xs:element name="csymbol" type="csymbol.type"/>
103
+
104
+ <!-- And the group of everything -->
105
+
106
+ <xs:group name="Content-tokens.class">
107
+ <xs:choice>
108
+ <xs:element ref="cn"/>
109
+ <xs:element ref="ci"/>
110
+ <xs:element ref="csymbol"/>
111
+ </xs:choice>
112
+ </xs:group>
113
+
114
+ </xs:schema>
115
+ <!--
116
+ Copyright &#251; 2002 World Wide Web Consortium, (Massachusetts Institute
117
+ of Technology, Institut National de Recherche en Informatique et en
118
+ Automatique, Keio University). All Rights Reserved. See
119
+ http://www.w3.org/Consortium/Legal/.
120
+ -->
@@ -0,0 +1,88 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+
3
+ <xs:schema
4
+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
5
+ xmlns="http://www.w3.org/1998/Math/MathML"
6
+ targetNamespace="http://www.w3.org/1998/Math/MathML"
7
+ elementFormDefault="qualified"
8
+ >
9
+
10
+ <xs:annotation>
11
+ <xs:documentation>
12
+ This is an XML Schema module for the vector calculs operators of content
13
+ MathML.
14
+ Author: St&#233;phane Dalmas, INRIA.
15
+ </xs:documentation>
16
+ </xs:annotation>
17
+
18
+ <!-- "divergence" -->
19
+
20
+ <xs:attributeGroup name="divergence.attlist">
21
+ <xs:attributeGroup ref="Definition.attrib"/>
22
+ <xs:attributeGroup ref="Common.attrib"/>
23
+ </xs:attributeGroup>
24
+
25
+ <xs:complexType name="divergence.type">
26
+ <xs:attributeGroup ref="divergence.attlist"/>
27
+ </xs:complexType>
28
+
29
+ <xs:element name="divergence" type="divergence.type"/>
30
+
31
+ <!-- "grad" -->
32
+
33
+ <xs:attributeGroup name="grad.attlist">
34
+ <xs:attributeGroup ref="Definition.attrib"/>
35
+ <xs:attributeGroup ref="Common.attrib"/>
36
+ </xs:attributeGroup>
37
+
38
+ <xs:complexType name="grad.type">
39
+ <xs:attributeGroup ref="grad.attlist"/>
40
+ </xs:complexType>
41
+
42
+ <xs:element name="grad" type="grad.type"/>
43
+
44
+ <!-- "curl" -->
45
+
46
+ <xs:attributeGroup name="curl.attlist">
47
+ <xs:attributeGroup ref="Definition.attrib"/>
48
+ <xs:attributeGroup ref="Common.attrib"/>
49
+ </xs:attributeGroup>
50
+
51
+ <xs:complexType name="curl.type">
52
+ <xs:attributeGroup ref="curl.attlist"/>
53
+ </xs:complexType>
54
+
55
+ <xs:element name="curl" type="curl.type"/>
56
+
57
+ <!-- "laplacian" -->
58
+
59
+ <xs:attributeGroup name="laplacian.attlist">
60
+ <xs:attributeGroup ref="Definition.attrib"/>
61
+ <xs:attributeGroup ref="Common.attrib"/>
62
+ </xs:attributeGroup>
63
+
64
+ <xs:complexType name="laplacian.type">
65
+ <xs:attributeGroup ref="laplacian.attlist"/>
66
+ </xs:complexType>
67
+
68
+ <xs:element name="laplacian" type="laplacian.type"/>
69
+
70
+ <!-- And the group of everything -->
71
+
72
+ <xs:group name="Content-vector-calculus.class">
73
+ <xs:choice>
74
+ <xs:element ref="divergence"/>
75
+ <xs:element ref="grad"/>
76
+ <xs:element ref="curl"/>
77
+ <xs:element ref="laplacian"/>
78
+ </xs:choice>
79
+ </xs:group>
80
+
81
+
82
+ </xs:schema>
83
+ <!--
84
+ Copyright &#251; 2002 World Wide Web Consortium, (Massachusetts Institute
85
+ of Technology, Institut National de Recherche en Informatique et en
86
+ Automatique, Keio University). All Rights Reserved. See
87
+ http://www.w3.org/Consortium/Legal/.
88
+ -->
@@ -0,0 +1,59 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+
3
+ <xs:schema
4
+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
5
+ xmlns="http://www.w3.org/1998/Math/MathML"
6
+ targetNamespace="http://www.w3.org/1998/Math/MathML"
7
+ elementFormDefault="qualified"
8
+ >
9
+ <xs:annotation>
10
+ <xs:documentation>
11
+ This is an XML Schema for MathML.
12
+ Author: St&#233;phane Dalmas, INRIA.
13
+ </xs:documentation>
14
+ </xs:annotation>
15
+
16
+ <!-- common stuff -->
17
+
18
+ <xs:include schemaLocation="common/math.xsd"/>
19
+ <xs:include schemaLocation="common/common-attribs.xsd"/>
20
+
21
+ <!-- Presentation -->
22
+ <xs:include schemaLocation="presentation/common-types.xsd"/>
23
+ <xs:include schemaLocation="presentation/common-attribs.xsd"/>
24
+ <xs:include schemaLocation="presentation/characters.xsd"/>
25
+ <xs:include schemaLocation="presentation/tokens.xsd"/>
26
+ <xs:include schemaLocation="presentation/scripts.xsd"/>
27
+ <xs:include schemaLocation="presentation/space.xsd"/>
28
+ <xs:include schemaLocation="presentation/layout.xsd"/>
29
+ <xs:include schemaLocation="presentation/table.xsd"/>
30
+ <xs:include schemaLocation="presentation/style.xsd"/>
31
+ <xs:include schemaLocation="presentation/error.xsd"/>
32
+ <xs:include schemaLocation="presentation/action.xsd"/>
33
+
34
+ <!-- Content -->
35
+
36
+ <xs:include schemaLocation="content/common-attrib.xsd"/>
37
+ <xs:include schemaLocation="content/tokens.xsd"/>
38
+ <xs:include schemaLocation="content/arith.xsd"/>
39
+ <xs:include schemaLocation="content/functions.xsd"/>
40
+ <xs:include schemaLocation="content/logic.xsd"/>
41
+ <xs:include schemaLocation="content/constructs.xsd"/>
42
+ <xs:include schemaLocation="content/constants.xsd"/>
43
+ <xs:include schemaLocation="content/elementary-functions.xsd"/>
44
+ <xs:include schemaLocation="content/relations.xsd"/>
45
+ <xs:include schemaLocation="content/semantics.xsd"/>
46
+ <xs:include schemaLocation="content/sets.xsd"/>
47
+ <xs:include schemaLocation="content/linear-algebra.xsd"/>
48
+ <xs:include schemaLocation="content/calculus.xsd"/>
49
+ <xs:include schemaLocation="content/vector-calculus.xsd"/>
50
+ <xs:include schemaLocation="content/statistics.xsd"/>
51
+
52
+
53
+ </xs:schema>
54
+ <!--
55
+ Copyright &#251; 2002 World Wide Web Consortium, (Massachusetts Institute
56
+ of Technology, Institut National de Recherche en Informatique et en
57
+ Automatique, Keio University). All Rights Reserved. See
58
+ http://www.w3.org/Consortium/Legal/.
59
+ -->
@@ -0,0 +1,44 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+
3
+ <xs:schema
4
+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
5
+ xmlns="http://www.w3.org/1998/Math/MathML"
6
+ targetNamespace="http://www.w3.org/1998/Math/MathML"
7
+ elementFormDefault="qualified"
8
+ >
9
+
10
+ <xs:annotation>
11
+ <xs:documentation>
12
+ This is the XML Schema module for the MathML "maction" element.
13
+ Author: St&#233;phane Dalmas, INRIA.
14
+ </xs:documentation>
15
+ </xs:annotation>
16
+
17
+ <xs:attributeGroup name="maction.attlist">
18
+ <xs:attribute name="actiontype" type="xs:string" use="required"/>
19
+ <xs:attribute name="selection" type="xs:positiveInteger" default="1"/>
20
+ <xs:attributeGroup ref="Common.attrib"/>
21
+ </xs:attributeGroup>
22
+
23
+ <xs:group name="maction.content">
24
+ <xs:sequence>
25
+ <xs:group ref="Presentation-expr.class"/>
26
+ </xs:sequence>
27
+ </xs:group>
28
+
29
+ <xs:complexType name="maction.type">
30
+ <xs:group ref="maction.content" minOccurs="1" maxOccurs="unbounded"/>
31
+ <xs:attributeGroup ref="maction.attlist"/>
32
+ </xs:complexType>
33
+
34
+ <xs:element name="maction" type="maction.type"/>
35
+
36
+ </xs:schema>
37
+
38
+
39
+ <!--
40
+ Copyright &#251; 2002 World Wide Web Consortium, (Massachusetts Institute
41
+ of Technology, Institut National de Recherche en Informatique et en
42
+ Automatique, Keio University). All Rights Reserved. See
43
+ http://www.w3.org/Consortium/Legal/.
44
+ -->