Browse Source

Fix fences rule

closing fence should not be indented more than 3 spaces
pull/14/head
Alex Kocharin 10 years ago
parent
commit
e7c60e1a01
  1. 5
      lib/rules_block/fences.js
  2. 19
      test/fixtures/commonmark/bad.txt
  3. 13
      test/fixtures/commonmark/good.txt

5
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

19
test/fixtures/commonmark/bad.txt

@ -32,25 +32,6 @@ error:
<h1>foo #</h1>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src line: 1335
.
```
aaa
```
.
<pre><code>aaa
```
</code></pre>
.
error:
<pre><code>aaa
</code></pre>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src line: 3124

13
test/fixtures/commonmark/good.txt

@ -1060,6 +1060,19 @@ aaa
</code></pre>
.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src line: 1335
.
```
aaa
```
.
<pre><code>aaa
```
</code></pre>
.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src line: 1348

Loading…
Cancel
Save