@@ -40,16 +40,8 @@ module Text.Pandoc.Readers.Org.ParserState
40 , trimInlinesF
40 , trimInlinesF
43− , ExportSettingSetter
44 , ExportSettings (..)
43 , ExportSettings (..)
45 , ArchivedTreesOption (..)
44 , ArchivedTreesOption (..)
46− , setExportArchivedTrees
48− , setExportEmphasizedText
49− , setExportSmartQuotes
50− , setExportSpecialStrings
51− , setExportSubSuperscripts
52− , modifyExportSettings
53 , optionsToParserState
45 , optionsToParserState
@@ -80,26 +72,6 @@ type OrgNoteTable = [OrgNoteRecord]
80-- link-type, the corresponding function transforms the given link string.
72-- link-type, the corresponding function transforms the given link string.
81type OrgLinkFormatters = M.Map String (String -> String)
73type OrgLinkFormatters = M.Map String (String -> String)
83−-- | Options for the way archived trees are handled.
84−data ArchivedTreesOption =
85− ArchivedTreesExport -- ^ Export the complete tree
86− | ArchivedTreesNoExport -- ^ Exclude archived trees from exporting
87− | ArchivedTreesHeadlineOnly -- ^ Export only the headline, discard the contents
89−-- | Export settings <http://orgmode.org/manual/Export-settings.html>
90−-- These settings can be changed via OPTIONS statements.
91−data ExportSettings = ExportSettings
92− { exportArchivedTrees :: ArchivedTreesOption -- ^ How to treat archived trees
93− , exportDrawers :: Either [String] [String]
94− -- ^ Specify drawer names which should be exported. @Left@ names are
95− -- explicitly excluded from the resulting output while @Right@ means that
96− -- only the listed drawer names should be included.
97− , exportEmphasizedText :: Bool -- ^ Parse emphasized text
98− , exportSmartQuotes :: Bool -- ^ Parse quotes smartly
99− , exportSpecialStrings :: Bool -- ^ Parse ellipses and dashes smartly
100− , exportSubSuperscripts :: Bool -- ^ TeX-like syntax for sub- and superscripts
103-- | Org-mode parser state
75-- | Org-mode parser state
104data OrgParserState = OrgParserState
76data OrgParserState = OrgParserState
105 { orgStateAnchorIds :: [String]
77 { orgStateAnchorIds :: [String]
@@ -142,9 +114,6 @@ instance HasHeaderMap OrgParserState where
142 extractHeaderMap = orgStateHeaderMap
114 extractHeaderMap = orgStateHeaderMap
143 updateHeaderMap f s = s{ orgStateHeaderMap = f (orgStateHeaderMap s) }
115 updateHeaderMap f s = s{ orgStateHeaderMap = f (orgStateHeaderMap s) }
145−instance Default ExportSettings where
146− def = defaultExportSettings
148instance Default OrgParserState where
117instance Default OrgParserState where
149 def = defaultOrgParserState
118 def = defaultOrgParserState
@@ -166,60 +135,46 @@ defaultOrgParserState = OrgParserState
166 , orgStateParserContext = NullState
135 , orgStateParserContext = NullState
169−defaultExportSettings :: ExportSettings
170−defaultExportSettings = ExportSettings
171− { exportArchivedTrees = ArchivedTreesHeadlineOnly
172− , exportDrawers = Left ["LOGBOOK"]
173− , exportEmphasizedText = True
174− , exportSmartQuotes = True
175− , exportSpecialStrings = True
176− , exportSubSuperscripts = True
179optionsToParserState :: ReaderOptions -> OrgParserState
138optionsToParserState :: ReaderOptions -> OrgParserState
180optionsToParserState opts =
139optionsToParserState opts =
181 def { orgStateOptions = opts }
140 def { orgStateOptions = opts }
185−-- Setter for exporting options
143+-- Export Settings
188−-- This whole section could be scraped if we were using lenses.
146+-- | Options for the way archived trees are handled.
190−type ExportSettingSetter a = a -> ExportSettings -> ExportSettings
192−-- | Set export options for archived trees.
193−setExportArchivedTrees :: ExportSettingSetter ArchivedTreesOption
147+data ArchivedTreesOption =
194−setExportArchivedTrees val es = es { exportArchivedTrees = val }
148+ ArchivedTreesExport -- ^ Export the complete tree
195−
149+ | ArchivedTreesNoExport -- ^ Exclude archived trees from exporting
196−-- | Set export options for drawers. See the @exportDrawers@ in ADT
150+ | ArchivedTreesHeadlineOnly -- ^ Export only the headline, discard the contents
197−-- @ExportSettings@ for details.
198−setExportDrawers :: ExportSettingSetter (Either [String] [String])
199−setExportDrawers val es = es { exportDrawers = val }
201−-- | Set export options for emphasis parsing.
202−setExportEmphasizedText :: ExportSettingSetter Bool
203−setExportEmphasizedText val es = es { exportEmphasizedText = val }
205−-- | Set export options for parsing of smart quotes.
206−setExportSmartQuotes :: ExportSettingSetter Bool
207−setExportSmartQuotes val es = es { exportSmartQuotes = val }
209−-- | Set export options for parsing of special strings (like em/en dashes or
152+-- | Export settings <http://orgmode.org/manual/Export-settings.html>
210−-- ellipses).
153+-- These settings can be changed via OPTIONS statements.
211−setExportSpecialStrings :: ExportSettingSetter Bool
154+data ExportSettings = ExportSettings
212−setExportSpecialStrings val es = es { exportSpecialStrings = val }
155+ { exportArchivedTrees :: ArchivedTreesOption -- ^ How to treat archived trees
156+ , exportDrawers :: Either [String] [String]
157+ -- ^ Specify drawer names which should be exported. @Left@ names are
158+ -- explicitly excluded from the resulting output while @Right@ means that
159+ -- only the listed drawer names should be included.
160+ , exportEmphasizedText :: Bool -- ^ Parse emphasized text
161+ , exportSmartQuotes :: Bool -- ^ Parse quotes smartly
162+ , exportSpecialStrings :: Bool -- ^ Parse ellipses and dashes smartly
163+ , exportSubSuperscripts :: Bool -- ^ TeX-like syntax for sub- and superscripts
214−-- | Set export options for sub/superscript parsing. The short syntax will
166+instance Default ExportSettings where
215−-- not be parsed if this is set set to @False@.
167+ def = defaultExportSettings
216−setExportSubSuperscripts :: ExportSettingSetter Bool
217−setExportSubSuperscripts val es = es { exportSubSuperscripts = val }
219−-- | Modify a parser state
169+defaultExportSettings :: ExportSettings
220−modifyExportSettings :: ExportSettingSetter a -> a -> OrgParserState -> OrgParserState
170+defaultExportSettings = ExportSettings
221−modifyExportSettings setter val state =
171+ { exportArchivedTrees = ArchivedTreesHeadlineOnly
222− state { orgStateExportSettings = setter val . orgStateExportSettings $ state }
172+ , exportDrawers = Left ["LOGBOOK"]
173+ , exportEmphasizedText = True
174+ , exportSmartQuotes = True
175+ , exportSpecialStrings = True
176+ , exportSubSuperscripts = True