0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-28 09:12:45 +00:00

Fix class injection

This commit is contained in:
Trevor Buckner
2025-01-29 12:00:36 -05:00
parent 6dfd44e2f1
commit d0a06b5cf7

View File

@@ -176,6 +176,7 @@ const BrewRenderer = (props)=>{
...(!displayOptions.pageShadows ? { boxShadow: 'none' } : {})
// Add more conditions as needed
};
let classes = 'page';
let attributes = {};
if(props.renderer == 'legacy') {
@@ -187,8 +188,9 @@ const BrewRenderer = (props)=>{
const firstLineTokens = Markdown.marked.lexer(pageText.split('\n', 1)[0])[0].tokens;
const injectedTags = firstLineTokens.find((obj)=>obj.injectedTags !== undefined)?.injectedTags;
if(injectedTags) {
styles = { ...styles, ...injectedTags.styles };
styles = _.mapKeys(styles, (v, k)=>_.camelCase(k)); // Convert CSS to camelCase for React
styles = { ...styles, ...injectedTags.styles };
styles = _.mapKeys(styles, (v, k)=>_.camelCase(k)); // Convert CSS to camelCase for React
classes = [classes, injectedTags.classes].join(' ').trim();
attributes = injectedTags.attributes;
}
pageText = pageText.includes('\n') ? pageText.substring(pageText.indexOf('\n') + 1) : ''; // Remove the \page line
@@ -197,7 +199,7 @@ const BrewRenderer = (props)=>{
pageText += `\n\n \n\\column\n `; //Artificial column break at page end to emulate column-fill:auto (until `wide` is used, when column-fill:balance will reappear)
const html = Markdown.render(pageText, index);
return <BrewPage className='page' index={index} key={index} contents={html} style={styles} attributes={attributes} onVisibilityChange={handlePageVisibilityChange} />;
return <BrewPage className={classes} index={index} key={index} contents={html} style={styles} attributes={attributes} onVisibilityChange={handlePageVisibilityChange} />;
}
};