module Text.Pandoc.Options ( Extension(..)
, pandocExtensions
, plainExtensions
, strictExtensions
, phpMarkdownExtraExtensions
, githubMarkdownExtensions
, multimarkdownExtensions
, ReaderOptions(..)
, HTMLMathMethod (..)
, CiteMethod (..)
, ObfuscationMethod (..)
, HTMLSlideVariant (..)
, EPUBVersion (..)
, WrapOption (..)
, WriterOptions (..)
, TrackChanges (..)
, def
, isEnabled
) where
import Data.Set (Set)
import qualified Data.Set as Set
import Data.Default
import Text.Pandoc.Highlighting (Style, pygments)
import Text.Pandoc.MediaBag (MediaBag)
import Data.Data (Data)
import Data.Typeable (Typeable)
import GHC.Generics (Generic)
data Extension =
Ext_footnotes
| Ext_inline_notes
| Ext_pandoc_title_block
| Ext_yaml_metadata_block
| Ext_mmd_title_block
| Ext_table_captions
| Ext_implicit_figures
| Ext_simple_tables
| Ext_multiline_tables
| Ext_grid_tables
| Ext_pipe_tables
| Ext_citations
| Ext_raw_tex
| Ext_raw_html
| Ext_tex_math_dollars
| Ext_tex_math_single_backslash
| Ext_tex_math_double_backslash
| Ext_latex_macros
| Ext_fenced_code_blocks
| Ext_fenced_code_attributes
| Ext_backtick_code_blocks
| Ext_inline_code_attributes
| Ext_markdown_in_html_blocks
| Ext_native_divs
| Ext_native_spans
| Ext_markdown_attribute
| Ext_escaped_line_breaks
| Ext_link_attributes
| Ext_mmd_link_attributes
| Ext_autolink_bare_uris
| Ext_fancy_lists
| Ext_lists_without_preceding_blankline
| Ext_startnum
| Ext_definition_lists
| Ext_compact_definition_lists
| Ext_example_lists
| Ext_all_symbols_escapable
| Ext_intraword_underscores
| Ext_blank_before_blockquote
| Ext_blank_before_header
| Ext_strikeout
| Ext_superscript
| Ext_subscript
| Ext_hard_line_breaks
| Ext_ignore_line_breaks
| Ext_east_asian_line_breaks
| Ext_literate_haskell
| Ext_abbreviations
| Ext_emoji
| Ext_auto_identifiers
| Ext_ascii_identifiers
| Ext_header_attributes
| Ext_mmd_header_identifiers
| Ext_implicit_header_references
| Ext_line_blocks
| Ext_epub_html_exts
| Ext_shortcut_reference_links
deriving (Show, Read, Enum, Eq, Ord, Bounded, Data, Typeable, Generic)
pandocExtensions :: Set Extension
pandocExtensions = Set.fromList
[ Ext_footnotes
, Ext_inline_notes
, Ext_pandoc_title_block
, Ext_yaml_metadata_block
, Ext_table_captions
, Ext_implicit_figures
, Ext_simple_tables
, Ext_multiline_tables
, Ext_grid_tables
, Ext_pipe_tables
, Ext_citations
, Ext_raw_tex
, Ext_raw_html
, Ext_tex_math_dollars
, Ext_latex_macros
, Ext_fenced_code_blocks
, Ext_fenced_code_attributes
, Ext_backtick_code_blocks
, Ext_inline_code_attributes
, Ext_markdown_in_html_blocks
, Ext_native_divs
, Ext_native_spans
, Ext_escaped_line_breaks
, Ext_fancy_lists
, Ext_startnum
, Ext_definition_lists
, Ext_example_lists
, Ext_all_symbols_escapable
, Ext_intraword_underscores
, Ext_blank_before_blockquote
, Ext_blank_before_header
, Ext_strikeout
, Ext_superscript
, Ext_subscript
, Ext_auto_identifiers
, Ext_header_attributes
, Ext_link_attributes
, Ext_implicit_header_references
, Ext_line_blocks
, Ext_shortcut_reference_links
]
plainExtensions :: Set Extension
plainExtensions = Set.fromList
[ Ext_table_captions
, Ext_implicit_figures
, Ext_simple_tables
, Ext_multiline_tables
, Ext_grid_tables
, Ext_latex_macros
, Ext_fancy_lists
, Ext_startnum
, Ext_definition_lists
, Ext_example_lists
, Ext_intraword_underscores
, Ext_blank_before_blockquote
, Ext_blank_before_header
, Ext_strikeout
]
phpMarkdownExtraExtensions :: Set Extension
phpMarkdownExtraExtensions = Set.fromList
[ Ext_footnotes
, Ext_pipe_tables
, Ext_raw_html
, Ext_markdown_attribute
, Ext_fenced_code_blocks
, Ext_definition_lists
, Ext_intraword_underscores
, Ext_header_attributes
, Ext_link_attributes
, Ext_abbreviations
, Ext_shortcut_reference_links
]
githubMarkdownExtensions :: Set Extension
githubMarkdownExtensions = Set.fromList
[ Ext_pipe_tables
, Ext_raw_html
, Ext_fenced_code_blocks
, Ext_auto_identifiers
, Ext_ascii_identifiers
, Ext_backtick_code_blocks
, Ext_autolink_bare_uris
, Ext_intraword_underscores
, Ext_strikeout
, Ext_hard_line_breaks
, Ext_emoji
, Ext_lists_without_preceding_blankline
, Ext_shortcut_reference_links
]
multimarkdownExtensions :: Set Extension
multimarkdownExtensions = Set.fromList
[ Ext_pipe_tables
, Ext_raw_html
, Ext_markdown_attribute
, Ext_mmd_link_attributes
, Ext_raw_tex
, Ext_tex_math_double_backslash
, Ext_intraword_underscores
, Ext_mmd_title_block
, Ext_footnotes
, Ext_definition_lists
, Ext_all_symbols_escapable
, Ext_implicit_header_references
, Ext_auto_identifiers
, Ext_mmd_header_identifiers
, Ext_implicit_figures
, Ext_superscript
, Ext_subscript
]
strictExtensions :: Set Extension
strictExtensions = Set.fromList
[ Ext_raw_html
, Ext_shortcut_reference_links
]
data ReaderOptions = ReaderOptions{
readerExtensions :: Set Extension
, readerSmart :: Bool
, readerStandalone :: Bool
, readerParseRaw :: Bool
, readerColumns :: Int
, readerTabStop :: Int
, readerOldDashes :: Bool
, readerApplyMacros :: Bool
, readerIndentedCodeClasses :: [String]
, readerDefaultImageExtension :: String
, readerTrace :: Bool
, readerTrackChanges :: TrackChanges
, readerFileScope :: Bool
} deriving (Show, Read, Data, Typeable, Generic)
instance Default ReaderOptions
where def = ReaderOptions{
readerExtensions = pandocExtensions
, readerSmart = False
, readerStandalone = False
, readerParseRaw = False
, readerColumns = 80
, readerTabStop = 4
, readerOldDashes = False
, readerApplyMacros = True
, readerIndentedCodeClasses = []
, readerDefaultImageExtension = ""
, readerTrace = False
, readerTrackChanges = AcceptChanges
, readerFileScope = False
}
data EPUBVersion = EPUB2 | EPUB3 deriving (Eq, Show, Read, Data, Typeable, Generic)
data HTMLMathMethod = PlainMath
| LaTeXMathML (Maybe String)
| JsMath (Maybe String)
| GladTeX
| WebTeX String
| MathML (Maybe String)
| MathJax String
| KaTeX String String
deriving (Show, Read, Eq, Data, Typeable, Generic)
data CiteMethod = Citeproc
| Natbib
| Biblatex
deriving (Show, Read, Eq, Data, Typeable, Generic)
data ObfuscationMethod = NoObfuscation
| ReferenceObfuscation
| JavascriptObfuscation
deriving (Show, Read, Eq, Data, Typeable, Generic)
data HTMLSlideVariant = S5Slides
| SlidySlides
| SlideousSlides
| DZSlides
| RevealJsSlides
| NoSlides
deriving (Show, Read, Eq, Data, Typeable, Generic)
data TrackChanges = AcceptChanges
| RejectChanges
| AllChanges
deriving (Show, Read, Eq, Data, Typeable, Generic)
data WrapOption = WrapAuto
| WrapNone
| WrapPreserve
deriving (Show, Read, Eq, Data, Typeable, Generic)
data WriterOptions = WriterOptions
{ writerStandalone :: Bool
, writerTemplate :: String
, writerVariables :: [(String, String)]
, writerTabStop :: Int
, writerTableOfContents :: Bool
, writerSlideVariant :: HTMLSlideVariant
, writerIncremental :: Bool
, writerHTMLMathMethod :: HTMLMathMethod
, writerIgnoreNotes :: Bool
, writerNumberSections :: Bool
, writerNumberOffset :: [Int]
, writerSectionDivs :: Bool
, writerExtensions :: Set Extension
, writerReferenceLinks :: Bool
, writerDpi :: Int
, writerWrapText :: WrapOption
, writerColumns :: Int
, writerEmailObfuscation :: ObfuscationMethod
, writerIdentifierPrefix :: String
, writerSourceURL :: Maybe String
, writerUserDataDir :: Maybe FilePath
, writerCiteMethod :: CiteMethod
, writerDocbook5 :: Bool
, writerHtml5 :: Bool
, writerHtmlQTags :: Bool
, writerBeamer :: Bool
, writerSlideLevel :: Maybe Int
, writerChapters :: Bool
, writerListings :: Bool
, writerHighlight :: Bool
, writerHighlightStyle :: Style
, writerSetextHeaders :: Bool
, writerTeXLigatures :: Bool
, writerEpubVersion :: Maybe EPUBVersion
, writerEpubMetadata :: String
, writerEpubStylesheet :: Maybe String
, writerEpubFonts :: [FilePath]
, writerEpubChapterLevel :: Int
, writerTOCDepth :: Int
, writerReferenceODT :: Maybe FilePath
, writerReferenceDocx :: Maybe FilePath
, writerMediaBag :: MediaBag
, writerVerbose :: Bool
, writerLaTeXArgs :: [String]
} deriving (Show, Data, Typeable, Generic)
instance Default WriterOptions where
def = WriterOptions { writerStandalone = False
, writerTemplate = ""
, writerVariables = []
, writerTabStop = 4
, writerTableOfContents = False
, writerSlideVariant = NoSlides
, writerIncremental = False
, writerHTMLMathMethod = PlainMath
, writerIgnoreNotes = False
, writerNumberSections = False
, writerNumberOffset = [0,0,0,0,0,0]
, writerSectionDivs = False
, writerExtensions = pandocExtensions
, writerReferenceLinks = False
, writerDpi = 96
, writerWrapText = WrapAuto
, writerColumns = 72
, writerEmailObfuscation = NoObfuscation
, writerIdentifierPrefix = ""
, writerSourceURL = Nothing
, writerUserDataDir = Nothing
, writerCiteMethod = Citeproc
, writerDocbook5 = False
, writerHtml5 = False
, writerHtmlQTags = False
, writerBeamer = False
, writerSlideLevel = Nothing
, writerChapters = False
, writerListings = False
, writerHighlight = False
, writerHighlightStyle = pygments
, writerSetextHeaders = True
, writerTeXLigatures = True
, writerEpubVersion = Nothing
, writerEpubMetadata = ""
, writerEpubStylesheet = Nothing
, writerEpubFonts = []
, writerEpubChapterLevel = 1
, writerTOCDepth = 3
, writerReferenceODT = Nothing
, writerReferenceDocx = Nothing
, writerMediaBag = mempty
, writerVerbose = False
, writerLaTeXArgs = []
}
isEnabled :: Extension -> WriterOptions -> Bool
isEnabled ext opts = ext `Set.member` (writerExtensions opts)