You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
How to write custom Extension with nested elements #850
Hi, i have written an extension and this works fine until i have nested elements.
Currently i am struggling to understand how it should be implemented properly.
I see that my issue is how i take the content out and render it, but i dont understand how it should be done properly.
Many thanks for suggestions and help.
There are not so many inline parsers that support nested elements (with their own parsing/rendering rules). You would have to look at examples in the code inheriting from IPostInlineProcessor (e.g. EmphasisInlineParser, or SmartyPantsInlineParser...) but none are easy to grasp. The idea is that you have to create pseudo-inline "marker" elements that delemit opening/closing during InlineParser.Match that insert them into the syntax tree, and then you process them once the paragraph is done (via IPostInlineProcessor.Process) and you recover opening/closing inlines, and replace them with proper inline containers. Unfortunately, it's not easy. You would have to dig into existing inline parsers that support this and figure this out.
Activity
xoofx commentedon Mar 13, 2025
There are not so many inline parsers that support nested elements (with their own parsing/rendering rules). You would have to look at examples in the code inheriting from
IPostInlineProcessor(e.g.EmphasisInlineParser, orSmartyPantsInlineParser...) but none are easy to grasp. The idea is that you have to create pseudo-inline "marker" elements that delemit opening/closing duringInlineParser.Matchthat insert them into the syntax tree, and then you process them once the paragraph is done (viaIPostInlineProcessor.Process) and you recover opening/closing inlines, and replace them with proper inline containers. Unfortunately, it's not easy. You would have to dig into existing inline parsers that support this and figure this out.