1
1
mirror of https://github.com/github/semantic.git synced 2024-12-25 07:55:12 +03:00

Add a function to produce a node from a subrange.

This commit is contained in:
Rob Rix 2015-12-01 15:57:37 -05:00
parent 776580768c
commit 26625e1c1c

View File

@ -35,6 +35,8 @@ splitTerm source term = fst $ cata toElement term where
toElement (Info range lineRange categories) (Indexed i) = (Ul (classify categories) $ children ++ [ Text $ substring Range { start = previous, end = end range } source ], range) where
(children, previous) = foldl accumulate ([], start range) i
accumulate (children, previous) (child, range) = (children ++ [ Text $ substring Range { start = previous, end = start range } source, child ], end range)
subtext :: Int -> Int -> HTML
subtext start end = Text $ substring (Range start end) source
classify :: Set.Set Category -> Maybe ClassName
classify categories = foldr (const . Just) Nothing categories