Add basic \textcolor support to LaTeX reader

This commit is contained in:
Marc Schreiber 2017-05-02 10:48:57 +02:00
parent 022d58e02a
commit 49336ee6ee
2 changed files with 21 additions and 0 deletions

View file

@ -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

13
test/command/textcolor.md Normal file
View file

@ -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"]]]]
```