diff --git a/shared/naturalcrit/markdown.js b/shared/naturalcrit/markdown.js index 16623b8a5..1960776d3 100644 --- a/shared/naturalcrit/markdown.js +++ b/shared/naturalcrit/markdown.js @@ -134,7 +134,7 @@ const mustacheInjectInline = { const match = inlineRegex.exec(src); if(match) { const lastToken = tokens[tokens.length - 1]; - if(!lastToken) + if(!lastToken || lastToken.type == 'mustacheInjectInline') return false; const tags = ` ${processStyleTags(match[1])}`; @@ -169,7 +169,7 @@ const mustacheInjectBlock = { const match = inlineRegex.exec(src); if(match) { const lastToken = tokens[tokens.length - 1]; - if(!lastToken) + if(!lastToken || lastToken.type == 'mustacheInjectBlock') return false; lastToken.originalType = 'mustacheInjectBlock'; diff --git a/tests/markdown/mustache-span.test.js b/tests/markdown/mustache-span.test.js index 6d249ebcb..e7c65ea77 100644 --- a/tests/markdown/mustache-span.test.js +++ b/tests/markdown/mustache-span.test.js @@ -105,6 +105,22 @@ test('Renders a mustache span with text, id, class and a couple of css propertie expect(rendered).toBe('text'); }); +test('Two consecutive injections into Inline', function() { + const source = '{{dog Sample Text}}{cat}{toad}'; + const rendered = Markdown.render(source); + // FIXME: Drops original attributes in favor of injection, rather than adding. + // FIXME: Doesn't keep the raw text of second injection. + // FIXME: Renders the extra class attribute (which is dropped by the browser). + expect(rendered).toBe('

Sample Text

\n'); +}); + +test('Two consecutive injections into Block', function() { + const source = '{{dog\nSample Text\n}}\n{cat}\n{toad}'; + const rendered = Markdown.render(source); + // FIXME: Renders the extra class attribute (which is dropped by the browser). + expect(rendered).toBe('

Sample Text

\n

{toad}

\n'); +}); + // TODO: add tests for ID with accordance to CSS spec: // // From https://drafts.csswg.org/selectors/#id-selectors: