From d40008f5c7aa4fe39ed36c4aee367cff7bf368be Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Sun, 20 Jun 2021 14:18:09 +0200 Subject: [PATCH] Add test for directives w/ containers Related to GH-3. --- dev/lib/directive-container.js | 10 ++++++---- package.json | 16 ++++++++-------- test/index.js | 10 ++++++++-- 3 files changed, 22 insertions(+), 14 deletions(-) diff --git a/dev/lib/directive-container.js b/dev/lib/directive-container.js index afa0fb3..801757f 100644 --- a/dev/lib/directive-container.js +++ b/dev/lib/directive-container.js @@ -139,8 +139,8 @@ function tokenizeDirectiveContainer(effects, ok, nok) { return after(code) } - const token = effects.enter('chunkDocument', { - contentType: 'document', + const token = effects.enter(types.chunkDocument, { + contentType: constants.contentTypeDocument, previous }) if (previous) previous.next = token @@ -151,13 +151,15 @@ function tokenizeDirectiveContainer(effects, ok, nok) { /** @type {State} */ function contentContinue(code) { if (code === codes.eof) { - effects.exit('chunkDocument') + const t = effects.exit(types.chunkDocument) + self.parser.lazy[t.start.line] = false return after(code) } if (markdownLineEnding(code)) { effects.consume(code) - effects.exit('chunkDocument') + const t = effects.exit(types.chunkDocument) + self.parser.lazy[t.start.line] = false return lineStart } diff --git a/package.json b/package.json index b365ff1..5cedc3b 100644 --- a/package.json +++ b/package.json @@ -38,19 +38,19 @@ "default": "./index.js" }, "dependencies": { - "micromark-factory-space": "^1.0.0-alpha.2", - "micromark-factory-whitespace": "^1.0.0-alpha.2", - "micromark-util-character": "^1.0.0-alpha.2", - "micromark-util-symbol": "^1.0.0-alpha.2", - "micromark-util-types": "^1.0.0-alpha.2", + "micromark-factory-space": "^1.0.0-beta.1", + "micromark-factory-whitespace": "^1.0.0-beta.1", + "micromark-util-character": "^1.0.0-beta.1", + "micromark-util-symbol": "^1.0.0-beta.1", + "micromark-util-types": "^1.0.0-beta.1", "parse-entities": "^3.0.0" }, "devDependencies": { "@types/tape": "^4.0.0", "c8": "^7.0.0", "html-void-elements": "^2.0.0", - "micromark": "^3.0.0-alpha.2", - "micromark-build": "^1.0.0-alpha.2", + "micromark": "^3.0.0-beta.1", + "micromark-build": "^1.0.0-beta.1", "prettier": "^2.0.0", "remark-cli": "^9.0.0", "remark-preset-wooorm": "^8.0.0", @@ -58,7 +58,7 @@ "tape": "^5.0.0", "type-coverage": "^2.0.0", "typescript": "^4.0.0", - "xo": "^0.40.0" + "xo": "^0.39.0" }, "scripts": { "build": "rimraf \"dev/**/*.d.ts\" \"test/**/*.d.ts\" && tsc && type-coverage && micromark-build", diff --git a/test/index.js b/test/index.js index bc5a6f4..605a066 100644 --- a/test/index.js +++ b/test/index.js @@ -1032,7 +1032,7 @@ test('micromark-extension-directive (syntax)', (t) => { t.equal( micromark('>a\n:::a\nb', options()), - '
\n

a

\n
\n', + '
\n

a

\n
', 'should support a block quote before a container' ) @@ -1074,7 +1074,7 @@ test('micromark-extension-directive (syntax)', (t) => { t.equal( micromark('* a\n:::a\nb', options()), - '\n', + '', 'should support a list before a container' ) @@ -1371,6 +1371,12 @@ test('content', (t) => { 'should support lists w/ attribute braces in container directives' ) + t.equal( + micromark(':::i\n- +\na', options()), + '', + 'should support lazy containers in an unclosed container directive' + ) + t.end() })