Typst reader: improve handling of inline #quote.

Closes #9413.
This commit is contained in:
John MacFarlane
2024-02-05 08:55:28 -08:00
parent 3ef74d1fd2
commit bab30eaf41
+15 -2
View File
@@ -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