支持多行注释文本的渲染;优化函数高亮
parent
bcfdacce70
commit
9c78c80bc8
|
@ -20,8 +20,9 @@ const BUILDIN2 =
|
|||
/\b(Object|String|Array|Boolean|Number|Function|class|Promise|Map|Set|WeakMap|WeakSet|URL)\b/g
|
||||
const STR = /(['"`])(.*?)(?<!\\)\1/g
|
||||
const NUM = /\b(\d+)\b/g
|
||||
const FN = /([\.\s])([a-zA-Z$][\da-zA-Z_]*)(\(.*?\))/g
|
||||
const CM = /(?=\s)?([ ]*\/\/.*)|(^\/\/.*)/g
|
||||
const FN = /([\.\s])([a-zA-Z$_#][\da-zA-Z_]*)\s?(\(.*?\)?)/g
|
||||
const CM1 = /(?=\s)?([ ]*\/\/.*)|(^\/\/.*)/g
|
||||
const CM2 = /\/\*([\w\W]*?)\*\//g
|
||||
const EXP = /([=\(][ ]*)\/(.+?)\/([gmi]*)/g
|
||||
const INLINE = {
|
||||
code: /`([^`]*?[^`\\\s])`/g,
|
||||
|
@ -51,7 +52,7 @@ function parseJs(code) {
|
|||
}`
|
||||
})
|
||||
.replace(FN, '$1[fn]$2[/fn]$3')
|
||||
.replace(KEYWOWRD1, '[key]$1[/key]')
|
||||
.replace(KEYWOWRD1, '[key]<em>$1</em>[/key]')
|
||||
.replace(KEYWOWRD2, ' [key]$1[/key] ')
|
||||
.replace(KEYWOWRD3, '[key]$1[/key]')
|
||||
.replace(BUILDIN1, '[num]<em>$1</em>[/num]')
|
||||
|
@ -67,7 +68,7 @@ function parseJs(code) {
|
|||
|
||||
return `[cm]${pun}[/cm][str]${str}[/str][cm]${pun}[/cm]`
|
||||
})
|
||||
.replace(CM, (m, str) => {
|
||||
.replace(CM1, (m, str) => {
|
||||
str = str
|
||||
.replace(/\[(\w+)\](.*?)\[\/\1\]/g, '$2')
|
||||
.replace(/&/g, '&')
|
||||
|
@ -75,6 +76,16 @@ function parseJs(code) {
|
|||
.replace(/>/g, '>')
|
||||
return `[cm]${str}[/cm]`
|
||||
})
|
||||
.replace(CM2, (m, str) => {
|
||||
str = str
|
||||
.replace(/\[(\w+)\](.*?)\[\/\1\]/g, '$2')
|
||||
.replace(/&/g, '&')
|
||||
.replace(/</g, '<')
|
||||
.replace(/>/g, '>')
|
||||
|
||||
str = `/*${str}*/`.split('\n').map(s => `[cm]${s}[/cm]`)
|
||||
return str.join('\n')
|
||||
})
|
||||
}
|
||||
|
||||
function rebuild(code) {
|
||||
|
|
|
@ -80,7 +80,6 @@
|
|||
.scroll {
|
||||
overflow: hidden;
|
||||
flex: 1;
|
||||
padding: 5px 0 0;
|
||||
line-height: 20px;
|
||||
font-size: 14px;
|
||||
color: var(--color-dark-1);
|
||||
|
|
Reference in New Issue