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,41 @@
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
+ xmlns:xlink="http://www.w3.org/1999/xlink"
7
+ targetNamespace="http://www.w3.org/1998/Math/MathML"
8
+ elementFormDefault="qualified"
9
+ >
10
+
11
+ <xs:annotation>
12
+ <xs:documentation>
13
+ This is the common attributes module for MathML.
14
+ Author: St&#233;phane Dalmas, INRIA.
15
+ </xs:documentation>
16
+ </xs:annotation>
17
+
18
+
19
+ <xs:import namespace="http://www.w3.org/1999/xlink" schemaLocation="xlink-href.xsd"/>
20
+ <xs:import/> <!-- import any foreign namespace -->
21
+
22
+
23
+ <!-- The type of "class" is from the XHTML modularization with Schema
24
+ document -->
25
+ <xs:attributeGroup name="Common.attrib">
26
+ <xs:attribute name="class" type="xs:NMTOKENS"/>
27
+ <xs:attribute name="style" type="xs:string"/>
28
+ <xs:attribute name="xref" type="xs:IDREF"/>
29
+ <xs:attribute name="id" type="xs:ID"/>
30
+ <xs:attribute ref="xlink:href"/>
31
+ <!-- allow attributes from foreign namespaces, and don't check them -->
32
+ <xs:anyAttribute namespace="##other" processContents="skip"/>
33
+ </xs:attributeGroup>
34
+
35
+ </xs:schema>
36
+ <!--
37
+ Copyright &#251; 2002 World Wide Web Consortium, (Massachusetts Institute
38
+ of Technology, Institut National de Recherche en Informatique et en
39
+ Automatique, Keio University). All Rights Reserved. See
40
+ http://www.w3.org/Consortium/Legal/.
41
+ -->
@@ -0,0 +1,126 @@
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 defining the "math" element of MathML.
13
+ Author: St&#233;phane Dalmas, INRIA.
14
+ </xs:documentation>
15
+ </xs:annotation>
16
+
17
+ <!-- The four groups that govern a lot of things -->
18
+
19
+ <!-- currently very lax. Should be tightened from Chapter 5 -->
20
+
21
+ <xs:group name="Presentation-expr.class">
22
+ <xs:choice>
23
+ <xs:group ref="PresExpr.class"/>
24
+ <xs:group ref="ContExpr.class"/>
25
+ </xs:choice>
26
+ </xs:group>
27
+
28
+ <xs:group name="Content-expr.class">
29
+ <xs:choice>
30
+ <xs:group ref="ContExpr.class"/>
31
+ <xs:group ref="PresExpr.class"/>
32
+ </xs:choice>
33
+ </xs:group>
34
+
35
+ <xs:group name="PresExpr.class">
36
+ <xs:choice>
37
+ <xs:group ref="Presentation-token.class"/>
38
+ <xs:group ref="Presentation-layout.class"/>
39
+ <xs:group ref="Presentation-script.class"/>
40
+ <xs:group ref="Presentation-table.class"/>
41
+ <xs:element ref="mspace"/>
42
+ <xs:element ref="maction"/>
43
+ <xs:element ref="merror"/>
44
+ <xs:element ref="mstyle"/>
45
+ </xs:choice>
46
+ </xs:group>
47
+
48
+ <xs:group name="ContExpr.class">
49
+ <xs:choice>
50
+ <xs:group ref="Content-tokens.class"/>
51
+ <xs:group ref="Content-arith.class"/>
52
+ <xs:group ref="Content-functions.class"/>
53
+ <xs:group ref="Content-logic.class"/>
54
+ <xs:group ref="Content-constants.class"/>
55
+ <xs:group ref="Content-sets.class"/>
56
+ <xs:group ref="Content-relations.class"/>
57
+ <xs:group ref="Content-elementary-functions.class"/>
58
+ <xs:group ref="Content-calculus.class"/>
59
+ <xs:group ref="Content-linear-algebra.class"/>
60
+ <xs:group ref="Content-vector-calculus.class"/>
61
+ <xs:group ref="Content-statistics.class"/>
62
+ <xs:group ref="Content-constructs.class"/>
63
+ <xs:element ref="semantics"/>
64
+ </xs:choice>
65
+ </xs:group>
66
+
67
+ <!-- "math" -->
68
+
69
+ <xs:attributeGroup name="Browser-interface.attrib">
70
+ <xs:attribute name="baseline" type="xs:string"/>
71
+ <xs:attribute name="overflow" default="scroll">
72
+ <xs:simpleType>
73
+ <xs:restriction base="xs:string">
74
+ <xs:enumeration value="scroll"/>
75
+ <xs:enumeration value="elide"/>
76
+ <xs:enumeration value="truncate"/>
77
+ <xs:enumeration value="scale"/>
78
+ </xs:restriction>
79
+ </xs:simpleType>
80
+ </xs:attribute>
81
+ <xs:attribute name="altimg" type="xs:anyURI"/>
82
+ <xs:attribute name="alttext" type="xs:string"/>
83
+ <xs:attribute name="type" type="xs:string"/>
84
+ <xs:attribute name="name" type="xs:string"/>
85
+ <xs:attribute name="height" type="xs:string"/>
86
+ <xs:attribute name="width" type="xs:string"/>
87
+ </xs:attributeGroup>
88
+
89
+ <xs:attributeGroup name="math.attlist">
90
+ <xs:attributeGroup ref="Browser-interface.attrib"/>
91
+ <xs:attribute name="macros" type="xs:string"/>
92
+ <!-- deprecated
93
+ <xs:attribute name="mode" type="xs:string"/>
94
+ -->
95
+ <xs:attribute name="display" default="inline">
96
+ <xs:simpleType>
97
+ <xs:restriction base="xs:string">
98
+ <xs:enumeration value="block"/>
99
+ <xs:enumeration value="inline"/>
100
+ </xs:restriction>
101
+ </xs:simpleType>
102
+ </xs:attribute>
103
+ <xs:attributeGroup ref="Common.attrib"/>
104
+ </xs:attributeGroup>
105
+
106
+ <xs:group name="math.content">
107
+ <xs:choice>
108
+ <xs:group ref="PresExpr.class"/>
109
+ <xs:group ref="ContExpr.class"/>
110
+ </xs:choice>
111
+ </xs:group>
112
+
113
+ <xs:complexType name="math.type">
114
+ <xs:group ref="math.content" minOccurs="0" maxOccurs="unbounded"/>
115
+ <xs:attributeGroup ref="math.attlist"/>
116
+ </xs:complexType>
117
+
118
+ <xs:element name="math" type="math.type"/>
119
+
120
+ </xs:schema>
121
+ <!--
122
+ Copyright &#251; 2002 World Wide Web Consortium, (Massachusetts Institute
123
+ of Technology, Institut National de Recherche en Informatique et en
124
+ Automatique, Keio University). All Rights Reserved. See
125
+ http://www.w3.org/Consortium/Legal/.
126
+ -->
@@ -0,0 +1,20 @@
1
+ <schema targetNamespace="http://www.w3.org/1999/xlink"
2
+ xmlns:xlink="http://www.w3.org/1999/xlink"
3
+ xmlns="http://www.w3.org/2001/XMLSchema">
4
+ <annotation>
5
+ <documentation xml:lang="en">
6
+ This schema provides the XLink href attribute for use in the MathML2
7
+ schema. Written by Max Froumentin, W3C.
8
+ </documentation>
9
+ </annotation>
10
+
11
+ <attribute name="href" type="anyURI"/>
12
+ </schema>
13
+
14
+
15
+ <!--
16
+ Copyright &#251; 2002 World Wide Web Consortium, (Massachusetts Institute
17
+ of Technology, Institut National de Recherche en Informatique et en
18
+ Automatique, Keio University). All Rights Reserved. See
19
+ http://www.w3.org/Consortium/Legal/.
20
+ -->
@@ -0,0 +1,90 @@
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 "arithmetic" operators of content
13
+ MathML.
14
+ Author: St&#233;phane Dalmas, INRIA.
15
+ </xs:documentation>
16
+ </xs:annotation>
17
+
18
+ <!-- a common type for all this -->
19
+
20
+ <xs:complexType name="Arith.type">
21
+ <xs:attributeGroup ref="Definition.attrib"/>
22
+ <xs:attributeGroup ref="Common.attrib"/>
23
+ </xs:complexType>
24
+
25
+ <!-- The elements -->
26
+
27
+ <xs:element name="abs" type="Arith.type"/>
28
+ <xs:element name="conjugate" type="Arith.type"/>
29
+ <xs:element name="arg" type="Arith.type"/>
30
+ <xs:element name="real" type="Arith.type"/>
31
+ <xs:element name="imaginary" type="Arith.type"/>
32
+
33
+ <xs:element name="floor" type="Arith.type"/>
34
+ <xs:element name="ceiling" type="Arith.type"/>
35
+
36
+ <xs:element name="power" type="Arith.type"/>
37
+ <xs:element name="root" type="Arith.type"/>
38
+
39
+ <xs:element name="minus" type="Arith.type"/>
40
+ <xs:element name="plus" type="Arith.type"/>
41
+ <xs:element name="sum" type="Arith.type"/>
42
+ <xs:element name="times" type="Arith.type"/>
43
+ <xs:element name="product" type="Arith.type"/>
44
+
45
+ <xs:element name="max" type="Arith.type"/>
46
+ <xs:element name="min" type="Arith.type"/>
47
+
48
+ <xs:element name="factorial" type="Arith.type"/>
49
+ <xs:element name="quotient" type="Arith.type"/>
50
+ <xs:element name="divide" type="Arith.type"/>
51
+ <xs:element name="rem" type="Arith.type"/>
52
+ <xs:element name="gcd" type="Arith.type"/>
53
+ <xs:element name="lcm" type="Arith.type"/>
54
+
55
+ <!-- And the group of everything -->
56
+
57
+ <xs:group name="Content-arith.class">
58
+ <xs:choice>
59
+ <xs:element ref="abs"/>
60
+ <xs:element ref="conjugate"/>
61
+ <xs:element ref="factorial"/>
62
+ <xs:element ref="arg"/>
63
+ <xs:element ref="real"/>
64
+ <xs:element ref="imaginary"/>
65
+ <xs:element ref="floor"/>
66
+ <xs:element ref="ceiling"/>
67
+ <xs:element ref="quotient"/>
68
+ <xs:element ref="divide"/>
69
+ <xs:element ref="rem"/>
70
+ <xs:element ref="minus"/>
71
+ <xs:element ref="plus"/>
72
+ <xs:element ref="times"/>
73
+ <xs:element ref="power"/>
74
+ <xs:element ref="root"/>
75
+ <xs:element ref="max"/>
76
+ <xs:element ref="min"/>
77
+ <xs:element ref="gcd"/>
78
+ <xs:element ref="lcm"/>
79
+ <xs:element ref="sum"/>
80
+ <xs:element ref="product"/>
81
+ </xs:choice>
82
+ </xs:group>
83
+
84
+ </xs:schema>
85
+ <!--
86
+ Copyright &#251; 2002 World Wide Web Consortium, (Massachusetts Institute
87
+ of Technology, Institut National de Recherche en Informatique et en
88
+ Automatique, Keio University). All Rights Reserved. See
89
+ http://www.w3.org/Consortium/Legal/.
90
+ -->
@@ -0,0 +1,146 @@
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 calculs operators of content
13
+ MathML.
14
+ Author: St&#233;phane Dalmas, INRIA.
15
+ </xs:documentation>
16
+ </xs:annotation>
17
+
18
+ <!-- "int" -->
19
+
20
+ <xs:attributeGroup name="int.attlist">
21
+ <xs:attributeGroup ref="Definition.attrib"/>
22
+ <xs:attributeGroup ref="Common.attrib"/>
23
+ </xs:attributeGroup>
24
+
25
+ <xs:complexType name="int.type">
26
+ <xs:attributeGroup ref="int.attlist"/>
27
+ </xs:complexType>
28
+
29
+ <xs:element name="int" type="int.type"/>
30
+
31
+ <!-- "diff" -->
32
+
33
+ <xs:attributeGroup name="diff.attlist">
34
+ <xs:attributeGroup ref="Definition.attrib"/>
35
+ <xs:attributeGroup ref="Common.attrib"/>
36
+ </xs:attributeGroup>
37
+
38
+ <xs:complexType name="diff.type">
39
+ <xs:attributeGroup ref="diff.attlist"/>
40
+ </xs:complexType>
41
+
42
+ <xs:element name="diff" type="diff.type"/>
43
+
44
+ <!-- "partialdiff" -->
45
+
46
+ <xs:attributeGroup name="partialdiff.attlist">
47
+ <xs:attributeGroup ref="Definition.attrib"/>
48
+ <xs:attributeGroup ref="Common.attrib"/>
49
+ </xs:attributeGroup>
50
+
51
+ <xs:complexType name="partialdiff.type">
52
+ <xs:attributeGroup ref="partialdiff.attlist"/>
53
+ </xs:complexType>
54
+
55
+ <xs:element name="partialdiff" type="partialdiff.type"/>
56
+
57
+ <!-- "limit" -->
58
+
59
+ <xs:attributeGroup name="limit.attlist">
60
+ <xs:attributeGroup ref="Definition.attrib"/>
61
+ <xs:attributeGroup ref="Common.attrib"/>
62
+ </xs:attributeGroup>
63
+
64
+
65
+ <xs:complexType name="limit.type">
66
+ <xs:attributeGroup ref="limit.attlist"/>
67
+ </xs:complexType>
68
+
69
+ <xs:element name="limit" type="limit.type"/>
70
+
71
+ <!-- "lowlimit" -->
72
+
73
+ <xs:attributeGroup name="lowlimit.attlist">
74
+ <xs:attributeGroup ref="Definition.attrib"/>
75
+ <xs:attributeGroup ref="Common.attrib"/>
76
+ </xs:attributeGroup>
77
+
78
+ <xs:group name="lowlimit.content">
79
+ <xs:sequence>
80
+ <xs:group ref="Content-expr.class"/>
81
+ </xs:sequence>
82
+ </xs:group>
83
+
84
+ <xs:complexType name="lowlimit.type">
85
+ <xs:group ref="lowlimit.content" minOccurs="1" maxOccurs="unbounded"/>
86
+ <xs:attributeGroup ref="lowlimit.attlist"/>
87
+ </xs:complexType>
88
+
89
+ <xs:element name="lowlimit" type="lowlimit.type"/>
90
+
91
+ <!-- "uplimit" -->
92
+
93
+ <xs:attributeGroup name="uplimit.attlist">
94
+ <xs:attributeGroup ref="Definition.attrib"/>
95
+ <xs:attributeGroup ref="Common.attrib"/>
96
+ </xs:attributeGroup>
97
+
98
+ <xs:group name="uplimit.content">
99
+ <xs:sequence>
100
+ <xs:group ref="Content-expr.class"/>
101
+ </xs:sequence>
102
+ </xs:group>
103
+
104
+ <xs:complexType name="uplimit.type">
105
+ <xs:group ref="uplimit.content" minOccurs="1" maxOccurs="unbounded"/>
106
+ <xs:attributeGroup ref="uplimit.attlist"/>
107
+ </xs:complexType>
108
+
109
+ <xs:element name="uplimit" type="uplimit.type"/>
110
+
111
+ <!-- "tendsto" -->
112
+
113
+ <xs:attributeGroup name="tendsto.attlist">
114
+ <xs:attribute name="type" type="xs:string"/>
115
+ <xs:attributeGroup ref="Definition.attrib"/>
116
+ <xs:attributeGroup ref="Common.attrib"/>
117
+ </xs:attributeGroup>
118
+
119
+
120
+ <xs:complexType name="tendsto.type">
121
+ <xs:attributeGroup ref="tendsto.attlist"/>
122
+ </xs:complexType>
123
+
124
+ <xs:element name="tendsto" type="tendsto.type"/>
125
+
126
+ <!-- And the group of everything -->
127
+
128
+ <xs:group name="Content-calculus.class">
129
+ <xs:choice>
130
+ <xs:element ref="int"/>
131
+ <xs:element ref="diff"/>
132
+ <xs:element ref="partialdiff"/>
133
+ <xs:element ref="limit"/>
134
+ <xs:element ref="lowlimit"/>
135
+ <xs:element ref="uplimit"/>
136
+ <xs:element ref="tendsto"/>
137
+ </xs:choice>
138
+ </xs:group>
139
+
140
+ </xs:schema>
141
+ <!--
142
+ Copyright &#251; 2002 World Wide Web Consortium, (Massachusetts Institute
143
+ of Technology, Institut National de Recherche en Informatique et en
144
+ Automatique, Keio University). All Rights Reserved. See
145
+ http://www.w3.org/Consortium/Legal/.
146
+ -->
@@ -0,0 +1,30 @@
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 defining common attributes for the
13
+ content part of MathML.
14
+ Authors: St&#233;phane Dalmas, INRIA.
15
+ </xs:documentation>
16
+ </xs:annotation>
17
+
18
+ <xs:attributeGroup name="Definition.attrib">
19
+ <xs:attribute name="encoding" type="xs:string"/>
20
+ <xs:attribute name="definitionURL" type="xs:anyURI"/>
21
+ </xs:attributeGroup>
22
+
23
+ </xs:schema>
24
+
25
+ <!--
26
+ Copyright &#251; 2002 World Wide Web Consortium, (Massachusetts Institute
27
+ of Technology, Institut National de Recherche en Informatique et en
28
+ Automatique, Keio University). All Rights Reserved. See
29
+ http://www.w3.org/Consortium/Legal/.
30
+ -->