Access metastring in Fence component to highlight line numbers #241
-
|
Greetings! I am trying to add the ability to highlight specific lines of code in my I need the // nodes.js
const nodes = {
...
fence: {
render: Fence,
attributes: {
language: {
type: String,
},
metastring: {
type: String,
},
},
},
...
}And then passing that to the // Fence.jsx
export function Fence({ children, language, metastring }) {
console.log(language)
console.log(metastring)
const shouldHighlightLine = calculateLinesToHighlight('{1,2,3-4}');
...But |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
|
@ian-whitestone two things: for one, there is a condition in our parser where the If you remove the space in your example, then those values will show up in the Here is a playground that demonstrates how this works: https://markdoc.dev/sandbox?mode=ast&c=YGBgezEsMy00fQpzZWxlY3QgLi4uCmBgYA%253D%253D |
Beta Was this translation helpful? Give feedback.
-
|
To pass a custom attribute to a fenced code block, use the following syntax: |
Beta Was this translation helpful? Give feedback.
-
|
Thanks @mfix-stripe and @rpaul-stripe for the quick responses! Using @rpaul-stripe 's solution worked. |
Beta Was this translation helpful? Give feedback.


To pass a custom attribute to a fenced code block, use the following syntax: