How do you use inline text elements eg, kbd
?
#483
-
I can see in the Markdoc spec that it supports inline text elements such as
However, when I try it in the markdoc sandbox, I have it working on an astro website sandbox: https://stackblitz.com/edit/github-4aoujs?file=src%2Fcontent%2Fdocs%2Fintro.mdoc,markdoc.config.mjs However, it doesn't work like the spec, as I can't get the
In markdoc
Even though it doesn't work with So the main question is, what is the proper way to set up inline text elements? Is it supposed to work with |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
The
By default, Markdoc tag attributes render out in HTML as attributes of the same name on the underlying HTML tag. In your example, the "primary" attribute in the Markdoc tag will become a literal const config = {
tags: {
kbd: {
render: 'kbd',
attributes: {
primary: { type: String },
},
transform(node, config) {
return new Markdoc.Tag(this.render, {}, node.attributes.primary);
}
}
}
}; |
Beta Was this translation helpful? Give feedback.
The
markdoc-html-tag-schemas
thing that you link is a third-party library that would have to be installed separately — Markdoc itself doesn't come with akbd
tag, so that is why it isn't recognized in the Markdoc sandbox.By default, Markdoc tag attributes render out in HTML as attributes of the same name on the underlying HTML tag. In your example, the "primary" attribute in the Markdoc tag will become a literal
primary="Ctrl"
attribute on thekbd
HTML tag in the output. In order to make an attribute's content render as the child of the node, you need to use a transfor…