You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by sl...@apache.org on 2021/05/30 17:20:58 UTC

[maven-doxia] branch DOXIA-568 updated (5045144 -> 3e0b52b)

This is an automated email from the ASF dual-hosted git repository.

slachiewicz pushed a change to branch DOXIA-568
in repository https://gitbox.apache.org/repos/asf/maven-doxia.git.


 discard 5045144  [DOXIA-568] Enable ANCHORLINKS extension
     add b55285c  [DOXIA-616] Markdown: Properly expose the language specified in fenced code blocks
     add 0ffc54a  Bump version to 1.10-SNAPSHOT
     add d679431  [DOXIA-542] Markdown module converts all apostrophes to quotation marks
     add 82f421e  Fix Java 7 compatibility that was broken with DOXIA-616
     add 8128fd3  [DOXIA-618]
     add 7930502  Bump fop from 2.5 to 2.6
     add e1d7a71  Bump junit from 4.13.1 to 4.13.2
     add e02a241  Dependabot: ignore Java 8 dependencies
     add 98e259c  Bump ant-apache-regexp from 1.10.9 to 1.10.10
     add 589e703  [DOXIA-609] Fixed crosslinks starting with a dot in markdown files
     add 794c39d  Adjust Github CI config
     add 5443de7  [DOXIA-588] Update Xhtml5BaseSinkTest align missing
     add 35b96ae  Bump actions/cache from 2.1.4 to 2.1.6
     add baa05cf  Prepare switch plexus-container-default to org.eclipse.sisu.plexus
     add 8bfb5be  (doc) misc javadoc updates
     add 64ddf82  [DOXIA-614] Make Parser::parse(Reader,Sink,String) the default method for modules
     add cb017d8  [DOXIA-614] Exclude expected changes to API - clirr reported errors
     add 497a438  [DOXIA-614] Support passing source reference to Doxia instance
     new 490ba7a  [DOXIA-568] Introduce AssertJ
     new 3e0b52b  [DOXIA-568] Enable ANCHORLINKS extension

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (5045144)
            \
             N -- N -- N   refs/heads/DOXIA-568 (3e0b52b)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .github/dependabot.yml                             |  35 ++-
 .github/workflows/maven.yml                        |  51 +++++
 doxia-core/pom.xml                                 |   8 +-
 .../java/org/apache/maven/doxia/DefaultDoxia.java  |  10 +-
 .../main/java/org/apache/maven/doxia/Doxia.java    |  33 ++-
 .../apache/maven/doxia/parser/AbstractParser.java  |  55 +++--
 .../maven/doxia/parser/AbstractXmlParser.java      |  16 +-
 .../maven/doxia/parser/Xhtml5BaseParser.java       |   4 +-
 .../apache/maven/doxia/parser/XhtmlBaseParser.java |   7 +-
 .../maven/doxia/sink/impl/Xhtml5BaseSink.java      |  28 ++-
 .../maven/doxia/sink/impl/XhtmlBaseSink.java       |  28 ++-
 .../org/apache/maven/doxia/AbstractModuleTest.java |   3 +-
 ...MacroManagerTest.java => DefaultDoxiaTest.java} |  41 ++--
 .../doxia/macro/manager/MacroManagerTest.java      |   2 +-
 .../maven/doxia/parser/AbstractParserTest.java     |  17 +-
 .../maven/doxia/sink/impl/Xhtml5BaseSinkTest.java  |   6 +-
 .../maven/doxia/sink/impl/XhtmlBaseSinkTest.java   |  15 +-
 doxia-logging-api/pom.xml                          |   2 +-
 doxia-modules/doxia-module-apt/pom.xml             |   2 +-
 .../maven/doxia/module/apt/AptParserTest.java      |   2 +-
 .../apache/maven/doxia/module/apt/AptSinkTest.java |  47 ++++
 doxia-modules/doxia-module-confluence/pom.xml      |   2 +-
 .../module/confluence/ConfluenceParserTest.java    |   2 +-
 doxia-modules/doxia-module-docbook-simple/pom.xml  |   2 +-
 .../doxia/module/docbook/DocBookParserTest.java    |   2 +-
 doxia-modules/doxia-module-fml/pom.xml             |   4 +-
 .../apache/maven/doxia/module/fml/FmlParser.java   |   4 +-
 .../maven/doxia/module/fml/FmlParserTest.java      |   2 +-
 doxia-modules/doxia-module-fo/pom.xml              |   4 +-
 doxia-modules/doxia-module-itext/pom.xml           |   2 +-
 doxia-modules/doxia-module-latex/pom.xml           |   2 +-
 doxia-modules/doxia-module-markdown/pom.xml        |  83 ++++++-
 .../doxia-module-markdown/src/it/general/pom.xml   |  69 ++++++
 .../src/it/general/src/site/markdown/DOXIA-473.md  |   4 +
 .../general/src/site/markdown/DOXIA-535.markdown   |   3 +
 .../src/it/general/src/site/markdown/DOXIA-571.md  |  28 ++-
 .../src/it/general/src/site/markdown/DOXIA-597.md  |   3 +
 .../site/markdown/DOXIA-616-fenced-code-block.md   |  26 +++
 .../src/it/general/src/site/markdown/index.md      |   5 +
 .../src/it/general/src/site/markdown/metadata.md   |  11 +
 .../src/it/general/src/site/markdown/quotes.md     |   5 +
 .../src/it/general/src/site/site.xml}              |  37 +--
 .../src/it/general/verify.groovy                   | 108 +++++++++
 .../doxia-module-markdown/src/it/settings.xml      |  55 +++++
 .../module/markdown/FlexmarkDoxiaExtension.java    |  58 -----
 .../module/markdown/FlexmarkDoxiaLinkResolver.java |   3 +-
 .../module/markdown/FlexmarkDoxiaNodeRenderer.java | 146 ------------
 .../doxia/module/markdown/MarkdownParser.java      | 244 +++++++++++---------
 .../markdown/FlexmarkDoxiaLinkResolverTest.java    |  22 ++
 .../module/markdown/MarkdownParserModuleTest.java  |   4 +-
 .../doxia/module/markdown/MarkdownParserTest.java  | 248 +++++++++++++--------
 .../src/test/resources/fenced-code-block.md        |   5 +
 .../src/test/resources/first-heading.md            |   2 +-
 .../src/test/resources/metadata.md                 |  13 +-
 .../src/test/resources/quote-vs-apostrophe.md      |   3 +
 doxia-modules/doxia-module-rtf/pom.xml             |   2 +-
 doxia-modules/doxia-module-twiki/pom.xml           |   2 +-
 .../doxia/module/twiki/parser/TwikiParserTest.java |   2 +-
 doxia-modules/doxia-module-xdoc/pom.xml            |   4 +-
 .../apache/maven/doxia/module/xdoc/XdocParser.java |   4 +-
 .../maven/doxia/module/xdoc/XdocParserTest.java    |   2 +-
 .../maven/doxia/module/xdoc/XdocSinkTest.java      |   2 +-
 doxia-modules/doxia-module-xhtml/pom.xml           |   2 +-
 .../maven/doxia/module/xhtml/XhtmlParser.java      |   6 +-
 .../maven/doxia/module/xhtml/XhtmlParserTest.java  |   2 +-
 doxia-modules/doxia-module-xhtml5/pom.xml          |   2 +-
 .../maven/doxia/module/xhtml5/Xhtml5Parser.java    |   6 +-
 .../doxia/module/xhtml5/Xhtml5ParserTest.java      |   2 +-
 doxia-modules/pom.xml                              |   2 +-
 doxia-sink-api/pom.xml                             |   2 +-
 doxia-test-docs/pom.xml                            |   2 +-
 pom.xml                                            |  58 ++---
 72 files changed, 1107 insertions(+), 618 deletions(-)
 create mode 100644 .github/workflows/maven.yml
 copy doxia-core/src/test/java/org/apache/maven/doxia/{macro/manager/MacroManagerTest.java => DefaultDoxiaTest.java} (55%)
 create mode 100644 doxia-modules/doxia-module-markdown/src/it/general/pom.xml
 create mode 100644 doxia-modules/doxia-module-markdown/src/it/general/src/site/markdown/DOXIA-473.md
 create mode 100644 doxia-modules/doxia-module-markdown/src/it/general/src/site/markdown/DOXIA-535.markdown
 copy doxia-test-docs/src/main/resources/maven-verifier-plugin/fml/faq.fml => doxia-modules/doxia-module-markdown/src/it/general/src/site/markdown/DOXIA-571.md (61%)
 create mode 100644 doxia-modules/doxia-module-markdown/src/it/general/src/site/markdown/DOXIA-597.md
 create mode 100644 doxia-modules/doxia-module-markdown/src/it/general/src/site/markdown/DOXIA-616-fenced-code-block.md
 create mode 100644 doxia-modules/doxia-module-markdown/src/it/general/src/site/markdown/index.md
 create mode 100644 doxia-modules/doxia-module-markdown/src/it/general/src/site/markdown/metadata.md
 create mode 100644 doxia-modules/doxia-module-markdown/src/it/general/src/site/markdown/quotes.md
 copy doxia-modules/{doxia-module-fo/src/site/xdoc/links.xml => doxia-module-markdown/src/it/general/src/site/site.xml} (52%)
 create mode 100644 doxia-modules/doxia-module-markdown/src/it/general/verify.groovy
 create mode 100644 doxia-modules/doxia-module-markdown/src/it/settings.xml
 delete mode 100644 doxia-modules/doxia-module-markdown/src/main/java/org/apache/maven/doxia/module/markdown/FlexmarkDoxiaExtension.java
 delete mode 100644 doxia-modules/doxia-module-markdown/src/main/java/org/apache/maven/doxia/module/markdown/FlexmarkDoxiaNodeRenderer.java
 create mode 100644 doxia-modules/doxia-module-markdown/src/test/resources/fenced-code-block.md
 create mode 100644 doxia-modules/doxia-module-markdown/src/test/resources/quote-vs-apostrophe.md

[maven-doxia] 01/02: [DOXIA-568] Introduce AssertJ

Posted by sl...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

slachiewicz pushed a commit to branch DOXIA-568
in repository https://gitbox.apache.org/repos/asf/maven-doxia.git

commit 490ba7ab4bd01421b004a482c5446f40a690dca3
Author: Sylwester Lachiewicz <sl...@apache.org>
AuthorDate: Sun May 30 18:06:26 2021 +0200

    [DOXIA-568] Introduce AssertJ
---
 doxia-core/pom.xml                                 |   6 +
 .../maven/doxia/parser/AbstractParserTest.java     |  17 +-
 doxia-modules/doxia-module-markdown/pom.xml        |   6 +
 .../module/markdown/MarkdownParserModuleTest.java  |   4 +-
 .../doxia/module/markdown/MarkdownParserTest.java  | 174 ++++++++++-----------
 5 files changed, 99 insertions(+), 108 deletions(-)

diff --git a/doxia-core/pom.xml b/doxia-core/pom.xml
index 449f433..7059d59 100644
--- a/doxia-core/pom.xml
+++ b/doxia-core/pom.xml
@@ -81,6 +81,12 @@ under the License.
       <artifactId>xmlunit-matchers</artifactId>
       <scope>test</scope>
     </dependency>
+    <dependency>
+      <groupId>org.assertj</groupId>
+      <artifactId>assertj-core</artifactId>
+      <version>2.9.1</version><!-- for Java 7 projects -->
+      <scope>test</scope>
+    </dependency>
 
   </dependencies>
 
diff --git a/doxia-core/src/test/java/org/apache/maven/doxia/parser/AbstractParserTest.java b/doxia-core/src/test/java/org/apache/maven/doxia/parser/AbstractParserTest.java
index 78d29d5..6729001 100644
--- a/doxia-core/src/test/java/org/apache/maven/doxia/parser/AbstractParserTest.java
+++ b/doxia-core/src/test/java/org/apache/maven/doxia/parser/AbstractParserTest.java
@@ -32,6 +32,8 @@ import java.io.Reader;
 import java.io.Writer;
 import java.util.Iterator;
 
+import static org.assertj.core.api.Assertions.assertThat;
+
 /**
  * Test the parsing of sample input files.
  * <br>
@@ -115,20 +117,7 @@ public abstract class AbstractParserTest
 
     protected void assertEquals( Iterator<SinkEventElement> it, String... names )
     {
-        StringBuilder expected = new StringBuilder();
-        StringBuilder actual = new StringBuilder();
-
-        for ( String name : names )
-        {
-            expected.append( name ).append( '\n' );
-        }
-
-        while ( it.hasNext() )
-        {
-            actual.append( it.next().getName() ).append( '\n' );
-        }
-
-        assertEquals( expected.toString(), actual.toString() );
+        assertThat ( it ).extracting( "name" ).containsExactly( names );
     }
 
     protected void assertStartsWith( Iterator<SinkEventElement> it, String... names )
diff --git a/doxia-modules/doxia-module-markdown/pom.xml b/doxia-modules/doxia-module-markdown/pom.xml
index 81061bc..43e7b9e 100644
--- a/doxia-modules/doxia-module-markdown/pom.xml
+++ b/doxia-modules/doxia-module-markdown/pom.xml
@@ -76,6 +76,12 @@ under the License.
       <groupId>commons-io</groupId>
       <artifactId>commons-io</artifactId>
     </dependency>
+    <dependency>
+      <groupId>org.assertj</groupId>
+      <artifactId>assertj-core</artifactId>
+      <version>2.9.1</version><!-- for Java 7 projects -->
+      <scope>test</scope>
+    </dependency>
   </dependencies>
   <build>
 
diff --git a/doxia-modules/doxia-module-markdown/src/test/java/org/apache/maven/doxia/module/markdown/MarkdownParserModuleTest.java b/doxia-modules/doxia-module-markdown/src/test/java/org/apache/maven/doxia/module/markdown/MarkdownParserModuleTest.java
index 4895969..c7451e8 100644
--- a/doxia-modules/doxia-module-markdown/src/test/java/org/apache/maven/doxia/module/markdown/MarkdownParserModuleTest.java
+++ b/doxia-modules/doxia-module-markdown/src/test/java/org/apache/maven/doxia/module/markdown/MarkdownParserModuleTest.java
@@ -22,6 +22,8 @@ package org.apache.maven.doxia.module.markdown;
 import org.apache.maven.doxia.parser.module.ParserModule;
 import org.codehaus.plexus.PlexusTestCase;
 
+import static org.assertj.core.api.Assertions.assertThat;
+
 /**
  * Test MarkdownParserModule.
  */
@@ -46,6 +48,6 @@ public class MarkdownParserModuleTest
 
     public void testExtensions()
     {
-        assertEquals( 2, parserModule.getExtensions().length );
+        assertThat( parserModule.getExtensions() ).hasSize( 2 );
     }
 }
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 11e4da5..242290f 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
@@ -1,10 +1,5 @@
 package org.apache.maven.doxia.module.markdown;
 
-import java.io.IOException;
-import java.io.Reader;
-import java.util.Iterator;
-import java.util.List;
-
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
@@ -32,6 +27,12 @@ import org.apache.maven.doxia.sink.impl.SinkEventAttributeSet;
 import org.apache.maven.doxia.sink.impl.SinkEventElement;
 import org.apache.maven.doxia.sink.impl.SinkEventTestingSink;
 
+import java.io.IOException;
+import java.io.Reader;
+import java.util.List;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
 /**
  * Tests for {@link MarkdownParser}.
  *
@@ -84,11 +85,10 @@ public class MarkdownParserTest
     public void testParagraphSinkEvent()
         throws Exception
     {
-        Iterator<SinkEventElement> it = parseFileToEventTestingSink( "paragraph" ).getEventList().iterator();
+        List<SinkEventElement> list = parseFileToEventTestingSink( "paragraph" ).getEventList();
 
-        assertEquals( it, "head", "head_", "body", "paragraph", "text", "paragraph_", "body_" );
-
-        assertFalse( it.hasNext() );
+        assertThat ( list ).extracting( "name" ).containsExactly(
+                "head", "head_", "body", "paragraph", "text", "paragraph_", "body_" );
     }
 
     /**
@@ -101,11 +101,9 @@ public class MarkdownParserTest
     {
         //System.out.println( parseFileToHtml( "font-bold" ) );
         List<SinkEventElement> eventList = parseFileToEventTestingSink( "font-bold" ).getEventList();
-        Iterator<SinkEventElement> it = eventList.iterator();
-
-        assertEquals( it, "head", "head_", "body", "paragraph", "inline", "text", "inline_", "paragraph_", "body_" );
 
-        assertFalse( it.hasNext() );
+        assertThat( eventList ).extracting( "name" ).containsExactly(
+                "head", "head_", "body", "paragraph", "inline", "text", "inline_", "paragraph_", "body_" );
 
         SinkEventElement inline = eventList.get( 4 );
         assertEquals( "inline", inline.getName() );
@@ -123,11 +121,10 @@ public class MarkdownParserTest
     {
         //System.out.println( parseFileToHtml( "font-italic" ) );
         List<SinkEventElement> eventList = parseFileToEventTestingSink( "font-italic" ).getEventList();
-        Iterator<SinkEventElement> it = eventList.iterator();
 
-        assertEquals( it, "head", "head_", "body", "paragraph", "inline", "text", "inline_", "paragraph_", "body_" );
+        assertThat( eventList ).extracting( "name" ).containsExactly(
+                "head", "head_", "body", "paragraph", "inline", "text", "inline_", "paragraph_", "body_" );
 
-        assertFalse( it.hasNext() );
         SinkEventElement inline = eventList.get( 4 );
         assertEquals( "inline", inline.getName() );
         SinkEventAttributeSet atts = (SinkEventAttributeSet) inline.getArgs()[0];
@@ -142,13 +139,11 @@ public class MarkdownParserTest
     public void testFontMonospacedSinkEvent()
         throws Exception
     {
-        //System.out.println( parseFileToHtml( "font-monospaced" ) );
         List<SinkEventElement> eventList = parseFileToEventTestingSink( "font-monospaced" ).getEventList();
-        Iterator<SinkEventElement> it = eventList.iterator();
 
-        assertEquals( it, "head", "head_", "body", "paragraph", "inline", "text", "inline_", "paragraph_", "body_" );
+        assertThat( eventList ).extracting( "name" ).containsExactly(
+                "head", "head_", "body", "paragraph", "inline", "text", "inline_", "paragraph_", "body_" );
 
-        assertFalse( it.hasNext() );
         SinkEventElement inline = eventList.get( 4 );
         assertEquals( "inline", inline.getName() );
         SinkEventAttributeSet atts = (SinkEventAttributeSet) inline.getArgs()[0];
@@ -163,11 +158,10 @@ public class MarkdownParserTest
     public void testCodeSinkEvent()
         throws Exception
     {
-        Iterator<SinkEventElement> it = parseFileToEventTestingSink( "code" ).getEventList().iterator();
-
-        assertEquals( it, "head", "head_", "body", "paragraph", "text", "paragraph_", "text", "verbatim", "inline", "text", "inline_", "verbatim_", "body_" );
+        List<SinkEventElement> eventList = parseFileToEventTestingSink( "code" ).getEventList();
 
-        assertFalse( it.hasNext() );
+        assertThat( eventList ).extracting( "name" ).containsExactly(
+                "head", "head_", "body", "paragraph", "text", "paragraph_", "text", "verbatim", "inline", "text", "inline_", "verbatim_", "body_" );
     }
 
     /**
@@ -179,11 +173,9 @@ public class MarkdownParserTest
         throws Exception
     {
         List<SinkEventElement> eventList = parseFileToEventTestingSink( "fenced-code-block" ).getEventList();
-        Iterator<SinkEventElement> it = eventList.iterator();
 
-        assertEquals( it, "head", "head_", "body", "paragraph", "text", "paragraph_", "text", "verbatim", "inline", "text", "inline_", "verbatim_", "body_" );
-
-        assertFalse( it.hasNext() );
+        assertThat( eventList ).extracting( "name" ).containsExactly(
+                "head", "head_", "body", "paragraph", "text", "paragraph_", "text", "verbatim", "inline", "text", "inline_", "verbatim_", "body_" );
 
         // PRE element must be a "verbatim" Sink event that specifies
         // BOXED = true
@@ -209,11 +201,10 @@ public class MarkdownParserTest
     public void testImageSinkEvent()
         throws Exception
     {
-        Iterator<SinkEventElement> it = parseFileToEventTestingSink( "image" ).getEventList().iterator();
-
-        assertEquals( it, "head", "head_", "body", "paragraph", "text", "figureGraphics", "text", "paragraph_", "body_" );
+        List<SinkEventElement> eventList = parseFileToEventTestingSink( "image" ).getEventList();
 
-        assertFalse( it.hasNext() );
+        assertThat( eventList ).extracting( "name" ).containsExactly(
+                "head", "head_", "body", "paragraph", "text", "figureGraphics", "text", "paragraph_", "body_" );
     }
 
     /**
@@ -224,11 +215,10 @@ public class MarkdownParserTest
     public void testLinkSinkEvent()
         throws Exception
     {
-        Iterator<SinkEventElement> it = parseFileToEventTestingSink( "link" ).getEventList().iterator();
+        List<SinkEventElement> eventList = parseFileToEventTestingSink( "link" ).getEventList();
 
-        assertEquals( it, "head", "head_", "body", "paragraph", "text", "link", "text", "link_", "text", "paragraph_", "body_" );
-
-        assertFalse( it.hasNext() );
+        assertThat( eventList ).extracting( "name" ).containsExactly(
+                "head", "head_", "body", "paragraph", "text", "link", "text", "link_", "text", "paragraph_", "body_" );
     }
 
     /**
@@ -241,23 +231,20 @@ public class MarkdownParserTest
     {
         List<SinkEventElement> eventList = parseFileToEventTestingSink( "link_rewrite" ).getEventList();
 
-        Iterator<SinkEventElement> it = eventList.iterator();
-        assertEquals( it, "head", "head_", "body", "paragraph", "text", "link", "text", "link_", "text", "link", "text",
+        assertThat( eventList ).extracting( "name" ).containsExactly(
+                "head", "head_", "body", "paragraph", "text", "link", "text", "link_", "text", "link", "text",
                       "link_", "text", "paragraph_", "body_" );
 
-        assertFalse( it.hasNext() );
-
         assertEquals( "doc.html", eventList.get( 5 ).getArgs()[0] );
         assertEquals( "ftp://doc.md", eventList.get( 9 ).getArgs()[0] );
     }
 
     public void testLinkWithAnchorAndQuery() throws Exception
     {
-        Iterator<SinkEventElement> it = parseFileToEventTestingSink( "link_anchor_query" ).getEventList().iterator();
+        List<SinkEventElement> eventList = parseFileToEventTestingSink( "link_anchor_query" ).getEventList();
 
-        assertEquals( it, "head", "head_", "body", "paragraph", "link", "text", "link_", "paragraph_", "body_" );
-
-        assertFalse( it.hasNext() );
+        assertThat( eventList ).extracting( "name" ).containsExactly(
+                "head", "head_", "body", "paragraph", "link", "text", "link_", "paragraph_", "body_" );
     }
 
     /**
@@ -268,12 +255,11 @@ public class MarkdownParserTest
     public void testListSinkEvent()
         throws Exception
     {
-        Iterator<SinkEventElement> it = parseFileToEventTestingSink( "list" ).getEventList().iterator();
+        List<SinkEventElement> eventList = parseFileToEventTestingSink( "list" ).getEventList();
 
-        assertEquals( it, "head", "head_", "body", "list", "text", "listItem", "text", "listItem_", "listItem", "text",
+        assertThat( eventList ).extracting( "name" ).containsExactly(
+                "head", "head_", "body", "list", "text", "listItem", "text", "listItem_", "listItem", "text",
                       "listItem_", "text", "list_", "body_" );
-
-        assertFalse( it.hasNext() );
     }
 
     /**
@@ -284,12 +270,11 @@ public class MarkdownParserTest
     public void testNumberedListSinkEvent()
         throws Exception
     {
-        Iterator<SinkEventElement> it = parseFileToEventTestingSink( "numbered-list" ).getEventList().iterator();
+        List<SinkEventElement> eventList = parseFileToEventTestingSink( "numbered-list" ).getEventList();
 
-        assertEquals( it, "head", "head_", "body", "numberedList", "text", "numberedListItem", "text", "numberedListItem_",
+        assertThat( eventList ).extracting( "name" ).containsExactly(
+                "head", "head_", "body", "numberedList", "text", "numberedListItem", "text", "numberedListItem_",
                       "numberedListItem", "text", "numberedListItem_", "text", "numberedList_", "body_" );
-
-        assertFalse( it.hasNext() );
     }
 
     /**
@@ -301,15 +286,13 @@ public class MarkdownParserTest
         throws Exception
     {
         List<SinkEventElement> eventList = parseFileToEventTestingSink( "metadata" ).getEventList();
-        Iterator<SinkEventElement> it = eventList.iterator();
 
-        assertEquals( it, "head", "title", "text", "text", "text", "title_", "author", "text", "author_", "date", "text", "date_",
+        assertThat( eventList ).extracting( "name" ).containsExactly(
+                "head", "title", "text", "text", "text", "title_", "author", "text", "author_", "date", "text", "date_",
                       "unknown", "head_", "body", "unknown", "text", "unknown", "paragraph", "text", "paragraph_", "section1",
                       "sectionTitle1", "text", "sectionTitle1_", "paragraph", "text", "paragraph_", "section1_",
                       "body_" );
 
-        assertFalse( it.hasNext() );
-
         // Title must be "A Title & a Test"
         assertEquals( "A Title ", eventList.get( 2 ).getArgs()[0]);
         assertEquals( "&", eventList.get( 3 ).getArgs()[0]);
@@ -340,14 +323,13 @@ public class MarkdownParserTest
     public void testFirstHeadingSinkEvent()
         throws Exception
     {
-        Iterator<SinkEventElement> it = parseFileToEventTestingSink( "first-heading" ).getEventList().iterator();
+        List<SinkEventElement> eventList = parseFileToEventTestingSink( "first-heading" ).getEventList();
 
         // NOTE: H1 is rendered as "unknown" and H2 is "section1" (see DOXIA-203)
-        assertEquals( it, "head", "title", "text", "title_", "head_", "body", "comment", "text",
+        assertThat( eventList ).extracting( "name" ).containsExactly(
+                "head", "title", "text", "title_", "head_", "body", "comment", "text",
                 "section1", "sectionTitle1", "text", "sectionTitle1_", "paragraph", "text",
                 "paragraph_", "section1_", "body_" );
-
-        assertFalse( it.hasNext() );
     }
 
     /**
@@ -358,13 +340,12 @@ public class MarkdownParserTest
     public void testCommentBeforeHeadingSinkEvent()
         throws Exception
     {
-        Iterator<SinkEventElement> it = parseFileToEventTestingSink( "comment-before-heading" ).getEventList().iterator();
+        List<SinkEventElement> eventList = parseFileToEventTestingSink( "comment-before-heading" ).getEventList();
 
         // NOTE: H1 is rendered as "unknown" and H2 is "section1" (see DOXIA-203)
-        assertEquals( it, "head", "title", "text", "title_", "head_", "body", "comment", "text", "unknown", "text",
+        assertThat( eventList ).extracting( "name" ).containsExactly(
+                "head", "title", "text", "title_", "head_", "body", "comment", "text", "unknown", "text",
                       "unknown", "paragraph", "text", "link", "text", "link_", "text", "paragraph_", "body_" );
-
-        assertFalse( it.hasNext() );
     }
 
     /**
@@ -375,17 +356,16 @@ public class MarkdownParserTest
     public void testHtmlContent()
         throws Exception
     {
-        Iterator<SinkEventElement> it = parseFileToEventTestingSink( "html-content" ).getEventList().iterator();
+        List<SinkEventElement> eventList = parseFileToEventTestingSink( "html-content" ).getEventList();
 
         // NOTE: H1 and DIV are rendered as "unknown" and H2 is "section1" (see DOXIA-203)
-        assertEquals( it, "head", "head_", "body", "unknown", "text", "paragraph", "inline", "text",
+        assertThat( eventList ).extracting( "name" ).containsExactly(
+                "head", "head_", "body", "unknown", "text", "paragraph", "inline", "text",
                       "inline_", "text", "inline", "text", "inline_", "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() );
     }
 
     /**
@@ -408,7 +388,7 @@ public class MarkdownParserTest
         return sink;
     }
 
-    protected String parseFileToHtml( String file ) throws ParseException, IOException
+    protected String parseFileToHtml( String file ) throws IOException
     {
         try ( Reader reader = getTestReader( file ) )
         {
@@ -416,12 +396,19 @@ public class MarkdownParserTest
         }
     }
 
+    public void testTocMacro2() throws IOException
+    {
+        String html = parseFileToHtml( "macro-toc" );
+        assertThat( html ).contains( "<!-- MACRO{toc|fromDepth=1|toDepth=2} -->" );
+    }
+
     public void testTocMacro()
         throws Exception
     {
-        Iterator<SinkEventElement> it = parseFileToEventTestingSink( "macro-toc" ).getEventList().iterator();
+        List<SinkEventElement> eventList = parseFileToEventTestingSink( "macro-toc" ).getEventList();
 
-        assertEquals( it, "head", "title", "text", "title_", "head_",
+        assertThat( eventList ).extracting( "name" ).containsExactly(
+                "head", "title", "text", "title_", "head_",
                       "body",
                       "list", // TOC start
                       "listItem", "link", "text", "link_", // emtpy section 2 TOC entry
@@ -443,28 +430,29 @@ public class MarkdownParserTest
     public void testTocMacroDoxia559()
         throws Exception
     {
-        Iterator<SinkEventElement> it = parseFileToEventTestingSink( "macro-toc-DOXIA-559" ).getEventList().iterator();
-
-        assertEquals( it, "head", "title", "text", "title_", "head_",
-                      "body",
-                      "list", // TOC start
-                      "listItem", "link", "text", "link_", // first section 2 TOC entry
-                      "list", // sections 3 list start
-                      "listItem", "link", "text", "link_", "listItem_", // empty section 3 TOC entry
-                      "list_", // sections 3 list end
-                      "listItem_", // first section 2 TOC entry end
-                      "listItem", "link", "text", "link_", "listItem_", // second section 2 TOC entry
-                      "list_", // TOC end
-                      "text",
-                      "section1", "sectionTitle1", "text", "sectionTitle1_",
-                      "section2",
-                      "section3", "sectionTitle3", "text", "sectionTitle3_",
-                      "section3_",
-                      "section2_",
-                      "section1_",
-                      "section1", "sectionTitle1", "text", "sectionTitle1_",
-                      "section1_",
-                      "body_" );
+        List<SinkEventElement> list = parseFileToEventTestingSink( "macro-toc-DOXIA-559" ).getEventList();
+
+        assertThat( list ).extracting( "name" ).containsExactly(
+              "head", "title", "text", "title_", "head_",
+              "body",
+              "list", // TOC start
+              "listItem", "link", "text", "link_", // first section 2 TOC entry
+              "list", // sections 3 list start
+              "listItem", "link", "text", "link_", "listItem_", // empty section 3 TOC entry
+              "list_", // sections 3 list end
+              "listItem_", // first section 2 TOC entry end
+              "listItem", "link", "text", "link_", "listItem_", // second section 2 TOC entry
+              "list_", // TOC end
+              "text",
+              "section1", "sectionTitle1", "text", "sectionTitle1_",
+              "section2",
+              "section3", "sectionTitle3", "text", "sectionTitle3_",
+              "section3_",
+              "section2_",
+              "section1_",
+              "section1", "sectionTitle1", "text", "sectionTitle1_",
+              "section1_",
+              "body_" );
     }
 
     // test fix for https://github.com/vsch/flexmark-java/issues/384

[maven-doxia] 02/02: [DOXIA-568] Enable ANCHORLINKS extension

Posted by sl...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

slachiewicz pushed a commit to branch DOXIA-568
in repository https://gitbox.apache.org/repos/asf/maven-doxia.git

commit 3e0b52b4ad102ceadf3d0dddffb10e479c41c3de
Author: Sylwester Lachiewicz <sl...@apache.org>
AuthorDate: Sun May 30 19:19:07 2021 +0200

    [DOXIA-568] Enable ANCHORLINKS extension
---
 .../maven/doxia/module/markdown/MarkdownParser.java  |  2 ++
 .../doxia/module/markdown/MarkdownParserTest.java    | 20 ++++++++++----------
 2 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/doxia-modules/doxia-module-markdown/src/main/java/org/apache/maven/doxia/module/markdown/MarkdownParser.java b/doxia-modules/doxia-module-markdown/src/main/java/org/apache/maven/doxia/module/markdown/MarkdownParser.java
index 33057ea..b77cf56 100644
--- a/doxia-modules/doxia-module-markdown/src/main/java/org/apache/maven/doxia/module/markdown/MarkdownParser.java
+++ b/doxia-modules/doxia-module-markdown/src/main/java/org/apache/maven/doxia/module/markdown/MarkdownParser.java
@@ -21,6 +21,7 @@ package org.apache.maven.doxia.module.markdown;
 
 import com.vladsch.flexmark.ast.Heading;
 import com.vladsch.flexmark.ast.HtmlCommentBlock;
+import com.vladsch.flexmark.ext.anchorlink.AnchorLinkExtension;
 import com.vladsch.flexmark.util.ast.Node;
 import com.vladsch.flexmark.ast.util.TextCollectingVisitor;
 import com.vladsch.flexmark.html.HtmlRenderer;
@@ -139,6 +140,7 @@ public class MarkdownParser
                 DefinitionExtension.create(),
                 TypographicExtension.create(),
                 TablesExtension.create(),
+                AnchorLinkExtension.create(),
                 WikiLinkExtension.create(),
                 StrikethroughExtension.create()
         ) );
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 242290f..492c9bb 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
@@ -289,8 +289,8 @@ public class MarkdownParserTest
 
         assertThat( eventList ).extracting( "name" ).containsExactly(
                 "head", "title", "text", "text", "text", "title_", "author", "text", "author_", "date", "text", "date_",
-                      "unknown", "head_", "body", "unknown", "text", "unknown", "paragraph", "text", "paragraph_", "section1",
-                      "sectionTitle1", "text", "sectionTitle1_", "paragraph", "text", "paragraph_", "section1_",
+                      "unknown", "head_", "body", "unknown", "link", "text", "link_", "unknown", "paragraph", "text", "paragraph_", "section1",
+                      "sectionTitle1", "link", "text", "link_", "sectionTitle1_", "paragraph", "text", "paragraph_", "section1_",
                       "body_" );
 
         // Title must be "A Title & a Test"
@@ -328,7 +328,7 @@ public class MarkdownParserTest
         // NOTE: H1 is rendered as "unknown" and H2 is "section1" (see DOXIA-203)
         assertThat( eventList ).extracting( "name" ).containsExactly(
                 "head", "title", "text", "title_", "head_", "body", "comment", "text",
-                "section1", "sectionTitle1", "text", "sectionTitle1_", "paragraph", "text",
+                "section1", "sectionTitle1", "link", "text", "link_", "sectionTitle1_", "paragraph", "text",
                 "paragraph_", "section1_", "body_" );
     }
 
@@ -344,7 +344,7 @@ public class MarkdownParserTest
 
         // NOTE: H1 is rendered as "unknown" and H2 is "section1" (see DOXIA-203)
         assertThat( eventList ).extracting( "name" ).containsExactly(
-                "head", "title", "text", "title_", "head_", "body", "comment", "text", "unknown", "text",
+                "head", "title", "text", "title_", "head_", "body", "comment", "text", "unknown", "link", "text", "link_",
                       "unknown", "paragraph", "text", "link", "text", "link_", "text", "paragraph_", "body_" );
     }
 
@@ -362,7 +362,7 @@ public class MarkdownParserTest
         assertThat( eventList ).extracting( "name" ).containsExactly(
                 "head", "head_", "body", "unknown", "text", "paragraph", "inline", "text",
                       "inline_", "text", "inline", "text", "inline_", "text", "paragraph_", "text", "unknown", "text", "horizontalRule", "unknown",
-                "text", "unknown", "paragraph", "text", "paragraph_", "text", "table", "tableRows", "text", "tableRow",
+                "link", "text", "link_", "unknown", "paragraph", "text", "paragraph_", "text", "table", "tableRows", "text", "tableRow",
                 "tableHeaderCell", "text", "tableHeaderCell_", "tableRow_", "text", "tableRow",
                                 "tableCell", "text", "tableCell_", "tableRow_", "text", "tableRows_", "table_",
                 "body_" );
@@ -420,8 +420,8 @@ public class MarkdownParserTest
                       "list_", // TOC end
                       "text",
                       "section1",
-                      "section2", "sectionTitle2", "text", "sectionTitle2_", "section2_",
-                      "section2", "sectionTitle2", "text", "sectionTitle2_", "section2_",
+                      "section2", "sectionTitle2", "link", "text", "link_", "sectionTitle2_", "section2_",
+                      "section2", "sectionTitle2", "link", "text", "link_", "sectionTitle2_", "section2_",
                       "section1_",
                       "body_" );
     }
@@ -444,13 +444,13 @@ public class MarkdownParserTest
               "listItem", "link", "text", "link_", "listItem_", // second section 2 TOC entry
               "list_", // TOC end
               "text",
-              "section1", "sectionTitle1", "text", "sectionTitle1_",
+              "section1", "sectionTitle1", "link", "text", "link_", "sectionTitle1_",
               "section2",
-              "section3", "sectionTitle3", "text", "sectionTitle3_",
+              "section3", "sectionTitle3", "link", "text", "link_", "sectionTitle3_",
               "section3_",
               "section2_",
               "section1_",
-              "section1", "sectionTitle1", "text", "sectionTitle1_",
+              "section1", "sectionTitle1", "link", "text", "link_", "sectionTitle1_",
               "section1_",
               "body_" );
     }