Do not take empty lines into account when computing raw block dedent (#1676)

This commit is contained in:
MALO 2023-07-10 18:23:14 +02:00 committed by GitHub
parent 78f96f844b
commit 507efc3a1c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 0 deletions

View File

@ -565,6 +565,9 @@ impl Raw {
let dedent = lines let dedent = lines
.iter() .iter()
.skip(1) .skip(1)
.filter(|line| !line.chars().all(char::is_whitespace))
// The line with the closing ``` is always taken into account
.chain(lines.last())
.map(|line| line.chars().take_while(|c| c.is_whitespace()).count()) .map(|line| line.chars().take_while(|c| c.is_whitespace()).count())
.min() .min()
.unwrap_or(0); .unwrap_or(0);

Binary file not shown.

Before

Width:  |  Height:  |  Size: 33 KiB

After

Width:  |  Height:  |  Size: 21 KiB

View File

@ -4,6 +4,10 @@
// No extra space. // No extra space.
`A``B` `A``B`
---
// Empty raw block.
Empty raw block:``.
--- ---
// Typst syntax inside. // Typst syntax inside.
```typ #let x = 1``` \ ```typ #let x = 1``` \
@ -48,6 +52,22 @@ The keyword ```rust let```.
C C
``` ```
---
// Do not take empty lines into account when computing dedent.
```
A
B
```
---
// Take last line into account when computing dedent.
```
A
B
```
--- ---
// Text show rule // Text show rule
#show raw: set text(font: "Roboto") #show raw: set text(font: "Roboto")