1import { visit } from 'unist-util-visit'; 2 3/** 4 * This simple plugin appends the code block meta to the node value. 5 */ 6export default function remarkLinkRewrite() { 7 return (tree, file) => { 8 if (!file.cwd || !file.history || !file.history.length) { 9 return; 10 } 11 12 visit(tree, 'code', node => { 13 if (node.meta) { 14 node.value = '@@@' + node.meta + '@@@' + node.value; 15 } 16 }); 17 }; 18} 19