[PATCH] Update GenerateManpage to new Pandoc API

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@koldfront.dk

One of the Debian developers maintaining the Pandoc package remarked:
I no longer use xmonad myself, but remember frm when I did that the biggest frustration was that you'd need a working _development_ environment, and each time Haskell packages went out of sync (using Debian unstable), xmonad was one of the last ones to get back in sync. I imagine that a decoupling from Pandoc might change that.
suggesting to change GenerateManPage to use cmark-hs instead: "Output in HTML, groff man, LaTeX, CommonMark, and a custom XML format is supported." · https://github.com/jgm/cmark-hs as cmark-hs does not have the amount of dependencies that Pandoc has (6 vs. 127, in Debian). What do you all think? I will be happy to take a stab at changing GenerateManPage to use cmark instead of Pandoc, if it sounds useful to you. Best regards, Adam -- "Written in water, yeah, it's bound to disappear Adam Sjøgren Written in water, Down the crater of your ear" asjo@koldfront.dk

This should probably be submitted as a PR.
On 7/14/20, Adam Sjøgren
One of the Debian developers maintaining the Pandoc package remarked:
I no longer use xmonad myself, but remember frm when I did that the biggest frustration was that you'd need a working _development_ environment, and each time Haskell packages went out of sync (using Debian unstable), xmonad was one of the last ones to get back in sync. I imagine that a decoupling from Pandoc might change that.
suggesting to change GenerateManPage to use cmark-hs instead:
"Output in HTML, groff man, LaTeX, CommonMark, and a custom XML format is supported."
· https://github.com/jgm/cmark-hs
as cmark-hs does not have the amount of dependencies that Pandoc has (6 vs. 127, in Debian).
What do you all think?
I will be happy to take a stab at changing GenerateManPage to use cmark instead of Pandoc, if it sounds useful to you.
Best regards,
Adam
-- "Written in water, yeah, it's bound to disappear Adam Sjøgren Written in water, Down the crater of your ear" asjo@koldfront.dk
_______________________________________________ xmonad mailing list xmonad@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/xmonad
-- brandon s allbery kf8nh allbery.b@gmail.com

Brandon writes:
On 7/14/20, Adam Sjøgren
wrote:
I will be happy to take a stab at changing GenerateManPage to use cmark instead of Pandoc, if it sounds useful to you.
This should probably be submitted as a PR.
Yes, I just wanted to check if the general consensus is that it would be a worthwhile change, before spending time on it. Best regards, Adam -- "Referring to glorified travelling salesmen Adam Sjøgren as ``road warriors'' is an insult to asjo@koldfront.dk gun-toting nomadic mercenaries everywhere."

Adam writes:
One of the Debian developers maintaining the Pandoc package remarked:
I no longer use xmonad myself, but remember frm when I did that the biggest frustration was that you'd need a working _development_ environment, and each time Haskell packages went out of sync (using Debian unstable), xmonad was one of the last ones to get back in sync. I imagine that a decoupling from Pandoc might change that.
[...]
I will be happy to take a stab at changing GenerateManPage to use cmark instead of Pandoc, if it sounds useful to you.
I have tried doing so now - Pandoc does more than cmark, so it's more intrusive than I would have liked. The most prominent downside, I think, is the lack of table-of-contents generation. The changes are on the use-cmark branch in this repository: · https://koldfront.dk/git/xmonad/ commit d5b8d08¹ (code, templates) and 9eb731f² (resulting generated pages respectively. Best regards, Adam ¹ https://koldfront.dk/git/xmonad/commit/?id=d5b8d08 ² https://koldfront.dk/git/xmonad/commit/?id=9eb731f -- "A splendid time is guaranteed for all" Adam Sjøgren asjo@koldfront.dk

Your messages are getting autofiled as spam here, so I wonder if
anyone else is seeing them.
On 7/16/20, Adam Sjøgren
Adam writes:
One of the Debian developers maintaining the Pandoc package remarked:
I no longer use xmonad myself, but remember frm when I did that the biggest frustration was that you'd need a working _development_ environment, and each time Haskell packages went out of sync (using Debian unstable), xmonad was one of the last ones to get back in sync. I imagine that a decoupling from Pandoc might change that.
[...]
I will be happy to take a stab at changing GenerateManPage to use cmark instead of Pandoc, if it sounds useful to you.
I have tried doing so now - Pandoc does more than cmark, so it's more intrusive than I would have liked.
The most prominent downside, I think, is the lack of table-of-contents generation.
The changes are on the use-cmark branch in this repository:
· https://koldfront.dk/git/xmonad/
commit d5b8d08¹ (code, templates) and 9eb731f² (resulting generated pages respectively.
Best regards,
Adam
¹ https://koldfront.dk/git/xmonad/commit/?id=d5b8d08 ² https://koldfront.dk/git/xmonad/commit/?id=9eb731f
-- "A splendid time is guaranteed for all" Adam Sjøgren asjo@koldfront.dk
_______________________________________________ xmonad mailing list xmonad@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/xmonad
-- brandon s allbery kf8nh allbery.b@gmail.com

Hi, On Thu, Jul 16, 2020 at 07:01:36AM +0200, Adam Sjøgren wrote:
Adam writes:
One of the Debian developers maintaining the Pandoc package remarked:
I no longer use xmonad myself, but remember frm when I did that the biggest frustration was that you'd need a working _development_ environment, and each time Haskell packages went out of sync (using Debian unstable), xmonad was one of the last ones to get back in sync. I imagine that a decoupling from Pandoc might change that.
[...]
I will be happy to take a stab at changing GenerateManPage to use cmark instead of Pandoc, if it sounds useful to you.
I have tried doing so now - Pandoc does more than cmark, so it's more intrusive than I would have liked. [...]
I tried an alternative approach: drop the Haskell dependency on Pandoc/cmark entirely and use the command-line interface, which I believe is more stable than the Haskell library interface. I implemented that here: https://github.com/xmonad/xmonad/pull/260 Do you folks think this is a viable option or are there any pitfalls that I'm not seeing? Any feedback highly appreciated. -- Tomáš Janoušek, a.k.a. Pivník, a.k.a. Liskni_si, https://work.lisk.in/
participants (3)
-
Adam Sjøgren
-
Brandon Allbery
-
Tomas Janousek