mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2025-12-29 09:02:37 +00:00
Merge pull request #2752 from Gazook89/Injection-Blocks-Take-3
Prevent Injection if preceded by another Injection token
This commit is contained in:
@@ -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';
|
||||
|
||||
@@ -105,6 +105,22 @@ test('Renders a mustache span with text, id, class and a couple of css propertie
|
||||
expect(rendered).toBe('<span class="inline-block pen" id="author" style="color:orange; font-family:trebuchet ms;">text</span>');
|
||||
});
|
||||
|
||||
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('<p><span class=" cat" class="inline-block cat" >Sample Text</span></p>\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('<div class=" cat" class="block cat" ><p>Sample Text</p>\n</div><p>{toad}</p>\n');
|
||||
});
|
||||
|
||||
// TODO: add tests for ID with accordance to CSS spec:
|
||||
//
|
||||
// From https://drafts.csswg.org/selectors/#id-selectors:
|
||||
|
||||
Reference in New Issue
Block a user