MCPcopy
hub / github.com/markmap/markmap / convertNode

Function convertNode

packages/markmap-html-parser/src/index.ts:254–275  ·  view source on GitHub ↗
(htmlRoot: IHtmlNode)

Source from the content-addressed store, hash-verified

252}
253
254export function convertNode(htmlRoot: IHtmlNode) {
255 return walkTree<IHtmlNode, IPureNode>(htmlRoot, (htmlNode, next) => {
256 const node: IPureNode = {
257 content: htmlNode.html,
258 children: next() || [],
259 };
260 if (htmlNode.data) {
261 node.payload = {
262 tag: htmlNode.tag,
263 ...htmlNode.data,
264 };
265 }
266 if (htmlNode.comments) {
267 if (htmlNode.comments.includes('foldAll')) {
268 node.payload = { ...node.payload, fold: 2 };
269 } else if (htmlNode.comments.includes('fold')) {
270 node.payload = { ...node.payload, fold: 1 };
271 }
272 }
273 return node;
274 });
275}
276
277export function buildTree(html: string, opts?: Partial<IHtmlParserOptions>) {
278 const htmlRoot = parseHtml(html, opts);

Callers 2

index.test.tsFile · 0.90
buildTreeFunction · 0.85

Calls 1

walkTreeFunction · 0.90

Tested by

no test coverage detected