File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -236,7 +236,10 @@ docTypeName = "HsLua DocLayout.Doc"
236236-- converted to plain @'Doc'@ values.
237237peekDoc :: StackIndex -> Lua (Doc Text )
238238peekDoc idx = Lua. ltype idx >>= \ case
239- Lua. TypeString -> Doc. literal <$> Lua. peek idx
239+ Lua. TypeString -> let stringToDoc s = if T. null s
240+ then Doc. empty
241+ else Doc. literal s
242+ in stringToDoc <$> Lua. peek idx
240243 Lua. TypeNumber -> Doc. literal <$> Lua. peek idx
241244 _ -> Lua. reportValueOnFailure docTypeName
242245 (`Lua.toAnyWithName` docTypeName)
Original file line number Diff line number Diff line change @@ -34,6 +34,10 @@ return {
3434 },
3535
3636 group ' Doc type' {
37+ test (' empty strings equal the empty Doc' , function ()
38+ assert .are_equal (doclayout .empty .. ' ' , doclayout .empty )
39+ end ),
40+
3741 test (' strings can be used as Doc values' , function ()
3842 assert .are_equal (doclayout .render (' hello world' ), ' hello world' )
3943 end ),
You can’t perform that action at this time.
0 commit comments