* To prevent unified from parsing any content of the code string we inject * it as a raw text node into the AST tree as a child of the code element
(rawCodeString: string)
| 75 | * it as a raw text node into the AST tree as a child of the code element |
| 76 | */ |
| 77 | function injectRawCodeStringPlugin(rawCodeString: string) { |
| 78 | return () => (tree: Root) => { |
| 79 | visit(tree, 'element', (node: Element) => { |
| 80 | if (node.tagName === 'code') { |
| 81 | node.children.push({ |
| 82 | type: 'text', |
| 83 | value: rawCodeString, |
| 84 | }) |
| 85 | } |
| 86 | }) |
| 87 | } |
| 88 | } |