Add basic \textcolor support to LaTeX reader
This commit is contained in:
parent
022d58e02a
commit
49336ee6ee
2 changed files with 21 additions and 0 deletions
|
@ -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
13
test/command/textcolor.md
Normal 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"]]]]
|
||||
```
|
Loading…
Add table
Reference in a new issue