Skip to content

Commit

Permalink
fix: check MathML and XHTML content in epub:switch
Browse files Browse the repository at this point in the history
FWIW :P

Fixes #835
  • Loading branch information
rdeltour committed Jan 12, 2019
1 parent 9058524 commit 39556e8
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@

namespace epub = "http://www.idpf.org/2007/ops"
namespace m = "http://www.w3.org/1998/Math/MathML"
namespace h = "http://www.w3.org/1999/xhtml"

common.elem.flow |= epub.switch.flow
common.elem.phrasing |= epub.switch.phrasing
Expand All @@ -14,7 +16,7 @@

epub.case.flow.content = epub.switch.any
epub.case.phrasing.content = epub.switch.any
epub.switch.any = (epub.switch.anyElement | text)*
epub.switch.any = (common.elem.flow | epub.switch.anyElement | text)*

epub.default.flow.content = common.inner.flow
epub.default.phrasing.content = common.inner.phrasing
Expand All @@ -25,8 +27,10 @@

epub.case.rn.attr = attribute required-namespace { datatype.URI }

epub.switch.anyElement = element * {
epub.switch.anyElement = element * - (m:* | h:*) {
(attribute * { text }
| text
| epub.switch.anyElement)*
| epub.switch.anyElement
| common.elem.flow
)*
}
8 changes: 8 additions & 0 deletions src/test/java/com/adobe/epubcheck/ops/OPSCheckerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,14 @@ public void testValidateXHTMLSwitch001()
testValidateDocument("xhtml/valid/switch-001.xhtml", "application/xhtml+xml",
EPUBVersion.VERSION_3);
}

@Test
public void testValidateXHTMLSwitchMathCase()
{
Collections.addAll(expectedErrors, MessageId.RSC_005);
testValidateDocument("xhtml/invalid/switch-invalid-mathml.xhtml", "application/xhtml+xml",
EPUBVersion.VERSION_3);
}

@Test
public void testValidateXHTMLTables001()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" lang="en">
<head>
<title>MathML invalid 001</title>
<meta charset="UTF-8" />
</head>
<body>
<h1>nested math tags should be invalid even inside epub switch</h1>
<epub:switch>
<epub:case required-namespace="http://www.w3.org/1998/Math/MathML">
<math alttext="placeholder" display="block" overflow="scroll"
xmlns="http://www.w3.org/1998/Math/MathML">
<math alttext="a">
<mn>11</mn>
<mo>,</mo>
<mo></mo>
<mn>3</mn>
<mo>,</mo>
<mn>5</mn>
</math>
</math>
</epub:case>
<epub:default>
<img src="../Images/Image0001.svg" alt="" /></epub:default>
</epub:switch>
</body>
</html>

0 comments on commit 39556e8

Please sign in to comment.