You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by st...@apache.org on 2014/02/27 13:23:32 UTC
svn commit: r1572533 - in
/maven/doxia/doxia/trunk/doxia-modules/doxia-module-markdown/src:
main/java/org/apache/maven/doxia/module/markdown/
test/java/org/apache/maven/doxia/module/markdown/ test/resources/
Author: stephenc
Date: Thu Feb 27 12:23:32 2014
New Revision: 1572533
URL: http://svn.apache.org/r1572533
Log:
[DOXIA-515] <div> elements in markdown html block content are silently swallowed
Added:
maven/doxia/doxia/trunk/doxia-modules/doxia-module-markdown/src/test/resources/html-content.md
Modified:
maven/doxia/doxia/trunk/doxia-modules/doxia-module-markdown/src/main/java/org/apache/maven/doxia/module/markdown/MarkdownParser.java
maven/doxia/doxia/trunk/doxia-modules/doxia-module-markdown/src/test/java/org/apache/maven/doxia/module/markdown/MarkdownParserTest.java
Modified: maven/doxia/doxia/trunk/doxia-modules/doxia-module-markdown/src/main/java/org/apache/maven/doxia/module/markdown/MarkdownParser.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-modules/doxia-module-markdown/src/main/java/org/apache/maven/doxia/module/markdown/MarkdownParser.java?rev=1572533&r1=1572532&r2=1572533&view=diff
==============================================================================
--- maven/doxia/doxia/trunk/doxia-modules/doxia-module-markdown/src/main/java/org/apache/maven/doxia/module/markdown/MarkdownParser.java (original)
+++ maven/doxia/doxia/trunk/doxia-modules/doxia-module-markdown/src/main/java/org/apache/maven/doxia/module/markdown/MarkdownParser.java Thu Feb 27 12:23:32 2014
@@ -21,12 +21,16 @@ package org.apache.maven.doxia.module.ma
import org.apache.commons.lang.StringEscapeUtils;
import org.apache.commons.lang.StringUtils;
+import org.apache.maven.doxia.macro.MacroExecutionException;
+import org.apache.maven.doxia.markup.HtmlMarkup;
import org.apache.maven.doxia.module.xhtml.XhtmlParser;
import org.apache.maven.doxia.parser.ParseException;
import org.apache.maven.doxia.parser.Parser;
import org.apache.maven.doxia.sink.Sink;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.util.IOUtil;
+import org.codehaus.plexus.util.xml.pull.XmlPullParser;
+import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
import org.pegdown.Extensions;
import org.pegdown.PegDownProcessor;
import org.pegdown.ast.HeaderNode;
@@ -226,4 +230,32 @@ public class MarkdownParser
return builder.toString();
}
+ @Override
+ protected boolean baseEndTag( XmlPullParser parser, Sink sink )
+ {
+ boolean visited = super.baseEndTag( parser, sink );
+ if ( !visited )
+ {
+ if ( parser.getName().equals( HtmlMarkup.DIV.toString() ) )
+ {
+ handleUnknown( parser, sink, TAG_TYPE_END );
+ visited = true;
+ }
+ }
+ return visited;
+ }
+
+ @Override
+ protected boolean baseStartTag(XmlPullParser parser, Sink sink) {
+ boolean visited = super.baseStartTag( parser, sink );
+ if ( !visited )
+ {
+ if ( parser.getName().equals( HtmlMarkup.DIV.toString() ) )
+ {
+ handleUnknown( parser, sink, TAG_TYPE_START );
+ visited = true;
+ }
+ }
+ return visited;
+ }
}
Modified: maven/doxia/doxia/trunk/doxia-modules/doxia-module-markdown/src/test/java/org/apache/maven/doxia/module/markdown/MarkdownParserTest.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-modules/doxia-module-markdown/src/test/java/org/apache/maven/doxia/module/markdown/MarkdownParserTest.java?rev=1572533&r1=1572532&r2=1572533&view=diff
==============================================================================
--- maven/doxia/doxia/trunk/doxia-modules/doxia-module-markdown/src/test/java/org/apache/maven/doxia/module/markdown/MarkdownParserTest.java (original)
+++ maven/doxia/doxia/trunk/doxia-modules/doxia-module-markdown/src/test/java/org/apache/maven/doxia/module/markdown/MarkdownParserTest.java Thu Feb 27 12:23:32 2014
@@ -128,7 +128,7 @@ public class MarkdownParserTest
{
Iterator<SinkEventElement> it = parseFileToEventTestingSink( "code" ).getEventList().iterator();
- assertEquals( it, "head", "head_", "body", "paragraph", "text", "paragraph_", "text", "verbatim", "text", "verbatim_", "body_" );
+ assertEquals( it, "head", "head_", "body", "paragraph", "text", "paragraph_", "text", "unknown", "verbatim", "text", "verbatim_", "unknown", "body_" );
assertFalse( it.hasNext() );
}
@@ -248,6 +248,27 @@ public class MarkdownParserTest
}
/**
+ * Assert the first header is passed as title event when parsing "comment-before-heading.md".
+ *
+ * @throws Exception if the event list is not correct when parsing the document.
+ */
+ public void testHtmlContent()
+ throws Exception
+ {
+ Iterator<SinkEventElement> it = parseFileToEventTestingSink( "html-content" ).getEventList().iterator();
+
+ // NOTE: H1 and DIV are rendered as "unknown" and H2 is "section1" (see DOXIA-203)
+ assertEquals( it, "head", "head_", "body", "unknown", "text", "paragraph", "bold", "text",
+ "bold_", "text", "bold", "text", "bold_", "text", "paragraph_", "text", "unknown", "text", "horizontalRule", "unknown",
+ "text", "unknown", "paragraph", "text", "paragraph_", "text", "table", "tableRows", "text", "tableRow",
+ "tableHeaderCell", "text", "tableHeaderCell_", "tableRow_", "text", "tableRow",
+ "tableCell", "text", "tableCell_", "tableRow_", "text", "tableRows_", "table_",
+ "body_" );
+
+ assertFalse( it.hasNext() );
+ }
+
+ /**
* Parse the file and return a {@link SinkEventTestingSink}.
*
* @param file the file to parse with {@link #parser}.
Added: maven/doxia/doxia/trunk/doxia-modules/doxia-module-markdown/src/test/resources/html-content.md
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-modules/doxia-module-markdown/src/test/resources/html-content.md?rev=1572533&view=auto
==============================================================================
--- maven/doxia/doxia/trunk/doxia-modules/doxia-module-markdown/src/test/resources/html-content.md (added)
+++ maven/doxia/doxia/trunk/doxia-modules/doxia-module-markdown/src/test/resources/html-content.md Thu Feb 27 12:23:32 2014
@@ -0,0 +1,18 @@
+
+<div>
+<p><b>Example</b> is a <b>test</b> of mixing html and markdown
+
+</p>
+</div>
+
+---
+
+Heading
+=======
+
+Some text
+
+<table>
+<tr><th>column</th></tr>
+<tr><td>data</td></tr>
+</table>
\ No newline at end of file