plurimath 0.2.0 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/rake.yml +13 -0
- data/.github/workflows/release.yml +22 -0
- data/.gitignore +1 -0
- data/.hound.yml +5 -0
- data/.rubocop.yml +8 -0
- data/AsciiMath-Supported-Data.adoc +2000 -0
- data/Gemfile +3 -0
- data/Latex-Supported-Data.adoc +1879 -0
- data/MathML-Supported-Data.adoc +287 -0
- data/README.adoc +96 -0
- data/lib/plurimath/asciimath/constants.rb +267 -229
- data/lib/plurimath/asciimath/parse.rb +125 -26
- data/lib/plurimath/asciimath/parser.rb +6 -3
- data/lib/plurimath/asciimath/transform.rb +1135 -208
- data/lib/plurimath/asciimath.rb +1 -1
- data/lib/plurimath/html/constants.rb +50 -0
- data/lib/plurimath/html/parse.rb +149 -0
- data/lib/plurimath/html/parser.rb +26 -0
- data/lib/plurimath/html/transform.rb +363 -0
- data/lib/plurimath/html.rb +1 -1
- data/lib/plurimath/latex/constants.rb +3729 -1906
- data/lib/plurimath/latex/parse.rb +167 -51
- data/lib/plurimath/latex/parser.rb +12 -4
- data/lib/plurimath/latex/transform.rb +598 -183
- data/lib/plurimath/math/base.rb +15 -0
- data/lib/plurimath/math/formula.rb +96 -11
- data/lib/plurimath/math/function/bar.rb +34 -0
- data/lib/plurimath/math/function/base.rb +32 -5
- data/lib/plurimath/math/function/binary_function.rb +104 -17
- data/lib/plurimath/math/function/cancel.rb +8 -0
- data/lib/plurimath/math/function/ceil.rb +3 -0
- data/lib/plurimath/math/function/color.rb +16 -6
- data/lib/plurimath/math/function/f.rb +8 -0
- data/lib/plurimath/math/function/fenced.rb +95 -3
- data/lib/plurimath/math/function/floor.rb +15 -0
- data/lib/plurimath/math/function/font_style/bold.rb +37 -0
- data/lib/plurimath/math/function/font_style/double_struck.rb +37 -0
- data/lib/plurimath/math/function/font_style/fraktur.rb +37 -0
- data/lib/plurimath/math/function/font_style/italic.rb +37 -0
- data/lib/plurimath/math/function/font_style/monospace.rb +37 -0
- data/lib/plurimath/math/function/font_style/normal.rb +37 -0
- data/lib/plurimath/math/function/font_style/sans-serif.rb +37 -0
- data/lib/plurimath/math/function/font_style/script.rb +37 -0
- data/lib/plurimath/math/function/font_style.rb +18 -25
- data/lib/plurimath/math/function/frac.rb +35 -5
- data/lib/plurimath/math/function/g.rb +7 -0
- data/lib/plurimath/math/function/hat.rb +12 -0
- data/lib/plurimath/math/function/inf.rb +21 -1
- data/lib/plurimath/math/function/int.rb +23 -2
- data/lib/plurimath/math/function/left.rb +25 -4
- data/lib/plurimath/math/function/lim.rb +40 -2
- data/lib/plurimath/math/function/limits.rb +8 -0
- data/lib/plurimath/math/function/log.rb +61 -4
- data/lib/plurimath/math/function/longdiv.rb +12 -0
- data/lib/plurimath/math/function/mbox.rb +31 -0
- data/lib/plurimath/math/function/menclose.rb +46 -0
- data/lib/plurimath/math/function/merror.rb +12 -0
- data/lib/plurimath/math/function/mod.rb +25 -4
- data/lib/plurimath/math/function/msgroup.rb +37 -0
- data/lib/plurimath/math/function/msline.rb +12 -0
- data/lib/plurimath/math/function/multiscript.rb +30 -0
- data/lib/plurimath/math/function/norm.rb +18 -1
- data/lib/plurimath/math/function/obrace.rb +17 -0
- data/lib/plurimath/math/function/oint.rb +2 -2
- data/lib/plurimath/math/function/over.rb +36 -0
- data/lib/plurimath/math/function/overset.rb +36 -7
- data/lib/plurimath/math/function/phantom.rb +28 -0
- data/lib/plurimath/math/function/power.rb +33 -9
- data/lib/plurimath/math/function/power_base.rb +110 -5
- data/lib/plurimath/math/function/prod.rb +29 -2
- data/lib/plurimath/math/function/right.rb +44 -0
- data/lib/plurimath/math/function/root.rb +27 -4
- data/lib/plurimath/math/function/rule.rb +33 -0
- data/lib/plurimath/math/function/scarries.rb +12 -0
- data/lib/plurimath/math/function/scarry.rb +12 -0
- data/lib/plurimath/math/function/sqrt.rb +24 -2
- data/lib/plurimath/math/function/stackrel.rb +27 -0
- data/lib/plurimath/math/function/substack.rb +7 -1
- data/lib/plurimath/math/function/sum.rb +56 -2
- data/lib/plurimath/math/function/sup.rb +3 -0
- data/lib/plurimath/math/function/table/align.rb +24 -0
- data/lib/plurimath/math/function/table/array.rb +44 -0
- data/lib/plurimath/math/function/table/bmatrix.rb +37 -0
- data/lib/plurimath/math/function/table/matrix.rb +32 -0
- data/lib/plurimath/math/function/table/multline.rb +24 -0
- data/lib/plurimath/math/function/table/pmatrix.rb +24 -0
- data/lib/plurimath/math/function/table/split.rb +24 -0
- data/lib/plurimath/math/function/table/vmatrix.rb +24 -0
- data/lib/plurimath/math/function/table.rb +190 -20
- data/lib/plurimath/math/function/td.rb +27 -9
- data/lib/plurimath/math/function/ternary_function.rb +83 -8
- data/lib/plurimath/math/function/text.rb +45 -8
- data/lib/plurimath/math/function/tr.rb +28 -4
- data/lib/plurimath/math/function/ubrace.rb +17 -0
- data/lib/plurimath/math/function/ul.rb +29 -0
- data/lib/plurimath/math/function/unary_function.rb +85 -7
- data/lib/plurimath/math/function/underline.rb +12 -0
- data/lib/plurimath/math/function/underover.rb +107 -0
- data/lib/plurimath/math/function/underset.rb +39 -0
- data/lib/plurimath/math/function/vec.rb +10 -0
- data/lib/plurimath/math/function.rb +13 -2
- data/lib/plurimath/math/number.rb +11 -3
- data/lib/plurimath/math/symbol.rb +57 -9
- data/lib/plurimath/math/unicode.rb +11 -0
- data/lib/plurimath/math.rb +15 -6
- data/lib/plurimath/mathml/constants.rb +224 -179
- data/lib/plurimath/mathml/parser.rb +24 -7
- data/lib/plurimath/mathml/transform.rb +249 -148
- data/lib/plurimath/mathml.rb +1 -1
- data/lib/plurimath/omml/parser.rb +42 -0
- data/lib/plurimath/omml/transform.rb +278 -0
- data/lib/plurimath/omml.rb +1 -1
- data/lib/plurimath/unitsml.rb +4 -0
- data/lib/plurimath/utility.rb +395 -0
- data/lib/plurimath/version.rb +1 -1
- data/plurimath.gemspec +1 -0
- metadata +66 -9
- data/.github/workflows/test.yml +0 -36
- data/README.md +0 -40
- data/lib/plurimath/mathml/parse.rb +0 -63
@@ -4,77 +4,76 @@ module Plurimath
|
|
4
4
|
class Mathml
|
5
5
|
class Constants
|
6
6
|
UNICODE_SYMBOLS = {
|
7
|
-
"&#
|
8
|
-
"&#
|
9
|
-
"&#
|
7
|
+
"α": "alpha",
|
8
|
+
"β": "beta",
|
9
|
+
"γ": "gamma",
|
10
10
|
"Γ": "Gamma",
|
11
|
-
"&#
|
11
|
+
"δ": "delta",
|
12
12
|
"Δ": "Delta",
|
13
13
|
"∆": "Delta",
|
14
|
-
"&#
|
14
|
+
"ε": "epsilon",
|
15
15
|
"ɛ": "varepsilon",
|
16
|
-
"&#
|
17
|
-
"&#
|
18
|
-
"&#
|
16
|
+
"ζ": "zeta",
|
17
|
+
"η": "eta",
|
18
|
+
"θ": "theta",
|
19
19
|
"Θ": "Theta",
|
20
|
-
"&#
|
21
|
-
"&#
|
22
|
-
"&#
|
23
|
-
"&#
|
24
|
-
"&#
|
25
|
-
"&#
|
26
|
-
"&#
|
27
|
-
"&#
|
28
|
-
"&#
|
20
|
+
"ϑ": "vartheta",
|
21
|
+
"ι": "iota",
|
22
|
+
"κ": "kappa",
|
23
|
+
"λ": "lambda",
|
24
|
+
"Λ": "Lambda",
|
25
|
+
"μ": "mu",
|
26
|
+
"ν": "nu",
|
27
|
+
"ξ": "xi",
|
28
|
+
"Ξ": "Xi",
|
29
29
|
"π": "pi",
|
30
|
-
"&#
|
31
|
-
"&#
|
32
|
-
"&#
|
33
|
-
"&#
|
34
|
-
"&#
|
35
|
-
"&#
|
36
|
-
"&#
|
37
|
-
"&#
|
38
|
-
"&#
|
39
|
-
"&#
|
40
|
-
"&#
|
41
|
-
"&#
|
42
|
-
"&#
|
43
|
-
"&#
|
44
|
-
"&#
|
45
|
-
"&#
|
30
|
+
"Π": "Pi",
|
31
|
+
"ρ": "rho",
|
32
|
+
"ς": "beta",
|
33
|
+
"σ": "sigma",
|
34
|
+
"Σ": "Sigma",
|
35
|
+
"τ": "tau",
|
36
|
+
"υ": "upsilon",
|
37
|
+
"φ": "phi",
|
38
|
+
"Φ": "Phi",
|
39
|
+
"ϕ": "varphi",
|
40
|
+
"χ": "chi",
|
41
|
+
"ψ": "psi",
|
42
|
+
"Ψ": "Psi",
|
43
|
+
"ω": "omega",
|
44
|
+
"Ω": "omega",
|
45
|
+
"⋅": "dot",
|
46
46
|
"∙": "*",
|
47
|
-
"&#
|
47
|
+
"·": ".",
|
48
48
|
"∗": "**",
|
49
|
-
"&#
|
50
|
-
"&#
|
51
|
-
"&#
|
52
|
-
"&#
|
53
|
-
"&#
|
54
|
-
"&#
|
49
|
+
"⋆": "***",
|
50
|
+
"×": "xx",
|
51
|
+
"⋉": "|><",
|
52
|
+
"⋊": "><|",
|
53
|
+
"⋈": "|><|",
|
54
|
+
"÷": "-:",
|
55
55
|
"∘": "@",
|
56
56
|
"⊕": "o+",
|
57
|
-
"&#
|
57
|
+
"⨁": "o+",
|
58
58
|
"⊗": "ox",
|
59
59
|
"⊙": " ",
|
60
60
|
"∑": "sum",
|
61
|
-
"∏": "prod",
|
62
61
|
"∏": "prod",
|
63
62
|
"∧": "^^",
|
64
|
-
"&#
|
63
|
+
"⋀": "^^^",
|
65
64
|
"∨": "vv",
|
66
65
|
"⋁": "vvv",
|
67
66
|
"∩": "nn",
|
68
|
-
"&#
|
69
|
-
"&#
|
70
|
-
"&#
|
67
|
+
"⋂": "nnn",
|
68
|
+
"∪": "cup",
|
69
|
+
"⋃": "uuu",
|
71
70
|
"≠": "!=",
|
72
71
|
"≤": "<=",
|
73
72
|
"≥": ">=",
|
74
|
-
"&#
|
75
|
-
"&#
|
76
|
-
"&#
|
77
|
-
"&#
|
73
|
+
"≺": "-<",
|
74
|
+
"≻": ">-",
|
75
|
+
"⪯": "-<=",
|
76
|
+
"⪰": " >-=",
|
78
77
|
"∈": "in",
|
79
78
|
"∉": "!in",
|
80
79
|
"⊂": "sub",
|
@@ -84,65 +83,68 @@ module Plurimath
|
|
84
83
|
"≡": "-=",
|
85
84
|
"≅": "~=",
|
86
85
|
"≈": "~~",
|
87
|
-
"&#
|
88
|
-
"&#
|
86
|
+
"∝": "prop",
|
87
|
+
"¬": "not",
|
89
88
|
"∀": "AA",
|
90
89
|
"∃": "EE",
|
91
|
-
"&#
|
92
|
-
"&#
|
93
|
-
"&#
|
94
|
-
"&#
|
90
|
+
"⊥": "_|_",
|
91
|
+
"⊤": "TT",
|
92
|
+
"⊢": "|--",
|
93
|
+
"⊨": "|==",
|
95
94
|
"〈": "(:",
|
96
|
-
"&#
|
97
|
-
"&#
|
98
|
-
"&#
|
99
|
-
"&#
|
100
|
-
"&#
|
95
|
+
"〉": ":)",
|
96
|
+
"⟨": "<<",
|
97
|
+
"⟩": ">>",
|
98
|
+
"∫": "int",
|
99
|
+
"∮": "oint",
|
101
100
|
"∂": "del",
|
102
101
|
"∇": "grad",
|
103
|
-
"&#
|
102
|
+
"±": "+-",
|
104
103
|
"∅": "O/",
|
105
|
-
"&#
|
104
|
+
"∞": "oo",
|
106
105
|
"ℵ": "aleph",
|
107
106
|
"∴": ":.",
|
108
107
|
"∵": ":'",
|
109
108
|
"∠": "/_",
|
110
|
-
"&#
|
109
|
+
"△": "/_\\",
|
111
110
|
"′": "'",
|
112
|
-
"&#
|
113
|
-
"&#
|
111
|
+
"  ": "quad",
|
112
|
+
"    ": "qquad",
|
114
113
|
"⌢": "frown",
|
115
|
-
"&#
|
116
|
-
"&#
|
117
|
-
"&#
|
118
|
-
"&#
|
119
|
-
"&#
|
120
|
-
"&#
|
121
|
-
"&#
|
114
|
+
"⋯": "cdots",
|
115
|
+
"⋮": "vdots",
|
116
|
+
"⋱": "ddots",
|
117
|
+
"⋄": "diamond",
|
118
|
+
"□": "square",
|
119
|
+
"⌊": "|__",
|
120
|
+
"⌋": "__|",
|
122
121
|
"⌈": "|~",
|
123
122
|
"⌉": "~|",
|
124
123
|
"ℂ": "CC",
|
125
124
|
"ℕ": "NN",
|
126
|
-
"&#
|
127
|
-
"&#
|
125
|
+
"ℚ": "QQ",
|
126
|
+
"ℝ": "RR",
|
128
127
|
"ℤ": "ZZ",
|
129
128
|
"↑": "uarr",
|
130
129
|
"↓": "darr",
|
131
130
|
"←": "larr",
|
132
131
|
"↔": "harr",
|
133
|
-
"&#
|
134
|
-
"&#
|
135
|
-
"&#
|
132
|
+
"⇒": "rArr",
|
133
|
+
"⇐": "lArr",
|
134
|
+
"⇔": "hArr",
|
136
135
|
"→": "->",
|
137
|
-
"&#
|
138
|
-
"&#
|
136
|
+
"↣": ">->",
|
137
|
+
"↠": "->>",
|
139
138
|
"⤖": ">->>",
|
140
|
-
"&#
|
139
|
+
"↦": "|->",
|
141
140
|
"…": "...",
|
142
141
|
"−": "-",
|
143
|
-
"&#
|
144
|
-
"&#
|
145
|
-
"&#
|
142
|
+
"⏞": "obrace",
|
143
|
+
"⏟": "ubrace",
|
144
|
+
"&": "&",
|
145
|
+
">": ">",
|
146
|
+
"<": "<",
|
147
|
+
"&": "&",
|
146
148
|
}.freeze
|
147
149
|
SYMBOLS = {
|
148
150
|
"|": "|",
|
@@ -226,102 +228,145 @@ module Plurimath
|
|
226
228
|
f
|
227
229
|
g
|
228
230
|
].freeze
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
231
|
+
OPERATORS = [
|
232
|
+
"    ",
|
233
|
+
"  ",
|
234
|
+
"*",
|
235
|
+
"<",
|
236
|
+
">",
|
237
|
+
" ",
|
238
|
+
"¬",
|
239
|
+
"±",
|
240
|
+
"×",
|
241
|
+
"÷",
|
242
|
+
"Γ",
|
243
|
+
"Δ",
|
244
|
+
"Θ",
|
245
|
+
"Λ",
|
246
|
+
"Ξ",
|
247
|
+
"Π",
|
248
|
+
"Σ",
|
249
|
+
"Ω",
|
250
|
+
"…",
|
251
|
+
"′",
|
252
|
+
"ℂ",
|
253
|
+
"ℕ",
|
254
|
+
"ℚ",
|
255
|
+
"ℝ",
|
256
|
+
"ℤ",
|
257
|
+
"ℵ",
|
258
|
+
"←",
|
259
|
+
"↑",
|
260
|
+
"→",
|
261
|
+
"→",
|
262
|
+
"↓",
|
263
|
+
"↔",
|
264
|
+
"↠",
|
265
|
+
"↣",
|
266
|
+
"↦",
|
267
|
+
"⇐",
|
268
|
+
"⇒",
|
269
|
+
"⇒",
|
270
|
+
"⇔",
|
271
|
+
"⇔",
|
272
|
+
"∀",
|
273
|
+
"∂",
|
274
|
+
"∃",
|
275
|
+
"∅",
|
276
|
+
"∇",
|
277
|
+
"∈",
|
278
|
+
"∉",
|
279
|
+
"∏",
|
280
|
+
"∑",
|
281
|
+
"−",
|
282
|
+
"∓",
|
283
|
+
"∝",
|
284
|
+
"∞",
|
285
|
+
"∠",
|
286
|
+
"∧",
|
287
|
+
"∨",
|
288
|
+
"∩",
|
289
|
+
"∪",
|
290
|
+
"∫",
|
291
|
+
"∮",
|
292
|
+
"∴",
|
293
|
+
"∵",
|
294
|
+
"∼",
|
295
|
+
"≅",
|
296
|
+
"≈",
|
297
|
+
"≔",
|
298
|
+
"≠",
|
299
|
+
"≡",
|
300
|
+
"≤",
|
301
|
+
"≥",
|
302
|
+
"≪",
|
303
|
+
"≫",
|
304
|
+
"≺",
|
305
|
+
"≻",
|
306
|
+
"⊂",
|
307
|
+
"⊃",
|
308
|
+
"⊆",
|
309
|
+
"⊇",
|
310
|
+
"⊕",
|
311
|
+
"⊗",
|
312
|
+
"⊙",
|
313
|
+
"⊢",
|
314
|
+
"⊤",
|
315
|
+
"⊥",
|
316
|
+
"⊨",
|
317
|
+
"⋀",
|
318
|
+
"⋁",
|
319
|
+
"⋂",
|
320
|
+
"⋃",
|
321
|
+
"⋄",
|
322
|
+
"⋅",
|
323
|
+
"⋆",
|
324
|
+
"⋈",
|
325
|
+
"⋉",
|
326
|
+
"⋊",
|
327
|
+
"⋮",
|
328
|
+
"⋯",
|
329
|
+
"⋱",
|
330
|
+
"⌈",
|
331
|
+
"⌉",
|
332
|
+
"⌊",
|
333
|
+
"⌋",
|
334
|
+
"⌢",
|
335
|
+
"□",
|
336
|
+
"△",
|
337
|
+
"⚬",
|
338
|
+
"⤖",
|
339
|
+
"⪯",
|
340
|
+
"⪰",
|
341
|
+
"+",
|
342
|
+
"=",
|
343
|
+
":",
|
344
|
+
"<",
|
345
|
+
"×",
|
346
|
+
"±",
|
347
|
+
"&",
|
348
|
+
";",
|
349
|
+
">",
|
350
|
+
"|",
|
351
|
+
"lim",
|
352
|
+
"max",
|
353
|
+
"min",
|
354
|
+
"\\",
|
355
|
+
"//",
|
356
|
+
"/",
|
357
|
+
"if",
|
358
|
+
"^",
|
359
|
+
"_",
|
360
|
+
"+",
|
361
|
+
"/",
|
362
|
+
"=",
|
363
|
+
":",
|
364
|
+
",",
|
365
|
+
")",
|
366
|
+
"(",
|
367
|
+
"[",
|
368
|
+
"]",
|
270
369
|
].freeze
|
271
|
-
BINARY_CLASSES = %i[
|
272
|
-
underset
|
273
|
-
stackrel
|
274
|
-
overset
|
275
|
-
color
|
276
|
-
prod
|
277
|
-
frac
|
278
|
-
root
|
279
|
-
oint
|
280
|
-
int
|
281
|
-
sum
|
282
|
-
mod
|
283
|
-
log
|
284
|
-
].freeze
|
285
|
-
FONT_CLASSES = %i[
|
286
|
-
fraktur
|
287
|
-
sans-serif
|
288
|
-
monospace
|
289
|
-
script
|
290
|
-
double-struck
|
291
|
-
bold
|
292
|
-
].freeze
|
293
|
-
FONT_TYPES = {
|
294
|
-
:bb=>"bold",
|
295
|
-
:fr=>"fraktur",
|
296
|
-
:cc=>"script",
|
297
|
-
:sf=>"sans-serif",
|
298
|
-
:tt=>"monospace",
|
299
|
-
:mbf=>"bold",
|
300
|
-
:mit=>"italic",
|
301
|
-
:mtt=>"monospace",
|
302
|
-
:Bbb=>"double-struck",
|
303
|
-
:bbb=>"double-struck",
|
304
|
-
:mscr=>"mathbb",
|
305
|
-
:mfrak=>"fraktur",
|
306
|
-
:msans=>"sans-serif",
|
307
|
-
:mbfit=>"bold italic",
|
308
|
-
:mathbf=>"bold",
|
309
|
-
:mathit=>"italic",
|
310
|
-
:mathds=>"mathbb",
|
311
|
-
:mathrm=>"mathrm",
|
312
|
-
:mathtt=>"monospace",
|
313
|
-
:mathsf=>"sans-serif",
|
314
|
-
:mathbb=>"double-struck",
|
315
|
-
:mbfsans=>"bold sans-serif",
|
316
|
-
:mathcal=>"script",
|
317
|
-
:mathbold=>"bold",
|
318
|
-
:mathfrak=>"fraktur",
|
319
|
-
:mathbfit=>"bold italic",
|
320
|
-
:mathsfbf=>"sans-serif bold",
|
321
|
-
:mathsfit=>"sans-serif italic",
|
322
|
-
:mbfitsans=>"bold italic sans-serif",
|
323
|
-
:mathsfbfit=>"sans-serif bold italic",
|
324
|
-
}.freeze
|
325
370
|
end
|
326
371
|
end
|
327
372
|
end
|
@@ -1,6 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative "parse"
|
4
3
|
require_relative "constants"
|
5
4
|
require_relative "transform"
|
6
5
|
module Plurimath
|
@@ -9,16 +8,34 @@ module Plurimath
|
|
9
8
|
attr_accessor :text
|
10
9
|
|
11
10
|
def initialize(text)
|
12
|
-
@text = text
|
11
|
+
@text = text
|
13
12
|
end
|
14
13
|
|
15
14
|
def parse
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
15
|
+
ox_nodes = Ox.load(text, strip_namespace: true).nodes
|
16
|
+
nodes = parse_nodes(ox_nodes)
|
17
|
+
Math::Formula.new(
|
18
|
+
Transform.new.apply(nodes).flatten.compact,
|
19
|
+
)
|
20
|
+
end
|
21
|
+
|
22
|
+
def parse_nodes(nodes)
|
23
|
+
nodes.map do |node|
|
24
|
+
next if node.is_a?(Ox::Comment)
|
20
25
|
|
21
|
-
|
26
|
+
if node.is_a?(String)
|
27
|
+
node
|
28
|
+
elsif !node.attributes.empty?
|
29
|
+
{
|
30
|
+
node.name.to_sym => {
|
31
|
+
attributes: node.attributes.transform_keys(&:to_sym),
|
32
|
+
value: parse_nodes(node.nodes),
|
33
|
+
},
|
34
|
+
}
|
35
|
+
else
|
36
|
+
{ node.name.to_sym => parse_nodes(node.nodes) }
|
37
|
+
end
|
38
|
+
end
|
22
39
|
end
|
23
40
|
end
|
24
41
|
end
|