Skip to content

Commit eaeb919

Browse files
committed
Fixed alignment problem in multiline, simple and pipe tables.
1 parent a2138d4 commit eaeb919

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/Text/Table/Builder.hs

+5-5
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ module Text.Table.Builder (
4141
) where
4242

4343
import Data.List
44-
import Data.Text (pack, unpack, justifyLeft, justifyRight, center)
44+
import Data.Text (pack, unpack, strip, justifyLeft, justifyRight, center)
4545

4646
-- Local import
4747
import Text.Table.Definition
@@ -163,10 +163,10 @@ addGutter :: Gutter -> Lines -> Lines
163163
addGutter g (x:xs) = x : map ((replicate g ' ')++) xs
164164

165165
alignText :: Width -> Align -> String -> String
166-
alignText w (LeftAlign) = unpack . justifyLeft w ' ' . pack
167-
alignText w (RightAlign) = unpack . justifyRight w ' ' . pack
168-
alignText w (CenterAlign) = unpack . center w ' ' . pack
169-
alignText w (DefaultAlign) = unpack . justifyLeft w ' ' . pack
166+
alignText w (LeftAlign) = unpack . justifyLeft w ' ' . strip . pack
167+
alignText w (RightAlign) = unpack . justifyRight w ' ' . strip . pack
168+
alignText w (CenterAlign) = unpack . center w ' ' . strip . pack
169+
alignText w (DefaultAlign) = unpack . justifyLeft w ' ' . strip . pack
170170

171171
row2Md :: TableType -> Row -> String
172172
row2Md (Grid) (Row cs) = flatten $ transpose $ appendPipes $ map (cellToLines Grid) cs

0 commit comments

Comments
 (0)