aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Text/Pandoc/Readers/LaTeX.hs22
-rw-r--r--test/command/textcolor.md11
2 files changed, 26 insertions, 7 deletions
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
diff --git a/test/command/textcolor.md b/test/command/textcolor.md
index 7719a1c6b..013e55d67 100644
--- a/test/command/textcolor.md
+++ b/test/command/textcolor.md
@@ -11,3 +11,14 @@
^D
[Para [Span ("",[],[("style","color: blue")]) [Str "Hello",Space,Strong [Str "World"]]]]
```
+
+```
+% pandoc -f latex -t native
+\textcolor{orange}{
+ \begin{itemize}
+ \item Test
+ \end{itemize}
+}
+^D
+
+```