Created
February 20, 2015 16:06
-
-
Save terryburton/1da92ca900f49d9ad3df to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/usr/bin/env runhaskell | |
import Text.Pandoc.JSON | |
import Data.Char | |
main = toJSONFilter rewritewikilinks | |
rewritewikilinks :: Inline -> [Inline] | |
rewritewikilinks ( Link txt ('#':url,title) ) = [ ( Link txt ("#"++url,title) ) ] | |
rewritewikilinks ( Link txt ('h':'t':'t':'p':':':url,title) ) = [ ( Link txt ("http:"++url,title) ) ] | |
rewritewikilinks ( Link txt ('h':'t':'t':'p':'s':':':url,title) ) = [ ( Link txt ("https:"++url,title) ) ] | |
rewritewikilinks ( Link txt (url,title) ) = [ ( Link txt ("#" ++ map toLower url,title) ) ] | |
rewritewikilinks x = [x] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment