0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-29 19:52:43 +00:00

Small tweaks to processStyle.

This changes the output on arbitrary outputs to always wrap the value in
quotes instead of only doing so on whitespaced values.
This commit is contained in:
David Bolack
2023-11-11 15:47:27 -06:00
parent fcdaef2445
commit c068aca9ff
2 changed files with 3 additions and 3 deletions

View File

@@ -331,13 +331,13 @@ const processStyleTags = (string)=>{
const id = _.remove(tags, (tag)=>tag.startsWith('#')).map((tag)=>tag.slice(1))[0];
const classes = _.remove(tags, (tag)=>(!tag.includes(':')) && (!tag.includes('=')));
const attributes = _.remove(tags, (tag)=>(!tag.includes(':')) && (!tag.includes('#')));
const attributes = _.remove(tags, (tag)=>(!tag.includes(':')) && (!tag.includes('#'))).map((attr)=>attr.replace(/="?([^"]*)"?/g, '="$1"'));;
const styles = tags.map((tag)=>tag.replace(/:"?([^"]*)"?/g, ':$1;').trim());
return `${classes.join(' ')}" ` +
`${id ? `id="${id}"` : ''} ` +
`${styles.length ? `style="${styles.join(' ')}"` : ''}` +
`${attributes.length ? attributes.join('') : ''}`;
`${attributes.length ? ` ${attributes.join(' ')}` : ''}`;
};
module.exports = {