markmap-html-parser
Advanced tools
Comparing version 0.15.9-alpha.5 to 0.15.9-alpha.6
@@ -23,2 +23,3 @@ import { IPureNode } from 'markmap-common'; | ||
comments?: string[]; | ||
data?: Record<string, unknown>; | ||
} | ||
@@ -25,0 +26,0 @@ export interface IHtmlParserOptions { |
@@ -65,6 +65,6 @@ "use strict"; | ||
if (child.type === "comment") { | ||
const data = child.data.trim(); | ||
if (data.startsWith(MARKMAP_COMMENT_PREFIX)) { | ||
const data2 = child.data.trim(); | ||
if (data2.startsWith(MARKMAP_COMMENT_PREFIX)) { | ||
node.comments || (node.comments = []); | ||
node.comments.push(data.slice(MARKMAP_COMMENT_PREFIX.length).trim()); | ||
node.comments.push(data2.slice(MARKMAP_COMMENT_PREFIX.length).trim()); | ||
$(child).remove(); | ||
@@ -74,2 +74,6 @@ } | ||
}); | ||
const data = $el.data(); | ||
if (data && Object.keys(data).length) { | ||
node.data = data; | ||
} | ||
node.html = (($el.is(options.selectorPreserveTag) ? $.html($el) : $el.html()) || "").trimEnd(); | ||
@@ -156,7 +160,12 @@ }); | ||
}; | ||
if (htmlNode.data) { | ||
node.payload = { | ||
...htmlNode.data | ||
}; | ||
} | ||
if (htmlNode.comments) { | ||
if (htmlNode.comments.includes("foldAll")) { | ||
node.payload = { fold: 2 }; | ||
node.payload = { ...node.payload, fold: 2 }; | ||
} else if (htmlNode.comments.includes("fold")) { | ||
node.payload = { fold: 1 }; | ||
node.payload = { ...node.payload, fold: 1 }; | ||
} | ||
@@ -163,0 +172,0 @@ } |
{ | ||
"name": "markmap-html-parser", | ||
"version": "0.15.9-alpha.5+c64866f", | ||
"version": "0.15.9-alpha.6+ccc1c15", | ||
"description": "Parse HTML into markmap data structure", | ||
@@ -44,3 +44,3 @@ "author": "Gerald <gera2ld@live.com>", | ||
"devDependencies": { | ||
"markmap-common": "0.15.9-alpha.5+c64866f" | ||
"markmap-common": "0.15.9-alpha.6+ccc1c15" | ||
}, | ||
@@ -64,3 +64,3 @@ "dependencies": { | ||
}, | ||
"gitHead": "c64866fb4873a99923be18ea70715aa49a6dabef" | ||
"gitHead": "ccc1c157905c0a8aedbadcb579a79d7114b45b0b" | ||
} |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
503134
14336