mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-06 05:42:40 +00:00
Update to Marked v14
This commit is contained in:
8
package-lock.json
generated
8
package-lock.json
generated
@@ -34,7 +34,7 @@
|
|||||||
"jwt-simple": "^0.5.6",
|
"jwt-simple": "^0.5.6",
|
||||||
"less": "^3.13.1",
|
"less": "^3.13.1",
|
||||||
"lodash": "^4.17.21",
|
"lodash": "^4.17.21",
|
||||||
"marked": "13.0.3",
|
"marked": "14.0.0",
|
||||||
"marked-emoji": "^2.0.0",
|
"marked-emoji": "^2.0.0",
|
||||||
"marked-extended-tables": "^2.0.0",
|
"marked-extended-tables": "^2.0.0",
|
||||||
"marked-gfm-heading-id": "^4.0.1",
|
"marked-gfm-heading-id": "^4.0.1",
|
||||||
@@ -9840,9 +9840,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/marked": {
|
"node_modules/marked": {
|
||||||
"version": "13.0.3",
|
"version": "14.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/marked/-/marked-13.0.3.tgz",
|
"resolved": "https://registry.npmjs.org/marked/-/marked-14.0.0.tgz",
|
||||||
"integrity": "sha512-rqRix3/TWzE9rIoFGIn8JmsVfhiuC8VIQ8IdX5TfzmeBucdY05/0UlzKaw0eVtpcN/OdVFpBk7CjKGo9iHJ/zA==",
|
"integrity": "sha512-uIj4+faQ+MgHgwUW1l2PsPglZLOLOT1uErt06dAPtx2kjteLAkbsd/0FiYg/MGS+i7ZKLb7w2WClxHkzOOuryQ==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"bin": {
|
"bin": {
|
||||||
"marked": "bin/marked.js"
|
"marked": "bin/marked.js"
|
||||||
|
|||||||
@@ -108,7 +108,7 @@
|
|||||||
"jwt-simple": "^0.5.6",
|
"jwt-simple": "^0.5.6",
|
||||||
"less": "^3.13.1",
|
"less": "^3.13.1",
|
||||||
"lodash": "^4.17.21",
|
"lodash": "^4.17.21",
|
||||||
"marked": "13.0.3",
|
"marked": "14.0.0",
|
||||||
"marked-emoji": "^2.0.0",
|
"marked-emoji": "^2.0.0",
|
||||||
"marked-extended-tables": "^2.0.0",
|
"marked-extended-tables": "^2.0.0",
|
||||||
"marked-gfm-heading-id": "^4.0.1",
|
"marked-gfm-heading-id": "^4.0.1",
|
||||||
|
|||||||
@@ -61,7 +61,8 @@ mathParser.functions.signed = function (a) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
//Processes the markdown within an HTML block if it's just a class-wrapper
|
//Processes the markdown within an HTML block if it's just a class-wrapper
|
||||||
renderer.html = function (html) {
|
renderer.html = function (token) {
|
||||||
|
let html = token.text;
|
||||||
if(_.startsWith(_.trim(html), '<div') && _.endsWith(_.trim(html), '</div>')){
|
if(_.startsWith(_.trim(html), '<div') && _.endsWith(_.trim(html), '</div>')){
|
||||||
const openTag = html.substring(0, html.indexOf('>')+1);
|
const openTag = html.substring(0, html.indexOf('>')+1);
|
||||||
html = html.substring(html.indexOf('>')+1);
|
html = html.substring(html.indexOf('>')+1);
|
||||||
@@ -72,18 +73,21 @@ renderer.html = function (html) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Don't wrap {{ Spans alone on a line, or {{ Divs in <p> tags
|
// Don't wrap {{ Spans alone on a line, or {{ Divs in <p> tags
|
||||||
renderer.paragraph = function(text){
|
renderer.paragraph = function(token){
|
||||||
let match;
|
let match;
|
||||||
|
const text = this.parser.parseInline(token.tokens);
|
||||||
if(text.startsWith('<div') || text.startsWith('</div'))
|
if(text.startsWith('<div') || text.startsWith('</div'))
|
||||||
return `${text}`;
|
return `${text}`;
|
||||||
else if(match = text.match(/(^|^.*?\n)<span class="inline-block(.*?<\/span>)$/)) {
|
else if(match = text.match(/(^|^.*?\n)<span class="inline-block(.*?<\/span>)$/))
|
||||||
return `${match[1].trim() ? `<p>${match[1]}</p>` : ''}<span class="inline-block${match[2]}`;
|
return `${match[1].trim() ? `<p>${match[1]}</p>` : ''}<span class="inline-block${match[2]}`;
|
||||||
} else
|
else
|
||||||
return `<p>${text}</p>\n`;
|
return `<p>${text}</p>\n`;
|
||||||
};
|
};
|
||||||
|
|
||||||
//Fix local links in the Preview iFrame to link inside the frame
|
//Fix local links in the Preview iFrame to link inside the frame
|
||||||
renderer.link = function (href, title, text) {
|
renderer.link = function (token) {
|
||||||
|
let {href, title, tokens} = token;
|
||||||
|
const text = this.parser.parseInline(tokens)
|
||||||
let self = false;
|
let self = false;
|
||||||
if(href[0] == '#') {
|
if(href[0] == '#') {
|
||||||
self = true;
|
self = true;
|
||||||
@@ -105,8 +109,8 @@ renderer.link = function (href, title, text) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Expose `src` attribute as `--HB_src` to make the URL accessible via CSS
|
// Expose `src` attribute as `--HB_src` to make the URL accessible via CSS
|
||||||
renderer.image = function (href, title, text) {
|
renderer.image = function (token) {
|
||||||
href = cleanUrl(href);
|
let {href, title, text} = token;
|
||||||
if(href === null)
|
if(href === null)
|
||||||
return text;
|
return text;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user