This is an automated email from the ASF dual-hosted git repository. michaelo pushed a commit to branch default-xhtml5 in repository https://gitbox.apache.org/repos/asf/maven-doxia.git
commit 05a9cfe1b5a383598c22814fa8a69257a3b164c3 Author: Michael Osipov <[email protected]> AuthorDate: Sat May 28 21:49:31 2022 +0200 More fixes --- .../maven/doxia/sink/impl/Xhtml5BaseSink.java | 2 +- .../maven/doxia/parser/Xhtml5BaseParserTest.java | 20 +++--- .../doxia/module/markdown/MarkdownParserTest.java | 9 ++- .../maven/doxia/module/xdoc/XdocSinkTest.java | 72 ++++++++++++++++------ .../xhtml5/Xhtml5SinkWithLanguageIdTest.java | 2 +- .../src/test/resources/test.xhtml | 2 +- doxia-modules/pom.xml | 1 - 7 files changed, 70 insertions(+), 38 deletions(-) diff --git a/doxia-core/src/main/java/org/apache/maven/doxia/sink/impl/Xhtml5BaseSink.java b/doxia-core/src/main/java/org/apache/maven/doxia/sink/impl/Xhtml5BaseSink.java index 91b40bb9..891471ad 100644 --- a/doxia-core/src/main/java/org/apache/maven/doxia/sink/impl/Xhtml5BaseSink.java +++ b/doxia-core/src/main/java/org/apache/maven/doxia/sink/impl/Xhtml5BaseSink.java @@ -531,7 +531,7 @@ public class Xhtml5BaseSink { MutableAttributeSet att = new SinkEventAttributeSet(); att.addAttributes( SinkUtils.filterAttributes( - attributes, SinkUtils.SINK_BASE_ATTRIBUTES ) ); + attributes, SinkUtils.SINK_BASE_ATTRIBUTES ) ); writeStartTag( HtmlMarkup.SECTION, att ); } diff --git a/doxia-core/src/test/java/org/apache/maven/doxia/parser/Xhtml5BaseParserTest.java b/doxia-core/src/test/java/org/apache/maven/doxia/parser/Xhtml5BaseParserTest.java index e6669aeb..a5166bb4 100644 --- a/doxia-core/src/test/java/org/apache/maven/doxia/parser/Xhtml5BaseParserTest.java +++ b/doxia-core/src/test/java/org/apache/maven/doxia/parser/Xhtml5BaseParserTest.java @@ -30,7 +30,7 @@ import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.*; /** - * Test for XhtmlBaseParser. + * Test for Xhtml5BaseParser. */ public class Xhtml5BaseParserTest extends AbstractParserTest @@ -63,8 +63,8 @@ public class Xhtml5BaseParserTest @Test public void testDoxiaVersion() { - assertNotNull( XhtmlBaseParser.doxiaVersion() ); - assertNotEquals( "unknown", XhtmlBaseParser.doxiaVersion() ); + assertNotNull( Xhtml5BaseParser.doxiaVersion() ); + assertNotEquals( "unknown", Xhtml5BaseParser.doxiaVersion() ); } @Test @@ -307,7 +307,7 @@ public class Xhtml5BaseParserTest throws Exception { // test EOLs within <pre>: the sink MUST receive a text event for the EOL - String text = "<pre><a href=\"what.html\">what</a>" + XhtmlBaseParser.EOL + String text = "<pre><a href=\"what.html\">what</a>" + Xhtml5BaseParser.EOL + "<a href=\"what.html\">what</a></pre>"; parser.parse( text, sink ); @@ -330,12 +330,12 @@ public class Xhtml5BaseParserTest throws Exception { StringBuilder sb = new StringBuilder(); - sb.append( "<!DOCTYPE test [" ).append( XhtmlBaseParser.EOL ); - sb.append( "<!ENTITY foo \"ř\">" ).append( XhtmlBaseParser.EOL ); - sb.append( "<!ENTITY foo1 \" \">" ).append( XhtmlBaseParser.EOL ); - sb.append( "<!ENTITY foo2 \"š\">" ).append( XhtmlBaseParser.EOL ); - sb.append( "<!ENTITY tritPos \"𝟭\">" ).append( XhtmlBaseParser.EOL ); - sb.append( "]>" ).append( XhtmlBaseParser.EOL ); + sb.append( "<!DOCTYPE test [" ).append( Xhtml5BaseParser.EOL ); + sb.append( "<!ENTITY foo \"ř\">" ).append( Xhtml5BaseParser.EOL ); + sb.append( "<!ENTITY foo1 \" \">" ).append( Xhtml5BaseParser.EOL ); + sb.append( "<!ENTITY foo2 \"š\">" ).append( Xhtml5BaseParser.EOL ); + sb.append( "<!ENTITY tritPos \"𝟭\">" ).append( Xhtml5BaseParser.EOL ); + sb.append( "]>" ).append( Xhtml5BaseParser.EOL ); sb.append( "<p>&foo;&foo1;&foo2;&tritPos;</p>" ); parser.setValidate( false ); diff --git a/doxia-modules/doxia-module-markdown/src/test/java/org/apache/maven/doxia/module/markdown/MarkdownParserTest.java b/doxia-modules/doxia-module-markdown/src/test/java/org/apache/maven/doxia/module/markdown/MarkdownParserTest.java index 7c5329bf..8519fe38 100644 --- a/doxia-modules/doxia-module-markdown/src/test/java/org/apache/maven/doxia/module/markdown/MarkdownParserTest.java +++ b/doxia-modules/doxia-module-markdown/src/test/java/org/apache/maven/doxia/module/markdown/MarkdownParserTest.java @@ -110,7 +110,7 @@ public class MarkdownParserTest SinkEventElement inline = eventList.get( 4 ); assertEquals( "inline", inline.getName() ); SinkEventAttributeSet atts = (SinkEventAttributeSet) inline.getArgs()[0]; - assertTrue( atts.containsAttribute( SinkEventAttributes.SEMANTICS, "bold" ) ); + assertTrue( atts.containsAttribute( SinkEventAttributes.SEMANTICS, "strong" ) ); } /** @@ -132,7 +132,7 @@ public class MarkdownParserTest SinkEventElement inline = eventList.get( 4 ); assertEquals( "inline", inline.getName() ); SinkEventAttributeSet atts = (SinkEventAttributeSet) inline.getArgs()[0]; - assertTrue( atts.containsAttribute( SinkEventAttributes.SEMANTICS, "italic" ) ); + assertTrue( atts.containsAttribute( SinkEventAttributes.SEMANTICS, "emphasis" ) ); } /** @@ -389,9 +389,8 @@ public class MarkdownParserTest { Iterator<SinkEventElement> it = parseFileToEventTestingSink( "html-content" ).getEventList().iterator(); - // NOTE: DIV is rendered as "unknown" (see DOXIA-203) - assertSinkEquals( it, "head", "head_", "body", "unknown", "text", "paragraph", "inline", "text", - "inline_", "text", "inline", "text", "inline_", "text", "paragraph_", "text", "unknown", "text", + assertSinkEquals( it, "head", "head_", "body", "division", "text", "paragraph", "inline", "text", + "inline_", "text", "inline", "text", "inline_", "text", "paragraph_", "text", "division_", "text", "horizontalRule", "section1", "sectionTitle1", "text", "sectionTitle1_", "paragraph", "text", "paragraph_", "text", "table", "tableRows", "text", "tableRow", "tableHeaderCell", "text", "tableHeaderCell_", "tableRow_", "text", "tableRow", "tableCell", "text", "tableCell_", "tableRow_", diff --git a/doxia-modules/doxia-module-xdoc/src/test/java/org/apache/maven/doxia/module/xdoc/XdocSinkTest.java b/doxia-modules/doxia-module-xdoc/src/test/java/org/apache/maven/doxia/module/xdoc/XdocSinkTest.java index d33d5031..3f2ca708 100644 --- a/doxia-modules/doxia-module-xdoc/src/test/java/org/apache/maven/doxia/module/xdoc/XdocSinkTest.java +++ b/doxia-modules/doxia-module-xdoc/src/test/java/org/apache/maven/doxia/module/xdoc/XdocSinkTest.java @@ -37,6 +37,44 @@ import static org.junit.jupiter.api.Assertions.assertEquals; public class XdocSinkTest extends AbstractSinkTest { + /** {@inheritDoc} */ + @Test + public void testSection1() + { + String title = "Title1"; + getSink().section1(); + getSink().sectionTitle1(); + getSink().text( title ); + getSink().sectionTitle1_(); + getSink().section1_(); + getSink().flush(); + getSink().close(); + + String actual = getSinkContent(); + String expected = getSection1Block( title ); + + assertEquals( expected, actual, "Wrong section1 block!" ); + } + + /** {@inheritDoc} */ + @Test + public void testSection2() + { + String title = "Title2"; + getSink().section2(); + getSink().sectionTitle2(); + getSink().text( title ); + getSink().sectionTitle2_(); + getSink().section2_(); + getSink().flush(); + getSink().close(); + + String actual = getSinkContent(); + String expected = getSection2Block( title ); + + assertEquals( expected, actual, "Wrong section2 block!" ); + } + /** {@inheritDoc} */ protected String outputExtension() { @@ -92,19 +130,19 @@ public class XdocSinkTest /** {@inheritDoc} */ protected String getArticleBlock() { - return ""; + return "<article></article>"; } /** {@inheritDoc} */ protected String getNavigationBlock() { - return ""; + return "<nav></nav>"; } /** {@inheritDoc} */ protected String getSidebarBlock() { - return ""; + return "<aside></aside>"; } /** {@inheritDoc} */ @@ -128,37 +166,37 @@ public class XdocSinkTest /** {@inheritDoc} */ protected String getSection3Block( String title ) { - return "<h3>" + title + "</h3>"; + return "<header>" + EOL + "<h3>" + title + "</h3></header>"; } /** {@inheritDoc} */ protected String getSection4Block( String title ) { - return "<h4>" + title + "</h4>"; + return "<header>" + EOL + "<h4>" + title + "</h4></header>"; } /** {@inheritDoc} */ protected String getSection5Block( String title ) { - return "<h5>" + title + "</h5>"; + return "<header>" + EOL + "<h5>" + title + "</h5></header>"; } /** {@inheritDoc} */ protected String getHeaderBlock() { - return ""; + return "<header></header>"; } /** {@inheritDoc} */ protected String getContentBlock() { - return ""; + return "<main>" + EOL + "<div class=\"content\"></div></main>"; } /** {@inheritDoc} */ protected String getFooterBlock() { - return ""; + return "<footer></footer>"; } /** {@inheritDoc} */ @@ -182,16 +220,12 @@ public class XdocSinkTest /** {@inheritDoc} */ protected String getFigureBlock( String source, String caption ) { - String figureBlock = "<img src=\"" + escapeHTML( source ) + "\""; + String figureBlock = "<figure><img src=\"" + escapeHTML( source ) + "\" alt=\"\" />"; if ( caption != null ) { - figureBlock += " alt=\"" + caption + "\""; + figureBlock += "<figcaption>" + caption + "</figcaption>"; } - else //@todo fix DOXIA-361 - { - figureBlock += " alt=\"\""; - } - figureBlock += " />"; + figureBlock += "</figure>"; return figureBlock; } @@ -211,13 +245,13 @@ public class XdocSinkTest /** {@inheritDoc} */ protected String getDataBlock( String value, String text ) { - return text; + return "<data value=\"" + value + "\">" + text + "</data>"; } /** {@inheritDoc} */ protected String getTimeBlock( String datetime, String text ) { - return text; + return "<time datetime=\"" + datetime + "\">" + text + "</time>"; } /** {@inheritDoc} */ @@ -319,7 +353,7 @@ public class XdocSinkTest /** {@inheritDoc} */ protected String getLineBreakOpportunityBlock() { - return ""; + return "<wbr />"; } /** {@inheritDoc} */ diff --git a/doxia-modules/doxia-module-xhtml5/src/test/java/org/apache/maven/doxia/module/xhtml5/Xhtml5SinkWithLanguageIdTest.java b/doxia-modules/doxia-module-xhtml5/src/test/java/org/apache/maven/doxia/module/xhtml5/Xhtml5SinkWithLanguageIdTest.java index e86acd52..2e84f7cd 100644 --- a/doxia-modules/doxia-module-xhtml5/src/test/java/org/apache/maven/doxia/module/xhtml5/Xhtml5SinkWithLanguageIdTest.java +++ b/doxia-modules/doxia-module-xhtml5/src/test/java/org/apache/maven/doxia/module/xhtml5/Xhtml5SinkWithLanguageIdTest.java @@ -37,7 +37,7 @@ public class Xhtml5SinkWithLanguageIdTest /** {@inheritDoc} */ protected String getHeadBlock() { - return "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">" + return "<!DOCTYPE html>" + "<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"en\" xml:lang=\"en\">" + "<head><title></title>" + "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"/></head>"; diff --git a/doxia-modules/doxia-module-xhtml5/src/test/resources/test.xhtml b/doxia-modules/doxia-module-xhtml5/src/test/resources/test.xhtml index 5e4fa810..45f924dc 100644 --- a/doxia-modules/doxia-module-xhtml5/src/test/resources/test.xhtml +++ b/doxia-modules/doxia-module-xhtml5/src/test/resources/test.xhtml @@ -1,4 +1,4 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> +<!DOCTYPE html> <!-- Licensed to the Apache Software Foundation (ASF) under one diff --git a/doxia-modules/pom.xml b/doxia-modules/pom.xml index 723d9b00..574772f2 100644 --- a/doxia-modules/pom.xml +++ b/doxia-modules/pom.xml @@ -39,7 +39,6 @@ under the License. <module>doxia-module-xdoc</module> <module>doxia-module-xhtml</module> <module>doxia-module-xhtml5</module> - <!-- this has a dep on xhtml module, so needs to be built last! --> <module>doxia-module-markdown</module> </modules>
