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

Add Text() retrieval for BaseBlock types #460

Merged
merged 2 commits into from
Oct 12, 2024

Conversation

cbednarski
Copy link
Contributor

I was trying to use the ast to parse code blocks, and noticed that Text() was always returning empty data.

After digging into this a bit I discovered that the BaseNode type only retrieves Text from child nodes. However, the BaseBlock type (used for code and fenced code blocks) does not have children. Instead, it needs its own Text() implementation to enumerate Lines() to retrieve the text segment(s) identified during parsing.

If you would like to verify that the code change resolves the issue, please comment out the new code in ast/block.go and run the tests.

I've also verified this fix against the test program included in #459.

Thanks!

Closes #459

This implementation was missing, making it impossible to retrieve Text
from block types, such as CodeBlock and FencedCodeBlock, via the ast
interface.
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.

ast: Empty Text() from code blocks
2 participants