diff options
-rw-r--r-- | app/Main.hs | 5 | ||||
-rw-r--r-- | src/Servall/WikiParser.hs | 20 |
2 files changed, 17 insertions, 8 deletions
diff --git a/app/Main.hs b/app/Main.hs index 74a03eb..ea64179 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -199,10 +199,13 @@ app = serve api server api :: Proxy API api = Proxy +servall :: ServerConfig -> IO () +servall config = run (configPort config) app + main :: IO () main = do config <- execParser opts - run (configPort config) app + servall config where opts = info (optParser <**> helper) diff --git a/src/Servall/WikiParser.hs b/src/Servall/WikiParser.hs index b5188a4..7053197 100644 --- a/src/Servall/WikiParser.hs +++ b/src/Servall/WikiParser.hs @@ -206,21 +206,27 @@ fixHeaderTemplates (Pandoc m blocks) = Pandoc m (go [] blocks) where go acc (Header level (x, y, attr) content : bs) = let (raws, rest) = span isTemplateBlock bs in go - (acc ++ [Header level (x, y, attr ++ concatMap infobox' raws) content] + ( acc + ++ [ Header + level + ( x + , y + , attr ++ infobox (T.concat (map templateFromRawBlock raws)) + ) + content + ] ) rest go acc (b : bs) = go (acc ++ [b]) bs - infobox' :: Block -> [(Text, Text)] - infobox' (RawBlock (Format "mediawiki") temp) = - fromRight [] - $ (\wt -> if isInfobox wt then filterNameValues (wtArgs wt) else []) - <$> parseOnly templateP temp - infobox' _ = [] isTemplateBlock :: Block -> Bool isTemplateBlock (RawBlock (Format "mediawiki") temp) = True isTemplateBlock _ = False +templateFromRawBlock :: Block -> Text +templateFromRawBlock (RawBlock (Format "mediawiki") temp) = temp +templateFromRawBlock _ = "" + fixInline :: Inline -> Inline fixInline (Link attr label (url, "wikilink")) = Link attr label ("wiki:" <> url, "") |