feat(md-loader): support html

This commit is contained in:
07akioni 2019-10-30 16:22:49 +08:00
parent ad76b5736e
commit 52a58fa727

View File

@ -44,22 +44,20 @@ function getPartsOfDemo (tokens) {
let script = null
let style = null
let title = null
let content = null
// let content = null
const contentTokens = []
contentTokens.links = tokens.links
for (const token of tokens) {
if (token.type === 'heading' && token.depth === 1) {
title = token.text
}
if (token.type === 'paragraph') {
content = token.text
}
if (token.type === 'code' && (token.lang === 'template' || token.lang === 'html')) {
} else if (token.type === 'code' && (token.lang === 'template' || token.lang === 'html')) {
template = token.text
}
if (token.type === 'code' && (token.lang === 'script' || token.lang === 'js')) {
} else if (token.type === 'code' && (token.lang === 'script' || token.lang === 'js')) {
script = token.text
}
if (token.type === 'code' && (token.lang === 'style' || token.lang === 'css')) {
} else if (token.type === 'code' && (token.lang === 'style' || token.lang === 'css')) {
style = token.text
} else {
contentTokens.push(token)
}
}
return {
@ -67,7 +65,7 @@ function getPartsOfDemo (tokens) {
script: script,
style: style,
title: title,
content: content
content: marked.parser(contentTokens)
}
}
@ -143,7 +141,7 @@ function convertMd2Demo (text) {
module.exports = convertMd2Demo
// const startTime = new Date()
// for (let i = 0; i < 100; ++i) {
// const md = fs.readFileSync('./marked/basic.md').toString()
// const md = fs.readFileSync('./demo/documentation/components/input/enUS/lazyFocus.md').toString()
// convertMd2Demo(md)
// }
// const endTime = new Date()