diff options
| author | John MacFarlane <jgm@berkeley.edu> | 2024-02-05 08:55:28 -0800 |
|---|---|---|
| committer | John MacFarlane <jgm@berkeley.edu> | 2024-02-05 08:55:28 -0800 |
| commit | bab30eaf4179c1af69d813f24e13bae1c0255321 (patch) | |
| tree | fd3348fa7f6d93813bbb6617ba697095741696ec | |
| parent | 3ef74d1fd2fa7937da841f90d3ff3d8dc87488c8 (diff) | |
Typst reader: improve handling of inline `#quote`.
Closes #9413.
| -rw-r--r-- | src/Text/Pandoc/Readers/Typst.hs | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/Text/Pandoc/Readers/Typst.hs b/src/Text/Pandoc/Readers/Typst.hs index b0be897da..57063fc75 100644 --- a/src/Text/Pandoc/Readers/Typst.hs +++ b/src/Text/Pandoc/Readers/Typst.hs @@ -503,8 +503,8 @@ inlineHandlers = M.fromList B.underline <$> pWithContents pInlines body) ,("quote", \_ fields -> do (getField "block" fields <|> pure False) >>= guard . not - body <- getField "body" fields >>= pWithContents pInlines - pure $ B.doubleQuoted body) + body <- getInlineBody fields >>= pWithContents pInlines + pure $ B.doubleQuoted $ B.trimInlines body) ,("link", \_ fields -> do dest <- getField "dest" fields src <- case dest of @@ -569,6 +569,19 @@ inlineHandlers = M.fromList (if display then B.displayMath else B.math) . writeTeX <$> pMathMany body) ] +getInlineBody :: PandocMonad m => M.Map Identifier Val -> P m (Seq Content) +getInlineBody fields = + parbreaksToLinebreaks <$> getField "body" fields + +parbreaksToLinebreaks :: Seq Content -> Seq Content +parbreaksToLinebreaks = + fmap go . Seq.dropWhileL isParbreak . Seq.dropWhileR isParbreak + where + go (Elt "parbreak" pos _) = Elt "linebreak" pos mempty + go x = x + isParbreak (Elt "parbreak" _ _) = True + isParbreak _ = False + pPara :: PandocMonad m => P m B.Blocks pPara = B.para . B.trimInlines . collapseAdjacentCites . mconcat |
