Skip to content

Replace the Tag class by a POJO to make the RenderableTreeNode serializable #490

Discussion options

You must be logged in to vote

Hey @CapitaineToinon,

Using the class is actually completely optional. You can write your transform functions in your project so that they return a POJO with the shape {$$mdtype: 'Tag', name: 'foo', attributes: {}, children: []} and it should work exactly the same way. The Tag.isTag function checks the $$mdtype property rather than looking to see if a value is a tag instance, so it will still work as expected.

I'm not really familiar with svelte or devalue, but I would assume you would be able to manually serialize the renderable tree to JSON somewhere before it hits the framework. You can just wrap JSON.stringify around the output of Markdoc.transform and then call JSON.parse on it befor…

Replies: 3 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected by mfix-stripe
Comment options

You must be logged in to vote
1 reply
@mfix-stripe
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
bug Something isn't working
3 participants
Converted from issue

This discussion was converted from issue #488 on March 08, 2024 14:46.