{-# LANGUAGE CPP                        #-}
{-# LANGUAGE DeriveDataTypeable         #-}
{-# LANGUAGE DeriveGeneric              #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE TemplateHaskell            #-}
{-# LANGUAGE OverloadedStrings          #-}
{- |
   Module      : Text.Pandoc.Extensions
   Copyright   : Copyright (C) 2012-2022 John MacFarlane
   License     : GNU GPL, version 2 or above

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

Data structures and functions for representing markup extensions.
-}
module Text.Pandoc.Extensions ( Extension(..)
                              , Extensions
                              , emptyExtensions
                              , extensionsFromList
                              , parseFormatSpec
                              , extensionEnabled
                              , enableExtension
                              , disableExtension
                              , getDefaultExtensions
                              , getAllExtensions
                              , pandocExtensions
                              , plainExtensions
                              , strictExtensions
                              , phpMarkdownExtraExtensions
                              , githubMarkdownExtensions
                              , multimarkdownExtensions )
where
import Data.Bits (clearBit, setBit, testBit, (.|.))
import Data.Data (Data)
import Data.List (foldl')
import qualified Data.Text as T
import Data.Typeable (Typeable)
import GHC.Generics (Generic)
import Safe (readMay)
import Text.Parsec
import Data.Aeson.TH (deriveJSON)
import Data.Aeson

-- | Individually selectable syntax extensions.
data Extension =
      Ext_abbreviations       -- ^ PHP markdown extra abbreviation definitions
    | Ext_all_symbols_escapable  -- ^ Make all non-alphanumerics escapable
    | Ext_amuse -- ^ Enable Text::Amuse extensions to Emacs Muse markup
    | Ext_angle_brackets_escapable  -- ^ Make < and > escapable
    | Ext_ascii_identifiers   -- ^ ascii-only identifiers for headers;
                              -- presupposes Ext_auto_identifiers
    | Ext_attributes          -- ^ Generic attribute syntax
    | Ext_auto_identifiers    -- ^ Automatic identifiers for headers
    | Ext_autolink_bare_uris  -- ^ Make all absolute URIs into links
    | Ext_backtick_code_blocks    -- ^ GitHub style ``` code blocks
    | Ext_blank_before_blockquote -- ^ Require blank line before a blockquote
    | Ext_blank_before_header     -- ^ Require blank line before a header
    | Ext_bracketed_spans         -- ^ Bracketed spans with attributes
    | Ext_citations           -- ^ Pandoc/citeproc citations
    | Ext_compact_definition_lists  -- ^ Definition lists without space between items,
                                    --   and disallow laziness
    | Ext_definition_lists    -- ^ Definition lists as in pandoc, mmd, php
    | Ext_east_asian_line_breaks  -- ^ Newlines in paragraphs are ignored between
                                  --   East Asian wide characters. Note: this extension
                                  --   does not affect readers/writers directly; it causes
                                  --   the eastAsianLineBreakFilter to be applied after
                                  --   parsing, in Text.Pandoc.App.convertWithOpts.
    | Ext_element_citations   -- ^ Use element-citation elements for JATS citations
    | Ext_emoji               -- ^ Support emoji like :smile:
    | Ext_empty_paragraphs -- ^ Allow empty paragraphs
    | Ext_epub_html_exts      -- ^ Recognise the EPUB extended version of HTML
    | Ext_escaped_line_breaks     -- ^ Treat a backslash at EOL as linebreak
    | Ext_example_lists       -- ^ Markdown-style numbered examples
    | Ext_fancy_lists         -- ^ Enable fancy list numbers and delimiters
    | Ext_fenced_code_attributes  -- ^ Allow attributes on fenced code blocks
    | Ext_fenced_code_blocks  -- ^ Parse fenced code blocks
    | Ext_fenced_divs             -- ^ Allow fenced div syntax :::
    | Ext_footnotes           -- ^ Pandoc\/PHP\/MMD style footnotes
    | Ext_four_space_rule     -- ^ Require 4-space indent for list contents
    | Ext_gfm_auto_identifiers  -- ^ Use GitHub's method for generating
                              -- header identifiers; presupposes
                              -- Ext_auto_identifiers
    | Ext_grid_tables         -- ^ Grid tables (pandoc, reST)
    | Ext_gutenberg           -- ^ Use Project Gutenberg conventions for plain
    | Ext_hard_line_breaks    -- ^ All newlines become hard line breaks
    | Ext_header_attributes   -- ^ Explicit header attributes {#id .class k=v}
    | Ext_ignore_line_breaks  -- ^ Newlines in paragraphs are ignored
    | Ext_implicit_figures    -- ^ A paragraph with just an image is a figure
    | Ext_implicit_header_references -- ^ Implicit reference links for headers
    | Ext_inline_code_attributes  -- ^ Allow attributes on inline code
    | Ext_inline_notes        -- ^ Pandoc-style inline notes
    | Ext_intraword_underscores  -- ^ Treat underscore inside word as literal
    | Ext_latex_macros        -- ^ Parse LaTeX macro definitions (for math only)
    | Ext_line_blocks         -- ^ RST style line blocks
    | Ext_link_attributes         -- ^ link and image attributes
    | Ext_lists_without_preceding_blankline -- ^ Allow lists without preceding blank
    | Ext_literate_haskell    -- ^ Enable literate Haskell conventions
    | Ext_markdown_attribute      -- ^ Interpret text inside HTML as markdown iff
                                  --   container has attribute 'markdown'
    | Ext_markdown_in_html_blocks -- ^ Interpret as markdown inside HTML blocks
    | Ext_mmd_header_identifiers -- ^ Multimarkdown style header identifiers [myid]
    | Ext_mmd_link_attributes     -- ^ MMD style reference link attributes
    | Ext_mmd_title_block     -- ^ Multimarkdown metadata block
    | Ext_multiline_tables    -- ^ Pandoc-style multiline tables
    | Ext_native_divs             -- ^ Use Div blocks for contents of <div> tags
    | Ext_native_spans            -- ^ Use Span inlines for contents of <span>
    | Ext_native_numbering    -- ^ Use output format's native numbering for figures and tables
    | Ext_ntb                 -- ^ ConTeXt Natural Tables
    | Ext_old_dashes          -- ^ -- = em, - before number = en
    | Ext_pandoc_title_block  -- ^ Pandoc title block
    | Ext_pipe_tables         -- ^ Pipe tables (as in PHP markdown extra)
    | Ext_raw_attribute           -- ^ Allow explicit raw blocks/inlines
    | Ext_raw_html            -- ^ Allow raw HTML
    | Ext_raw_tex             -- ^ Allow raw TeX (other than math)
    | Ext_raw_markdown        -- ^ Parse markdown in ipynb as raw markdown
    | Ext_rebase_relative_paths -- ^ Rebase relative image and link paths,
                                -- relative to directory of containing file
    | Ext_short_subsuperscripts -- ^ sub-&superscripts w/o closing char (v~i)
    | Ext_shortcut_reference_links -- ^ Shortcut reference links
    | Ext_simple_tables       -- ^ Pandoc-style simple tables
    | Ext_smart               -- ^ "Smart" quotes, apostrophes, ellipses, dashes
    | Ext_sourcepos           -- ^ Include source position attributes
    | Ext_space_in_atx_header -- ^ Require space between # and header text
    | Ext_spaced_reference_links -- ^ Allow space between two parts of ref link
    | Ext_startnum            -- ^ Make start number of ordered list significant
    | Ext_strikeout           -- ^ Strikeout using ~~this~~ syntax
    | Ext_subscript           -- ^ Subscript using ~this~ syntax
    | Ext_superscript         -- ^ Superscript using ^this^ syntax
    | Ext_styles              -- ^ Read styles that pandoc doesn't know
    | Ext_task_lists          -- ^ Parse certain list items as task list items
    | Ext_table_captions      -- ^ Pandoc-style table captions
    | Ext_tex_math_dollars    -- ^ TeX math between $..$ or $$..$$
    | Ext_tex_math_double_backslash  -- ^ TeX math btw \\(..\\) \\[..\\]
    | Ext_tex_math_single_backslash  -- ^ TeX math btw \(..\) \[..\]
    | Ext_xrefs_name          -- ^ Use xrefs with names
    | Ext_xrefs_number        -- ^ Use xrefs with numbers
    | Ext_yaml_metadata_block -- ^ YAML metadata block
    deriving (Int -> Extension -> ShowS
[Extension] -> ShowS
Extension -> String
(Int -> Extension -> ShowS)
-> (Extension -> String)
-> ([Extension] -> ShowS)
-> Show Extension
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Extension] -> ShowS
$cshowList :: [Extension] -> ShowS
show :: Extension -> String
$cshow :: Extension -> String
showsPrec :: Int -> Extension -> ShowS
$cshowsPrec :: Int -> Extension -> ShowS
Show, ReadPrec [Extension]
ReadPrec Extension
Int -> ReadS Extension
ReadS [Extension]
(Int -> ReadS Extension)
-> ReadS [Extension]
-> ReadPrec Extension
-> ReadPrec [Extension]
-> Read Extension
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Extension]
$creadListPrec :: ReadPrec [Extension]
readPrec :: ReadPrec Extension
$creadPrec :: ReadPrec Extension
readList :: ReadS [Extension]
$creadList :: ReadS [Extension]
readsPrec :: Int -> ReadS Extension
$creadsPrec :: Int -> ReadS Extension
Read, Int -> Extension
Extension -> Int
Extension -> [Extension]
Extension -> Extension
Extension -> Extension -> [Extension]
Extension -> Extension -> Extension -> [Extension]
(Extension -> Extension)
-> (Extension -> Extension)
-> (Int -> Extension)
-> (Extension -> Int)
-> (Extension -> [Extension])
-> (Extension -> Extension -> [Extension])
-> (Extension -> Extension -> [Extension])
-> (Extension -> Extension -> Extension -> [Extension])
-> Enum Extension
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
enumFromThenTo :: Extension -> Extension -> Extension -> [Extension]
$cenumFromThenTo :: Extension -> Extension -> Extension -> [Extension]
enumFromTo :: Extension -> Extension -> [Extension]
$cenumFromTo :: Extension -> Extension -> [Extension]
enumFromThen :: Extension -> Extension -> [Extension]
$cenumFromThen :: Extension -> Extension -> [Extension]
enumFrom :: Extension -> [Extension]
$cenumFrom :: Extension -> [Extension]
fromEnum :: Extension -> Int
$cfromEnum :: Extension -> Int
toEnum :: Int -> Extension
$ctoEnum :: Int -> Extension
pred :: Extension -> Extension
$cpred :: Extension -> Extension
succ :: Extension -> Extension
$csucc :: Extension -> Extension
Enum, Extension -> Extension -> Bool
(Extension -> Extension -> Bool)
-> (Extension -> Extension -> Bool) -> Eq Extension
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Extension -> Extension -> Bool
$c/= :: Extension -> Extension -> Bool
== :: Extension -> Extension -> Bool
$c== :: Extension -> Extension -> Bool
Eq, Eq Extension
Eq Extension
-> (Extension -> Extension -> Ordering)
-> (Extension -> Extension -> Bool)
-> (Extension -> Extension -> Bool)
-> (Extension -> Extension -> Bool)
-> (Extension -> Extension -> Bool)
-> (Extension -> Extension -> Extension)
-> (Extension -> Extension -> Extension)
-> Ord Extension
Extension -> Extension -> Bool
Extension -> Extension -> Ordering
Extension -> Extension -> Extension
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: Extension -> Extension -> Extension
$cmin :: Extension -> Extension -> Extension
max :: Extension -> Extension -> Extension
$cmax :: Extension -> Extension -> Extension
>= :: Extension -> Extension -> Bool
$c>= :: Extension -> Extension -> Bool
> :: Extension -> Extension -> Bool
$c> :: Extension -> Extension -> Bool
<= :: Extension -> Extension -> Bool
$c<= :: Extension -> Extension -> Bool
< :: Extension -> Extension -> Bool
$c< :: Extension -> Extension -> Bool
compare :: Extension -> Extension -> Ordering
$ccompare :: Extension -> Extension -> Ordering
Ord, Extension
Extension -> Extension -> Bounded Extension
forall a. a -> a -> Bounded a
maxBound :: Extension
$cmaxBound :: Extension
minBound :: Extension
$cminBound :: Extension
Bounded, Typeable Extension
Typeable Extension
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Extension -> c Extension)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Extension)
-> (Extension -> Constr)
-> (Extension -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c Extension))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Extension))
-> ((forall b. Data b => b -> b) -> Extension -> Extension)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Extension -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Extension -> r)
-> (forall u. (forall d. Data d => d -> u) -> Extension -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> Extension -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Extension -> m Extension)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Extension -> m Extension)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Extension -> m Extension)
-> Data Extension
Extension -> DataType
Extension -> Constr
(forall b. Data b => b -> b) -> Extension -> Extension
forall a.
Typeable a
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> Extension -> u
forall u. (forall d. Data d => d -> u) -> Extension -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Extension -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Extension -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Extension -> m Extension
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Extension -> m Extension
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Extension
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Extension -> c Extension
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Extension)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Extension)
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Extension -> m Extension
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Extension -> m Extension
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Extension -> m Extension
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Extension -> m Extension
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Extension -> m Extension
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Extension -> m Extension
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Extension -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Extension -> u
gmapQ :: forall u. (forall d. Data d => d -> u) -> Extension -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> Extension -> [u]
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Extension -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Extension -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Extension -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Extension -> r
gmapT :: (forall b. Data b => b -> b) -> Extension -> Extension
$cgmapT :: (forall b. Data b => b -> b) -> Extension -> Extension
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Extension)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Extension)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Extension)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Extension)
dataTypeOf :: Extension -> DataType
$cdataTypeOf :: Extension -> DataType
toConstr :: Extension -> Constr
$ctoConstr :: Extension -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Extension
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Extension
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Extension -> c Extension
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Extension -> c Extension
Data, Typeable, (forall x. Extension -> Rep Extension x)
-> (forall x. Rep Extension x -> Extension) -> Generic Extension
forall x. Rep Extension x -> Extension
forall x. Extension -> Rep Extension x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Extension x -> Extension
$cfrom :: forall x. Extension -> Rep Extension x
Generic)

$(deriveJSON defaultOptions{ constructorTagModifier = drop 4 } ''Extension)

newtype Extensions = Extensions Integer
  deriving (Int -> Extensions -> ShowS
[Extensions] -> ShowS
Extensions -> String
(Int -> Extensions -> ShowS)
-> (Extensions -> String)
-> ([Extensions] -> ShowS)
-> Show Extensions
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Extensions] -> ShowS
$cshowList :: [Extensions] -> ShowS
show :: Extensions -> String
$cshow :: Extensions -> String
showsPrec :: Int -> Extensions -> ShowS
$cshowsPrec :: Int -> Extensions -> ShowS
Show, ReadPrec [Extensions]
ReadPrec Extensions
Int -> ReadS Extensions
ReadS [Extensions]
(Int -> ReadS Extensions)
-> ReadS [Extensions]
-> ReadPrec Extensions
-> ReadPrec [Extensions]
-> Read Extensions
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Extensions]
$creadListPrec :: ReadPrec [Extensions]
readPrec :: ReadPrec Extensions
$creadPrec :: ReadPrec Extensions
readList :: ReadS [Extensions]
$creadList :: ReadS [Extensions]
readsPrec :: Int -> ReadS Extensions
$creadsPrec :: Int -> ReadS Extensions
Read, Extensions -> Extensions -> Bool
(Extensions -> Extensions -> Bool)
-> (Extensions -> Extensions -> Bool) -> Eq Extensions
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Extensions -> Extensions -> Bool
$c/= :: Extensions -> Extensions -> Bool
== :: Extensions -> Extensions -> Bool
$c== :: Extensions -> Extensions -> Bool
Eq, Eq Extensions
Eq Extensions
-> (Extensions -> Extensions -> Ordering)
-> (Extensions -> Extensions -> Bool)
-> (Extensions -> Extensions -> Bool)
-> (Extensions -> Extensions -> Bool)
-> (Extensions -> Extensions -> Bool)
-> (Extensions -> Extensions -> Extensions)
-> (Extensions -> Extensions -> Extensions)
-> Ord Extensions
Extensions -> Extensions -> Bool
Extensions -> Extensions -> Ordering
Extensions -> Extensions -> Extensions
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: Extensions -> Extensions -> Extensions
$cmin :: Extensions -> Extensions -> Extensions
max :: Extensions -> Extensions -> Extensions
$cmax :: Extensions -> Extensions -> Extensions
>= :: Extensions -> Extensions -> Bool
$c>= :: Extensions -> Extensions -> Bool
> :: Extensions -> Extensions -> Bool
$c> :: Extensions -> Extensions -> Bool
<= :: Extensions -> Extensions -> Bool
$c<= :: Extensions -> Extensions -> Bool
< :: Extensions -> Extensions -> Bool
$c< :: Extensions -> Extensions -> Bool
compare :: Extensions -> Extensions -> Ordering
$ccompare :: Extensions -> Extensions -> Ordering
Ord, Typeable Extensions
Typeable Extensions
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Extensions -> c Extensions)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Extensions)
-> (Extensions -> Constr)
-> (Extensions -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c Extensions))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c Extensions))
-> ((forall b. Data b => b -> b) -> Extensions -> Extensions)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Extensions -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Extensions -> r)
-> (forall u. (forall d. Data d => d -> u) -> Extensions -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> Extensions -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Extensions -> m Extensions)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Extensions -> m Extensions)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Extensions -> m Extensions)
-> Data Extensions
Extensions -> DataType
Extensions -> Constr
(forall b. Data b => b -> b) -> Extensions -> Extensions
forall a.
Typeable a
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> Extensions -> u
forall u. (forall d. Data d => d -> u) -> Extensions -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Extensions -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Extensions -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Extensions -> m Extensions
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Extensions -> m Extensions
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Extensions
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Extensions -> c Extensions
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Extensions)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Extensions)
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Extensions -> m Extensions
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Extensions -> m Extensions
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Extensions -> m Extensions
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Extensions -> m Extensions
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Extensions -> m Extensions
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Extensions -> m Extensions
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Extensions -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Extensions -> u
gmapQ :: forall u. (forall d. Data d => d -> u) -> Extensions -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> Extensions -> [u]
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Extensions -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Extensions -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Extensions -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Extensions -> r
gmapT :: (forall b. Data b => b -> b) -> Extensions -> Extensions
$cgmapT :: (forall b. Data b => b -> b) -> Extensions -> Extensions
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Extensions)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Extensions)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Extensions)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Extensions)
dataTypeOf :: Extensions -> DataType
$cdataTypeOf :: Extensions -> DataType
toConstr :: Extensions -> Constr
$ctoConstr :: Extensions -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Extensions
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Extensions
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Extensions -> c Extensions
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Extensions -> c Extensions
Data, Typeable, (forall x. Extensions -> Rep Extensions x)
-> (forall x. Rep Extensions x -> Extensions) -> Generic Extensions
forall x. Rep Extensions x -> Extensions
forall x. Extensions -> Rep Extensions x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Extensions x -> Extensions
$cfrom :: forall x. Extensions -> Rep Extensions x
Generic)

instance Semigroup Extensions where
  (Extensions Integer
a) <> :: Extensions -> Extensions -> Extensions
<> (Extensions Integer
b) = Integer -> Extensions
Extensions (Integer
a Integer -> Integer -> Integer
forall a. Bits a => a -> a -> a
.|. Integer
b)
instance Monoid Extensions where
  mempty :: Extensions
mempty = Integer -> Extensions
Extensions Integer
0
  mappend :: Extensions -> Extensions -> Extensions
mappend = Extensions -> Extensions -> Extensions
forall a. Semigroup a => a -> a -> a
(<>)

instance FromJSON Extensions where
  parseJSON :: Value -> Parser Extensions
parseJSON =
    Extensions -> Parser Extensions
forall (m :: * -> *) a. Monad m => a -> m a
return (Extensions -> Parser Extensions)
-> (Value -> Extensions) -> Value -> Parser Extensions
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Extension -> Extensions -> Extensions)
-> Extensions -> Result Extension -> Extensions
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr Extension -> Extensions -> Extensions
enableExtension Extensions
emptyExtensions (Result Extension -> Extensions)
-> (Value -> Result Extension) -> Value -> Extensions
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Result Extension
forall a. FromJSON a => Value -> Result a
fromJSON

instance ToJSON Extensions where
  toJSON :: Extensions -> Value
toJSON Extensions
exts = [Extension] -> Value
forall a. ToJSON a => a -> Value
toJSON ([Extension] -> Value) -> [Extension] -> Value
forall a b. (a -> b) -> a -> b
$
    [Extension
ext | Extension
ext <- [Extension
forall a. Bounded a => a
minBound..Extension
forall a. Bounded a => a
maxBound], Extension -> Extensions -> Bool
extensionEnabled Extension
ext Extensions
exts]

extensionsFromList :: [Extension] -> Extensions
extensionsFromList :: [Extension] -> Extensions
extensionsFromList = (Extension -> Extensions -> Extensions)
-> Extensions -> [Extension] -> Extensions
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr Extension -> Extensions -> Extensions
enableExtension Extensions
emptyExtensions

emptyExtensions :: Extensions
emptyExtensions :: Extensions
emptyExtensions = Integer -> Extensions
Extensions Integer
0

extensionEnabled :: Extension -> Extensions -> Bool
extensionEnabled :: Extension -> Extensions -> Bool
extensionEnabled Extension
x (Extensions Integer
exts) = Integer -> Int -> Bool
forall a. Bits a => a -> Int -> Bool
testBit Integer
exts (Extension -> Int
forall a. Enum a => a -> Int
fromEnum Extension
x)

enableExtension :: Extension -> Extensions -> Extensions
enableExtension :: Extension -> Extensions -> Extensions
enableExtension Extension
x (Extensions Integer
exts) = Integer -> Extensions
Extensions (Integer -> Int -> Integer
forall a. Bits a => a -> Int -> a
setBit Integer
exts (Extension -> Int
forall a. Enum a => a -> Int
fromEnum Extension
x))

disableExtension :: Extension -> Extensions -> Extensions
disableExtension :: Extension -> Extensions -> Extensions
disableExtension Extension
x (Extensions Integer
exts) = Integer -> Extensions
Extensions (Integer -> Int -> Integer
forall a. Bits a => a -> Int -> a
clearBit Integer
exts (Extension -> Int
forall a. Enum a => a -> Int
fromEnum Extension
x))

-- | Extensions to be used with pandoc-flavored markdown.
pandocExtensions :: Extensions
pandocExtensions :: Extensions
pandocExtensions = [Extension] -> Extensions
extensionsFromList
  [ Extension
Ext_footnotes
  , Extension
Ext_inline_notes
  , Extension
Ext_pandoc_title_block
  , Extension
Ext_yaml_metadata_block
  , Extension
Ext_table_captions
  , Extension
Ext_implicit_figures
  , Extension
Ext_simple_tables
  , Extension
Ext_multiline_tables
  , Extension
Ext_grid_tables
  , Extension
Ext_pipe_tables
  , Extension
Ext_citations
  , Extension
Ext_raw_tex
  , Extension
Ext_raw_html
  , Extension
Ext_tex_math_dollars
  , Extension
Ext_latex_macros
  , Extension
Ext_fenced_code_blocks
  , Extension
Ext_fenced_code_attributes
  , Extension
Ext_backtick_code_blocks
  , Extension
Ext_inline_code_attributes
  , Extension
Ext_raw_attribute
  , Extension
Ext_markdown_in_html_blocks
  , Extension
Ext_native_divs
  , Extension
Ext_fenced_divs
  , Extension
Ext_native_spans
  , Extension
Ext_bracketed_spans
  , Extension
Ext_escaped_line_breaks
  , Extension
Ext_fancy_lists
  , Extension
Ext_startnum
  , Extension
Ext_definition_lists
  , Extension
Ext_example_lists
  , Extension
Ext_all_symbols_escapable
  , Extension
Ext_intraword_underscores
  , Extension
Ext_blank_before_blockquote
  , Extension
Ext_blank_before_header
  , Extension
Ext_space_in_atx_header
  , Extension
Ext_strikeout
  , Extension
Ext_superscript
  , Extension
Ext_subscript
  , Extension
Ext_task_lists
  , Extension
Ext_auto_identifiers
  , Extension
Ext_header_attributes
  , Extension
Ext_link_attributes
  , Extension
Ext_implicit_header_references
  , Extension
Ext_line_blocks
  , Extension
Ext_shortcut_reference_links
  , Extension
Ext_smart
  ]

-- | Extensions to be used with plain text output.
plainExtensions :: Extensions
plainExtensions :: Extensions
plainExtensions = [Extension] -> Extensions
extensionsFromList
  [ Extension
Ext_table_captions
  , Extension
Ext_implicit_figures
  , Extension
Ext_simple_tables
  , Extension
Ext_multiline_tables
  , Extension
Ext_grid_tables
  , Extension
Ext_latex_macros
  , Extension
Ext_fancy_lists
  , Extension
Ext_startnum
  , Extension
Ext_definition_lists
  , Extension
Ext_example_lists
  , Extension
Ext_intraword_underscores
  , Extension
Ext_blank_before_blockquote
  , Extension
Ext_blank_before_header
  , Extension
Ext_strikeout
  ]

-- | Extensions to be used with PHP Markdown Extra.
phpMarkdownExtraExtensions :: Extensions
phpMarkdownExtraExtensions :: Extensions
phpMarkdownExtraExtensions = [Extension] -> Extensions
extensionsFromList
  [ Extension
Ext_footnotes
  , Extension
Ext_pipe_tables
  , Extension
Ext_raw_html
  , Extension
Ext_markdown_attribute
  , Extension
Ext_fenced_code_blocks
  , Extension
Ext_definition_lists
  , Extension
Ext_intraword_underscores
  , Extension
Ext_header_attributes
  , Extension
Ext_link_attributes
  , Extension
Ext_abbreviations
  , Extension
Ext_shortcut_reference_links
  , Extension
Ext_spaced_reference_links
  ]

-- | Extensions to be used with github-flavored markdown.
githubMarkdownExtensions :: Extensions
githubMarkdownExtensions :: Extensions
githubMarkdownExtensions = [Extension] -> Extensions
extensionsFromList
  [ Extension
Ext_pipe_tables
  , Extension
Ext_raw_html
  , Extension
Ext_native_divs
  , Extension
Ext_auto_identifiers
  , Extension
Ext_gfm_auto_identifiers
  , Extension
Ext_autolink_bare_uris
  , Extension
Ext_strikeout
  , Extension
Ext_task_lists
  , Extension
Ext_emoji
  , Extension
Ext_fenced_code_blocks
  , Extension
Ext_backtick_code_blocks
  ]

-- | Extensions to be used with multimarkdown.
multimarkdownExtensions :: Extensions
multimarkdownExtensions :: Extensions
multimarkdownExtensions = [Extension] -> Extensions
extensionsFromList
  [ Extension
Ext_pipe_tables
  , Extension
Ext_raw_html
  , Extension
Ext_markdown_attribute
  , Extension
Ext_mmd_link_attributes
  -- , Ext_raw_tex
  -- Note: MMD's raw TeX syntax requires raw TeX to be
  -- enclosed in HTML comment
  , Extension
Ext_tex_math_double_backslash
  , Extension
Ext_tex_math_dollars
  , Extension
Ext_intraword_underscores
  , Extension
Ext_mmd_title_block
  , Extension
Ext_footnotes
  , Extension
Ext_definition_lists
  , Extension
Ext_all_symbols_escapable
  , Extension
Ext_implicit_header_references
  , Extension
Ext_shortcut_reference_links
  , Extension
Ext_auto_identifiers
  , Extension
Ext_mmd_header_identifiers
  , Extension
Ext_implicit_figures
  , Extension
Ext_short_subsuperscripts
  , Extension
Ext_subscript
  , Extension
Ext_superscript
  , Extension
Ext_backtick_code_blocks
  , Extension
Ext_spaced_reference_links
  -- So far only in dev version of mmd:
  , Extension
Ext_raw_attribute
  ]

-- | Language extensions to be used with strict markdown.
strictExtensions :: Extensions
strictExtensions :: Extensions
strictExtensions = [Extension] -> Extensions
extensionsFromList
  [ Extension
Ext_raw_html
  , Extension
Ext_shortcut_reference_links
  , Extension
Ext_spaced_reference_links
  ]

-- | Default extensions from format-describing string.
getDefaultExtensions :: T.Text -> Extensions
getDefaultExtensions :: Text -> Extensions
getDefaultExtensions Text
"markdown_strict"   = Extensions
strictExtensions
getDefaultExtensions Text
"markdown_phpextra" = Extensions
phpMarkdownExtraExtensions
getDefaultExtensions Text
"markdown_mmd"      = Extensions
multimarkdownExtensions
getDefaultExtensions Text
"markdown_github"   = Extensions
githubMarkdownExtensions Extensions -> Extensions -> Extensions
forall a. Semigroup a => a -> a -> a
<>
  [Extension] -> Extensions
extensionsFromList
    [ Extension
Ext_all_symbols_escapable
    , Extension
Ext_backtick_code_blocks
    , Extension
Ext_fenced_code_blocks
    , Extension
Ext_space_in_atx_header
    , Extension
Ext_intraword_underscores
    , Extension
Ext_lists_without_preceding_blankline
    , Extension
Ext_shortcut_reference_links
    ]
getDefaultExtensions Text
"markdown"          = Extensions
pandocExtensions
getDefaultExtensions Text
"ipynb"             =
  [Extension] -> Extensions
extensionsFromList
    [ Extension
Ext_all_symbols_escapable
    , Extension
Ext_pipe_tables
    , Extension
Ext_raw_html
    , Extension
Ext_fenced_code_blocks
    , Extension
Ext_auto_identifiers
    , Extension
Ext_gfm_auto_identifiers
    , Extension
Ext_backtick_code_blocks
    , Extension
Ext_autolink_bare_uris
    , Extension
Ext_space_in_atx_header
    , Extension
Ext_intraword_underscores
    , Extension
Ext_strikeout
    , Extension
Ext_task_lists
    , Extension
Ext_lists_without_preceding_blankline
    , Extension
Ext_shortcut_reference_links
    , Extension
Ext_tex_math_dollars
    ]
getDefaultExtensions Text
"muse"            = [Extension] -> Extensions
extensionsFromList
                                           [Extension
Ext_amuse,
                                            Extension
Ext_auto_identifiers]
getDefaultExtensions Text
"plain"           = Extensions
plainExtensions
getDefaultExtensions Text
"gfm"             = [Extension] -> Extensions
extensionsFromList
  [ Extension
Ext_pipe_tables
  , Extension
Ext_raw_html
  , Extension
Ext_native_divs
  , Extension
Ext_auto_identifiers
  , Extension
Ext_gfm_auto_identifiers
  , Extension
Ext_autolink_bare_uris
  , Extension
Ext_strikeout
  , Extension
Ext_task_lists
  , Extension
Ext_emoji
  , Extension
Ext_yaml_metadata_block
  , Extension
Ext_footnotes
  ]
getDefaultExtensions Text
"commonmark"      = [Extension] -> Extensions
extensionsFromList
                                          [Extension
Ext_raw_html]
getDefaultExtensions Text
"commonmark_x"    = [Extension] -> Extensions
extensionsFromList
  [ Extension
Ext_pipe_tables
  , Extension
Ext_raw_html
  , Extension
Ext_gfm_auto_identifiers
  , Extension
Ext_strikeout
  , Extension
Ext_task_lists
  , Extension
Ext_emoji
  , Extension
Ext_pipe_tables
  , Extension
Ext_raw_html
  , Extension
Ext_raw_tex            -- only supported in writer (for math)
  , Extension
Ext_smart
  , Extension
Ext_tex_math_dollars
  , Extension
Ext_superscript
  , Extension
Ext_subscript
  , Extension
Ext_definition_lists
  , Extension
Ext_footnotes
  , Extension
Ext_fancy_lists
  , Extension
Ext_fenced_divs
  , Extension
Ext_bracketed_spans
  , Extension
Ext_raw_attribute
  , Extension
Ext_implicit_header_references
  , Extension
Ext_attributes
  , Extension
Ext_yaml_metadata_block
  ]
getDefaultExtensions Text
"org"             = [Extension] -> Extensions
extensionsFromList
                                          [Extension
Ext_citations,
                                           Extension
Ext_task_lists,
                                           Extension
Ext_auto_identifiers]
getDefaultExtensions Text
"html"            = [Extension] -> Extensions
extensionsFromList
                                          [Extension
Ext_auto_identifiers,
                                           Extension
Ext_native_divs,
                                           Extension
Ext_line_blocks,
                                           Extension
Ext_native_spans]
getDefaultExtensions Text
"html4"           = Text -> Extensions
getDefaultExtensions Text
"html"
getDefaultExtensions Text
"html5"           = Text -> Extensions
getDefaultExtensions Text
"html"
getDefaultExtensions Text
"epub"            = [Extension] -> Extensions
extensionsFromList
                                          [Extension
Ext_raw_html,
                                           Extension
Ext_native_divs,
                                           Extension
Ext_native_spans,
                                           Extension
Ext_epub_html_exts]
getDefaultExtensions Text
"epub2"           = Text -> Extensions
getDefaultExtensions Text
"epub"
getDefaultExtensions Text
"epub3"           = Text -> Extensions
getDefaultExtensions Text
"epub"
getDefaultExtensions Text
"latex"           = [Extension] -> Extensions
extensionsFromList
                                          [Extension
Ext_smart,
                                           Extension
Ext_latex_macros,
                                           Extension
Ext_auto_identifiers]
getDefaultExtensions Text
"beamer"          = [Extension] -> Extensions
extensionsFromList
                                          [Extension
Ext_smart,
                                           Extension
Ext_latex_macros,
                                           Extension
Ext_auto_identifiers]
getDefaultExtensions Text
"context"         = [Extension] -> Extensions
extensionsFromList
                                          [Extension
Ext_smart,
                                           Extension
Ext_auto_identifiers]
getDefaultExtensions Text
"textile"         = [Extension] -> Extensions
extensionsFromList
                                          [Extension
Ext_old_dashes,
                                           Extension
Ext_smart,
                                           Extension
Ext_raw_html,
                                           Extension
Ext_auto_identifiers]
getDefaultExtensions Text
"jats"            = [Extension] -> Extensions
extensionsFromList
                                          [Extension
Ext_auto_identifiers]
getDefaultExtensions Text
"jats_archiving"  = Text -> Extensions
getDefaultExtensions Text
"jats"
getDefaultExtensions Text
"jats_publishing" = Text -> Extensions
getDefaultExtensions Text
"jats"
getDefaultExtensions Text
"jats_articleauthoring" = Text -> Extensions
getDefaultExtensions Text
"jats"
getDefaultExtensions Text
"opml"            = Extensions
pandocExtensions -- affects notes
getDefaultExtensions Text
"markua"          = [Extension] -> Extensions
extensionsFromList
                                          []
getDefaultExtensions Text
_                 = [Extension] -> Extensions
extensionsFromList
                                          [Extension
Ext_auto_identifiers]


-- | Get all valid extensions for a format. This is used
-- mainly in checking format specifications for validity.
getAllExtensions :: T.Text -> Extensions
getAllExtensions :: Text -> Extensions
getAllExtensions Text
f = Extensions
universalExtensions Extensions -> Extensions -> Extensions
forall a. Semigroup a => a -> a -> a
<> Text -> Extensions
forall {t}. (Eq t, IsString t) => t -> Extensions
getAll Text
f
 where
  autoIdExtensions :: Extensions
autoIdExtensions           = [Extension] -> Extensions
extensionsFromList
    [ Extension
Ext_auto_identifiers
    , Extension
Ext_gfm_auto_identifiers
    , Extension
Ext_ascii_identifiers
    ]
  universalExtensions :: Extensions
universalExtensions        = [Extension] -> Extensions
extensionsFromList
    [ Extension
Ext_east_asian_line_breaks ]
  allMarkdownExtensions :: Extensions
allMarkdownExtensions =
    Extensions
pandocExtensions Extensions -> Extensions -> Extensions
forall a. Semigroup a => a -> a -> a
<> Extensions
autoIdExtensions Extensions -> Extensions -> Extensions
forall a. Semigroup a => a -> a -> a
<>
      [Extension] -> Extensions
extensionsFromList
       [ Extension
Ext_old_dashes
       , Extension
Ext_angle_brackets_escapable
       , Extension
Ext_lists_without_preceding_blankline
       , Extension
Ext_four_space_rule
       , Extension
Ext_spaced_reference_links
       , Extension
Ext_hard_line_breaks
       , Extension
Ext_ignore_line_breaks
       , Extension
Ext_east_asian_line_breaks
       , Extension
Ext_emoji
       , Extension
Ext_tex_math_single_backslash
       , Extension
Ext_tex_math_double_backslash
       , Extension
Ext_markdown_attribute
       , Extension
Ext_mmd_title_block
       , Extension
Ext_abbreviations
       , Extension
Ext_autolink_bare_uris
       , Extension
Ext_mmd_link_attributes
       , Extension
Ext_mmd_header_identifiers
       , Extension
Ext_compact_definition_lists
       , Extension
Ext_gutenberg
       , Extension
Ext_smart
       , Extension
Ext_literate_haskell
       , Extension
Ext_short_subsuperscripts
       , Extension
Ext_rebase_relative_paths
       ]
  getAll :: t -> Extensions
getAll t
"markdown_strict"   = Extensions
allMarkdownExtensions
  getAll t
"markdown_phpextra" = Extensions
allMarkdownExtensions
  getAll t
"markdown_mmd"      = Extensions
allMarkdownExtensions
  getAll t
"markdown_github"   = Extensions
allMarkdownExtensions
  getAll t
"markdown"          = Extensions
allMarkdownExtensions
  getAll t
"ipynb"             = Extensions
allMarkdownExtensions Extensions -> Extensions -> Extensions
forall a. Semigroup a => a -> a -> a
<> [Extension] -> Extensions
extensionsFromList
    [ Extension
Ext_raw_markdown ]
  getAll t
"docx"            = Extensions
autoIdExtensions Extensions -> Extensions -> Extensions
forall a. Semigroup a => a -> a -> a
<> [Extension] -> Extensions
extensionsFromList
    [ Extension
Ext_empty_paragraphs
    , Extension
Ext_native_numbering
    , Extension
Ext_styles
    ]
  getAll t
"opendocument"    = [Extension] -> Extensions
extensionsFromList
    [ Extension
Ext_empty_paragraphs
    , Extension
Ext_native_numbering
    , Extension
Ext_xrefs_name
    , Extension
Ext_xrefs_number
    ]
  getAll t
"odt"             = t -> Extensions
getAll t
"opendocument" Extensions -> Extensions -> Extensions
forall a. Semigroup a => a -> a -> a
<> Extensions
autoIdExtensions
  getAll t
"muse"            = Extensions
autoIdExtensions Extensions -> Extensions -> Extensions
forall a. Semigroup a => a -> a -> a
<>
    [Extension] -> Extensions
extensionsFromList
    [ Extension
Ext_amuse ]
  getAll t
"asciidoc"        = Extensions
autoIdExtensions
  getAll t
"plain"           = Extensions
allMarkdownExtensions
  getAll t
"gfm"             = t -> Extensions
getAll t
"commonmark"
  getAll t
"commonmark"      =
    [Extension] -> Extensions
extensionsFromList
    [ Extension
Ext_gfm_auto_identifiers
    , Extension
Ext_ascii_identifiers
    , Extension
Ext_pipe_tables
    , Extension
Ext_autolink_bare_uris
    , Extension
Ext_strikeout
    , Extension
Ext_task_lists
    , Extension
Ext_emoji
    , Extension
Ext_raw_html
    , Extension
Ext_raw_tex            -- only supported in writer (for math)
    , Extension
Ext_implicit_figures
    , Extension
Ext_hard_line_breaks
    , Extension
Ext_smart
    , Extension
Ext_tex_math_dollars
    , Extension
Ext_superscript
    , Extension
Ext_subscript
    , Extension
Ext_definition_lists
    , Extension
Ext_footnotes
    , Extension
Ext_fancy_lists
    , Extension
Ext_fenced_divs
    , Extension
Ext_bracketed_spans
    , Extension
Ext_raw_attribute
    , Extension
Ext_implicit_header_references
    , Extension
Ext_attributes
    , Extension
Ext_sourcepos
    , Extension
Ext_yaml_metadata_block
    , Extension
Ext_rebase_relative_paths
    ]
  getAll t
"commonmark_x"    = t -> Extensions
getAll t
"commonmark"
  getAll t
"org"             = Extensions
autoIdExtensions Extensions -> Extensions -> Extensions
forall a. Semigroup a => a -> a -> a
<>
    [Extension] -> Extensions
extensionsFromList
    [ Extension
Ext_citations
    , Extension
Ext_smart
    , Extension
Ext_fancy_lists
    , Extension
Ext_task_lists
    ]
  getAll t
"html"            = Extensions
autoIdExtensions Extensions -> Extensions -> Extensions
forall a. Semigroup a => a -> a -> a
<>
    [Extension] -> Extensions
extensionsFromList
    [ Extension
Ext_native_divs
    , Extension
Ext_line_blocks
    , Extension
Ext_native_spans
    , Extension
Ext_empty_paragraphs
    , Extension
Ext_raw_html
    , Extension
Ext_raw_tex
    , Extension
Ext_task_lists
    , Extension
Ext_tex_math_dollars
    , Extension
Ext_tex_math_single_backslash
    , Extension
Ext_tex_math_double_backslash
    , Extension
Ext_literate_haskell
    , Extension
Ext_epub_html_exts
    , Extension
Ext_smart
    ]
  getAll t
"html4"           = t -> Extensions
getAll t
"html"
  getAll t
"html5"           = t -> Extensions
getAll t
"html"
  getAll t
"epub"            = t -> Extensions
getAll t
"html"
  getAll t
"epub2"           = t -> Extensions
getAll t
"epub"
  getAll t
"epub3"           = t -> Extensions
getAll t
"epub"
  getAll t
"latex"           = Extensions
autoIdExtensions Extensions -> Extensions -> Extensions
forall a. Semigroup a => a -> a -> a
<>
    [Extension] -> Extensions
extensionsFromList
    [ Extension
Ext_smart
    , Extension
Ext_latex_macros
    , Extension
Ext_raw_tex
    , Extension
Ext_task_lists
    , Extension
Ext_literate_haskell
    ]
  getAll t
"beamer"          = t -> Extensions
getAll t
"latex"
  getAll t
"context"         = Extensions
autoIdExtensions Extensions -> Extensions -> Extensions
forall a. Semigroup a => a -> a -> a
<>
    [Extension] -> Extensions
extensionsFromList
    [ Extension
Ext_smart
    , Extension
Ext_raw_tex
    , Extension
Ext_ntb
    ]
  getAll t
"textile"         = Extensions
autoIdExtensions Extensions -> Extensions -> Extensions
forall a. Semigroup a => a -> a -> a
<>
    [Extension] -> Extensions
extensionsFromList
    [ Extension
Ext_old_dashes
    , Extension
Ext_smart
    , Extension
Ext_raw_tex
    ]
  getAll t
"jats"            =
    [Extension] -> Extensions
extensionsFromList
    [ Extension
Ext_auto_identifiers
    , Extension
Ext_element_citations
    ]
  getAll t
"jats_archiving"  = t -> Extensions
getAll t
"jats"
  getAll t
"jats_publishing" = t -> Extensions
getAll t
"jats"
  getAll t
"jats_articleauthoring" = t -> Extensions
getAll t
"jats"
  getAll t
"opml"            = Extensions
allMarkdownExtensions -- affects notes
  getAll t
"twiki"           = Extensions
autoIdExtensions Extensions -> Extensions -> Extensions
forall a. Semigroup a => a -> a -> a
<>
    [Extension] -> Extensions
extensionsFromList
    [ Extension
Ext_smart ]
  getAll t
"vimwiki"         = Extensions
autoIdExtensions
  getAll t
"dokuwiki"        = Extensions
autoIdExtensions
  getAll t
"tikiwiki"        = Extensions
autoIdExtensions
  getAll t
"rst"             = Extensions
autoIdExtensions Extensions -> Extensions -> Extensions
forall a. Semigroup a => a -> a -> a
<>
    [Extension] -> Extensions
extensionsFromList
    [ Extension
Ext_smart
    , Extension
Ext_literate_haskell
    ]
  getAll t
"mediawiki"       = Extensions
autoIdExtensions Extensions -> Extensions -> Extensions
forall a. Semigroup a => a -> a -> a
<>
    [Extension] -> Extensions
extensionsFromList
    [ Extension
Ext_smart ]
  getAll t
_                 = Extensions
forall a. Monoid a => a
mempty


-- | Parse a format-specifying string into a markup format,
-- a set of extensions to enable, and a set of extensions to disable.
parseFormatSpec :: T.Text
                -> Either ParseError (T.Text, [Extension], [Extension])
parseFormatSpec :: Text -> Either ParseError (Text, [Extension], [Extension])
parseFormatSpec = Parsec Text () (Text, [Extension], [Extension])
-> String
-> Text
-> Either ParseError (Text, [Extension], [Extension])
forall s t a.
Stream s Identity t =>
Parsec s () a -> String -> s -> Either ParseError a
parse Parsec Text () (Text, [Extension], [Extension])
forall {u}.
ParsecT Text u Identity (Text, [Extension], [Extension])
formatSpec String
""
  where formatSpec :: ParsecT Text u Identity (Text, [Extension], [Extension])
formatSpec = do
          String
name <- ParsecT Text u Identity String
forall {u}. ParsecT Text u Identity String
formatName
          ([Extension]
extsToEnable, [Extension]
extsToDisable) <- (([Extension], [Extension])
 -> (([Extension], [Extension]) -> ([Extension], [Extension]))
 -> ([Extension], [Extension]))
-> ([Extension], [Extension])
-> [([Extension], [Extension]) -> ([Extension], [Extension])]
-> ([Extension], [Extension])
forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
foldl' (((([Extension], [Extension]) -> ([Extension], [Extension]))
 -> ([Extension], [Extension]) -> ([Extension], [Extension]))
-> ([Extension], [Extension])
-> (([Extension], [Extension]) -> ([Extension], [Extension]))
-> ([Extension], [Extension])
forall a b c. (a -> b -> c) -> b -> a -> c
flip (([Extension], [Extension]) -> ([Extension], [Extension]))
-> ([Extension], [Extension]) -> ([Extension], [Extension])
forall a b. (a -> b) -> a -> b
($)) ([],[]) ([([Extension], [Extension]) -> ([Extension], [Extension])]
 -> ([Extension], [Extension]))
-> ParsecT
     Text
     u
     Identity
     [([Extension], [Extension]) -> ([Extension], [Extension])]
-> ParsecT Text u Identity ([Extension], [Extension])
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
                                             ParsecT
  Text
  u
  Identity
  (([Extension], [Extension]) -> ([Extension], [Extension]))
-> ParsecT
     Text
     u
     Identity
     [([Extension], [Extension]) -> ([Extension], [Extension])]
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many ParsecT
  Text
  u
  Identity
  (([Extension], [Extension]) -> ([Extension], [Extension]))
forall {u}.
ParsecT
  Text
  u
  Identity
  (([Extension], [Extension]) -> ([Extension], [Extension]))
extMod
          (Text, [Extension], [Extension])
-> ParsecT Text u Identity (Text, [Extension], [Extension])
forall (m :: * -> *) a. Monad m => a -> m a
return (String -> Text
T.pack String
name, [Extension] -> [Extension]
forall a. [a] -> [a]
reverse [Extension]
extsToEnable, [Extension] -> [Extension]
forall a. [a] -> [a]
reverse [Extension]
extsToDisable)
        formatName :: ParsecT Text u Identity String
formatName = ParsecT Text u Identity Char -> ParsecT Text u Identity String
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m [a]
many1 (ParsecT Text u Identity Char -> ParsecT Text u Identity String)
-> ParsecT Text u Identity Char -> ParsecT Text u Identity String
forall a b. (a -> b) -> a -> b
$ String -> ParsecT Text u Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
String -> ParsecT s u m Char
noneOf String
"-+"
        extMod :: ParsecT
  Text
  u
  Identity
  (([Extension], [Extension]) -> ([Extension], [Extension]))
extMod = do
          Char
polarity <- String -> ParsecT Text u Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
String -> ParsecT s u m Char
oneOf String
"-+"
          String
name <- ParsecT Text u Identity Char -> ParsecT Text u Identity String
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many (ParsecT Text u Identity Char -> ParsecT Text u Identity String)
-> ParsecT Text u Identity Char -> ParsecT Text u Identity String
forall a b. (a -> b) -> a -> b
$ String -> ParsecT Text u Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
String -> ParsecT s u m Char
noneOf String
"-+"
          Extension
ext <- case String -> Maybe Extension
forall a. Read a => String -> Maybe a
readMay (String
"Ext_" String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
name) of
                       Just Extension
n  -> Extension -> ParsecT Text u Identity Extension
forall (m :: * -> *) a. Monad m => a -> m a
return Extension
n
                       Maybe Extension
Nothing
                         | String
name String -> String -> Bool
forall a. Eq a => a -> a -> Bool
== String
"lhs" -> Extension -> ParsecT Text u Identity Extension
forall (m :: * -> *) a. Monad m => a -> m a
return Extension
Ext_literate_haskell
                         | Bool
otherwise -> String -> ParsecT Text u Identity Extension
forall s (m :: * -> *) t u a.
Stream s m t =>
String -> ParsecT s u m a
unexpected (String -> ParsecT Text u Identity Extension)
-> String -> ParsecT Text u Identity Extension
forall a b. (a -> b) -> a -> b
$
                                          String
"unknown extension: " String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
name
          (([Extension], [Extension]) -> ([Extension], [Extension]))
-> ParsecT
     Text
     u
     Identity
     (([Extension], [Extension]) -> ([Extension], [Extension]))
forall (m :: * -> *) a. Monad m => a -> m a
return ((([Extension], [Extension]) -> ([Extension], [Extension]))
 -> ParsecT
      Text
      u
      Identity
      (([Extension], [Extension]) -> ([Extension], [Extension])))
-> (([Extension], [Extension]) -> ([Extension], [Extension]))
-> ParsecT
     Text
     u
     Identity
     (([Extension], [Extension]) -> ([Extension], [Extension]))
forall a b. (a -> b) -> a -> b
$ \([Extension]
extsToEnable, [Extension]
extsToDisable) ->
                    case Char
polarity of
                        Char
'+' -> (Extension
ext Extension -> [Extension] -> [Extension]
forall a. a -> [a] -> [a]
: [Extension]
extsToEnable, [Extension]
extsToDisable)
                        Char
_   -> ([Extension]
extsToEnable, Extension
ext Extension -> [Extension] -> [Extension]
forall a. a -> [a] -> [a]
: [Extension]
extsToDisable)