Skip to content

Commit

Permalink
Typst reader: improve handling of inline #quote.
Browse files Browse the repository at this point in the history
Closes #9413.
  • Loading branch information
jgm committed Feb 5, 2024
1 parent 3ef74d1 commit bab30ea
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/Text/Pandoc/Readers/Typst.hs
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit bab30ea

Please sign in to comment.