mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-22 07:27:51 +00:00
lint
This commit is contained in:
@@ -152,7 +152,7 @@ const BrewRenderer = (props)=>{
|
||||
renderedPages.length = 0;
|
||||
|
||||
// Render currently-edited page first so cross-page effects (variables, links) can propagate out first
|
||||
renderedPages[props.currentEditorPage] = renderPage(rawPages[props.currentEditorPage], props.currentEditorPage)
|
||||
renderedPages[props.currentEditorPage] = renderPage(rawPages[props.currentEditorPage], props.currentEditorPage);
|
||||
|
||||
_.forEach(rawPages, (page, index)=>{
|
||||
if((isInView(index) || !renderedPages[index]) && typeof window !== 'undefined'){
|
||||
|
||||
@@ -336,9 +336,9 @@ const replaceVar = function(input, hoist=false, allowUnresolved=false) {
|
||||
const label = match[2];
|
||||
|
||||
//v=====--------------------< HANDLE MATH >-------------------=====v//
|
||||
let mathRegex = /[a-z]+\(|[+\-*/^()]/g;
|
||||
let matches = label.split(mathRegex)
|
||||
let mathVars = matches.filter(match => isNaN(match))?.map((s)=>s.trim()); // Capture any variable names
|
||||
const mathRegex = /[a-z]+\(|[+\-*/^()]/g;
|
||||
const matches = label.split(mathRegex);
|
||||
const mathVars = matches.filter((match)=>isNaN(match))?.map((s)=>s.trim()); // Capture any variable names
|
||||
|
||||
let replacedLabel = label;
|
||||
|
||||
@@ -366,8 +366,8 @@ const replaceVar = function(input, hoist=false, allowUnresolved=false) {
|
||||
const linkRegex = /^([^<\s][^\s]*|<.*?>)(?: ("(?:\\"|[^"])*"|'(?:\\'|[^'])*'|\((?:\\\(|\\\)|[^()])*\)))?$/m;
|
||||
const linkMatch = linkRegex.exec(foundVar.content);
|
||||
|
||||
let href = linkMatch ? linkMatch[1] : null; //TODO: TRIM OFF < > IF PRESENT
|
||||
let title = linkMatch ? linkMatch[2]?.slice(1, -1) : null;
|
||||
const href = linkMatch ? linkMatch[1] : null; //TODO: TRIM OFF < > IF PRESENT
|
||||
const title = linkMatch ? linkMatch[2]?.slice(1, -1) : null;
|
||||
|
||||
if(!prefix[0] && href) // Link
|
||||
return `[${label}](${href}${title ? ` "${title}"` : ''})`;
|
||||
@@ -446,14 +446,14 @@ const processVariableQueue = function() {
|
||||
item.type = 'text';
|
||||
}
|
||||
}
|
||||
varsQueue = varsQueue.filter(item => item.type !== 'resolved'); // Remove any fully-resolved variable definitions
|
||||
varsQueue = varsQueue.filter((item)=>item.type !== 'resolved'); // Remove any fully-resolved variable definitions
|
||||
|
||||
if(finalLoop)
|
||||
break;
|
||||
if(!resolvedOne)
|
||||
finalLoop = true;
|
||||
}
|
||||
varsQueue = varsQueue.filter(item => item.type !== 'varDefBlock');
|
||||
varsQueue = varsQueue.filter((item)=>item.type !== 'varDefBlock');
|
||||
};
|
||||
|
||||
function MarkedVariables() {
|
||||
@@ -467,7 +467,7 @@ function MarkedVariables() {
|
||||
const inlineCallRegex = /[!$]?\[((?!\s*\])(?:\\.|[^\[\]\\])+)\](?!\()/; //Matches 12, [13]
|
||||
|
||||
// Combine regexes and wrap in parens like so: (regex1)|(regex2)|(regex3)|(regex4)
|
||||
let combinedRegex = new RegExp([codeBlockSkip, blockDefRegex, blockCallRegex, inlineDefRegex, inlineCallRegex].map(s => `(${s.source})`).join('|'), 'gm');
|
||||
const combinedRegex = new RegExp([codeBlockSkip, blockDefRegex, blockCallRegex, inlineDefRegex, inlineCallRegex].map((s)=>`(${s.source})`).join('|'), 'gm');
|
||||
|
||||
let lastIndex = 0;
|
||||
let match;
|
||||
@@ -562,7 +562,7 @@ function MarkedVariables() {
|
||||
|
||||
processVariableQueue();
|
||||
|
||||
const output = varsQueue.map(item => item.content).join('');
|
||||
const output = varsQueue.map((item)=>item.content).join('');
|
||||
varsQueue = []; // Must clear varsQueue because custom HTML renderer uses Marked.parse which will preprocess again without clearing the array
|
||||
return output;
|
||||
}
|
||||
@@ -571,7 +571,7 @@ function MarkedVariables() {
|
||||
};
|
||||
//^=====--------------------< Variable Handling >-------------------=====^//
|
||||
|
||||
Marked.use(MarkedVariables())
|
||||
Marked.use(MarkedVariables());
|
||||
Marked.use({ extensions: [mustacheSpans, mustacheDivs, mustacheInjectInline, definitionLists, superSubScripts] });
|
||||
Marked.use(mustacheInjectBlock);
|
||||
Marked.use({ renderer: renderer, tokenizer: tokenizer, mangle: false });
|
||||
|
||||
@@ -136,7 +136,7 @@ describe('Block-level variables', ()=>{
|
||||
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('<p>two</p><p>one</p><p>two</p>'.trimReturns());
|
||||
});
|
||||
|
||||
it("Ignores undefined variables that can't be hoisted", function() {
|
||||
it('Ignores undefined variables that can\'t be hoisted', function() {
|
||||
const source = dedent`
|
||||
$[var](My name is $[first] $[last])
|
||||
|
||||
|
||||
Reference in New Issue
Block a user