Skip to content

Commit

Permalink
Fix tainted state for custom matters
Browse files Browse the repository at this point in the history
Closes GH-1.
  • Loading branch information
wooorm committed Sep 23, 2020
1 parent a95c672 commit 6ecfa09
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
3 changes: 2 additions & 1 deletion lib/syntax.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function parse(matter) {
var fenceType = name + 'Fence'
var sequenceType = fenceType + 'Sequence'
var fenceConstruct = {tokenize: tokenizeFence, partial: true}
var buffer = fence(matter, 'open')
var buffer

return {tokenize: tokenizeFrontmatter, concrete: true}

Expand All @@ -41,6 +41,7 @@ function parse(matter) {
}

effects.enter(name)
buffer = fence(matter, 'open')
return effects.attempt(fenceConstruct, afterOpeningFence, nok)(code)
}

Expand Down
18 changes: 13 additions & 5 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,22 +188,30 @@ test('markdown -> html (micromark)', function (t) {
'should support blank lines in yaml'
)

var customOptions = {
extensions: [syntax(custom)],
htmlExtensions: [html(custom)]
}

t.deepEqual(
micromark('<<<\na\n\nb\n>>>', {
extensions: [syntax(custom)],
htmlExtensions: [html(custom)]
}),
micromark('<<<\na\n\nb\n>>>', customOptions),
'',
'should support a custom matter (1)'
)

t.deepEqual(
micromark('<<<\na\n\nb\n>>>', customOptions),
'',
'should support a custom matter (2)'
)

t.deepEqual(
micromark('{\na\n\nb\n}', {
extensions: [syntax(json)],
htmlExtensions: [html(json)]
}),
'',
'should support a custom matter (2)'
'should support a custom matter (3)'
)

t.deepEqual(
Expand Down

0 comments on commit 6ecfa09

Please sign in to comment.