git.iko.soy/typeable/pandoc
on master help sign in
Add block version of \textcolor
commitd9439808f2fe226aad027c8c9d0a38217a1e8c34 authorMarc Schreiber <marc.schreiber@fh-aachen.de> dateWed 3 May 2017, 12:00 (10 years ago) parent49336ee
2 files changed+26−7
src/Text/Pandoc/Readers/LaTeX.hs+15−7 test/command/textcolor.md+11
src/Text/Pandoc/Readers/LaTeX.hs+15−7
@@ -393,6 +393,8 @@ blockCommands = M.fromList $
393393 , ("graphicspath", graphicsPath)
394394 -- hyperlink
395395 , ("hypertarget", braced >> grouped block)
396+ -- textcolor
397+ , ("textcolor", blockTextcolor)
396398 ] ++ map ignoreBlocks
397399 -- these commands will be ignored unless --parse-raw is specified,
398400 -- in which case they will appear as raw latex blocks
@@ -414,6 +416,12 @@ blockCommands = M.fromList $
414416 , "pagebreak"
415417 ]
416418
419+blockTextcolor :: PandocMonad m => LP m Blocks
420+blockTextcolor = do
421+ skipopts
422+ color <- braced
423+ return <$> divWith ("",[],[("style","color: " ++ color)]) $ block
424+
417425graphicsPath :: PandocMonad m => LP m Blocks
418426graphicsPath = do
419427 ps <- bgroup *> (manyTill braced egroup)
@@ -681,7 +689,7 @@ inlineCommands = M.fromList $
681689 , ("textnhtt", ttfamily)
682690 , ("nhttfamily", ttfamily)
683691 -- textcolor
684− , ("textcolor", textcolor)
692+ , ("textcolor", inlineTextcolor)
685693 ] ++ map ignoreInlines
686694 -- these commands will be ignored unless --parse-raw is specified,
687695 -- in which case they will appear as raw latex blocks:
@@ -693,6 +701,12 @@ inlineCommands = M.fromList $
693701 , "pagebreak"
694702 ]
695703
704+inlineTextcolor :: PandocMonad m => LP m Inlines
705+inlineTextcolor = do
706+ skipopts
707+ color <- braced
708+ spanWith ("",[],[("style","color: " ++ color)]) <$> tok
709+
696710ttfamily :: PandocMonad m => LP m Inlines
697711ttfamily = (code . stringify . toList) <$> tok
698712
@@ -758,12 +772,6 @@ dosiunitx = do
758772 emptyOr160 unit,
759773 unit]
760774
761−textcolor :: PandocMonad m => LP m Inlines
762−textcolor = do
763− skipopts
764− color <- braced
765− spanWith ("",[],[("style","color: " ++ color)]) <$> tok
766−
767775lit :: String -> LP m Inlines
768776lit = pure . str
769777
test/command/textcolor.md+11
@@ -11,3 +11,14 @@
1111^D
1212[Para [Span ("",[],[("style","color: blue")]) [Str "Hello",Space,Strong [Str "World"]]]]
1313```
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+```