flexmark-java icon indicating copy to clipboard operation
flexmark-java copied to clipboard

Concat words without splitter when more then one `\n` provided

Open nikialeksey opened this issue 6 years ago • 5 comments

To Reproduce

String raw = new TextCollectingVisitor().collectAndGetText(
    Parser.builder().build().parse("Hello\n\nworld")
);
System.out.println(raw); // Helloworld

Expected behavior System.out.println(raw);

Hello

world

nikialeksey avatar Dec 09 '18 12:12 nikialeksey

@nikialeksey, the old use case was limited to extracting inline nodes, which I agree is useless for the general case.

The next release has this fixed so you will get the result you are looking for and there is also a TableTextCollectingVisitor which extends text collecting visitor to extract table header and body columns, adds line breaks after table rows and a blank line after each table.

I will be making a release in short order.

vsch avatar Dec 10 '18 15:12 vsch

@nikialeksey, fix for this is available. Repo updated, maven updated but may take a while to show up in maven central.

vsch avatar Dec 11 '18 01:12 vsch

@vsch Cool! I will check it today. Thanks!

nikialeksey avatar Dec 11 '18 03:12 nikialeksey

@vsch Works correclty! Thanks for the fast response.

nikialeksey avatar Dec 11 '18 04:12 nikialeksey

@vsch Hi!

Reproduced again on a version 0.62.2, but with other inputs:

val raw = TextCollectingVisitor().collectAndGetText(
    Parser.builder().build().parse("## Hello\n\n## world")
)
println(raw) // Helloworld

Expected:

Hello

world

nikialeksey avatar Oct 04 '21 15:10 nikialeksey