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

Refactor of AST traversal method #944

Conversation

abelsromero
Copy link
Member

@abelsromero abelsromero commented Oct 14, 2024

Thank you for opening a pull request and contributing to asciidoctor-maven-plugin!

What kind of change does this PR introduce? (check at least one)

  • Bugfix
  • Feature
  • Documentation
  • Refactor
  • Build improvement
  • Other (please describe)

What is the goal of this pull request?

Solve limitations in the current method used to traverse the AST.
Currently, we explored all nodes in a loop in NodeSinker that already showed issues with nested elements that need to generate content "around" nodes, like lists. That forced to have specific loops for such elements.
The new method does not look externally (outside of NodeProcessors) but instead injects NodeSinker in the NodeProcessors so each one decides if further traversal needs to happen. This has simplified the code notably and removes the need for specific dependency injection.
Now all NodeProcessors are instantiated and stored in NodeSinker without special cases.

Are there any alternative ways to implement this?

Probably, so far this works 😄

Are there any implications of this pull request? Anything a user must know?

There are some changes in how HTML content is generated:

  • Empty document no longer generated empty <h1></h1>
  • Empty literal no longer generated empty <pre></pre>
  • Sections are now wrapped around <div> elements for better organization.
  • Fixed Listing blocks outputting content instead of source

Is it related to an existing issue?

  • Yes
  • No

But it's related to this PR #938

Finally, please add a corresponding entry to CHANGELOG.adoc

@abelsromero abelsromero changed the title Make traversal part of NodeProcessor Refactor of AST traversal method Oct 18, 2024
@abelsromero abelsromero marked this pull request as ready for review October 18, 2024 20:40
@abelsromero abelsromero force-pushed the branch-main/refactor-AST-traversal-in-parser-doxia-module branch from c30eed8 to 620a81d Compare October 18, 2024 21:41
@abelsromero abelsromero force-pushed the branch-main/refactor-AST-traversal-in-parser-doxia-module branch from 620a81d to 722bfb6 Compare October 18, 2024 21:44
@abelsromero abelsromero force-pushed the branch-main/refactor-AST-traversal-in-parser-doxia-module branch from 722bfb6 to 54b14d5 Compare October 18, 2024 21:58
@abelsromero abelsromero force-pushed the branch-main/refactor-AST-traversal-in-parser-doxia-module branch from 54b14d5 to 002102c Compare October 18, 2024 22:17
@abelsromero abelsromero force-pushed the branch-main/refactor-AST-traversal-in-parser-doxia-module branch from 002102c to 65502e9 Compare October 18, 2024 22:29
@abelsromero abelsromero force-pushed the branch-main/refactor-AST-traversal-in-parser-doxia-module branch from 65502e9 to 5c1fc75 Compare October 18, 2024 22:40
@abelsromero abelsromero force-pushed the branch-main/refactor-AST-traversal-in-parser-doxia-module branch from 5c1fc75 to d77ba1c Compare October 19, 2024 10:02
@abelsromero abelsromero merged commit 912de34 into asciidoctor:main Oct 19, 2024
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant