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

AST #239

Merged
merged 12 commits into from
Oct 11, 2024
Merged

AST #239

merged 12 commits into from
Oct 11, 2024

Conversation

Andrew-Morozko
Copy link
Contributor

@Andrew-Morozko Andrew-Morozko commented Sep 6, 2024

Partial switch to AST:

  • Plugins have the ability to return ast content (see stixview)
  • Printers (to be renamed to formatters) handle custom nodes and incorrect nodes (i.e. raw html in pdf printer) and replace them with error messages

What's left to do:

  • Plugins can return custom blocks and custom inline elements (an arbitrary protobuf message inside of the AST)
  • Formatters can declare and expect custom protobuf messages to be returned to them inside the AST (i.e. RawLaTeX)
  • Plugins can declare custom protobuf messages and provide custom RPC format functions for them (they would be called to translate plugin's protobuf message to the set of messages that could be used by the formatter)

I truly am sorry for another huge PR, even though I split this feature in two pieces it still got away from me 😭

@traut traut mentioned this pull request Sep 28, 2024
Copy link
Contributor

@anasmuhmd anasmuhmd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whew! Thank you! @Andrew-Morozko

c = c.NextSibling()
default:
n.ReplaceChild(n, c, repl)
c = repl
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be c = repl.NextSibling() ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's intentional, added a comment and a limit on recursive replacements.

This allows replacer to be a pure function for replacement logic like
Node A needs to be replaced by CustomRendererA
Node B needs to be replaced by CustomRendererB

CustomRendererA may replace Node A with Node B, or include Node B in one of the children. We don't know what custom renderers may do. Speaking of this, added the ability to return errors from replacers, useful when remote plugins are in play.

@Andrew-Morozko Andrew-Morozko merged commit a10d378 into main Oct 11, 2024
6 checks passed
@Andrew-Morozko Andrew-Morozko deleted the custom-ast branch October 11, 2024 00:27
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.

3 participants