Created
March 23, 2016 15:51
-
-
Save jamtur01/10b2fb4e190a67a5dbe8 to your computer and use it in GitHub Desktop.
Minipages filter for Pandoc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Text.Pandoc | |
import Text.Pandoc.JSON | |
main = toJSONFilter addMinipages' | |
addMinipages' :: Pandoc -> Pandoc | |
addMinipages' = bottomUp addMinipages | |
addMinipages :: [Block] -> [Block] | |
addMinipages (CodeBlock attr code : xs) | |
| not (beginsWithEndMinipage xs) = | |
[ RawBlock (Format "latex") "\\begin{minipage}{\\linewidth}" | |
, CodeBlock attr code | |
, RawBlock (Format "latex") "\\end{minipage}" ] | |
++ addMinipages xs | |
addMinipages (x:xs) = x : addMinipages xs | |
addMinipages [] = [] | |
beginsWithEndMinipage (RawBlock (Format "latex") "\\end{minipage}":_) = True | |
beginsWithEndMinipage _ = False |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment