vsch / flexmark-java

CommonMark/Markdown Java parser with source level AST. CommonMark 0.28, emulation of: pegdown, kramdown, markdown.pl, MultiMarkdown. With HTML to MD, MD to PDF, MD to DOCX conversion modules.
BSD 2-Clause "Simplified" License
2.21k stars 260 forks source link

TextCollectingVisitor works better with code blocks #575

Closed roxspring closed 1 year ago

roxspring commented 1 year ago

Changes, with unit tests where appropriate:

  1. Refactored TextCollectingVisitor to avoid duplicate code
  2. TextContainer has a new collectEndText(..) method allowing Paragraph to append it's optional trailing line break
  3. Consistently add a blank line before all (non-first) Block text (implicitly including FencedCodeBlock, no longer relying on Paragraph special case)
  4. IndentedCodeBlock implements TextContainer and collects content chars.

Closes #574

vsch commented 1 year ago

@roxspring, thank you for the PR. I reviewed the changes and will merge it and make a new release.