From d9439808f2fe226aad027c8c9d0a38217a1e8c34 Mon Sep 17 00:00:00 2001 From: Marc Schreiber Date: Wed, 3 May 2017 12:00:30 +0200 Subject: Add block version of \textcolor --- src/Text/Pandoc/Readers/LaTeX.hs | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'src/Text') diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs index 6252293d7..1c1aa4c62 100644 --- a/src/Text/Pandoc/Readers/LaTeX.hs +++ b/src/Text/Pandoc/Readers/LaTeX.hs @@ -393,6 +393,8 @@ blockCommands = M.fromList $ , ("graphicspath", graphicsPath) -- hyperlink , ("hypertarget", braced >> grouped block) + -- textcolor + , ("textcolor", blockTextcolor) ] ++ map ignoreBlocks -- these commands will be ignored unless --parse-raw is specified, -- in which case they will appear as raw latex blocks @@ -414,6 +416,12 @@ blockCommands = M.fromList $ , "pagebreak" ] +blockTextcolor :: PandocMonad m => LP m Blocks +blockTextcolor = do + skipopts + color <- braced + return <$> divWith ("",[],[("style","color: " ++ color)]) $ block + graphicsPath :: PandocMonad m => LP m Blocks graphicsPath = do ps <- bgroup *> (manyTill braced egroup) @@ -681,7 +689,7 @@ inlineCommands = M.fromList $ , ("textnhtt", ttfamily) , ("nhttfamily", ttfamily) -- textcolor - , ("textcolor", textcolor) + , ("textcolor", inlineTextcolor) ] ++ map ignoreInlines -- these commands will be ignored unless --parse-raw is specified, -- in which case they will appear as raw latex blocks: @@ -693,6 +701,12 @@ inlineCommands = M.fromList $ , "pagebreak" ] +inlineTextcolor :: PandocMonad m => LP m Inlines +inlineTextcolor = do + skipopts + color <- braced + spanWith ("",[],[("style","color: " ++ color)]) <$> tok + ttfamily :: PandocMonad m => LP m Inlines ttfamily = (code . stringify . toList) <$> tok @@ -758,12 +772,6 @@ dosiunitx = do emptyOr160 unit, unit] -textcolor :: PandocMonad m => LP m Inlines -textcolor = do - skipopts - color <- braced - spanWith ("",[],[("style","color: " ++ color)]) <$> tok - lit :: String -> LP m Inlines lit = pure . str -- cgit v1.2.3