@@ -76,6 +76,7 @@ import HsLua as Lua hiding (concat)
7676import Text.DocLayout (Doc , (<+>) , ($$) , ($+$) )
7777
7878import qualified Data.Text as T
79+ import qualified Data.Text.Lazy as TL
7980import qualified Text.DocLayout as Doc
8081
8182--
@@ -243,9 +244,18 @@ typeDoc = deftype "Doc"
243244-- line length parameter is omitted or nil.
244245render :: LuaError e => DocumentedFunction e
245246render = defun " render"
246- ### liftPure2 (flip Doc. render)
247+ ### (\ doc mbcolwidth useAnsi ->
248+ if useAnsi == Just True
249+ then pure $ TL. toStrict $ Doc. renderANSI mbcolwidth doc
250+ else pure $ Doc. renderPlain mbcolwidth doc)
247251 <#> docParam " doc"
248- <#> opt (integralParam " colwidth" " planned maximum line length" )
252+ <#> opt (integralParam " colwidth" $
253+ " Maximum number of characters per line.\n " <>
254+ " A value of `nil`, the default, means that the text " <>
255+ " is not reflown." )
256+ <#> opt (boolParam " ansi" $
257+ " Whether to generate plain text or ANSI terminal output.\n " <>
258+ " Defaults to `false`." )
249259 =#> functionResult pushText " string" " rendered doc"
250260 #? T. unlines
251261 [ " Render a [[Doc]]. The text is reflowed on breakable spaces to"
0 commit comments