fix: remove up to the fence indentation from each content line (#4074)

This commit is contained in:
Miodrag Obradovic
2026-09-03 23:10:39 -06:00
committed by GitHub
parent 300bb1dce0
commit 0244f08d62
3 changed files with 24 additions and 5 deletions
+3 -5
View File
@@ -68,11 +68,9 @@ function indentCodeCompensation(raw: string, text: string, rules: Rules) {
const [indentInNode] = matchIndentInNode;
if (indentInNode.length >= indentToCode.length) {
return node.slice(indentToCode.length);
}
return node;
// Up to the fence's own indentation is removed from each line, so a line
// indented less than the fence loses whatever indentation it has.
return node.slice(Math.min(indentInNode.length, indentToCode.length));
})
.join('\n');
}
@@ -0,0 +1,7 @@
<pre><code>aaa
aaa
aaa
</code></pre>
<p>sep</p>
<pre><code> aaa
</code></pre>
+14
View File
@@ -0,0 +1,14 @@
---
renderExact: true
---
```
aaa
aaa
aaa
```
sep
```
aaa
```