Fix containers in directive (container)

Closes GH-4.
This commit is contained in:
Titus Wormer 2021-01-04 10:51:12 +01:00
parent 90f35b016f
commit 152323ec29
No known key found for this signature in database
GPG key ID: E6E581152ED04E2E
4 changed files with 25 additions and 6 deletions

View file

@ -10,8 +10,8 @@ var createAttributes = require('./factory-attributes')
var createLabel = require('./factory-label')
var createName = require('./factory-name')
var label = {tokenize: tokenizeLabel}
var attributes = {tokenize: tokenizeAttributes}
var label = {tokenize: tokenizeLabel, partial: true}
var attributes = {tokenize: tokenizeAttributes, partial: true}
function tokenizeDirectiveContainer(effects, ok, nok) {
var self = this
@ -46,6 +46,7 @@ function tokenizeDirectiveContainer(effects, ok, nok) {
}
function afterName(code) {
console.log('after:name:', code)
return code === 91 /* `[` */
? effects.attempt(label, afterLabel, afterLabel)(code)
: afterLabel(code)

View file

@ -8,8 +8,8 @@ var createAttributes = require('./factory-attributes')
var createLabel = require('./factory-label')
var createName = require('./factory-name')
var label = {tokenize: tokenizeLabel}
var attributes = {tokenize: tokenizeAttributes}
var label = {tokenize: tokenizeLabel, partial: true}
var attributes = {tokenize: tokenizeAttributes, partial: true}
function tokenizeDirectiveLeaf(effects, ok, nok) {
return start

View file

@ -7,8 +7,8 @@ var createAttributes = require('./factory-attributes')
var createLabel = require('./factory-label')
var createName = require('./factory-name')
var label = {tokenize: tokenizeLabel}
var attributes = {tokenize: tokenizeAttributes}
var label = {tokenize: tokenizeLabel, partial: true}
var attributes = {tokenize: tokenizeAttributes, partial: true}
function previous(code) {
// If there is a previous code, there will always be a tail.

18
test.js
View file

@ -1262,6 +1262,24 @@ test('content', function (t) {
'should support text directives in container directives'
)
t.equal(
micromark(':::section\n* a\n:::', options({'*': h})),
'<section>\n<ul>\n<li>a</li>\n</ul>\n</section>',
'should support lists in container directives'
)
t.equal(
micromark(':::section[]\n* a\n:::', options({'*': h})),
'<section>\n<ul>\n<li>a</li>\n</ul>\n</section>',
'should support lists w/ label brackets in container directives'
)
t.equal(
micromark(':::section{}\n* a\n:::', options({'*': h})),
'<section>\n<ul>\n<li>a</li>\n</ul>\n</section>',
'should support lists w/ attribute braces in container directives'
)
t.end()
})