{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE ScopedTypeVariables #-}
{- |
   Module      : Text.Pandoc.Readers.CommonMark
   Copyright   : Copyright (C) 2015-2020 John MacFarlane
   License     : GNU GPL, version 2 or above

   Maintainer  : John MacFarlane <jgm@berkeley.edu>
   Stability   : alpha
   Portability : portable

Conversion of CommonMark-formatted plain text to 'Pandoc' document.

CommonMark is a strongly specified variant of Markdown: http://commonmark.org.
-}
module Text.Pandoc.Readers.CommonMark (readCommonMark)
where

import Commonmark
import Commonmark.Extensions
import Commonmark.Pandoc
import Data.Text (Text)
import Text.Pandoc.Class.PandocMonad (PandocMonad)
import Text.Pandoc.Definition
import Text.Pandoc.Builder as B
import Text.Pandoc.Options
import Text.Pandoc.Error
import Control.Monad.Except
import Data.Functor.Identity (runIdentity)
import Data.Typeable

-- | Parse a CommonMark formatted string into a 'Pandoc' structure.
readCommonMark :: PandocMonad m => ReaderOptions -> Text -> m Pandoc
readCommonMark :: ReaderOptions -> Text -> m Pandoc
readCommonMark ReaderOptions
opts Text
s
  | Extension -> ReaderOptions -> Bool
forall a. HasSyntaxExtensions a => Extension -> a -> Bool
isEnabled Extension
Ext_sourcepos ReaderOptions
opts =
    case Identity (Either ParseError (Cm SourceRange Blocks))
-> Either ParseError (Cm SourceRange Blocks)
forall a. Identity a -> a
runIdentity (SyntaxSpec
  Identity (Cm SourceRange Inlines) (Cm SourceRange Blocks)
-> String
-> Text
-> Identity (Either ParseError (Cm SourceRange Blocks))
forall (m :: * -> *) il bl.
(Monad m, IsBlock il bl, IsInline il) =>
SyntaxSpec m il bl -> String -> Text -> m (Either ParseError bl)
commonmarkWith (ReaderOptions
-> SyntaxSpec
     Identity (Cm SourceRange Inlines) (Cm SourceRange Blocks)
forall (m :: * -> *) a.
(Monad m, Typeable m, Typeable a, Rangeable (Cm a Inlines),
 Rangeable (Cm a Blocks)) =>
ReaderOptions -> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
specFor ReaderOptions
opts) String
"" Text
s) of
      Left ParseError
err -> PandocError -> m Pandoc
forall e (m :: * -> *) a. MonadError e m => e -> m a
throwError (PandocError -> m Pandoc) -> PandocError -> m Pandoc
forall a b. (a -> b) -> a -> b
$ Text -> ParseError -> PandocError
PandocParsecError Text
s ParseError
err
      Right (Cm Blocks
bls :: Cm SourceRange Blocks) -> Pandoc -> m Pandoc
forall (m :: * -> *) a. Monad m => a -> m a
return (Pandoc -> m Pandoc) -> Pandoc -> m Pandoc
forall a b. (a -> b) -> a -> b
$ Blocks -> Pandoc
B.doc Blocks
bls
  | Bool
otherwise =
    case Identity (Either ParseError (Cm () Blocks))
-> Either ParseError (Cm () Blocks)
forall a. Identity a -> a
runIdentity (SyntaxSpec Identity (Cm () Inlines) (Cm () Blocks)
-> String -> Text -> Identity (Either ParseError (Cm () Blocks))
forall (m :: * -> *) il bl.
(Monad m, IsBlock il bl, IsInline il) =>
SyntaxSpec m il bl -> String -> Text -> m (Either ParseError bl)
commonmarkWith (ReaderOptions -> SyntaxSpec Identity (Cm () Inlines) (Cm () Blocks)
forall (m :: * -> *) a.
(Monad m, Typeable m, Typeable a, Rangeable (Cm a Inlines),
 Rangeable (Cm a Blocks)) =>
ReaderOptions -> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
specFor ReaderOptions
opts) String
"" Text
s) of
      Left ParseError
err -> PandocError -> m Pandoc
forall e (m :: * -> *) a. MonadError e m => e -> m a
throwError (PandocError -> m Pandoc) -> PandocError -> m Pandoc
forall a b. (a -> b) -> a -> b
$ Text -> ParseError -> PandocError
PandocParsecError Text
s ParseError
err
      Right (Cm Blocks
bls :: Cm () Blocks) -> Pandoc -> m Pandoc
forall (m :: * -> *) a. Monad m => a -> m a
return (Pandoc -> m Pandoc) -> Pandoc -> m Pandoc
forall a b. (a -> b) -> a -> b
$ Blocks -> Pandoc
B.doc Blocks
bls

specFor :: (Monad m, Typeable m, Typeable a,
            Rangeable (Cm a Inlines), Rangeable (Cm a Blocks))
        => ReaderOptions -> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
specFor :: ReaderOptions -> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
specFor ReaderOptions
opts = ((SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
  -> SyntaxSpec m (Cm a Inlines) (Cm a Blocks))
 -> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
 -> SyntaxSpec m (Cm a Inlines) (Cm a Blocks))
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
    -> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr (SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
 -> SyntaxSpec m (Cm a Inlines) (Cm a Blocks))
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
forall a b. (a -> b) -> a -> b
($) SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
forall (m :: * -> *) il bl.
(Monad m, IsBlock il bl, IsInline il) =>
SyntaxSpec m il bl
defaultSyntaxSpec [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
 -> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
exts
 where
  exts :: [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
 -> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
exts = [ (SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
forall (m :: * -> *) il bl.
(Monad m, IsBlock il bl, IsInline il) =>
SyntaxSpec m il bl
hardLineBreaksSpec SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
forall a. Semigroup a => a -> a -> a
<>) | Extension -> ReaderOptions -> Bool
forall a. HasSyntaxExtensions a => Extension -> a -> Bool
isEnabled Extension
Ext_hard_line_breaks ReaderOptions
opts ] [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
 -> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
-> [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
    -> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
-> [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
    -> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
forall a. [a] -> [a] -> [a]
++
         [ (SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
forall (m :: * -> *) il bl.
(Monad m, IsBlock il bl, IsInline il, HasQuoted il) =>
SyntaxSpec m il bl
smartPunctuationSpec SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
forall a. Semigroup a => a -> a -> a
<>) | Extension -> ReaderOptions -> Bool
forall a. HasSyntaxExtensions a => Extension -> a -> Bool
isEnabled Extension
Ext_smart ReaderOptions
opts ] [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
 -> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
-> [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
    -> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
-> [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
    -> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
forall a. [a] -> [a] -> [a]
++
         [ (SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
forall (m :: * -> *) il bl.
(Monad m, IsBlock il bl, IsInline il, HasStrikethrough il) =>
SyntaxSpec m il bl
strikethroughSpec SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
forall a. Semigroup a => a -> a -> a
<>) | Extension -> ReaderOptions -> Bool
forall a. HasSyntaxExtensions a => Extension -> a -> Bool
isEnabled Extension
Ext_strikeout ReaderOptions
opts ] [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
 -> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
-> [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
    -> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
-> [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
    -> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
forall a. [a] -> [a] -> [a]
++
         [ (SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
forall (m :: * -> *) il bl.
(Monad m, IsBlock il bl, IsInline il, HasSuperscript il) =>
SyntaxSpec m il bl
superscriptSpec SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
forall a. Semigroup a => a -> a -> a
<>) | Extension -> ReaderOptions -> Bool
forall a. HasSyntaxExtensions a => Extension -> a -> Bool
isEnabled Extension
Ext_superscript ReaderOptions
opts ] [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
 -> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
-> [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
    -> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
-> [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
    -> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
forall a. [a] -> [a] -> [a]
++
         [ (SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
forall (m :: * -> *) il bl.
(Monad m, IsBlock il bl, IsInline il, HasSubscript il) =>
SyntaxSpec m il bl
subscriptSpec SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
forall a. Semigroup a => a -> a -> a
<>) | Extension -> ReaderOptions -> Bool
forall a. HasSyntaxExtensions a => Extension -> a -> Bool
isEnabled Extension
Ext_subscript ReaderOptions
opts ] [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
 -> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
-> [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
    -> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
-> [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
    -> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
forall a. [a] -> [a] -> [a]
++
         [ (SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
forall (m :: * -> *) il bl.
(Monad m, IsBlock il bl, IsInline il, HasMath il) =>
SyntaxSpec m il bl
mathSpec SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
forall a. Semigroup a => a -> a -> a
<>) | Extension -> ReaderOptions -> Bool
forall a. HasSyntaxExtensions a => Extension -> a -> Bool
isEnabled Extension
Ext_tex_math_dollars ReaderOptions
opts ] [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
 -> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
-> [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
    -> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
-> [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
    -> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
forall a. [a] -> [a] -> [a]
++
         [ (SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
forall (m :: * -> *) il bl.
(Monad m, IsBlock il bl, IsInline il) =>
SyntaxSpec m il bl
fancyListSpec SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
forall a. Semigroup a => a -> a -> a
<>) | Extension -> ReaderOptions -> Bool
forall a. HasSyntaxExtensions a => Extension -> a -> Bool
isEnabled Extension
Ext_fancy_lists ReaderOptions
opts ] [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
 -> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
-> [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
    -> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
-> [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
    -> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
forall a. [a] -> [a] -> [a]
++
         [ (SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
forall (m :: * -> *) il bl.
(Monad m, IsInline il, IsBlock il bl, HasDiv bl) =>
SyntaxSpec m il bl
fencedDivSpec SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
forall a. Semigroup a => a -> a -> a
<>) | Extension -> ReaderOptions -> Bool
forall a. HasSyntaxExtensions a => Extension -> a -> Bool
isEnabled Extension
Ext_fenced_divs ReaderOptions
opts ] [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
 -> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
-> [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
    -> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
-> [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
    -> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
forall a. [a] -> [a] -> [a]
++
         [ (SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
forall (m :: * -> *) il bl.
(Monad m, IsInline il, HasSpan il) =>
SyntaxSpec m il bl
bracketedSpanSpec SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
forall a. Semigroup a => a -> a -> a
<>) | Extension -> ReaderOptions -> Bool
forall a. HasSyntaxExtensions a => Extension -> a -> Bool
isEnabled Extension
Ext_bracketed_spans ReaderOptions
opts ] [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
 -> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
-> [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
    -> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
-> [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
    -> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
forall a. [a] -> [a] -> [a]
++
         [ (SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
forall (m :: * -> *) il bl.
(Monad m, IsBlock il bl) =>
SyntaxSpec m il bl
rawAttributeSpec SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
forall a. Semigroup a => a -> a -> a
<>) | Extension -> ReaderOptions -> Bool
forall a. HasSyntaxExtensions a => Extension -> a -> Bool
isEnabled Extension
Ext_raw_attribute ReaderOptions
opts ] [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
 -> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
-> [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
    -> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
-> [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
    -> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
forall a. [a] -> [a] -> [a]
++
         [ (SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
forall (m :: * -> *) il bl.
(Monad m, IsInline il) =>
SyntaxSpec m il bl
attributesSpec SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
forall a. Semigroup a => a -> a -> a
<>) | Extension -> ReaderOptions -> Bool
forall a. HasSyntaxExtensions a => Extension -> a -> Bool
isEnabled Extension
Ext_attributes ReaderOptions
opts ] [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
 -> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
-> [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
    -> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
-> [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
    -> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
forall a. [a] -> [a] -> [a]
++
         [ (SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
forall a. Semigroup a => a -> a -> a
<> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
forall (m :: * -> *) il bl.
(Monad m, IsBlock il bl, IsInline il, HasPipeTable il bl) =>
SyntaxSpec m il bl
pipeTableSpec) | Extension -> ReaderOptions -> Bool
forall a. HasSyntaxExtensions a => Extension -> a -> Bool
isEnabled Extension
Ext_pipe_tables ReaderOptions
opts ] [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
 -> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
-> [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
    -> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
-> [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
    -> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
forall a. [a] -> [a] -> [a]
++
            -- see #6739
         [ (SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
forall (m :: * -> *) il bl.
(Monad m, IsBlock il bl, IsInline il) =>
SyntaxSpec m il bl
autolinkSpec SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
forall a. Semigroup a => a -> a -> a
<>) | Extension -> ReaderOptions -> Bool
forall a. HasSyntaxExtensions a => Extension -> a -> Bool
isEnabled Extension
Ext_autolink_bare_uris ReaderOptions
opts ] [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
 -> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
-> [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
    -> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
-> [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
    -> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
forall a. [a] -> [a] -> [a]
++
         [ (SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
forall (m :: * -> *) il bl.
(Monad m, IsBlock il bl, IsInline il, HasEmoji il) =>
SyntaxSpec m il bl
emojiSpec SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
forall a. Semigroup a => a -> a -> a
<>) | Extension -> ReaderOptions -> Bool
forall a. HasSyntaxExtensions a => Extension -> a -> Bool
isEnabled Extension
Ext_emoji ReaderOptions
opts ] [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
 -> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
-> [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
    -> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
-> [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
    -> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
forall a. [a] -> [a] -> [a]
++
         [ (SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
forall (m :: * -> *) il bl.
(Monad m, IsBlock il bl, IsInline il, ToPlainText il) =>
SyntaxSpec m il bl
autoIdentifiersSpec SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
forall a. Semigroup a => a -> a -> a
<>)
           | Extension -> ReaderOptions -> Bool
forall a. HasSyntaxExtensions a => Extension -> a -> Bool
isEnabled Extension
Ext_gfm_auto_identifiers ReaderOptions
opts
           , Bool -> Bool
not (Extension -> ReaderOptions -> Bool
forall a. HasSyntaxExtensions a => Extension -> a -> Bool
isEnabled Extension
Ext_ascii_identifiers ReaderOptions
opts) ] [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
 -> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
-> [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
    -> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
-> [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
    -> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
forall a. [a] -> [a] -> [a]
++
         [ (SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
forall (m :: * -> *) il bl.
(Monad m, IsBlock il bl, IsInline il, ToPlainText il) =>
SyntaxSpec m il bl
autoIdentifiersAsciiSpec SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
forall a. Semigroup a => a -> a -> a
<>)
           | Extension -> ReaderOptions -> Bool
forall a. HasSyntaxExtensions a => Extension -> a -> Bool
isEnabled Extension
Ext_gfm_auto_identifiers ReaderOptions
opts
           , Extension -> ReaderOptions -> Bool
forall a. HasSyntaxExtensions a => Extension -> a -> Bool
isEnabled Extension
Ext_ascii_identifiers ReaderOptions
opts ] [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
 -> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
-> [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
    -> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
-> [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
    -> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
forall a. [a] -> [a] -> [a]
++
         [ (SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
forall (m :: * -> *) il bl.
(Monad m, IsBlock il bl, IsInline il) =>
SyntaxSpec m il bl
implicitHeadingReferencesSpec SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
forall a. Semigroup a => a -> a -> a
<>)
           | Extension -> ReaderOptions -> Bool
forall a. HasSyntaxExtensions a => Extension -> a -> Bool
isEnabled Extension
Ext_implicit_header_references ReaderOptions
opts ] [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
 -> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
-> [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
    -> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
-> [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
    -> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
forall a. [a] -> [a] -> [a]
++
         [ (SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
forall (m :: * -> *) il bl.
(Monad m, Typeable m, IsBlock il bl, IsInline il, Typeable il,
 Typeable bl, HasFootnote il bl) =>
SyntaxSpec m il bl
footnoteSpec SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
forall a. Semigroup a => a -> a -> a
<>) | Extension -> ReaderOptions -> Bool
forall a. HasSyntaxExtensions a => Extension -> a -> Bool
isEnabled Extension
Ext_footnotes ReaderOptions
opts ] [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
 -> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
-> [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
    -> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
-> [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
    -> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
forall a. [a] -> [a] -> [a]
++
         [ (SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
forall (m :: * -> *) il bl.
(Monad m, IsBlock il bl, IsInline il, Typeable il, Typeable bl,
 HasDefinitionList il bl) =>
SyntaxSpec m il bl
definitionListSpec SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
forall a. Semigroup a => a -> a -> a
<>) | Extension -> ReaderOptions -> Bool
forall a. HasSyntaxExtensions a => Extension -> a -> Bool
isEnabled Extension
Ext_definition_lists ReaderOptions
opts ] [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
 -> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
-> [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
    -> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
-> [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
    -> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
forall a. [a] -> [a] -> [a]
++
         [ (SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
forall (m :: * -> *) il bl.
(Monad m, IsBlock il bl, IsInline il, HasTaskList il bl) =>
SyntaxSpec m il bl
taskListSpec SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
forall a. Semigroup a => a -> a -> a
<>) | Extension -> ReaderOptions -> Bool
forall a. HasSyntaxExtensions a => Extension -> a -> Bool
isEnabled Extension
Ext_task_lists ReaderOptions
opts ]