Replies: 1 comment 2 replies
-
Our perspective on this is that the fence is the standard CommonMark way to indicate unprocessed content in a Markdown document, so we're reluctant to support literal text in any arbitrary tag as it would create a lot of interoperability challenges with other parts of the Markdown ecosystem. We also really prefer to avoid having any schema dependencies inside of the parser, we want to be able to do the parse step without having any awareness of what tags the user has defined, and it would be hard to do that if we made it so that certain tags accepted literal bodies.
Yes, I agree that the current steps that you have to take to implement a custom fence processor are cumbersome, add unnecessary complexity, and have very poor composability. I think it'd make sense to have a better extensibility model around this — a dedicated way to register individual fenced block types without having to put a bunch of conditional statements in a single fence transform function. We could perhaps come up with a hybrid approach where we make fences behave more like tags while remaining aligned with the CommonMark syntax. Maybe instead of just allowing annotations in the fence info line, we allow it to be a named tag, in which case that tag gets the literal content. e.g.:
And then you could register a We'd need to figure out what the behavior is around processing markdoc tags within the fence. Right now, the literal text still gets parsed for Markdoc tags unless the fence is annotated with |
Beta Was this translation helpful? Give feedback.
-
The builtin node "fence" has no children and its content is stored in attributes.content without and process.
Such behaviour would be useful for creating custom nodes, especially for rendering other syntax, e.g. LaTeX math, Mermaid diagram ...
Currently, tag children is always processed, making the content unsuitable for above cases;
Workaround is to customize
transform
of fence node as in this discussion and example below, but it would add complexity handling normal codeblock and special renderers.Beta Was this translation helpful? Give feedback.
All reactions