Created
September 16, 2014 03:16
-
-
Save balachia/d836f8829aec61cb4b54 to your computer and use it in GitHub Desktop.
Pandoc filter that cleans up internal references to figures and tables.
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
{- | |
Pandoc filter that cleans up internal references to figures and tables. | |
It's an attempt to deal with: https://github.com/jgm/pandoc/issues/813 | |
Compile with: | |
ghc --make pandoc-internalref.hs | |
and use in pandoc with | |
--filter [PATH]/pandoc-internalref | |
-} | |
module Main where | |
import Text.Pandoc.JSON | |
import Data.List | |
main = toJSONFilter makeref | |
makeref :: Inline -> [Inline] | |
makeref (Link txt ('#':ident, x)) | |
| Just subident <- stripPrefix "fig:" ident = reflink | |
| Just subident <- stripPrefix "tab:" ident = reflink | |
where reflink = [Link [RawInline (Format "latex") ("\\ref*{" ++ ident ++ "}")] ("#" ++ ident, x)] | |
makeref x = [x] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment