Skip to content

Commit

Permalink
Reset indentation requirements inside [] content block.
Browse files Browse the repository at this point in the history
e.g.
```
/ B: #block[
- a
]
```
We don't need indentation inside the block content.
  • Loading branch information
jgm committed Oct 22, 2024
1 parent f53f1ba commit cddea1e
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 33 deletions.
7 changes: 5 additions & 2 deletions src/Typst/Parse.hs
Original file line number Diff line number Diff line change
Expand Up @@ -990,19 +990,22 @@ pContent = do
void $ char '['
col <- sourceColumn <$> getPosition
oldLineStartCol <- stLineStartCol <$> getState
oldIndent <- stIndent <$> getState
updateState $ \st ->
st
{ stLineStartCol = col,
stContentBlockNesting =
stContentBlockNesting st + 1
stContentBlockNesting st + 1,
stIndent = []
}
ms <- manyTill pMarkup (char ']')
ws
updateState $ \st ->
st
{ stLineStartCol = oldLineStartCol,
stContentBlockNesting =
stContentBlockNesting st - 1
stContentBlockNesting st - 1,
stIndent = oldIndent
}
pure $ Content ms

Expand Down
64 changes: 33 additions & 31 deletions test/out/layout/list-02.out
Original file line number Diff line number Diff line change
Expand Up @@ -39,38 +39,40 @@
]
]))))
, SoftBreak
, Text "-"
, Space
, Text "Level"
, Space
, Text "1"
, SoftBreak
, Text "-"
, Space
, Text "Level"
, Space
, Code
"test/typ/layout/list-02.typ"
( line 3 , column 12 )
(Block
(Content
[ SoftBreak
, Text "2"
, Space
, Text "through"
, Space
, Text "content"
, Space
, Text "block"
, ParBreak
]))
, ParBreak
, BulletListItem
[ Text "Level"
, Space
, Text "1"
, SoftBreak
, BulletListItem
[ Text "Level"
, Space
, Code
"test/typ/layout/list-02.typ"
( line 3 , column 12 )
(Block
(Content
[ SoftBreak
, Text "2"
, Space
, Text "through"
, Space
, Text "content"
, Space
, Text "block"
, ParBreak
]))
, ParBreak
]
]
]
--- evaluated ---
document(body: { text(body: [
- Level 1
- Level ]),
text(body: [
]),
list(children: ({ text(body: [Level 1
]),
list(children: ({ text(body: [Level ]),
text(body: [
2 through content block]),
parbreak(),
parbreak() })
parbreak(),
parbreak() })) })) })

0 comments on commit cddea1e

Please sign in to comment.