Skip to content

Commit

Permalink
Handle single space at the end of a list item
Browse files Browse the repository at this point in the history
Also makes tests execute cleanly on Windows

Closes #32
  • Loading branch information
ahus1 committed Jul 29, 2022
1 parent dea2774 commit 1b69856
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -445,8 +445,8 @@ class ToAsciiDocSerializerKt @JvmOverloads constructor(private var rootNode: Roo
val len = children.size
while (i < len) {
val c = children[i]
if (c is RootNode) {
children[i] = c.getChildren()[0]
if (c is RootNode && c.children.size == 1) {
children[i] = c.children[0]
} else if (c.javaClass == SuperNode::class.java && c.children.size == 1) {
children[i] = c.children[0]
}
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/nl/jworks/markdown_to_asciidoc/Stepdefs.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ public void the_markdown_source(String markdown) throws Throwable {
@When("^it is converted to AsciiDoc")
public void it_is_converted_to_asciidoc() throws Throwable {
// Express the Regexp above with the code you wish you had
this.asciiDoc = Converter.convertMarkdownToAsciiDoc(markdown);
this.asciiDoc = Converter.convertMarkdownToAsciiDoc(markdown.replaceAll("\r\n", "\n"));
}

@Then("^the result should match the AsciiDoc source$")
public void the_result_should_match_the_asciidoc_source(String result) throws Throwable {
// Express the Regexp above with the code you wish you had

assertEquals(result, asciiDoc);
assertEquals(result.replaceAll("\r\n", "\n"), asciiDoc.replaceAll("\r\n", "\n"));

}
}
11 changes: 11 additions & 0 deletions src/test/resources/nl/jworks/markdown_to_asciidoc/lists.feature
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,17 @@ Feature: Lists
* https://github.com/geb/geb-example-maven[http://github.com/geb/geb-example-maven]
"""

Scenario: Render a list item that ends with a blank
Given the Markdown source
"""
-{sp}
"""
When it is converted to AsciiDoc
Then the result should match the AsciiDoc source
"""
*
"""

#@@knownissue This doesn't work. Item 4 is contains 3 para nodes instead of a code block
# Scenario: Render 4 numbered items with a code block
# Given the Markdown source
Expand Down

0 comments on commit 1b69856

Please sign in to comment.