diff --git a/shared/naturalcrit/markdown.js b/shared/naturalcrit/markdown.js index fdc1b06ce..38a6c685b 100644 --- a/shared/naturalcrit/markdown.js +++ b/shared/naturalcrit/markdown.js @@ -45,7 +45,7 @@ const mustacheSpans = { let delim; while (delim = inlineRegex.exec(match[0])) { if(!tags) { - tags = ` ${processStyleTags(delim[0].substring(2))}`; + tags = `${processStyleTags(delim[0].substring(2))}`; endTags = delim[0].length; } if(delim[0].startsWith('{{')) { @@ -95,7 +95,7 @@ const mustacheDivs = { let delim; while (delim = blockRegex.exec(match[0])?.[0].trim()) { if(!tags) { - tags = ` ${processStyleTags(delim.substring(2))}`; + tags = `${processStyleTags(delim.substring(2))}`; endTags = delim.length; } if(delim.startsWith('{{')) { @@ -138,7 +138,8 @@ const mustacheInjectInline = { const lastToken = tokens[tokens.length - 1]; if(!lastToken || lastToken.type == 'mustacheInjectInline') return false; - const tags = ` ${processStyleTags(match[1])}`; + + const tags = `${processStyleTags(match[1])}`; lastToken.originalType = lastToken.type; lastToken.type = 'mustacheInjectInline'; lastToken.tags = tags; @@ -174,7 +175,7 @@ const mustacheInjectBlock = { return false; lastToken.originalType = 'mustacheInjectBlock'; - lastToken.tags = ` ${processStyleTags(match[1])}`; + lastToken.tags = `${processStyleTags(match[1])}`; return { type : 'mustacheInjectBlock', // Should match "name" above raw : match[0], // Text to consume from the source diff --git a/tests/markdown/mustache-syntax.test.js b/tests/markdown/mustache-syntax.test.js index 790af84f6..e6bb9cee5 100644 --- a/tests/markdown/mustache-syntax.test.js +++ b/tests/markdown/mustache-syntax.test.js @@ -13,109 +13,94 @@ String.prototype.trimReturns = function(){ // Remove the `.failing()` method once you have fixed the issue. describe('Inline: When using the Inline syntax {{ }}', ()=>{ - it.failing('Renders a mustache span with text only', function() { + it('Renders a mustache span with text only', function() { const source = '{{ text}}'; const rendered = Markdown.render(source); - // FIXME: adds extra \s after class names expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('text'); }); - it.failing('Renders a mustache span with text only, but with spaces', function() { + it('Renders a mustache span with text only, but with spaces', function() { const source = '{{ this is a text}}'; const rendered = Markdown.render(source); - // FIXME: adds extra \s after class names expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('this is a text'); }); - it.failing('Renders an empty mustache span', function() { + it('Renders an empty mustache span', function() { const source = '{{}}'; const rendered = Markdown.render(source); - // FIXME: adds extra \s after class names expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(''); }); - it.failing('Renders a mustache span with just a space', function() { + it('Renders a mustache span with just a space', function() { const source = '{{ }}'; const rendered = Markdown.render(source); - // FIXME: adds extra \s after class names expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(''); }); - it.failing('Renders a mustache span with a few spaces only', function() { + it('Renders a mustache span with a few spaces only', function() { const source = '{{ }}'; const rendered = Markdown.render(source); - // FIXME: adds extra \s after class names expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(''); }); - it.failing('Renders a mustache span with text and class', function() { + it('Renders a mustache span with text and class', function() { const source = '{{my-class text}}'; const rendered = Markdown.render(source); - // FIXME: adds two extra \s before closing `>` in opening tag. expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('text'); }); - it.failing('Renders a mustache span with text and two classes', function() { + it('Renders a mustache span with text and two classes', function() { const source = '{{my-class,my-class2 text}}'; const rendered = Markdown.render(source); - // FIXME: adds two extra \s before closing `>` in opening tag. expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('text'); }); - it.failing('Renders a mustache span with text with spaces and class', function() { + it('Renders a mustache span with text with spaces and class', function() { const source = '{{my-class this is a text}}'; const rendered = Markdown.render(source); - // FIXME: adds two extra \s before closing `>` in opening tag expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('this is a text'); }); - it.failing('Renders a mustache span with text and id', function() { + it('Renders a mustache span with text and id', function() { const source = '{{#my-span text}}'; const rendered = Markdown.render(source); - // FIXME: adds extra \s before closing `>` in opening tag, and another after class names expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('text'); }); - it.failing('Renders a mustache span with text and two ids', function() { + it('Renders a mustache span with text and two ids', function() { const source = '{{#my-span,#my-favorite-span text}}'; const rendered = Markdown.render(source); - // FIXME: adds extra \s before closing `>` in opening tag, and another after class names expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('text'); }); - it.failing('Renders a mustache span with text and css property', function() { + it('Renders a mustache span with text and css property', function() { const source = '{{color:red text}}'; const rendered = Markdown.render(source); - // FIXME: adds extra \s after class names expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('text'); }); - it.failing('Renders a mustache span with text and two css properties', function() { + it('Renders a mustache span with text and two css properties', function() { const source = '{{color:red,padding:5px text}}'; const rendered = Markdown.render(source); - // FIXME: adds extra \s after class names expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('text'); }); - it.failing('Renders a mustache span with text and css property which contains quotes', function() { + it('Renders a mustache span with text and css property which contains quotes', function() { const source = '{{font-family:"trebuchet ms" text}}'; const rendered = Markdown.render(source); - // FIXME: adds extra \s after class names expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('text'); }); - it.failing('Renders a mustache span with text and two css properties which contains quotes', function() { + it('Renders a mustache span with text and two css properties which contains quotes', function() { const source = '{{font-family:"trebuchet ms",padding:"5px 10px" text}}'; const rendered = Markdown.render(source); - // FIXME: adds extra \s after class names expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('text'); }); - it.failing('Renders a mustache span with text with quotes and css property which contains quotes', function() { + it('Renders a mustache span with text with quotes and css property which contains quotes', function() { const source = '{{font-family:"trebuchet ms" text "with quotes"}}'; const rendered = Markdown.render(source); - // FIXME: adds extra \s after class names expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('text “with quotes”'); }); @@ -147,21 +132,19 @@ describe('Inline: When using the Inline syntax {{ }}', ()=>{ // BLOCK SYNTAX describe(`Block: When using the Block syntax {{tags\\ntext\\n}}`, ()=>{ - it.failing('Renders a div with text only', function() { + it('Renders a div with text only', function() { const source = dedent`{{ text }}`; const rendered = Markdown.render(source).trimReturns(); - // FIXME: adds extra \s after class names expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(`

text

`); }); - it.failing('Renders an empty div', function() { + it('Renders an empty div', function() { const source = dedent`{{ }}`; const rendered = Markdown.render(source).trimReturns(); - // FIXME: adds extra \s after class names expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(`
`); }); @@ -169,52 +152,46 @@ describe(`Block: When using the Block syntax {{tags\\ntext\\n}}`, ()=>{ const source = dedent`{{ }}`; const rendered = Markdown.render(source).trimReturns(); - // this actually renders in HB as '{{ }}'... expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(`

{{}}

`); }); - it.failing('Renders a div with a single class', function() { + it('Renders a div with a single class', function() { const source = dedent`{{cat }}`; const rendered = Markdown.render(source).trimReturns(); - // FIXME: adds two extra \s before closing `>` in opening tag expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(`
`); }); - it.failing('Renders a div with a single class and text', function() { + it('Renders a div with a single class and text', function() { const source = dedent`{{cat Sample text. }}`; const rendered = Markdown.render(source).trimReturns(); - // FIXME: adds two extra \s before closing `>` in opening tag expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(`

Sample text.

`); }); - it.failing('Renders a div with two classes and text', function() { + it('Renders a div with two classes and text', function() { const source = dedent`{{cat,dog Sample text. }}`; const rendered = Markdown.render(source).trimReturns(); - // FIXME: adds two extra \s before closing `>` in opening tag expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(`

Sample text.

`); }); - it.failing('Renders a div with a style and text', function() { + it('Renders a div with a style and text', function() { const source = dedent`{{color:red Sample text. }}`; const rendered = Markdown.render(source).trimReturns(); - // FIXME: adds two extra \s before closing `>` in opening tag expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(`

Sample text.

`); }); - it.failing('Renders a div with a class, style and text', function() { + it('Renders a div with a class, style and text', function() { const source = dedent`{{cat,color:red Sample text. }}`; const rendered = Markdown.render(source).trimReturns(); - // FIXME: adds extra \s after the class attribute expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(`

Sample text.

`); }); @@ -226,12 +203,11 @@ describe(`Block: When using the Block syntax {{tags\\ntext\\n}}`, ()=>{ expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(`

Sample text.

`); }); - it.failing('Renders a div with a single ID', function() { + it('Renders a div with a single ID', function() { const source = dedent`{{#cat,#dog Sample text. }}`; const rendered = Markdown.render(source).trimReturns(); - // FIXME: adds extra \s before closing `>` in opening tag, and another after class names expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(`

Sample text.

`); });