summaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorMALO <57839069+MDLC01@users.noreply.github.com>2023-07-10 18:23:14 +0200
committerGitHub <noreply@github.com>2023-07-10 18:23:14 +0200
commit507efc3a1c14e8487705c7424d605a1663d3fe6e (patch)
treec37a61c0d363fa3d813d7dd6a143dd43968e728c /crates
parent78f96f844bc54c5385c1efda0b5faad3c49fa79b (diff)
Do not take empty lines into account when computing `raw` block dedent (#1676)
Diffstat (limited to 'crates')
-rw-r--r--crates/typst/src/syntax/ast.rs3
1 files changed, 3 insertions, 0 deletions
diff --git a/crates/typst/src/syntax/ast.rs b/crates/typst/src/syntax/ast.rs
index 4a0de424..48be1b07 100644
--- a/crates/typst/src/syntax/ast.rs
+++ b/crates/typst/src/syntax/ast.rs
@@ -565,6 +565,9 @@ impl Raw {
let dedent = lines
.iter()
.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())
.min()
.unwrap_or(0);