git.iko.soy/typeable/pandoc
on master help sign in
Org reader: respect export setting disabling footnotes

Footnotes can be removed from the final document with the `#+OPTION: f:nil` export setting.

commitf396fc2e6789bed0083051e34503f56fc921169d authorAlbert Krewinkel <albert@zeitkraut.de> dateTue 30 Jun 2020, 22:19 (6 years ago) parent02dfcda
4 files changed+23−2
src/Text/Pandoc/Readers/Org/ExportSettings.hs+1−1 src/Text/Pandoc/Readers/Org/Inlines.hs+4−1 src/Text/Pandoc/Readers/Org/ParserState.hs+2 test/Tests/Readers/Org/Directive.hs+16
src/Text/Pandoc/Readers/Org/ExportSettings.hs+1−1
@@ -49,7 +49,7 @@ exportSetting = choice
4949 , ignoredSetting "date"
5050 , booleanSetting "e" (\val es -> es { exportWithEntities = val })
5151 , booleanSetting "email" (\val es -> es { exportWithEmail = val })
52− , ignoredSetting "f"
52+ , booleanSetting "f" (\val es -> es { exportWithFootnotes = val })
5353 , integerSetting "H" (\val es -> es { exportHeadlineLevels = val })
5454 , ignoredSetting "inline"
5555 , ignoredSetting "num"
src/Text/Pandoc/Readers/Org/Inlines.hs+4−1
@@ -378,7 +378,10 @@ citation = try $ do
378378 else rest
379379
380380footnote :: PandocMonad m => OrgParser m (F Inlines)
381−footnote = try $ inlineNote <|> referencedNote
381+footnote = try $ do
382+ note <- inlineNote <|> referencedNote
383+ withNote <- getExportSetting exportWithFootnotes
384+ return $ if withNote then note else mempty
382385
383386inlineNote :: PandocMonad m => OrgParser m (F Inlines)
384387inlineNote = try $ do
src/Text/Pandoc/Readers/Org/ParserState.hs+2
@@ -258,6 +258,7 @@ data ExportSettings = ExportSettings
258258 , exportWithCreator :: Bool -- ^ Include creator in final meta-data
259259 , exportWithEmail :: Bool -- ^ Include email in final meta-data
260260 , exportWithEntities :: Bool -- ^ Include MathML-like entities
261+ , exportWithFootnotes :: Bool -- ^ Include footnotes
261262 , exportWithLatex :: TeXExport -- ^ Handling of raw TeX commands
262263 , exportWithPlanning :: Bool -- ^ Keep planning info after headlines
263264 , exportWithTags :: Bool -- ^ Keep tags as part of headlines
@@ -281,6 +282,7 @@ defaultExportSettings = ExportSettings
281282 , exportWithCreator = True
282283 , exportWithEmail = True
283284 , exportWithEntities = True
285+ , exportWithFootnotes = True
284286 , exportWithLatex = TeXExport
285287 , exportWithPlanning = False
286288 , exportWithTags = True
test/Tests/Readers/Org/Directive.hs+16
@@ -156,6 +156,22 @@ tests =
156156 ] =?>
157157 para "Icelandic letter: \\thorn"
158158
159+ , testGroup "Option f"
160+ [ "disable inline footnotes" =:
161+ T.unlines [ "#+OPTIONS: f:nil"
162+ , "Funny![fn:funny:or not]"
163+ ] =?>
164+ para "Funny!"
165+
166+ , "disable reference footnotes" =:
167+ T.unlines [ "#+OPTIONS: f:nil"
168+ , "Burn everything[fn:1] down!"
169+ , ""
170+ , "[fn:2] Not quite everything."
171+ ] =?>
172+ para "Burn everything down!"
173+ ]
174+
159175 , "disable inclusion of todo keywords" =:
160176 T.unlines [ "#+OPTIONS: todo:nil"
161177 , "** DONE todo export"