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 2020/03/08 20:47:44 UTC
[maven-doxia] 01/01: [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 4d2c04e3db0ecc4641b336ce3af26fafa1b806dd
Author: Sylwester Lachiewicz <sl...@apache.org>
AuthorDate: Fri Feb 7 08:46:58 2020 +0100
[DOXIA-568] Enable ANCHORLINKS extension
---
.../maven/doxia/module/markdown/MarkdownParser.java | 9 ++++++---
.../doxia/module/markdown/MarkdownParserTest.java | 18 ++++++++++++------
2 files changed, 18 insertions(+), 9 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 f40e123..a00adda 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
@@ -134,15 +134,18 @@ public class MarkdownParser
throws IOException
{
String text = IOUtil.toString( source );
- MutableDataHolder flexmarkOptions = PegdownOptionsAdapter.flexmarkOptions(
- Extensions.ALL & ~( Extensions.HARDWRAPS | Extensions.ANCHORLINKS ) ).toMutable();
+
ArrayList<Extension> extensions = new ArrayList<>();
+
+ MutableDataHolder flexmarkOptions = PegdownOptionsAdapter
+ .flexmarkOptions( Extensions.ALL & ~( Extensions.HARDWRAPS ) )
+ .toMutable();
for ( Extension extension : flexmarkOptions.get( com.vladsch.flexmark.parser.Parser.EXTENSIONS ) )
{
extensions.add( extension );
}
-
extensions.add( FlexmarkDoxiaExtension.create() );
+
flexmarkOptions.set( com.vladsch.flexmark.parser.Parser.EXTENSIONS, extensions );
flexmarkOptions.set( HtmlRenderer.HTML_BLOCK_OPEN_TAG_EOL, false );
flexmarkOptions.set( HtmlRenderer.HTML_BLOCK_CLOSE_TAG_EOL, 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 861dc9f..7149879 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,4 @@
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 +26,13 @@ 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.Iterator;
+import java.util.List;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+
/**
* Tests for {@link MarkdownParser}.
*
@@ -361,6 +362,11 @@ public class MarkdownParserTest
}
}
+ public void testTocMacro2() throws IOException, ParseException
+ {
+ String html = parseFileToHtml( "macro-toc" );
+ assertTrue( html.contains( "<!-- MACRO{toc|fromDepth=1|toDepth=2} -->" ) );
+ }
/** @throws Exception */
public void testTocMacro()
throws Exception