Created
December 7, 2014 00:53
-
-
Save mpickering/f1718fcdc4c56273ed52 to your computer and use it in GitHub Desktop.
LaTeX Argument Parser
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
{-# LANGUAGE ViewPatterns #-} | |
module InTex where | |
import Text.Pandoc.JSON | |
import Text.Pandoc | |
import Data.List | |
main :: IO () | |
main = toJSONFilter readFootnotes | |
readFootnotes :: Inline -> Inline | |
readFootnotes (footnoteText -> Just args) = RawInline (Format "tex") res | |
where | |
parsed = writeLaTeX def . readMarkdown def | |
res = fnString ++ parsed args ++ "}" | |
readFootnotes i = i | |
fnString = "\\footnotetext{" | |
footnoteText :: Inline -> Maybe String | |
footnoteText (RawInline (Format "tex") s) = | |
if fnString `isPrefixOf` s | |
then Just . init . drop (length fnString) $ s -- Remove closing brace | |
else Nothing | |
footnoteText x = Nothing | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment