commonmark-0.2.3: Pure Haskell commonmark parser.

Safe Haskell | Safe-Inferred
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 Source #

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

newtype WithSourceMap a Source #

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 Source # |

Instance details

Defined in Commonmark.SourceMap

Methods

pure :: a -> WithSourceMap a Source #

(<*>) :: WithSourceMap (a -> b) -> WithSourceMap a -> WithSourceMap b Source #

liftA2 :: (a -> b -> c) -> WithSourceMap a -> WithSourceMap b -> WithSourceMap c Source #

(*>) :: WithSourceMap a -> WithSourceMap b -> WithSourceMap b Source #

(<*) :: WithSourceMap a -> WithSourceMap b -> WithSourceMap a Source #

Functor WithSourceMap Source # |
Instance details Defined in Commonmark.SourceMap Methods fmap :: (a -> b) -> WithSourceMap a -> WithSourceMap b Source # (<$) :: a -> WithSourceMap b -> WithSourceMap a Source #
Monad WithSourceMap Source # |
Instance details Defined in Commonmark.SourceMap Methods (>>=) :: WithSourceMap a -> (a -> WithSourceMap b) -> WithSourceMap b Source # (>>) :: WithSourceMap a -> WithSourceMap b -> WithSourceMap b Source # return :: a -> WithSourceMap a Source #
(Show a, Semigroup a, Monoid a) => Monoid (WithSourceMap a) Source # |
Instance details Defined in Commonmark.SourceMap Methods mempty :: WithSourceMap a Source # mappend :: WithSourceMap a -> WithSourceMap a -> WithSourceMap a Source # mconcat :: [WithSourceMap a] -> WithSourceMap a Source #
(Show a, Semigroup a) => Semigroup (WithSourceMap a) Source # |
Instance details Defined in Commonmark.SourceMap Methods (<>) :: WithSourceMap a -> WithSourceMap a -> WithSourceMap a Source # sconcat :: NonEmpty (WithSourceMap a) -> WithSourceMap a Source # stimes :: Integral b => b -> WithSourceMap a -> WithSourceMap a Source #
(Show a, Monoid a) => Show (WithSourceMap a) Source # |
Instance details Defined in Commonmark.SourceMap Methods showsPrec :: Int -> WithSourceMap a -> ShowS Source # show :: WithSourceMap a -> String Source # showList :: [WithSourceMap a] -> ShowS Source #
HasAttributes (WithSourceMap a) Source # |
Instance details Defined in Commonmark.SourceMap Methods addAttributes :: Attributes -> WithSourceMap a -> WithSourceMap a Source #
(IsInline a, Semigroup a) => IsInline (WithSourceMap a) Source # |

Instance details

Defined in Commonmark.SourceMap

Methods

lineBreak :: WithSourceMap a Source #

softBreak :: WithSourceMap a Source #

str :: Text -> WithSourceMap a Source #

entity :: Text -> WithSourceMap a Source #

escapedChar :: Char -> WithSourceMap a Source #

emph :: WithSourceMap a -> WithSourceMap a Source #

strong :: WithSourceMap a -> WithSourceMap a Source #

link :: Text -> Text -> WithSourceMap a -> WithSourceMap a Source #

image :: Text -> Text -> WithSourceMap a -> WithSourceMap a Source #

code :: Text -> WithSourceMap a Source #

rawInline :: Format -> Text -> WithSourceMap a Source #

(Rangeable a, Monoid a, Show a) => Rangeable (WithSourceMap a) Source # |
Instance details Defined in Commonmark.SourceMap Methods ranged :: SourceRange -> WithSourceMap a -> WithSourceMap a Source #
ToPlainText a => ToPlainText (WithSourceMap a) Source # |
Instance details Defined in Commonmark.SourceMap Methods toPlainText :: WithSourceMap a -> Text Source #
(IsBlock b a, IsInline b, IsInline (WithSourceMap b), Semigroup a) => IsBlock (WithSourceMap b) (WithSourceMap a) Source # |

Instance details

Defined in Commonmark.SourceMap

Methods

paragraph :: WithSourceMap b -> WithSourceMap a Source #

plain :: WithSourceMap b -> WithSourceMap a Source #

thematicBreak :: WithSourceMap a Source #

blockQuote :: WithSourceMap a -> WithSourceMap a Source #

codeBlock :: Text -> Text -> WithSourceMap a Source #

heading :: Int -> WithSourceMap b -> WithSourceMap a Source #

rawBlock :: Format -> Text -> WithSourceMap a Source #

referenceLinkDefinition :: Text -> (Text, Text) -> WithSourceMap a Source #

list :: ListType -> ListSpacing -> [WithSourceMap a] -> WithSourceMap a Source #

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

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

addName :: Text -> WithSourceMap () Source #