git.iko.soy/typeable/pandoc
on master help sign in
Add basic \textcolor support to LaTeX reader
commit49336ee6eeecc352e248d1262ea1b46070e00243 authorMarc Schreiber <marc.schreiber@fh-aachen.de> dateTue 2 May 2017, 10:48 (10 years ago) parent022d58e
2 files changed+21
src/Text/Pandoc/Readers/LaTeX.hs+8 test/command/textcolor.md+13
src/Text/Pandoc/Readers/LaTeX.hs+8
@@ -680,6 +680,8 @@ inlineCommands = M.fromList $
680680 , ("nohyphens", tok)
681681 , ("textnhtt", ttfamily)
682682 , ("nhttfamily", ttfamily)
683+ -- textcolor
684+ , ("textcolor", textcolor)
683685 ] ++ map ignoreInlines
684686 -- these commands will be ignored unless --parse-raw is specified,
685687 -- in which case they will appear as raw latex blocks:
@@ -756,6 +758,12 @@ dosiunitx = do
756758 emptyOr160 unit,
757759 unit]
758760
761+textcolor :: PandocMonad m => LP m Inlines
762+textcolor = do
763+ skipopts
764+ color <- braced
765+ spanWith ("",[],[("style","color: " ++ color)]) <$> tok
766+
759767lit :: String -> LP m Inlines
760768lit = pure . str
761769
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+```