From 68262c59ed8abf9a96574cd7cedabce594169fe5 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Mon, 2 Sep 2019 11:05:28 -0700 Subject: [PATCH] ;shake manuals: workaround to avoid ANSI codes in plaintext help This seems to be a groff bug, as of 1.22.3 & 1.22.4. It always calls grotty with no flags, even with -c, so grotty adds ANSI/SGR escape codes in the -Tascii output. Now instead of groff, we call the lower level commands directly, requiring tbl, eqn, troff, grotty to be in PATH and compatible. Not ideal. [ci skip] --- Shake.hs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Shake.hs b/Shake.hs index ce24ecf7d..43401848d 100755 --- a/Shake.hs +++ b/Shake.hs @@ -98,8 +98,8 @@ usage = unlines ,"See also: make help" ] -groff = "groff" -makeinfo = "makeinfo" +-- groff = "groff -c" ++ " -Wall" -- see "groff" below +makeinfo = "makeinfo" ++ " --no-warn" -- silence makeinfo warnings - comment out to see them pandoc = "pandoc" -- Must support both BSD sed and GNU sed. Tips: @@ -285,7 +285,13 @@ main = do txtmanuals |%> \out -> do -- hledger/hledger.txt let src = manualNameToManpageName $ dropExtension out need [src] - cmd Shell groff "-t -e -mandoc -Tascii" src "| col -bx >" out -- http://www.tldp.org/HOWTO/Man-Page/q10.html + -- cmd Shell groff "-t -e -mandoc -Tascii" src "| col -b >" out -- http://www.tldp.org/HOWTO/Man-Page/q10.html + -- Workaround: groff 1.22.4 always calls grotty in a way that adds ANSI/SGR escape codes. + -- (groff -c is supposed to switch those to backspaces, which we could + -- remove with col -b, but it doesn't as can be seen with groff -V.) + -- To get plain text, we run groff's lower-level commands (from -V) and add -cbuo. + -- -Wall silences most troff warnings, remove to see them + cmd Shell "tbl" src "| eqn -Tascii | troff -Wall -mandoc -Tascii | grotty -cbuo >" out -- Generate Info manuals suitable for viewing with info. phony "infomanuals" $ need infomanuals