Skip to content

Inconsistent TextCollectingVisitor behaviour with code blocks #574

@roxspring

Description

@roxspring

The TextCollectingVisitor appears to have inconsistent behaviour with IndentedCodeBlock vs FencedCodeBlock.
The former doesn't have its text collected at all while the latter does but drops line breaks before hand.

To reproduce, run the following code using version 0.64.4:

final String markdown = "" +
    "Introductory para:\n" +
    "\n" +
    "```\n" +
    "Fenced\n" +
    "```\n" +
    "\n" +
    "    Indented\n" +
    "\n";
String text = new TextCollectingVisitor().collectAndGetText(Parser.builder().build().parse(markdown));
System.out.println(text);

The surprising result of this is to print out the following, notably with Fenced coalesced onto the previous line and Indented omitted entirely:

Introductory para:Fenced

I would expect that the TextCollectingVisitor would both pieces of text, with newlines intact:

Introductory para:

Fenced

Indented

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions