mirror of
https://github.com/typst/typst
synced 2025-05-15 09:35:28 +08:00
Do not take empty lines into account when computing raw
block dedent (#1676)
This commit is contained in:
parent
78f96f844b
commit
507efc3a1c
@ -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 |
@ -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")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user