aboutsummaryrefslogtreecommitdiff
path: root/src/Text
diff options
context:
space:
mode:
authorMarc Schreiber <marc.schreiber@fh-aachen.de>2017-06-01 09:09:27 +0200
committerMarc Schreiber <marc.schreiber@fh-aachen.de>2017-06-01 09:50:51 +0200
commit181c56d4003aa83abed23b95a452c4890aa3797c (patch)
tree3177546a658de48869d9732ac19d411b08c3d552 /src/Text
parentb1d0c61f2dd5e89f4cbc8f4d868704bf681a7086 (diff)
downloadpandoc-181c56d4003aa83abed23b95a452c4890aa3797c.tar.gz
Add \colorbox support
Diffstat (limited to 'src/Text')
-rw-r--r--src/Text/Pandoc/Readers/LaTeX.hs22
1 files changed, 12 insertions, 10 deletions
diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs
index 6b44df468..1d13f7107 100644
--- a/src/Text/Pandoc/Readers/LaTeX.hs
+++ b/src/Text/Pandoc/Readers/LaTeX.hs
@@ -393,8 +393,9 @@ blockCommands = M.fromList $
, ("graphicspath", graphicsPath)
-- hyperlink
, ("hypertarget", braced >> grouped block)
- -- textcolor
- , ("textcolor", blockTextcolor)
+ -- 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
@@ -416,11 +417,11 @@ blockCommands = M.fromList $
, "pagebreak"
]
-blockTextcolor :: PandocMonad m => LP m Blocks
-blockTextcolor = do
+coloredBlock :: PandocMonad m => String -> LP m Blocks
+coloredBlock stylename = do
skipopts
color <- braced
- let constructor = divWith ("",[],[("style","color: " ++ color)])
+ let constructor = divWith ("",[],[("style",stylename ++ ": " ++ color)])
inlineContents <|> constructor <$> blockContents
where inlineContents = do
ils <- grouped inline
@@ -694,8 +695,9 @@ inlineCommands = M.fromList $
, ("nohyphens", tok)
, ("textnhtt", ttfamily)
, ("nhttfamily", ttfamily)
- -- textcolor
- , ("textcolor", inlineTextcolor)
+ -- LaTeX colors
+ , ("textcolor", coloredInline "color")
+ , ("colorbox", coloredInline "background-color")
] ++ map ignoreInlines
-- these commands will be ignored unless --parse-raw is specified,
-- in which case they will appear as raw latex blocks:
@@ -707,11 +709,11 @@ inlineCommands = M.fromList $
, "pagebreak"
]
-inlineTextcolor :: PandocMonad m => LP m Inlines
-inlineTextcolor = do
+coloredInline :: PandocMonad m => String -> LP m Inlines
+coloredInline stylename = do
skipopts
color <- braced
- spanWith ("",[],[("style","color: " ++ color)]) <$> tok
+ spanWith ("",[],[("style",stylename ++ ": " ++ color)]) <$> tok
ttfamily :: PandocMonad m => LP m Inlines
ttfamily = (code . stringify . toList) <$> tok