Skip to content

Commit 17a1956

Browse files
authored
MathML defaults (#250)
Defaults for MathML, based chiefly on https://w3c.github.io/mathml-docs/mathml-safe-list and discussion in #103.
1 parent fbdaa30 commit 17a1956

4 files changed

+357
-4
lines changed

builtins/safe-default-configuration.json

+266
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,248 @@
506506
"namespace": null
507507
}
508508
]
509+
},
510+
{
511+
"name": "math",
512+
"namespace": "http://www.w3.org/1998/Math/MathML",
513+
"attributes": []
514+
},
515+
{
516+
"name": "merror",
517+
"namespace": "http://www.w3.org/1998/Math/MathML",
518+
"attributes": []
519+
},
520+
{
521+
"name": "mfrac",
522+
"namespace": "http://www.w3.org/1998/Math/MathML",
523+
"attributes": []
524+
},
525+
{
526+
"name": "mi",
527+
"namespace": "http://www.w3.org/1998/Math/MathML",
528+
"attributes": []
529+
},
530+
{
531+
"name": "mmultiscripts",
532+
"namespace": "http://www.w3.org/1998/Math/MathML",
533+
"attributes": []
534+
},
535+
{
536+
"name": "mn",
537+
"namespace": "http://www.w3.org/1998/Math/MathML",
538+
"attributes": []
539+
},
540+
{
541+
"name": "mo",
542+
"namespace": "http://www.w3.org/1998/Math/MathML",
543+
"attributes": [
544+
{
545+
"name": "form",
546+
"namespace": null
547+
},
548+
{
549+
"name": "fence",
550+
"namespace": null
551+
},
552+
{
553+
"name": "separator",
554+
"namespace": null
555+
},
556+
{
557+
"name": "lspace",
558+
"namespace": null
559+
},
560+
{
561+
"name": "rspace",
562+
"namespace": null
563+
},
564+
{
565+
"name": "stretchy",
566+
"namespace": null
567+
},
568+
{
569+
"name": "symmetric",
570+
"namespace": null
571+
},
572+
{
573+
"name": "maxsize",
574+
"namespace": null
575+
},
576+
{
577+
"name": "minsize",
578+
"namespace": null
579+
},
580+
{
581+
"name": "largeop",
582+
"namespace": null
583+
},
584+
{
585+
"name": "movablelimits",
586+
"namespace": null
587+
}
588+
]
589+
},
590+
{
591+
"name": "mover",
592+
"namespace": "http://www.w3.org/1998/Math/MathML",
593+
"attributes": [
594+
{
595+
"name": "accent",
596+
"namespace": null
597+
}
598+
]
599+
},
600+
{
601+
"name": "mpadded",
602+
"namespace": "http://www.w3.org/1998/Math/MathML",
603+
"attributes": [
604+
{
605+
"name": "width",
606+
"namespace": null
607+
},
608+
{
609+
"name": "height",
610+
"namespace": null
611+
},
612+
{
613+
"name": "depth",
614+
"namespace": null
615+
},
616+
{
617+
"name": "lspace",
618+
"namespace": null
619+
},
620+
{
621+
"name": "voffset",
622+
"namespace": null
623+
}
624+
]
625+
},
626+
{
627+
"name": "mphantom",
628+
"namespace": "http://www.w3.org/1998/Math/MathML",
629+
"attributes": []
630+
},
631+
{
632+
"name": "mprescripts",
633+
"namespace": "http://www.w3.org/1998/Math/MathML",
634+
"attributes": []
635+
},
636+
{
637+
"name": "mroot",
638+
"namespace": "http://www.w3.org/1998/Math/MathML",
639+
"attributes": []
640+
},
641+
{
642+
"name": "mrow",
643+
"namespace": "http://www.w3.org/1998/Math/MathML",
644+
"attributes": []
645+
},
646+
{
647+
"name": "ms",
648+
"namespace": "http://www.w3.org/1998/Math/MathML",
649+
"attributes": []
650+
},
651+
{
652+
"name": "mspace",
653+
"namespace": "http://www.w3.org/1998/Math/MathML",
654+
"attributes": [
655+
{
656+
"name": "width",
657+
"namespace": null
658+
},
659+
{
660+
"name": "height",
661+
"namespace": null
662+
},
663+
{
664+
"name": "depth",
665+
"namespace": null
666+
}
667+
]
668+
},
669+
{
670+
"name": "msqrt",
671+
"namespace": "http://www.w3.org/1998/Math/MathML",
672+
"attributes": []
673+
},
674+
{
675+
"name": "mstyle",
676+
"namespace": "http://www.w3.org/1998/Math/MathML",
677+
"attributes": []
678+
},
679+
{
680+
"name": "msub",
681+
"namespace": "http://www.w3.org/1998/Math/MathML",
682+
"attributes": []
683+
},
684+
{
685+
"name": "msubsup",
686+
"namespace": "http://www.w3.org/1998/Math/MathML",
687+
"attributes": []
688+
},
689+
{
690+
"name": "msup",
691+
"namespace": "http://www.w3.org/1998/Math/MathML",
692+
"attributes": []
693+
},
694+
{
695+
"name": "mtable",
696+
"namespace": "http://www.w3.org/1998/Math/MathML",
697+
"attributes": []
698+
},
699+
{
700+
"name": "mtd",
701+
"namespace": "http://www.w3.org/1998/Math/MathML",
702+
"attributes": [
703+
{
704+
"name": "columnspan",
705+
"namespace": null
706+
},
707+
{
708+
"name": "rowspan",
709+
"namespace": null
710+
}
711+
]
712+
},
713+
{
714+
"name": "mtext",
715+
"namespace": "http://www.w3.org/1998/Math/MathML",
716+
"attributes": []
717+
},
718+
{
719+
"name": "mtr",
720+
"namespace": "http://www.w3.org/1998/Math/MathML",
721+
"attributes": []
722+
},
723+
{
724+
"name": "munder",
725+
"namespace": "http://www.w3.org/1998/Math/MathML",
726+
"attributes": [
727+
{
728+
"name": "accentunder",
729+
"namespace": null
730+
}
731+
]
732+
},
733+
{
734+
"name": "munderover",
735+
"namespace": "http://www.w3.org/1998/Math/MathML",
736+
"attributes": [
737+
{
738+
"name": "accent",
739+
"namespace": null
740+
},
741+
{
742+
"name": "accentunder",
743+
"namespace": null
744+
}
745+
]
746+
},
747+
{
748+
"name": "semantics",
749+
"namespace": "http://www.w3.org/1998/Math/MathML",
750+
"attributes": []
509751
}
510752
],
511753
"attributes": [
@@ -520,6 +762,30 @@
520762
{
521763
"name": "title",
522764
"namespace": null
765+
},
766+
{
767+
"name": "dir",
768+
"namespace": null
769+
},
770+
{
771+
"name": "displaystyle",
772+
"namespace": null
773+
},
774+
{
775+
"name": "mathbackground",
776+
"namespace": null
777+
},
778+
{
779+
"name": "mathcolor",
780+
"namespace": null
781+
},
782+
{
783+
"name": "mathsize",
784+
"namespace": null
785+
},
786+
{
787+
"name": "scriptlevel",
788+
"namespace": null
523789
}
524790
]
525791
}

builtins/safe-default-configuration.py

+9-3
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,17 @@ def main():
2424
pass
2525
elif line.startswith("- "):
2626
current.append({ "name": line[2:], "namespace": None })
27-
elif line == "[HTML Global]":
27+
elif line.startswith("[") and line.endswith("Global]"):
2828
current = result["attributes"]
2929
else:
30-
elem = { "name": line, "namespace": "http://www.w3.org/1999/xhtml",
31-
"attributes": [] }
30+
if line.startswith("math "):
31+
elem = {"name": line[5:],
32+
"namespace": "http://www.w3.org/1998/Math/MathML"}
33+
elif line.startswith("svg "):
34+
elem = {"name": line[4:], "namespace": "http://www.w3.org/2000/svg"}
35+
else:
36+
elem = {"name": line, "namespace": "http://www.w3.org/1999/xhtml"}
37+
elem["attributes"] = []
3238
result["elements"].append(elem)
3339
current = elem["attributes"]
3440

builtins/safe-default-configuration.txt

+75-1
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,6 @@ th
158158
// Purposely omitted.
159159

160160
// SVG: TBD
161-
// MathML: TDB
162161

163162
// HTML global attributes
164163
//
@@ -169,3 +168,78 @@ th
169168
- lang
170169
- title
171170

171+
// MathML
172+
// https://w3c.github.io/mathml-core/#mathml-elements-and-attributes
173+
//
174+
// See also: https://w3c.github.io/mathml-docs/mathml-safe-list
175+
176+
math math
177+
math merror
178+
math mfrac
179+
math mi
180+
math mmultiscripts
181+
math mn
182+
math mo
183+
- form
184+
- fence
185+
- separator
186+
- lspace
187+
- rspace
188+
- stretchy
189+
- symmetric
190+
- maxsize
191+
- minsize
192+
- largeop
193+
- movablelimits
194+
math mover
195+
- accent
196+
math mpadded
197+
- width
198+
- height
199+
- depth
200+
- lspace
201+
- voffset
202+
math mphantom
203+
math mprescripts
204+
math mroot
205+
math mrow
206+
math ms
207+
math mspace
208+
- width
209+
- height
210+
- depth
211+
math msqrt
212+
math mstyle
213+
math msub
214+
math msubsup
215+
math msup
216+
math mtable
217+
math mtd
218+
- columnspan
219+
- rowspan
220+
math mtext
221+
math mtr
222+
math munder
223+
- accentunder
224+
math munderover
225+
- accent
226+
- accentunder
227+
math semantics
228+
229+
// Purposely omitted:
230+
// - math annotation
231+
// - math annotation-xml
232+
// - math maction
233+
234+
// MathML global attributes
235+
// https://w3c.github.io/mathml-core/#global-attributes
236+
//
237+
// Most are purposely omitted.
238+
[MathML Global]
239+
- dir
240+
- displaystyle
241+
- mathbackground
242+
- mathcolor
243+
- mathsize
244+
- scriptlevel
245+

0 commit comments

Comments
 (0)