You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by kw...@apache.org on 2024/10/08 13:25:33 UTC
(maven-doxia) branch bugfix/md-heading-at-beginning-of-line created (now 90746f5b)
This is an automated email from the ASF dual-hosted git repository.
kwin pushed a change to branch bugfix/md-heading-at-beginning-of-line
in repository https://gitbox.apache.org/repos/asf/maven-doxia.git
at 90746f5b [DOXIA-747] Emit headings at beginning of line for Markdown
This branch includes the following new commits:
new 90746f5b [DOXIA-747] Emit headings at beginning of line for Markdown
The 1 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.
(maven-doxia) 01/01: [DOXIA-747] Emit headings at beginning of line for Markdown
Posted by kw...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
kwin pushed a commit to branch bugfix/md-heading-at-beginning-of-line
in repository https://gitbox.apache.org/repos/asf/maven-doxia.git
commit 90746f5bb417757c719359a03903933bbc5b51bd
Author: Konrad Windszus <kw...@apache.org>
AuthorDate: Tue Oct 8 15:25:23 2024 +0200
[DOXIA-747] Emit headings at beginning of line for Markdown
---
.../apache/maven/doxia/module/markdown/MarkdownSink.java | 1 +
.../maven/doxia/module/markdown/MarkdownSinkTest.java | 15 +++++++++++++++
2 files changed, 16 insertions(+)
diff --git a/doxia-modules/doxia-module-markdown/src/main/java/org/apache/maven/doxia/module/markdown/MarkdownSink.java b/doxia-modules/doxia-module-markdown/src/main/java/org/apache/maven/doxia/module/markdown/MarkdownSink.java
index 80fb936c..91dceae9 100644
--- a/doxia-modules/doxia-module-markdown/src/main/java/org/apache/maven/doxia/module/markdown/MarkdownSink.java
+++ b/doxia-modules/doxia-module-markdown/src/main/java/org/apache/maven/doxia/module/markdown/MarkdownSink.java
@@ -409,6 +409,7 @@ public class MarkdownSink extends AbstractTextSink implements MarkdownMarkup {
@Override
public void sectionTitle(int level, SinkEventAttributes attributes) {
if (level > 0) {
+ ensureBeginningOfLine();
writeUnescaped(StringUtils.repeat(SECTION_TITLE_START_MARKUP, level) + SPACE);
}
}
diff --git a/doxia-modules/doxia-module-markdown/src/test/java/org/apache/maven/doxia/module/markdown/MarkdownSinkTest.java b/doxia-modules/doxia-module-markdown/src/test/java/org/apache/maven/doxia/module/markdown/MarkdownSinkTest.java
index f98d7b9a..44d1162e 100644
--- a/doxia-modules/doxia-module-markdown/src/test/java/org/apache/maven/doxia/module/markdown/MarkdownSinkTest.java
+++ b/doxia-modules/doxia-module-markdown/src/test/java/org/apache/maven/doxia/module/markdown/MarkdownSinkTest.java
@@ -498,4 +498,19 @@ public class MarkdownSinkTest extends AbstractSinkTest {
assertEquals(expected, getSinkContent(), "Wrong inline code!");
}
+
+ @Test
+ public void testHeadingAfterInlineElement() {
+ try (final Sink sink = getSink()) {
+ sink.text("Text");
+ sink.section1();
+ sink.sectionTitle1();
+ sink.text("Section1");
+ sink.sectionTitle1_();
+ sink.section1_();
+ }
+ // heading must be on a new line
+ String expected = "Text" + EOL + "# Section1" + EOL + EOL;
+ assertEquals(expected, getSinkContent(), "Wrong heading after inline element!");
+ }
}