summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Schreiber <marc.schreiber@fh-aachen.de>2017-05-02 10:48:57 +0200
committerMarc Schreiber <marc.schreiber@fh-aachen.de>2017-05-02 10:48:57 +0200
commit49336ee6eeecc352e248d1262ea1b46070e00243 (patch)
treee088f12bb54d80cfe2efbbb0e31cc70011504094
parent022d58e02a6276aa830639ad641aae1542731bbe (diff)
Add basic \textcolor support to LaTeX reader
-rw-r--r--src/Text/Pandoc/Readers/LaTeX.hs8
-rw-r--r--test/command/textcolor.md13
2 files changed, 21 insertions, 0 deletions
diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs
index a54238206..6252293d7 100644
--- a/src/Text/Pandoc/Readers/LaTeX.hs
+++ b/src/Text/Pandoc/Readers/LaTeX.hs
@@ -680,6 +680,8 @@ inlineCommands = M.fromList $
, ("nohyphens", tok)
, ("textnhtt", ttfamily)
, ("nhttfamily", ttfamily)
+ -- textcolor
+ , ("textcolor", textcolor)
] ++ map ignoreInlines
-- these commands will be ignored unless --parse-raw is specified,
-- in which case they will appear as raw latex blocks:
@@ -756,6 +758,12 @@ 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
new file mode 100644
index 000000000..7719a1c6b
--- /dev/null
+++ b/test/command/textcolor.md
@@ -0,0 +1,13 @@
+```
+% pandoc -f latex -t native
+\textcolor{red}{Hello World}
+^D
+[Para [Span ("",[],[("style","color: red")]) [Str "Hello",Space,Str "World"]]]
+```
+
+```
+% pandoc -f latex -t native
+\textcolor{blue}{Hello \textbf{World}}
+^D
+[Para [Span ("",[],[("style","color: blue")]) [Str "Hello",Space,Strong [Str "World"]]]]
+```