From e7c60e1a01c8ab005ace3566b04f4ab90badcc2f Mon Sep 17 00:00:00 2001 From: Alex Kocharin Date: Wed, 29 Oct 2014 07:06:05 +0300 Subject: [PATCH] Fix fences rule closing fence should not be indented more than 3 spaces --- lib/rules_block/fences.js | 5 +++++ test/fixtures/commonmark/bad.txt | 19 ------------------- test/fixtures/commonmark/good.txt | 13 +++++++++++++ 3 files changed, 18 insertions(+), 19 deletions(-) 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