[Question] AST transformation for duplicating TypeScript blocks as JavaScript #399
Unanswered
amirhhashemi
asked this question in
Q&A
Replies: 1 comment
-
|
Hello! We are moving feature requests and support questions to discussions and using issues only for bugs to help better track those going forward. See you in the Discussions tab! |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hey! I’m trying to add a feature to a documentation website where a JavaScript version of each TypeScript code block is automatically generated, and the user can toggle between them.
The idea is that every TypeScript code block should be immediately followed by its automatically generated JavaScript equivalent. Then, I can hide one of them with CSS depending on which version the user wants to see.
I’m struggling to figure out how to manipulate the AST to achieve this. For internal reasons, I can’t use a Remark plugin, so I’d like to implement this as an Expressive Code plugin.
For example, given this input HTML (the
figureandfigcaptionelements are added by the frames plugin):I want it transformed into this:
The second code block should behave exactly like any other Expressive Code block.
I’ve tried using the
postprocessRenderedBlockGrouphook, where I have access torenderedGroupContents. However, I can’t figure out how to determine the position of each code block so I can insert the corresponding JS version.Beta Was this translation helpful? Give feedback.
All reactions