INNER CODE UNIT · JavaScript

collectJsxCleanup

tradingview/lightweight-charts · website/plugins/docs-markdown/index.js:399

function collectJsxCleanup(node, ctx) {
	const outer = nodeOffsets(node);
	if (outer === null) {
		return;
	}
	const replacement = renderMdxComponent(node, ctx.components);
	const children = node.children ?? [];
	// Either the component draws its own Markdown, or it has no children a
	// reader would see: both cases replace the element whole. (A renderer that
	// only wraps children has nothing to wrap here, and its opening delimiter
	// alone would corrupt the text.)
	if (replacement?.text !== undefined || children.length === 0) {
		ctx.edits.push({ start: outer[0], end: outer[1], text: replacement?.text });
		return;
	}
	unwrapJsxElement(node, children, outer, replacement, ctx);
}

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…