Browse Source

Allow tildes in info string of a fence block with tilde marker

This is now allowed as per commonmark 0.29 spec:
~~~ js ~~~
console.log('hello, world!');
~~~

See also:
b7651e4f8b
pull/570/head
Alex Kocharin 5 years ago
parent
commit
254b776beb
  1. 6
      lib/rules_block/fence.js
  2. 19
      test/fixtures/commonmark/bad.txt
  3. 12
      test/fixtures/commonmark/good.txt
  4. 10
      test/fixtures/markdown-it/commonmark_extras.txt

6
lib/rules_block/fence.js

@ -31,7 +31,11 @@ module.exports = function fence(state, startLine, endLine, silent) {
markup = state.src.slice(mem, pos);
params = state.src.slice(pos, max);
if (params.indexOf(String.fromCharCode(marker)) >= 0) { return false; }
if (marker === 0x60 /* ` */) {
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; }

19
test/fixtures/commonmark/bad.txt

@ -15,25 +15,6 @@ error:
aaa</p>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src line: 1995
.
~~~ aa ``` ~~~
foo
~~~
.
<pre><code class="language-aa">foo
</code></pre>
.
error:
<p>~~~ aa ``` ~~~
foo</p>
<pre><code></code></pre>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src line: 5176

12
test/fixtures/commonmark/good.txt

@ -1473,6 +1473,18 @@ foo
foo</p>
.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src line: 1995
.
~~~ aa ``` ~~~
foo
~~~
.
<pre><code class="language-aa">foo
</code></pre>
.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src line: 2007

10
test/fixtures/markdown-it/commonmark_extras.txt

@ -190,16 +190,6 @@ bar
</ul>
.
Info string in fenced code block can't contain marker used for the fence
.
~~~test~
~~~test`
.
<p>~~~test~</p>
<pre><code class="test`"></code></pre>
.
Tabs should be stripped from the beginning of the line
.
foo

Loading…
Cancel
Save