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/06/03 22:29:28 UTC

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

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 3e0b52b  [DOXIA-568] Enable ANCHORLINKS extension
 discard 490ba7a  [DOXIA-568] Introduce AssertJ
     add 587212b  remove unused code
     add 80e16ac  replace deprecated class from commons-lang (#65)
     add 382491c  fill in some generic types (#66)
     new a1173cc  [DOXIA-568] Introduce AssertJ
     new ac56af2  [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   (3e0b52b)
            \
             N -- N -- N   refs/heads/DOXIA-568 (ac56af2)

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:
 doxia-core/pom.xml                                 |  5 ++
 .../org/apache/maven/doxia/util/HtmlTools.java     |  2 +-
 .../apache/maven/doxia/module/itext/ITextSink.java | 13 -----
 .../doxia/module/itext/SinkActionContext.java      |  2 -
 .../org/apache/maven/doxia/module/rtf/RtfSink.java | 59 ++++++++++------------
 .../apache/maven/doxia/module/rtf/WMFWriter.java   |  4 +-
 6 files changed, 36 insertions(+), 49 deletions(-)

[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 a1173cc9ad00a8c5dd08ea026e35e699f0aabce2
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 cbfc95d..b5285ff 100644
--- a/doxia-core/pom.xml
+++ b/doxia-core/pom.xml
@@ -86,6 +86,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 ac56af27c9231be361aac49b6a51917b0ca0bb61
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_" );
     }