diff options
| author | John MacFarlane <jgm@berkeley.edu> | 2023-12-08 21:54:39 -0800 |
|---|---|---|
| committer | John MacFarlane <jgm@berkeley.edu> | 2023-12-08 21:54:39 -0800 |
| commit | d57f3d576e505c805e8aa727b588235558c9abf3 (patch) | |
| tree | 7899cc6abdcb153b1fb6a36a24c992998bca2c3b /src/Text | |
| parent | fb4cea44b91e5c858c45ca67599ca7925bf159c8 (diff) | |
Typst reader: support quote element. (typst 0.9)
Diffstat (limited to 'src/Text')
| -rw-r--r-- | src/Text/Pandoc/Readers/Typst.hs | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/Text/Pandoc/Readers/Typst.hs b/src/Text/Pandoc/Readers/Typst.hs index 7c1b18b4e..b440884ca 100644 --- a/src/Text/Pandoc/Readers/Typst.hs +++ b/src/Text/Pandoc/Readers/Typst.hs @@ -30,7 +30,7 @@ import Typst ( parseTypst, evaluateTypst ) import Text.Pandoc.Error (PandocError(..)) import Text.Pandoc.Shared (tshow, blocksToInlines) import Control.Monad.Except (throwError) -import Control.Monad (MonadPlus (mplus), void, mzero) +import Control.Monad (MonadPlus (mplus), void, mzero, guard) import qualified Data.Foldable as F import qualified Data.Map as M import Data.Maybe (catMaybes, fromMaybe) @@ -170,6 +170,14 @@ blockHandlers = M.fromList lev <- getField "level" fields <|> pure 1 B.headerWith (fromMaybe "" mbident,[],[]) lev <$> pWithContents pInlines body) + ,("quote", \_ fields -> do + getField "block" fields >>= guard + body <- getField "body" fields >>= pWithContents pBlocks + attribution <- + ((\x -> B.para ("\x2104\xa0" <> x)) <$> + (getField "attribution" fields >>= pWithContents pInlines)) + <|> pure mempty + pure $ B.blockQuote $ body <> attribution) ,("list", \_ fields -> do children <- V.toList <$> getField "children" fields B.bulletList <$> mapM (pWithContents pBlocks) children) @@ -431,6 +439,10 @@ inlineHandlers = M.fromList ,("underline", \_ fields -> do body <- getField "body" fields 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) ,("link", \_ fields -> do dest <- getField "dest" fields src <- case dest of |
