diff --git a/lib/rules_block/fences.js b/lib/rules_block/fences.js index 1b15685..186cdbb 100644 --- a/lib/rules_block/fences.js +++ b/lib/rules_block/fences.js @@ -55,6 +55,11 @@ module.exports = function fences(state, startLine, endLine, silent) { if (state.src.charCodeAt(pos) !== marker) { continue; } + if (state.tShift[nextLine] - state.blkIndent >= 4) { + // closing fence should be indented less than 4 spaces + continue; + } + pos = state.skipChars(pos, marker); // closing code fence must be at least as long as the opening one diff --git a/test/fixtures/commonmark/bad.txt b/test/fixtures/commonmark/bad.txt index 6959dfa..9479a0f 100644 --- a/test/fixtures/commonmark/bad.txt +++ b/test/fixtures/commonmark/bad.txt @@ -32,25 +32,6 @@ error:

foo #

-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -src line: 1335 - -. -``` -aaa - ``` -. -
aaa
-    ```
-
-. - -error: - -
aaa
-
- - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ src line: 3124 diff --git a/test/fixtures/commonmark/good.txt b/test/fixtures/commonmark/good.txt index 8c2c3b1..804d689 100644 --- a/test/fixtures/commonmark/good.txt +++ b/test/fixtures/commonmark/good.txt @@ -1060,6 +1060,19 @@ aaa . +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +src line: 1335 + +. +``` +aaa + ``` +. +
aaa
+    ```
+
+. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ src line: 1348