Skip to content

Commit 608ba7c

Browse files
author
MarkedJS bot
committedJan 26, 2021
🗜️ build [skip ci]
1 parent 53c79ee commit 608ba7c

File tree

3 files changed

+20
-11
lines changed

3 files changed

+20
-11
lines changed
 

‎lib/marked.esm.js

+9-5
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ var Tokenizer_1 = class Tokenizer {
403403
};
404404
}
405405

406-
const text = cap[0].replace(/^ {4}/gm, '');
406+
const text = cap[0].replace(/^ {1,4}/gm, '');
407407
return {
408408
type: 'code',
409409
raw: cap[0],
@@ -1031,8 +1031,8 @@ const {
10311031
* Block-Level Grammar
10321032
*/
10331033
const block = {
1034-
newline: /^\n+/,
1035-
code: /^( {4}[^\n]+\n*)+/,
1034+
newline: /^(?: *(?:\n|$))+/,
1035+
code: /^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/,
10361036
fences: /^ {0,3}(`{3,}(?=[^`\n]*\n)|~{3,})([^\n]*)\n(?:|([\s\S]*?)\n)(?: {0,3}\1[~`]* *(?:\n+|$)|$)/,
10371037
hr: /^ {0,3}((?:- *){3,}|(?:_ *){3,}|(?:\* *){3,})(?:\n+|$)/,
10381038
heading: /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,
@@ -1054,7 +1054,7 @@ const block = {
10541054
lheading: /^([^\n]+)\n {0,3}(=+|-+) *(?:\n+|$)/,
10551055
// regex template, placeholders will be replaced according to different paragraph
10561056
// interruption rules of commonmark and the original markdown spec:
1057-
_paragraph: /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html)[^\n]+)*)/,
1057+
_paragraph: /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html| +\n)[^\n]+)*)/,
10581058
text: /^[^\n]+/
10591059
};
10601060

@@ -1486,7 +1486,9 @@ var Lexer_1 = class Lexer {
14861486
* Lexing
14871487
*/
14881488
blockTokens(src, tokens = [], top = true) {
1489-
src = src.replace(/^ +$/gm, '');
1489+
if (this.options.pedantic) {
1490+
src = src.replace(/^ +$/gm, '');
1491+
}
14901492
let token, i, l, lastToken;
14911493

14921494
while (src) {
@@ -1856,6 +1858,8 @@ var Renderer_1 = class Renderer {
18561858
}
18571859
}
18581860

1861+
code = code.replace(/\n$/, '') + '\n';
1862+
18591863
if (!lang) {
18601864
return '<pre><code>'
18611865
+ (escaped ? code : escape$2(code, true))

‎lib/marked.js

+10-5
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@
501501
};
502502
}
503503

504-
var text = cap[0].replace(/^ {4}/gm, '');
504+
var text = cap[0].replace(/^ {1,4}/gm, '');
505505
return {
506506
type: 'code',
507507
raw: cap[0],
@@ -1153,8 +1153,8 @@
11531153
*/
11541154

11551155
var block = {
1156-
newline: /^\n+/,
1157-
code: /^( {4}[^\n]+\n*)+/,
1156+
newline: /^(?: *(?:\n|$))+/,
1157+
code: /^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/,
11581158
fences: /^ {0,3}(`{3,}(?=[^`\n]*\n)|~{3,})([^\n]*)\n(?:|([\s\S]*?)\n)(?: {0,3}\1[~`]* *(?:\n+|$)|$)/,
11591159
hr: /^ {0,3}((?:- *){3,}|(?:_ *){3,}|(?:\* *){3,})(?:\n+|$)/,
11601160
heading: /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,
@@ -1176,7 +1176,7 @@
11761176
lheading: /^([^\n]+)\n {0,3}(=+|-+) *(?:\n+|$)/,
11771177
// regex template, placeholders will be replaced according to different paragraph
11781178
// interruption rules of commonmark and the original markdown spec:
1179-
_paragraph: /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html)[^\n]+)*)/,
1179+
_paragraph: /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html| +\n)[^\n]+)*)/,
11801180
text: /^[^\n]+/
11811181
};
11821182
block._label = /(?!\s*\])(?:\\[\[\]]|[^\[\]])+/;
@@ -1478,7 +1478,10 @@
14781478
top = true;
14791479
}
14801480

1481-
src = src.replace(/^ +$/gm, '');
1481+
if (this.options.pedantic) {
1482+
src = src.replace(/^ +$/gm, '');
1483+
}
1484+
14821485
var token, i, l, lastToken;
14831486

14841487
while (src) {
@@ -1899,6 +1902,8 @@
18991902
}
19001903
}
19011904

1905+
_code = _code.replace(/\n$/, '') + '\n';
1906+
19021907
if (!lang) {
19031908
return '<pre><code>' + (escaped ? _code : escape$1(_code, true)) + '</code></pre>\n';
19041909
}

‎marked.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)
Please sign in to comment.