From 7e98ee3de59b99258937a552e2244e6082452e13 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Tue, 22 Dec 2015 17:53:47 -0500 Subject: [PATCH] Add a function to map a line into a Renderable line. --- src/Split.hs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Split.hs b/src/Split.hs index 73e7722f5..ba7ab5a43 100644 --- a/src/Split.hs +++ b/src/Split.hs @@ -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)]