CMark

cmark-0.5.5.1: Fast, accurate CommonMark (Markdown) parser and renderer

Safe Haskell | None
Language | Haskell2010

CMark

Synopsis

- commonmarkToHtml :: [CMarkOption] -> Text -> Text
- commonmarkToXml :: [CMarkOption] -> Text -> Text
- commonmarkToMan :: [CMarkOption] -> Maybe Int -> Text -> Text
- commonmarkToLaTeX :: [CMarkOption] -> Maybe Int -> Text -> Text
- commonmarkToNode :: [CMarkOption] -> Text -> Node
- nodeToHtml :: [CMarkOption] -> Node -> Text
- nodeToXml :: [CMarkOption] -> Node -> Text
- nodeToMan :: [CMarkOption] -> Maybe Int -> Node -> Text
- nodeToLaTeX :: [CMarkOption] -> Maybe Int -> Node -> Text
- nodeToCommonmark :: [CMarkOption] -> Maybe Int -> Node -> Text
- optSourcePos :: CMarkOption
- optNormalize :: CMarkOption
- optHardBreaks :: CMarkOption
- optSmart :: CMarkOption
- optSafe :: CMarkOption
- data Node = Node (Maybe PosInfo) NodeType [Node]
- data NodeType
  - = DOCUMENT
  - | THEMATIC_BREAK
  - | PARAGRAPH
  - | BLOCK_QUOTE
  - | HTML_BLOCK Text
  - | CUSTOM_BLOCK OnEnter OnExit
  - | CODE_BLOCK Info Text
  - | HEADING Level
  - | LIST ListAttributes
  - | ITEM
  - | TEXT Text
  - | SOFTBREAK
  - | LINEBREAK
  - | HTML_INLINE Text
  - | CUSTOM_INLINE OnEnter OnExit
  - | CODE Text
  - | EMPH
  - | STRONG
  - | LINK Url Title
  - | IMAGE Url Title
- data PosInfo = PosInfo {
  - startLine :: Int
  - startColumn :: Int
  - endLine :: Int
  - endColumn :: Int
  }
- data DelimType
  - = PERIOD_DELIM
  - | PAREN_DELIM
- data ListType
  - = BULLET_LIST
  - | ORDERED_LIST
- data ListAttributes = ListAttributes {
  - listType :: ListType
  - listTight :: Bool
  - listStart :: Int
  - listDelim :: DelimType
  }
- type Url = Text
- type Title = Text
- type Level = Int
- type Info = Text
- data CMarkOption

# Documentation

commonmarkToHtml :: [CMarkOption] -> Text -> Text #

Convert CommonMark formatted text to Html, using cmark's built-in renderer.

commonmarkToXml :: [CMarkOption] -> Text -> Text #

Convert CommonMark formatted text to CommonMark XML, using cmark's built-in renderer.

commonmarkToMan :: [CMarkOption] -> Maybe Int -> Text -> Text #

Convert CommonMark formatted text to groff man, using cmark's built-in renderer.

commonmarkToLaTeX :: [CMarkOption] -> Maybe Int -> Text -> Text #

Convert CommonMark formatted text to latex, using cmark's built-in renderer.

commonmarkToNode :: [CMarkOption] -> Text -> Node #

Convert CommonMark formatted text to a structured `Node` tree, which can be transformed or rendered using Haskell code.

nodeToHtml :: [CMarkOption] -> Node -> Text #

nodeToXml :: [CMarkOption] -> Node -> Text #

nodeToMan :: [CMarkOption] -> Maybe Int -> Node -> Text #

nodeToLaTeX :: [CMarkOption] -> Maybe Int -> Node -> Text #

nodeToCommonmark :: [CMarkOption] -> Maybe Int -> Node -> Text #

optSourcePos :: CMarkOption #

Include a `data-sourcepos` attribute on block elements.

optNormalize :: CMarkOption #

Normalize the document by consolidating adjacent text nodes.

optHardBreaks :: CMarkOption #

Render `softbreak` elements as hard line breaks.

optSmart :: CMarkOption #

Convert straight quotes to curly, `---` to em-dash, `--` to en-dash.

optSafe :: CMarkOption #

Suppress rendering of raw HTML and potentially dangerous URLs in links and images.

data Node #

Constructors

Node (Maybe PosInfo) NodeType [Node] |

Instances

Eq Node # |
Methods (==) :: Node -> Node -> Bool # (/=) :: Node -> Node -> Bool #
Data Node # |
Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Node -> c Node # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Node # toConstr :: Node -> Constr # dataTypeOf :: Node -> DataType # dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c Node) # dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Node) # gmapT :: (forall b. Data b => b -> b) -> Node -> Node # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Node -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Node -> r # gmapQ :: (forall d. Data d => d -> u) -> Node -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Node -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Node -> m Node # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Node -> m Node # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Node -> m Node #
Ord Node # |
Methods compare :: Node -> Node -> Ordering # (<) :: Node -> Node -> Bool # (<=) :: Node -> Node -> Bool # (>) :: Node -> Node -> Bool # (>=) :: Node -> Node -> Bool # max :: Node -> Node -> Node # min :: Node -> Node -> Node #
Read Node # |
Methods readsPrec :: Int -> ReadS Node # readList :: ReadS [Node] # readPrec :: ReadPrec Node # readListPrec :: ReadPrec [Node] #
Show Node # |
Methods showsPrec :: Int -> Node -> ShowS # show :: Node -> String # showList :: [Node] -> ShowS #
Generic Node # |
Associated Types type Rep Node :: * -> * # Methods from :: Node -> Rep Node x # to :: Rep Node x -> Node #
type Rep Node # |
type Rep Node = D1 (MetaData "Node" "CMark" "cmark-0.5.5.1-1DK7iFGnGJu6bG91JoBdep" False) (C1 (MetaCons "Node" PrefixI False) ((:*:) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Maybe PosInfo))) ((:*:) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 NodeType)) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [Node])))))

data NodeType #

Constructors

DOCUMENT |
THEMATIC_BREAK |
PARAGRAPH |
BLOCK_QUOTE |
HTML_BLOCK Text |
CUSTOM_BLOCK OnEnter OnExit |
CODE_BLOCK Info Text |
HEADING Level |
LIST ListAttributes |
ITEM |
TEXT Text |
SOFTBREAK |
LINEBREAK |
HTML_INLINE Text |
CUSTOM_INLINE OnEnter OnExit |
CODE Text |
EMPH |
STRONG |
LINK Url Title |
IMAGE Url Title |

Instances

Eq NodeType # |
Methods (==) :: NodeType -> NodeType -> Bool # (/=) :: NodeType -> NodeType -> Bool #
Data NodeType # |
Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> NodeType -> c NodeType # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c NodeType # toConstr :: NodeType -> Constr # dataTypeOf :: NodeType -> DataType # dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c NodeType) # dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c NodeType) # gmapT :: (forall b. Data b => b -> b) -> NodeType -> NodeType # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> NodeType -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> NodeType -> r # gmapQ :: (forall d. Data d => d -> u) -> NodeType -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> NodeType -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> NodeType -> m NodeType # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> NodeType -> m NodeType # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> NodeType -> m NodeType #
Ord NodeType # |
Methods compare :: NodeType -> NodeType -> Ordering # (<) :: NodeType -> NodeType -> Bool # (<=) :: NodeType -> NodeType -> Bool # (>) :: NodeType -> NodeType -> Bool # (>=) :: NodeType -> NodeType -> Bool # max :: NodeType -> NodeType -> NodeType # min :: NodeType -> NodeType -> NodeType #
Read NodeType # |
Methods readsPrec :: Int -> ReadS NodeType # readList :: ReadS [NodeType] # readPrec :: ReadPrec NodeType # readListPrec :: ReadPrec [NodeType] #
Show NodeType # |
Methods showsPrec :: Int -> NodeType -> ShowS # show :: NodeType -> String # showList :: [NodeType] -> ShowS #
Generic NodeType # |
Associated Types type Rep NodeType :: * -> * # Methods from :: NodeType -> Rep NodeType x # to :: Rep NodeType x -> NodeType #
type Rep NodeType # |
type Rep NodeType

data PosInfo #

Constructors

PosInfo |
Fields startLine :: Int startColumn :: Int endLine :: Int endColumn :: Int

Instances

Eq PosInfo # |
Methods (==) :: PosInfo -> PosInfo -> Bool # (/=) :: PosInfo -> PosInfo -> Bool #
Data PosInfo # |
Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> PosInfo -> c PosInfo # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c PosInfo # toConstr :: PosInfo -> Constr # dataTypeOf :: PosInfo -> DataType # dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c PosInfo) # dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c PosInfo) # gmapT :: (forall b. Data b => b -> b) -> PosInfo -> PosInfo # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> PosInfo -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> PosInfo -> r # gmapQ :: (forall d. Data d => d -> u) -> PosInfo -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> PosInfo -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> PosInfo -> m PosInfo # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> PosInfo -> m PosInfo # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> PosInfo -> m PosInfo #
Ord PosInfo # |
Methods compare :: PosInfo -> PosInfo -> Ordering # (<) :: PosInfo -> PosInfo -> Bool # (<=) :: PosInfo -> PosInfo -> Bool # (>) :: PosInfo -> PosInfo -> Bool # (>=) :: PosInfo -> PosInfo -> Bool # max :: PosInfo -> PosInfo -> PosInfo # min :: PosInfo -> PosInfo -> PosInfo #
Read PosInfo # |
Methods readsPrec :: Int -> ReadS PosInfo # readList :: ReadS [PosInfo] # readPrec :: ReadPrec PosInfo # readListPrec :: ReadPrec [PosInfo] #
Show PosInfo # |
Methods showsPrec :: Int -> PosInfo -> ShowS # show :: PosInfo -> String # showList :: [PosInfo] -> ShowS #
Generic PosInfo # |
Associated Types type Rep PosInfo :: * -> * # Methods from :: PosInfo -> Rep PosInfo x # to :: Rep PosInfo x -> PosInfo #
type Rep PosInfo # |
type Rep PosInfo = D1 (MetaData "PosInfo" "CMark" "cmark-0.5.5.1-1DK7iFGnGJu6bG91JoBdep" False) (C1 (MetaCons "PosInfo" PrefixI True) ((:*:) ((:*:) (S1 (MetaSel (Just Symbol "startLine") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Int)) (S1 (MetaSel (Just Symbol "startColumn") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Int))) ((:*:) (S1 (MetaSel (Just Symbol "endLine") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Int)) (S1 (MetaSel (Just Symbol "endColumn") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Int)))))

data DelimType #

Constructors

PERIOD_DELIM |
PAREN_DELIM |

Instances

Eq DelimType # |
Methods (==) :: DelimType -> DelimType -> Bool # (/=) :: DelimType -> DelimType -> Bool #
Data DelimType # |
Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> DelimType -> c DelimType # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c DelimType # toConstr :: DelimType -> Constr # dataTypeOf :: DelimType -> DataType # dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c DelimType) # dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c DelimType) # gmapT :: (forall b. Data b => b -> b) -> DelimType -> DelimType # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> DelimType -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> DelimType -> r # gmapQ :: (forall d. Data d => d -> u) -> DelimType -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> DelimType -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> DelimType -> m DelimType # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> DelimType -> m DelimType # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> DelimType -> m DelimType #
Ord DelimType # |
Methods compare :: DelimType -> DelimType -> Ordering # (<) :: DelimType -> DelimType -> Bool # (<=) :: DelimType -> DelimType -> Bool # (>) :: DelimType -> DelimType -> Bool # (>=) :: DelimType -> DelimType -> Bool # max :: DelimType -> DelimType -> DelimType # min :: DelimType -> DelimType -> DelimType #
Read DelimType # |
Methods readsPrec :: Int -> ReadS DelimType # readList :: ReadS [DelimType] # readPrec :: ReadPrec DelimType # readListPrec :: ReadPrec [DelimType] #
Show DelimType # |
Methods showsPrec :: Int -> DelimType -> ShowS # show :: DelimType -> String # showList :: [DelimType] -> ShowS #
Generic DelimType # |
Associated Types type Rep DelimType :: * -> * # Methods from :: DelimType -> Rep DelimType x # to :: Rep DelimType x -> DelimType #
type Rep DelimType # |
type Rep DelimType = D1 (MetaData "DelimType" "CMark" "cmark-0.5.5.1-1DK7iFGnGJu6bG91JoBdep" False) ((:+:) (C1 (MetaCons "PERIOD_DELIM" PrefixI False) U1) (C1 (MetaCons "PAREN_DELIM" PrefixI False) U1))

data ListType #

Constructors

BULLET_LIST |
ORDERED_LIST |

Instances

Eq ListType # |
Methods (==) :: ListType -> ListType -> Bool # (/=) :: ListType -> ListType -> Bool #
Data ListType # |
Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> ListType -> c ListType # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c ListType # toConstr :: ListType -> Constr # dataTypeOf :: ListType -> DataType # dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c ListType) # dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c ListType) # gmapT :: (forall b. Data b => b -> b) -> ListType -> ListType # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> ListType -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> ListType -> r # gmapQ :: (forall d. Data d => d -> u) -> ListType -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> ListType -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> ListType -> m ListType # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> ListType -> m ListType # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> ListType -> m ListType #
Ord ListType # |
Methods compare :: ListType -> ListType -> Ordering # (<) :: ListType -> ListType -> Bool # (<=) :: ListType -> ListType -> Bool # (>) :: ListType -> ListType -> Bool # (>=) :: ListType -> ListType -> Bool # max :: ListType -> ListType -> ListType # min :: ListType -> ListType -> ListType #
Read ListType # |
Methods readsPrec :: Int -> ReadS ListType # readList :: ReadS [ListType] # readPrec :: ReadPrec ListType # readListPrec :: ReadPrec [ListType] #
Show ListType # |
Methods showsPrec :: Int -> ListType -> ShowS # show :: ListType -> String # showList :: [ListType] -> ShowS #
Generic ListType # |
Associated Types type Rep ListType :: * -> * # Methods from :: ListType -> Rep ListType x # to :: Rep ListType x -> ListType #
type Rep ListType # |
type Rep ListType = D1 (MetaData "ListType" "CMark" "cmark-0.5.5.1-1DK7iFGnGJu6bG91JoBdep" False) ((:+:) (C1 (MetaCons "BULLET_LIST" PrefixI False) U1) (C1 (MetaCons "ORDERED_LIST" PrefixI False) U1))

data ListAttributes #

Constructors

ListAttributes |
Fields listType :: ListType listTight :: Bool listStart :: Int listDelim :: DelimType

Instances

Eq ListAttributes # |
Methods (==) :: ListAttributes -> ListAttributes -> Bool # (/=) :: ListAttributes -> ListAttributes -> Bool #
Data ListAttributes # |
Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> ListAttributes -> c ListAttributes # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c ListAttributes # toConstr :: ListAttributes -> Constr # dataTypeOf :: ListAttributes -> DataType # dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c ListAttributes) # dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c ListAttributes) # gmapT :: (forall b. Data b => b -> b) -> ListAttributes -> ListAttributes # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> ListAttributes -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> ListAttributes -> r # gmapQ :: (forall d. Data d => d -> u) -> ListAttributes -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> ListAttributes -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> ListAttributes -> m ListAttributes # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> ListAttributes -> m ListAttributes # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> ListAttributes -> m ListAttributes #
Ord ListAttributes # |
Methods compare :: ListAttributes -> ListAttributes -> Ordering # (<) :: ListAttributes -> ListAttributes -> Bool # (<=) :: ListAttributes -> ListAttributes -> Bool # (>) :: ListAttributes -> ListAttributes -> Bool # (>=) :: ListAttributes -> ListAttributes -> Bool # max :: ListAttributes -> ListAttributes -> ListAttributes # min :: ListAttributes -> ListAttributes -> ListAttributes #
Read ListAttributes # |
Methods readsPrec :: Int -> ReadS ListAttributes # readList :: ReadS [ListAttributes] # readPrec :: ReadPrec ListAttributes # readListPrec :: ReadPrec [ListAttributes] #
Show ListAttributes # |
Methods showsPrec :: Int -> ListAttributes -> ShowS # show :: ListAttributes -> String # showList :: [ListAttributes] -> ShowS #
Generic ListAttributes # |
Associated Types type Rep ListAttributes :: * -> * # Methods from :: ListAttributes -> Rep ListAttributes x # to :: Rep ListAttributes x -> ListAttributes #
type Rep ListAttributes # |
type Rep ListAttributes = D1 (MetaData "ListAttributes" "CMark" "cmark-0.5.5.1-1DK7iFGnGJu6bG91JoBdep" False) (C1 (MetaCons "ListAttributes" PrefixI True) ((:*:) ((:*:) (S1 (MetaSel (Just Symbol "listType") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 ListType)) (S1 (MetaSel (Just Symbol "listTight") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Bool))) ((:*:) (S1 (MetaSel (Just Symbol "listStart") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Int)) (S1 (MetaSel (Just Symbol "listDelim") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 DelimType)))))

type Url = Text #

type Title = Text #

type Level = Int #

type Info = Text #

data CMarkOption #