From 93544ee4bfbea1cc72f98bf1986d5823664c9237 Mon Sep 17 00:00:00 2001 From: Alex Kocharin Date: Wed, 30 Nov 2016 15:44:22 +0300 Subject: [PATCH] Fenced code block info string should not contain fence marker Fix https://github.com/markdown-it/markdown-it/issues/301 --- lib/rules_block/fence.js | 2 +- test/fixtures/markdown-it/commonmark_extras.txt | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/rules_block/fence.js b/lib/rules_block/fence.js index a02bd5f..d9f6bb7 100644 --- a/lib/rules_block/fence.js +++ b/lib/rules_block/fence.js @@ -28,7 +28,7 @@ module.exports = function fence(state, startLine, endLine, silent) { markup = state.src.slice(mem, pos); params = state.src.slice(pos, max); - if (params.indexOf('`') >= 0) { return false; } + if (params.indexOf(String.fromCharCode(marker)) >= 0) { return false; } // Since start is found, we can report success here in validation mode if (silent) { return true; } diff --git a/test/fixtures/markdown-it/commonmark_extras.txt b/test/fixtures/markdown-it/commonmark_extras.txt index 3851a5d..41181c9 100644 --- a/test/fixtures/markdown-it/commonmark_extras.txt +++ b/test/fixtures/markdown-it/commonmark_extras.txt @@ -149,6 +149,16 @@ bar . +Info string in fenced code block can't contain marker used for the fence +. +~~~test~ + +~~~test` +. +

~~~test~

+
+. + Coverage. Directive can terminate paragraph. . a