Skip to content
Permalink
Browse files

;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]
  • Loading branch information...
simonmichael committed Sep 2, 2019
1 parent 2a2cec4 commit 68262c59ed8abf9a96574cd7cedabce594169fe5
Showing with 9 additions and 3 deletions.
  1. +9 −3 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

0 comments on commit 68262c5

Please sign in to comment.
You can’t perform that action at this time.