lys-markdown-parser
Advanced tools
Comparing version 3.5.1 to 3.6.0
{ | ||
"name": "lys-markdown-parser", | ||
"version": "3.5.1", | ||
"version": "3.6.0", | ||
"description": "js markdown parser", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -16,2 +16,8 @@ /** | ||
function removeAllChildren(element) { | ||
while (element.firstChild) { | ||
element.removeChild(element.firstChild); | ||
} | ||
} | ||
/** | ||
@@ -89,4 +95,21 @@ * AST 转 dom | ||
case nodeType.text: { | ||
const text = node.value; | ||
ele = document.createTextNode(text); | ||
// const text = node.value; | ||
// ele = document.createTextNode(text); | ||
ele = document.createElement('span'); | ||
ele.setAttribute('md-type', 'text-node'); | ||
node.__update = (key, newNode) => { | ||
removeAllChildren(ele); | ||
// 对纯文本节点做链接提取,提升用户体验 | ||
newNode[key].split(/([A-z]+:\/{2}\S+)/g).forEach((i, index) => { | ||
if (index % 2 === 1) { | ||
const a = document.createElement('a'); | ||
a.href = i; | ||
a.textContent = i; | ||
ele.appendChild(a); | ||
} else { | ||
ele.appendChild(document.createTextNode(i)); | ||
} | ||
}); | ||
}; | ||
node.__update('value', node); | ||
break; | ||
@@ -93,0 +116,0 @@ } |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
307013
6973