git.iko.soy/typeable/pandoc
on master help sign in
Add block version of \textcolor
d943980Marc Schreiber
src/Text/Pandoc/Readers/LaTeX.hs+15−7
@@ -393,6 +393,8 @@ blockCommands = M.fromList $
393 , ("graphicspath", graphicsPath)
393 , ("graphicspath", graphicsPath)
394 -- hyperlink
394 -- hyperlink
395 , ("hypertarget", braced >> grouped block)
395 , ("hypertarget", braced >> grouped block)
396+ -- textcolor
397+ , ("textcolor", blockTextcolor)
396 ] ++ map ignoreBlocks
398 ] ++ map ignoreBlocks
397 -- these commands will be ignored unless --parse-raw is specified,
399 -- these commands will be ignored unless --parse-raw is specified,
398 -- in which case they will appear as raw latex blocks
400 -- in which case they will appear as raw latex blocks
@@ -414,6 +416,12 @@ blockCommands = M.fromList $
414 , "pagebreak"
416 , "pagebreak"
415 ]
417 ]
416
418
419+blockTextcolor :: PandocMonad m => LP m Blocks
420+blockTextcolor = do
421+ skipopts
422+ color <- braced
423+ return <$> divWith ("",[],[("style","color: " ++ color)]) $ block
424+
417graphicsPath :: PandocMonad m => LP m Blocks
425graphicsPath :: PandocMonad m => LP m Blocks
418graphicsPath = do
426graphicsPath = do
419 ps <- bgroup *> (manyTill braced egroup)
427 ps <- bgroup *> (manyTill braced egroup)
@@ -681,7 +689,7 @@ inlineCommands = M.fromList $
681 , ("textnhtt", ttfamily)
689 , ("textnhtt", ttfamily)
682 , ("nhttfamily", ttfamily)
690 , ("nhttfamily", ttfamily)
683 -- textcolor
691 -- textcolor
684− , ("textcolor", textcolor)
692+ , ("textcolor", inlineTextcolor)
685 ] ++ map ignoreInlines
693 ] ++ map ignoreInlines
686 -- these commands will be ignored unless --parse-raw is specified,
694 -- these commands will be ignored unless --parse-raw is specified,
687 -- in which case they will appear as raw latex blocks:
695 -- in which case they will appear as raw latex blocks:
@@ -693,6 +701,12 @@ inlineCommands = M.fromList $
693 , "pagebreak"
701 , "pagebreak"
694 ]
702 ]
695
703
704+inlineTextcolor :: PandocMonad m => LP m Inlines
705+inlineTextcolor = do
706+ skipopts
707+ color <- braced
708+ spanWith ("",[],[("style","color: " ++ color)]) <$> tok
709+
696ttfamily :: PandocMonad m => LP m Inlines
710ttfamily :: PandocMonad m => LP m Inlines
697ttfamily = (code . stringify . toList) <$> tok
711ttfamily = (code . stringify . toList) <$> tok
698
712
@@ -758,12 +772,6 @@ dosiunitx = do
758 emptyOr160 unit,
772 emptyOr160 unit,
759 unit]
773 unit]
760
774
761−textcolor :: PandocMonad m => LP m Inlines
762−textcolor = do
763− skipopts
764− color <- braced
765− spanWith ("",[],[("style","color: " ++ color)]) <$> tok
766−
767lit :: String -> LP m Inlines
775lit :: String -> LP m Inlines
768lit = pure . str
776lit = pure . str
769
777
test/command/textcolor.md+11
@@ -11,3 +11,14 @@
11^D
11^D
12[Para [Span ("",[],[("style","color: blue")]) [Str "Hello",Space,Strong [Str "World"]]]]
12[Para [Span ("",[],[("style","color: blue")]) [Str "Hello",Space,Strong [Str "World"]]]]
13```
13```
14+
15+```
16+% pandoc -f latex -t native
17+\textcolor{orange}{
18+ \begin{itemize}
19+ \item Test
20+ \end{itemize}
21+}
22+^D
23+
24+```