Skip to content

Commit

Permalink
restrict malign except in legacy schema
Browse files Browse the repository at this point in the history
  • Loading branch information
davidcarlisle committed Aug 11, 2022
1 parent 05d1747 commit 4e897dc
Show file tree
Hide file tree
Showing 14 changed files with 368 additions and 218 deletions.
10 changes: 6 additions & 4 deletions rnc/mathml4-core.rnc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace h = "http://www.w3.org/1999/xhtml"

start |= math

math = element math {math.attributes,MathExpression*}
math = element math {math.attributes,ImpliedMrow}

MathMLoneventAttributes =
attribute onabort {text}?,
Expand Down Expand Up @@ -179,7 +179,9 @@ MathExpression = TokenExpression|
mmultiscripts|mtable|maction|
semantics

ImpliedMrow = MathExpression*
MathMalignExpression = MathExpression

ImpliedMrow = MathMalignExpression*

TableRowExpression = mtr

Expand Down Expand Up @@ -244,7 +246,7 @@ mprescripts = element mprescripts {mprescripts.attributes,empty}
mprescripts.attributes =
MathMLPGlobalAttributes

mrow = element mrow {mrow.attributes, MathExpression*}
mrow = element mrow {mrow.attributes, ImpliedMrow}
mrow.attributes =
MathMLPGlobalAttributes

Expand Down Expand Up @@ -337,7 +339,7 @@ mtd.attributes =
attribute columnspan {xsd:positiveInteger}?


maction = element maction {maction.attributes, MathExpression+}
maction = element maction {maction.attributes, ImpliedMrow}
maction.attributes =
MathMLPGlobalAttributes,
attribute actiontype {text}?,
Expand Down
30 changes: 30 additions & 0 deletions rnc/mathml4-legacy.rnc
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,33 @@ mspace.attributes &= DeprecatedTokenAtt
ms.attributes &= DeprecatedTokenAtt

semantics.attributes &= DefEncAtt


# malignmark in tokens
token.content |= malignmark
# malignmark in mfrac etc
MathExpression |= MalignExpression

maligngroup.attributes |=
attribute groupalign {"left" | "center" | "right" | "decimalpoint"}?

malignmark.attributes |=
attribute edge {"left" | "right"}?

# groupalign
group-alignment = "left" | "center" | "right" | "decimalpoint"
group-alignment-list = list {group-alignment+}
group-alignment-list-list = xsd:string {
pattern = '(\s*\{\s*(left|center|right|decimalpoint)(\s+(left|center|right|decimalpoint))*\})*\s*' }

mstyle.generalattributes &=
attribute groupalign {group-alignment-list-list}?

mtable.attributes &=
attribute groupalign {group-alignment-list-list}?

mtr.attributes &=
attribute groupalign {group-alignment-list-list}?

mtd.attributes &=
attribute groupalign {group-alignment-list}?
41 changes: 14 additions & 27 deletions rnc/mathml4-presentation.rnc
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,16 @@ MathMLPGlobalAttributes &=
attribute href {xsd:anyURI}?,
attribute other {text}?

MathMalignExpression |= MalignExpression

MathExpression |= PresentationExpression

TableRowExpression |= mlabeledtr


MstackExpression = MathExpression|mscarries|msline|msrow|msgroup
MstackExpression = MathMalignExpression|mscarries|msline|msrow|msgroup

MsrowExpression = MathExpression|none
MsrowExpression = MathMalignExpression|none


linestyle = "none" | "solid" | "dashed"
Expand Down Expand Up @@ -81,14 +83,10 @@ character = xsd:string {
pattern = '\s*\S\s*'}


group-alignment = "left" | "center" | "right" | "decimalpoint"
group-alignment-list = list {group-alignment+}
group-alignment-list-list = xsd:string {
pattern = '(\s*\{\s*(left|center|right|decimalpoint)(\s+(left|center|right|decimalpoint))*\})*\s*' }
positive-integer = xsd:positiveInteger


token.content |= mglyph|malignmark|text
token.content |= mglyph|text



Expand Down Expand Up @@ -142,23 +140,17 @@ msline.attributes =
attribute rightoverhang {length-percentage}?,
attribute mslinethickness {length-percentage | "thin" | "medium" | "thick"}?



MalignExpression = maligngroup|malignmark

malignmark = element malignmark {malignmark.attributes, empty}
malignmark.attributes =
MathMLPGlobalAttributes,
attribute edge {"left" | "right"}?
malignmark.attributes = MathMLPGlobalAttributes


maligngroup = element maligngroup {maligngroup.attributes, empty}
maligngroup.attributes =
MathMLPGlobalAttributes,
attribute groupalign {"left" | "center" | "right" | "decimalpoint"}?
maligngroup.attributes = MathMLPGlobalAttributes



PresentationExpression = TokenExpression|MalignExpression|
PresentationExpression = TokenExpression|
mrow|mfrac|msqrt|mroot|mstyle|merror|mpadded|mphantom|
mfenced|menclose|msub|msup|msubsup|munder|mover|munderover|
mmultiscripts|mtable|mstack|mlongdiv|maction
Expand All @@ -179,8 +171,8 @@ mstyle.attributes &=
mstyle.generalattributes

mstyle.specificattributes =
attribute scriptlevel {integer}?,
attribute displaystyle {"true" | "false"}?,
attribute Xscriptlevel {integer}?,
attribute Xdisplaystyle {"true" | "false"}?,
attribute scriptsizemultiplier {number}?,
attribute scriptminsize {length-percentage}?,
attribute infixlinebreakstyle {"before" | "after" | "duplicate"}?,
Expand Down Expand Up @@ -211,7 +203,6 @@ mstyle.generalattributes =
attribute form {"prefix" | "infix" | "postfix"}?,
attribute frame {linestyle}?,
attribute framespacing {list {length-percentage, length-percentage}}?,
attribute groupalign {group-alignment-list-list}?,
attribute height {length-percentage}?,
attribute indentalign {"left" | "center" | "right" | "auto" | "id"}?,
attribute indentalignfirst {"left" | "center" | "right" | "auto" | "id" | "indentalign"}?,
Expand Down Expand Up @@ -267,7 +258,7 @@ math.attributes &= mstyle.specificattributes
math.attributes &= mstyle.generalattributes
math.attributes &= attribute overflow {"linebreak" | "scroll" | "elide" | "truncate" | "scale"}?

mfenced = element mfenced {mfenced.attributes, MathExpression*}
mfenced = element mfenced {mfenced.attributes, ImpliedMrow}
mfenced.attributes =
MathMLPGlobalAttributes,
attribute open {text}?,
Expand Down Expand Up @@ -306,7 +297,6 @@ mtable.attributes &=
pattern ='\s*(top|bottom|center|baseline|axis)(\s+-?[0-9]+)?\s*'}}?,
attribute rowalign {list {verticalalign+} }?,
attribute columnalign {list {columnalignstyle+} }?,
attribute groupalign {group-alignment-list-list}?,
attribute alignmentscope {list {("true" | "false") +}}?,
attribute columnwidth {list {("auto" | length-percentage | "fit") +}}?,
attribute width {"auto" | length-percentage}?,
Expand All @@ -332,15 +322,12 @@ mlabeledtr.attributes =

mtr.attributes &=
attribute rowalign {"top" | "bottom" | "center" | "baseline" | "axis"}?,
attribute columnalign {list {columnalignstyle+} }?,
attribute groupalign {group-alignment-list-list}?

attribute columnalign {list {columnalignstyle+} }?


mtd.attributes &=
attribute rowalign {"top" | "bottom" | "center" | "baseline" | "axis"}?,
attribute columnalign {columnalignstyle}?,
attribute groupalign {group-alignment-list}?
attribute columnalign {columnalignstyle}?


mstack = element mstack {mstack.attributes, MstackExpression*}
Expand Down
43 changes: 32 additions & 11 deletions rng/mathml4-content.rng
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,31 @@
<data type="string"/>
</attribute>
</define>
<define name="CommonAtt" combine="choice">
<define name="math.attributes" combine="interleave">
<optional>
<attribute name="alttext"/>
</optional>
</define>
<define name="MathMLDataAttributes" combine="interleave">
<optional>
<attribute name="data-other"/>
</optional>
</define>
<define name="CommonAtt" combine="interleave">
<zeroOrMore>
<ref name="NonMathMLAtt"/>
</zeroOrMore>
<ref name="MathMLDataAttributes"/>
<optional>
<attribute name="class">
<data type="NCName"/>
</attribute>
</optional>
<optional>
<attribute name="style">
<data type="string"/>
</attribute>
</optional>
<optional>
<attribute name="href">
<data type="anyURI"/>
Expand Down Expand Up @@ -1244,10 +1265,10 @@
<define name="nary-stats.class">
<choice>
<ref name="mean"/>
<ref name="sdev"/>
<ref name="variance"/>
<ref name="median"/>
<ref name="mode"/>
<ref name="sdev"/>
<ref name="variance"/>
</choice>
</define>
<define name="ContExp" combine="choice">
Expand All @@ -1260,29 +1281,29 @@
<empty/>
</element>
</define>
<define name="sdev">
<element name="sdev">
<define name="median">
<element name="median">
<ref name="CommonAtt"/>
<ref name="DefEncAtt"/>
<empty/>
</element>
</define>
<define name="variance">
<element name="variance">
<define name="mode">
<element name="mode">
<ref name="CommonAtt"/>
<ref name="DefEncAtt"/>
<empty/>
</element>
</define>
<define name="median">
<element name="median">
<define name="sdev">
<element name="sdev">
<ref name="CommonAtt"/>
<ref name="DefEncAtt"/>
<empty/>
</element>
</define>
<define name="mode">
<element name="mode">
<define name="variance">
<element name="variance">
<ref name="CommonAtt"/>
<ref name="DefEncAtt"/>
<empty/>
Expand Down
Loading

0 comments on commit 4e897dc

Please sign in to comment.