I have trouble to use the highlighted lines and showLineNumbers feature.
```js {1,3-4} showLineNumbers
function fancyAlert(arg) {
if (arg) {
$.facebox({ div: '#foo' })
}
}
```
In general the line numbers work, if I force showLineNumbers on plugin creation. I'm using next-mdx-remote.
I played around a little bit and build myself a small plugin that prints the HAST before rehype-prism-plus is executed. I'm not a rehype or remark expert at all! This is what my HAST looks like:
{
type: 'element',
tagName: 'code',
properties: {
className: [ 'language-js' ],
metastring: '{1,3-4} showLineNumbers',
'{1,3-4}': true,
showLineNumbers: true
},
children: [
{
type: 'text',
value: 'function fancyAlert(arg) {\n' +
' if (arg) {\n' +
" $.facebox({ div: '#foo' })\n" +
' }\n' +
'}\n'
}
],
position: {
start: { line: 6, column: 1, offset: 40 },
end: { line: 12, column: 4, offset: 150 }
}
}
The issue seems to be, that a property called data is expected that should contain the meta, but instead I have a metastring property as part of properties.
I have no idea if that problem is on my side, or incompatible packages, or if we should just fix it here (by supporting both).
For now I solve this using a plugin on my side, that I run before this plugin:
const fixMetaPlugin = (options = {}) => {
return (tree) => {
visit(tree, 'element', visitor);
};
function visitor(node, index, parent) {
if (!parent || parent.tagName !== 'pre' || node.tagName !== 'code') {
return;
}
node.data = { ...node.data, meta: node.properties.metastring };
}
};
I have trouble to use the highlighted lines and
showLineNumbersfeature.In general the line numbers work, if I force
showLineNumberson plugin creation. I'm usingnext-mdx-remote.I played around a little bit and build myself a small plugin that prints the HAST before
rehype-prism-plusis executed. I'm not a rehype or remark expert at all! This is what my HAST looks like:The issue seems to be, that a property called
datais expected that should contain themeta, but instead I have ametastringproperty as part ofproperties.I have no idea if that problem is on my side, or incompatible packages, or if we should just fix it here (by supporting both).
For now I solve this using a plugin on my side, that I run before this plugin: