MCPcopy Create free account
hub / github.com/scalar/scalar / injectRawCodeStringPlugin

Function injectRawCodeStringPlugin

packages/code-highlight/src/code/highlight.ts:77–88  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

75 * it as a raw text node into the AST tree as a child of the code element
76 */
77function 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}

Callers 1

syntaxHighlightFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected