From c35eed55065316fc1a35b7ac3e32ca22f9df91f2 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Wed, 29 May 2024 10:29:26 -1000 Subject: [PATCH] imp: cli: fix help headings highlighting --- hledger/Hledger/Cli/CliOptions.hs | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/hledger/Hledger/Cli/CliOptions.hs b/hledger/Hledger/Cli/CliOptions.hs index 8f0609ecb..bceebf510 100644 --- a/hledger/Hledger/Cli/CliOptions.hs +++ b/hledger/Hledger/Cli/CliOptions.hs @@ -466,18 +466,20 @@ highlightHelp | not useColorOnStdout = id | otherwise = unlines . zipWith (curry f) [1..] . lines where - f (n,s) - | n==1 = bold s - | any (`isPrefixOf` s) [ -- keep synced with Hledger.Cli.mainmode - "General input flags" - ,"General reporting flags" - ,"General help flags" - ,"Flags" - ,"General flags" - ,"Examples" - ] = bold s - | otherwise = s - + f (n,l) + | n==1 = bold l + | isHelpHeading l = bold l + | otherwise = l + -- keep synced with Hledger.Cli.mainmode: + isHelpHeading l = isAlphaNum (headDef ' ' l) && (lastDef ' ' l == ':') + -- any s (`isPrefixOf` s) [ + -- "General input flags" + -- ,"General reporting flags" + -- ,"General help flags" + -- ,"Flags" + -- ,"General flags" + -- ,"Examples" + -- ] -- | Get the most appropriate documentation topic for a mode. -- Currently, that is either the hledger, hledger-ui or hledger-web -- manual.