🗜️ build [skip ci]
This commit is contained in:
parent
a9696e2898
commit
41990a5364
@ -1,6 +1,6 @@
|
||||
/**
|
||||
* marked - a markdown parser
|
||||
* Copyright (c) 2011-2021, Christopher Jeffrey. (MIT Licensed)
|
||||
* Copyright (c) 2011-2022, Christopher Jeffrey. (MIT Licensed)
|
||||
* https://github.com/markedjs/marked
|
||||
*/
|
||||
|
||||
@ -26,6 +26,9 @@ function _defineProperties(target, props) {
|
||||
function _createClass(Constructor, protoProps, staticProps) {
|
||||
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
||||
if (staticProps) _defineProperties(Constructor, staticProps);
|
||||
Object.defineProperty(Constructor, "prototype", {
|
||||
writable: false
|
||||
});
|
||||
return Constructor;
|
||||
}
|
||||
|
||||
@ -432,18 +435,12 @@ var Tokenizer = /*#__PURE__*/function () {
|
||||
_proto.space = function space(src) {
|
||||
var cap = this.rules.block.newline.exec(src);
|
||||
|
||||
if (cap) {
|
||||
if (cap[0].length > 1) {
|
||||
if (cap && cap[0].length > 0) {
|
||||
return {
|
||||
type: 'space',
|
||||
raw: cap[0]
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
raw: '\n'
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
_proto.code = function code(src) {
|
||||
@ -667,10 +664,30 @@ var Tokenizer = /*#__PURE__*/function () {
|
||||
for (i = 0; i < l; i++) {
|
||||
this.lexer.state.top = false;
|
||||
list.items[i].tokens = this.lexer.blockTokens(list.items[i].text, []);
|
||||
|
||||
if (!list.loose && list.items[i].tokens.some(function (t) {
|
||||
var spacers = list.items[i].tokens.filter(function (t) {
|
||||
return t.type === 'space';
|
||||
})) {
|
||||
});
|
||||
var hasMultipleLineBreaks = spacers.every(function (t) {
|
||||
var chars = t.raw.split('');
|
||||
var lineBreaks = 0;
|
||||
|
||||
for (var _iterator = _createForOfIteratorHelperLoose(chars), _step; !(_step = _iterator()).done;) {
|
||||
var _char = _step.value;
|
||||
|
||||
if (_char === '\n') {
|
||||
lineBreaks += 1;
|
||||
}
|
||||
|
||||
if (lineBreaks > 1) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
if (!list.loose && spacers.length && hasMultipleLineBreaks) {
|
||||
// Having a single line break doesn't mean a list is loose. A single line break is terminating the last list item
|
||||
list.loose = true;
|
||||
list.items[i].loose = true;
|
||||
}
|
||||
@ -1495,7 +1512,11 @@ var Lexer = /*#__PURE__*/function () {
|
||||
if (token = this.tokenizer.space(src)) {
|
||||
src = src.substring(token.raw.length);
|
||||
|
||||
if (token.type) {
|
||||
if (token.raw.length === 1 && tokens.length > 0) {
|
||||
// if there's a single \n as a spacer, it's terminating the last line,
|
||||
// so move it there so that we don't get unecessary paragraph tags
|
||||
tokens[tokens.length - 1].raw += '\n';
|
||||
} else {
|
||||
tokens.push(token);
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
/**
|
||||
* marked - a markdown parser
|
||||
* Copyright (c) 2011-2021, Christopher Jeffrey. (MIT Licensed)
|
||||
* Copyright (c) 2011-2022, Christopher Jeffrey. (MIT Licensed)
|
||||
* https://github.com/markedjs/marked
|
||||
*/
|
||||
|
||||
@ -355,15 +355,12 @@ class Tokenizer {
|
||||
|
||||
space(src) {
|
||||
const cap = this.rules.block.newline.exec(src);
|
||||
if (cap) {
|
||||
if (cap[0].length > 1) {
|
||||
if (cap && cap[0].length > 0) {
|
||||
return {
|
||||
type: 'space',
|
||||
raw: cap[0]
|
||||
};
|
||||
}
|
||||
return { raw: '\n' };
|
||||
}
|
||||
}
|
||||
|
||||
code(src) {
|
||||
@ -586,7 +583,24 @@ class Tokenizer {
|
||||
for (i = 0; i < l; i++) {
|
||||
this.lexer.state.top = false;
|
||||
list.items[i].tokens = this.lexer.blockTokens(list.items[i].text, []);
|
||||
if (!list.loose && list.items[i].tokens.some(t => t.type === 'space')) {
|
||||
const spacers = list.items[i].tokens.filter(t => t.type === 'space');
|
||||
const hasMultipleLineBreaks = spacers.every(t => {
|
||||
const chars = t.raw.split('');
|
||||
let lineBreaks = 0;
|
||||
for (const char of chars) {
|
||||
if (char === '\n') {
|
||||
lineBreaks += 1;
|
||||
}
|
||||
if (lineBreaks > 1) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
if (!list.loose && spacers.length && hasMultipleLineBreaks) {
|
||||
// Having a single line break doesn't mean a list is loose. A single line break is terminating the last list item
|
||||
list.loose = true;
|
||||
list.items[i].loose = true;
|
||||
}
|
||||
@ -1477,7 +1491,11 @@ class Lexer {
|
||||
// newline
|
||||
if (token = this.tokenizer.space(src)) {
|
||||
src = src.substring(token.raw.length);
|
||||
if (token.type) {
|
||||
if (token.raw.length === 1 && tokens.length > 0) {
|
||||
// if there's a single \n as a spacer, it's terminating the last line,
|
||||
// so move it there so that we don't get unecessary paragraph tags
|
||||
tokens[tokens.length - 1].raw += '\n';
|
||||
} else {
|
||||
tokens.push(token);
|
||||
}
|
||||
continue;
|
||||
|
@ -1,6 +1,6 @@
|
||||
/**
|
||||
* marked - a markdown parser
|
||||
* Copyright (c) 2011-2021, Christopher Jeffrey. (MIT Licensed)
|
||||
* Copyright (c) 2011-2022, Christopher Jeffrey. (MIT Licensed)
|
||||
* https://github.com/markedjs/marked
|
||||
*/
|
||||
|
||||
@ -28,6 +28,9 @@
|
||||
function _createClass(Constructor, protoProps, staticProps) {
|
||||
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
||||
if (staticProps) _defineProperties(Constructor, staticProps);
|
||||
Object.defineProperty(Constructor, "prototype", {
|
||||
writable: false
|
||||
});
|
||||
return Constructor;
|
||||
}
|
||||
|
||||
@ -434,18 +437,12 @@
|
||||
_proto.space = function space(src) {
|
||||
var cap = this.rules.block.newline.exec(src);
|
||||
|
||||
if (cap) {
|
||||
if (cap[0].length > 1) {
|
||||
if (cap && cap[0].length > 0) {
|
||||
return {
|
||||
type: 'space',
|
||||
raw: cap[0]
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
raw: '\n'
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
_proto.code = function code(src) {
|
||||
@ -669,10 +666,30 @@
|
||||
for (i = 0; i < l; i++) {
|
||||
this.lexer.state.top = false;
|
||||
list.items[i].tokens = this.lexer.blockTokens(list.items[i].text, []);
|
||||
|
||||
if (!list.loose && list.items[i].tokens.some(function (t) {
|
||||
var spacers = list.items[i].tokens.filter(function (t) {
|
||||
return t.type === 'space';
|
||||
})) {
|
||||
});
|
||||
var hasMultipleLineBreaks = spacers.every(function (t) {
|
||||
var chars = t.raw.split('');
|
||||
var lineBreaks = 0;
|
||||
|
||||
for (var _iterator = _createForOfIteratorHelperLoose(chars), _step; !(_step = _iterator()).done;) {
|
||||
var _char = _step.value;
|
||||
|
||||
if (_char === '\n') {
|
||||
lineBreaks += 1;
|
||||
}
|
||||
|
||||
if (lineBreaks > 1) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
if (!list.loose && spacers.length && hasMultipleLineBreaks) {
|
||||
// Having a single line break doesn't mean a list is loose. A single line break is terminating the last list item
|
||||
list.loose = true;
|
||||
list.items[i].loose = true;
|
||||
}
|
||||
@ -1497,7 +1514,11 @@
|
||||
if (token = this.tokenizer.space(src)) {
|
||||
src = src.substring(token.raw.length);
|
||||
|
||||
if (token.type) {
|
||||
if (token.raw.length === 1 && tokens.length > 0) {
|
||||
// if there's a single \n as a spacer, it's terminating the last line,
|
||||
// so move it there so that we don't get unecessary paragraph tags
|
||||
tokens[tokens.length - 1].raw += '\n';
|
||||
} else {
|
||||
tokens.push(token);
|
||||
}
|
||||
|
||||
|
4
marked.min.js
vendored
4
marked.min.js
vendored
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user