1
1
mirror of https://github.com/github/semantic.git synced 2025-01-06 06:46:07 +03:00

Add a function to map a line into a Renderable line.

This commit is contained in:
Rob Rix 2015-12-22 17:53:47 -05:00
parent b165994569
commit 7e98ee3de5

View File

@ -33,7 +33,7 @@ split diff before after = return . renderHtml
. mconcat $ toMarkup <$> reverse numbered
where
rows = toRenderable <$> fst (splitDiffByLines diff (0, 0) (before, after))
toRenderable (Row a b) = Row (Renderable . (,) before <$> a) (Renderable . (,) after <$> b)
toRenderable (Row a b) = Row (renderable before a) (renderable after b)
numbered = foldl numberRows [] rows
maxNumber = case numbered of
[] -> 0
@ -45,6 +45,8 @@ split diff before after = return . renderHtml
columnWidth = max (20 + digits maxNumber * 8) 40
renderable source = fmap (Renderable . (,) source)
numberRows :: [(Int, Line a, Int, Line a)] -> Row a -> [(Int, Line a, Int, Line a)]
numberRows [] (Row EmptyLine EmptyLine) = []
numberRows [] (Row left@(Line _) EmptyLine) = [(1, left, 0, EmptyLine)]