diff options
author | John MacFarlane <jgm@berkeley.edu> | 2017-07-25 11:42:10 +0200 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2017-07-25 11:42:10 +0200 |
commit | 2b039acb4ec6af8792c4e212822d3fe359633d16 (patch) | |
tree | f73c000a3d3da3920c9965416b56c88dea11247f /src/Text/Pandoc | |
parent | 862d92f09a394a318a554fc7e5ec1b4ab0da1a2a (diff) | |
parent | f93d7d06f688654137b5e728601441881ff5aebf (diff) | |
download | pandoc-2b039acb4ec6af8792c4e212822d3fe359633d16.tar.gz |
Merge branch 'textcolor-support' of https://github.com/schrieveslaach/pandoc into schrieveslaach-textcolor-support
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r-- | src/Text/Pandoc/Readers/LaTeX.hs | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs index 494f532a1..5877bbbe1 100644 --- a/src/Text/Pandoc/Readers/LaTeX.hs +++ b/src/Text/Pandoc/Readers/LaTeX.hs @@ -1311,6 +1311,9 @@ inlineCommands = M.fromList $ , ("nohyphens", tok) , ("textnhtt", ttfamily) , ("nhttfamily", ttfamily) + -- LaTeX colors + , ("textcolor", coloredInline "color") + , ("colorbox", coloredInline "background-color") -- fontawesome , ("faCheck", lit "\10003") , ("faClose", lit "\10007") @@ -1331,6 +1334,12 @@ ifstrequal = do else getInput >>= setInput . (ifnotequal ++) return mempty +coloredInline :: PandocMonad m => String -> LP m Inlines +coloredInline stylename = do + skipopts + color <- braced + spanWith ("",[],[("style",stylename ++ ": " ++ toksToString color)]) <$> tok + ttfamily :: PandocMonad m => LP m Inlines ttfamily = (code . stringify . toList) <$> tok @@ -1709,6 +1718,9 @@ blockCommands = M.fromList $ , ("graphicspath", graphicsPath) -- hyperlink , ("hypertarget", try $ braced >> grouped block) + -- LaTeX colors + , ("textcolor", coloredBlock "color") + , ("colorbox", coloredBlock "background-color") ] @@ -1872,6 +1884,14 @@ addImageCaption = walkM go Nothing -> Image attr alt (src,tit) go x = return x +coloredBlock :: PandocMonad m => String -> LP m Blocks +coloredBlock stylename = try $ do + skipopts + color <- braced + notFollowedBy (grouped inline) + let constructor = divWith ("",[],[("style",stylename ++ ": " ++ toksToString color)]) + constructor <$> grouped block + graphicsPath :: PandocMonad m => LP m Blocks graphicsPath = do ps <- map toksToString <$> (bgroup *> manyTill braced egroup) |