summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Servall/WikiParser.hs13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/Servall/WikiParser.hs b/src/Servall/WikiParser.hs
index ec15e1c..2680fad 100644
--- a/src/Servall/WikiParser.hs
+++ b/src/Servall/WikiParser.hs
@@ -1,6 +1,7 @@
{-# LANGUAGE OverloadedStrings #-}
module Servall.WikiParser
( parseWikiTemplates
+ , wikiFilter
) where
import Control.Applicative ( (<|>) )
@@ -31,6 +32,10 @@ import qualified Data.Text as T
import Data.Text ( Text )
import GHC.Generics ( Generic )
import Servall.Types
+import Text.Pandoc.Definition ( Inline(..)
+ , Pandoc
+ )
+import Text.Pandoc.Generic ( topDown )
parseWikiTemplates :: Text -> Either String [WikiTemplate]
parseWikiTemplates = parseOnly wikiP
@@ -103,3 +108,11 @@ wikilinkP = do
beg <- string "[["
content <- T.pack <$> manyTill anyChar (string "]]")
return $ beg <> content <> "]]"
+
+wikiFilter :: Pandoc -> Pandoc
+wikiFilter = topDown fixUrl
+
+fixUrl :: Inline -> Inline
+fixUrl (Link attr label (url, "wikilink")) =
+ Link attr label ("wiki:" <> url, "")
+fixUrl x = x