优化markd解析库
parent
9c78c80bc8
commit
5c24ae9c7c
|
@ -42,7 +42,6 @@ const INLINE = {
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseJs(code) {
|
function parseJs(code) {
|
||||||
// console.log(code)
|
|
||||||
return code
|
return code
|
||||||
.replace(EXP, (m, pun, str, flag) => {
|
.replace(EXP, (m, pun, str, flag) => {
|
||||||
str = str.replace(/&/g, '&').replace(/(\\.)/g, '[fn]$1[/fn]')
|
str = str.replace(/&/g, '&').replace(/(\\.)/g, '[fn]$1[/fn]')
|
||||||
|
@ -61,6 +60,7 @@ function parseJs(code) {
|
||||||
.replace(STR, (m, pun, str) => {
|
.replace(STR, (m, pun, str) => {
|
||||||
str = str
|
str = str
|
||||||
.replace(/\[(\w+)\](.*?)\[\/\1\]/g, '$2')
|
.replace(/\[(\w+)\](.*?)\[\/\1\]/g, '$2')
|
||||||
|
.replace(/<(\/?)xmp>/g, '<$1xmp>')
|
||||||
.replace(/&/g, '&')
|
.replace(/&/g, '&')
|
||||||
.replace(/</g, '<')
|
.replace(/</g, '<')
|
||||||
.replace(/>/g, '>')
|
.replace(/>/g, '>')
|
||||||
|
@ -89,6 +89,7 @@ function parseJs(code) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function rebuild(code) {
|
function rebuild(code) {
|
||||||
|
// console.log(code)
|
||||||
return code
|
return code
|
||||||
.replace(/\[(\/?)tag\]/g, (m, s) => (s ? '</i>' : '<i class="r">'))
|
.replace(/\[(\/?)tag\]/g, (m, s) => (s ? '</i>' : '<i class="r">'))
|
||||||
.replace(/\[(\/?)attr\]/g, (m, s) => (s ? '</i>' : '<i class="b">'))
|
.replace(/\[(\/?)attr\]/g, (m, s) => (s ? '</i>' : '<i class="b">'))
|
||||||
|
|
|
@ -214,10 +214,13 @@ class Tool {
|
||||||
let attr = hideCopy ? ' hide-copy' : ''
|
let attr = hideCopy ? ' hide-copy' : ''
|
||||||
|
|
||||||
if (isCodeBlock) {
|
if (isCodeBlock) {
|
||||||
list.push('</wc-code>')
|
list.push('</xmp></wc-code>')
|
||||||
} else {
|
} else {
|
||||||
list.push(
|
list.push(
|
||||||
tmp.replace(/^```([\w\#\-]*?)$/, `<wc-code lang="$1"${attr}>`)
|
tmp.replace(
|
||||||
|
/^```([\w\#\-]*?)$/,
|
||||||
|
`<wc-code lang="$1"${attr}><xmp>`
|
||||||
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
isCodeBlock = !isCodeBlock
|
isCodeBlock = !isCodeBlock
|
||||||
|
@ -225,8 +228,7 @@ class Tool {
|
||||||
var qlink
|
var qlink
|
||||||
if (isCodeBlock) {
|
if (isCodeBlock) {
|
||||||
it = it
|
it = it
|
||||||
.replace(/</g, '<')
|
.replace(/<(\/?)([a-z][a-z\d\-]*?)([^>]*?)>/g, '<$1$2$3>')
|
||||||
.replace(/>/g, '>')
|
|
||||||
.replace('\\`\\`\\`', '```')
|
.replace('\\`\\`\\`', '```')
|
||||||
} else {
|
} else {
|
||||||
if (Helper.isTable(tmp) && !isTable) {
|
if (Helper.isTable(tmp) && !isTable) {
|
||||||
|
|
|
@ -69,6 +69,7 @@
|
||||||
flex: 1;
|
flex: 1;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
width: 100%;
|
||||||
border: 1px solid var(--color-grey-2);
|
border: 1px solid var(--color-grey-2);
|
||||||
border-radius: inherit;
|
border-radius: inherit;
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
|
@ -77,6 +78,7 @@
|
||||||
|
|
||||||
.toolbar {
|
.toolbar {
|
||||||
display: none;
|
display: none;
|
||||||
|
width: 100%;
|
||||||
height: 34px;
|
height: 34px;
|
||||||
padding: 5px;
|
padding: 5px;
|
||||||
line-height: 24px;
|
line-height: 24px;
|
||||||
|
@ -118,12 +120,14 @@
|
||||||
.editor-outbox {
|
.editor-outbox {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
display: flex;
|
display: flex;
|
||||||
|
width: 100%;
|
||||||
min-height: 300px;
|
min-height: 300px;
|
||||||
border-radius: 3px;
|
border-radius: 3px;
|
||||||
|
|
||||||
.editor,
|
.editor,
|
||||||
.preview {
|
.preview {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
|
flex-shrink: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.editor {
|
.editor {
|
||||||
|
|
Reference in New Issue