MCPcopy
hub / github.com/nhn/tui.editor / codeBlock

Function codeBlock

apps/editor/src/markdown/htmlRenderConvertors.ts:85–108  ·  view source on GitHub ↗
(node: MdNode)

Source from the content-addressed store, hash-verified

83 },
84
85 codeBlock(node: MdNode) {
86 const { fenceLength, info } = node as CodeBlockMdNode;
87 const infoWords = info ? info.split(/\s+/) : [];
88 const preClasses = [];
89 const codeAttrs: TokenAttrs = {};
90
91 if (fenceLength > 3) {
92 codeAttrs['data-backticks'] = fenceLength;
93 }
94 if (infoWords.length > 0 && infoWords[0].length > 0) {
95 const [lang] = infoWords;
96
97 preClasses.push(`lang-${lang}`);
98 codeAttrs['data-language'] = lang;
99 }
100
101 return [
102 { type: 'openTag', tagName: 'pre', classNames: preClasses },
103 { type: 'openTag', tagName: 'code', attributes: codeAttrs },
104 { type: 'text', content: node.literal! },
105 { type: 'closeTag', tagName: 'code' },
106 { type: 'closeTag', tagName: 'pre' },
107 ];
108 },
109
110 customInline(node: MdNode, { origin, entering, skipChildren }: Context) {
111 const { info } = node as CustomInlineMdNode;

Callers

nothing calls this directly

Calls 2

splitMethod · 0.65
pushMethod · 0.65

Tested by

no test coverage detected