lerobot/robot-learning-tutorial
508
1// Remark plugin to ignore citations inside code (block and inline)2export default function remarkIgnoreCitationsInCode() {3 return (tree) => {4 const visit = (node) => {5 if (!node || typeof node !== 'object') return;6 const type = node.type;7 if (type === 'code' || type === 'inlineCode') {8 if (typeof node.value === 'string' && node.value.includes('@')) {9 // Use a sentinel to avoid rehype-citation, will be restored later in rehype10 node.value = node.value.replace(/@/g, '__AT_SENTINEL__');11 }12 return; // do not traverse into code13 }14 const children = Array.isArray(node.children) ? node.children : [];15 children.forEach(visit);16 };17 visit(tree);18 };19}20 21 22 