git.iko.soy/typeable/pandoc
on master help sign in
Add basic \textcolor support to LaTeX reader
49336eeMarc Schreiber
src/Text/Pandoc/Readers/LaTeX.hs+8
@@ -680,6 +680,8 @@ inlineCommands = M.fromList $
680 , ("nohyphens", tok)
680 , ("nohyphens", tok)
681 , ("textnhtt", ttfamily)
681 , ("textnhtt", ttfamily)
682 , ("nhttfamily", ttfamily)
682 , ("nhttfamily", ttfamily)
683+ -- textcolor
684+ , ("textcolor", textcolor)
683 ] ++ map ignoreInlines
685 ] ++ map ignoreInlines
684 -- these commands will be ignored unless --parse-raw is specified,
686 -- these commands will be ignored unless --parse-raw is specified,
685 -- in which case they will appear as raw latex blocks:
687 -- in which case they will appear as raw latex blocks:
@@ -756,6 +758,12 @@ dosiunitx = do
756 emptyOr160 unit,
758 emptyOr160 unit,
757 unit]
759 unit]
758
760
761+textcolor :: PandocMonad m => LP m Inlines
762+textcolor = do
763+ skipopts
764+ color <- braced
765+ spanWith ("",[],[("style","color: " ++ color)]) <$> tok
766+
759lit :: String -> LP m Inlines
767lit :: String -> LP m Inlines
760lit = pure . str
768lit = pure . str
761
769
test/command/textcolor.mdnew file+13
@@ -0,0 +1,13 @@
1+```
2+% pandoc -f latex -t native
3+\textcolor{red}{Hello World}
4+^D
5+[Para [Span ("",[],[("style","color: red")]) [Str "Hello",Space,Str "World"]]]
6+```
7+
8+```
9+% pandoc -f latex -t native
10+\textcolor{blue}{Hello \textbf{World}}
11+^D
12+[Para [Span ("",[],[("style","color: blue")]) [Str "Hello",Space,Strong [Str "World"]]]]
13+```