Skip to content

Commit

Permalink
Fix multi matters w/ the same first character
Browse files Browse the repository at this point in the history
Closes GH-2.
  • Loading branch information
wooorm committed Sep 29, 2020
1 parent f43114f commit 6e36691
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/syntax.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,16 @@ function create(options) {
var index = -1
var flow = {}
var matter
var code

while (++index < length) {
matter = settings[index]
flow[fence(matter, 'open').charCodeAt(0)] = parse(matter)
code = fence(matter, 'open').charCodeAt(0)
if (code in flow) {
flow[code].push(parse(matter))
} else {
flow[code] = [parse(matter)]
}
}

return {flow: flow}
Expand Down
10 changes: 10 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ var html = require('./html')
var custom = {type: 'custom', marker: {open: '<', close: '>'}}
var json = {type: 'json', fence: {open: '{', close: '}'}}
var yamlAnywhere = {type: 'yaml', marker: '-', anywhere: true}
var customAndYaml = [{type: 'custom', marker: {open: '-', close: '.'}}, 'yaml']

test('core', function (t) {
t.throws(
Expand Down Expand Up @@ -232,5 +233,14 @@ test('markdown -> html (micromark)', function (t) {
'should not support custom matters in the middle'
)

t.deepEqual(
micromark('---\nasd\n...', {
extensions: [syntax(customAndYaml)],
htmlExtensions: [html(customAndYaml)]
}),
'',
'should not support custom matters in the middle'
)

t.end()
})

0 comments on commit 6e36691

Please sign in to comment.