Skip to content

Commit

Permalink
Fix multiple line rendering bug
Browse files Browse the repository at this point in the history
More details #26
  • Loading branch information
psibi committed Aug 8, 2020
1 parent e80e4b8 commit 31c0881
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/Tldr.hs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ toSGR cons =
]

renderNode :: NodeType -> Handle -> IO ()
renderNode (TEXT txt) handle = TIO.hPutStrLn handle txt
renderNode (TEXT txt) handle = TIO.hPutStrLn handle (txt <> "\n")
renderNode (HTML_BLOCK txt) handle = TIO.hPutStrLn handle txt
renderNode (CODE_BLOCK _ txt) handle = TIO.hPutStrLn handle txt
renderNode (HTML_INLINE txt) handle = TIO.hPutStrLn handle txt
Expand All @@ -71,6 +71,7 @@ handleSubsetNodeType (CODE txt) = txt
handleSubsetNodeType _ = mempty

handleSubsetNode :: Node -> Text
handleSubsetNode (Node _ SOFTBREAK _) = "\n"
handleSubsetNode (Node _ ntype xs) =
handleSubsetNodeType ntype <> T.concat (Prelude.map handleSubsetNode xs)

Expand Down
4 changes: 3 additions & 1 deletion test/data/grep.golden
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
grep
Matches patterns in input text.Supports simple patterns and regular expressions.

Matches patterns in input text.
Supports simple patterns and regular expressions.

- Search for an exact string:
grep {{search_string}} {{path/to/file}}
Expand Down
1 change: 1 addition & 0 deletions test/data/ls.golden
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
ls

List directory contents.

- List files one per line:
Expand Down
1 change: 1 addition & 0 deletions test/data/ps.golden
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
ps

Information about running processes.

- List all running processes:
Expand Down

0 comments on commit 31c0881

Please sign in to comment.