diff options
author | Yuchen Pei <hi@ypei.me> | 2022-09-14 10:40:41 +1000 |
---|---|---|
committer | Yuchen Pei <hi@ypei.me> | 2022-09-14 10:40:41 +1000 |
commit | 7b28a1cdf2c0b5f431377f218720698e8dfdbb47 (patch) | |
tree | 0262e7d52c18eba4232df885f9ced43d1fea9329 /src/Servall/WikiParser.hs | |
parent | 8ed506f22238846da39378f412eb251ad39034b3 (diff) |
Prepending level 1 heading
Diffstat (limited to 'src/Servall/WikiParser.hs')
-rw-r--r-- | src/Servall/WikiParser.hs | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/Servall/WikiParser.hs b/src/Servall/WikiParser.hs index 2680fad..e284a3b 100644 --- a/src/Servall/WikiParser.hs +++ b/src/Servall/WikiParser.hs @@ -32,8 +32,9 @@ 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.Definition ( Block(..) + , Inline(..) + , Pandoc(..) ) import Text.Pandoc.Generic ( topDown ) @@ -109,8 +110,12 @@ wikilinkP = do content <- T.pack <$> manyTill anyChar (string "]]") return $ beg <> content <> "]]" -wikiFilter :: Pandoc -> Pandoc -wikiFilter = topDown fixUrl +wikiFilter :: Text -> Pandoc -> Pandoc +wikiFilter title = insertHeader title . topDown fixUrl + +insertHeader :: Text -> Pandoc -> Pandoc +insertHeader title (Pandoc m bs) = + Pandoc m (Header 1 ("", [], []) [Str title] : bs) fixUrl :: Inline -> Inline fixUrl (Link attr label (url, "wikilink")) = |