1
1
mirror of https://github.com/github/semantic.git synced 2024-11-24 00:42:33 +03:00

Add a function to branches only.

This commit is contained in:
Rob Rix 2016-02-24 13:24:51 -07:00
parent 0b89844b84
commit 7949048e13
2 changed files with 8 additions and 0 deletions

View File

@ -38,6 +38,7 @@ library
build-depends: base >= 4.8 && < 5
, bifunctors
, blaze-html
, blaze-markup
, bytestring
, c-storable-deriving
, containers

View File

@ -15,6 +15,7 @@ import Range
import Control.Monad.Free
import Text.Blaze.Html
import Text.Blaze.Html5 hiding (map)
import qualified Text.Blaze.Internal as Blaze
import qualified Text.Blaze.Html5.Attributes as A
import qualified Data.Text as T
import qualified Data.Text.Lazy as TL
@ -103,6 +104,12 @@ instance ToMarkup f => ToMarkup (Renderable (Info, Syntax a (f, Range))) where
where markupForSeparatorAndChild :: ToMarkup f => ([Markup], Int) -> (f, Range) -> ([Markup], Int)
markupForSeparatorAndChild (rows, previous) (child, range) = (rows ++ [ string (toString $ slice (Range previous $ start range) source), toMarkup child ], end range)
wrapIn _ l@Blaze.Leaf{} = l
wrapIn _ l@Blaze.CustomLeaf{} = l
wrapIn _ l@Blaze.Content{} = l
wrapIn _ l@Blaze.Comment{} = l
wrapIn f p = f p
contentElements children = let (elements, previous) = foldl' markupForSeparatorAndChild ([], start range) children in
elements ++ [ string . toString $ slice (Range previous $ end range) source ]