From 152323ec2983130f3c7b8ddd9cf833cd82c15a50 Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Mon, 4 Jan 2021 10:51:12 +0100 Subject: [PATCH] Fix containers in directive (container) Closes GH-4. --- lib/tokenize-directive-container.js | 5 +++-- lib/tokenize-directive-leaf.js | 4 ++-- lib/tokenize-directive-text.js | 4 ++-- test.js | 18 ++++++++++++++++++ 4 files changed, 25 insertions(+), 6 deletions(-) diff --git a/lib/tokenize-directive-container.js b/lib/tokenize-directive-container.js index c5c7139..a825702 100644 --- a/lib/tokenize-directive-container.js +++ b/lib/tokenize-directive-container.js @@ -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) diff --git a/lib/tokenize-directive-leaf.js b/lib/tokenize-directive-leaf.js index adfd3d7..07c3295 100644 --- a/lib/tokenize-directive-leaf.js +++ b/lib/tokenize-directive-leaf.js @@ -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 diff --git a/lib/tokenize-directive-text.js b/lib/tokenize-directive-text.js index 4f211b4..00aff94 100644 --- a/lib/tokenize-directive-text.js +++ b/lib/tokenize-directive-text.js @@ -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. diff --git a/test.js b/test.js index b928ddf..111d2c2 100644 --- a/test.js +++ b/test.js @@ -1262,6 +1262,24 @@ test('content', function (t) { 'should support text directives in container directives' ) + t.equal( + micromark(':::section\n* a\n:::', options({'*': h})), + '
\n\n
', + 'should support lists in container directives' + ) + + t.equal( + micromark(':::section[]\n* a\n:::', options({'*': h})), + '
\n\n
', + 'should support lists w/ label brackets in container directives' + ) + + t.equal( + micromark(':::section{}\n* a\n:::', options({'*': h})), + '
\n\n
', + 'should support lists w/ attribute braces in container directives' + ) + t.end() })