mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-07 03:22:38 +00:00
Merge pull request #1627 from naturalcrit/Marked.jsToV3.02
Make Markdown extensions work with Marked.js 3
This commit is contained in:
16
package-lock.json
generated
16
package-lock.json
generated
@@ -27,7 +27,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": "2.1.3",
|
"marked": "3.0.2",
|
||||||
"markedLegacy": "npm:marked@^0.3.19",
|
"markedLegacy": "npm:marked@^0.3.19",
|
||||||
"moment": "^2.29.1",
|
"moment": "^2.29.1",
|
||||||
"mongoose": "^5.13.7",
|
"mongoose": "^5.13.7",
|
||||||
@@ -5974,14 +5974,14 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/marked": {
|
"node_modules/marked": {
|
||||||
"version": "2.1.3",
|
"version": "3.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/marked/-/marked-2.1.3.tgz",
|
"resolved": "https://registry.npmjs.org/marked/-/marked-3.0.2.tgz",
|
||||||
"integrity": "sha512-/Q+7MGzaETqifOMWYEA7HVMaZb4XbcRfaOzcSsHZEith83KGlvaSG33u0SKu89Mj5h+T8V2hM+8O45Qc5XTgwA==",
|
"integrity": "sha512-TMJQQ79Z0e3rJYazY0tIoMsFzteUGw9fB3FD+gzuIT3zLuG9L9ckIvUfF51apdJkcqc208jJN2KbtPbOvXtbjA==",
|
||||||
"bin": {
|
"bin": {
|
||||||
"marked": "bin/marked"
|
"marked": "bin/marked"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">= 10"
|
"node": ">= 12"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/markedLegacy": {
|
"node_modules/markedLegacy": {
|
||||||
@@ -14059,9 +14059,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"marked": {
|
"marked": {
|
||||||
"version": "2.1.3",
|
"version": "3.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/marked/-/marked-2.1.3.tgz",
|
"resolved": "https://registry.npmjs.org/marked/-/marked-3.0.2.tgz",
|
||||||
"integrity": "sha512-/Q+7MGzaETqifOMWYEA7HVMaZb4XbcRfaOzcSsHZEith83KGlvaSG33u0SKu89Mj5h+T8V2hM+8O45Qc5XTgwA=="
|
"integrity": "sha512-TMJQQ79Z0e3rJYazY0tIoMsFzteUGw9fB3FD+gzuIT3zLuG9L9ckIvUfF51apdJkcqc208jJN2KbtPbOvXtbjA=="
|
||||||
},
|
},
|
||||||
"markedLegacy": {
|
"markedLegacy": {
|
||||||
"version": "npm:marked@0.3.19",
|
"version": "npm:marked@0.3.19",
|
||||||
|
|||||||
@@ -58,7 +58,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": "2.1.3",
|
"marked": "3.0.2",
|
||||||
"markedLegacy": "npm:marked@^0.3.19",
|
"markedLegacy": "npm:marked@^0.3.19",
|
||||||
"moment": "^2.29.1",
|
"moment": "^2.29.1",
|
||||||
"mongoose": "^5.13.7",
|
"mongoose": "^5.13.7",
|
||||||
|
|||||||
@@ -65,13 +65,13 @@ const mustacheSpans = {
|
|||||||
raw : raw, // Text to consume from the source
|
raw : raw, // Text to consume from the source
|
||||||
text : text, // Additional custom properties
|
text : text, // Additional custom properties
|
||||||
tags : tags,
|
tags : tags,
|
||||||
tokens : this.inlineTokens(text) // inlineTokens to process **bold**, *italics*, etc.
|
tokens : this.lexer.inlineTokens(text) // inlineTokens to process **bold**, *italics*, etc.
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
renderer(token) {
|
renderer(token) {
|
||||||
return `<span class="inline-block${token.tags}>${this.parseInline(token.tokens)}</span>`; // parseInline to turn child tokens into HTML
|
return `<span class="inline-block${token.tags}>${this.parser.parseInline(token.tokens)}</span>`; // parseInline to turn child tokens into HTML
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -114,13 +114,13 @@ const mustacheDivs = {
|
|||||||
raw : raw, // Text to consume from the source
|
raw : raw, // Text to consume from the source
|
||||||
text : text, // Additional custom properties
|
text : text, // Additional custom properties
|
||||||
tags : tags,
|
tags : tags,
|
||||||
tokens : this.inline(this.blockTokens(text))
|
tokens : this.lexer.blockTokens(text)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
renderer(token) {
|
renderer(token) {
|
||||||
return `<div class="block${token.tags}>${this.parse(token.tokens)}</div>`; // parseInline to turn child tokens into HTML
|
return `<div class="block${token.tags}>${this.parser.parse(token.tokens)}</div>`; // parseInline to turn child tokens into HTML
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -149,7 +149,7 @@ const mustacheInjectInline = {
|
|||||||
},
|
},
|
||||||
renderer(token) {
|
renderer(token) {
|
||||||
token.type = token.originalType;
|
token.type = token.originalType;
|
||||||
const text = this.parseInline([token]);
|
const text = this.parser.parseInline([token]);
|
||||||
const openingTag = /(<[^\s<>]+)([^\n<>]*>.*)/s.exec(text);
|
const openingTag = /(<[^\s<>]+)([^\n<>]*>.*)/s.exec(text);
|
||||||
if(openingTag) {
|
if(openingTag) {
|
||||||
return `${openingTag[1]} class="${token.tags}${openingTag[2]}`;
|
return `${openingTag[1]} class="${token.tags}${openingTag[2]}`;
|
||||||
@@ -182,7 +182,7 @@ const mustacheInjectBlock = {
|
|||||||
},
|
},
|
||||||
renderer(token) {
|
renderer(token) {
|
||||||
token.type = token.originalType;
|
token.type = token.originalType;
|
||||||
const text = this.parse([token]);
|
const text = this.parser.parse([token]);
|
||||||
const openingTag = /(<[^\s<>]+)([^\n<>]*>.*)/s.exec(text);
|
const openingTag = /(<[^\s<>]+)([^\n<>]*>.*)/s.exec(text);
|
||||||
if(openingTag) {
|
if(openingTag) {
|
||||||
return `${openingTag[1]} class="${token.tags}${openingTag[2]}`;
|
return `${openingTag[1]} class="${token.tags}${openingTag[2]}`;
|
||||||
@@ -211,8 +211,8 @@ const definitionLists = {
|
|||||||
const definitions = [];
|
const definitions = [];
|
||||||
while (match = regex.exec(src)) {
|
while (match = regex.exec(src)) {
|
||||||
definitions.push({
|
definitions.push({
|
||||||
dt : this.inlineTokens(match[1].trim()),
|
dt : this.lexer.inlineTokens(match[1].trim()),
|
||||||
dd : this.inlineTokens(match[2].trim())
|
dd : this.lexer.inlineTokens(match[2].trim())
|
||||||
});
|
});
|
||||||
endIndex = regex.lastIndex;
|
endIndex = regex.lastIndex;
|
||||||
}
|
}
|
||||||
@@ -227,8 +227,8 @@ const definitionLists = {
|
|||||||
renderer(token) {
|
renderer(token) {
|
||||||
return `<dl>
|
return `<dl>
|
||||||
${token.definitions.reduce((html, def)=>{
|
${token.definitions.reduce((html, def)=>{
|
||||||
return `${html}<dt>${this.parseInline(def.dt)}</dt>`
|
return `${html}<dt>${this.parser.parseInline(def.dt)}</dt>`
|
||||||
+ `<dd>${this.parseInline(def.dd)}</dd>\n`;
|
+ `<dd>${this.parser.parseInline(def.dd)}</dd>\n`;
|
||||||
}, '')}
|
}, '')}
|
||||||
</dl>`;
|
</dl>`;
|
||||||
}
|
}
|
||||||
@@ -302,7 +302,7 @@ const spanTable = {
|
|||||||
row = item.header[j];
|
row = item.header[j];
|
||||||
for (k = 0; k < row.length; k++) {
|
for (k = 0; k < row.length; k++) {
|
||||||
row[k].tokens = [];
|
row[k].tokens = [];
|
||||||
this.inlineTokens(row[k].text, row[k].tokens);
|
this.lexer.inlineTokens(row[k].text, row[k].tokens);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -312,7 +312,7 @@ const spanTable = {
|
|||||||
row = item.rows[j];
|
row = item.rows[j];
|
||||||
for (k = 0; k < row.length; k++) {
|
for (k = 0; k < row.length; k++) {
|
||||||
row[k].tokens = [];
|
row[k].tokens = [];
|
||||||
this.inlineTokens(row[k].text, row[k].tokens);
|
this.lexer.inlineTokens(row[k].text, row[k].tokens);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return item;
|
return item;
|
||||||
@@ -329,7 +329,7 @@ const spanTable = {
|
|||||||
output += `<tr>`;
|
output += `<tr>`;
|
||||||
for (j = 0; j < row.length; j++) {
|
for (j = 0; j < row.length; j++) {
|
||||||
cell = row[j];
|
cell = row[j];
|
||||||
text = this.parseInline(cell.tokens);
|
text = this.parser.parseInline(cell.tokens);
|
||||||
output += getTableCell(text, cell, 'th', token.align[col]);
|
output += getTableCell(text, cell, 'th', token.align[col]);
|
||||||
col += cell.colspan;
|
col += cell.colspan;
|
||||||
}
|
}
|
||||||
@@ -344,7 +344,7 @@ const spanTable = {
|
|||||||
output += `<tr>`;
|
output += `<tr>`;
|
||||||
for (j = 0; j < row.length; j++) {
|
for (j = 0; j < row.length; j++) {
|
||||||
cell = row[j];
|
cell = row[j];
|
||||||
text = this.parseInline(cell.tokens);
|
text = this.parser.parseInline(cell.tokens);
|
||||||
output += getTableCell(text, cell, 'td', token.align[col]);
|
output += getTableCell(text, cell, 'td', token.align[col]);
|
||||||
col += cell.colspan;
|
col += cell.colspan;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user