Skip to content

Commit 0244f08

Browse files
authored
fix: remove up to the fence indentation from each content line (#4074)
1 parent 300bb1d commit 0244f08

3 files changed

Lines changed: 24 additions & 5 deletions

File tree

‎src/Tokenizer.ts‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,9 @@ function indentCodeCompensation(raw: string, text: string, rules: Rules) {
6868

6969
const [indentInNode] = matchIndentInNode;
7070

71-
if (indentInNode.length >= indentToCode.length) {
72-
return node.slice(indentToCode.length);
73-
}
74-
75-
return node;
71+
// Up to the fence's own indentation is removed from each line, so a line
72+
// indented less than the fence loses whatever indentation it has.
73+
return node.slice(Math.min(indentInNode.length, indentToCode.length));
7674
})
7775
.join('\n');
7876
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<pre><code>aaa
2+
aaa
3+
aaa
4+
</code></pre>
5+
<p>sep</p>
6+
<pre><code> aaa
7+
</code></pre>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
renderExact: true
3+
---
4+
```
5+
aaa
6+
aaa
7+
aaa
8+
```
9+
10+
sep
11+
12+
```
13+
aaa
14+
```

0 commit comments

Comments
 (0)