Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
basic-uniapp-v3
概览
概览
详情
活动
周期分析
版本库
存储库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
Basic
basic-uniapp-v3
Commits
4b60e641
提交
4b60e641
authored
12月 30, 2024
作者:
方治民
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: 修复 fui-parse 组件打包引入 marked 异常问题,移除 hljs、markedjs 依赖
上级
b91bebf0
显示空白字符变更
内嵌
并排
正在显示
17 个修改的文件
包含
4 行增加
和
6092 行删除
+4
-6092
firstui-code.vue
src/components/FirstUI/fui-parse/firstui-code.vue
+0
-214
fui-parse.vue
src/components/FirstUI/fui-parse/fui-parse.vue
+4
-7
highlight.code.js
...components/FirstUI/fui-parse/high-light/highlight.code.js
+0
-1207
index.js
src/components/FirstUI/fui-parse/high-light/index.js
+0
-25
c-like.js
...mponents/FirstUI/fui-parse/high-light/languages/c-like.js
+0
-286
c.js
src/components/FirstUI/fui-parse/high-light/languages/c.js
+0
-25
cpp.js
src/components/FirstUI/fui-parse/high-light/languages/cpp.js
+0
-20
css.js
src/components/FirstUI/fui-parse/high-light/languages/css.js
+0
-129
javascript.js
...ents/FirstUI/fui-parse/high-light/languages/javascript.js
+0
-245
markdown.js
...onents/FirstUI/fui-parse/high-light/languages/markdown.js
+0
-112
sql.js
src/components/FirstUI/fui-parse/high-light/languages/sql.js
+0
-164
typescript.js
...ents/FirstUI/fui-parse/high-light/languages/typescript.js
+0
-209
xml.js
src/components/FirstUI/fui-parse/high-light/languages/xml.js
+0
-149
regex.js
src/components/FirstUI/fui-parse/high-light/regex.js
+0
-133
index.js
src/components/FirstUI/fui-parse/marked/index.js
+0
-1593
marked.js
src/components/FirstUI/fui-parse/marked/lib/marked.js
+0
-1573
components.d.ts
types/components.d.ts
+0
-1
没有找到文件。
src/components/FirstUI/fui-parse/firstui-code.vue
deleted
100644 → 0
浏览文件 @
b91bebf0
<
template
>
<view
class=
"hljs"
>
<rich-text
:nodes=
"code"
space=
"nbsp"
></rich-text>
</view>
</
template
>
<
script
>
import
hljs
from
'./high-light/index.js'
// 支持的解析语言列表
const
LANGUAGE_LIST
=
[
'javascript'
,
'css'
,
'xml'
,
'sql'
,
'typescript'
,
'markdown'
,
'c++'
,
'c'
,
];
export
default
{
name
:
"firstui-audio"
,
props
:
{
codeText
:
{
type
:
String
,
default
:
''
},
language
:
{
type
:
String
,
default
:
'javascript'
}
},
data
()
{
return
{
code
:
''
};
},
created
()
{
this
.
parseCode
(
this
.
codeText
,
this
.
language
)
},
methods
:
{
parseCode
(
input
,
language
)
{
const
lang
=
LANGUAGE_LIST
.
includes
(
language
)
?
language
:
'javascript'
const
{
value
}
=
hljs
.
highlight
(
lang
,
input
)
const
highlighted
=
value
.
replace
(
'&'
,
'&'
).
trim
()
let
codeResult
=
`<code class="
${
lang
}
">
${
highlighted
}
</code>`
codeResult
=
codeResult
.
replace
(
/
\n
/g
,
"<br/>"
).
replace
(
'
\
<code
\
>'
,
''
)
this
.
code
=
codeResult
;
}
}
}
</
script
>
<
style
>
/*
Style with support for rainbow parens
*/
.hljs
{
/* #ifndef APP-NVUE */
display
:
block
;
/* #endif */
overflow-x
:
auto
;
padding
:
0.5em
;
background
:
#282c34
;
color
:
#d1d9e1
;
}
.hljs-comment
,
.hljs-quote
{
color
:
#969896
;
font-style
:
italic
;
}
.hljs-keyword
,
.hljs-selector-tag
,
.hljs-literal
,
.hljs-type
,
.hljs-addition
{
color
:
#cc99cc
;
}
.hljs-number
,
.hljs-selector-attr
,
.hljs-selector-pseudo
{
color
:
#f99157
;
}
.hljs-string
,
.hljs-doctag
,
.hljs-regexp
{
color
:
#8abeb7
;
}
.hljs-title
,
.hljs-name
,
.hljs-section
,
.hljs-built_in
{
color
:
#b5bd68
;
}
.hljs-variable
,
.hljs-template-variable
,
.hljs-selector-id
,
.hljs-class
.hljs-title
{
color
:
#ffcc66
;
}
.hljs-section
,
.hljs-name
,
.hljs-strong
{
font-weight
:
bold
;
}
.hljs-symbol
,
.hljs-bullet
,
.hljs-subst
,
.hljs-meta
,
.hljs-link
{
color
:
#f99157
;
}
.hljs-deletion
{
color
:
#dc322f
;
}
.hljs-formula
{
background
:
#eee8d5
;
}
.hljs-attr
,
.hljs-attribute
{
color
:
#81a2be
;
}
.hljs-emphasis
{
font-style
:
italic
;
}
/* #ifdef VUE3 */
:deep
(
.hljs-comment
),
:deep
(
.hljs-quote
)
{
color
:
#969896
;
font-style
:
italic
;
}
:deep
(
.hljs-keyword
),
:deep
(
.hljs-selector-tag
),
:deep
(
.hljs-literal
),
:deep
(
.hljs-type
),
:deep
(
.hljs-addition
)
{
color
:
#cc99cc
;
}
:deep
(
.hljs-number
),
:deep
(
.hljs-selector-attr
),
:deep
(
.hljs-selector-pseudo
)
{
color
:
#f99157
;
}
:deep
(
.hljs-string
),
:deep
(
.hljs-doctag
),
:deep
(
.hljs-regexp
)
{
color
:
#8abeb7
;
}
:deep
(
.hljs-title
),
:deep
(
.hljs-name
),
:deep
(
.hljs-section
),
:deep
(
.hljs-built_in
)
{
color
:
#b5bd68
;
}
:deep
(
.hljs-variable
),
:deep
(
.hljs-template-variable
),
:deep
(
.hljs-selector-id
),
:deep
(
.hljs-class
.hljs-title
)
{
color
:
#ffcc66
;
}
:deep
(
.hljs-section
),
:deep
(
.hljs-name
),
:deep
(
.hljs-strong
)
{
font-weight
:
bold
;
}
:deep
(
.hljs-symbol
),
:deep
(
.hljs-bullet
),
:deep
(
.hljs-subst
),
:deep
(
.hljs-meta
),
:deep
(
.hljs-link
)
{
color
:
#f99157
;
}
:deep
(
.hljs-deletion
)
{
color
:
#dc322f
;
}
:deep
(
.hljs-formula
)
{
background
:
#eee8d5
;
}
:deep
(
.hljs-attr
),
:deep
(
.hljs-attribute
)
{
color
:
#81a2be
;
}
:deep
(
.hljs-emphasis
)
{
font-style
:
italic
;
}
/* #endif */
</
style
>
src/components/FirstUI/fui-parse/fui-parse.vue
浏览文件 @
4b60e641
...
...
@@ -172,10 +172,8 @@
</
template
>
<
script
>
import
firstuiCode
from
'./firstui-code.vue'
import
firstuiAudio
from
'./firstui-audio.vue'
import
HtmlToJson
from
'./utils/html2json.js'
;
import
marked
from
'./marked/index.js'
import
util
from
'./utils/util.js'
;
const
BIND_NAME
=
'fuiParse'
export
default
{
...
...
@@ -187,7 +185,6 @@
}
},
components
:
{
firstuiCode
,
firstuiAudio
},
props
:
{
...
...
@@ -207,10 +204,10 @@
if
(
!
val
)
return
;
// 采用markdown解析
if
(
this
.
language
===
'markdown'
||
this
.
language
===
'md'
)
{
const
parseNodes
=
marked
(
val
);
setTimeout
(()
=>
{
this
.
_parseNodes
(
parseNodes
)
},
0
);
//
const parseNodes = marked(val);
//
setTimeout(() => {
//
this._parseNodes(parseNodes)
//
}, 0);
}
else
{
// 默认采用html解析
setTimeout
(()
=>
{
...
...
src/components/FirstUI/fui-parse/high-light/highlight.code.js
deleted
100644 → 0
浏览文件 @
b91bebf0
/*
Syntax highlighting with language autodetection.
https://highlightjs.org/
Modified by: firstui
organization: FirstUI(https://www.firstui.cn/)
*/
const
_hljs
=
(
function
(
factory
)
{
// Find the global object for export to both the browser and web workers.
var
globalObject
=
typeof
window
===
'object'
&&
window
||
typeof
self
===
'object'
&&
self
;
// Setup highlight.js for different environments. First is Node.js or
// CommonJS.
// `nodeType` is checked to ensure that `exports` is not a HTML element.
if
(
globalObject
)
{
// Export hljs globally even when using AMD for cases when this script
// is loaded with others that may still expect a global hljs.
globalObject
.
hljs
=
factory
({});
return
globalObject
.
hljs
;
}
else
{
return
factory
({});
}
}(
function
(
hljs
)
{
// Convenience variables for build-in objects
var
ArrayProto
=
[],
objectKeys
=
Object
.
keys
;
// Global internal variables used within the highlight.js library.
var
languages
=
{},
aliases
=
{};
// safe/production mode - swallows more errors, tries to keep running
// even if a single syntax or parse hits a fatal error
var
SAFE_MODE
=
true
;
// Regular expressions used throughout the highlight.js library.
var
noHighlightRe
=
/^
(
no-
?
highlight|plain|text
)
$/i
,
languagePrefixRe
=
/
\b
lang
(?:
uage
)?
-
([\w
-
]
+
)\b
/i
,
fixMarkupRe
=
/
((
^
(
<
[^
>
]
+>|
\t
|
)
+|
(?:\n)))
/gm
;
// The object will be assigned by the build tool. It used to synchronize API
// of external language files with minified version of the highlight.js library.
var
API_REPLACES
;
var
spanEndTag
=
'</span>'
;
var
LANGUAGE_NOT_FOUND
=
"Could not find the language '{}', did you forget to load/include a language module?"
;
// Global options used when within external APIs. This is modified when
// calling the `hljs.configure` function.
var
options
=
{
classPrefix
:
'hljs-'
,
tabReplace
:
null
,
useBR
:
false
,
languages
:
undefined
};
// keywords that should have no default relevance value
var
COMMON_KEYWORDS
=
'of and for in not or if then'
.
split
(
' '
);
/* Utility functions */
function
escape
(
value
)
{
return
value
.
replace
(
/&/g
,
'&'
).
replace
(
/</g
,
'<'
).
replace
(
/>/g
,
'>'
);
}
function
tag
(
node
)
{
return
node
.
nodeName
.
toLowerCase
();
}
function
testRe
(
re
,
lexeme
)
{
var
match
=
re
&&
re
.
exec
(
lexeme
);
return
match
&&
match
.
index
===
0
;
}
function
isNotHighlighted
(
language
)
{
return
noHighlightRe
.
test
(
language
);
}
function
blockLanguage
(
block
)
{
var
i
,
match
,
length
,
_class
;
var
classes
=
block
.
className
+
' '
;
classes
+=
block
.
parentNode
?
block
.
parentNode
.
className
:
''
;
// language-* takes precedence over non-prefixed class names.
match
=
languagePrefixRe
.
exec
(
classes
);
if
(
match
)
{
var
language
=
getLanguage
(
match
[
1
]);
if
(
!
language
)
{
console
.
warn
(
LANGUAGE_NOT_FOUND
.
replace
(
"{}"
,
match
[
1
]));
console
.
warn
(
"Falling back to no-highlight mode for this block."
,
block
);
}
return
language
?
match
[
1
]
:
'no-highlight'
;
}
classes
=
classes
.
split
(
/
\s
+/
);
for
(
i
=
0
,
length
=
classes
.
length
;
i
<
length
;
i
++
)
{
_class
=
classes
[
i
];
if
(
isNotHighlighted
(
_class
)
||
getLanguage
(
_class
))
{
return
_class
;
}
}
}
/**
* performs a shallow merge of multiple objects into one
*
* @arguments list of objects with properties to merge
* @returns a single new object
*/
function
inherit
(
parent
)
{
// inherit(parent, override_obj, override_obj, ...)
var
key
;
var
result
=
{};
var
objects
=
Array
.
prototype
.
slice
.
call
(
arguments
,
1
);
for
(
key
in
parent
)
result
[
key
]
=
parent
[
key
];
objects
.
forEach
(
function
(
obj
)
{
for
(
key
in
obj
)
result
[
key
]
=
obj
[
key
];
});
return
result
;
}
/* Stream merging */
function
nodeStream
(
node
)
{
var
result
=
[];
(
function
_nodeStream
(
node
,
offset
)
{
for
(
var
child
=
node
.
firstChild
;
child
;
child
=
child
.
nextSibling
)
{
if
(
child
.
nodeType
===
3
)
offset
+=
child
.
nodeValue
.
length
;
else
if
(
child
.
nodeType
===
1
)
{
result
.
push
({
event
:
'start'
,
offset
:
offset
,
node
:
child
});
offset
=
_nodeStream
(
child
,
offset
);
// Prevent void elements from having an end tag that would actually
// double them in the output. There are more void elements in HTML
// but we list only those realistically expected in code display.
if
(
!
tag
(
child
).
match
(
/br|hr|img|input/
))
{
result
.
push
({
event
:
'stop'
,
offset
:
offset
,
node
:
child
});
}
}
}
return
offset
;
})(
node
,
0
);
return
result
;
}
function
mergeStreams
(
original
,
highlighted
,
value
)
{
var
processed
=
0
;
var
result
=
''
;
var
nodeStack
=
[];
function
selectStream
()
{
if
(
!
original
.
length
||
!
highlighted
.
length
)
{
return
original
.
length
?
original
:
highlighted
;
}
if
(
original
[
0
].
offset
!==
highlighted
[
0
].
offset
)
{
return
(
original
[
0
].
offset
<
highlighted
[
0
].
offset
)
?
original
:
highlighted
;
}
/*
To avoid starting the stream just before it should stop the order is
ensured that original always starts first and closes last:
if (event1 == 'start' && event2 == 'start')
return original;
if (event1 == 'start' && event2 == 'stop')
return highlighted;
if (event1 == 'stop' && event2 == 'start')
return original;
if (event1 == 'stop' && event2 == 'stop')
return highlighted;
... which is collapsed to:
*/
return
highlighted
[
0
].
event
===
'start'
?
original
:
highlighted
;
}
function
open
(
node
)
{
function
attr_str
(
a
)
{
return
' '
+
a
.
nodeName
+
'="'
+
escape
(
a
.
value
).
replace
(
/"/g
,
'"'
)
+
'"'
;
}
result
+=
'<'
+
tag
(
node
)
+
ArrayProto
.
map
.
call
(
node
.
attributes
,
attr_str
).
join
(
''
)
+
'>'
;
}
function
close
(
node
)
{
result
+=
'</'
+
tag
(
node
)
+
'>'
;
}
function
render
(
event
)
{
(
event
.
event
===
'start'
?
open
:
close
)(
event
.
node
);
}
while
(
original
.
length
||
highlighted
.
length
)
{
var
stream
=
selectStream
();
result
+=
escape
(
value
.
substring
(
processed
,
stream
[
0
].
offset
));
processed
=
stream
[
0
].
offset
;
if
(
stream
===
original
)
{
/*
On any opening or closing tag of the original markup we first close
the entire highlighted node stack, then render the original tag along
with all the following original tags at the same offset and then
reopen all the tags on the highlighted stack.
*/
nodeStack
.
reverse
().
forEach
(
close
);
do
{
render
(
stream
.
splice
(
0
,
1
)[
0
]);
stream
=
selectStream
();
}
while
(
stream
===
original
&&
stream
.
length
&&
stream
[
0
].
offset
===
processed
);
nodeStack
.
reverse
().
forEach
(
open
);
}
else
{
if
(
stream
[
0
].
event
===
'start'
)
{
nodeStack
.
push
(
stream
[
0
].
node
);
}
else
{
nodeStack
.
pop
();
}
render
(
stream
.
splice
(
0
,
1
)[
0
]);
}
}
return
result
+
escape
(
value
.
substr
(
processed
));
}
/* Initialization */
function
dependencyOnParent
(
mode
)
{
if
(
!
mode
)
return
false
;
return
mode
.
endsWithParent
||
dependencyOnParent
(
mode
.
starts
);
}
function
expand_or_clone_mode
(
mode
)
{
if
(
mode
.
variants
&&
!
mode
.
cached_variants
)
{
mode
.
cached_variants
=
mode
.
variants
.
map
(
function
(
variant
)
{
return
inherit
(
mode
,
{
variants
:
null
},
variant
);
});
}
// EXPAND
// if we have variants then essentially "replace" the mode with the variants
// this happens in compileMode, where this function is called from
if
(
mode
.
cached_variants
)
return
mode
.
cached_variants
;
// CLONE
// if we have dependencies on parents then we need a unique
// instance of ourselves, so we can be reused with many
// different parents without issue
if
(
dependencyOnParent
(
mode
))
return
[
inherit
(
mode
,
{
starts
:
mode
.
starts
?
inherit
(
mode
.
starts
)
:
null
})];
if
(
Object
.
isFrozen
(
mode
))
return
[
inherit
(
mode
)];
// no special dependency issues, just return ourselves
return
[
mode
];
}
function
restoreLanguageApi
(
obj
)
{
if
(
API_REPLACES
&&
!
obj
.
langApiRestored
)
{
obj
.
langApiRestored
=
true
;
for
(
var
key
in
API_REPLACES
)
{
if
(
obj
[
key
])
{
obj
[
API_REPLACES
[
key
]]
=
obj
[
key
];
}
}
(
obj
.
contains
||
[]).
concat
(
obj
.
variants
||
[]).
forEach
(
restoreLanguageApi
);
}
}
function
compileKeywords
(
rawKeywords
,
case_insensitive
)
{
var
compiled_keywords
=
{};
if
(
typeof
rawKeywords
===
'string'
)
{
// string
splitAndCompile
(
'keyword'
,
rawKeywords
);
}
else
{
objectKeys
(
rawKeywords
).
forEach
(
function
(
className
)
{
splitAndCompile
(
className
,
rawKeywords
[
className
]);
});
}
return
compiled_keywords
;
// ---
function
splitAndCompile
(
className
,
str
)
{
if
(
case_insensitive
)
{
str
=
str
.
toLowerCase
();
}
str
.
split
(
' '
).
forEach
(
function
(
keyword
)
{
var
pair
=
keyword
.
split
(
'|'
);
compiled_keywords
[
pair
[
0
]]
=
[
className
,
scoreForKeyword
(
pair
[
0
],
pair
[
1
])];
});
}
}
function
scoreForKeyword
(
keyword
,
providedScore
)
{
// manual scores always win over common keywords
// so you can force a score of 1 if you really insist
if
(
providedScore
)
return
Number
(
providedScore
);
return
commonKeyword
(
keyword
)
?
0
:
1
;
}
function
commonKeyword
(
word
)
{
return
COMMON_KEYWORDS
.
indexOf
(
word
.
toLowerCase
())
!=
-
1
;
}
function
compileLanguage
(
language
)
{
function
reStr
(
re
)
{
return
(
re
&&
re
.
source
)
||
re
;
}
function
langRe
(
value
,
global
)
{
return
new
RegExp
(
reStr
(
value
),
'm'
+
(
language
.
case_insensitive
?
'i'
:
''
)
+
(
global
?
'g'
:
''
)
);
}
function
reCountMatchGroups
(
re
)
{
return
(
new
RegExp
(
re
.
toString
()
+
'|'
)).
exec
(
''
).
length
-
1
;
}
// joinRe logically computes regexps.join(separator), but fixes the
// backreferences so they continue to match.
// it also places each individual regular expression into it's own
// match group, keeping track of the sequencing of those match groups
// is currently an exercise for the caller. :-)
function
joinRe
(
regexps
,
separator
)
{
// backreferenceRe matches an open parenthesis or backreference. To avoid
// an incorrect parse, it additionally matches the following:
// - [...] elements, where the meaning of parentheses and escapes change
// - other escape sequences, so we do not misparse escape sequences as
// interesting elements
// - non-matching or lookahead parentheses, which do not capture. These
// follow the '(' with a '?'.
var
backreferenceRe
=
/
\[(?:[^\\\]]
|
\\
.
)
*
\]
|
\(\??
|
\\([
1-9
][
0-9
]
*
)
|
\\
./
;
var
numCaptures
=
0
;
var
ret
=
''
;
for
(
var
i
=
0
;
i
<
regexps
.
length
;
i
++
)
{
numCaptures
+=
1
;
var
offset
=
numCaptures
;
var
re
=
reStr
(
regexps
[
i
]);
if
(
i
>
0
)
{
ret
+=
separator
;
}
ret
+=
"("
;
while
(
re
.
length
>
0
)
{
var
match
=
backreferenceRe
.
exec
(
re
);
if
(
match
==
null
)
{
ret
+=
re
;
break
;
}
ret
+=
re
.
substring
(
0
,
match
.
index
);
re
=
re
.
substring
(
match
.
index
+
match
[
0
].
length
);
if
(
match
[
0
][
0
]
==
'
\
\'
&& match[1]) {
// Adjust the backreference.
ret += '
\\
' + String(Number(match[1]) + offset);
} else {
ret += match[0];
if (match[0] == '
(
') {
numCaptures++;
}
}
}
ret += ")";
}
return ret;
}
function buildModeRegex(mode) {
var matchIndexes = {};
var matcherRe;
var regexes = [];
var matcher = {};
var matchAt = 1;
function addRule(rule, regex) {
matchIndexes[matchAt] = rule;
regexes.push([rule, regex]);
matchAt += reCountMatchGroups(regex) + 1;
}
var term;
for (var i = 0; i < mode.contains.length; i++) {
var re;
term = mode.contains[i];
if (term.beginKeywords) {
re = '
\\
.?(?:
' + term.begin + '
)
\\
.?
';
} else {
re = term.begin;
}
addRule(term, re);
}
if (mode.terminator_end)
addRule("end", mode.terminator_end);
if (mode.illegal)
addRule("illegal", mode.illegal);
var terminators = regexes.map(function(el) {
return el[1];
});
matcherRe = langRe(joinRe(terminators, '
|
'), true);
matcher.lastIndex = 0;
matcher.exec = function(s) {
var rule;
if (regexes.length === 0) return null;
matcherRe.lastIndex = matcher.lastIndex;
var match = matcherRe.exec(s);
if (!match) {
return null;
}
for (var i = 0; i < match.length; i++) {
if (match[i] != undefined && matchIndexes["" + i] != undefined) {
rule = matchIndexes["" + i];
break;
}
}
// illegal or end match
if (typeof rule === "string") {
match.type = rule;
match.extra = [mode.illegal, mode.terminator_end];
} else {
match.type = "begin";
match.rule = rule;
}
return match;
};
return matcher;
}
function compileMode(mode, parent) {
if (mode.compiled)
return;
mode.compiled = true;
mode.keywords = mode.keywords || mode.beginKeywords;
if (mode.keywords)
mode.keywords = compileKeywords(mode.keywords, language.case_insensitive);
mode.lexemesRe = langRe(mode.lexemes || /
\
w+/, true);
if (parent) {
if (mode.beginKeywords) {
mode.begin = '
\\
b
(
' + mode.beginKeywords.split('
').join('
|
') + '
)
\\
b
';
}
if (!mode.begin)
mode.begin = /
\
B|
\
b/;
mode.beginRe = langRe(mode.begin);
if (mode.endSameAsBegin)
mode.end = mode.begin;
if (!mode.end && !mode.endsWithParent)
mode.end = /
\
B|
\
b/;
if (mode.end)
mode.endRe = langRe(mode.end);
mode.terminator_end = reStr(mode.end) || '';
if (mode.endsWithParent && parent.terminator_end)
mode.terminator_end += (mode.end ? '
|
' : '') + parent.terminator_end;
}
if (mode.illegal)
mode.illegalRe = langRe(mode.illegal);
if (mode.relevance == null)
mode.relevance = 1;
if (!mode.contains) {
mode.contains = [];
}
mode.contains = Array.prototype.concat.apply([], mode.contains.map(function(c) {
return expand_or_clone_mode(c === '
self
' ? mode : c);
}));
mode.contains.forEach(function(c) {
compileMode(c, mode);
});
if (mode.starts) {
compileMode(mode.starts, parent);
}
mode.terminators = buildModeRegex(mode);
}
// self is not valid at the top-level
if (language.contains && language.contains.indexOf('
self
') != -1) {
if (!SAFE_MODE) {
throw new Error(
"ERR: contains `self` is not supported at the top-level of a language. See documentation."
)
} else {
// silently remove the broken rule (effectively ignoring it), this has historically
// been the behavior in the past, so this removal preserves compatibility with broken
// grammars when running in Safe Mode
language.contains = language.contains.filter(function(mode) {
return mode != '
self
';
});
}
}
compileMode(language);
}
/**
* Core highlighting function.
*
* @param {string} languageName - the language to use for highlighting
* @param {string} code - the code to highlight
* @param {boolean} ignore_illegals - whether to ignore illegal matches, default is to bail
* @param {array<mode>} continuation - array of continuation modes
*
* @returns an object that represents the result
* @property {string} language - the language name
* @property {number} relevance - the relevance score
* @property {string} value - the highlighted HTML code
* @property {mode} top - top of the current mode stack
* @property {boolean} illegal - indicates whether any illegal matches were found
*/
function highlight(languageName, code, ignore_illegals, continuation) {
var codeToHighlight = code;
function escapeRe(value) {
return new RegExp(value.replace(/[-
\
/
\\
^$*+?.()|[
\
]{}]/g, '
\\
$
&
'), '
m
');
}
function endOfMode(mode, lexeme) {
if (testRe(mode.endRe, lexeme)) {
while (mode.endsParent && mode.parent) {
mode = mode.parent;
}
return mode;
}
if (mode.endsWithParent) {
return endOfMode(mode.parent, lexeme);
}
}
function keywordMatch(mode, match) {
var match_str = language.case_insensitive ? match[0].toLowerCase() : match[0];
return mode.keywords.hasOwnProperty(match_str) && mode.keywords[match_str];
}
function buildSpan(className, insideSpan, leaveOpen, noPrefix) {
if (!leaveOpen && insideSpan === '') return '';
if (!className) return insideSpan;
var classPrefix = noPrefix ? '' : options.classPrefix,
openSpan = '
<
span
class
=
"' + classPrefix,
closeSpan = leaveOpen ? '' : spanEndTag;
openSpan += className + '"
>
';
return openSpan + insideSpan + closeSpan;
}
function processKeywords() {
var keyword_match, last_index, match, result;
if (!top.keywords)
return escape(mode_buffer);
result = '';
last_index = 0;
top.lexemesRe.lastIndex = 0;
match = top.lexemesRe.exec(mode_buffer);
while (match) {
result += escape(mode_buffer.substring(last_index, match.index));
keyword_match = keywordMatch(top, match);
if (keyword_match) {
relevance += keyword_match[1];
result += buildSpan(keyword_match[0], escape(match[0]));
} else {
result += escape(match[0]);
}
last_index = top.lexemesRe.lastIndex;
match = top.lexemesRe.exec(mode_buffer);
}
return result + escape(mode_buffer.substr(last_index));
}
function processSubLanguage() {
var explicit = typeof top.subLanguage === '
string
';
if (explicit && !languages[top.subLanguage]) {
return escape(mode_buffer);
}
var result = explicit ?
highlight(top.subLanguage, mode_buffer, true, continuations[top.subLanguage]) :
highlightAuto(mode_buffer, top.subLanguage.length ? top.subLanguage : undefined);
// Counting embedded language score towards the host language may be disabled
// with zeroing the containing mode relevance. Use case in point is Markdown that
// allows XML everywhere and makes every XML snippet to have a much larger Markdown
// score.
if (top.relevance > 0) {
relevance += result.relevance;
}
if (explicit) {
continuations[top.subLanguage] = result.top;
}
return buildSpan(result.language, result.value, false, true);
}
function processBuffer() {
result += (top.subLanguage != null ? processSubLanguage() : processKeywords());
mode_buffer = '';
}
function startNewMode(mode) {
result += mode.className ? buildSpan(mode.className, '', true) : '';
top = Object.create(mode, {
parent: {
value: top
}
});
}
function doBeginMatch(match) {
var lexeme = match[0];
var new_mode = match.rule;
if (new_mode && new_mode.endSameAsBegin) {
new_mode.endRe = escapeRe(lexeme);
}
if (new_mode.skip) {
mode_buffer += lexeme;
} else {
if (new_mode.excludeBegin) {
mode_buffer += lexeme;
}
processBuffer();
if (!new_mode.returnBegin && !new_mode.excludeBegin) {
mode_buffer = lexeme;
}
}
startNewMode(new_mode);
return new_mode.returnBegin ? 0 : lexeme.length;
}
function doEndMatch(match) {
var lexeme = match[0];
var matchPlusRemainder = codeToHighlight.substr(match.index);
var end_mode = endOfMode(top, matchPlusRemainder);
if (!end_mode) {
return;
}
var origin = top;
if (origin.skip) {
mode_buffer += lexeme;
} else {
if (!(origin.returnEnd || origin.excludeEnd)) {
mode_buffer += lexeme;
}
processBuffer();
if (origin.excludeEnd) {
mode_buffer = lexeme;
}
}
do {
if (top.className) {
result += spanEndTag;
}
if (!top.skip && !top.subLanguage) {
relevance += top.relevance;
}
top = top.parent;
} while (top !== end_mode.parent);
if (end_mode.starts) {
if (end_mode.endSameAsBegin) {
end_mode.starts.endRe = end_mode.endRe;
}
startNewMode(end_mode.starts);
}
return origin.returnEnd ? 0 : lexeme.length;
}
var lastMatch = {};
function processLexeme(text_before_match, match) {
var lexeme = match && match[0];
// add non-matched text to the current mode buffer
mode_buffer += text_before_match;
if (lexeme == null) {
processBuffer();
return 0;
}
// we'
ve
found
a
0
width
match
and
we
're stuck, so we need to advance
// this happens when we have badly behaved rules that have optional matchers to the degree that
// sometimes they can end up matching nothing at all
// Ref: https://github.com/highlightjs/highlight.js/issues/2140
if (lastMatch.type == "begin" && match.type == "end" && lastMatch.index == match.index &&
lexeme === "") {
// spit the "skipped" character that our regex choked on back into the output sequence
mode_buffer += codeToHighlight.slice(match.index, match.index + 1);
return 1;
}
lastMatch = match;
if (match.type === "begin") {
return doBeginMatch(match);
} else if (match.type === "illegal" && !ignore_illegals) {
// illegal match, we do not continue processing
throw new Error('
Illegal
lexeme
"' + lexeme + '"
for
mode
"' + (top.className ||
'<unnamed>') + '"
');
} else if (match.type === "end") {
var processed = doEndMatch(match);
if (processed != undefined)
return processed;
}
/*
Why might be find ourselves here? Only one occasion now. An end match that was
triggered but could not be completed. When might this happen? When an `endSameasBegin`
rule sets the end rule to a specific match. Since the overall mode termination rule that'
s
being
used
to
scan
the
text
isn
't recompiled that means that any match that LOOKS like
the end (but is not, because it is not an exact match to the beginning) will
end up here. A definite end match, but when `doEndMatch` tries to "reapply"
the end rule and fails to match, we wind up here, and just silently ignore the end.
This causes no real harm other than stopping a few times too many.
*/
mode_buffer += lexeme;
return lexeme.length;
}
var language = getLanguage(languageName);
if (!language) {
console.error(LANGUAGE_NOT_FOUND.replace("{}", languageName));
throw new Error('
Unknown
language
:
"' + languageName + '"
');
}
compileLanguage(language);
var top = continuation || language;
var continuations = {}; // keep continuations for sub-languages
var result = '',
current;
for (current = top; current !== language; current = current.parent) {
if (current.className) {
result = buildSpan(current.className, '', true) + result;
}
}
var mode_buffer = '';
var relevance = 0;
try {
var match, count, index = 0;
while (true) {
top.terminators.lastIndex = index;
match = top.terminators.exec(codeToHighlight);
if (!match)
break;
count = processLexeme(codeToHighlight.substring(index, match.index), match);
index = match.index + count;
}
processLexeme(codeToHighlight.substr(index));
for (current = top; current.parent; current = current.parent) { // close dangling modes
if (current.className) {
result += spanEndTag;
}
}
return {
relevance: relevance,
value: result,
illegal: false,
language: languageName,
top: top
};
} catch (err) {
if (err.message && err.message.indexOf('
Illegal
') !== -1) {
return {
illegal: true,
relevance: 0,
value: escape(codeToHighlight)
};
} else if (SAFE_MODE) {
return {
relevance: 0,
value: escape(codeToHighlight),
language: languageName,
top: top,
errorRaised: err
};
} else {
throw err;
}
}
}
/*
Highlighting with language detection. Accepts a string with the code to
highlight. Returns an object with the following properties:
- language (detected language)
- relevance (int)
- value (an HTML string with highlighting markup)
- second_best (object with the same structure for second-best heuristically
detected language, may be absent)
*/
function highlightAuto(code, languageSubset) {
languageSubset = languageSubset || options.languages || objectKeys(languages);
var result = {
relevance: 0,
value: escape(code)
};
var second_best = result;
languageSubset.filter(getLanguage).filter(autoDetection).forEach(function(name) {
var current = highlight(name, code, false);
current.language = name;
if (current.relevance > second_best.relevance) {
second_best = current;
}
if (current.relevance > result.relevance) {
second_best = result;
result = current;
}
});
if (second_best.language) {
result.second_best = second_best;
}
return result;
}
/*
Post-processing of the highlighted markup:
- replace TABs with something more useful
- replace real line-breaks with '
<
br
>
' for non-pre containers
*/
function fixMarkup(value) {
if (!(options.tabReplace || options.useBR)) {
return value;
}
return value.replace(fixMarkupRe, function(match, p1) {
if (options.useBR && match === '
\
n
') {
return '
<
br
>
';
} else if (options.tabReplace) {
return p1.replace(/
\
t/g, options.tabReplace);
}
return '';
});
}
function buildClassName(prevClassName, currentLang, resultLang) {
var language = currentLang ? aliases[currentLang] : resultLang,
result = [prevClassName.trim()];
if (!prevClassName.match(/
\
bhljs
\
b/)) {
result.push('
hljs
');
}
if (prevClassName.indexOf(language) === -1) {
result.push(language);
}
return result.join('
').trim();
}
/*
Applies highlighting to a DOM node containing code. Accepts a DOM node and
two optional parameters for fixMarkup.
*/
function highlightBlock(block) {
var node, originalStream, result, resultNode, text;
var language = blockLanguage(block);
if (isNotHighlighted(language))
return;
if (options.useBR) {
node = document.createElement('
div
');
node.innerHTML = block.innerHTML.replace(/
\
n/g, '').replace(/<br[
\
/]*>/g, '
\
n
');
} else {
node = block;
}
text = node.textContent;
result = language ? highlight(language, text, true) : highlightAuto(text);
originalStream = nodeStream(node);
if (originalStream.length) {
resultNode = document.createElement('
div
');
resultNode.innerHTML = result.value;
result.value = mergeStreams(originalStream, nodeStream(resultNode), text);
}
result.value = fixMarkup(result.value);
block.innerHTML = result.value;
block.className = buildClassName(block.className, language, result.language);
block.result = {
language: result.language,
re: result.relevance
};
if (result.second_best) {
block.second_best = {
language: result.second_best.language,
re: result.second_best.relevance
};
}
}
/*
Updates highlight.js global options with values passed in the form of an object.
*/
function configure(user_options) {
options = inherit(options, user_options);
}
/*
Applies highlighting to all <pre><code>..</code></pre> blocks on a page.
*/
function initHighlighting() {
if (initHighlighting.called)
return;
initHighlighting.called = true;
var blocks = document.querySelectorAll('
pre
code
');
ArrayProto.forEach.call(blocks, highlightBlock);
}
/*
Attaches highlighting to the page load event.
*/
function initHighlightingOnLoad() {
window.addEventListener('
DOMContentLoaded
', initHighlighting, false);
window.addEventListener('
load
', initHighlighting, false);
}
var PLAINTEXT_LANGUAGE = {
disableAutodetect: true
};
function registerLanguage(name, language) {
var lang;
try {
lang = language(hljs);
} catch (error) {
console.error("Language definition for '
{}
' could not be registered.".replace("{}", name));
// hard or soft error
if (!SAFE_MODE) {
throw error;
} else {
console.error(error);
}
// languages that have serious errors are replaced with essentially a
// "plaintext" stand-in so that the code blocks will still get normal
// css classes applied to them - and one bad language won'
t
break
the
// entire highlighter
lang
=
PLAINTEXT_LANGUAGE
;
}
languages
[
name
]
=
lang
;
restoreLanguageApi
(
lang
);
lang
.
rawDefinition
=
language
.
bind
(
null
,
hljs
);
if
(
lang
.
aliases
)
{
lang
.
aliases
.
forEach
(
function
(
alias
)
{
aliases
[
alias
]
=
name
;
});
}
}
function
listLanguages
()
{
return
objectKeys
(
languages
);
}
/*
intended usage: When one language truly requires another
Unlike `getLanguage`, this will throw when the requested language
is not available.
*/
function
requireLanguage
(
name
)
{
var
lang
=
getLanguage
(
name
);
if
(
lang
)
{
return
lang
;
}
var
err
=
new
Error
(
'The
\'
{}
\'
language is required, but not loaded.'
.
replace
(
'{}'
,
name
));
throw
err
;
}
function
getLanguage
(
name
)
{
name
=
(
name
||
''
).
toLowerCase
();
return
languages
[
name
]
||
languages
[
aliases
[
name
]];
}
function
autoDetection
(
name
)
{
var
lang
=
getLanguage
(
name
);
return
lang
&&
!
lang
.
disableAutodetect
;
}
/* Interface definition */
hljs
.
highlight
=
highlight
;
hljs
.
highlightAuto
=
highlightAuto
;
hljs
.
fixMarkup
=
fixMarkup
;
hljs
.
highlightBlock
=
highlightBlock
;
hljs
.
configure
=
configure
;
hljs
.
initHighlighting
=
initHighlighting
;
hljs
.
initHighlightingOnLoad
=
initHighlightingOnLoad
;
hljs
.
registerLanguage
=
registerLanguage
;
hljs
.
listLanguages
=
listLanguages
;
hljs
.
getLanguage
=
getLanguage
;
hljs
.
requireLanguage
=
requireLanguage
;
hljs
.
autoDetection
=
autoDetection
;
hljs
.
inherit
=
inherit
;
hljs
.
debugMode
=
function
()
{
SAFE_MODE
=
false
;
}
// Common regexps
hljs
.
IDENT_RE
=
'[a-zA-Z]
\\
w*'
;
hljs
.
UNDERSCORE_IDENT_RE
=
'[a-zA-Z_]
\\
w*'
;
hljs
.
NUMBER_RE
=
'
\\
b
\\
d+(
\\
.
\\
d+)?'
;
hljs
.
C_NUMBER_RE
=
'(-?)(
\\
b0[xX][a-fA-F0-9]+|(
\\
b
\\
d+(
\\
.
\\
d*)?|
\\
.
\\
d+)([eE][-+]?
\\
d+)?)'
;
// 0x..., 0..., decimal, float
hljs
.
BINARY_NUMBER_RE
=
'
\\
b(0b[01]+)'
;
// 0b...
hljs
.
RE_STARTERS_RE
=
'!|!=|!==|%|%=|&|&&|&=|
\\
*|
\\
*=|
\\
+|
\\
+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|
\\
?|
\\
[|
\\
{|
\\
(|
\\
^|
\\
^=|
\\
||
\\
|=|
\\
|
\\
||~'
;
// Common modes
hljs
.
BACKSLASH_ESCAPE
=
{
begin
:
'
\\\\
[
\\
s
\\
S]'
,
relevance
:
0
};
hljs
.
APOS_STRING_MODE
=
{
className
:
'string'
,
begin
:
'
\'
'
,
end
:
'
\'
'
,
illegal
:
'
\\
n'
,
contains
:
[
hljs
.
BACKSLASH_ESCAPE
]
};
hljs
.
QUOTE_STRING_MODE
=
{
className
:
'string'
,
begin
:
'"'
,
end
:
'"'
,
illegal
:
'
\\
n'
,
contains
:
[
hljs
.
BACKSLASH_ESCAPE
]
};
hljs
.
PHRASAL_WORDS_MODE
=
{
begin
:
/
\b(
a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more
)\b
/
};
hljs
.
COMMENT
=
function
(
begin
,
end
,
inherits
)
{
var
mode
=
hljs
.
inherit
({
className
:
'comment'
,
begin
:
begin
,
end
:
end
,
contains
:
[]
},
inherits
||
{}
);
mode
.
contains
.
push
(
hljs
.
PHRASAL_WORDS_MODE
);
mode
.
contains
.
push
({
className
:
'doctag'
,
begin
:
'(?:TODO|FIXME|NOTE|BUG|XXX):'
,
relevance
:
0
});
return
mode
;
};
hljs
.
C_LINE_COMMENT_MODE
=
hljs
.
COMMENT
(
'//'
,
'$'
);
hljs
.
C_BLOCK_COMMENT_MODE
=
hljs
.
COMMENT
(
'/
\\
*'
,
'
\\
*/'
);
hljs
.
HASH_COMMENT_MODE
=
hljs
.
COMMENT
(
'#'
,
'$'
);
hljs
.
NUMBER_MODE
=
{
className
:
'number'
,
begin
:
hljs
.
NUMBER_RE
,
relevance
:
0
};
hljs
.
C_NUMBER_MODE
=
{
className
:
'number'
,
begin
:
hljs
.
C_NUMBER_RE
,
relevance
:
0
};
hljs
.
BINARY_NUMBER_MODE
=
{
className
:
'number'
,
begin
:
hljs
.
BINARY_NUMBER_RE
,
relevance
:
0
};
hljs
.
CSS_NUMBER_MODE
=
{
className
:
'number'
,
begin
:
hljs
.
NUMBER_RE
+
'('
+
'%|em|ex|ch|rem'
+
'|vw|vh|vmin|vmax'
+
'|cm|mm|in|pt|pc|px'
+
'|deg|grad|rad|turn'
+
'|s|ms'
+
'|Hz|kHz'
+
'|dpi|dpcm|dppx'
+
')?'
,
relevance
:
0
};
hljs
.
REGEXP_MODE
=
{
className
:
'regexp'
,
begin
:
/
\/
/
,
end
:
/
\/[
gimuy
]
*/
,
illegal
:
/
\n
/
,
contains
:
[
hljs
.
BACKSLASH_ESCAPE
,
{
begin
:
/
\[
/
,
end
:
/
\]
/
,
relevance
:
0
,
contains
:
[
hljs
.
BACKSLASH_ESCAPE
]
}
]
};
hljs
.
TITLE_MODE
=
{
className
:
'title'
,
begin
:
hljs
.
IDENT_RE
,
relevance
:
0
};
hljs
.
UNDERSCORE_TITLE_MODE
=
{
className
:
'title'
,
begin
:
hljs
.
UNDERSCORE_IDENT_RE
,
relevance
:
0
};
hljs
.
METHOD_GUARD
=
{
// excludes method names from keyword processing
begin
:
'
\\
.
\\
s*'
+
hljs
.
UNDERSCORE_IDENT_RE
,
relevance
:
0
};
var
constants
=
[
hljs
.
BACKSLASH_ESCAPE
,
hljs
.
APOS_STRING_MODE
,
hljs
.
QUOTE_STRING_MODE
,
hljs
.
PHRASAL_WORDS_MODE
,
hljs
.
COMMENT
,
hljs
.
C_LINE_COMMENT_MODE
,
hljs
.
C_BLOCK_COMMENT_MODE
,
hljs
.
HASH_COMMENT_MODE
,
hljs
.
NUMBER_MODE
,
hljs
.
C_NUMBER_MODE
,
hljs
.
BINARY_NUMBER_MODE
,
hljs
.
CSS_NUMBER_MODE
,
hljs
.
REGEXP_MODE
,
hljs
.
TITLE_MODE
,
hljs
.
UNDERSCORE_TITLE_MODE
,
hljs
.
METHOD_GUARD
]
constants
.
forEach
(
function
(
obj
)
{
deepFreeze
(
obj
);
});
// https://github.com/substack/deep-freeze/blob/master/index.js
function
deepFreeze
(
o
)
{
Object
.
freeze
(
o
);
var
objIsFunction
=
typeof
o
===
'function'
;
Object
.
getOwnPropertyNames
(
o
).
forEach
(
function
(
prop
)
{
if
(
o
.
hasOwnProperty
(
prop
)
&&
o
[
prop
]
!==
null
&&
(
typeof
o
[
prop
]
===
"object"
||
typeof
o
[
prop
]
===
"function"
)
// IE11 fix: https://github.com/highlightjs/highlight.js/issues/2318
// TODO: remove in the future
&&
(
objIsFunction
?
prop
!==
'caller'
&&
prop
!==
'callee'
&&
prop
!==
'arguments'
:
true
)
&&
!
Object
.
isFrozen
(
o
[
prop
]))
{
deepFreeze
(
o
[
prop
]);
}
});
return
o
;
};
return
hljs
;
}));
export
default
_hljs
;
src/components/FirstUI/fui-parse/high-light/index.js
deleted
100644 → 0
浏览文件 @
b91bebf0
/**
* Modified by: firstui
* organization: FirstUI(https://www.firstui.cn/)
*/
import
hljs
from
'./highlight.code.js'
import
javascript
from
'./languages/javascript.js'
import
css
from
'./languages/css.js'
import
xml
from
'./languages/xml.js'
import
sql
from
'./languages/sql.js'
import
typescript
from
'./languages/typescript.js'
import
markdown
from
'./languages/markdown.js'
import
cpp
from
'./languages/cpp.js'
import
c
from
'./languages/c.js'
hljs
.
registerLanguage
(
'javascript'
,
javascript
);
hljs
.
registerLanguage
(
'css'
,
css
);
hljs
.
registerLanguage
(
'xml'
,
xml
);
hljs
.
registerLanguage
(
'sql'
,
sql
);
hljs
.
registerLanguage
(
'typescript'
,
typescript
);
hljs
.
registerLanguage
(
'markdown'
,
markdown
);
hljs
.
registerLanguage
(
'c++'
,
cpp
);
hljs
.
registerLanguage
(
'c'
,
c
);
export
default
hljs
;
src/components/FirstUI/fui-parse/high-light/languages/c-like.js
deleted
100644 → 0
浏览文件 @
b91bebf0
/*
Language: C-like foundation grammar for C/C++ grammars
Author: Ivan Sagalaev <maniac@softwaremaniacs.org>
Contributors: Evgeny Stepanischev <imbolk@gmail.com>, Zaven Muradyan <megalivoithos@gmail.com>, Roel Deckers <admin@codingcat.nl>, Sam Wu <samsam2310@gmail.com>, Jordi Petit <jordi.petit@gmail.com>, Pieter Vantorre <pietervantorre@gmail.com>, Google Inc. (David Benjamin) <davidben@google.com>
Modified by: firstui
organization: FirstUI(https://www.firstui.cn/)
*/
/* In the future the intention is to split out the C/C++ grammars distinctly
since they are separate languages. They will likely share a common foundation
though, and this file sets the groundwork for that - so that we get the breaking
change in v10 and don't have to change the requirements again later.
See: https://github.com/highlightjs/highlight.js/issues/2146
*/
import
{
optional
}
from
'../regex.js'
/** @type LanguageFn */
export
default
function
(
hljs
)
{
// added for historic reasons because `hljs.C_LINE_COMMENT_MODE` does
// not include such support nor can we be sure all the grammars depending
// on it would desire this behavior
const
C_LINE_COMMENT_MODE
=
hljs
.
COMMENT
(
'//'
,
'$'
,
{
contains
:
[{
begin
:
/
\\\n
/
}]
});
const
DECLTYPE_AUTO_RE
=
'decltype
\\
(auto
\\
)'
;
const
NAMESPACE_RE
=
'[a-zA-Z_]
\\
w*::'
;
const
TEMPLATE_ARGUMENT_RE
=
'<[^<>]+>'
;
const
FUNCTION_TYPE_RE
=
'('
+
DECLTYPE_AUTO_RE
+
'|'
+
optional
(
NAMESPACE_RE
)
+
'[a-zA-Z_]
\\
w*'
+
optional
(
TEMPLATE_ARGUMENT_RE
)
+
')'
;
const
CPP_PRIMITIVE_TYPES
=
{
className
:
'keyword'
,
begin
:
'
\\
b[a-z
\\
d_]*_t
\\
b'
};
// https://en.cppreference.com/w/cpp/language/escape
// \\ \x \xFF \u2837 \u00323747 \374
const
CHARACTER_ESCAPES
=
'
\\\\
(x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4,8}|[0-7]{3}|
\\
S)'
;
const
STRINGS
=
{
className
:
'string'
,
variants
:
[{
begin
:
'(u8?|U|L)?"'
,
end
:
'"'
,
illegal
:
'
\\
n'
,
contains
:
[
hljs
.
BACKSLASH_ESCAPE
]
},
{
begin
:
'(u8?|U|L)?
\'
('
+
CHARACTER_ESCAPES
+
"|.)"
,
end
:
'
\'
'
,
illegal
:
'.'
},
// hljs.END_SAME_AS_BEGIN({
// begin: /(?:u8?|U|L)?R"([^()\\ ]{0,16})\(/,
// end: /\)([^()\\ ]{0,16})"/
// })
]
};
const
NUMBERS
=
{
className
:
'number'
,
variants
:
[{
begin
:
'
\\
b(0b[01
\'
]+)'
},
{
begin
:
'(-?)
\\
b([
\\
d
\'
]+(
\\
.[
\\
d
\'
]*)?|
\\
.[
\\
d
\'
]+)(u|U|l|L|ul|UL|f|F|b|B)'
},
{
begin
:
'(-?)(
\\
b0[xX][a-fA-F0-9
\'
]+|(
\\
b[
\\
d
\'
]+(
\\
.[
\\
d
\'
]*)?|
\\
.[
\\
d
\'
]+)([eE][-+]?[
\\
d
\'
]+)?)'
}
],
relevance
:
0
};
const
PREPROCESSOR
=
{
className
:
'meta'
,
begin
:
/#
\s
*
[
a-z
]
+
\b
/
,
end
:
/$/
,
keywords
:
{
'meta-keyword'
:
'if else elif endif define undef warning error line '
+
'pragma _Pragma ifdef ifndef include'
},
contains
:
[{
begin
:
/
\\\n
/
,
relevance
:
0
},
hljs
.
inherit
(
STRINGS
,
{
className
:
'meta-string'
}),
{
className
:
'meta-string'
,
begin
:
/<.*
?
>/
,
end
:
/$/
,
illegal
:
'
\\
n'
},
C_LINE_COMMENT_MODE
,
hljs
.
C_BLOCK_COMMENT_MODE
]
};
const
TITLE_MODE
=
{
className
:
'title'
,
begin
:
optional
(
NAMESPACE_RE
)
+
hljs
.
IDENT_RE
,
relevance
:
0
};
const
FUNCTION_TITLE
=
optional
(
NAMESPACE_RE
)
+
hljs
.
IDENT_RE
+
'
\\
s*
\\
('
;
const
CPP_KEYWORDS
=
{
keyword
:
'int float while private char char8_t char16_t char32_t catch import module export virtual operator sizeof '
+
'dynamic_cast|10 typedef const_cast|10 const for static_cast|10 union namespace '
+
'unsigned long volatile static protected bool template mutable if public friend '
+
'do goto auto void enum else break extern using asm case typeid wchar_t '
+
'short reinterpret_cast|10 default double register explicit signed typename try this '
+
'switch continue inline delete alignas alignof constexpr consteval constinit decltype '
+
'concept co_await co_return co_yield requires '
+
'noexcept static_assert thread_local restrict final override '
+
'atomic_bool atomic_char atomic_schar '
+
'atomic_uchar atomic_short atomic_ushort atomic_int atomic_uint atomic_long atomic_ulong atomic_llong '
+
'atomic_ullong new throw return '
+
'and and_eq bitand bitor compl not not_eq or or_eq xor xor_eq'
,
built_in
:
'std string wstring cin cout cerr clog stdin stdout stderr stringstream istringstream ostringstream '
+
'auto_ptr deque list queue stack vector map set pair bitset multiset multimap unordered_set '
+
'unordered_map unordered_multiset unordered_multimap priority_queue make_pair array shared_ptr abort terminate abs acos '
+
'asin atan2 atan calloc ceil cosh cos exit exp fabs floor fmod fprintf fputs free frexp '
+
'fscanf future isalnum isalpha iscntrl isdigit isgraph islower isprint ispunct isspace isupper '
+
'isxdigit tolower toupper labs ldexp log10 log malloc realloc memchr memcmp memcpy memset modf pow '
+
'printf putchar puts scanf sinh sin snprintf sprintf sqrt sscanf strcat strchr strcmp '
+
'strcpy strcspn strlen strncat strncmp strncpy strpbrk strrchr strspn strstr tanh tan '
+
'vfprintf vprintf vsprintf endl initializer_list unique_ptr _Bool complex _Complex imaginary _Imaginary'
,
literal
:
'true false nullptr NULL'
};
const
EXPRESSION_CONTAINS
=
[
PREPROCESSOR
,
CPP_PRIMITIVE_TYPES
,
C_LINE_COMMENT_MODE
,
hljs
.
C_BLOCK_COMMENT_MODE
,
NUMBERS
,
STRINGS
];
const
EXPRESSION_CONTEXT
=
{
// This mode covers expression context where we can't expect a function
// definition and shouldn't highlight anything that looks like one:
// `return some()`, `else if()`, `(x*sum(1, 2))`
variants
:
[{
begin
:
/=/
,
end
:
/;/
},
{
begin
:
/
\(
/
,
end
:
/
\)
/
},
{
beginKeywords
:
'new throw return else'
,
end
:
/;/
}
],
keywords
:
CPP_KEYWORDS
,
contains
:
EXPRESSION_CONTAINS
.
concat
([{
begin
:
/
\(
/
,
end
:
/
\)
/
,
keywords
:
CPP_KEYWORDS
,
contains
:
EXPRESSION_CONTAINS
.
concat
([
'self'
]),
relevance
:
0
}]),
relevance
:
0
};
const
FUNCTION_DECLARATION
=
{
className
:
'function'
,
begin
:
'('
+
FUNCTION_TYPE_RE
+
'[
\\
*&
\\
s]+)+'
+
FUNCTION_TITLE
,
returnBegin
:
true
,
end
:
/
[
{;=
]
/
,
excludeEnd
:
true
,
keywords
:
CPP_KEYWORDS
,
illegal
:
/
[^\w\s\*
&:<>
]
/
,
contains
:
[{
// to prevent it from being confused as the function title
begin
:
DECLTYPE_AUTO_RE
,
keywords
:
CPP_KEYWORDS
,
relevance
:
0
},
{
begin
:
FUNCTION_TITLE
,
returnBegin
:
true
,
contains
:
[
TITLE_MODE
],
relevance
:
0
},
{
className
:
'params'
,
begin
:
/
\(
/
,
end
:
/
\)
/
,
keywords
:
CPP_KEYWORDS
,
relevance
:
0
,
contains
:
[
C_LINE_COMMENT_MODE
,
hljs
.
C_BLOCK_COMMENT_MODE
,
STRINGS
,
NUMBERS
,
CPP_PRIMITIVE_TYPES
,
// Count matching parentheses.
{
begin
:
/
\(
/
,
end
:
/
\)
/
,
keywords
:
CPP_KEYWORDS
,
relevance
:
0
,
contains
:
[
'self'
,
C_LINE_COMMENT_MODE
,
hljs
.
C_BLOCK_COMMENT_MODE
,
STRINGS
,
NUMBERS
,
CPP_PRIMITIVE_TYPES
]
}
]
},
CPP_PRIMITIVE_TYPES
,
C_LINE_COMMENT_MODE
,
hljs
.
C_BLOCK_COMMENT_MODE
,
PREPROCESSOR
]
};
return
{
aliases
:
[
'c'
,
'cc'
,
'h'
,
'c++'
,
'h++'
,
'hpp'
,
'hh'
,
'hxx'
,
'cxx'
],
keywords
:
CPP_KEYWORDS
,
// the base c-like language will NEVER be auto-detected, rather the
// derivitives: c, c++, arduino turn auto-detect back on for themselves
disableAutodetect
:
true
,
illegal
:
'</'
,
contains
:
[].
concat
(
EXPRESSION_CONTEXT
,
FUNCTION_DECLARATION
,
EXPRESSION_CONTAINS
,
[
PREPROCESSOR
,
{
// containers: ie, `vector <int> rooms (9);`
begin
:
'
\\
b(deque|list|queue|priority_queue|pair|stack|vector|map|set|bitset|multiset|multimap|unordered_map|unordered_set|unordered_multiset|unordered_multimap|array)
\\
s*<'
,
end
:
'>'
,
keywords
:
CPP_KEYWORDS
,
contains
:
[
'self'
,
CPP_PRIMITIVE_TYPES
]
},
{
begin
:
hljs
.
IDENT_RE
+
'::'
,
keywords
:
CPP_KEYWORDS
},
{
className
:
'class'
,
beginKeywords
:
'enum class struct union'
,
end
:
/
[
{;:<>=
]
/
,
contains
:
[{
beginKeywords
:
"final class struct"
},
hljs
.
TITLE_MODE
]
}
]),
exports
:
{
preprocessor
:
PREPROCESSOR
,
strings
:
STRINGS
,
keywords
:
CPP_KEYWORDS
}
};
}
src/components/FirstUI/fui-parse/high-light/languages/c.js
deleted
100644 → 0
浏览文件 @
b91bebf0
/*
Language: C
Category: common, system
Website: https://en.wikipedia.org/wiki/C_(programming_language)
Modified by: firstui
organization: FirstUI(https://www.firstui.cn/)
*/
import
cLike
from
'./c-like.js'
;
/** @type LanguageFn */
export
default
function
(
hljs
)
{
const
lang
=
cLike
(
hljs
);
// Until C is actually different than C++ there is no reason to auto-detect C
// as it's own language since it would just fail auto-detect testing or
// simply match with C++.
//
// See further comments in c-like.js.
// lang.disableAutodetect = false;
lang
.
name
=
'C'
;
lang
.
aliases
=
[
'c'
,
'h'
];
return
lang
;
}
src/components/FirstUI/fui-parse/high-light/languages/cpp.js
deleted
100644 → 0
浏览文件 @
b91bebf0
/*
Language: C++
Category: common, system
Website: https://isocpp.org
Modified by: firstui
organization: FirstUI(https://www.firstui.cn/)
*/
import
cLike
from
'./c-like.js'
;
/** @type LanguageFn */
export
default
function
(
hljs
)
{
const
lang
=
cLike
(
hljs
);
// return auto-detection back on
lang
.
disableAutodetect
=
false
;
lang
.
name
=
'C++'
;
lang
.
aliases
=
[
'cc'
,
'c++'
,
'h++'
,
'hpp'
,
'hh'
,
'hxx'
,
'cxx'
];
return
lang
;
}
src/components/FirstUI/fui-parse/high-light/languages/css.js
deleted
100644 → 0
浏览文件 @
b91bebf0
/**
* Modified by: firstui
* organization: FirstUI(https://www.firstui.cn/)
*/
export
default
function
(
hljs
)
{
var
FUNCTION_LIKE
=
{
begin
:
/
[\w
-
]
+
\(
/
,
returnBegin
:
true
,
contains
:
[
{
className
:
'built_in'
,
begin
:
/
[\w
-
]
+/
},
{
begin
:
/
\(
/
,
end
:
/
\)
/
,
contains
:
[
hljs
.
APOS_STRING_MODE
,
hljs
.
QUOTE_STRING_MODE
,
hljs
.
CSS_NUMBER_MODE
,
]
}
]
}
var
ATTRIBUTE
=
{
className
:
'attribute'
,
begin
:
/
\S
/
,
end
:
':'
,
excludeEnd
:
true
,
starts
:
{
endsWithParent
:
true
,
excludeEnd
:
true
,
contains
:
[
FUNCTION_LIKE
,
hljs
.
CSS_NUMBER_MODE
,
hljs
.
QUOTE_STRING_MODE
,
hljs
.
APOS_STRING_MODE
,
hljs
.
C_BLOCK_COMMENT_MODE
,
{
className
:
'number'
,
begin
:
'#[0-9A-Fa-f]+'
},
{
className
:
'meta'
,
begin
:
'!important'
}
]
}
}
var
AT_IDENTIFIER
=
'@[a-z-]+'
// @font-face
var
AT_MODIFIERS
=
"and or not only"
var
MEDIA_TYPES
=
"all print screen speech"
var
AT_PROPERTY_RE
=
/@
\-?\w[\w]
*
(\-\w
+
)
*/
// @-webkit-keyframes
var
IDENT_RE
=
'[a-zA-Z-][a-zA-Z0-9_-]*'
;
var
RULE
=
{
begin
:
/
(?:[
A-Z
\_\.\-]
+|--
[
a-zA-Z0-9_-
]
+
)\s
*:/
,
returnBegin
:
true
,
end
:
';'
,
endsWithParent
:
true
,
contains
:
[
ATTRIBUTE
]
};
return
{
case_insensitive
:
true
,
illegal
:
/
[
=
\/
|'
\$]
/
,
contains
:
[
hljs
.
C_BLOCK_COMMENT_MODE
,
{
className
:
'selector-id'
,
begin
:
/#
[
A-Za-z0-9_-
]
+/
},
{
className
:
'selector-class'
,
begin
:
/
\.[
A-Za-z0-9_-
]
+/
},
{
className
:
'selector-attr'
,
begin
:
/
\[
/
,
end
:
/
\]
/
,
illegal
:
'$'
,
contains
:
[
hljs
.
APOS_STRING_MODE
,
hljs
.
QUOTE_STRING_MODE
,
]
},
{
className
:
'selector-pseudo'
,
begin
:
/:
(
:
)?[
a-zA-Z0-9
\_\-\+\(\)
"'.
]
+/
},
// matching these here allows us to treat them more like regular CSS
// rules so everything between the {} gets regular rule highlighting,
// which is what we want for page and font-face
{
begin
:
'@(page|font-face)'
,
lexemes
:
AT_IDENTIFIER
,
keywords
:
'@page @font-face'
},
{
begin
:
'@'
,
end
:
'[{;]'
,
// at_rule eating first "{" is a good thing
// because it doesn’t let it to be parsed as
// a rule set but instead drops parser into
// the default mode which is how it should be.
illegal
:
/:/
,
// break on Less variables @var: ...
returnBegin
:
true
,
contains
:
[
{
className
:
'keyword'
,
begin
:
AT_PROPERTY_RE
},
{
begin
:
/
\s
/
,
endsWithParent
:
true
,
excludeEnd
:
true
,
relevance
:
0
,
keywords
:
AT_MODIFIERS
,
contains
:
[
{
begin
:
/
[
a-z-
]
+:/
,
className
:
"attribute"
},
hljs
.
APOS_STRING_MODE
,
hljs
.
QUOTE_STRING_MODE
,
hljs
.
CSS_NUMBER_MODE
]
}
]
},
{
className
:
'selector-tag'
,
begin
:
IDENT_RE
,
relevance
:
0
},
{
begin
:
'{'
,
end
:
'}'
,
illegal
:
/
\S
/
,
contains
:
[
hljs
.
C_BLOCK_COMMENT_MODE
,
RULE
,
]
}
]
};
};
src/components/FirstUI/fui-parse/high-light/languages/javascript.js
deleted
100644 → 0
浏览文件 @
b91bebf0
/**
* Modified by: firstui
* organization: FirstUI(https://www.firstui.cn/)
*/
export
default
function
(
hljs
)
{
var
FRAGMENT
=
{
begin
:
'<>'
,
end
:
'</>'
};
var
XML_TAG
=
{
begin
:
/<
[
A-Za-z0-9
\\
._:-
]
+/
,
end
:
/
\/[
A-Za-z0-9
\\
._:-
]
+>|
\/
>/
};
var
IDENT_RE
=
'[A-Za-z$_][0-9A-Za-z$_]*'
;
var
KEYWORDS
=
{
keyword
:
'in of if for while finally var new function do return void else break catch '
+
'instanceof with throw case default try this switch continue typeof delete '
+
'let yield const export super debugger as async await static '
+
// ECMAScript 6 modules import
'import from as'
,
literal
:
'true false null undefined NaN Infinity'
,
built_in
:
'eval isFinite isNaN parseFloat parseInt decodeURI decodeURIComponent '
+
'encodeURI encodeURIComponent escape unescape Object Function Boolean Error '
+
'EvalError InternalError RangeError ReferenceError StopIteration SyntaxError '
+
'TypeError URIError Number Math Date String RegExp Array Float32Array '
+
'Float64Array Int16Array Int32Array Int8Array Uint16Array Uint32Array '
+
'Uint8Array Uint8ClampedArray ArrayBuffer DataView JSON Intl arguments require '
+
'module console window document Symbol Set Map WeakSet WeakMap Proxy Reflect '
+
'Promise'
};
var
NUMBER
=
{
className
:
'number'
,
variants
:
[
{
begin
:
'
\\
b(0[bB][01]+)n?'
},
{
begin
:
'
\\
b(0[oO][0-7]+)n?'
},
{
begin
:
hljs
.
C_NUMBER_RE
+
'n?'
}
],
relevance
:
0
};
var
SUBST
=
{
className
:
'subst'
,
begin
:
'
\\
$
\\
{'
,
end
:
'
\\
}'
,
keywords
:
KEYWORDS
,
contains
:
[]
// defined later
};
var
HTML_TEMPLATE
=
{
begin
:
'html`'
,
end
:
''
,
starts
:
{
end
:
'`'
,
returnEnd
:
false
,
contains
:
[
hljs
.
BACKSLASH_ESCAPE
,
SUBST
],
subLanguage
:
'xml'
,
}
};
var
CSS_TEMPLATE
=
{
begin
:
'css`'
,
end
:
''
,
starts
:
{
end
:
'`'
,
returnEnd
:
false
,
contains
:
[
hljs
.
BACKSLASH_ESCAPE
,
SUBST
],
subLanguage
:
'css'
,
}
};
var
TEMPLATE_STRING
=
{
className
:
'string'
,
begin
:
'`'
,
end
:
'`'
,
contains
:
[
hljs
.
BACKSLASH_ESCAPE
,
SUBST
]
};
SUBST
.
contains
=
[
hljs
.
APOS_STRING_MODE
,
hljs
.
QUOTE_STRING_MODE
,
HTML_TEMPLATE
,
CSS_TEMPLATE
,
TEMPLATE_STRING
,
NUMBER
,
hljs
.
REGEXP_MODE
];
var
PARAMS_CONTAINS
=
SUBST
.
contains
.
concat
([
hljs
.
C_BLOCK_COMMENT_MODE
,
hljs
.
C_LINE_COMMENT_MODE
]);
return
{
aliases
:
[
'js'
,
'jsx'
,
'mjs'
,
'cjs'
],
keywords
:
KEYWORDS
,
contains
:
[
{
className
:
'meta'
,
relevance
:
10
,
begin
:
/^
\s
*
[
'"
]
use
(
strict|asm
)[
'"
]
/
},
{
className
:
'meta'
,
begin
:
/^#!/
,
end
:
/$/
},
hljs
.
APOS_STRING_MODE
,
hljs
.
QUOTE_STRING_MODE
,
HTML_TEMPLATE
,
CSS_TEMPLATE
,
TEMPLATE_STRING
,
hljs
.
C_LINE_COMMENT_MODE
,
hljs
.
COMMENT
(
'/
\\
*
\\
*'
,
'
\\
*/'
,
{
relevance
:
0
,
contains
:
[
{
className
:
'doctag'
,
begin
:
'@[A-Za-z]+'
,
contains
:
[
{
className
:
'type'
,
begin
:
'
\\
{'
,
end
:
'
\\
}'
,
relevance
:
0
},
{
className
:
'variable'
,
begin
:
IDENT_RE
+
'(?=
\\
s*(-)|$)'
,
endsParent
:
true
,
relevance
:
0
},
// eat spaces (not newlines) so we can find
// types or variables
{
begin
:
/
(?=[^\n])\s
/
,
relevance
:
0
},
]
}
]
}
),
hljs
.
C_BLOCK_COMMENT_MODE
,
NUMBER
,
{
// object attr container
begin
:
/
[
{,
\n]\s
*/
,
relevance
:
0
,
contains
:
[
{
begin
:
IDENT_RE
+
'
\\
s*:'
,
returnBegin
:
true
,
relevance
:
0
,
contains
:
[{
className
:
'attr'
,
begin
:
IDENT_RE
,
relevance
:
0
}]
}
]
},
{
// "value" container
begin
:
'('
+
hljs
.
RE_STARTERS_RE
+
'|
\\
b(case|return|throw)
\\
b)
\\
s*'
,
keywords
:
'return throw case'
,
contains
:
[
hljs
.
C_LINE_COMMENT_MODE
,
hljs
.
C_BLOCK_COMMENT_MODE
,
hljs
.
REGEXP_MODE
,
{
className
:
'function'
,
begin
:
'(
\\
(.*?
\\
)|'
+
IDENT_RE
+
')
\\
s*=>'
,
returnBegin
:
true
,
end
:
'
\\
s*=>'
,
contains
:
[
{
className
:
'params'
,
variants
:
[
{
begin
:
IDENT_RE
},
{
begin
:
/
\(\s
*
\)
/
,
},
{
begin
:
/
\(
/
,
end
:
/
\)
/
,
excludeBegin
:
true
,
excludeEnd
:
true
,
keywords
:
KEYWORDS
,
contains
:
PARAMS_CONTAINS
}
]
}
]
},
{
className
:
''
,
begin
:
/
\s
/
,
end
:
/
\s
*/
,
skip
:
true
,
},
{
// JSX
variants
:
[
{
begin
:
FRAGMENT
.
begin
,
end
:
FRAGMENT
.
end
},
{
begin
:
XML_TAG
.
begin
,
end
:
XML_TAG
.
end
}
],
subLanguage
:
'xml'
,
contains
:
[
{
begin
:
XML_TAG
.
begin
,
end
:
XML_TAG
.
end
,
skip
:
true
,
contains
:
[
'self'
]
}
]
},
],
relevance
:
0
},
{
className
:
'function'
,
beginKeywords
:
'function'
,
end
:
/
\{
/
,
excludeEnd
:
true
,
contains
:
[
hljs
.
inherit
(
hljs
.
TITLE_MODE
,
{
begin
:
IDENT_RE
}),
{
className
:
'params'
,
begin
:
/
\(
/
,
end
:
/
\)
/
,
excludeBegin
:
true
,
excludeEnd
:
true
,
contains
:
PARAMS_CONTAINS
}
],
illegal
:
/
\[
|%/
},
{
begin
:
/
\$[
(.
]
/
// relevance booster for a pattern common to JS libs: `$(something)` and `$.something`
},
hljs
.
METHOD_GUARD
,
{
// ES6 class
className
:
'class'
,
beginKeywords
:
'class'
,
end
:
/
[
{;=
]
/
,
excludeEnd
:
true
,
illegal
:
/
[
:"
\[\]]
/
,
contains
:
[
{
beginKeywords
:
'extends'
},
hljs
.
UNDERSCORE_TITLE_MODE
]
},
{
beginKeywords
:
'constructor get set'
,
end
:
/
\{
/
,
excludeEnd
:
true
}
],
illegal
:
/#
(?!
!
)
/
};
};
src/components/FirstUI/fui-parse/high-light/languages/markdown.js
deleted
100644 → 0
浏览文件 @
b91bebf0
/**
* Modified by: firstui
* organization: FirstUI(https://www.firstui.cn/)
*/
export
default
function
(
hljs
)
{
return
{
aliases
:
[
'md'
,
'mkdown'
,
'mkd'
],
contains
:
[
// highlight headers
{
className
:
'section'
,
variants
:
[
{
begin
:
'^#{1,6}'
,
end
:
'$'
},
{
begin
:
'^.+?
\\
n[=-]{2,}$'
}
]
},
// inline html
{
begin
:
'<'
,
end
:
'>'
,
subLanguage
:
'xml'
,
relevance
:
0
},
// lists (indicators only)
{
className
:
'bullet'
,
begin
:
'^
\\
s*([*+-]|(
\\
d+
\\
.))
\\
s+'
},
// strong segments
{
className
:
'strong'
,
begin
:
'[*_]{2}.+?[*_]{2}'
},
// emphasis segments
{
className
:
'emphasis'
,
variants
:
[
{
begin
:
'
\\
*.+?
\\
*'
},
{
begin
:
'_.+?_'
,
relevance
:
0
}
]
},
// blockquotes
{
className
:
'quote'
,
begin
:
'^>
\\
s+'
,
end
:
'$'
},
// code snippets
{
className
:
'code'
,
variants
:
[
{
begin
:
'^```
\\
w*
\\
s*$'
,
end
:
'^```[ ]*$'
},
{
begin
:
'`.+?`'
},
{
begin
:
'^( {4}|
\\
t)'
,
end
:
'$'
,
relevance
:
0
}
]
},
// horizontal rules
{
begin
:
'^[-
\\
*]{3,}'
,
end
:
'$'
},
// using links - title and link
{
begin
:
'
\\
[.+?
\\
][
\\
(
\\
[].*?[
\\
)
\\
]]'
,
returnBegin
:
true
,
contains
:
[
{
className
:
'string'
,
begin
:
'
\\
['
,
end
:
'
\\
]'
,
excludeBegin
:
true
,
returnEnd
:
true
,
relevance
:
0
},
{
className
:
'link'
,
begin
:
'
\\
]
\\
('
,
end
:
'
\\
)'
,
excludeBegin
:
true
,
excludeEnd
:
true
},
{
className
:
'symbol'
,
begin
:
'
\\
]
\\
['
,
end
:
'
\\
]'
,
excludeBegin
:
true
,
excludeEnd
:
true
}
],
relevance
:
10
},
{
begin
:
/^
\[[^\n]
+
\]
:/
,
returnBegin
:
true
,
contains
:
[
{
className
:
'symbol'
,
begin
:
/
\[
/
,
end
:
/
\]
/
,
excludeBegin
:
true
,
excludeEnd
:
true
},
{
className
:
'link'
,
begin
:
/:
\s
*/
,
end
:
/$/
,
excludeBegin
:
true
}
]
}
]
};
};
src/components/FirstUI/fui-parse/high-light/languages/sql.js
deleted
100644 → 0
浏览文件 @
b91bebf0
/**
* Modified by: firstui
* organization: FirstUI(https://www.firstui.cn/)
*/
export
default
function
(
hljs
)
{
var
COMMENT_MODE
=
hljs
.
COMMENT
(
'--'
,
'$'
);
return
{
case_insensitive
:
true
,
illegal
:
/
[
<>{}*
]
/
,
contains
:
[
{
beginKeywords
:
'begin end start commit rollback savepoint lock alter create drop rename call '
+
'delete do handler insert load replace select truncate update set show pragma grant '
+
'merge describe use explain help declare prepare execute deallocate release '
+
'unlock purge reset change stop analyze cache flush optimize repair kill '
+
'install uninstall checksum restore check backup revoke comment values with'
,
end
:
/;/
,
endsWithParent
:
true
,
lexemes
:
/
[\w\.]
+/
,
keywords
:
{
keyword
:
'as abort abs absolute acc acce accep accept access accessed accessible account acos action activate add '
+
'addtime admin administer advanced advise aes_decrypt aes_encrypt after agent aggregate ali alia alias '
+
'all allocate allow alter always analyze ancillary and anti any anydata anydataset anyschema anytype apply '
+
'archive archived archivelog are as asc ascii asin assembly assertion associate asynchronous at atan '
+
'atn2 attr attri attrib attribu attribut attribute attributes audit authenticated authentication authid '
+
'authors auto autoallocate autodblink autoextend automatic availability avg backup badfile basicfile '
+
'before begin beginning benchmark between bfile bfile_base big bigfile bin binary_double binary_float '
+
'binlog bit_and bit_count bit_length bit_or bit_xor bitmap blob_base block blocksize body both bound '
+
'bucket buffer_cache buffer_pool build bulk by byte byteordermark bytes cache caching call calling cancel '
+
'capacity cascade cascaded case cast catalog category ceil ceiling chain change changed char_base '
+
'char_length character_length characters characterset charindex charset charsetform charsetid check '
+
'checksum checksum_agg child choose chr chunk class cleanup clear client clob clob_base clone close '
+
'cluster_id cluster_probability cluster_set clustering coalesce coercibility col collate collation '
+
'collect colu colum column column_value columns columns_updated comment commit compact compatibility '
+
'compiled complete composite_limit compound compress compute concat concat_ws concurrent confirm conn '
+
'connec connect connect_by_iscycle connect_by_isleaf connect_by_root connect_time connection '
+
'consider consistent constant constraint constraints constructor container content contents context '
+
'contributors controlfile conv convert convert_tz corr corr_k corr_s corresponding corruption cos cost '
+
'count count_big counted covar_pop covar_samp cpu_per_call cpu_per_session crc32 create creation '
+
'critical cross cube cume_dist curdate current current_date current_time current_timestamp current_user '
+
'cursor curtime customdatum cycle data database databases datafile datafiles datalength date_add '
+
'date_cache date_format date_sub dateadd datediff datefromparts datename datepart datetime2fromparts '
+
'day day_to_second dayname dayofmonth dayofweek dayofyear days db_role_change dbtimezone ddl deallocate '
+
'declare decode decompose decrement decrypt deduplicate def defa defau defaul default defaults '
+
'deferred defi defin define degrees delayed delegate delete delete_all delimited demand dense_rank '
+
'depth dequeue des_decrypt des_encrypt des_key_file desc descr descri describ describe descriptor '
+
'deterministic diagnostics difference dimension direct_load directory disable disable_all '
+
'disallow disassociate discardfile disconnect diskgroup distinct distinctrow distribute distributed div '
+
'do document domain dotnet double downgrade drop dumpfile duplicate duration each edition editionable '
+
'editions element ellipsis else elsif elt empty enable enable_all enclosed encode encoding encrypt '
+
'end end-exec endian enforced engine engines enqueue enterprise entityescaping eomonth error errors '
+
'escaped evalname evaluate event eventdata events except exception exceptions exchange exclude excluding '
+
'execu execut execute exempt exists exit exp expire explain explode export export_set extended extent external '
+
'external_1 external_2 externally extract failed failed_login_attempts failover failure far fast '
+
'feature_set feature_value fetch field fields file file_name_convert filesystem_like_logging final '
+
'finish first first_value fixed flash_cache flashback floor flush following follows for forall force foreign '
+
'form forma format found found_rows freelist freelists freepools fresh from from_base64 from_days '
+
'ftp full function general generated get get_format get_lock getdate getutcdate global global_name '
+
'globally go goto grant grants greatest group group_concat group_id grouping grouping_id groups '
+
'gtid_subtract guarantee guard handler hash hashkeys having hea head headi headin heading heap help hex '
+
'hierarchy high high_priority hosts hour hours http id ident_current ident_incr ident_seed identified '
+
'identity idle_time if ifnull ignore iif ilike ilm immediate import in include including increment '
+
'index indexes indexing indextype indicator indices inet6_aton inet6_ntoa inet_aton inet_ntoa infile '
+
'initial initialized initially initrans inmemory inner innodb input insert install instance instantiable '
+
'instr interface interleaved intersect into invalidate invisible is is_free_lock is_ipv4 is_ipv4_compat '
+
'is_not is_not_null is_used_lock isdate isnull isolation iterate java join json json_exists '
+
'keep keep_duplicates key keys kill language large last last_day last_insert_id last_value lateral lax lcase '
+
'lead leading least leaves left len lenght length less level levels library like like2 like4 likec limit '
+
'lines link list listagg little ln load load_file lob lobs local localtime localtimestamp locate '
+
'locator lock locked log log10 log2 logfile logfiles logging logical logical_reads_per_call '
+
'logoff logon logs long loop low low_priority lower lpad lrtrim ltrim main make_set makedate maketime '
+
'managed management manual map mapping mask master master_pos_wait match matched materialized max '
+
'maxextents maximize maxinstances maxlen maxlogfiles maxloghistory maxlogmembers maxsize maxtrans '
+
'md5 measures median medium member memcompress memory merge microsecond mid migration min minextents '
+
'minimum mining minus minute minutes minvalue missing mod mode model modification modify module monitoring month '
+
'months mount move movement multiset mutex name name_const names nan national native natural nav nchar '
+
'nclob nested never new newline next nextval no no_write_to_binlog noarchivelog noaudit nobadfile '
+
'nocheck nocompress nocopy nocycle nodelay nodiscardfile noentityescaping noguarantee nokeep nologfile '
+
'nomapping nomaxvalue nominimize nominvalue nomonitoring none noneditionable nonschema noorder '
+
'nopr nopro noprom nopromp noprompt norely noresetlogs noreverse normal norowdependencies noschemacheck '
+
'noswitch not nothing notice notnull notrim novalidate now nowait nth_value nullif nulls num numb numbe '
+
'nvarchar nvarchar2 object ocicoll ocidate ocidatetime ociduration ociinterval ociloblocator ocinumber '
+
'ociref ocirefcursor ocirowid ocistring ocitype oct octet_length of off offline offset oid oidindex old '
+
'on online only opaque open operations operator optimal optimize option optionally or oracle oracle_date '
+
'oradata ord ordaudio orddicom orddoc order ordimage ordinality ordvideo organization orlany orlvary '
+
'out outer outfile outline output over overflow overriding package pad parallel parallel_enable '
+
'parameters parent parse partial partition partitions pascal passing password password_grace_time '
+
'password_lock_time password_reuse_max password_reuse_time password_verify_function patch path patindex '
+
'pctincrease pctthreshold pctused pctversion percent percent_rank percentile_cont percentile_disc '
+
'performance period period_add period_diff permanent physical pi pipe pipelined pivot pluggable plugin '
+
'policy position post_transaction pow power pragma prebuilt precedes preceding precision prediction '
+
'prediction_cost prediction_details prediction_probability prediction_set prepare present preserve '
+
'prior priority private private_sga privileges procedural procedure procedure_analyze processlist '
+
'profiles project prompt protection public publishingservername purge quarter query quick quiesce quota '
+
'quotename radians raise rand range rank raw read reads readsize rebuild record records '
+
'recover recovery recursive recycle redo reduced ref reference referenced references referencing refresh '
+
'regexp_like register regr_avgx regr_avgy regr_count regr_intercept regr_r2 regr_slope regr_sxx regr_sxy '
+
'reject rekey relational relative relaylog release release_lock relies_on relocate rely rem remainder rename '
+
'repair repeat replace replicate replication required reset resetlogs resize resource respect restore '
+
'restricted result result_cache resumable resume retention return returning returns reuse reverse revoke '
+
'right rlike role roles rollback rolling rollup round row row_count rowdependencies rowid rownum rows '
+
'rtrim rules safe salt sample save savepoint sb1 sb2 sb4 scan schema schemacheck scn scope scroll '
+
'sdo_georaster sdo_topo_geometry search sec_to_time second seconds section securefile security seed segment select '
+
'self semi sequence sequential serializable server servererror session session_user sessions_per_user set '
+
'sets settings sha sha1 sha2 share shared shared_pool short show shrink shutdown si_averagecolor '
+
'si_colorhistogram si_featurelist si_positionalcolor si_stillimage si_texture siblings sid sign sin '
+
'size size_t sizes skip slave sleep smalldatetimefromparts smallfile snapshot some soname sort soundex '
+
'source space sparse spfile split sql sql_big_result sql_buffer_result sql_cache sql_calc_found_rows '
+
'sql_small_result sql_variant_property sqlcode sqldata sqlerror sqlname sqlstate sqrt square standalone '
+
'standby start starting startup statement static statistics stats_binomial_test stats_crosstab '
+
'stats_ks_test stats_mode stats_mw_test stats_one_way_anova stats_t_test_ stats_t_test_indep '
+
'stats_t_test_one stats_t_test_paired stats_wsr_test status std stddev stddev_pop stddev_samp stdev '
+
'stop storage store stored str str_to_date straight_join strcmp strict string struct stuff style subdate '
+
'subpartition subpartitions substitutable substr substring subtime subtring_index subtype success sum '
+
'suspend switch switchoffset switchover sync synchronous synonym sys sys_xmlagg sysasm sysaux sysdate '
+
'sysdatetimeoffset sysdba sysoper system system_user sysutcdatetime table tables tablespace tablesample tan tdo '
+
'template temporary terminated tertiary_weights test than then thread through tier ties time time_format '
+
'time_zone timediff timefromparts timeout timestamp timestampadd timestampdiff timezone_abbr '
+
'timezone_minute timezone_region to to_base64 to_date to_days to_seconds todatetimeoffset trace tracking '
+
'transaction transactional translate translation treat trigger trigger_nestlevel triggers trim truncate '
+
'try_cast try_convert try_parse type ub1 ub2 ub4 ucase unarchived unbounded uncompress '
+
'under undo unhex unicode uniform uninstall union unique unix_timestamp unknown unlimited unlock unnest unpivot '
+
'unrecoverable unsafe unsigned until untrusted unusable unused update updated upgrade upped upper upsert '
+
'url urowid usable usage use use_stored_outlines user user_data user_resources users using utc_date '
+
'utc_timestamp uuid uuid_short validate validate_password_strength validation valist value values var '
+
'var_samp varcharc vari varia variab variabl variable variables variance varp varraw varrawc varray '
+
'verify version versions view virtual visible void wait wallet warning warnings week weekday weekofyear '
+
'wellformed when whene whenev wheneve whenever where while whitespace window with within without work wrapped '
+
'xdb xml xmlagg xmlattributes xmlcast xmlcolattval xmlelement xmlexists xmlforest xmlindex xmlnamespaces '
+
'xmlpi xmlquery xmlroot xmlschema xmlserialize xmltable xmltype xor year year_to_month years yearweek'
,
literal
:
'true false null unknown'
,
built_in
:
'array bigint binary bit blob bool boolean char character date dec decimal float int int8 integer interval number '
+
'numeric real record serial serial8 smallint text time timestamp tinyint varchar varchar2 varying void'
},
contains
:
[
{
className
:
'string'
,
begin
:
'
\'
'
,
end
:
'
\'
'
,
contains
:
[{
begin
:
'
\'\'
'
}]
},
{
className
:
'string'
,
begin
:
'"'
,
end
:
'"'
,
contains
:
[{
begin
:
'""'
}]
},
{
className
:
'string'
,
begin
:
'`'
,
end
:
'`'
},
hljs
.
C_NUMBER_MODE
,
hljs
.
C_BLOCK_COMMENT_MODE
,
COMMENT_MODE
,
hljs
.
HASH_COMMENT_MODE
]
},
hljs
.
C_BLOCK_COMMENT_MODE
,
COMMENT_MODE
,
hljs
.
HASH_COMMENT_MODE
]
};
};
src/components/FirstUI/fui-parse/high-light/languages/typescript.js
deleted
100644 → 0
浏览文件 @
b91bebf0
/**
* Modified by: firstui
* organization: FirstUI(https://www.firstui.cn/)
*/
export
default
function
(
hljs
)
{
var
JS_IDENT_RE
=
'[A-Za-z$_][0-9A-Za-z$_]*'
;
var
KEYWORDS
=
{
keyword
:
'in if for while finally var new function do return void else break catch '
+
'instanceof with throw case default try this switch continue typeof delete '
+
'let yield const class public private protected get set super '
+
'static implements enum export import declare type namespace abstract '
+
'as from extends async await'
,
literal
:
'true false null undefined NaN Infinity'
,
built_in
:
'eval isFinite isNaN parseFloat parseInt decodeURI decodeURIComponent '
+
'encodeURI encodeURIComponent escape unescape Object Function Boolean Error '
+
'EvalError InternalError RangeError ReferenceError StopIteration SyntaxError '
+
'TypeError URIError Number Math Date String RegExp Array Float32Array '
+
'Float64Array Int16Array Int32Array Int8Array Uint16Array Uint32Array '
+
'Uint8Array Uint8ClampedArray ArrayBuffer DataView JSON Intl arguments require '
+
'module console window document any number boolean string void Promise'
};
var
DECORATOR
=
{
className
:
'meta'
,
begin
:
'@'
+
JS_IDENT_RE
,
};
var
ARGS
=
{
begin
:
'
\\
('
,
end
:
/
\)
/
,
keywords
:
KEYWORDS
,
contains
:
[
'self'
,
hljs
.
QUOTE_STRING_MODE
,
hljs
.
APOS_STRING_MODE
,
hljs
.
NUMBER_MODE
]
};
var
PARAMS
=
{
className
:
'params'
,
begin
:
/
\(
/
,
end
:
/
\)
/
,
excludeBegin
:
true
,
excludeEnd
:
true
,
keywords
:
KEYWORDS
,
contains
:
[
hljs
.
C_LINE_COMMENT_MODE
,
hljs
.
C_BLOCK_COMMENT_MODE
,
DECORATOR
,
ARGS
]
};
var
NUMBER
=
{
className
:
'number'
,
variants
:
[
{
begin
:
'
\\
b(0[bB][01]+)n?'
},
{
begin
:
'
\\
b(0[oO][0-7]+)n?'
},
{
begin
:
hljs
.
C_NUMBER_RE
+
'n?'
}
],
relevance
:
0
};
var
SUBST
=
{
className
:
'subst'
,
begin
:
'
\\
$
\\
{'
,
end
:
'
\\
}'
,
keywords
:
KEYWORDS
,
contains
:
[]
// defined later
};
var
HTML_TEMPLATE
=
{
begin
:
'html`'
,
end
:
''
,
starts
:
{
end
:
'`'
,
returnEnd
:
false
,
contains
:
[
hljs
.
BACKSLASH_ESCAPE
,
SUBST
],
subLanguage
:
'xml'
,
}
};
var
CSS_TEMPLATE
=
{
begin
:
'css`'
,
end
:
''
,
starts
:
{
end
:
'`'
,
returnEnd
:
false
,
contains
:
[
hljs
.
BACKSLASH_ESCAPE
,
SUBST
],
subLanguage
:
'css'
,
}
};
var
TEMPLATE_STRING
=
{
className
:
'string'
,
begin
:
'`'
,
end
:
'`'
,
contains
:
[
hljs
.
BACKSLASH_ESCAPE
,
SUBST
]
};
SUBST
.
contains
=
[
hljs
.
APOS_STRING_MODE
,
hljs
.
QUOTE_STRING_MODE
,
HTML_TEMPLATE
,
CSS_TEMPLATE
,
TEMPLATE_STRING
,
NUMBER
,
hljs
.
REGEXP_MODE
];
return
{
aliases
:
[
'ts'
],
keywords
:
KEYWORDS
,
contains
:
[
{
className
:
'meta'
,
begin
:
/^
\s
*
[
'"
]
use strict
[
'"
]
/
},
hljs
.
APOS_STRING_MODE
,
hljs
.
QUOTE_STRING_MODE
,
HTML_TEMPLATE
,
CSS_TEMPLATE
,
TEMPLATE_STRING
,
hljs
.
C_LINE_COMMENT_MODE
,
hljs
.
C_BLOCK_COMMENT_MODE
,
NUMBER
,
{
// "value" container
begin
:
'('
+
hljs
.
RE_STARTERS_RE
+
'|
\\
b(case|return|throw)
\\
b)
\\
s*'
,
keywords
:
'return throw case'
,
contains
:
[
hljs
.
C_LINE_COMMENT_MODE
,
hljs
.
C_BLOCK_COMMENT_MODE
,
hljs
.
REGEXP_MODE
,
{
className
:
'function'
,
begin
:
'(
\\
(.*?
\\
)|'
+
hljs
.
IDENT_RE
+
')
\\
s*=>'
,
returnBegin
:
true
,
end
:
'
\\
s*=>'
,
contains
:
[
{
className
:
'params'
,
variants
:
[
{
begin
:
hljs
.
IDENT_RE
},
{
begin
:
/
\(\s
*
\)
/
,
},
{
begin
:
/
\(
/
,
end
:
/
\)
/
,
excludeBegin
:
true
,
excludeEnd
:
true
,
keywords
:
KEYWORDS
,
contains
:
[
'self'
,
hljs
.
C_LINE_COMMENT_MODE
,
hljs
.
C_BLOCK_COMMENT_MODE
]
}
]
}
]
}
],
relevance
:
0
},
{
className
:
'function'
,
beginKeywords
:
'function'
,
end
:
/
[\{
;
]
/
,
excludeEnd
:
true
,
keywords
:
KEYWORDS
,
contains
:
[
'self'
,
hljs
.
inherit
(
hljs
.
TITLE_MODE
,
{
begin
:
JS_IDENT_RE
}),
PARAMS
],
illegal
:
/%/
,
relevance
:
0
// () => {} is more typical in TypeScript
},
{
beginKeywords
:
'constructor'
,
end
:
/
[\{
;
]
/
,
excludeEnd
:
true
,
contains
:
[
'self'
,
PARAMS
]
},
{
// prevent references like module.id from being higlighted as module definitions
begin
:
/module
\.
/
,
keywords
:
{
built_in
:
'module'
},
relevance
:
0
},
{
beginKeywords
:
'module'
,
end
:
/
\{
/
,
excludeEnd
:
true
},
{
beginKeywords
:
'interface'
,
end
:
/
\{
/
,
excludeEnd
:
true
,
keywords
:
'interface extends'
},
{
begin
:
/
\$[
(.
]
/
// relevance booster for a pattern common to JS libs: `$(something)` and `$.something`
},
{
begin
:
'
\\
.'
+
hljs
.
IDENT_RE
,
relevance
:
0
// hack: prevents detection of keywords after dots
},
DECORATOR
,
ARGS
]
};
};
src/components/FirstUI/fui-parse/high-light/languages/xml.js
deleted
100644 → 0
浏览文件 @
b91bebf0
/**
* Modified by: firstui
* organization: FirstUI(https://www.firstui.cn/)
*/
export
default
function
(
hljs
)
{
var
XML_IDENT_RE
=
'[A-Za-z0-9
\\
._:-]+'
;
var
XML_ENTITIES
=
{
className
:
'symbol'
,
begin
:
'&[a-z]+;|&#[0-9]+;|&#x[a-f0-9]+;'
};
var
XML_META_KEYWORDS
=
{
begin
:
'
\\
s'
,
contains
:[
{
className
:
'meta-keyword'
,
begin
:
'#?[a-z_][a-z1-9_-]+'
,
illegal
:
'
\\
n'
,
}
]
};
var
XML_META_PAR_KEYWORDS
=
hljs
.
inherit
(
XML_META_KEYWORDS
,
{
begin
:
'
\\
('
,
end
:
'
\\
)'
});
var
APOS_META_STRING_MODE
=
hljs
.
inherit
(
hljs
.
APOS_STRING_MODE
,
{
className
:
'meta-string'
});
var
QUOTE_META_STRING_MODE
=
hljs
.
inherit
(
hljs
.
QUOTE_STRING_MODE
,
{
className
:
'meta-string'
});
var
TAG_INTERNALS
=
{
endsWithParent
:
true
,
illegal
:
/</
,
relevance
:
0
,
contains
:
[
{
className
:
'attr'
,
begin
:
XML_IDENT_RE
,
relevance
:
0
},
{
begin
:
/=
\s
*/
,
relevance
:
0
,
contains
:
[
{
className
:
'string'
,
endsParent
:
true
,
variants
:
[
{
begin
:
/"/
,
end
:
/"/
,
contains
:
[
XML_ENTITIES
]},
{
begin
:
/'/
,
end
:
/'/
,
contains
:
[
XML_ENTITIES
]},
{
begin
:
/
[^\s
"'=<>`
]
+/
}
]
}
]
}
]
};
return
{
aliases
:
[
'html'
,
'xhtml'
,
'rss'
,
'atom'
,
'xjb'
,
'xsd'
,
'xsl'
,
'plist'
,
'wsf'
,
'svg'
],
case_insensitive
:
true
,
contains
:
[
{
className
:
'meta'
,
begin
:
'<![a-z]'
,
end
:
'>'
,
relevance
:
10
,
contains
:
[
XML_META_KEYWORDS
,
QUOTE_META_STRING_MODE
,
APOS_META_STRING_MODE
,
XML_META_PAR_KEYWORDS
,
{
begin
:
'
\\
['
,
end
:
'
\\
]'
,
contains
:[
{
className
:
'meta'
,
begin
:
'<![a-z]'
,
end
:
'>'
,
contains
:
[
XML_META_KEYWORDS
,
XML_META_PAR_KEYWORDS
,
QUOTE_META_STRING_MODE
,
APOS_META_STRING_MODE
]
}
]
}
]
},
hljs
.
COMMENT
(
'<!--'
,
'-->'
,
{
relevance
:
10
}
),
{
begin
:
'<
\\
!
\\
[CDATA
\\
['
,
end
:
'
\\
]
\\
]>'
,
relevance
:
10
},
XML_ENTITIES
,
{
className
:
'meta'
,
begin
:
/<
\?
xml/
,
end
:
/
\?
>/
,
relevance
:
10
},
{
begin
:
/<
\?(
php
)?
/
,
end
:
/
\?
>/
,
subLanguage
:
'php'
,
contains
:
[
// We don't want the php closing tag ?> to close the PHP block when
// inside any of the following blocks:
{
begin
:
'/
\\
*'
,
end
:
'
\\
*/'
,
skip
:
true
},
{
begin
:
'b"'
,
end
:
'"'
,
skip
:
true
},
{
begin
:
'b
\'
'
,
end
:
'
\'
'
,
skip
:
true
},
hljs
.
inherit
(
hljs
.
APOS_STRING_MODE
,
{
illegal
:
null
,
className
:
null
,
contains
:
null
,
skip
:
true
}),
hljs
.
inherit
(
hljs
.
QUOTE_STRING_MODE
,
{
illegal
:
null
,
className
:
null
,
contains
:
null
,
skip
:
true
})
]
},
{
className
:
'tag'
,
/*
The lookahead pattern (?=...) ensures that 'begin' only matches
'<style' as a single word, followed by a whitespace or an
ending braket. The '$' is needed for the lexeme to be recognized
by hljs.subMode() that tests lexemes outside the stream.
*/
begin
:
'<style(?=
\\
s|>)'
,
end
:
'>'
,
keywords
:
{
name
:
'style'
},
contains
:
[
TAG_INTERNALS
],
starts
:
{
end
:
'</style>'
,
returnEnd
:
true
,
subLanguage
:
[
'css'
,
'xml'
]
}
},
{
className
:
'tag'
,
// See the comment in the <style tag about the lookahead pattern
begin
:
'<script(?=
\\
s|>)'
,
end
:
'>'
,
keywords
:
{
name
:
'script'
},
contains
:
[
TAG_INTERNALS
],
starts
:
{
end
:
'
\
<
\
/script
\
>'
,
returnEnd
:
true
,
subLanguage
:
[
'actionscript'
,
'javascript'
,
'handlebars'
,
'xml'
]
}
},
{
className
:
'tag'
,
begin
:
'</?'
,
end
:
'/?>'
,
contains
:
[
{
className
:
'name'
,
begin
:
/
[^\/
><
\s]
+/
,
relevance
:
0
},
TAG_INTERNALS
]
}
]
};
};
src/components/FirstUI/fui-parse/high-light/regex.js
deleted
100644 → 0
浏览文件 @
b91bebf0
/**
* @param {string} value
* @returns {RegExp}
* */
export
function
escape
(
value
)
{
return
new
RegExp
(
value
.
replace
(
/
[
-
/\\
^$*+?.()|[
\]
{}
]
/g
,
'
\\
$&'
),
'm'
);
}
/**
* @param {RegExp | string } re
* @returns {string}
*/
export
function
source
(
re
)
{
if
(
!
re
)
return
null
;
if
(
typeof
re
===
"string"
)
return
re
;
return
re
.
source
;
}
/**
* @param {RegExp | string } re
* @returns {string}
*/
export
function
lookahead
(
re
)
{
return
concat
(
'(?='
,
re
,
')'
);
}
/**
* @param {RegExp | string } re
* @returns {string}
*/
export
function
anyNumberOfTimes
(
re
)
{
return
concat
(
'('
,
re
,
')*'
);
}
/**
* @param {RegExp | string } re
* @returns {string}
*/
export
function
optional
(
re
)
{
return
concat
(
'('
,
re
,
')?'
);
}
/**
* @param {...(RegExp | string) } args
* @returns {string}
*/
export
function
concat
(...
args
)
{
const
joined
=
args
.
map
((
x
)
=>
source
(
x
)).
join
(
""
);
return
joined
;
}
/**
* Any of the passed expresssions may match
*
* Creates a huge this | this | that | that match
* @param {(RegExp | string)[] } args
* @returns {string}
*/
export
function
either
(...
args
)
{
const
joined
=
'('
+
args
.
map
((
x
)
=>
source
(
x
)).
join
(
"|"
)
+
")"
;
return
joined
;
}
/**
* @param {RegExp} re
* @returns {number}
*/
export
function
countMatchGroups
(
re
)
{
return
(
new
RegExp
(
re
.
toString
()
+
'|'
)).
exec
(
''
).
length
-
1
;
}
/**
* Does lexeme start with a regular expression match at the beginning
* @param {RegExp} re
* @param {string} lexeme
*/
export
function
startsWith
(
re
,
lexeme
)
{
const
match
=
re
&&
re
.
exec
(
lexeme
);
return
match
&&
match
.
index
===
0
;
}
// join logically computes regexps.join(separator), but fixes the
// backreferences so they continue to match.
// it also places each individual regular expression into it's own
// match group, keeping track of the sequencing of those match groups
// is currently an exercise for the caller. :-)
/**
* @param {(string | RegExp)[]} regexps
* @param {string} separator
* @returns {string}
*/
export
function
join
(
regexps
,
separator
=
"|"
)
{
// backreferenceRe matches an open parenthesis or backreference. To avoid
// an incorrect parse, it additionally matches the following:
// - [...] elements, where the meaning of parentheses and escapes change
// - other escape sequences, so we do not misparse escape sequences as
// interesting elements
// - non-matching or lookahead parentheses, which do not capture. These
// follow the '(' with a '?'.
const
backreferenceRe
=
/
\[(?:[^\\\]]
|
\\
.
)
*
\]
|
\(\??
|
\\([
1-9
][
0-9
]
*
)
|
\\
./
;
let
numCaptures
=
0
;
let
ret
=
''
;
for
(
let
i
=
0
;
i
<
regexps
.
length
;
i
++
)
{
numCaptures
+=
1
;
const
offset
=
numCaptures
;
let
re
=
source
(
regexps
[
i
]);
if
(
i
>
0
)
{
ret
+=
separator
;
}
ret
+=
"("
;
while
(
re
.
length
>
0
)
{
const
match
=
backreferenceRe
.
exec
(
re
);
if
(
match
==
null
)
{
ret
+=
re
;
break
;
}
ret
+=
re
.
substring
(
0
,
match
.
index
);
re
=
re
.
substring
(
match
.
index
+
match
[
0
].
length
);
if
(
match
[
0
][
0
]
===
'
\
\'
&& match[1]) {
// Adjust the backreference.
ret += '
\\
' + String(Number(match[1]) + offset);
} else {
ret += match[0];
if (match[0] === '
(
') {
numCaptures++;
}
}
}
ret += ")";
}
return ret;
}
src/components/FirstUI/fui-parse/marked/index.js
deleted
100644 → 0
浏览文件 @
b91bebf0
/**
* marked - a markdown parser
* Copyright (c) 2011-2014, Christopher Jeffrey. (MIT Licensed)
* https://github.com/markedjs/marked
*/
// (function(root, markedRoot) {
'use strict'
;
/**
* Block-Level Grammar
*/
var
block
=
{
newline
:
/^
\n
+/
,
code
:
/^
(
{4}[^\n]
+
\n
*
)
+/
,
fences
:
noop
,
hr
:
/^
{0,3}((?:
- *
){3,}
|
(?:
_ *
){3,}
|
(?:\*
*
){3,})(?:\n
+|$
)
/
,
heading
:
/^ *
(
#
{1,6})
*
([^\n]
+
?)
*
(?:
#+ *
)?(?:\n
+|$
)
/
,
nptable
:
noop
,
blockquote
:
/^
(
{0,3}
>
?(
paragraph|
[^\n]
*
)(?:\n
|$
))
+/
,
list
:
/^
(
*
)(
bull
)
[\s\S]
+
?(?:
hr|def|
\n{2,}(?!
)(?!\1
bull
)\n
*|
\s
*$
)
/
,
html
:
'^ {0,3}(?:'
// optional indentation
+
'<(script|pre|style)[
\\
s>][
\\
s
\\
S]*?(?:</
\\
1>[^
\\
n]*
\\
n+|$)'
// (1)
+
'|comment[^
\\
n]*(
\\
n+|$)'
// (2)
+
'|<
\\
?[
\\
s
\\
S]*?
\\
?>
\\
n*'
// (3)
+
'|<![A-Z][
\\
s
\\
S]*?>
\\
n*'
// (4)
+
'|<!
\\
[CDATA
\\
[[
\\
s
\\
S]*?
\\
]
\\
]>
\\
n*'
// (5)
+
'|</?(tag)(?: +|
\\
n|/?>)[
\\
s
\\
S]*?(?:
\\
n{2,}|$)'
// (6)
+
'|<(?!script|pre|style)([a-z][
\\
w-]*)(?:attribute)*? */?>(?=
\\
h*
\\
n)[
\\
s
\\
S]*?(?:
\\
n{2,}|$)'
// (7) open tag
+
'|</(?!script|pre|style)[a-z][
\\
w-]*
\\
s*>(?=
\\
h*
\\
n)[
\\
s
\\
S]*?(?:
\\
n{2,}|$)'
// (7) closing tag
+
')'
,
def
:
/^
{0,3}\[(
label
)\]
: *
\n?
*<
?([^\s
>
]
+
)
>
?(?:(?:
+
\n?
*| *
\n
*
)(
title
))?
*
(?:\n
+|$
)
/
,
table
:
noop
,
lheading
:
/^
([^\n]
+
)\n
*
(
=|-
){2,}
*
(?:\n
+|$
)
/
,
paragraph
:
/^
([^\n]
+
(?:\n(?!
hr|heading|lheading|
{0,3}
>|<
\/?(?:
tag
)(?:
+|
\n
|
\/?
>
)
|<
(?:
script|pre|style|!--
))[^\n]
+
)
*
)
/
,
text
:
/^
[^\n]
+/
};
block
.
_label
=
/
(?!\s
*
\])(?:\\[\[\]]
|
[^\[\]])
+/
;
block
.
_title
=
/
(?:
"
(?:\\
"
?
|
[^
"
\\])
*"|'
[^
'
\n]
*
(?:\n[^
'
\n]
+
)
*
\n?
'|
\([^
()
]
*
\))
/
;
block
.
def
=
edit
(
block
.
def
)
.
replace
(
'label'
,
block
.
_label
)
.
replace
(
'title'
,
block
.
_title
)
.
getRegex
();
block
.
bullet
=
/
(?:[
*+-
]
|
\d
+
\.)
/
;
block
.
item
=
/^
(
*
)(
bull
)
[^\n]
*
(?:\n(?!\1
bull
)[^\n]
*
)
*/
;
block
.
item
=
edit
(
block
.
item
,
'gm'
)
.
replace
(
/bull/g
,
block
.
bullet
)
.
getRegex
();
block
.
list
=
edit
(
block
.
list
)
.
replace
(
/bull/g
,
block
.
bullet
)
.
replace
(
'hr'
,
'
\\
n+(?=
\\
1?(?:(?:- *){3,}|(?:_ *){3,}|(?:
\\
* *){3,})(?:
\\
n+|$))'
)
.
replace
(
'def'
,
'
\\
n+(?='
+
block
.
def
.
source
+
')'
)
.
getRegex
();
block
.
_tag
=
'address|article|aside|base|basefont|blockquote|body|caption'
+
'|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption'
+
'|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe'
+
'|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option'
+
'|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr'
+
'|track|ul'
;
block
.
_comment
=
/<!--
(?!
-
?
>
)[\s\S]
*
?
-->/
;
block
.
html
=
edit
(
block
.
html
,
'i'
)
.
replace
(
'comment'
,
block
.
_comment
)
.
replace
(
'tag'
,
block
.
_tag
)
.
replace
(
'attribute'
,
/ +
[
a-zA-Z:_
][\w
.:-
]
*
(?:
*= *"
[^
"
\n]
*"| *= *'
[^
'
\n]
*'| *= *
[^\s
"'=<>`
]
+
)?
/
)
.
getRegex
();
block
.
paragraph
=
edit
(
block
.
paragraph
)
.
replace
(
'hr'
,
block
.
hr
)
.
replace
(
'heading'
,
block
.
heading
)
.
replace
(
'lheading'
,
block
.
lheading
)
.
replace
(
'tag'
,
block
.
_tag
)
// pars can be interrupted by type (6) html blocks
.
getRegex
();
block
.
blockquote
=
edit
(
block
.
blockquote
)
.
replace
(
'paragraph'
,
block
.
paragraph
)
.
getRegex
();
/**
* Normal Block Grammar
*/
block
.
normal
=
merge
({},
block
);
/**
* GFM Block Grammar
*/
block
.
gfm
=
merge
({},
block
.
normal
,
{
fences
:
/^ *
(
`
{3,}
|~
{3,})[
\.]
*
(\S
+
)?
*
\n([\s\S]
*
?)\n?
*
\1
*
(?:\n
+|$
)
/
,
paragraph
:
/^/
,
heading
:
/^ *
(
#
{1,6})
+
([^\n]
+
?)
*#* *
(?:\n
+|$
)
/
});
block
.
gfm
.
paragraph
=
edit
(
block
.
paragraph
)
.
replace
(
'(?!'
,
'(?!'
+
block
.
gfm
.
fences
.
source
.
replace
(
'
\\
1'
,
'
\\
2'
)
+
'|'
+
block
.
list
.
source
.
replace
(
'
\\
1'
,
'
\\
3'
)
+
'|'
)
.
getRegex
();
/**
* GFM + Tables Block Grammar
*/
block
.
tables
=
merge
({},
block
.
gfm
,
{
nptable
:
/^ *
([^
|
\n
]
.*
\|
.*
)\n
*
([
-:
]
+ *
\|[
-| :
]
*
)(?:\n((?:
.*
[^
>
\n
]
.*
(?:\n
|$
))
*
)\n
*|$
)
/
,
table
:
/^ *
\|(
.+
)\n
*
\|?(
*
[
-:
]
+
[
-| :
]
*
)(?:\n((?:
*
[^
>
\n
]
.*
(?:\n
|$
))
*
)\n
*|$
)
/
});
/**
* Pedantic grammar
*/
block
.
pedantic
=
merge
({},
block
.
normal
,
{
html
:
edit
(
'^ *(?:comment *(?:
\\
n|
\\
s*$)'
+
'|<(tag)[
\\
s
\\
S]+?</
\\
1> *(?:
\\
n{2,}|
\\
s*$)'
// closed tag
+
'|<tag(?:"[^"]*"|
\'
[^
\'
]*
\'
|
\\
s[^
\'
"/>
\\
s]*)*?/?> *(?:
\\
n{2,}|
\\
s*$))'
)
.
replace
(
'comment'
,
block
.
_comment
)
.
replace
(
/tag/g
,
'(?!(?:'
+
'a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub'
+
'|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)'
+
'
\\
b)
\\
w+(?!:|[^
\\
w
\\
s@]*@)
\\
b'
)
.
getRegex
(),
def
:
/^ *
\[([^\]]
+
)\]
: *<
?([^\s
>
]
+
)
>
?(?:
+
([
"(
][^\n]
+
[
")
]))?
*
(?:\n
+|$
)
/
});
/**
* Block Lexer
*/
function
Lexer
(
options
)
{
this
.
tokens
=
[];
this
.
tokens
.
links
=
Object
.
create
(
null
);
this
.
options
=
options
||
marked
.
defaults
;
this
.
rules
=
block
.
normal
;
if
(
this
.
options
.
pedantic
)
{
this
.
rules
=
block
.
pedantic
;
}
else
if
(
this
.
options
.
gfm
)
{
if
(
this
.
options
.
tables
)
{
this
.
rules
=
block
.
tables
;
}
else
{
this
.
rules
=
block
.
gfm
;
}
}
}
/**
* Expose Block Rules
*/
Lexer
.
rules
=
block
;
/**
* Static Lex Method
*/
Lexer
.
lex
=
function
(
src
,
options
)
{
var
lexer
=
new
Lexer
(
options
);
return
lexer
.
lex
(
src
);
};
/**
* Preprocessing
*/
Lexer
.
prototype
.
lex
=
function
(
src
)
{
src
=
src
.
replace
(
/
\r\n
|
\r
/g
,
'
\
n'
)
.
replace
(
/
\t
/g
,
' '
)
.
replace
(
/
\u
00a0/g
,
' '
)
.
replace
(
/
\u
2424/g
,
'
\
n'
);
return
this
.
token
(
src
,
true
);
};
/**
* Lexing
*/
Lexer
.
prototype
.
token
=
function
(
src
,
top
)
{
src
=
src
.
replace
(
/^ +$/gm
,
''
);
var
next
,
loose
,
cap
,
bull
,
b
,
item
,
listStart
,
listItems
,
t
,
space
,
i
,
tag
,
l
,
isordered
,
istask
,
ischecked
;
while
(
src
)
{
// newline
if
(
cap
=
this
.
rules
.
newline
.
exec
(
src
))
{
src
=
src
.
substring
(
cap
[
0
].
length
);
if
(
cap
[
0
].
length
>
1
)
{
this
.
tokens
.
push
({
type
:
'space'
});
}
}
// code
if
(
cap
=
this
.
rules
.
code
.
exec
(
src
))
{
src
=
src
.
substring
(
cap
[
0
].
length
);
cap
=
cap
[
0
].
replace
(
/^
{4}
/gm
,
''
);
this
.
tokens
.
push
({
type
:
'code'
,
text
:
!
this
.
options
.
pedantic
?
rtrim
(
cap
,
'
\
n'
)
:
cap
});
continue
;
}
// fences (gfm)
if
(
cap
=
this
.
rules
.
fences
.
exec
(
src
))
{
src
=
src
.
substring
(
cap
[
0
].
length
);
this
.
tokens
.
push
({
type
:
'code'
,
lang
:
cap
[
2
],
text
:
cap
[
3
]
||
''
});
continue
;
}
// heading
if
(
cap
=
this
.
rules
.
heading
.
exec
(
src
))
{
src
=
src
.
substring
(
cap
[
0
].
length
);
this
.
tokens
.
push
({
type
:
'heading'
,
depth
:
cap
[
1
].
length
,
text
:
cap
[
2
]
});
continue
;
}
// table no leading pipe (gfm)
if
(
top
&&
(
cap
=
this
.
rules
.
nptable
.
exec
(
src
)))
{
item
=
{
type
:
'table'
,
header
:
splitCells
(
cap
[
1
].
replace
(
/^ *| *
\|
*$/g
,
''
)),
align
:
cap
[
2
].
replace
(
/^ *|
\|
*$/g
,
''
).
split
(
/ *
\|
*/
),
cells
:
cap
[
3
]
?
cap
[
3
].
replace
(
/
\n
$/
,
''
).
split
(
'
\
n'
)
:
[]
};
if
(
item
.
header
.
length
===
item
.
align
.
length
)
{
src
=
src
.
substring
(
cap
[
0
].
length
);
for
(
i
=
0
;
i
<
item
.
align
.
length
;
i
++
)
{
if
(
/^ *-+: *$/
.
test
(
item
.
align
[
i
]))
{
item
.
align
[
i
]
=
'right'
;
}
else
if
(
/^ *:-+: *$/
.
test
(
item
.
align
[
i
]))
{
item
.
align
[
i
]
=
'center'
;
}
else
if
(
/^ *:-+ *$/
.
test
(
item
.
align
[
i
]))
{
item
.
align
[
i
]
=
'left'
;
}
else
{
item
.
align
[
i
]
=
null
;
}
}
for
(
i
=
0
;
i
<
item
.
cells
.
length
;
i
++
)
{
item
.
cells
[
i
]
=
splitCells
(
item
.
cells
[
i
],
item
.
header
.
length
);
}
this
.
tokens
.
push
(
item
);
continue
;
}
}
// hr
if
(
cap
=
this
.
rules
.
hr
.
exec
(
src
))
{
src
=
src
.
substring
(
cap
[
0
].
length
);
this
.
tokens
.
push
({
type
:
'hr'
});
continue
;
}
// blockquote
if
(
cap
=
this
.
rules
.
blockquote
.
exec
(
src
))
{
src
=
src
.
substring
(
cap
[
0
].
length
);
this
.
tokens
.
push
({
type
:
'blockquote_start'
});
cap
=
cap
[
0
].
replace
(
/^ *>
?
/gm
,
''
);
// Pass `top` to keep the current
// "toplevel" state. This is exactly
// how markdown.pl works.
this
.
token
(
cap
,
top
);
this
.
tokens
.
push
({
type
:
'blockquote_end'
});
continue
;
}
// list
if
(
cap
=
this
.
rules
.
list
.
exec
(
src
))
{
src
=
src
.
substring
(
cap
[
0
].
length
);
bull
=
cap
[
2
];
isordered
=
bull
.
length
>
1
;
listStart
=
{
type
:
'list_start'
,
ordered
:
isordered
,
start
:
isordered
?
+
bull
:
''
,
loose
:
false
};
this
.
tokens
.
push
(
listStart
);
// Get each top-level item.
cap
=
cap
[
0
].
match
(
this
.
rules
.
item
);
listItems
=
[];
next
=
false
;
l
=
cap
.
length
;
i
=
0
;
for
(;
i
<
l
;
i
++
)
{
item
=
cap
[
i
];
// Remove the list item's bullet
// so it is seen as the next token.
space
=
item
.
length
;
item
=
item
.
replace
(
/^ *
([
*+-
]
|
\d
+
\.)
+/
,
''
);
// Outdent whatever the
// list item contains. Hacky.
if
(
~
item
.
indexOf
(
'
\
n '
))
{
space
-=
item
.
length
;
item
=
!
this
.
options
.
pedantic
?
item
.
replace
(
new
RegExp
(
'^ {1,'
+
space
+
'}'
,
'gm'
),
''
)
:
item
.
replace
(
/^
{1,4}
/gm
,
''
);
}
// Determine whether the next list item belongs here.
// Backpedal if it does not belong in this list.
if
(
this
.
options
.
smartLists
&&
i
!==
l
-
1
)
{
b
=
block
.
bullet
.
exec
(
cap
[
i
+
1
])[
0
];
if
(
bull
!==
b
&&
!
(
bull
.
length
>
1
&&
b
.
length
>
1
))
{
src
=
cap
.
slice
(
i
+
1
).
join
(
'
\
n'
)
+
src
;
i
=
l
-
1
;
}
}
// Determine whether item is loose or not.
// Use: /(^|\n)(?! )[^\n]+\n\n(?!\s*$)/
// for discount behavior.
loose
=
next
||
/
\n\n(?!\s
*$
)
/
.
test
(
item
);
if
(
i
!==
l
-
1
)
{
next
=
item
.
charAt
(
item
.
length
-
1
)
===
'
\
n'
;
if
(
!
loose
)
loose
=
next
;
}
if
(
loose
)
{
listStart
.
loose
=
true
;
}
// Check for task list items
istask
=
/^
\[[
xX
]\]
/
.
test
(
item
);
ischecked
=
undefined
;
if
(
istask
)
{
ischecked
=
item
[
1
]
!==
' '
;
item
=
item
.
replace
(
/^
\[[
xX
]\]
+/
,
''
);
}
t
=
{
type
:
'list_item_start'
,
task
:
istask
,
checked
:
ischecked
,
loose
:
loose
};
listItems
.
push
(
t
);
this
.
tokens
.
push
(
t
);
// Recurse.
this
.
token
(
item
,
false
);
this
.
tokens
.
push
({
type
:
'list_item_end'
});
}
if
(
listStart
.
loose
)
{
l
=
listItems
.
length
;
i
=
0
;
for
(;
i
<
l
;
i
++
)
{
listItems
[
i
].
loose
=
true
;
}
}
this
.
tokens
.
push
({
type
:
'list_end'
});
continue
;
}
// html
if
(
cap
=
this
.
rules
.
html
.
exec
(
src
))
{
src
=
src
.
substring
(
cap
[
0
].
length
);
this
.
tokens
.
push
({
type
:
this
.
options
.
sanitize
?
'paragraph'
:
'html'
,
pre
:
!
this
.
options
.
sanitizer
&&
(
cap
[
1
]
===
'pre'
||
cap
[
1
]
===
'script'
||
cap
[
1
]
===
'style'
),
text
:
cap
[
0
]
});
continue
;
}
// def
if
(
top
&&
(
cap
=
this
.
rules
.
def
.
exec
(
src
)))
{
src
=
src
.
substring
(
cap
[
0
].
length
);
if
(
cap
[
3
])
cap
[
3
]
=
cap
[
3
].
substring
(
1
,
cap
[
3
].
length
-
1
);
tag
=
cap
[
1
].
toLowerCase
().
replace
(
/
\s
+/g
,
' '
);
if
(
!
this
.
tokens
.
links
[
tag
])
{
this
.
tokens
.
links
[
tag
]
=
{
href
:
cap
[
2
],
title
:
cap
[
3
]
};
}
continue
;
}
// table (gfm)
if
(
top
&&
(
cap
=
this
.
rules
.
table
.
exec
(
src
)))
{
item
=
{
type
:
'table'
,
header
:
splitCells
(
cap
[
1
].
replace
(
/^ *| *
\|
*$/g
,
''
)),
align
:
cap
[
2
].
replace
(
/^ *|
\|
*$/g
,
''
).
split
(
/ *
\|
*/
),
cells
:
cap
[
3
]
?
cap
[
3
].
replace
(
/
(?:
*
\|
*
)?\n
$/
,
''
).
split
(
'
\
n'
)
:
[]
};
if
(
item
.
header
.
length
===
item
.
align
.
length
)
{
src
=
src
.
substring
(
cap
[
0
].
length
);
for
(
i
=
0
;
i
<
item
.
align
.
length
;
i
++
)
{
if
(
/^ *-+: *$/
.
test
(
item
.
align
[
i
]))
{
item
.
align
[
i
]
=
'right'
;
}
else
if
(
/^ *:-+: *$/
.
test
(
item
.
align
[
i
]))
{
item
.
align
[
i
]
=
'center'
;
}
else
if
(
/^ *:-+ *$/
.
test
(
item
.
align
[
i
]))
{
item
.
align
[
i
]
=
'left'
;
}
else
{
item
.
align
[
i
]
=
null
;
}
}
for
(
i
=
0
;
i
<
item
.
cells
.
length
;
i
++
)
{
item
.
cells
[
i
]
=
splitCells
(
item
.
cells
[
i
].
replace
(
/^ *
\|
*| *
\|
*$/g
,
''
),
item
.
header
.
length
);
}
this
.
tokens
.
push
(
item
);
continue
;
}
}
// lheading
if
(
cap
=
this
.
rules
.
lheading
.
exec
(
src
))
{
src
=
src
.
substring
(
cap
[
0
].
length
);
this
.
tokens
.
push
({
type
:
'heading'
,
depth
:
cap
[
2
]
===
'='
?
1
:
2
,
text
:
cap
[
1
]
});
continue
;
}
// top-level paragraph
if
(
top
&&
(
cap
=
this
.
rules
.
paragraph
.
exec
(
src
)))
{
src
=
src
.
substring
(
cap
[
0
].
length
);
this
.
tokens
.
push
({
type
:
'paragraph'
,
text
:
cap
[
1
].
charAt
(
cap
[
1
].
length
-
1
)
===
'
\
n'
?
cap
[
1
].
slice
(
0
,
-
1
)
:
cap
[
1
]
});
continue
;
}
// text
if
(
cap
=
this
.
rules
.
text
.
exec
(
src
))
{
// Top-level should never reach here.
src
=
src
.
substring
(
cap
[
0
].
length
);
this
.
tokens
.
push
({
type
:
'text'
,
text
:
cap
[
0
]
});
continue
;
}
if
(
src
)
{
throw
new
Error
(
'Infinite loop on byte: '
+
src
.
charCodeAt
(
0
));
}
}
return
this
.
tokens
;
};
/**
* Inline-Level Grammar
*/
var
inline
=
{
escape
:
/^
\\([
!"#$%&'()*+,
\-
.
/
:;<=>?@
\[\]\\
^_`{|}~
])
/
,
autolink
:
/^<
(
scheme:
[^\s\x
00-
\x
1f<>
]
*|email
)
>/
,
url
:
noop
,
tag
:
'^comment'
+
'|^</[a-zA-Z][
\\
w:-]*
\\
s*>'
// self-closing tag
+
'|^<[a-zA-Z][
\\
w-]*(?:attribute)*?
\\
s*/?>'
// open tag
+
'|^<
\\
?[
\\
s
\\
S]*?
\\
?>'
// processing instruction, e.g. <?php ?>
+
'|^<![a-zA-Z]+
\\
s[
\\
s
\\
S]*?>'
// declaration, e.g. <!DOCTYPE html>
+
'|^<!
\\
[CDATA
\\
[[
\\
s
\\
S]*?
\\
]
\\
]>'
,
// CDATA section
link
:
/^!
?\[(
label
)\]\(
href
(?:\s
+
(
title
))?\s
*
\)
/
,
reflink
:
/^!
?\[(
label
)\]\[(?!\s
*
\])((?:\\[\[\]]?
|
[^\[\]\\])
+
)\]
/
,
nolink
:
/^!
?\[(?!\s
*
\])((?:\[[^\[\]]
*
\]
|
\\[\[\]]
|
[^\[\]])
*
)\](?:\[\])?
/
,
strong
:
/^__
([^\s])
__
(?!
_
)
|^
\*\*([^\s])\*\*(?!\*)
|^__
([^\s][\s\S]
*
?[^\s])
__
(?!
_
)
|^
\*\*([^\s][\s\S]
*
?[^\s])\*\*(?!\*)
/
,
em
:
/^_
([^\s
_
])
_
(?!
_
)
|^
\*([^\s
*"<
\[])\*(?!\*)
|^_
([^\s][\s\S]
*
?[^\s
_
])
_
(?!
_
)
|^_
([^\s
_
][\s\S]
*
?[^\s])
_
(?!
_
)
|^
\*([^\s
"<
\[][\s\S]
*
?[^\s
*
])\*(?!\*)
|^
\*([^\s
*"<
\[][\s\S]
*
?[^\s])\*(?!\*)
/
,
code
:
/^
(
`+
)\s
*
([\s\S]
*
?[^
`
]?)\s
*
\1(?!
`
)
/
,
br
:
/^
(
{2,}
|
\\)\n(?!\s
*$
)
/
,
del
:
noop
,
text
:
/^
[\s\S]
+
?(?=[\\
<!
\[
`*
]
|
\b
_|
{2,}\n
|$
)
/
};
inline
.
_escapes
=
/
\\([
!"#$%&'()*+,
\-
.
/
:;<=>?@
\[\]\\
^_`{|}~
])
/g
;
inline
.
_scheme
=
/
[
a-zA-Z
][
a-zA-Z0-9+.-
]{1,31}
/
;
inline
.
_email
=
/
[
a-zA-Z0-9.!#$%&'*+
/
=?^_`{|}~-
]
+
(
@
)[
a-zA-Z0-9
](?:[
a-zA-Z0-9-
]{0,61}[
a-zA-Z0-9
])?(?:\.[
a-zA-Z0-9
](?:[
a-zA-Z0-9-
]{0,61}[
a-zA-Z0-9
])?)
+
(?![
-_
])
/
;
inline
.
autolink
=
edit
(
inline
.
autolink
)
.
replace
(
'scheme'
,
inline
.
_scheme
)
.
replace
(
'email'
,
inline
.
_email
)
.
getRegex
();
inline
.
_attribute
=
/
\s
+
[
a-zA-Z:_
][\w
.:-
]
*
(?:\s
*=
\s
*"
[^
"
]
*"|
\s
*=
\s
*'
[^
'
]
*'|
\s
*=
\s
*
[^\s
"'=<>`
]
+
)?
/
;
inline
.
tag
=
edit
(
inline
.
tag
)
.
replace
(
'comment'
,
block
.
_comment
)
.
replace
(
'attribute'
,
inline
.
_attribute
)
.
getRegex
();
inline
.
_label
=
/
(?:\[[^\[\]]
*
\]
|
\\[\[\]]?
|`
[^
`
]
*`|
[^\[\]\\])
*
?
/
;
inline
.
_href
=
/
\s
*
(
<
(?:\\[
<>
]?
|
[^\s
<>
\\])
*>|
(?:\\[
()
]?
|
\([^\s\x
00-
\x
1f
\\]
*
\)
|
[^\s\x
00-
\x
1f()
\\])
*
?)
/
;
inline
.
_title
=
/"
(?:\\
"
?
|
[^
"
\\])
*"|'
(?:\\
'
?
|
[^
'
\\])
*'|
\((?:\\\)?
|
[^
)
\\])
*
\)
/
;
inline
.
link
=
edit
(
inline
.
link
)
.
replace
(
'label'
,
inline
.
_label
)
.
replace
(
'href'
,
inline
.
_href
)
.
replace
(
'title'
,
inline
.
_title
)
.
getRegex
();
inline
.
reflink
=
edit
(
inline
.
reflink
)
.
replace
(
'label'
,
inline
.
_label
)
.
getRegex
();
/**
* Normal Inline Grammar
*/
inline
.
normal
=
merge
({},
inline
);
/**
* Pedantic Inline Grammar
*/
inline
.
pedantic
=
merge
({},
inline
.
normal
,
{
strong
:
/^__
(?=\S)([\s\S]
*
?\S)
__
(?!
_
)
|^
\*\*(?=\S)([\s\S]
*
?\S)\*\*(?!\*)
/
,
em
:
/^_
(?=\S)([\s\S]
*
?\S)
_
(?!
_
)
|^
\*(?=\S)([\s\S]
*
?\S)\*(?!\*)
/
,
link
:
edit
(
/^!
?\[(
label
)\]\((
.*
?)\)
/
)
.
replace
(
'label'
,
inline
.
_label
)
.
getRegex
(),
reflink
:
edit
(
/^!
?\[(
label
)\]\s
*
\[([^\]]
*
)\]
/
)
.
replace
(
'label'
,
inline
.
_label
)
.
getRegex
()
});
/**
* GFM Inline Grammar
*/
inline
.
gfm
=
merge
({},
inline
.
normal
,
{
escape
:
edit
(
inline
.
escape
).
replace
(
'])'
,
'~|])'
).
getRegex
(),
url
:
edit
(
/^
((?:
ftp|https
?)
:
\/\/
|www
\.)(?:[
a-zA-Z0-9
\-]
+
\.?)
+
[^\s
<
]
*|^email/
)
.
replace
(
'email'
,
inline
.
_email
)
.
getRegex
(),
_backpedal
:
/
(?:[^
?!.,:;*_~()&
]
+|
\([^
)
]
*
\)
|&
(?![
a-zA-Z0-9
]
+;$
)
|
[
?!.,:;*_~)
]
+
(?!
$
))
+/
,
del
:
/^~+
(?=\S)([\s\S]
*
?\S)
~+/
,
text
:
edit
(
inline
.
text
)
.
replace
(
']|'
,
'~]|'
)
.
replace
(
'|'
,
'|https?://|ftp://|www
\\
.|[a-zA-Z0-9.!#$%&
\'
*+/=?^_`{
\\
|}~-]+@|'
)
.
getRegex
()
});
/**
* GFM + Line Breaks Inline Grammar
*/
inline
.
breaks
=
merge
({},
inline
.
gfm
,
{
br
:
edit
(
inline
.
br
).
replace
(
'{2,}'
,
'*'
).
getRegex
(),
text
:
edit
(
inline
.
gfm
.
text
).
replace
(
'{2,}'
,
'*'
).
getRegex
()
});
/**
* Inline Lexer & Compiler
*/
function
InlineLexer
(
links
,
options
)
{
this
.
options
=
options
||
marked
.
defaults
;
this
.
links
=
links
;
this
.
rules
=
inline
.
normal
;
this
.
renderer
=
this
.
options
.
renderer
||
new
Renderer
();
this
.
renderer
.
options
=
this
.
options
;
if
(
!
this
.
links
)
{
throw
new
Error
(
'Tokens array requires a `links` property.'
);
}
if
(
this
.
options
.
pedantic
)
{
this
.
rules
=
inline
.
pedantic
;
}
else
if
(
this
.
options
.
gfm
)
{
if
(
this
.
options
.
breaks
)
{
this
.
rules
=
inline
.
breaks
;
}
else
{
this
.
rules
=
inline
.
gfm
;
}
}
}
/**
* Expose Inline Rules
*/
InlineLexer
.
rules
=
inline
;
/**
* Static Lexing/Compiling Method
*/
InlineLexer
.
output
=
function
(
src
,
links
,
options
)
{
var
inline
=
new
InlineLexer
(
links
,
options
);
return
inline
.
output
(
src
);
};
/**
* Lexing/Compiling
*/
InlineLexer
.
prototype
.
output
=
function
(
src
)
{
var
out
=
''
,
link
,
text
,
href
,
title
,
cap
,
prevCapZero
;
while
(
src
)
{
// escape
if
(
cap
=
this
.
rules
.
escape
.
exec
(
src
))
{
src
=
src
.
substring
(
cap
[
0
].
length
);
out
+=
cap
[
1
];
continue
;
}
// autolink
if
(
cap
=
this
.
rules
.
autolink
.
exec
(
src
))
{
src
=
src
.
substring
(
cap
[
0
].
length
);
if
(
cap
[
2
]
===
'@'
)
{
text
=
escape
(
this
.
mangle
(
cap
[
1
]));
href
=
'mailto:'
+
text
;
}
else
{
text
=
escape
(
cap
[
1
]);
href
=
text
;
}
out
+=
this
.
renderer
.
link
(
href
,
null
,
text
);
continue
;
}
// url (gfm)
if
(
!
this
.
inLink
&&
(
cap
=
this
.
rules
.
url
.
exec
(
src
)))
{
do
{
prevCapZero
=
cap
[
0
];
cap
[
0
]
=
this
.
rules
.
_backpedal
.
exec
(
cap
[
0
])[
0
];
}
while
(
prevCapZero
!==
cap
[
0
]);
src
=
src
.
substring
(
cap
[
0
].
length
);
if
(
cap
[
2
]
===
'@'
)
{
text
=
escape
(
cap
[
0
]);
href
=
'mailto:'
+
text
;
}
else
{
text
=
escape
(
cap
[
0
]);
if
(
cap
[
1
]
===
'www.'
)
{
href
=
'http://'
+
text
;
}
else
{
href
=
text
;
}
}
out
+=
this
.
renderer
.
link
(
href
,
null
,
text
);
continue
;
}
// tag
if
(
cap
=
this
.
rules
.
tag
.
exec
(
src
))
{
if
(
!
this
.
inLink
&&
/^<a /i
.
test
(
cap
[
0
]))
{
this
.
inLink
=
true
;
}
else
if
(
this
.
inLink
&&
/^<
\/
a>/i
.
test
(
cap
[
0
]))
{
this
.
inLink
=
false
;
}
src
=
src
.
substring
(
cap
[
0
].
length
);
out
+=
this
.
options
.
sanitize
?
this
.
options
.
sanitizer
?
this
.
options
.
sanitizer
(
cap
[
0
])
:
escape
(
cap
[
0
])
:
cap
[
0
]
continue
;
}
// link
if
(
cap
=
this
.
rules
.
link
.
exec
(
src
))
{
src
=
src
.
substring
(
cap
[
0
].
length
);
this
.
inLink
=
true
;
href
=
cap
[
2
];
if
(
this
.
options
.
pedantic
)
{
link
=
/^
([^
'"
]
*
[^\s])\s
+
([
'"
])(
.*
)\2
/
.
exec
(
href
);
if
(
link
)
{
href
=
link
[
1
];
title
=
link
[
3
];
}
else
{
title
=
''
;
}
}
else
{
title
=
cap
[
3
]
?
cap
[
3
].
slice
(
1
,
-
1
)
:
''
;
}
href
=
href
.
trim
().
replace
(
/^<
([\s\S]
*
)
>$/
,
'$1'
);
out
+=
this
.
outputLink
(
cap
,
{
href
:
InlineLexer
.
escapes
(
href
),
title
:
InlineLexer
.
escapes
(
title
)
});
this
.
inLink
=
false
;
continue
;
}
// reflink, nolink
if
((
cap
=
this
.
rules
.
reflink
.
exec
(
src
))
||
(
cap
=
this
.
rules
.
nolink
.
exec
(
src
)))
{
src
=
src
.
substring
(
cap
[
0
].
length
);
link
=
(
cap
[
2
]
||
cap
[
1
]).
replace
(
/
\s
+/g
,
' '
);
link
=
this
.
links
[
link
.
toLowerCase
()];
if
(
!
link
||
!
link
.
href
)
{
out
+=
cap
[
0
].
charAt
(
0
);
src
=
cap
[
0
].
substring
(
1
)
+
src
;
continue
;
}
this
.
inLink
=
true
;
out
+=
this
.
outputLink
(
cap
,
link
);
this
.
inLink
=
false
;
continue
;
}
// strong
if
(
cap
=
this
.
rules
.
strong
.
exec
(
src
))
{
src
=
src
.
substring
(
cap
[
0
].
length
);
out
+=
this
.
renderer
.
strong
(
this
.
output
(
cap
[
4
]
||
cap
[
3
]
||
cap
[
2
]
||
cap
[
1
]));
continue
;
}
// em
if
(
cap
=
this
.
rules
.
em
.
exec
(
src
))
{
src
=
src
.
substring
(
cap
[
0
].
length
);
out
+=
this
.
renderer
.
em
(
this
.
output
(
cap
[
6
]
||
cap
[
5
]
||
cap
[
4
]
||
cap
[
3
]
||
cap
[
2
]
||
cap
[
1
]));
continue
;
}
// code
if
(
cap
=
this
.
rules
.
code
.
exec
(
src
))
{
src
=
src
.
substring
(
cap
[
0
].
length
);
out
+=
this
.
renderer
.
codespan
(
escape
(
cap
[
2
].
trim
(),
true
));
continue
;
}
// br
if
(
cap
=
this
.
rules
.
br
.
exec
(
src
))
{
src
=
src
.
substring
(
cap
[
0
].
length
);
out
+=
this
.
renderer
.
br
();
continue
;
}
// del (gfm)
if
(
cap
=
this
.
rules
.
del
.
exec
(
src
))
{
src
=
src
.
substring
(
cap
[
0
].
length
);
out
+=
this
.
renderer
.
del
(
this
.
output
(
cap
[
1
]));
continue
;
}
// text
if
(
cap
=
this
.
rules
.
text
.
exec
(
src
))
{
src
=
src
.
substring
(
cap
[
0
].
length
);
out
+=
this
.
renderer
.
text
(
escape
(
this
.
smartypants
(
cap
[
0
])));
continue
;
}
if
(
src
)
{
throw
new
Error
(
'Infinite loop on byte: '
+
src
.
charCodeAt
(
0
));
}
}
return
out
;
};
InlineLexer
.
escapes
=
function
(
text
)
{
return
text
?
text
.
replace
(
InlineLexer
.
rules
.
_escapes
,
'$1'
)
:
text
;
}
/**
* Compile Link
*/
InlineLexer
.
prototype
.
outputLink
=
function
(
cap
,
link
)
{
var
href
=
link
.
href
,
title
=
link
.
title
?
escape
(
link
.
title
)
:
null
;
return
cap
[
0
].
charAt
(
0
)
!==
'!'
?
this
.
renderer
.
link
(
href
,
title
,
this
.
output
(
cap
[
1
]))
:
this
.
renderer
.
image
(
href
,
title
,
escape
(
cap
[
1
]));
};
/**
* Smartypants Transformations
*/
InlineLexer
.
prototype
.
smartypants
=
function
(
text
)
{
if
(
!
this
.
options
.
smartypants
)
return
text
;
return
text
// em-dashes
.
replace
(
/---/g
,
'
\
u2014'
)
// en-dashes
.
replace
(
/--/g
,
'
\
u2013'
)
// opening singles
.
replace
(
/
(
^|
[
-
\u
2014
/
(
\[
{"
\s])
'/g
,
'$1
\
u2018'
)
// closing singles & apostrophes
.
replace
(
/'/g
,
'
\
u2019'
)
// opening doubles
.
replace
(
/
(
^|
[
-
\u
2014
/
(
\[
{
\u
2018
\s])
"/g
,
'$1
\
u201c'
)
// closing doubles
.
replace
(
/"/g
,
'
\
u201d'
)
// ellipses
.
replace
(
/
\.{3}
/g
,
'
\
u2026'
);
};
/**
* Mangle Links
*/
InlineLexer
.
prototype
.
mangle
=
function
(
text
)
{
if
(
!
this
.
options
.
mangle
)
return
text
;
var
out
=
''
,
l
=
text
.
length
,
i
=
0
,
ch
;
for
(;
i
<
l
;
i
++
)
{
ch
=
text
.
charCodeAt
(
i
);
if
(
Math
.
random
()
>
0.5
)
{
ch
=
'x'
+
ch
.
toString
(
16
);
}
out
+=
'&#'
+
ch
+
';'
;
}
return
out
;
};
/**
* Renderer
*/
function
Renderer
(
options
)
{
this
.
options
=
options
||
marked
.
defaults
;
}
Renderer
.
prototype
.
code
=
function
(
code
,
lang
,
escaped
)
{
if
(
this
.
options
.
highlight
)
{
var
out
=
this
.
options
.
highlight
(
code
,
lang
);
if
(
out
!=
null
&&
out
!==
code
)
{
escaped
=
true
;
code
=
out
;
}
}
if
(
!
lang
)
{
return
'<pre><code>'
+
(
escaped
?
code
:
escape
(
code
,
true
))
+
'</code></pre>'
;
}
return
'<pre><code class="'
+
this
.
options
.
langPrefix
+
escape
(
lang
,
true
)
+
'">'
+
(
escaped
?
code
:
escape
(
code
,
true
))
+
'</code></pre>
\
n'
;
};
Renderer
.
prototype
.
blockquote
=
function
(
quote
)
{
return
'<blockquote>
\
n'
+
quote
+
'</blockquote>
\
n'
;
};
Renderer
.
prototype
.
html
=
function
(
html
)
{
return
html
;
};
Renderer
.
prototype
.
heading
=
function
(
text
,
level
,
raw
)
{
if
(
this
.
options
.
headerIds
)
{
return
'<h'
+
level
+
' id="'
+
this
.
options
.
headerPrefix
+
raw
.
toLowerCase
().
replace
(
/
[^\w]
+/g
,
'-'
)
+
'">'
+
text
+
'</h'
+
level
+
'>
\
n'
;
}
// ignore IDs
return
'<h'
+
level
+
'>'
+
text
+
'</h'
+
level
+
'>
\
n'
;
};
Renderer
.
prototype
.
hr
=
function
()
{
return
this
.
options
.
xhtml
?
'<hr/>
\
n'
:
'<hr>
\
n'
;
};
Renderer
.
prototype
.
list
=
function
(
body
,
ordered
,
start
)
{
var
type
=
ordered
?
'ol'
:
'ul'
,
startatt
=
(
ordered
&&
start
!==
1
)
?
(
' start="'
+
start
+
'"'
)
:
''
;
return
'<'
+
type
+
startatt
+
'>
\
n'
+
body
+
'</'
+
type
+
'>
\
n'
;
};
Renderer
.
prototype
.
listitem
=
function
(
text
)
{
return
'<li>'
+
text
+
'</li>
\
n'
;
};
Renderer
.
prototype
.
checkbox
=
function
(
checked
)
{
return
'<input '
+
(
checked
?
'checked="" '
:
''
)
+
'disabled="" type="checkbox"'
+
(
this
.
options
.
xhtml
?
' /'
:
''
)
+
'> '
;
}
Renderer
.
prototype
.
paragraph
=
function
(
text
)
{
return
'<p>'
+
text
+
'</p>
\
n'
;
};
Renderer
.
prototype
.
table
=
function
(
header
,
body
)
{
if
(
body
)
body
=
'<tbody>'
+
body
+
'</tbody>'
;
return
'<table>
\
n'
+
'<thead>
\
n'
+
header
+
'</thead>
\
n'
+
body
+
'</table>
\
n'
;
};
Renderer
.
prototype
.
tablerow
=
function
(
content
)
{
return
'<tr>
\
n'
+
content
+
'</tr>
\
n'
;
};
Renderer
.
prototype
.
tablecell
=
function
(
content
,
flags
)
{
var
type
=
flags
.
header
?
'th'
:
'td'
;
var
tag
=
flags
.
align
?
'<'
+
type
+
' align="'
+
flags
.
align
+
'">'
:
'<'
+
type
+
'>'
;
return
tag
+
content
+
'</'
+
type
+
'>
\
n'
;
};
// span level renderer
Renderer
.
prototype
.
strong
=
function
(
text
)
{
return
'<strong>'
+
text
+
'</strong>'
;
};
Renderer
.
prototype
.
em
=
function
(
text
)
{
return
'<em>'
+
text
+
'</em>'
;
};
Renderer
.
prototype
.
codespan
=
function
(
text
)
{
return
'<code>'
+
text
+
'</code>'
;
};
Renderer
.
prototype
.
br
=
function
()
{
return
this
.
options
.
xhtml
?
'<br/>'
:
'<br>'
;
};
Renderer
.
prototype
.
del
=
function
(
text
)
{
return
'<del>'
+
text
+
'</del>'
;
};
Renderer
.
prototype
.
link
=
function
(
href
,
title
,
text
)
{
if
(
this
.
options
.
sanitize
)
{
try
{
var
prot
=
decodeURIComponent
(
unescape
(
href
))
.
replace
(
/
[^\w
:
]
/g
,
''
)
.
toLowerCase
();
}
catch
(
e
)
{
return
text
;
}
if
(
prot
.
indexOf
(
'javascript:'
)
===
0
||
prot
.
indexOf
(
'vbscript:'
)
===
0
||
prot
.
indexOf
(
'data:'
)
===
0
)
{
return
text
;
}
}
if
(
this
.
options
.
baseUrl
&&
!
originIndependentUrl
.
test
(
href
))
{
href
=
resolveUrl
(
this
.
options
.
baseUrl
,
href
);
}
try
{
href
=
encodeURI
(
href
).
replace
(
/%25/g
,
'%'
);
}
catch
(
e
)
{
return
text
;
}
var
out
=
'<a href="'
+
escape
(
href
)
+
'"'
;
if
(
title
)
{
out
+=
' title="'
+
title
+
'"'
;
}
out
+=
'>'
+
text
+
'</a>'
;
return
out
;
};
Renderer
.
prototype
.
image
=
function
(
href
,
title
,
text
)
{
if
(
this
.
options
.
baseUrl
&&
!
originIndependentUrl
.
test
(
href
))
{
href
=
resolveUrl
(
this
.
options
.
baseUrl
,
href
);
}
var
out
=
'<img src="'
+
href
+
'" alt="'
+
text
+
'"'
;
if
(
title
)
{
out
+=
' title="'
+
title
+
'"'
;
}
out
+=
this
.
options
.
xhtml
?
'/>'
:
'>'
;
return
out
;
};
Renderer
.
prototype
.
text
=
function
(
text
)
{
return
text
;
};
/**
* TextRenderer
* returns only the textual part of the token
*/
function
TextRenderer
()
{}
// no need for block level renderers
TextRenderer
.
prototype
.
strong
=
TextRenderer
.
prototype
.
em
=
TextRenderer
.
prototype
.
codespan
=
TextRenderer
.
prototype
.
del
=
TextRenderer
.
prototype
.
text
=
function
(
text
)
{
return
text
;
}
TextRenderer
.
prototype
.
link
=
TextRenderer
.
prototype
.
image
=
function
(
href
,
title
,
text
)
{
return
''
+
text
;
}
TextRenderer
.
prototype
.
br
=
function
()
{
return
''
;
}
/**
* Parsing & Compiling
*/
function
Parser
(
options
)
{
this
.
tokens
=
[];
this
.
token
=
null
;
this
.
options
=
options
||
marked
.
defaults
;
this
.
options
.
renderer
=
this
.
options
.
renderer
||
new
Renderer
();
this
.
renderer
=
this
.
options
.
renderer
;
this
.
renderer
.
options
=
this
.
options
;
}
/**
* Static Parse Method
*/
Parser
.
parse
=
function
(
src
,
options
)
{
var
parser
=
new
Parser
(
options
);
return
parser
.
parse
(
src
);
};
/**
* Parse Loop
*/
Parser
.
prototype
.
parse
=
function
(
src
)
{
this
.
inline
=
new
InlineLexer
(
src
.
links
,
this
.
options
);
// use an InlineLexer with a TextRenderer to extract pure text
this
.
inlineText
=
new
InlineLexer
(
src
.
links
,
merge
({},
this
.
options
,
{
renderer
:
new
TextRenderer
()
})
);
this
.
tokens
=
src
.
reverse
();
var
out
=
''
;
while
(
this
.
next
())
{
out
+=
this
.
tok
();
}
return
out
;
};
/**
* Next Token
*/
Parser
.
prototype
.
next
=
function
()
{
return
this
.
token
=
this
.
tokens
.
pop
();
};
/**
* Preview Next Token
*/
Parser
.
prototype
.
peek
=
function
()
{
return
this
.
tokens
[
this
.
tokens
.
length
-
1
]
||
0
;
};
/**
* Parse Text Tokens
*/
Parser
.
prototype
.
parseText
=
function
()
{
var
body
=
this
.
token
.
text
;
while
(
this
.
peek
().
type
===
'text'
)
{
body
+=
'
\
n'
+
this
.
next
().
text
;
}
return
this
.
inline
.
output
(
body
);
};
/**
* Parse Current Token
*/
Parser
.
prototype
.
tok
=
function
()
{
switch
(
this
.
token
.
type
)
{
case
'space'
:
{
return
''
;
}
case
'hr'
:
{
return
this
.
renderer
.
hr
();
}
case
'heading'
:
{
return
this
.
renderer
.
heading
(
this
.
inline
.
output
(
this
.
token
.
text
),
this
.
token
.
depth
,
unescape
(
this
.
inlineText
.
output
(
this
.
token
.
text
)));
}
case
'code'
:
{
return
this
.
renderer
.
code
(
this
.
token
.
text
,
this
.
token
.
lang
,
this
.
token
.
escaped
);
}
case
'table'
:
{
var
header
=
''
,
body
=
''
,
i
,
row
,
cell
,
j
;
// header
cell
=
''
;
for
(
i
=
0
;
i
<
this
.
token
.
header
.
length
;
i
++
)
{
cell
+=
this
.
renderer
.
tablecell
(
this
.
inline
.
output
(
this
.
token
.
header
[
i
]),
{
header
:
true
,
align
:
this
.
token
.
align
[
i
]
}
);
}
header
+=
this
.
renderer
.
tablerow
(
cell
);
for
(
i
=
0
;
i
<
this
.
token
.
cells
.
length
;
i
++
)
{
row
=
this
.
token
.
cells
[
i
];
cell
=
''
;
for
(
j
=
0
;
j
<
row
.
length
;
j
++
)
{
cell
+=
this
.
renderer
.
tablecell
(
this
.
inline
.
output
(
row
[
j
]),
{
header
:
false
,
align
:
this
.
token
.
align
[
j
]
}
);
}
body
+=
this
.
renderer
.
tablerow
(
cell
);
}
return
this
.
renderer
.
table
(
header
,
body
);
}
case
'blockquote_start'
:
{
body
=
''
;
while
(
this
.
next
().
type
!==
'blockquote_end'
)
{
body
+=
this
.
tok
();
}
return
this
.
renderer
.
blockquote
(
body
);
}
case
'list_start'
:
{
body
=
''
;
var
ordered
=
this
.
token
.
ordered
,
start
=
this
.
token
.
start
;
while
(
this
.
next
().
type
!==
'list_end'
)
{
body
+=
this
.
tok
();
}
return
this
.
renderer
.
list
(
body
,
ordered
,
start
);
}
case
'list_item_start'
:
{
body
=
''
;
var
loose
=
this
.
token
.
loose
;
if
(
this
.
token
.
task
)
{
body
+=
this
.
renderer
.
checkbox
(
this
.
token
.
checked
);
}
while
(
this
.
next
().
type
!==
'list_item_end'
)
{
body
+=
!
loose
&&
this
.
token
.
type
===
'text'
?
this
.
parseText
()
:
this
.
tok
();
}
return
this
.
renderer
.
listitem
(
body
);
}
case
'html'
:
{
// TODO parse inline content if parameter markdown=1
return
this
.
renderer
.
html
(
this
.
token
.
text
);
}
case
'paragraph'
:
{
return
this
.
renderer
.
paragraph
(
this
.
inline
.
output
(
this
.
token
.
text
));
}
case
'text'
:
{
return
this
.
renderer
.
paragraph
(
this
.
parseText
());
}
}
};
/**
* Helpers
*/
function
escape
(
html
,
encode
)
{
return
html
.
replace
(
!
encode
?
/&
(?!
#
?\w
+;
)
/g
:
/&/g
,
'&'
)
.
replace
(
/</g
,
'<'
)
.
replace
(
/>/g
,
'>'
)
.
replace
(
/"/g
,
'"'
)
.
replace
(
/'/g
,
'''
);
}
function
unescape
(
html
)
{
// explicitly match decimal, hex, and named HTML entities
return
html
.
replace
(
/&
(
#
(?:\d
+
)
|
(?:
#x
[
0-9A-Fa-f
]
+
)
|
(?:\w
+
))
;
?
/ig
,
function
(
_
,
n
)
{
n
=
n
.
toLowerCase
();
if
(
n
===
'colon'
)
return
':'
;
if
(
n
.
charAt
(
0
)
===
'#'
)
{
return
n
.
charAt
(
1
)
===
'x'
?
String
.
fromCharCode
(
parseInt
(
n
.
substring
(
2
),
16
))
:
String
.
fromCharCode
(
+
n
.
substring
(
1
));
}
return
''
;
});
}
function
edit
(
regex
,
opt
)
{
regex
=
regex
.
source
||
regex
;
opt
=
opt
||
''
;
return
{
replace
:
function
(
name
,
val
)
{
val
=
val
.
source
||
val
;
val
=
val
.
replace
(
/
(
^|
[^\[])\^
/g
,
'$1'
);
regex
=
regex
.
replace
(
name
,
val
);
return
this
;
},
getRegex
:
function
()
{
return
new
RegExp
(
regex
,
opt
);
}
};
}
function
resolveUrl
(
base
,
href
)
{
if
(
!
baseUrls
[
' '
+
base
])
{
// we can ignore everything in base after the last slash of its path component,
// but we might need to add _that_
// https://tools.ietf.org/html/rfc3986#section-3
if
(
/^
[^
:
]
+:
\/
*
[^/]
*$/
.
test
(
base
))
{
baseUrls
[
' '
+
base
]
=
base
+
'/'
;
}
else
{
baseUrls
[
' '
+
base
]
=
rtrim
(
base
,
'/'
,
true
);
}
}
base
=
baseUrls
[
' '
+
base
];
if
(
href
.
slice
(
0
,
2
)
===
'//'
)
{
return
base
.
replace
(
/:
[\s\S]
*/
,
':'
)
+
href
;
}
else
if
(
href
.
charAt
(
0
)
===
'/'
)
{
return
base
.
replace
(
/
(
:
\/
*
[^/]
*
)[\s\S]
*/
,
'$1'
)
+
href
;
}
else
{
return
base
+
href
;
}
}
var
baseUrls
=
{};
var
originIndependentUrl
=
/^$|^
[
a-z
][
a-z0-9+.-
]
*:|^
[
?#
]
/i
;
function
noop
()
{}
noop
.
exec
=
noop
;
function
merge
(
obj
)
{
var
i
=
1
,
target
,
key
;
for
(;
i
<
arguments
.
length
;
i
++
)
{
target
=
arguments
[
i
];
for
(
key
in
target
)
{
if
(
Object
.
prototype
.
hasOwnProperty
.
call
(
target
,
key
))
{
obj
[
key
]
=
target
[
key
];
}
}
}
return
obj
;
}
function
splitCells
(
tableRow
,
count
)
{
// ensure that every cell-delimiting pipe has a space
// before it to distinguish it from an escaped pipe
var
row
=
tableRow
.
replace
(
/
\|
/g
,
function
(
match
,
offset
,
str
)
{
var
escaped
=
false
,
curr
=
offset
;
while
(
--
curr
>=
0
&&
str
[
curr
]
===
'
\
\'
) escaped = !escaped;
if (escaped) {
// odd number of slashes means | is escaped
// so we leave it alone
return '
|
';
} else {
// add space before unescaped |
return '
|
';
}
}),
cells = row.split(/
\
|/),
i = 0;
if (cells.length > count) {
cells.splice(count);
} else {
while (cells.length < count) cells.push('');
}
for (; i < cells.length; i++) {
// leading or trailing whitespace is ignored per the gfm spec
cells[i] = cells[i].trim().replace(/
\\\
|/g, '
|
');
}
return cells;
}
// Remove trailing '
c
's. Equivalent to str.replace(/c*$/, '').
// /c*$/ is vulnerable to REDOS.
// invert: Remove suffix of non-c chars instead. Default falsey.
function rtrim(str, c, invert) {
if (str.length === 0) {
return '';
}
// Length of suffix matching the invert condition.
var suffLen = 0;
// Step left until we fail to match the invert condition.
while (suffLen < str.length) {
var currChar = str.charAt(str.length - suffLen - 1);
if (currChar === c && !invert) {
suffLen++;
} else if (currChar !== c && invert) {
suffLen++;
} else {
break;
}
}
return str.substr(0, str.length - suffLen);
}
/**
* Marked
*/
function marked(src, opt, callback) {
// throw error in case of non string input
if (typeof src === '
undefined
' || src === null) {
throw new Error('
marked
():
input
parameter
is
undefined
or
null
');
}
if (typeof src !== '
string
') {
throw new Error('
marked
():
input
parameter
is
of
type
' +
Object.prototype.toString.call(src) + '
,
string
expected
');
}
if (callback || typeof opt === '
function
') {
if (!callback) {
callback = opt;
opt = null;
}
opt = merge({}, marked.defaults, opt || {});
var highlight = opt.highlight,
tokens,
pending,
i = 0;
try {
tokens = Lexer.lex(src, opt)
} catch (e) {
return callback(e);
}
pending = tokens.length;
var done = function(err) {
if (err) {
opt.highlight = highlight;
return callback(err);
}
var out;
try {
out = Parser.parse(tokens, opt);
} catch (e) {
err = e;
}
opt.highlight = highlight;
return err ?
callback(err) :
callback(null, out);
};
if (!highlight || highlight.length < 3) {
return done();
}
delete opt.highlight;
if (!pending) return done();
for (; i < tokens.length; i++) {
(function(token) {
if (token.type !== '
code
') {
return --pending || done();
}
return highlight(token.text, token.lang, function(err, code) {
if (err) return done(err);
if (code == null || code === token.text) {
return --pending || done();
}
token.text = code;
token.escaped = true;
--pending || done();
});
})(tokens[i]);
}
return;
}
try {
if (opt) opt = merge({}, marked.defaults, opt);
return Parser.parse(Lexer.lex(src, opt), opt);
} catch (e) {
e.message += '
\
nPlease
report
this
to
https
:
//github.com/markedjs/marked.';
if
((
opt
||
marked
.
defaults
).
silent
)
{
return
'<p>An error occurred:</p><pre>'
+
escape
(
e
.
message
+
''
,
true
)
+
'</pre>'
;
}
throw
e
;
}
}
/**
* Options
*/
marked
.
options
=
marked
.
setOptions
=
function
(
opt
)
{
merge
(
marked
.
defaults
,
opt
);
return
marked
;
};
marked
.
getDefaults
=
function
()
{
return
{
baseUrl
:
null
,
breaks
:
false
,
gfm
:
true
,
headerIds
:
true
,
headerPrefix
:
''
,
highlight
:
null
,
langPrefix
:
'language-'
,
mangle
:
true
,
pedantic
:
false
,
renderer
:
new
Renderer
(),
sanitize
:
false
,
sanitizer
:
null
,
silent
:
false
,
smartLists
:
false
,
smartypants
:
false
,
tables
:
true
,
xhtml
:
false
};
}
marked
.
defaults
=
marked
.
getDefaults
();
/**
* Expose
*/
marked
.
Parser
=
Parser
;
marked
.
parser
=
Parser
.
parse
;
marked
.
Renderer
=
Renderer
;
marked
.
TextRenderer
=
TextRenderer
;
marked
.
Lexer
=
Lexer
;
marked
.
lexer
=
Lexer
.
lex
;
marked
.
InlineLexer
=
InlineLexer
;
marked
.
inlineLexer
=
InlineLexer
.
output
;
marked
.
parse
=
marked
;
// if (typeof module !== 'undefined' && typeof exports === 'object') {
// module.exports = marked;
// } else if (typeof define === 'function' && define.amd) {
// define(function() { return marked; });
// } else {
// root.marked = marked;
// }
// })(this || (typeof window !== 'undefined' ? window : global));
export
default
marked
src/components/FirstUI/fui-parse/marked/lib/marked.js
deleted
100644 → 0
浏览文件 @
b91bebf0
/**
* marked - a markdown parser
* Copyright (c) 2011-2014, Christopher Jeffrey. (MIT Licensed)
* https://github.com/markedjs/marked
*/
;(
function
(
root
)
{
'use strict'
;
/**
* Block-Level Grammar
*/
var
block
=
{
newline
:
/^
\n
+/
,
code
:
/^
(
{4}[^\n]
+
\n
*
)
+/
,
fences
:
noop
,
hr
:
/^
{0,3}((?:
- *
){3,}
|
(?:
_ *
){3,}
|
(?:\*
*
){3,})(?:\n
+|$
)
/
,
heading
:
/^ *
(
#
{1,6})
*
([^\n]
+
?)
*
(?:
#+ *
)?(?:\n
+|$
)
/
,
nptable
:
noop
,
blockquote
:
/^
(
{0,3}
>
?(
paragraph|
[^\n]
*
)(?:\n
|$
))
+/
,
list
:
/^
(
*
)(
bull
)
[\s\S]
+
?(?:
hr|def|
\n{2,}(?!
)(?!\1
bull
)\n
*|
\s
*$
)
/
,
html
:
'^ {0,3}(?:'
// optional indentation
+
'<(script|pre|style)[
\\
s>][
\\
s
\\
S]*?(?:</
\\
1>[^
\\
n]*
\\
n+|$)'
// (1)
+
'|comment[^
\\
n]*(
\\
n+|$)'
// (2)
+
'|<
\\
?[
\\
s
\\
S]*?
\\
?>
\\
n*'
// (3)
+
'|<![A-Z][
\\
s
\\
S]*?>
\\
n*'
// (4)
+
'|<!
\\
[CDATA
\\
[[
\\
s
\\
S]*?
\\
]
\\
]>
\\
n*'
// (5)
+
'|</?(tag)(?: +|
\\
n|/?>)[
\\
s
\\
S]*?(?:
\\
n{2,}|$)'
// (6)
+
'|<(?!script|pre|style)([a-z][
\\
w-]*)(?:attribute)*? */?>(?=
\\
h*
\\
n)[
\\
s
\\
S]*?(?:
\\
n{2,}|$)'
// (7) open tag
+
'|</(?!script|pre|style)[a-z][
\\
w-]*
\\
s*>(?=
\\
h*
\\
n)[
\\
s
\\
S]*?(?:
\\
n{2,}|$)'
// (7) closing tag
+
')'
,
def
:
/^
{0,3}\[(
label
)\]
: *
\n?
*<
?([^\s
>
]
+
)
>
?(?:(?:
+
\n?
*| *
\n
*
)(
title
))?
*
(?:\n
+|$
)
/
,
table
:
noop
,
lheading
:
/^
([^\n]
+
)\n
*
(
=|-
){2,}
*
(?:\n
+|$
)
/
,
paragraph
:
/^
([^\n]
+
(?:\n(?!
hr|heading|lheading|
{0,3}
>|<
\/?(?:
tag
)(?:
+|
\n
|
\/?
>
)
|<
(?:
script|pre|style|!--
))[^\n]
+
)
*
)
/
,
text
:
/^
[^\n]
+/
};
block
.
_label
=
/
(?!\s
*
\])(?:\\[\[\]]
|
[^\[\]])
+/
;
block
.
_title
=
/
(?:
"
(?:\\
"
?
|
[^
"
\\])
*"|'
[^
'
\n]
*
(?:\n[^
'
\n]
+
)
*
\n?
'|
\([^
()
]
*
\))
/
;
block
.
def
=
edit
(
block
.
def
)
.
replace
(
'label'
,
block
.
_label
)
.
replace
(
'title'
,
block
.
_title
)
.
getRegex
();
block
.
bullet
=
/
(?:[
*+-
]
|
\d
+
\.)
/
;
block
.
item
=
/^
(
*
)(
bull
)
[^\n]
*
(?:\n(?!\1
bull
)[^\n]
*
)
*/
;
block
.
item
=
edit
(
block
.
item
,
'gm'
)
.
replace
(
/bull/g
,
block
.
bullet
)
.
getRegex
();
block
.
list
=
edit
(
block
.
list
)
.
replace
(
/bull/g
,
block
.
bullet
)
.
replace
(
'hr'
,
'
\\
n+(?=
\\
1?(?:(?:- *){3,}|(?:_ *){3,}|(?:
\\
* *){3,})(?:
\\
n+|$))'
)
.
replace
(
'def'
,
'
\\
n+(?='
+
block
.
def
.
source
+
')'
)
.
getRegex
();
block
.
_tag
=
'address|article|aside|base|basefont|blockquote|body|caption'
+
'|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption'
+
'|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe'
+
'|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option'
+
'|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr'
+
'|track|ul'
;
block
.
_comment
=
/<!--
(?!
-
?
>
)[\s\S]
*
?
-->/
;
block
.
html
=
edit
(
block
.
html
,
'i'
)
.
replace
(
'comment'
,
block
.
_comment
)
.
replace
(
'tag'
,
block
.
_tag
)
.
replace
(
'attribute'
,
/ +
[
a-zA-Z:_
][\w
.:-
]
*
(?:
*= *"
[^
"
\n]
*"| *= *'
[^
'
\n]
*'| *= *
[^\s
"'=<>`
]
+
)?
/
)
.
getRegex
();
block
.
paragraph
=
edit
(
block
.
paragraph
)
.
replace
(
'hr'
,
block
.
hr
)
.
replace
(
'heading'
,
block
.
heading
)
.
replace
(
'lheading'
,
block
.
lheading
)
.
replace
(
'tag'
,
block
.
_tag
)
// pars can be interrupted by type (6) html blocks
.
getRegex
();
block
.
blockquote
=
edit
(
block
.
blockquote
)
.
replace
(
'paragraph'
,
block
.
paragraph
)
.
getRegex
();
/**
* Normal Block Grammar
*/
block
.
normal
=
merge
({},
block
);
/**
* GFM Block Grammar
*/
block
.
gfm
=
merge
({},
block
.
normal
,
{
fences
:
/^ *
(
`
{3,}
|~
{3,})[
\.]
*
(\S
+
)?
*
\n([\s\S]
*
?)\n?
*
\1
*
(?:\n
+|$
)
/
,
paragraph
:
/^/
,
heading
:
/^ *
(
#
{1,6})
+
([^\n]
+
?)
*#* *
(?:\n
+|$
)
/
});
block
.
gfm
.
paragraph
=
edit
(
block
.
paragraph
)
.
replace
(
'(?!'
,
'(?!'
+
block
.
gfm
.
fences
.
source
.
replace
(
'
\\
1'
,
'
\\
2'
)
+
'|'
+
block
.
list
.
source
.
replace
(
'
\\
1'
,
'
\\
3'
)
+
'|'
)
.
getRegex
();
/**
* GFM + Tables Block Grammar
*/
block
.
tables
=
merge
({},
block
.
gfm
,
{
nptable
:
/^ *
([^
|
\n
]
.*
\|
.*
)\n
*
([
-:
]
+ *
\|[
-| :
]
*
)(?:\n((?:
.*
[^
>
\n
]
.*
(?:\n
|$
))
*
)\n
*|$
)
/
,
table
:
/^ *
\|(
.+
)\n
*
\|?(
*
[
-:
]
+
[
-| :
]
*
)(?:\n((?:
*
[^
>
\n
]
.*
(?:\n
|$
))
*
)\n
*|$
)
/
});
/**
* Pedantic grammar
*/
block
.
pedantic
=
merge
({},
block
.
normal
,
{
html
:
edit
(
'^ *(?:comment *(?:
\\
n|
\\
s*$)'
+
'|<(tag)[
\\
s
\\
S]+?</
\\
1> *(?:
\\
n{2,}|
\\
s*$)'
// closed tag
+
'|<tag(?:"[^"]*"|
\'
[^
\'
]*
\'
|
\\
s[^
\'
"/>
\\
s]*)*?/?> *(?:
\\
n{2,}|
\\
s*$))'
)
.
replace
(
'comment'
,
block
.
_comment
)
.
replace
(
/tag/g
,
'(?!(?:'
+
'a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub'
+
'|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)'
+
'
\\
b)
\\
w+(?!:|[^
\\
w
\\
s@]*@)
\\
b'
)
.
getRegex
(),
def
:
/^ *
\[([^\]]
+
)\]
: *<
?([^\s
>
]
+
)
>
?(?:
+
([
"(
][^\n]
+
[
")
]))?
*
(?:\n
+|$
)
/
});
/**
* Block Lexer
*/
function
Lexer
(
options
)
{
this
.
tokens
=
[];
this
.
tokens
.
links
=
Object
.
create
(
null
);
this
.
options
=
options
||
marked
.
defaults
;
this
.
rules
=
block
.
normal
;
if
(
this
.
options
.
pedantic
)
{
this
.
rules
=
block
.
pedantic
;
}
else
if
(
this
.
options
.
gfm
)
{
if
(
this
.
options
.
tables
)
{
this
.
rules
=
block
.
tables
;
}
else
{
this
.
rules
=
block
.
gfm
;
}
}
}
/**
* Expose Block Rules
*/
Lexer
.
rules
=
block
;
/**
* Static Lex Method
*/
Lexer
.
lex
=
function
(
src
,
options
)
{
var
lexer
=
new
Lexer
(
options
);
return
lexer
.
lex
(
src
);
};
/**
* Preprocessing
*/
Lexer
.
prototype
.
lex
=
function
(
src
)
{
src
=
src
.
replace
(
/
\r\n
|
\r
/g
,
'
\
n'
)
.
replace
(
/
\t
/g
,
' '
)
.
replace
(
/
\u
00a0/g
,
' '
)
.
replace
(
/
\u
2424/g
,
'
\
n'
);
return
this
.
token
(
src
,
true
);
};
/**
* Lexing
*/
Lexer
.
prototype
.
token
=
function
(
src
,
top
)
{
src
=
src
.
replace
(
/^ +$/gm
,
''
);
var
next
,
loose
,
cap
,
bull
,
b
,
item
,
listStart
,
listItems
,
t
,
space
,
i
,
tag
,
l
,
isordered
,
istask
,
ischecked
;
while
(
src
)
{
// newline
if
(
cap
=
this
.
rules
.
newline
.
exec
(
src
))
{
src
=
src
.
substring
(
cap
[
0
].
length
);
if
(
cap
[
0
].
length
>
1
)
{
this
.
tokens
.
push
({
type
:
'space'
});
}
}
// code
if
(
cap
=
this
.
rules
.
code
.
exec
(
src
))
{
src
=
src
.
substring
(
cap
[
0
].
length
);
cap
=
cap
[
0
].
replace
(
/^
{4}
/gm
,
''
);
this
.
tokens
.
push
({
type
:
'code'
,
text
:
!
this
.
options
.
pedantic
?
rtrim
(
cap
,
'
\
n'
)
:
cap
});
continue
;
}
// fences (gfm)
if
(
cap
=
this
.
rules
.
fences
.
exec
(
src
))
{
src
=
src
.
substring
(
cap
[
0
].
length
);
this
.
tokens
.
push
({
type
:
'code'
,
lang
:
cap
[
2
],
text
:
cap
[
3
]
||
''
});
continue
;
}
// heading
if
(
cap
=
this
.
rules
.
heading
.
exec
(
src
))
{
src
=
src
.
substring
(
cap
[
0
].
length
);
this
.
tokens
.
push
({
type
:
'heading'
,
depth
:
cap
[
1
].
length
,
text
:
cap
[
2
]
});
continue
;
}
// table no leading pipe (gfm)
if
(
top
&&
(
cap
=
this
.
rules
.
nptable
.
exec
(
src
)))
{
item
=
{
type
:
'table'
,
header
:
splitCells
(
cap
[
1
].
replace
(
/^ *| *
\|
*$/g
,
''
)),
align
:
cap
[
2
].
replace
(
/^ *|
\|
*$/g
,
''
).
split
(
/ *
\|
*/
),
cells
:
cap
[
3
]
?
cap
[
3
].
replace
(
/
\n
$/
,
''
).
split
(
'
\
n'
)
:
[]
};
if
(
item
.
header
.
length
===
item
.
align
.
length
)
{
src
=
src
.
substring
(
cap
[
0
].
length
);
for
(
i
=
0
;
i
<
item
.
align
.
length
;
i
++
)
{
if
(
/^ *-+: *$/
.
test
(
item
.
align
[
i
]))
{
item
.
align
[
i
]
=
'right'
;
}
else
if
(
/^ *:-+: *$/
.
test
(
item
.
align
[
i
]))
{
item
.
align
[
i
]
=
'center'
;
}
else
if
(
/^ *:-+ *$/
.
test
(
item
.
align
[
i
]))
{
item
.
align
[
i
]
=
'left'
;
}
else
{
item
.
align
[
i
]
=
null
;
}
}
for
(
i
=
0
;
i
<
item
.
cells
.
length
;
i
++
)
{
item
.
cells
[
i
]
=
splitCells
(
item
.
cells
[
i
],
item
.
header
.
length
);
}
this
.
tokens
.
push
(
item
);
continue
;
}
}
// hr
if
(
cap
=
this
.
rules
.
hr
.
exec
(
src
))
{
src
=
src
.
substring
(
cap
[
0
].
length
);
this
.
tokens
.
push
({
type
:
'hr'
});
continue
;
}
// blockquote
if
(
cap
=
this
.
rules
.
blockquote
.
exec
(
src
))
{
src
=
src
.
substring
(
cap
[
0
].
length
);
this
.
tokens
.
push
({
type
:
'blockquote_start'
});
cap
=
cap
[
0
].
replace
(
/^ *>
?
/gm
,
''
);
// Pass `top` to keep the current
// "toplevel" state. This is exactly
// how markdown.pl works.
this
.
token
(
cap
,
top
);
this
.
tokens
.
push
({
type
:
'blockquote_end'
});
continue
;
}
// list
if
(
cap
=
this
.
rules
.
list
.
exec
(
src
))
{
src
=
src
.
substring
(
cap
[
0
].
length
);
bull
=
cap
[
2
];
isordered
=
bull
.
length
>
1
;
listStart
=
{
type
:
'list_start'
,
ordered
:
isordered
,
start
:
isordered
?
+
bull
:
''
,
loose
:
false
};
this
.
tokens
.
push
(
listStart
);
// Get each top-level item.
cap
=
cap
[
0
].
match
(
this
.
rules
.
item
);
listItems
=
[];
next
=
false
;
l
=
cap
.
length
;
i
=
0
;
for
(;
i
<
l
;
i
++
)
{
item
=
cap
[
i
];
// Remove the list item's bullet
// so it is seen as the next token.
space
=
item
.
length
;
item
=
item
.
replace
(
/^ *
([
*+-
]
|
\d
+
\.)
+/
,
''
);
// Outdent whatever the
// list item contains. Hacky.
if
(
~
item
.
indexOf
(
'
\
n '
))
{
space
-=
item
.
length
;
item
=
!
this
.
options
.
pedantic
?
item
.
replace
(
new
RegExp
(
'^ {1,'
+
space
+
'}'
,
'gm'
),
''
)
:
item
.
replace
(
/^
{1,4}
/gm
,
''
);
}
// Determine whether the next list item belongs here.
// Backpedal if it does not belong in this list.
if
(
this
.
options
.
smartLists
&&
i
!==
l
-
1
)
{
b
=
block
.
bullet
.
exec
(
cap
[
i
+
1
])[
0
];
if
(
bull
!==
b
&&
!
(
bull
.
length
>
1
&&
b
.
length
>
1
))
{
src
=
cap
.
slice
(
i
+
1
).
join
(
'
\
n'
)
+
src
;
i
=
l
-
1
;
}
}
// Determine whether item is loose or not.
// Use: /(^|\n)(?! )[^\n]+\n\n(?!\s*$)/
// for discount behavior.
loose
=
next
||
/
\n\n(?!\s
*$
)
/
.
test
(
item
);
if
(
i
!==
l
-
1
)
{
next
=
item
.
charAt
(
item
.
length
-
1
)
===
'
\
n'
;
if
(
!
loose
)
loose
=
next
;
}
if
(
loose
)
{
listStart
.
loose
=
true
;
}
// Check for task list items
istask
=
/^
\[[
xX
]\]
/
.
test
(
item
);
ischecked
=
undefined
;
if
(
istask
)
{
ischecked
=
item
[
1
]
!==
' '
;
item
=
item
.
replace
(
/^
\[[
xX
]\]
+/
,
''
);
}
t
=
{
type
:
'list_item_start'
,
task
:
istask
,
checked
:
ischecked
,
loose
:
loose
};
listItems
.
push
(
t
);
this
.
tokens
.
push
(
t
);
// Recurse.
this
.
token
(
item
,
false
);
this
.
tokens
.
push
({
type
:
'list_item_end'
});
}
if
(
listStart
.
loose
)
{
l
=
listItems
.
length
;
i
=
0
;
for
(;
i
<
l
;
i
++
)
{
listItems
[
i
].
loose
=
true
;
}
}
this
.
tokens
.
push
({
type
:
'list_end'
});
continue
;
}
// html
if
(
cap
=
this
.
rules
.
html
.
exec
(
src
))
{
src
=
src
.
substring
(
cap
[
0
].
length
);
this
.
tokens
.
push
({
type
:
this
.
options
.
sanitize
?
'paragraph'
:
'html'
,
pre
:
!
this
.
options
.
sanitizer
&&
(
cap
[
1
]
===
'pre'
||
cap
[
1
]
===
'script'
||
cap
[
1
]
===
'style'
),
text
:
cap
[
0
]
});
continue
;
}
// def
if
(
top
&&
(
cap
=
this
.
rules
.
def
.
exec
(
src
)))
{
src
=
src
.
substring
(
cap
[
0
].
length
);
if
(
cap
[
3
])
cap
[
3
]
=
cap
[
3
].
substring
(
1
,
cap
[
3
].
length
-
1
);
tag
=
cap
[
1
].
toLowerCase
().
replace
(
/
\s
+/g
,
' '
);
if
(
!
this
.
tokens
.
links
[
tag
])
{
this
.
tokens
.
links
[
tag
]
=
{
href
:
cap
[
2
],
title
:
cap
[
3
]
};
}
continue
;
}
// table (gfm)
if
(
top
&&
(
cap
=
this
.
rules
.
table
.
exec
(
src
)))
{
item
=
{
type
:
'table'
,
header
:
splitCells
(
cap
[
1
].
replace
(
/^ *| *
\|
*$/g
,
''
)),
align
:
cap
[
2
].
replace
(
/^ *|
\|
*$/g
,
''
).
split
(
/ *
\|
*/
),
cells
:
cap
[
3
]
?
cap
[
3
].
replace
(
/
(?:
*
\|
*
)?\n
$/
,
''
).
split
(
'
\
n'
)
:
[]
};
if
(
item
.
header
.
length
===
item
.
align
.
length
)
{
src
=
src
.
substring
(
cap
[
0
].
length
);
for
(
i
=
0
;
i
<
item
.
align
.
length
;
i
++
)
{
if
(
/^ *-+: *$/
.
test
(
item
.
align
[
i
]))
{
item
.
align
[
i
]
=
'right'
;
}
else
if
(
/^ *:-+: *$/
.
test
(
item
.
align
[
i
]))
{
item
.
align
[
i
]
=
'center'
;
}
else
if
(
/^ *:-+ *$/
.
test
(
item
.
align
[
i
]))
{
item
.
align
[
i
]
=
'left'
;
}
else
{
item
.
align
[
i
]
=
null
;
}
}
for
(
i
=
0
;
i
<
item
.
cells
.
length
;
i
++
)
{
item
.
cells
[
i
]
=
splitCells
(
item
.
cells
[
i
].
replace
(
/^ *
\|
*| *
\|
*$/g
,
''
),
item
.
header
.
length
);
}
this
.
tokens
.
push
(
item
);
continue
;
}
}
// lheading
if
(
cap
=
this
.
rules
.
lheading
.
exec
(
src
))
{
src
=
src
.
substring
(
cap
[
0
].
length
);
this
.
tokens
.
push
({
type
:
'heading'
,
depth
:
cap
[
2
]
===
'='
?
1
:
2
,
text
:
cap
[
1
]
});
continue
;
}
// top-level paragraph
if
(
top
&&
(
cap
=
this
.
rules
.
paragraph
.
exec
(
src
)))
{
src
=
src
.
substring
(
cap
[
0
].
length
);
this
.
tokens
.
push
({
type
:
'paragraph'
,
text
:
cap
[
1
].
charAt
(
cap
[
1
].
length
-
1
)
===
'
\
n'
?
cap
[
1
].
slice
(
0
,
-
1
)
:
cap
[
1
]
});
continue
;
}
// text
if
(
cap
=
this
.
rules
.
text
.
exec
(
src
))
{
// Top-level should never reach here.
src
=
src
.
substring
(
cap
[
0
].
length
);
this
.
tokens
.
push
({
type
:
'text'
,
text
:
cap
[
0
]
});
continue
;
}
if
(
src
)
{
throw
new
Error
(
'Infinite loop on byte: '
+
src
.
charCodeAt
(
0
));
}
}
return
this
.
tokens
;
};
/**
* Inline-Level Grammar
*/
var
inline
=
{
escape
:
/^
\\([
!"#$%&'()*+,
\-
.
/
:;<=>?@
\[\]\\
^_`{|}~
])
/
,
autolink
:
/^<
(
scheme:
[^\s\x
00-
\x
1f<>
]
*|email
)
>/
,
url
:
noop
,
tag
:
'^comment'
+
'|^</[a-zA-Z][
\\
w:-]*
\\
s*>'
// self-closing tag
+
'|^<[a-zA-Z][
\\
w-]*(?:attribute)*?
\\
s*/?>'
// open tag
+
'|^<
\\
?[
\\
s
\\
S]*?
\\
?>'
// processing instruction, e.g. <?php ?>
+
'|^<![a-zA-Z]+
\\
s[
\\
s
\\
S]*?>'
// declaration, e.g. <!DOCTYPE html>
+
'|^<!
\\
[CDATA
\\
[[
\\
s
\\
S]*?
\\
]
\\
]>'
,
// CDATA section
link
:
/^!
?\[(
label
)\]\(
href
(?:\s
+
(
title
))?\s
*
\)
/
,
reflink
:
/^!
?\[(
label
)\]\[(?!\s
*
\])((?:\\[\[\]]?
|
[^\[\]\\])
+
)\]
/
,
nolink
:
/^!
?\[(?!\s
*
\])((?:\[[^\[\]]
*
\]
|
\\[\[\]]
|
[^\[\]])
*
)\](?:\[\])?
/
,
strong
:
/^__
([^\s])
__
(?!
_
)
|^
\*\*([^\s])\*\*(?!\*)
|^__
([^\s][\s\S]
*
?[^\s])
__
(?!
_
)
|^
\*\*([^\s][\s\S]
*
?[^\s])\*\*(?!\*)
/
,
em
:
/^_
([^\s
_
])
_
(?!
_
)
|^
\*([^\s
*"<
\[])\*(?!\*)
|^_
([^\s][\s\S]
*
?[^\s
_
])
_
(?!
_
)
|^_
([^\s
_
][\s\S]
*
?[^\s])
_
(?!
_
)
|^
\*([^\s
"<
\[][\s\S]
*
?[^\s
*
])\*(?!\*)
|^
\*([^\s
*"<
\[][\s\S]
*
?[^\s])\*(?!\*)
/
,
code
:
/^
(
`+
)\s
*
([\s\S]
*
?[^
`
]?)\s
*
\1(?!
`
)
/
,
br
:
/^
(
{2,}
|
\\)\n(?!\s
*$
)
/
,
del
:
noop
,
text
:
/^
[\s\S]
+
?(?=[\\
<!
\[
`*
]
|
\b
_|
{2,}\n
|$
)
/
};
inline
.
_escapes
=
/
\\([
!"#$%&'()*+,
\-
.
/
:;<=>?@
\[\]\\
^_`{|}~
])
/g
;
inline
.
_scheme
=
/
[
a-zA-Z
][
a-zA-Z0-9+.-
]{1,31}
/
;
inline
.
_email
=
/
[
a-zA-Z0-9.!#$%&'*+
/
=?^_`{|}~-
]
+
(
@
)[
a-zA-Z0-9
](?:[
a-zA-Z0-9-
]{0,61}[
a-zA-Z0-9
])?(?:\.[
a-zA-Z0-9
](?:[
a-zA-Z0-9-
]{0,61}[
a-zA-Z0-9
])?)
+
(?![
-_
])
/
;
inline
.
autolink
=
edit
(
inline
.
autolink
)
.
replace
(
'scheme'
,
inline
.
_scheme
)
.
replace
(
'email'
,
inline
.
_email
)
.
getRegex
();
inline
.
_attribute
=
/
\s
+
[
a-zA-Z:_
][\w
.:-
]
*
(?:\s
*=
\s
*"
[^
"
]
*"|
\s
*=
\s
*'
[^
'
]
*'|
\s
*=
\s
*
[^\s
"'=<>`
]
+
)?
/
;
inline
.
tag
=
edit
(
inline
.
tag
)
.
replace
(
'comment'
,
block
.
_comment
)
.
replace
(
'attribute'
,
inline
.
_attribute
)
.
getRegex
();
inline
.
_label
=
/
(?:\[[^\[\]]
*
\]
|
\\[\[\]]?
|`
[^
`
]
*`|
[^\[\]\\])
*
?
/
;
inline
.
_href
=
/
\s
*
(
<
(?:\\[
<>
]?
|
[^\s
<>
\\])
*>|
(?:\\[
()
]?
|
\([^\s\x
00-
\x
1f
\\]
*
\)
|
[^\s\x
00-
\x
1f()
\\])
*
?)
/
;
inline
.
_title
=
/"
(?:\\
"
?
|
[^
"
\\])
*"|'
(?:\\
'
?
|
[^
'
\\])
*'|
\((?:\\\)?
|
[^
)
\\])
*
\)
/
;
inline
.
link
=
edit
(
inline
.
link
)
.
replace
(
'label'
,
inline
.
_label
)
.
replace
(
'href'
,
inline
.
_href
)
.
replace
(
'title'
,
inline
.
_title
)
.
getRegex
();
inline
.
reflink
=
edit
(
inline
.
reflink
)
.
replace
(
'label'
,
inline
.
_label
)
.
getRegex
();
/**
* Normal Inline Grammar
*/
inline
.
normal
=
merge
({},
inline
);
/**
* Pedantic Inline Grammar
*/
inline
.
pedantic
=
merge
({},
inline
.
normal
,
{
strong
:
/^__
(?=\S)([\s\S]
*
?\S)
__
(?!
_
)
|^
\*\*(?=\S)([\s\S]
*
?\S)\*\*(?!\*)
/
,
em
:
/^_
(?=\S)([\s\S]
*
?\S)
_
(?!
_
)
|^
\*(?=\S)([\s\S]
*
?\S)\*(?!\*)
/
,
link
:
edit
(
/^!
?\[(
label
)\]\((
.*
?)\)
/
)
.
replace
(
'label'
,
inline
.
_label
)
.
getRegex
(),
reflink
:
edit
(
/^!
?\[(
label
)\]\s
*
\[([^\]]
*
)\]
/
)
.
replace
(
'label'
,
inline
.
_label
)
.
getRegex
()
});
/**
* GFM Inline Grammar
*/
inline
.
gfm
=
merge
({},
inline
.
normal
,
{
escape
:
edit
(
inline
.
escape
).
replace
(
'])'
,
'~|])'
).
getRegex
(),
url
:
edit
(
/^
((?:
ftp|https
?)
:
\/\/
|www
\.)(?:[
a-zA-Z0-9
\-]
+
\.?)
+
[^\s
<
]
*|^email/
)
.
replace
(
'email'
,
inline
.
_email
)
.
getRegex
(),
_backpedal
:
/
(?:[^
?!.,:;*_~()&
]
+|
\([^
)
]
*
\)
|&
(?![
a-zA-Z0-9
]
+;$
)
|
[
?!.,:;*_~)
]
+
(?!
$
))
+/
,
del
:
/^~+
(?=\S)([\s\S]
*
?\S)
~+/
,
text
:
edit
(
inline
.
text
)
.
replace
(
']|'
,
'~]|'
)
.
replace
(
'|'
,
'|https?://|ftp://|www
\\
.|[a-zA-Z0-9.!#$%&
\'
*+/=?^_`{
\\
|}~-]+@|'
)
.
getRegex
()
});
/**
* GFM + Line Breaks Inline Grammar
*/
inline
.
breaks
=
merge
({},
inline
.
gfm
,
{
br
:
edit
(
inline
.
br
).
replace
(
'{2,}'
,
'*'
).
getRegex
(),
text
:
edit
(
inline
.
gfm
.
text
).
replace
(
'{2,}'
,
'*'
).
getRegex
()
});
/**
* Inline Lexer & Compiler
*/
function
InlineLexer
(
links
,
options
)
{
this
.
options
=
options
||
marked
.
defaults
;
this
.
links
=
links
;
this
.
rules
=
inline
.
normal
;
this
.
renderer
=
this
.
options
.
renderer
||
new
Renderer
();
this
.
renderer
.
options
=
this
.
options
;
if
(
!
this
.
links
)
{
throw
new
Error
(
'Tokens array requires a `links` property.'
);
}
if
(
this
.
options
.
pedantic
)
{
this
.
rules
=
inline
.
pedantic
;
}
else
if
(
this
.
options
.
gfm
)
{
if
(
this
.
options
.
breaks
)
{
this
.
rules
=
inline
.
breaks
;
}
else
{
this
.
rules
=
inline
.
gfm
;
}
}
}
/**
* Expose Inline Rules
*/
InlineLexer
.
rules
=
inline
;
/**
* Static Lexing/Compiling Method
*/
InlineLexer
.
output
=
function
(
src
,
links
,
options
)
{
var
inline
=
new
InlineLexer
(
links
,
options
);
return
inline
.
output
(
src
);
};
/**
* Lexing/Compiling
*/
InlineLexer
.
prototype
.
output
=
function
(
src
)
{
var
out
=
''
,
link
,
text
,
href
,
title
,
cap
,
prevCapZero
;
while
(
src
)
{
// escape
if
(
cap
=
this
.
rules
.
escape
.
exec
(
src
))
{
src
=
src
.
substring
(
cap
[
0
].
length
);
out
+=
cap
[
1
];
continue
;
}
// autolink
if
(
cap
=
this
.
rules
.
autolink
.
exec
(
src
))
{
src
=
src
.
substring
(
cap
[
0
].
length
);
if
(
cap
[
2
]
===
'@'
)
{
text
=
escape
(
this
.
mangle
(
cap
[
1
]));
href
=
'mailto:'
+
text
;
}
else
{
text
=
escape
(
cap
[
1
]);
href
=
text
;
}
out
+=
this
.
renderer
.
link
(
href
,
null
,
text
);
continue
;
}
// url (gfm)
if
(
!
this
.
inLink
&&
(
cap
=
this
.
rules
.
url
.
exec
(
src
)))
{
do
{
prevCapZero
=
cap
[
0
];
cap
[
0
]
=
this
.
rules
.
_backpedal
.
exec
(
cap
[
0
])[
0
];
}
while
(
prevCapZero
!==
cap
[
0
]);
src
=
src
.
substring
(
cap
[
0
].
length
);
if
(
cap
[
2
]
===
'@'
)
{
text
=
escape
(
cap
[
0
]);
href
=
'mailto:'
+
text
;
}
else
{
text
=
escape
(
cap
[
0
]);
if
(
cap
[
1
]
===
'www.'
)
{
href
=
'http://'
+
text
;
}
else
{
href
=
text
;
}
}
out
+=
this
.
renderer
.
link
(
href
,
null
,
text
);
continue
;
}
// tag
if
(
cap
=
this
.
rules
.
tag
.
exec
(
src
))
{
if
(
!
this
.
inLink
&&
/^<a /i
.
test
(
cap
[
0
]))
{
this
.
inLink
=
true
;
}
else
if
(
this
.
inLink
&&
/^<
\/
a>/i
.
test
(
cap
[
0
]))
{
this
.
inLink
=
false
;
}
src
=
src
.
substring
(
cap
[
0
].
length
);
out
+=
this
.
options
.
sanitize
?
this
.
options
.
sanitizer
?
this
.
options
.
sanitizer
(
cap
[
0
])
:
escape
(
cap
[
0
])
:
cap
[
0
]
continue
;
}
// link
if
(
cap
=
this
.
rules
.
link
.
exec
(
src
))
{
src
=
src
.
substring
(
cap
[
0
].
length
);
this
.
inLink
=
true
;
href
=
cap
[
2
];
if
(
this
.
options
.
pedantic
)
{
link
=
/^
([^
'"
]
*
[^\s])\s
+
([
'"
])(
.*
)\2
/
.
exec
(
href
);
if
(
link
)
{
href
=
link
[
1
];
title
=
link
[
3
];
}
else
{
title
=
''
;
}
}
else
{
title
=
cap
[
3
]
?
cap
[
3
].
slice
(
1
,
-
1
)
:
''
;
}
href
=
href
.
trim
().
replace
(
/^<
([\s\S]
*
)
>$/
,
'$1'
);
out
+=
this
.
outputLink
(
cap
,
{
href
:
InlineLexer
.
escapes
(
href
),
title
:
InlineLexer
.
escapes
(
title
)
});
this
.
inLink
=
false
;
continue
;
}
// reflink, nolink
if
((
cap
=
this
.
rules
.
reflink
.
exec
(
src
))
||
(
cap
=
this
.
rules
.
nolink
.
exec
(
src
)))
{
src
=
src
.
substring
(
cap
[
0
].
length
);
link
=
(
cap
[
2
]
||
cap
[
1
]).
replace
(
/
\s
+/g
,
' '
);
link
=
this
.
links
[
link
.
toLowerCase
()];
if
(
!
link
||
!
link
.
href
)
{
out
+=
cap
[
0
].
charAt
(
0
);
src
=
cap
[
0
].
substring
(
1
)
+
src
;
continue
;
}
this
.
inLink
=
true
;
out
+=
this
.
outputLink
(
cap
,
link
);
this
.
inLink
=
false
;
continue
;
}
// strong
if
(
cap
=
this
.
rules
.
strong
.
exec
(
src
))
{
src
=
src
.
substring
(
cap
[
0
].
length
);
out
+=
this
.
renderer
.
strong
(
this
.
output
(
cap
[
4
]
||
cap
[
3
]
||
cap
[
2
]
||
cap
[
1
]));
continue
;
}
// em
if
(
cap
=
this
.
rules
.
em
.
exec
(
src
))
{
src
=
src
.
substring
(
cap
[
0
].
length
);
out
+=
this
.
renderer
.
em
(
this
.
output
(
cap
[
6
]
||
cap
[
5
]
||
cap
[
4
]
||
cap
[
3
]
||
cap
[
2
]
||
cap
[
1
]));
continue
;
}
// code
if
(
cap
=
this
.
rules
.
code
.
exec
(
src
))
{
src
=
src
.
substring
(
cap
[
0
].
length
);
out
+=
this
.
renderer
.
codespan
(
escape
(
cap
[
2
].
trim
(),
true
));
continue
;
}
// br
if
(
cap
=
this
.
rules
.
br
.
exec
(
src
))
{
src
=
src
.
substring
(
cap
[
0
].
length
);
out
+=
this
.
renderer
.
br
();
continue
;
}
// del (gfm)
if
(
cap
=
this
.
rules
.
del
.
exec
(
src
))
{
src
=
src
.
substring
(
cap
[
0
].
length
);
out
+=
this
.
renderer
.
del
(
this
.
output
(
cap
[
1
]));
continue
;
}
// text
if
(
cap
=
this
.
rules
.
text
.
exec
(
src
))
{
src
=
src
.
substring
(
cap
[
0
].
length
);
out
+=
this
.
renderer
.
text
(
escape
(
this
.
smartypants
(
cap
[
0
])));
continue
;
}
if
(
src
)
{
throw
new
Error
(
'Infinite loop on byte: '
+
src
.
charCodeAt
(
0
));
}
}
return
out
;
};
InlineLexer
.
escapes
=
function
(
text
)
{
return
text
?
text
.
replace
(
InlineLexer
.
rules
.
_escapes
,
'$1'
)
:
text
;
}
/**
* Compile Link
*/
InlineLexer
.
prototype
.
outputLink
=
function
(
cap
,
link
)
{
var
href
=
link
.
href
,
title
=
link
.
title
?
escape
(
link
.
title
)
:
null
;
return
cap
[
0
].
charAt
(
0
)
!==
'!'
?
this
.
renderer
.
link
(
href
,
title
,
this
.
output
(
cap
[
1
]))
:
this
.
renderer
.
image
(
href
,
title
,
escape
(
cap
[
1
]));
};
/**
* Smartypants Transformations
*/
InlineLexer
.
prototype
.
smartypants
=
function
(
text
)
{
if
(
!
this
.
options
.
smartypants
)
return
text
;
return
text
// em-dashes
.
replace
(
/---/g
,
'
\
u2014'
)
// en-dashes
.
replace
(
/--/g
,
'
\
u2013'
)
// opening singles
.
replace
(
/
(
^|
[
-
\u
2014
/
(
\[
{"
\s])
'/g
,
'$1
\
u2018'
)
// closing singles & apostrophes
.
replace
(
/'/g
,
'
\
u2019'
)
// opening doubles
.
replace
(
/
(
^|
[
-
\u
2014
/
(
\[
{
\u
2018
\s])
"/g
,
'$1
\
u201c'
)
// closing doubles
.
replace
(
/"/g
,
'
\
u201d'
)
// ellipses
.
replace
(
/
\.{3}
/g
,
'
\
u2026'
);
};
/**
* Mangle Links
*/
InlineLexer
.
prototype
.
mangle
=
function
(
text
)
{
if
(
!
this
.
options
.
mangle
)
return
text
;
var
out
=
''
,
l
=
text
.
length
,
i
=
0
,
ch
;
for
(;
i
<
l
;
i
++
)
{
ch
=
text
.
charCodeAt
(
i
);
if
(
Math
.
random
()
>
0.5
)
{
ch
=
'x'
+
ch
.
toString
(
16
);
}
out
+=
'&#'
+
ch
+
';'
;
}
return
out
;
};
/**
* Renderer
*/
function
Renderer
(
options
)
{
this
.
options
=
options
||
marked
.
defaults
;
}
Renderer
.
prototype
.
code
=
function
(
code
,
lang
,
escaped
)
{
if
(
this
.
options
.
highlight
)
{
var
out
=
this
.
options
.
highlight
(
code
,
lang
);
if
(
out
!=
null
&&
out
!==
code
)
{
escaped
=
true
;
code
=
out
;
}
}
if
(
!
lang
)
{
return
'<pre><code>'
+
(
escaped
?
code
:
escape
(
code
,
true
))
+
'</code></pre>'
;
}
return
'<pre><code class="'
+
this
.
options
.
langPrefix
+
escape
(
lang
,
true
)
+
'">'
+
(
escaped
?
code
:
escape
(
code
,
true
))
+
'</code></pre>
\
n'
;
};
Renderer
.
prototype
.
blockquote
=
function
(
quote
)
{
return
'<blockquote>
\
n'
+
quote
+
'</blockquote>
\
n'
;
};
Renderer
.
prototype
.
html
=
function
(
html
)
{
return
html
;
};
Renderer
.
prototype
.
heading
=
function
(
text
,
level
,
raw
)
{
if
(
this
.
options
.
headerIds
)
{
return
'<h'
+
level
+
' id="'
+
this
.
options
.
headerPrefix
+
raw
.
toLowerCase
().
replace
(
/
[^\w]
+/g
,
'-'
)
+
'">'
+
text
+
'</h'
+
level
+
'>
\
n'
;
}
// ignore IDs
return
'<h'
+
level
+
'>'
+
text
+
'</h'
+
level
+
'>
\
n'
;
};
Renderer
.
prototype
.
hr
=
function
()
{
return
this
.
options
.
xhtml
?
'<hr/>
\
n'
:
'<hr>
\
n'
;
};
Renderer
.
prototype
.
list
=
function
(
body
,
ordered
,
start
)
{
var
type
=
ordered
?
'ol'
:
'ul'
,
startatt
=
(
ordered
&&
start
!==
1
)
?
(
' start="'
+
start
+
'"'
)
:
''
;
return
'<'
+
type
+
startatt
+
'>
\
n'
+
body
+
'</'
+
type
+
'>
\
n'
;
};
Renderer
.
prototype
.
listitem
=
function
(
text
)
{
return
'<li>'
+
text
+
'</li>
\
n'
;
};
Renderer
.
prototype
.
checkbox
=
function
(
checked
)
{
return
'<input '
+
(
checked
?
'checked="" '
:
''
)
+
'disabled="" type="checkbox"'
+
(
this
.
options
.
xhtml
?
' /'
:
''
)
+
'> '
;
}
Renderer
.
prototype
.
paragraph
=
function
(
text
)
{
return
'<p>'
+
text
+
'</p>
\
n'
;
};
Renderer
.
prototype
.
table
=
function
(
header
,
body
)
{
if
(
body
)
body
=
'<tbody>'
+
body
+
'</tbody>'
;
return
'<table>
\
n'
+
'<thead>
\
n'
+
header
+
'</thead>
\
n'
+
body
+
'</table>
\
n'
;
};
Renderer
.
prototype
.
tablerow
=
function
(
content
)
{
return
'<tr>
\
n'
+
content
+
'</tr>
\
n'
;
};
Renderer
.
prototype
.
tablecell
=
function
(
content
,
flags
)
{
var
type
=
flags
.
header
?
'th'
:
'td'
;
var
tag
=
flags
.
align
?
'<'
+
type
+
' align="'
+
flags
.
align
+
'">'
:
'<'
+
type
+
'>'
;
return
tag
+
content
+
'</'
+
type
+
'>
\
n'
;
};
// span level renderer
Renderer
.
prototype
.
strong
=
function
(
text
)
{
return
'<strong>'
+
text
+
'</strong>'
;
};
Renderer
.
prototype
.
em
=
function
(
text
)
{
return
'<em>'
+
text
+
'</em>'
;
};
Renderer
.
prototype
.
codespan
=
function
(
text
)
{
return
'<code>'
+
text
+
'</code>'
;
};
Renderer
.
prototype
.
br
=
function
()
{
return
this
.
options
.
xhtml
?
'<br/>'
:
'<br>'
;
};
Renderer
.
prototype
.
del
=
function
(
text
)
{
return
'<del>'
+
text
+
'</del>'
;
};
Renderer
.
prototype
.
link
=
function
(
href
,
title
,
text
)
{
if
(
this
.
options
.
sanitize
)
{
try
{
var
prot
=
decodeURIComponent
(
unescape
(
href
))
.
replace
(
/
[^\w
:
]
/g
,
''
)
.
toLowerCase
();
}
catch
(
e
)
{
return
text
;
}
if
(
prot
.
indexOf
(
'javascript:'
)
===
0
||
prot
.
indexOf
(
'vbscript:'
)
===
0
||
prot
.
indexOf
(
'data:'
)
===
0
)
{
return
text
;
}
}
if
(
this
.
options
.
baseUrl
&&
!
originIndependentUrl
.
test
(
href
))
{
href
=
resolveUrl
(
this
.
options
.
baseUrl
,
href
);
}
try
{
href
=
encodeURI
(
href
).
replace
(
/%25/g
,
'%'
);
}
catch
(
e
)
{
return
text
;
}
var
out
=
'<a href="'
+
escape
(
href
)
+
'"'
;
if
(
title
)
{
out
+=
' title="'
+
title
+
'"'
;
}
out
+=
'>'
+
text
+
'</a>'
;
return
out
;
};
Renderer
.
prototype
.
image
=
function
(
href
,
title
,
text
)
{
if
(
this
.
options
.
baseUrl
&&
!
originIndependentUrl
.
test
(
href
))
{
href
=
resolveUrl
(
this
.
options
.
baseUrl
,
href
);
}
var
out
=
'<img src="'
+
href
+
'" alt="'
+
text
+
'"'
;
if
(
title
)
{
out
+=
' title="'
+
title
+
'"'
;
}
out
+=
this
.
options
.
xhtml
?
'/>'
:
'>'
;
return
out
;
};
Renderer
.
prototype
.
text
=
function
(
text
)
{
return
text
;
};
/**
* TextRenderer
* returns only the textual part of the token
*/
function
TextRenderer
()
{}
// no need for block level renderers
TextRenderer
.
prototype
.
strong
=
TextRenderer
.
prototype
.
em
=
TextRenderer
.
prototype
.
codespan
=
TextRenderer
.
prototype
.
del
=
TextRenderer
.
prototype
.
text
=
function
(
text
)
{
return
text
;
}
TextRenderer
.
prototype
.
link
=
TextRenderer
.
prototype
.
image
=
function
(
href
,
title
,
text
)
{
return
''
+
text
;
}
TextRenderer
.
prototype
.
br
=
function
()
{
return
''
;
}
/**
* Parsing & Compiling
*/
function
Parser
(
options
)
{
this
.
tokens
=
[];
this
.
token
=
null
;
this
.
options
=
options
||
marked
.
defaults
;
this
.
options
.
renderer
=
this
.
options
.
renderer
||
new
Renderer
();
this
.
renderer
=
this
.
options
.
renderer
;
this
.
renderer
.
options
=
this
.
options
;
}
/**
* Static Parse Method
*/
Parser
.
parse
=
function
(
src
,
options
)
{
var
parser
=
new
Parser
(
options
);
return
parser
.
parse
(
src
);
};
/**
* Parse Loop
*/
Parser
.
prototype
.
parse
=
function
(
src
)
{
this
.
inline
=
new
InlineLexer
(
src
.
links
,
this
.
options
);
// use an InlineLexer with a TextRenderer to extract pure text
this
.
inlineText
=
new
InlineLexer
(
src
.
links
,
merge
({},
this
.
options
,
{
renderer
:
new
TextRenderer
()})
);
this
.
tokens
=
src
.
reverse
();
var
out
=
''
;
while
(
this
.
next
())
{
out
+=
this
.
tok
();
}
return
out
;
};
/**
* Next Token
*/
Parser
.
prototype
.
next
=
function
()
{
return
this
.
token
=
this
.
tokens
.
pop
();
};
/**
* Preview Next Token
*/
Parser
.
prototype
.
peek
=
function
()
{
return
this
.
tokens
[
this
.
tokens
.
length
-
1
]
||
0
;
};
/**
* Parse Text Tokens
*/
Parser
.
prototype
.
parseText
=
function
()
{
var
body
=
this
.
token
.
text
;
while
(
this
.
peek
().
type
===
'text'
)
{
body
+=
'
\
n'
+
this
.
next
().
text
;
}
return
this
.
inline
.
output
(
body
);
};
/**
* Parse Current Token
*/
Parser
.
prototype
.
tok
=
function
()
{
switch
(
this
.
token
.
type
)
{
case
'space'
:
{
return
''
;
}
case
'hr'
:
{
return
this
.
renderer
.
hr
();
}
case
'heading'
:
{
return
this
.
renderer
.
heading
(
this
.
inline
.
output
(
this
.
token
.
text
),
this
.
token
.
depth
,
unescape
(
this
.
inlineText
.
output
(
this
.
token
.
text
)));
}
case
'code'
:
{
return
this
.
renderer
.
code
(
this
.
token
.
text
,
this
.
token
.
lang
,
this
.
token
.
escaped
);
}
case
'table'
:
{
var
header
=
''
,
body
=
''
,
i
,
row
,
cell
,
j
;
// header
cell
=
''
;
for
(
i
=
0
;
i
<
this
.
token
.
header
.
length
;
i
++
)
{
cell
+=
this
.
renderer
.
tablecell
(
this
.
inline
.
output
(
this
.
token
.
header
[
i
]),
{
header
:
true
,
align
:
this
.
token
.
align
[
i
]
}
);
}
header
+=
this
.
renderer
.
tablerow
(
cell
);
for
(
i
=
0
;
i
<
this
.
token
.
cells
.
length
;
i
++
)
{
row
=
this
.
token
.
cells
[
i
];
cell
=
''
;
for
(
j
=
0
;
j
<
row
.
length
;
j
++
)
{
cell
+=
this
.
renderer
.
tablecell
(
this
.
inline
.
output
(
row
[
j
]),
{
header
:
false
,
align
:
this
.
token
.
align
[
j
]
}
);
}
body
+=
this
.
renderer
.
tablerow
(
cell
);
}
return
this
.
renderer
.
table
(
header
,
body
);
}
case
'blockquote_start'
:
{
body
=
''
;
while
(
this
.
next
().
type
!==
'blockquote_end'
)
{
body
+=
this
.
tok
();
}
return
this
.
renderer
.
blockquote
(
body
);
}
case
'list_start'
:
{
body
=
''
;
var
ordered
=
this
.
token
.
ordered
,
start
=
this
.
token
.
start
;
while
(
this
.
next
().
type
!==
'list_end'
)
{
body
+=
this
.
tok
();
}
return
this
.
renderer
.
list
(
body
,
ordered
,
start
);
}
case
'list_item_start'
:
{
body
=
''
;
var
loose
=
this
.
token
.
loose
;
if
(
this
.
token
.
task
)
{
body
+=
this
.
renderer
.
checkbox
(
this
.
token
.
checked
);
}
while
(
this
.
next
().
type
!==
'list_item_end'
)
{
body
+=
!
loose
&&
this
.
token
.
type
===
'text'
?
this
.
parseText
()
:
this
.
tok
();
}
return
this
.
renderer
.
listitem
(
body
);
}
case
'html'
:
{
// TODO parse inline content if parameter markdown=1
return
this
.
renderer
.
html
(
this
.
token
.
text
);
}
case
'paragraph'
:
{
return
this
.
renderer
.
paragraph
(
this
.
inline
.
output
(
this
.
token
.
text
));
}
case
'text'
:
{
return
this
.
renderer
.
paragraph
(
this
.
parseText
());
}
}
};
/**
* Helpers
*/
function
escape
(
html
,
encode
)
{
return
html
.
replace
(
!
encode
?
/&
(?!
#
?\w
+;
)
/g
:
/&/g
,
'&'
)
.
replace
(
/</g
,
'<'
)
.
replace
(
/>/g
,
'>'
)
.
replace
(
/"/g
,
'"'
)
.
replace
(
/'/g
,
'''
);
}
function
unescape
(
html
)
{
// explicitly match decimal, hex, and named HTML entities
return
html
.
replace
(
/&
(
#
(?:\d
+
)
|
(?:
#x
[
0-9A-Fa-f
]
+
)
|
(?:\w
+
))
;
?
/ig
,
function
(
_
,
n
)
{
n
=
n
.
toLowerCase
();
if
(
n
===
'colon'
)
return
':'
;
if
(
n
.
charAt
(
0
)
===
'#'
)
{
return
n
.
charAt
(
1
)
===
'x'
?
String
.
fromCharCode
(
parseInt
(
n
.
substring
(
2
),
16
))
:
String
.
fromCharCode
(
+
n
.
substring
(
1
));
}
return
''
;
});
}
function
edit
(
regex
,
opt
)
{
regex
=
regex
.
source
||
regex
;
opt
=
opt
||
''
;
return
{
replace
:
function
(
name
,
val
)
{
val
=
val
.
source
||
val
;
val
=
val
.
replace
(
/
(
^|
[^\[])\^
/g
,
'$1'
);
regex
=
regex
.
replace
(
name
,
val
);
return
this
;
},
getRegex
:
function
()
{
return
new
RegExp
(
regex
,
opt
);
}
};
}
function
resolveUrl
(
base
,
href
)
{
if
(
!
baseUrls
[
' '
+
base
])
{
// we can ignore everything in base after the last slash of its path component,
// but we might need to add _that_
// https://tools.ietf.org/html/rfc3986#section-3
if
(
/^
[^
:
]
+:
\/
*
[^/]
*$/
.
test
(
base
))
{
baseUrls
[
' '
+
base
]
=
base
+
'/'
;
}
else
{
baseUrls
[
' '
+
base
]
=
rtrim
(
base
,
'/'
,
true
);
}
}
base
=
baseUrls
[
' '
+
base
];
if
(
href
.
slice
(
0
,
2
)
===
'//'
)
{
return
base
.
replace
(
/:
[\s\S]
*/
,
':'
)
+
href
;
}
else
if
(
href
.
charAt
(
0
)
===
'/'
)
{
return
base
.
replace
(
/
(
:
\/
*
[^/]
*
)[\s\S]
*/
,
'$1'
)
+
href
;
}
else
{
return
base
+
href
;
}
}
var
baseUrls
=
{};
var
originIndependentUrl
=
/^$|^
[
a-z
][
a-z0-9+.-
]
*:|^
[
?#
]
/i
;
function
noop
()
{}
noop
.
exec
=
noop
;
function
merge
(
obj
)
{
var
i
=
1
,
target
,
key
;
for
(;
i
<
arguments
.
length
;
i
++
)
{
target
=
arguments
[
i
];
for
(
key
in
target
)
{
if
(
Object
.
prototype
.
hasOwnProperty
.
call
(
target
,
key
))
{
obj
[
key
]
=
target
[
key
];
}
}
}
return
obj
;
}
function
splitCells
(
tableRow
,
count
)
{
// ensure that every cell-delimiting pipe has a space
// before it to distinguish it from an escaped pipe
var
row
=
tableRow
.
replace
(
/
\|
/g
,
function
(
match
,
offset
,
str
)
{
var
escaped
=
false
,
curr
=
offset
;
while
(
--
curr
>=
0
&&
str
[
curr
]
===
'
\
\'
) escaped = !escaped;
if (escaped) {
// odd number of slashes means | is escaped
// so we leave it alone
return '
|
';
} else {
// add space before unescaped |
return '
|
';
}
}),
cells = row.split(/
\
|/),
i = 0;
if (cells.length > count) {
cells.splice(count);
} else {
while (cells.length < count) cells.push('');
}
for (; i < cells.length; i++) {
// leading or trailing whitespace is ignored per the gfm spec
cells[i] = cells[i].trim().replace(/
\\\
|/g, '
|
');
}
return cells;
}
// Remove trailing '
c
's. Equivalent to str.replace(/c*$/, '').
// /c*$/ is vulnerable to REDOS.
// invert: Remove suffix of non-c chars instead. Default falsey.
function rtrim(str, c, invert) {
if (str.length === 0) {
return '';
}
// Length of suffix matching the invert condition.
var suffLen = 0;
// Step left until we fail to match the invert condition.
while (suffLen < str.length) {
var currChar = str.charAt(str.length - suffLen - 1);
if (currChar === c && !invert) {
suffLen++;
} else if (currChar !== c && invert) {
suffLen++;
} else {
break;
}
}
return str.substr(0, str.length - suffLen);
}
/**
* Marked
*/
function marked(src, opt, callback) {
// throw error in case of non string input
if (typeof src === '
undefined
' || src === null) {
throw new Error('
marked
():
input
parameter
is
undefined
or
null
');
}
if (typeof src !== '
string
') {
throw new Error('
marked
():
input
parameter
is
of
type
'
+ Object.prototype.toString.call(src) + '
,
string
expected
');
}
if (callback || typeof opt === '
function
') {
if (!callback) {
callback = opt;
opt = null;
}
opt = merge({}, marked.defaults, opt || {});
var highlight = opt.highlight,
tokens,
pending,
i = 0;
try {
tokens = Lexer.lex(src, opt)
} catch (e) {
return callback(e);
}
pending = tokens.length;
var done = function(err) {
if (err) {
opt.highlight = highlight;
return callback(err);
}
var out;
try {
out = Parser.parse(tokens, opt);
} catch (e) {
err = e;
}
opt.highlight = highlight;
return err
? callback(err)
: callback(null, out);
};
if (!highlight || highlight.length < 3) {
return done();
}
delete opt.highlight;
if (!pending) return done();
for (; i < tokens.length; i++) {
(function(token) {
if (token.type !== '
code
') {
return --pending || done();
}
return highlight(token.text, token.lang, function(err, code) {
if (err) return done(err);
if (code == null || code === token.text) {
return --pending || done();
}
token.text = code;
token.escaped = true;
--pending || done();
});
})(tokens[i]);
}
return;
}
try {
if (opt) opt = merge({}, marked.defaults, opt);
return Parser.parse(Lexer.lex(src, opt), opt);
} catch (e) {
e.message += '
\
nPlease
report
this
to
https
:
//github.com/markedjs/marked.';
if
((
opt
||
marked
.
defaults
).
silent
)
{
return
'<p>An error occurred:</p><pre>'
+
escape
(
e
.
message
+
''
,
true
)
+
'</pre>'
;
}
throw
e
;
}
}
/**
* Options
*/
marked
.
options
=
marked
.
setOptions
=
function
(
opt
)
{
merge
(
marked
.
defaults
,
opt
);
return
marked
;
};
marked
.
getDefaults
=
function
()
{
return
{
baseUrl
:
null
,
breaks
:
false
,
gfm
:
true
,
headerIds
:
true
,
headerPrefix
:
''
,
highlight
:
null
,
langPrefix
:
'language-'
,
mangle
:
true
,
pedantic
:
false
,
renderer
:
new
Renderer
(),
sanitize
:
false
,
sanitizer
:
null
,
silent
:
false
,
smartLists
:
false
,
smartypants
:
false
,
tables
:
true
,
xhtml
:
false
};
}
marked
.
defaults
=
marked
.
getDefaults
();
/**
* Expose
*/
marked
.
Parser
=
Parser
;
marked
.
parser
=
Parser
.
parse
;
marked
.
Renderer
=
Renderer
;
marked
.
TextRenderer
=
TextRenderer
;
marked
.
Lexer
=
Lexer
;
marked
.
lexer
=
Lexer
.
lex
;
marked
.
InlineLexer
=
InlineLexer
;
marked
.
inlineLexer
=
InlineLexer
.
output
;
marked
.
parse
=
marked
;
if
(
typeof
module
!==
'undefined'
&&
typeof
exports
===
'object'
)
{
module
.
exports
=
marked
;
}
else
if
(
typeof
define
===
'function'
&&
define
.
amd
)
{
define
(
function
()
{
return
marked
;
});
}
else
{
root
.
marked
=
marked
;
}
})(
this
||
(
typeof
window
!==
'undefined'
?
window
:
global
));
types/components.d.ts
浏览文件 @
4b60e641
...
...
@@ -12,7 +12,6 @@ declare module 'vue' {
FDragItem
:
typeof
import
(
'./../src/components/FirstUI/fui-drag/f-drag-item.vue'
)[
'default'
]
FIndexListItem
:
typeof
import
(
'./../src/components/FirstUI/fui-index-list/f-index-list-item.vue'
)[
'default'
]
FirstuiAudio
:
typeof
import
(
'./../src/components/FirstUI/fui-parse/firstui-audio.vue'
)[
'default'
]
FirstuiCode
:
typeof
import
(
'./../src/components/FirstUI/fui-parse/firstui-code.vue'
)[
'default'
]
FuiActionsheet
:
typeof
import
(
'./../src/components/FirstUI/fui-actionsheet/fui-actionsheet.vue'
)[
'default'
]
FuiAlert
:
typeof
import
(
'./../src/components/FirstUI/fui-alert/fui-alert.vue'
)[
'default'
]
FuiAnimation
:
typeof
import
(
'./../src/components/FirstUI/fui-animation/fui-animation.vue'
)[
'default'
]
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论