0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-29 22:02:46 +00:00

Update to Marked v14

This commit is contained in:
Trevor Buckner
2025-03-05 15:40:14 -05:00
parent 0d4d97c5c5
commit 21f1704626
3 changed files with 16 additions and 12 deletions

View File

@@ -61,7 +61,8 @@ mathParser.functions.signed = function (a) {
};
//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>')){
const openTag = html.substring(0, 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
renderer.paragraph = function(text){
renderer.paragraph = function(token){
let match;
const text = this.parser.parseInline(token.tokens);
if(text.startsWith('<div') || text.startsWith('</div'))
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]}`;
} else
else
return `<p>${text}</p>\n`;
};
//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;
if(href[0] == '#') {
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
renderer.image = function (href, title, text) {
href = cleanUrl(href);
renderer.image = function (token) {
let {href, title, text} = token;
if(href === null)
return text;