@@ -13,7 +13,8 @@ import Data.Aeson ((.=))
13
13
import qualified Data.Aeson.Types as Json
14
14
import System.IO (Handle )
15
15
import Text.PrettyPrint.ANSI.Leijen
16
- ( Doc , (<>) , displayS , displayIO , dullcyan , fillSep , hardline , renderPretty , text
16
+ ( Doc , SimpleDoc (.. ), (<>) , displayS , displayIO , dullcyan , fillSep
17
+ , hardline , renderPretty , text
17
18
)
18
19
19
20
import qualified Reporting.Region as R
@@ -83,15 +84,38 @@ messageBar tag location =
83
84
-- RENDER DOCS
84
85
85
86
87
+ toHandle :: Handle -> String -> R. Region -> Report -> String -> IO ()
88
+ toHandle handle location region rprt source =
89
+ displayIO
90
+ handle
91
+ (renderPretty 1 80 (toDoc location region rprt source))
92
+
93
+
86
94
toString :: String -> R. Region -> Report -> String -> String
87
95
toString location region rprt source =
88
96
displayS
89
- (renderPretty 1 80 (toDoc location region rprt source))
97
+ (stripAnsi ( renderPretty 1 80 (toDoc location region rprt source) ))
90
98
" "
91
99
92
100
93
- toHandle :: Handle -> String -> R. Region -> Report -> String -> IO ()
94
- toHandle handle location region rprt source =
95
- displayIO
96
- handle
97
- (renderPretty 1 80 (toDoc location region rprt source))
101
+ stripAnsi :: SimpleDoc -> SimpleDoc
102
+ stripAnsi simpleDoc =
103
+ case simpleDoc of
104
+ SFail ->
105
+ SFail
106
+
107
+ SEmpty ->
108
+ SEmpty
109
+
110
+ SChar chr subDoc ->
111
+ SChar chr (stripAnsi subDoc)
112
+
113
+ SText n str subDoc ->
114
+ SText n str (stripAnsi subDoc)
115
+
116
+ SLine n subDoc ->
117
+ SLine n (stripAnsi subDoc)
118
+
119
+ SSGR _ subDoc ->
120
+ stripAnsi subDoc
121
+
0 commit comments