diff --git a/shared/naturalcrit/markdown.js b/shared/naturalcrit/markdown.js index 0fd4fdd8f..5b2f47309 100644 --- a/shared/naturalcrit/markdown.js +++ b/shared/naturalcrit/markdown.js @@ -338,13 +338,13 @@ const processStyleTags = (string)=>{ const styles = tags.map((tag)=>tag.replace(/:"?([^"]*)"?/g, ':$1;').trim()); if(attributes.length) { - attributes = attributes.map((attribute)=>attribute.replace(/(\w+)=(.+)/, '$1="$2"')); + attributes = attributes.map((attribute)=>attribute.replace(/(\w+)=(.+)/, ' $1="$2"')); } return `${classes.join(' ')}" ` + `${id ? `id="${id}"` : ''} ` + - `${styles.length ? `style="${styles.join(' ')}"` : ''} ` + - `${attributes.length ? attributes.join(' ') : ''}`; + `${styles.length ? `style="${styles.join(' ')}"` : ''}` + + `${attributes.length ? attributes.join('') : ''}`; }; module.exports = { diff --git a/tests/markdown/mustache-syntax.test.js b/tests/markdown/mustache-syntax.test.js index d9e1ce6f9..6669cc6cb 100644 --- a/tests/markdown/mustache-syntax.test.js +++ b/tests/markdown/mustache-syntax.test.js @@ -124,6 +124,12 @@ describe('Inline: When using the Inline syntax {{ }}', ()=>{ const rendered = Markdown.render(source); expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('text'); }); + + it('Renders an image with added attributes', function() { + const source = dedent`![homebrew mug](https://i.imgur.com/hMna6G0.png) {position:absolute,bottom:20px,left:130px,width:220px,a=b and c,d=e}`; + const rendered = Markdown.render(source).trimReturns(); + expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(`

homebrew mug

`); + }); }); // BLOCK SYNTAX @@ -216,6 +222,7 @@ describe(`Block: When using the Block syntax {{tags\\ntext\\n}}`, ()=>{ // FIXME: adds extra \s before closing `>` in opening tag, and another after class names expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(`

Sample text.

`); }); + }); // MUSTACHE INJECTION SYNTAX