1
1
mirror of https://github.com/github/semantic.git synced 2024-12-19 04:41:47 +03:00

Tidy up Markdown with the AST synonym.

This commit is contained in:
Rob Rix 2017-08-16 12:24:47 -04:00
parent 6bbaa7a8e6
commit a5812184b8

View File

@ -10,7 +10,7 @@ import Control.Comonad.Trans.Cofree as CofreeF (CofreeF(..))
import CMarkGFM
import Data.Ix
import Data.Source
import qualified Data.Syntax.Assignment as A (Node(..))
import qualified Data.Syntax.Assignment as A (AST, Node(..))
import Info
import TreeSitter.Language (Symbol(..), SymbolType(..))
@ -49,9 +49,9 @@ exts = [
, extTagfilter
]
cmarkParser :: Source -> Cofree (CofreeF [] NodeType) (A.Node Grammar)
cmarkParser :: Source -> A.AST (CofreeF [] NodeType) Grammar
cmarkParser source = toTerm (totalRange source) (totalSpan source) $ commonmarkToNode [ optSourcePos, optSafe ] exts (toText source)
where toTerm :: Range -> Span -> Node -> Cofree (CofreeF [] NodeType) (A.Node Grammar)
where toTerm :: Range -> Span -> Node -> A.AST (CofreeF [] NodeType) Grammar
toTerm within withinSpan (Node position t children) =
let range = maybe within (spanToRangeInLineRanges lineRanges . toSpan) position
span = maybe withinSpan toSpan position