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

serialize and deserialize custom nodes to JSON filters #11241

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

cscheid
Copy link
Collaborator

@cscheid cscheid commented Oct 29, 2024

Addresses #11235

Custom AST nodes are now serialized to and from JSON. This enables, for example, JSON filters to emit shortcodes, callouts, etc.

In order for JSON filters to do this well, they need to be careful about the way they consume and emit the JSON structure. This will need documentation and ideally library support.

This PR unlocks the core capability.

@cscheid
Copy link
Collaborator Author

cscheid commented Oct 29, 2024

Ah, Pandoc's Meta doesn't like to have Attr objects in it. This makes everything harder :(

@cscheid
Copy link
Collaborator Author

cscheid commented Oct 30, 2024

TODO:

  • from_json and to_json support in custom nodes

end
list:insert(inner)
end
return pandoc.MetaList(list)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Performance note: pandoc.MetaList (almost) the same as pandoc.List, the former just does a little more type correction. The latter is faster, as it's a C function.


def p_string(string):
return {
"t": "String",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should this be "t": "Str"? It seems that this function isn't used.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's been zero days since a GitHub Copilot accident.

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.

2 participants