mirror of
https://github.com/markedjs/marked.git
synced 2026-11-30 16:48:05 +01:00
fix: remove up to the fence indentation from each content line (#4074)
This commit is contained in:
+3
-5
@@ -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>
|
||||
@@ -0,0 +1,14 @@
|
||||
---
|
||||
renderExact: true
|
||||
---
|
||||
```
|
||||
aaa
|
||||
aaa
|
||||
aaa
|
||||
```
|
||||
|
||||
sep
|
||||
|
||||
```
|
||||
aaa
|
||||
```
|
||||
Reference in New Issue
Block a user