module Text.Pandoc.Options ( Extension(..)
, pandocExtensions
, strictExtensions
, phpMarkdownExtraExtensions
, githubMarkdownExtensions
, multimarkdownExtensions
, scholarlyMarkdownExtensions
, ReaderOptions(..)
, HTMLMathMethod (..)
, CiteMethod (..)
, ObfuscationMethod (..)
, HTMLSlideVariant (..)
, EPUBVersion (..)
, 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.Monoid
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_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_literate_haskell
| Ext_abbreviations
| 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_scholarly_markdown
deriving (Show, Read, Enum, Eq, Ord, Bounded)
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_implicit_header_references
, Ext_line_blocks
]
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_abbreviations
]
githubMarkdownExtensions :: Set Extension
githubMarkdownExtensions = Set.fromList
[ Ext_pipe_tables
, Ext_raw_html
, Ext_tex_math_single_backslash
, 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_lists_without_preceding_blankline
]
multimarkdownExtensions :: Set Extension
multimarkdownExtensions = Set.fromList
[ Ext_pipe_tables
, Ext_raw_html
, Ext_markdown_attribute
, Ext_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
]
scholarlyMarkdownExtensions :: Set Extension
scholarlyMarkdownExtensions = 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_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_implicit_header_references
, Ext_line_blocks
, Ext_scholarly_markdown
]
strictExtensions :: Set Extension
strictExtensions = Set.fromList
[ Ext_raw_html ]
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
} deriving (Show, Read)
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
}
data EPUBVersion = EPUB2 | EPUB3 deriving (Eq, Show, Read)
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 CiteMethod = Citeproc
| Natbib
| Biblatex
deriving (Show, Read, Eq)
data ObfuscationMethod = NoObfuscation
| ReferenceObfuscation
| JavascriptObfuscation
deriving (Show, Read, Eq)
data HTMLSlideVariant = S5Slides
| SlidySlides
| SlideousSlides
| DZSlides
| RevealJsSlides
| NoSlides
deriving (Show, Read, Eq)
data TrackChanges = AcceptChanges
| RejectChanges
| AllChanges
deriving (Show, Read, Eq)
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
, writerWrapText :: Bool
, writerColumns :: Int
, writerEmailObfuscation :: ObfuscationMethod
, writerIdentifierPrefix :: String
, writerSourceURL :: Maybe String
, writerUserDataDir :: Maybe FilePath
, writerCiteMethod :: CiteMethod
, 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
, writerScholarly :: Bool
} deriving Show
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
, writerWrapText = True
, writerColumns = 72
, writerEmailObfuscation = JavascriptObfuscation
, writerIdentifierPrefix = ""
, writerSourceURL = Nothing
, writerUserDataDir = Nothing
, writerCiteMethod = Citeproc
, 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
, writerScholarly = False
}
isEnabled :: Extension -> WriterOptions -> Bool
isEnabled ext opts = ext `Set.member` (writerExtensions opts)