mirror of
https://github.com/jgm/pandoc.git
synced 2026-09-01 15:38:09 +08:00
Typst writer: ensure that -, +, etc. are escaped at beginning of block.
Our recent relaxing of escaping (#9386) caused problems for things like emphasized `-` characters that were rendered using `#strong[-]#`. This now gets rendered as `#strong[\-]`. Closes #9478.
This commit is contained in:
@@ -218,6 +218,9 @@ listItemToTypst ind marker blocks = do
|
||||
return $ hang ind (marker <> space) contents
|
||||
|
||||
inlinesToTypst :: PandocMonad m => [Inline] -> TW m (Doc Text)
|
||||
inlinesToTypst ils@(Str t : _) -- need to escape - in '[-]' #9478
|
||||
| Just (c, _) <- T.uncons t
|
||||
, needsEscapeAtLineStart c = ("\\" <>) . hcat <$> mapM inlineToTypst ils
|
||||
inlinesToTypst ils = hcat <$> mapM inlineToTypst ils
|
||||
|
||||
inlineToTypst :: PandocMonad m => Inline -> TW m (Doc Text)
|
||||
@@ -360,11 +363,13 @@ escapeTypst context t =
|
||||
needsEscape '~' = True
|
||||
needsEscape ':' = context == TermContext
|
||||
needsEscape _ = False
|
||||
needsEscapeAtLineStart '/' = True
|
||||
needsEscapeAtLineStart '+' = True
|
||||
needsEscapeAtLineStart '-' = True
|
||||
needsEscapeAtLineStart '=' = True
|
||||
needsEscapeAtLineStart _ = False
|
||||
|
||||
needsEscapeAtLineStart :: Char -> Bool
|
||||
needsEscapeAtLineStart '/' = True
|
||||
needsEscapeAtLineStart '+' = True
|
||||
needsEscapeAtLineStart '-' = True
|
||||
needsEscapeAtLineStart '=' = True
|
||||
needsEscapeAtLineStart _ = False
|
||||
|
||||
data LabelType =
|
||||
FreestandingLabel
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
```
|
||||
% pandoc -t typst --wrap=preserve
|
||||
**- a -
|
||||
- b**
|
||||
^D
|
||||
#strong[\- a -
|
||||
\- b]
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user