Skip to content

Instantly share code, notes, and snippets.

@puffnfresh
Created May 31, 2020 01:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save puffnfresh/3bf96f282241c61ce486076b720045a3 to your computer and use it in GitHub Desktop.
Save puffnfresh/3bf96f282241c61ce486076b720045a3 to your computer and use it in GitHub Desktop.
#!/usr/bin/env nix-shell
#!nix-shell -p "haskellPackages.ghcWithPackages (p: [ p.pandoc p.pandoc-types ])" -i runhaskell
{-# LANGUAGE OverloadedStrings #-}
import Text.Pandoc.JSON
import Text.Pandoc.Shared (tshow)
import Data.Text as T
main :: IO ()
main = toJSONFilter latexBlock
latexBlock :: Block -> Block
latexBlock x@(CodeBlock (_, l, _) b) =
if l == ["agda"]
then RawBlock "latex" (T.unlines ["\\begin{code}", b, "\\end{code}"])
else x
latexBlock x = x
pandoc Naturals.lagda.md -t latex -f gfm -F agda-blocks.hs
@puffnfresh
Copy link
Author

Requires specifying Agda as the language in the Markdown:

```agda
example
```

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment