[xmonad] [PATCH] Update GenerateManpage to new Pandoc API

Adam Sjøgren asjo at koldfront.dk
Tue Jul 14 11:43:44 UTC 2020


Pandoc 2.8.0 changed the API for templates:

 · https://pandoc.org/releases.html#pandoc-2.8-2019-11-22
---
Debian unstable just got Pandoc 2.8.1, and the API for templates have
changed. This patch is my attempt to adapt GenerateManPage to the change;
the generated .1 and .html files look correct to me.

 util/GenerateManpage.hs | 11 +++++++----
 xmonad.cabal            |  2 +-
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/util/GenerateManpage.hs b/util/GenerateManpage.hs
index 7d0cd99..18f8c80 100644
--- a/util/GenerateManpage.hs
+++ b/util/GenerateManpage.hs
@@ -9,6 +9,7 @@
 -- Public License version 2 or later.
 
 import Control.Monad.IO.Class (liftIO)
+import Control.Error.Util (hush)
 import Data.Char
 import Data.List
 import qualified Data.Text as T
@@ -30,14 +31,16 @@ main = do
             . lines
             $ markdownSource
 
-        manTemplate <- getDefaultTemplate "man"
-        manBody <- writeMan def { writerTemplate = Just manTemplate } parsed
+        manTemplate <- getDefaultTemplate (T.pack "man")
+        compiledManTemplate <- compileTemplate "" manTemplate
+        manBody <- writeMan def { writerTemplate = hush compiledManTemplate } parsed
         liftIO $ TIO.writeFile "./man/xmonad.1" $ manBody
         liftIO $ putStrLn "Documentation created: man/xmonad.1"
 
-        htmltemplate <- getDefaultTemplate "html"
+        htmltemplate <- getDefaultTemplate (T.pack "html")
+        compiledHtmlTemplate <- compileTemplate "" htmltemplate
         htmlBody <- writeHtml5String def
-                                     { writerTemplate = Just htmltemplate
+                                     { writerTemplate = hush compiledHtmlTemplate
                                      , writerTableOfContents = True }
                                      parsed
         liftIO $ TIO.writeFile "./man/xmonad.1.html" htmlBody
diff --git a/xmonad.cabal b/xmonad.cabal
index c35b1ee..3f5810c 100644
--- a/xmonad.cabal
+++ b/xmonad.cabal
@@ -99,7 +99,7 @@ executable generatemanpage
   hs-source-dirs: util
 
   if flag(generatemanpage)
-    build-depends: base, pandoc >= 2, regex-posix, text
+    build-depends: base, pandoc >= 2.8.0, regex-posix, text
   else
     buildable: False
 
-- 
2.28.0.rc0

-- 
 "there one more pillow I could hold at night               Adam Sjøgren
  but it's breaking my heart it's making me cry"       asjo at koldfront.dk



More information about the xmonad mailing list