summaryrefslogtreecommitdiff
path: root/src/Text
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2024-02-05 08:55:28 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2024-02-05 08:55:28 -0800
commitbab30eaf4179c1af69d813f24e13bae1c0255321 (patch)
treefd3348fa7f6d93813bbb6617ba697095741696ec /src/Text
parent3ef74d1fd2fa7937da841f90d3ff3d8dc87488c8 (diff)
Typst reader: improve handling of inline `#quote`.
Closes #9413.
Diffstat (limited to 'src/Text')
-rw-r--r--src/Text/Pandoc/Readers/Typst.hs17
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