mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-06 14:22:52 +00:00
Somehow this change did not get commited or pushed.
This swaps the if block for an optional chaining
This commit is contained in:
@@ -186,14 +186,12 @@ const BrewRenderer = (props)=>{
|
|||||||
} else {
|
} else {
|
||||||
if(pageText.startsWith('\\page')) {
|
if(pageText.startsWith('\\page')) {
|
||||||
const firstLineTokens = Markdown.marked.lexer(pageText.split('\n', 1)[0])[0].tokens;
|
const firstLineTokens = Markdown.marked.lexer(pageText.split('\n', 1)[0])[0].tokens;
|
||||||
if(firstLineTokens) { // Catch invalid/empty mustache blocks
|
const injectedTags = firstLineTokens?.find((obj)=>obj.injectedTags !== undefined)?.injectedTags;
|
||||||
const injectedTags = firstLineTokens.find((obj)=>obj.injectedTags !== undefined)?.injectedTags;
|
if(injectedTags) {
|
||||||
if(injectedTags) {
|
styles = { ...styles, ...injectedTags.styles };
|
||||||
styles = { ...styles, ...injectedTags.styles };
|
styles = _.mapKeys(styles, (v, k)=>k.startsWith('--') ? k : _.camelCase(k)); // Convert CSS to camelCase for React
|
||||||
styles = _.mapKeys(styles, (v, k)=>k.startsWith('--') ? k : _.camelCase(k)); // Convert CSS to camelCase for React
|
classes = [classes, injectedTags.classes].join(' ').trim();
|
||||||
classes = [classes, injectedTags.classes].join(' ').trim();
|
attributes = injectedTags.attributes;
|
||||||
attributes = injectedTags.attributes;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
pageText = pageText.includes('\n') ? pageText.substring(pageText.indexOf('\n') + 1) : ''; // Remove the \page line
|
pageText = pageText.includes('\n') ? pageText.substring(pageText.indexOf('\n') + 1) : ''; // Remove the \page line
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user