File tree 3 files changed +14
-7
lines changed
3 files changed +14
-7
lines changed Original file line number Diff line number Diff line change @@ -53,7 +53,7 @@ Documentation
53
53
54
54
#### render
55
55
56
- ` render (doc[, colwidth[, ansi ]]) `
56
+ ` render (doc[, colwidth[, style ]]) `
57
57
58
58
Render the ` Doc ` using the given column width.
59
59
@@ -65,9 +65,9 @@ Parameters:
65
65
` colwidth `
66
66
: Maximum number of characters per line
67
67
68
- ` ansi `
69
- : Whether to generate plain or ANSI terminal output. Defaults to
70
- ` false ` . (boolean )
68
+ ` style `
69
+ : Whether to generate ' plain' or ' ANSI' terminal output. Must be
70
+ either ` 'plain' ` or ` 'ansi' ` . Defaults to ` 'plain' ` . (string )
71
71
72
72
### Doc construction
73
73
Original file line number Diff line number Diff line change @@ -268,15 +268,22 @@ render = defun "render"
268
268
" Maximum number of characters per line.\n " <>
269
269
" A value of `nil`, the default, means that the text " <>
270
270
" is not reflown." )
271
- <#> opt (boolParam " ansi " $
271
+ <#> opt (parameter peekRenderStyle " string " " style " $
272
272
" Whether to generate plain text or ANSI terminal output.\n " <>
273
- " Defaults to `false`." )
273
+ " Must be either `'plain'` or `'ansi'`.\n " <>
274
+ " Defaults to `'plain'`." )
274
275
=#> functionResult pushText " string" " rendered doc"
275
276
#? T. unlines
276
277
[ " Render a [[Doc]]. The text is reflowed on breakable spaces to"
277
278
, " match the given line length. Text is not reflowed if the line"
278
279
, " line length parameter is omitted or nil."
279
280
]
281
+ where
282
+ peekRenderStyle idx = peekByteString idx >>= \ case
283
+ " ansi" -> pure True
284
+ " ANSI" -> pure True
285
+ " plain" -> pure False
286
+ style -> failPeek $ " Unknown rendering style: " <> style
280
287
281
288
--
282
289
-- Querying
Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ local test = tasty.test_case
9
9
local assert = tasty .assert
10
10
11
11
local function renderANSI (doc , cols )
12
- return doclayout .render (doc , cols , true )
12
+ return doclayout .render (doc , cols , ' ansi ' )
13
13
end
14
14
15
15
-- Check existence static fields
You can’t perform that action at this time.
0 commit comments