Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TextCollectingVisitor works better with code blocks #575

Merged
merged 5 commits into from May 17, 2023

Conversation

roxspring
Copy link
Contributor

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

The call was happening first irrespective of whether the node was a TextContainer so lifted this logic out of the `if` block.
It seems that currently LineBreakNode is independant of TextContainer so it seems safe to pull that out of the `if` block.
Consequently only a single new line is needed to add paragraph breaks
- Removed special case logic for Paragraph blocks
- Generalised from BlankLineBreakNode case
Implementation based on Text collectText(..) but using getContentChars()
@roxspring roxspring marked this pull request as ready for review May 17, 2023 11:12
@vsch
Copy link
Owner

vsch commented May 17, 2023

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

@vsch vsch merged commit b9bfe63 into vsch:master May 17, 2023
1 check passed
@roxspring roxspring deleted the issue-574-better-block-text-collecting branch May 18, 2023 19:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Inconsistent TextCollectingVisitor behaviour with code blocks
2 participants