Skip to content

Commit

Permalink
Removed extra line in source blocks
Browse files Browse the repository at this point in the history
See #66
  • Loading branch information
bodiam committed Apr 11, 2024
1 parent bbe77df commit 79fa4bc
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 4 deletions.
4 changes: 0 additions & 4 deletions src/main/java/nl/jworks/markdown_to_asciidoc/Converter.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ public static void main(String[] args) {

public static String convertMarkdownToAsciiDoc(String markdown) {
PegDownProcessor processor = new PegDownProcessor(Extensions.ALL);
// insert blank line before fenced code block if necessary
if (markdown.contains("```")) {
markdown = markdown.replaceAll("(?m)(?<!\n\n)(\\s*)```(\\w*\n)((?:\\1[^\n]*\n)+)\\1```", "\n$1```$2$3$1```");
}
char[] markDown = markdown.toCharArray();
RootNode rootNode = processor.parseMarkdown(markDown);
return new ToAsciiDocSerializer(rootNode, markdown).toAsciiDoc();
Expand Down
33 changes: 33 additions & 0 deletions src/test/resources/nl/jworks/markdown_to_asciidoc/code.feature
Original file line number Diff line number Diff line change
Expand Up @@ -120,3 +120,36 @@ Feature: Code
We defined the `add` function to
"""

Scenario: Render no extra lines
Given the Markdown source
"""
foo
```kotlin
println("bar")
```
baz
```kotlin
println("bam")
```
"""
When it is converted to AsciiDoc
Then the result should match the AsciiDoc source
"""
foo
[source,kotlin]
----
println("bar")
----
baz
[source,kotlin]
----
println("bam")
----
"""

0 comments on commit 79fa4bc

Please sign in to comment.