mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-14 15:03:07 +00:00
Merge branch 'master' into autoPageNumberBrewVariable
This commit is contained in:
@@ -104,6 +104,11 @@ mathParser.functions.toWordsCaps = function (a) {
|
||||
}).join(' ');
|
||||
};
|
||||
|
||||
// Normalize variable names; trim edge spaces and shorten blocks of whitespace to 1 space
|
||||
const normalizeVarNames = (label)=>{
|
||||
return label.trim().replace(/\s+/g, ' ');
|
||||
};
|
||||
|
||||
//Processes the markdown within an HTML block if it's just a class-wrapper
|
||||
renderer.html = function (token) {
|
||||
let html = token.text;
|
||||
@@ -435,7 +440,7 @@ const forcedParagraphBreaks = {
|
||||
}
|
||||
},
|
||||
renderer(token) {
|
||||
return `<br>\n`.repeat(token.length);
|
||||
return `<div class='blank'></div>\n`.repeat(token.length);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -553,7 +558,7 @@ const replaceVar = function(input, hoist=false, allowUnresolved=false) {
|
||||
const match = regex.exec(input);
|
||||
|
||||
const prefix = match[1];
|
||||
const label = match[2];
|
||||
const label = normalizeVarNames(match[2]); // Ensure the label name is normalized as it should be in the var stack.
|
||||
|
||||
//v=====--------------------< HANDLE MATH >-------------------=====v//
|
||||
const mathRegex = /[a-z]+\(|[+\-*/^(),]/g;
|
||||
@@ -708,8 +713,8 @@ function MarkedVariables() {
|
||||
});
|
||||
}
|
||||
if(match[3]) { // Block Definition
|
||||
const label = match[4] ? match[4].trim().replace(/\s+/g, ' ') : null; // Trim edge spaces and shorten blocks of whitespace to 1 space
|
||||
const content = match[5] ? match[5].trim().replace(/[ \t]+/g, ' ') : null; // Trim edge spaces and shorten blocks of whitespace to 1 space
|
||||
const label = match[4] ? normalizeVarNames(match[4]) : null;
|
||||
const content = match[5] ? match[5].trim().replace(/[ \t]+/g, ' ') : null; // Normalize text content (except newlines for block-level content)
|
||||
|
||||
varsQueue.push(
|
||||
{ type : 'varDefBlock',
|
||||
@@ -718,7 +723,7 @@ function MarkedVariables() {
|
||||
});
|
||||
}
|
||||
if(match[6]) { // Block Call
|
||||
const label = match[7] ? match[7].trim().replace(/\s+/g, ' ') : null; // Trim edge spaces and shorten blocks of whitespace to 1 space
|
||||
const label = match[7] ? normalizeVarNames(match[7]) : null;
|
||||
|
||||
varsQueue.push(
|
||||
{ type : 'varCallBlock',
|
||||
@@ -727,7 +732,7 @@ function MarkedVariables() {
|
||||
});
|
||||
}
|
||||
if(match[8]) { // Inline Definition
|
||||
const label = match[10] ? match[10].trim().replace(/\s+/g, ' ') : null; // Trim edge spaces and shorten blocks of whitespace to 1 space
|
||||
const label = match[10] ? normalizeVarNames(match[10]) : null;
|
||||
let content = match[11] || null;
|
||||
|
||||
// In case of nested (), find the correct matching end )
|
||||
@@ -759,7 +764,7 @@ function MarkedVariables() {
|
||||
});
|
||||
}
|
||||
if(match[12]) { // Inline Call
|
||||
const label = match[13] ? match[13].trim().replace(/\s+/g, ' ') : null; // Trim edge spaces and shorten blocks of whitespace to 1 space
|
||||
const label = match[13] ? normalizeVarNames(match[13]) : null;
|
||||
|
||||
varsQueue.push(
|
||||
{ type : 'varCallInline',
|
||||
|
||||
Reference in New Issue
Block a user