Skip to content

Fix markdown parser #286

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/utils/compile-markdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ function compactParagraphs(tokens) {
}

balance += count(/\{\{#/g, token.text);
balance += count(/<[A-Z]/g, token.text);
balance -= count(/\{\{\//g, token.text);
balance -= count(/<\/[A-Z]/g, token.text);
}

return compacted;
Expand Down
20 changes: 19 additions & 1 deletion tests-node/unit/utils/compile-markdown-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const stripIndent = require('common-tags').stripIndent;
const compileMarkdown = require('../../../lib/utils/compile-markdown');

QUnit.module('Unit | compile-markdown', function(hooks) {
test('compacting paragraphs', function(assert) {
test('compacting curly paragraphs', function(assert) {
let input = stripIndent`
{{#foo-bar}}

Expand All @@ -20,6 +20,24 @@ QUnit.module('Unit | compile-markdown', function(hooks) {
assert.equal(result, expected);
});

test('compacting angle bracket paragraphs', function(assert) {
let input = stripIndent`
<FooBar>

</FooBar>
`;

// TODO: there is a space left before the closing tag but build is not broken :)
let result = compileMarkdown(input, { targetHandlebars: true });
let expected = stripIndent`
<div class="docs-md"><FooBar>

</FooBar></div>
`;

assert.equal(result, expected);
});

test('compacting implicit code blocks', function(assert) {
// Surrounding whitespace + 4-space indent = code block in MD
let input = stripIndent`
Expand Down