Skip to content

Commit

Permalink
Org reader: respect export setting disabling footnotes
Browse files Browse the repository at this point in the history
Footnotes can be removed from the final document with the `#+OPTION:
f:nil` export setting.
  • Loading branch information
tarleb committed Jun 30, 2020
1 parent efbc205 commit d6711bd
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Text/Pandoc/Readers/Org/ExportSettings.hs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ exportSetting = choice
, ignoredSetting "date"
, booleanSetting "e" (\val es -> es { exportWithEntities = val })
, booleanSetting "email" (\val es -> es { exportWithEmail = val })
, ignoredSetting "f"
, booleanSetting "f" (\val es -> es { exportWithFootnotes = val })
, integerSetting "H" (\val es -> es { exportHeadlineLevels = val })
, ignoredSetting "inline"
, ignoredSetting "num"
Expand Down
5 changes: 4 additions & 1 deletion src/Text/Pandoc/Readers/Org/Inlines.hs
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,10 @@ citation = try $ do
else rest

footnote :: PandocMonad m => OrgParser m (F Inlines)
footnote = try $ inlineNote <|> referencedNote
footnote = try $ do
note <- inlineNote <|> referencedNote
withNote <- getExportSetting exportWithFootnotes
return $ if withNote then note else mempty

inlineNote :: PandocMonad m => OrgParser m (F Inlines)
inlineNote = try $ do
Expand Down
2 changes: 2 additions & 0 deletions src/Text/Pandoc/Readers/Org/ParserState.hs
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ data ExportSettings = ExportSettings
, exportWithCreator :: Bool -- ^ Include creator in final meta-data
, exportWithEmail :: Bool -- ^ Include email in final meta-data
, exportWithEntities :: Bool -- ^ Include MathML-like entities
, exportWithFootnotes :: Bool -- ^ Include footnotes
, exportWithLatex :: TeXExport -- ^ Handling of raw TeX commands
, exportWithPlanning :: Bool -- ^ Keep planning info after headlines
, exportWithTags :: Bool -- ^ Keep tags as part of headlines
Expand All @@ -281,6 +282,7 @@ defaultExportSettings = ExportSettings
, exportWithCreator = True
, exportWithEmail = True
, exportWithEntities = True
, exportWithFootnotes = True
, exportWithLatex = TeXExport
, exportWithPlanning = False
, exportWithTags = True
Expand Down
16 changes: 16 additions & 0 deletions test/Tests/Readers/Org/Directive.hs
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,22 @@ tests =
] =?>
para "Icelandic letter: \\thorn"

, testGroup "Option f"
[ "disable inline footnotes" =:
T.unlines [ "#+OPTIONS: f:nil"
, "Funny![fn:funny:or not]"
] =?>
para "Funny!"

, "disable reference footnotes" =:
T.unlines [ "#+OPTIONS: f:nil"
, "Burn everything[fn:1] down!"
, ""
, "[fn:2] Not quite everything."
] =?>
para "Burn everything down!"
]

, "disable inclusion of todo keywords" =:
T.unlines [ "#+OPTIONS: todo:nil"
, "** DONE todo export"
Expand Down

0 comments on commit d6711bd

Please sign in to comment.