aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Readers
diff options
context:
space:
mode:
Diffstat (limited to 'src/Text/Pandoc/Readers')
-rw-r--r--src/Text/Pandoc/Readers/LaTeX.hs24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs
index 1ac872933..17fb48548 100644
--- a/src/Text/Pandoc/Readers/LaTeX.hs
+++ b/src/Text/Pandoc/Readers/LaTeX.hs
@@ -392,6 +392,9 @@ blockCommands = M.fromList $
, ("graphicspath", graphicsPath)
-- hyperlink
, ("hypertarget", braced >> grouped block)
+ -- LaTeX colors
+ , ("textcolor", coloredBlock "color")
+ , ("colorbox", coloredBlock "background-color")
] ++ map ignoreBlocks
-- these commands will be ignored unless --parse-raw is specified,
-- in which case they will appear as raw latex blocks
@@ -413,6 +416,18 @@ blockCommands = M.fromList $
, "pagebreak"
]
+coloredBlock :: PandocMonad m => String -> LP m Blocks
+coloredBlock stylename = do
+ skipopts
+ color <- braced
+ let constructor = divWith ("",[],[("style",stylename ++ ": " ++ color)])
+ inlineContents <|> constructor <$> blockContents
+ where inlineContents = do
+ ils <- grouped inline
+ rest <- inlines
+ return (para (ils <> rest))
+ blockContents = grouped block
+
graphicsPath :: PandocMonad m => LP m Blocks
graphicsPath = do
ps <- bgroup *> (manyTill braced egroup)
@@ -682,6 +697,9 @@ inlineCommands = M.fromList $
, ("nohyphens", tok)
, ("textnhtt", ttfamily)
, ("nhttfamily", ttfamily)
+ -- LaTeX colors
+ , ("textcolor", coloredInline "color")
+ , ("colorbox", coloredInline "background-color")
-- fontawesome
, ("faCheck", lit "\10003")
, ("faClose", lit "\10007")
@@ -696,6 +714,12 @@ inlineCommands = M.fromList $
, "pagebreak"
]
+coloredInline :: PandocMonad m => String -> LP m Inlines
+coloredInline stylename = do
+ skipopts
+ color <- braced
+ spanWith ("",[],[("style",stylename ++ ": " ++ color)]) <$> tok
+
ttfamily :: PandocMonad m => LP m Inlines
ttfamily = (code . stringify . toList) <$> tok