1{-# LANGUAGE DeriveDataTypeable #-}
2{-# LANGUAGE DeriveGeneric #-}
4Copyright (C) 2012-2016 John MacFarlane <jgm@berkeley.edu>
6This program is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation; either version 2 of the License, or
9(at your option) any later version.
11This program is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
16You should have received a copy of the GNU General Public License
17along with this program; if not, write to the Free Software
18Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 Module : Text.Pandoc.Options
23 Copyright : Copyright (C) 2012-2016 John MacFarlane
24 License : GNU GPL, version 2 or above
26 Maintainer : John MacFarlane <jgm@berkeley.edu>
28 Portability : portable
30Data structures and functions for representing parser and writer
33module Text.Pandoc.Options ( module Text.Pandoc.Extensions
37 , ObfuscationMethod (..)
38 , HTMLSlideVariant (..)
41 , TopLevelDivision (..)
44 , ReferenceLocation (..)
48import Data.Data (Data)
50import qualified Data.Set as Set
51import Data.Typeable (Typeable)
52import GHC.Generics (Generic)
53import Text.Pandoc.Extensions
54import Text.Pandoc.Highlighting (Style, pygments)
56data ReaderOptions = ReaderOptions{
57 readerExtensions :: Extensions -- ^ Syntax extensions
58 , readerStandalone :: Bool -- ^ Standalone document with header
59 , readerColumns :: Int -- ^ Number of columns in terminal
60 , readerTabStop :: Int -- ^ Tab stop
61 , readerApplyMacros :: Bool -- ^ Apply macros to TeX math
62 , readerIndentedCodeClasses :: [String] -- ^ Default classes for
63 -- indented code blocks
64 , readerAbbreviations :: Set.Set String -- ^ Strings to treat as abbreviations
65 , readerDefaultImageExtension :: String -- ^ Default extension for images
66 , readerTrackChanges :: TrackChanges
67} deriving (Show, Read, Data, Typeable, Generic)
69instance Default ReaderOptions
70 where def = ReaderOptions{
71 readerExtensions = emptyExtensions
72 , readerStandalone = False
75 , readerApplyMacros = True
76 , readerIndentedCodeClasses = []
77 , readerAbbreviations = defaultAbbrevs
78 , readerDefaultImageExtension = ""
79 , readerTrackChanges = AcceptChanges
82defaultAbbrevs :: Set.Set String
83defaultAbbrevs = Set.fromList
84 [ "Mr.", "Mrs.", "Ms.", "Capt.", "Dr.", "Prof.",
85 "Gen.", "Gov.", "e.g.", "i.e.", "Sgt.", "St.",
86 "vol.", "vs.", "Sen.", "Rep.", "Pres.", "Hon.",
87 "Rev.", "Ph.D.", "M.D.", "M.A.", "p.", "pp.",
88 "ch.", "sec.", "cf.", "cp."]
94data EPUBVersion = EPUB2 | EPUB3 deriving (Eq, Show, Read, Data, Typeable, Generic)
96data HTMLMathMethod = PlainMath
97 | LaTeXMathML (Maybe String) -- url of LaTeXMathML.js
98 | JsMath (Maybe String) -- url of jsMath load script
100 | WebTeX String -- url of TeX->image script.
102 | MathJax String -- url of MathJax.js
103 | KaTeX String String -- url of stylesheet and katex.js
104 deriving (Show, Read, Eq, Data, Typeable, Generic)
106data CiteMethod = Citeproc -- use citeproc to render them
107 | Natbib -- output natbib cite commands
108 | Biblatex -- output biblatex cite commands
109 deriving (Show, Read, Eq, Data, Typeable, Generic)
111-- | Methods for obfuscating email addresses in HTML.
112data ObfuscationMethod = NoObfuscation
113 | ReferenceObfuscation
114 | JavascriptObfuscation
115 deriving (Show, Read, Eq, Data, Typeable, Generic)
117-- | Varieties of HTML slide shows.
118data HTMLSlideVariant = S5Slides
124 deriving (Show, Read, Eq, Data, Typeable, Generic)
126-- | Options for accepting or rejecting MS Word track-changes.
127data TrackChanges = AcceptChanges
130 deriving (Show, Read, Eq, Data, Typeable, Generic)
132-- | Options for wrapping text in the output.
133data WrapOption = WrapAuto -- ^ Automatically wrap to width
134 | WrapNone -- ^ No non-semantic newlines
135 | WrapPreserve -- ^ Preserve wrapping of input source
136 deriving (Show, Read, Eq, Data, Typeable, Generic)
138-- | Options defining the type of top-level headers.
139data TopLevelDivision = TopLevelPart -- ^ Top-level headers become parts
140 | TopLevelChapter -- ^ Top-level headers become chapters
141 | TopLevelSection -- ^ Top-level headers become sections
142 | TopLevelDefault -- ^ Top-level type is determined via
144 deriving (Show, Read, Eq, Data, Typeable, Generic)
146-- | Locations for footnotes and references in markdown output
147data ReferenceLocation = EndOfBlock -- ^ End of block
148 | EndOfSection -- ^ prior to next section header (or end of document)
149 | EndOfDocument -- ^ at end of document
150 deriving (Show, Read, Eq, Data, Typeable, Generic)
152-- | Options for writers
153data WriterOptions = WriterOptions
154 { writerTemplate :: Maybe String -- ^ Template to use
155 , writerVariables :: [(String, String)] -- ^ Variables to set in template
156 , writerTabStop :: Int -- ^ Tabstop for conversion btw spaces and tabs
157 , writerTableOfContents :: Bool -- ^ Include table of contents
158 , writerIncremental :: Bool -- ^ True if lists should be incremental
159 , writerHTMLMathMethod :: HTMLMathMethod -- ^ How to print math in HTML
160 , writerNumberSections :: Bool -- ^ Number sections in LaTeX
161 , writerNumberOffset :: [Int] -- ^ Starting number for section, subsection, ...
162 , writerSectionDivs :: Bool -- ^ Put sections in div tags in HTML
163 , writerExtensions :: Extensions -- ^ Markdown extensions that can be used
164 , writerReferenceLinks :: Bool -- ^ Use reference links in writing markdown, rst
165 , writerDpi :: Int -- ^ Dpi for pixel to/from inch/cm conversions
166 , writerWrapText :: WrapOption -- ^ Option for wrapping text
167 , writerColumns :: Int -- ^ Characters in a line (for text wrapping)
168 , writerEmailObfuscation :: ObfuscationMethod -- ^ How to obfuscate emails
169 , writerIdentifierPrefix :: String -- ^ Prefix for section & note ids in HTML
170 -- and for footnote marks in markdown
171 , writerSourceURL :: Maybe String -- ^ Absolute URL + directory of 1st source file
172 , writerUserDataDir :: Maybe FilePath -- ^ Path of user data directory
173 , writerCiteMethod :: CiteMethod -- ^ How to print cites
174 , writerHtmlQTags :: Bool -- ^ Use @<q>@ tags for quotes in HTML
175 , writerSlideLevel :: Maybe Int -- ^ Force header level of slides
176 , writerTopLevelDivision :: TopLevelDivision -- ^ Type of top-level divisions
177 , writerListings :: Bool -- ^ Use listings package for code
178 , writerHighlightStyle :: Maybe Style -- ^ Style to use for highlighting
179 -- (Nothing = no highlighting)
180 , writerSetextHeaders :: Bool -- ^ Use setext headers for levels 1-2 in markdown
181 , writerEpubMetadata :: Maybe String -- ^ Metadata to include in EPUB
182 , writerEpubFonts :: [FilePath] -- ^ Paths to fonts to embed
183 , writerEpubChapterLevel :: Int -- ^ Header level for chapters (separate files)
184 , writerTOCDepth :: Int -- ^ Number of levels to include in TOC
185 , writerReferenceDoc :: Maybe FilePath -- ^ Path to reference document if specified
186 , writerLaTeXArgs :: [String] -- ^ Flags to pass to latex-engine
187 , writerReferenceLocation :: ReferenceLocation -- ^ Location of footnotes and references for writing markdown
188 } deriving (Show, Data, Typeable, Generic)
190instance Default WriterOptions where
191 def = WriterOptions { writerTemplate = Nothing
192 , writerVariables = []
194 , writerTableOfContents = False
195 , writerIncremental = False
196 , writerHTMLMathMethod = PlainMath
197 , writerNumberSections = False
198 , writerNumberOffset = [0,0,0,0,0,0]
199 , writerSectionDivs = False
200 , writerExtensions = emptyExtensions
201 , writerReferenceLinks = False
203 , writerWrapText = WrapAuto
205 , writerEmailObfuscation = NoObfuscation
206 , writerIdentifierPrefix = ""
207 , writerSourceURL = Nothing
208 , writerUserDataDir = Nothing
209 , writerCiteMethod = Citeproc
210 , writerHtmlQTags = False
211 , writerSlideLevel = Nothing
212 , writerTopLevelDivision = TopLevelDefault
213 , writerListings = False
214 , writerHighlightStyle = Just pygments
215 , writerSetextHeaders = True
216 , writerEpubMetadata = Nothing
217 , writerEpubFonts = []
218 , writerEpubChapterLevel = 1
220 , writerReferenceDoc = Nothing
221 , writerLaTeXArgs = []
222 , writerReferenceLocation = EndOfDocument
225-- | Returns True if the given extension is enabled.
226isEnabled :: Extension -> WriterOptions -> Bool
227isEnabled ext opts = ext `extensionEnabled` (writerExtensions opts)
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list