Created
July 10, 2018 06:59
-
-
Save lierdakil/c1bd46e057e886a6c39ef58d5b47e4e9 to your computer and use it in GitHub Desktop.
Pandoc filter to replace internal links with page references
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.JSON | |
import Data.List | |
main :: IO () | |
main = toJSONFilter myfilter | |
myfilter (Link _ text (url, _)) | |
| '#':ref <- url | |
= Span nullAttr $ | |
text <> | |
[ Space | |
, Str "(page" | |
, Space | |
, RawInline (Format "latex") ("\\pageref{" <> ref <> "}") | |
, Str ")" | |
] | |
myfilter x = x |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment