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:21:00 UTC

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

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_" );
     }