Skip to content

Commit dbb393d

Browse files
authored
fix: strip a tab that follows spaces in an indented code block (#4080)
* fix: strip a tab that follows spaces in an indented code block codeRemoveIndent tried its space alternative first, so a line indented with spaces then a tab lost only the spaces and kept the tab as content. Trying the tab alternative first matches CommonMark example 2, where a tab advances to the next four column stop and the whole run is indent. * test: move the tab tests to test/specs/new Uses renderExact so the fixture compares exactly, which htmlIsEqual does not, and keeps the assertions out of marked.test.js.
1 parent 24bf47c commit dbb393d

3 files changed

Lines changed: 35 additions & 1 deletion

File tree

‎src/rules.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ try {
4141
})();
4242

4343
export const other = {
44-
codeRemoveIndent: /^(?: {1,4}| {0,3}\t)/gm,
44+
codeRemoveIndent: /^(?: {0,3}\t| {1,4})/gm,
4545
outputLinkReplace: /\\([\[\]])/g,
4646
indentCodeCompensation: /^(\s+)(?:```)/,
4747
beginningSpace: /^\s+/,
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<pre><code>foo baz bim
2+
</code></pre>
3+
<p>sep</p>
4+
<pre><code>three spaces and a tab
5+
</code></pre>
6+
<p>sep</p>
7+
<pre><code>lone tab
8+
</code></pre>
9+
<p>sep</p>
10+
<pre><code>four spaces
11+
</code></pre>
12+
<p>sep</p>
13+
<pre><code> five spaces
14+
</code></pre>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
renderExact: true
3+
---
4+
foo baz bim
5+
6+
sep
7+
8+
three spaces and a tab
9+
10+
sep
11+
12+
lone tab
13+
14+
sep
15+
16+
four spaces
17+
18+
sep
19+
20+
five spaces

0 commit comments

Comments
 (0)