From 6ecfa096d57be19346e9c61c0061f77ae39c1ddb Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Wed, 23 Sep 2020 17:18:57 +0200 Subject: [PATCH] Fix tainted state for custom matters Closes GH-1. --- lib/syntax.js | 3 ++- test.js | 18 +++++++++++++----- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/lib/syntax.js b/lib/syntax.js index 783f449..a6c541f 100644 --- a/lib/syntax.js +++ b/lib/syntax.js @@ -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} @@ -41,6 +41,7 @@ function parse(matter) { } effects.enter(name) + buffer = fence(matter, 'open') return effects.attempt(fenceConstruct, afterOpeningFence, nok)(code) } diff --git a/test.js b/test.js index 9bae949..a86f629 100644 --- a/test.js +++ b/test.js @@ -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(