Commonmark.SourceMap

commonmark-0.2.6.1: Pure Haskell commonmark parser.

Safe Haskell | None
Language | Haskell2010

Commonmark.SourceMap

Synopsis

- newtype SourceMap = SourceMap {
  - unSourceMap :: Map SourcePos (Seq Text, Seq Text)
  }
- newtype WithSourceMap a = WithSourceMap {
  - unWithSourceMap :: State (Maybe Text, SourceMap) a
  }
- runWithSourceMap :: (Show a, Monoid a) => WithSourceMap a -> (a, SourceMap)
- addName :: Text -> WithSourceMap ()

# Documentation

newtype SourceMap #

A map from source positions to a pair of sequences: first, elements that start at that position; then, elements that end at that position.

Constructors

SourceMap |
Fields unSourceMap :: Map SourcePos (Seq Text, Seq Text)

#### Instances

Instances details

Monoid SourceMap # |
Instance details Defined in Commonmark.SourceMap Methods mempty :: SourceMap # mappend :: SourceMap -> SourceMap -> SourceMap # mconcat :: [SourceMap] -> SourceMap #
Semigroup SourceMap # |
Instance details Defined in Commonmark.SourceMap Methods (<>) :: SourceMap -> SourceMap -> SourceMap # sconcat :: NonEmpty SourceMap -> SourceMap # stimes :: Integral b => b -> SourceMap -> SourceMap #
Show SourceMap # |
Instance details Defined in Commonmark.SourceMap Methods showsPrec :: Int -> SourceMap -> ShowS # show :: SourceMap -> String # showList :: [SourceMap] -> ShowS #

newtype WithSourceMap a #

Use this when you want to extract a source map as well as the parsed content.

Constructors

WithSourceMap |
Fields unWithSourceMap :: State (Maybe Text, SourceMap) a

#### Instances

Instances details

Applicative WithSourceMap # |
Instance details Defined in Commonmark.SourceMap Methods pure :: a -> WithSourceMap a # (<*>) :: WithSourceMap (a -> b) -> WithSourceMap a -> WithSourceMap b # liftA2 :: (a -> b -> c) -> WithSourceMap a -> WithSourceMap b -> WithSourceMap c # (*>) :: WithSourceMap a -> WithSourceMap b -> WithSourceMap b # (<*) :: WithSourceMap a -> WithSourceMap b -> WithSourceMap a #
Functor WithSourceMap # |
Instance details Defined in Commonmark.SourceMap Methods fmap :: (a -> b) -> WithSourceMap a -> WithSourceMap b # (<$) :: a -> WithSourceMap b -> WithSourceMap a #
Monad WithSourceMap # |
Instance details Defined in Commonmark.SourceMap Methods (>>=) :: WithSourceMap a -> (a -> WithSourceMap b) -> WithSourceMap b # (>>) :: WithSourceMap a -> WithSourceMap b -> WithSourceMap b # return :: a -> WithSourceMap a #
HasAttributes (WithSourceMap a) # |
Instance details Defined in Commonmark.SourceMap Methods addAttributes :: Attributes -> WithSourceMap a -> WithSourceMap a #
(IsInline a, Semigroup a) => IsInline (WithSourceMap a) # |
Instance details Defined in Commonmark.SourceMap Methods lineBreak :: WithSourceMap a # softBreak :: WithSourceMap a # str :: Text -> WithSourceMap a # entity :: Text -> WithSourceMap a # escapedChar :: Char -> WithSourceMap a # emph :: WithSourceMap a -> WithSourceMap a # strong :: WithSourceMap a -> WithSourceMap a # link :: Text -> Text -> WithSourceMap a -> WithSourceMap a # image :: Text -> Text -> WithSourceMap a -> WithSourceMap a # code :: Text -> WithSourceMap a # rawInline :: Format -> Text -> WithSourceMap a #
(Rangeable a, Monoid a, Show a) => Rangeable (WithSourceMap a) # |
Instance details Defined in Commonmark.SourceMap Methods ranged :: SourceRange -> WithSourceMap a -> WithSourceMap a #
ToPlainText a => ToPlainText (WithSourceMap a) # |
Instance details Defined in Commonmark.SourceMap Methods toPlainText :: WithSourceMap a -> Text #
(Show a, Semigroup a, Monoid a) => Monoid (WithSourceMap a) # |
Instance details Defined in Commonmark.SourceMap Methods mempty :: WithSourceMap a # mappend :: WithSourceMap a -> WithSourceMap a -> WithSourceMap a # mconcat :: [WithSourceMap a] -> WithSourceMap a #
(Show a, Semigroup a) => Semigroup (WithSourceMap a) # |
Instance details Defined in Commonmark.SourceMap Methods (<>) :: WithSourceMap a -> WithSourceMap a -> WithSourceMap a # sconcat :: NonEmpty (WithSourceMap a) -> WithSourceMap a # stimes :: Integral b => b -> WithSourceMap a -> WithSourceMap a #
(Show a, Monoid a) => Show (WithSourceMap a) # |
Instance details Defined in Commonmark.SourceMap Methods showsPrec :: Int -> WithSourceMap a -> ShowS # show :: WithSourceMap a -> String # showList :: [WithSourceMap a] -> ShowS #
(IsBlock b a, IsInline b, IsInline (WithSourceMap b), Semigroup a) => IsBlock (WithSourceMap b) (WithSourceMap a) # |
Instance details Defined in Commonmark.SourceMap Methods paragraph :: WithSourceMap b -> WithSourceMap a # plain :: WithSourceMap b -> WithSourceMap a # thematicBreak :: WithSourceMap a # blockQuote :: WithSourceMap a -> WithSourceMap a # codeBlock :: Text -> Text -> WithSourceMap a # heading :: Int -> WithSourceMap b -> WithSourceMap a # rawBlock :: Format -> Text -> WithSourceMap a # referenceLinkDefinition :: Text -> (Text, Text) -> WithSourceMap a # list :: ListType -> ListSpacing -> [WithSourceMap a] -> WithSourceMap a #

runWithSourceMap :: (Show a, Monoid a) => WithSourceMap a -> (a, SourceMap) #

Extract a parsed value and a source map from a `WithSourceMap`.

addName :: Text -> WithSourceMap () #