mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-05 23:12:39 +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:
@@ -331,13 +331,13 @@ const processStyleTags = (string)=>{
|
|||||||
|
|
||||||
const id = _.remove(tags, (tag)=>tag.startsWith('#')).map((tag)=>tag.slice(1))[0];
|
const id = _.remove(tags, (tag)=>tag.startsWith('#')).map((tag)=>tag.slice(1))[0];
|
||||||
const classes = _.remove(tags, (tag)=>(!tag.includes(':')) && (!tag.includes('=')));
|
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());
|
const styles = tags.map((tag)=>tag.replace(/:"?([^"]*)"?/g, ':$1;').trim());
|
||||||
|
|
||||||
return `${classes.join(' ')}" ` +
|
return `${classes.join(' ')}" ` +
|
||||||
`${id ? `id="${id}"` : ''} ` +
|
`${id ? `id="${id}"` : ''} ` +
|
||||||
`${styles.length ? `style="${styles.join(' ')}"` : ''}` +
|
`${styles.length ? `style="${styles.join(' ')}"` : ''}` +
|
||||||
`${attributes.length ? attributes.join('') : ''}`;
|
`${attributes.length ? ` ${attributes.join(' ')}` : ''}`;
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
|||||||
@@ -126,7 +126,7 @@ describe('Inline: When using the Inline syntax {{ }}', ()=>{
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('Renders an image with added attributes', function() {
|
it('Renders an image with added attributes', function() {
|
||||||
const source = dedent` {position:absolute,bottom:20px,left:130px,width:220px,a=b and c,d=e}`;
|
const source = dedent` {position:absolute,bottom:20px,left:130px,width:220px,a="b and c",d=e}`;
|
||||||
const rendered = Markdown.render(source).trimReturns();
|
const rendered = Markdown.render(source).trimReturns();
|
||||||
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(`<p><img class=" " style="position:absolute; bottom:20px; left:130px; width:220px;" a="b and c" d="e" src="https://i.imgur.com/hMna6G0.png" alt="homebrew mug"></p>`);
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(`<p><img class=" " style="position:absolute; bottom:20px; left:130px; width:220px;" a="b and c" d="e" src="https://i.imgur.com/hMna6G0.png" alt="homebrew mug"></p>`);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user