Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
bb0386ed
V
vscode
项目概览
掘金者说
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
bb0386ed
编写于
4月 23, 2019
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
eng - update Marked.js to 0.6.2
上级
3af586c9
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
225 addition
and
109 deletion
+225
-109
src/vs/base/common/marked/cgmanifest.json
src/vs/base/common/marked/cgmanifest.json
+2
-2
src/vs/base/common/marked/marked.js
src/vs/base/common/marked/marked.js
+223
-107
未找到文件。
src/vs/base/common/marked/cgmanifest.json
浏览文件 @
bb0386ed
...
...
@@ -6,11 +6,11 @@
"git"
:
{
"name"
:
"marked"
,
"repositoryUrl"
:
"https://github.com/markedjs/marked"
,
"commitHash"
:
"
78c977bc3a47f9e2fb146477d1ca3dad0cb134e6
"
"commitHash"
:
"
529a8d4e185a8aa561e4d8d2891f8556b5717cd4
"
}
},
"license"
:
"MIT"
,
"version"
:
"0.
5.0
"
"version"
:
"0.
6.2
"
}
],
"version"
:
1
...
...
src/vs/base/common/marked/marked.js
浏览文件 @
bb0386ed
...
...
@@ -23,7 +23,7 @@ var block = {
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
*$
)
/
,
list
:
/^
(
{0,3}
)(
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)
...
...
@@ -31,8 +31,8 @@ var block = {
+
'
|<![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
+
'
|<(?!script|pre|style)([a-z][
\\
w-]*)(?:attribute)*? */?>(?=
[
\\
t]*(?:
\\
n|$)
)[
\\
s
\\
S]*?(?:
\\
n{2,}|$)
'
// (7) open tag
+
'
|</(?!script|pre|style)[a-z][
\\
w-]*
\\
s*>(?=
[
\\
t]*(?:
\\
n|$)
)[
\\
s
\\
S]*?(?:
\\
n{2,}|$)
'
// (7) closing tag
+
'
)
'
,
def
:
/^
{0,3}\[(
label
)\]
: *
\n?
*<
?([^\s
>
]
+
)
>
?(?:(?:
+
\n?
*| *
\n
*
)(
title
))?
*
(?:\n
+|$
)
/
,
table
:
noop
,
...
...
@@ -48,8 +48,8 @@ block.def = edit(block.def)
.
replace
(
'
title
'
,
block
.
_title
)
.
getRegex
();
block
.
bullet
=
/
(?:[
*+-
]
|
\d
+
\.)
/
;
block
.
item
=
/^
(
*
)(
bull
)
[^\n]
*
(?:\n(?!\1
bull
)[^\n]
*
)
*/
;
block
.
bullet
=
/
(?:[
*+-
]
|
\d
{1,9}
\.)
/
;
block
.
item
=
/^
(
*
)(
bull
)
?[^\n]
*
(?:\n(?!\1
bull
?
)[^\n]
*
)
*/
;
block
.
item
=
edit
(
block
.
item
,
'
gm
'
)
.
replace
(
/bull/g
,
block
.
bullet
)
.
getRegex
();
...
...
@@ -95,7 +95,7 @@ block.normal = merge({}, block);
*/
block
.
gfm
=
merge
({},
block
.
normal
,
{
fences
:
/^
*
(
`
{3,}
|~
{3,})[
\.]
*
(\S
+
)?
*
\n([\s\S]
*
?)\n?
*
\1
*
(?:\n
+
|$
)
/
,
fences
:
/^
{0,3}(
`
{3,}
|~
{3,})([^
`
\n]
*
)\n(?:
|
([\s\S]
*
?)\n)(?:
{0,3}\1[
~`
]
* *
(?:\n
+|$
)
|$
)
/
,
paragraph
:
/^/
,
heading
:
/^ *
(
#
{1,6})
+
([^\n]
+
?)
*#* *
(?:\n
+|$
)
/
});
...
...
@@ -235,7 +235,7 @@ Lexer.prototype.token = function(src, top) {
src
=
src
.
substring
(
cap
[
0
].
length
);
this
.
tokens
.
push
({
type
:
'
code
'
,
lang
:
cap
[
2
],
lang
:
cap
[
2
]
?
cap
[
2
].
trim
()
:
cap
[
2
]
,
text
:
cap
[
3
]
||
''
});
continue
;
...
...
@@ -253,7 +253,7 @@ Lexer.prototype.token = function(src, top) {
}
// table no leading pipe (gfm)
if
(
top
&&
(
cap
=
this
.
rules
.
nptable
.
exec
(
src
)
))
{
if
(
cap
=
this
.
rules
.
nptable
.
exec
(
src
))
{
item
=
{
type
:
'
table
'
,
header
:
splitCells
(
cap
[
1
].
replace
(
/^ *| *
\|
*$/g
,
''
)),
...
...
@@ -346,7 +346,7 @@ Lexer.prototype.token = function(src, top) {
// Remove the list item's bullet
// so it is seen as the next token.
space
=
item
.
length
;
item
=
item
.
replace
(
/^ *
([
*+-
]
|
\d
+
\.)
+
/
,
''
);
item
=
item
.
replace
(
/^ *
([
*+-
]
|
\d
+
\.)
*
/
,
''
);
// Outdent whatever the
// list item contains. Hacky.
...
...
@@ -359,9 +359,10 @@ Lexer.prototype.token = function(src, top) {
// Determine whether the next list item belongs here.
// Backpedal if it does not belong in this list.
if
(
this
.
options
.
smartLists
&&
i
!==
l
-
1
)
{
if
(
i
!==
l
-
1
)
{
b
=
block
.
bullet
.
exec
(
cap
[
i
+
1
])[
0
];
if
(
bull
!==
b
&&
!
(
bull
.
length
>
1
&&
b
.
length
>
1
))
{
if
(
bull
.
length
>
1
?
b
.
length
===
1
:
(
b
.
length
>
1
||
(
this
.
options
.
smartLists
&&
b
!==
bull
)))
{
src
=
cap
.
slice
(
i
+
1
).
join
(
'
\n
'
)
+
src
;
i
=
l
-
1
;
}
...
...
@@ -450,12 +451,12 @@ Lexer.prototype.token = function(src, top) {
}
// table (gfm)
if
(
top
&&
(
cap
=
this
.
rules
.
table
.
exec
(
src
)
))
{
if
(
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
'
)
:
[]
cells
:
cap
[
3
]
?
cap
[
3
].
replace
(
/
\n
$/
,
''
).
split
(
'
\n
'
)
:
[]
};
if
(
item
.
header
.
length
===
item
.
align
.
length
)
{
...
...
@@ -544,14 +545,19 @@ var inline = {
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(?!
`
)
/
,
strong
:
/^__
([^\s
_
])
__
(?!
_
)
|^
\*\*([^\s
*
])\*\*(?!\*)
|^__
([^\s][\s\S]
*
?[^\s])
__
(?!
_
)
|^
\*\*([^\s][\s\S]
*
?[^\s])\*\*(?!\*)
/
,
em
:
/^_
([^\s
_
])
_
(?!
_
)
|^
\*([^\s
*"<
\[])\*(?!\*)
|^_
([^\s][\s\S]
*
?[^\s
_
])
_
(?!
_
|
[^\s
punctuation
])
|^_
([^\s
_
][\s\S]
*
?[^\s])
_
(?!
_|
[^\s
punctuation
]
)
|^
\*([^\s
"<
\[][\s\S]
*
?[^\s
*
])\*(?!\*)
|^
\*([^\s
*"<
\[][\s\S]
*
?[^\s])\*(?!\*)
/
,
code
:
/^
(
`+
)
([^
`
]
|
[^
`
][\s\S]
*
?[^
`
])
\1(?!
`
)
/
,
br
:
/^
(
{2,}
|
\\)\n(?!\s
*$
)
/
,
del
:
noop
,
text
:
/^
[\s\S]
+
?(?=[\\
<!
\[
`*
]
|
\b
_|
{2,}\n
|$
)
/
text
:
/^
(
`+|
[^
`
])(?:[\s\S]
*
?(?:(?=[\\
<!
\[
`*
]
|
\b
_|$
)
|
[^
](?=
{2,}\n))
|
(?=
{2,}\n)
)
/
};
// list of punctuation marks from common mark spec
// without ` and ] to workaround Rule 17 (inline code blocks/links)
inline
.
_punctuation
=
'
!"#$%&
\'
()*+,
\\
-./:;<=>?@
\\
[^_{|}~
'
;
inline
.
em
=
edit
(
inline
.
em
).
replace
(
/punctuation/g
,
inline
.
_punctuation
).
getRegex
();
inline
.
_escapes
=
/
\\([
!"#$%&'()*+,
\-
.
/
:;<=>?@
\[\]\\
^_`{|}~
])
/g
;
inline
.
_scheme
=
/
[
a-zA-Z
][
a-zA-Z0-9+.-
]{1,31}
/
;
...
...
@@ -568,8 +574,8 @@ inline.tag = edit(inline.tag)
.
replace
(
'
attribute
'
,
inline
.
_attribute
)
.
getRegex
();
inline
.
_label
=
/
(?:\[[^\[\]]
*
\]
|
\\[\[\]]?
|`
[^
`
]
*`|
[^\[\]\\
])
*
?
/
;
inline
.
_href
=
/
\s
*
(
<
(?:\\[
<>
]?
|
[^\s
<>
\\])
*>|
(?:\\[
()
]?
|
\([^\s\x
00-
\x
1f
\\]
*
\)
|
[^\s\x
00-
\x
1f()
\\])
*
?
)
/
;
inline
.
_label
=
/
(?:\[[^\[\]]
*
\]
|
\\[\[\]]?
|`
[^
`
]
*`|
`
(?!
`
)
|
[^\[\]\\
`
])
*
?
/
;
inline
.
_href
=
/
\s
*
(
<
(?:\\[
<>
]?
|
[^\s
<>
\\])
*>|
[^\s\x
00-
\x
1f
]
*
)
/
;
inline
.
_title
=
/"
(?:\\
"
?
|
[^
"
\\])
*"|'
(?:\\
'
?
|
[^
'
\\])
*'|
\((?:\\\)?
|
[^
)
\\])
*
\)
/
;
inline
.
link
=
edit
(
inline
.
link
)
...
...
@@ -609,24 +615,23 @@ inline.pedantic = merge({}, inline.normal, {
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
(),
_extended_email
:
/
[
A-Za-z0-9._+-
]
+
(
@
)[
a-zA-Z0-9-_
]
+
(?:\.[
a-zA-Z0-9-_
]
*
[
a-zA-Z0-9
])
+
(?![
-_
])
/
,
url
:
/^
((?:
ftp|https
?)
:
\/\/
|www
\.)(?:[
a-zA-Z0-9
\-]
+
\.?)
+
[^\s
<
]
*|^email/
,
_backpedal
:
/
(?:[^
?!.,:;*_~()&
]
+|
\([^
)
]
*
\)
|&
(?![
a-zA-Z0-9
]
+;$
)
|
[
?!.,:;*_~)
]
+
(?!
$
))
+/
,
del
:
/^~+
(?=\S)([\s\S]
*
?\S)
~+/
,
text
:
edit
(
inline
.
text
)
.
replace
(
'
]|
'
,
'
~]|
'
)
.
replace
(
'
|
'
,
'
|https?://|ftp://|www
\\
.|[a-zA-Z0-9.!#$%&
\'
*+/=?^_`{
\\
|}~-]+@|
'
)
.
getRegex
()
text
:
/^
(
`+|
[^
`
])(?:[\s\S]
*
?(?:(?=[\\
<!
\[
`*~
]
|
\b
_|https
?
:
\/\/
|ftp:
\/\/
|www
\.
|$
)
|
[^
](?=
{2,}\n)
|
[^
a-zA-Z0-9.!#$%&'*+
\/
=?_`{
\|
}~-
](?=[
a-zA-Z0-9.!#$%&'*+
\/
=?_`{
\|
}~-
]
+@
))
|
(?=
{2,}\n
|
[
a-zA-Z0-9.!#$%&'*+
\/
=?_`{
\|
}~-
]
+@
))
/
});
inline
.
gfm
.
url
=
edit
(
inline
.
gfm
.
url
,
'
i
'
)
.
replace
(
'
email
'
,
inline
.
gfm
.
_extended_email
)
.
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
()
text
:
edit
(
inline
.
gfm
.
text
).
replace
(
/
\{
2,
\}
/g
,
'
*
'
).
getRegex
()
});
/**
...
...
@@ -687,43 +692,7 @@ InlineLexer.prototype.output = function(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
);
out
+=
escape
(
cap
[
1
]);
continue
;
}
...
...
@@ -734,17 +703,30 @@ InlineLexer.prototype.output = function(src) {
}
else
if
(
this
.
inLink
&&
/^<
\/
a>/i
.
test
(
cap
[
0
]))
{
this
.
inLink
=
false
;
}
if
(
!
this
.
inRawBlock
&&
/^<
(
pre|code|kbd|script
)(\s
|>
)
/i
.
test
(
cap
[
0
]))
{
this
.
inRawBlock
=
true
;
}
else
if
(
this
.
inRawBlock
&&
/^<
\/(
pre|code|kbd|script
)(\s
|>
)
/i
.
test
(
cap
[
0
]))
{
this
.
inRawBlock
=
false
;
}
src
=
src
.
substring
(
cap
[
0
].
length
);
out
+=
this
.
options
.
sanitize
?
this
.
options
.
sanitizer
?
this
.
options
.
sanitizer
(
cap
[
0
])
:
escape
(
cap
[
0
])
:
cap
[
0
]
:
cap
[
0
]
;
continue
;
}
// link
if
(
cap
=
this
.
rules
.
link
.
exec
(
src
))
{
var
lastParenIndex
=
findClosingBracket
(
cap
[
2
],
'
()
'
);
if
(
lastParenIndex
>
-
1
)
{
var
linkLen
=
cap
[
0
].
length
-
(
cap
[
2
].
length
-
lastParenIndex
)
-
(
cap
[
3
]
||
''
).
length
;
cap
[
2
]
=
cap
[
2
].
substring
(
0
,
lastParenIndex
);
cap
[
0
]
=
cap
[
0
].
substring
(
0
,
linkLen
).
trim
();
cap
[
3
]
=
''
;
}
src
=
src
.
substring
(
cap
[
0
].
length
);
this
.
inLink
=
true
;
href
=
cap
[
2
];
...
...
@@ -821,10 +803,51 @@ InlineLexer.prototype.output = function(src) {
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
)))
{
if
(
cap
[
2
]
===
'
@
'
)
{
text
=
escape
(
cap
[
0
]);
href
=
'
mailto:
'
+
text
;
}
else
{
// do extended autolink path validation
do
{
prevCapZero
=
cap
[
0
];
cap
[
0
]
=
this
.
rules
.
_backpedal
.
exec
(
cap
[
0
])[
0
];
}
while
(
prevCapZero
!==
cap
[
0
]);
text
=
escape
(
cap
[
0
]);
if
(
cap
[
1
]
===
'
www.
'
)
{
href
=
'
http://
'
+
text
;
}
else
{
href
=
text
;
}
}
src
=
src
.
substring
(
cap
[
0
].
length
);
out
+=
this
.
renderer
.
link
(
href
,
null
,
text
);
continue
;
}
// text
if
(
cap
=
this
.
rules
.
text
.
exec
(
src
))
{
src
=
src
.
substring
(
cap
[
0
].
length
);
out
+=
this
.
renderer
.
text
(
escape
(
this
.
smartypants
(
cap
[
0
])));
if
(
this
.
inRawBlock
)
{
out
+=
this
.
renderer
.
text
(
cap
[
0
]);
}
else
{
out
+=
this
.
renderer
.
text
(
escape
(
this
.
smartypants
(
cap
[
0
])));
}
continue
;
}
...
...
@@ -838,7 +861,7 @@ InlineLexer.prototype.output = function(src) {
InlineLexer
.
escapes
=
function
(
text
)
{
return
text
?
text
.
replace
(
InlineLexer
.
rules
.
_escapes
,
'
$1
'
)
:
text
;
}
}
;
/**
* Compile Link
...
...
@@ -906,7 +929,8 @@ function Renderer(options) {
this
.
options
=
options
||
marked
.
defaults
;
}
Renderer
.
prototype
.
code
=
function
(
code
,
lang
,
escaped
)
{
Renderer
.
prototype
.
code
=
function
(
code
,
infostring
,
escaped
)
{
var
lang
=
(
infostring
||
''
).
match
(
/
\S
*/
)[
0
];
if
(
this
.
options
.
highlight
)
{
var
out
=
this
.
options
.
highlight
(
code
,
lang
);
if
(
out
!=
null
&&
out
!==
code
)
{
...
...
@@ -937,13 +961,13 @@ Renderer.prototype.html = function(html) {
return
html
;
};
Renderer
.
prototype
.
heading
=
function
(
text
,
level
,
raw
)
{
Renderer
.
prototype
.
heading
=
function
(
text
,
level
,
raw
,
slugger
)
{
if
(
this
.
options
.
headerIds
)
{
return
'
<h
'
+
level
+
'
id="
'
+
this
.
options
.
headerPrefix
+
raw
.
toLowerCase
().
replace
(
/
[^\w]
+/g
,
'
-
'
)
+
slugger
.
slug
(
raw
)
+
'
">
'
+
text
+
'
</h
'
...
...
@@ -974,7 +998,7 @@ Renderer.prototype.checkbox = function(checked) {
+
'
disabled="" type="checkbox"
'
+
(
this
.
options
.
xhtml
?
'
/
'
:
''
)
+
'
>
'
;
}
}
;
Renderer
.
prototype
.
paragraph
=
function
(
text
)
{
return
'
<p>
'
+
text
+
'
</p>
\n
'
;
...
...
@@ -1025,24 +1049,8 @@ Renderer.prototype.del = function(text) {
};
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
)
{
href
=
cleanUrl
(
this
.
options
.
sanitize
,
this
.
options
.
baseUrl
,
href
);
if
(
href
===
null
)
{
return
text
;
}
var
out
=
'
<a href="
'
+
escape
(
href
)
+
'
"
'
;
...
...
@@ -1054,9 +1062,11 @@ Renderer.prototype.link = function(href, title, text) {
};
Renderer
.
prototype
.
image
=
function
(
href
,
title
,
text
)
{
if
(
this
.
options
.
baseUrl
&&
!
originIndependentUrl
.
test
(
href
))
{
href
=
resolveUrl
(
this
.
options
.
baseUrl
,
href
);
href
=
cleanUrl
(
this
.
options
.
sanitize
,
this
.
options
.
baseUrl
,
href
);
if
(
href
===
null
)
{
return
text
;
}
var
out
=
'
<img src="
'
+
href
+
'
" alt="
'
+
text
+
'
"
'
;
if
(
title
)
{
out
+=
'
title="
'
+
title
+
'
"
'
;
...
...
@@ -1084,16 +1094,16 @@ 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
...
...
@@ -1106,6 +1116,7 @@ function Parser(options) {
this
.
options
.
renderer
=
this
.
options
.
renderer
||
new
Renderer
();
this
.
renderer
=
this
.
options
.
renderer
;
this
.
renderer
.
options
=
this
.
options
;
this
.
slugger
=
new
Slugger
();
}
/**
...
...
@@ -1184,7 +1195,8 @@ Parser.prototype.tok = function() {
return
this
.
renderer
.
heading
(
this
.
inline
.
output
(
this
.
token
.
text
),
this
.
token
.
depth
,
unescape
(
this
.
inlineText
.
output
(
this
.
token
.
text
)));
unescape
(
this
.
inlineText
.
output
(
this
.
token
.
text
)),
this
.
slugger
);
}
case
'
code
'
:
{
return
this
.
renderer
.
code
(
this
.
token
.
text
,
...
...
@@ -1247,9 +1259,11 @@ Parser.prototype.tok = function() {
case
'
list_item_start
'
:
{
body
=
''
;
var
loose
=
this
.
token
.
loose
;
var
checked
=
this
.
token
.
checked
;
var
task
=
this
.
token
.
task
;
if
(
this
.
token
.
task
)
{
body
+=
this
.
renderer
.
checkbox
(
this
.
token
.
checked
);
body
+=
this
.
renderer
.
checkbox
(
checked
);
}
while
(
this
.
next
().
type
!==
'
list_item_end
'
)
{
...
...
@@ -1257,8 +1271,7 @@ Parser.prototype.tok = function() {
?
this
.
parseText
()
:
this
.
tok
();
}
return
this
.
renderer
.
listitem
(
body
);
return
this
.
renderer
.
listitem
(
body
,
task
,
checked
);
}
case
'
html
'
:
{
// TODO parse inline content if parameter markdown=1
...
...
@@ -1270,22 +1283,79 @@ Parser.prototype.tok = function() {
case
'
text
'
:
{
return
this
.
renderer
.
paragraph
(
this
.
parseText
());
}
default
:
{
var
errMsg
=
'
Token with "
'
+
this
.
token
.
type
+
'
" type was not found.
'
;
if
(
this
.
options
.
silent
)
{
console
.
log
(
errMsg
);
}
else
{
throw
new
Error
(
errMsg
);
}
}
}
};
/**
* Slugger generates header id
*/
function
Slugger
()
{
this
.
seen
=
{};
}
/**
* Convert string to unique id
*/
Slugger
.
prototype
.
slug
=
function
(
value
)
{
var
slug
=
value
.
toLowerCase
()
.
trim
()
.
replace
(
/
[\u
2000-
\u
206F
\u
2E00-
\u
2E7F
\\
'!"#$%&()*+,.
/
:;<=>?@[
\]
^`{|}~
]
/g
,
''
)
.
replace
(
/
\s
/g
,
'
-
'
);
if
(
this
.
seen
.
hasOwnProperty
(
slug
))
{
var
originalSlug
=
slug
;
do
{
this
.
seen
[
originalSlug
]
++
;
slug
=
originalSlug
+
'
-
'
+
this
.
seen
[
originalSlug
];
}
while
(
this
.
seen
.
hasOwnProperty
(
slug
));
}
this
.
seen
[
slug
]
=
0
;
return
slug
;
};
/**
* Helpers
*/
function
escape
(
html
,
encode
)
{
return
html
.
replace
(
!
encode
?
/&
(?!
#
?\w
+;
)
/g
:
/&/g
,
'
&
'
)
.
replace
(
/</g
,
'
<
'
)
.
replace
(
/>/g
,
'
>
'
)
.
replace
(
/"/g
,
'
"
'
)
.
replace
(
/'/g
,
'
'
'
);
if
(
encode
)
{
if
(
escape
.
escapeTest
.
test
(
html
))
{
return
html
.
replace
(
escape
.
escapeReplace
,
function
(
ch
)
{
return
escape
.
replacements
[
ch
];
});
}
}
else
{
if
(
escape
.
escapeTestNoEncode
.
test
(
html
))
{
return
html
.
replace
(
escape
.
escapeReplaceNoEncode
,
function
(
ch
)
{
return
escape
.
replacements
[
ch
];
});
}
}
return
html
;
}
escape
.
escapeTest
=
/
[
&<>"'
]
/
;
escape
.
escapeReplace
=
/
[
&<>"'
]
/g
;
escape
.
replacements
=
{
'
&
'
:
'
&
'
,
'
<
'
:
'
<
'
,
'
>
'
:
'
>
'
,
'
"
'
:
'
"
'
,
"
'
"
:
'
'
'
};
escape
.
escapeTestNoEncode
=
/
[
<>"'
]
|&
(?!
#
?\w
+;
)
/
;
escape
.
escapeReplaceNoEncode
=
/
[
<>"'
]
|&
(?!
#
?\w
+;
)
/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
)
{
...
...
@@ -1316,6 +1386,30 @@ function edit(regex, opt) {
};
}
function
cleanUrl
(
sanitize
,
base
,
href
)
{
if
(
sanitize
)
{
try
{
var
prot
=
decodeURIComponent
(
unescape
(
href
))
.
replace
(
/
[^\w
:
]
/g
,
''
)
.
toLowerCase
();
}
catch
(
e
)
{
return
null
;
}
if
(
prot
.
indexOf
(
'
javascript:
'
)
===
0
||
prot
.
indexOf
(
'
vbscript:
'
)
===
0
||
prot
.
indexOf
(
'
data:
'
)
===
0
)
{
return
null
;
}
}
if
(
base
&&
!
originIndependentUrl
.
test
(
href
))
{
href
=
resolveUrl
(
base
,
href
);
}
try
{
href
=
encodeURI
(
href
).
replace
(
/%25/g
,
'
%
'
);
}
catch
(
e
)
{
return
null
;
}
return
href
;
}
function
resolveUrl
(
base
,
href
)
{
if
(
!
baseUrls
[
'
'
+
base
])
{
// we can ignore everything in base after the last slash of its path component,
...
...
@@ -1418,6 +1512,26 @@ function rtrim(str, c, invert) {
return
str
.
substr
(
0
,
str
.
length
-
suffLen
);
}
function
findClosingBracket
(
str
,
b
)
{
if
(
str
.
indexOf
(
b
[
1
])
===
-
1
)
{
return
-
1
;
}
var
level
=
0
;
for
(
var
i
=
0
;
i
<
str
.
length
;
i
++
)
{
if
(
str
[
i
]
===
'
\\
'
)
{
i
++
;
}
else
if
(
str
[
i
]
===
b
[
0
])
{
level
++
;
}
else
if
(
str
[
i
]
===
b
[
1
])
{
level
--
;
if
(
level
<
0
)
{
return
i
;
}
}
}
return
-
1
;
}
/**
* Marked
*/
...
...
@@ -1446,7 +1560,7 @@ function marked(src, opt, callback) {
i
=
0
;
try
{
tokens
=
Lexer
.
lex
(
src
,
opt
)
tokens
=
Lexer
.
lex
(
src
,
opt
)
;
}
catch
(
e
)
{
return
callback
(
e
);
}
...
...
@@ -1545,7 +1659,7 @@ marked.getDefaults = function () {
tables
:
true
,
xhtml
:
false
};
}
}
;
marked
.
defaults
=
marked
.
getDefaults
();
...
...
@@ -1565,6 +1679,8 @@ marked.lexer = Lexer.lex;
marked
.
InlineLexer
=
InlineLexer
;
marked
.
inlineLexer
=
InlineLexer
.
output
;
marked
.
Slugger
=
Slugger
;
marked
.
parse
=
marked
;
// BEGIN MONACOCHANGE
...
...
@@ -1582,7 +1698,7 @@ __marked_exports = marked;
// ESM-comment-begin
define
(
function
()
{
return
__marked_exports
;
});
// ESM-comment-end
// ESM-uncomment-begin
// export var marked = __marked_exports;
// export var Parser = __marked_exports.Parser;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录