diff options
author | Albert Krewinkel <albert@zeitkraut.de> | 2016-10-30 13:20:25 +0100 |
---|---|---|
committer | Albert Krewinkel <albert@zeitkraut.de> | 2016-10-30 13:20:25 +0100 |
commit | 63bdc5d08f81365db15b1d9ae11c1d6af72ae35e (patch) | |
tree | 9bec9e51f597ba285d30fae303eb65c7053339e8 | |
parent | d5182778c45704b0a2d5d283a7fca5104588af81 (diff) |
Org reader: support the `todo` export option
The `todo` export option allows to toggle the inclusion of TODO keywords
in the output. Setting this to `nil` causes TODO keywords to be dropped
from headlines. The default is to include the keywords.
-rw-r--r-- | src/Text/Pandoc/Readers/Org/Blocks.hs | 5 | ||||
-rw-r--r-- | src/Text/Pandoc/Readers/Org/ExportSettings.hs | 2 | ||||
-rw-r--r-- | src/Text/Pandoc/Readers/Org/ParserState.hs | 2 | ||||
-rw-r--r-- | tests/Tests/Readers/Org.hs | 6 |
4 files changed, 13 insertions, 2 deletions
diff --git a/src/Text/Pandoc/Readers/Org/Blocks.hs b/src/Text/Pandoc/Readers/Org/Blocks.hs index ead600ccc..a5957dbc9 100644 --- a/src/Text/Pandoc/Readers/Org/Blocks.hs +++ b/src/Text/Pandoc/Readers/Org/Blocks.hs @@ -196,9 +196,12 @@ headlineToHeaderWithContents hdln@(Headline {..}) = do headlineToHeader :: Headline -> OrgParser Blocks headlineToHeader (Headline {..}) = do - let todoText = case headlineTodoMarker of + exportTodoKeyword <- getExportSetting exportWithTodoKeywords + let todoText = if exportTodoKeyword + then case headlineTodoMarker of Just kw -> todoKeywordToInlines kw <> B.space Nothing -> mempty + else mempty let text = tagTitle (todoText <> headlineText) headlineTags let propAttr = propertiesToAttr headlineProperties attr <- registerHeader propAttr headlineText diff --git a/src/Text/Pandoc/Readers/Org/ExportSettings.hs b/src/Text/Pandoc/Readers/Org/ExportSettings.hs index 283cfa998..764e5b0d5 100644 --- a/src/Text/Pandoc/Readers/Org/ExportSettings.hs +++ b/src/Text/Pandoc/Readers/Org/ExportSettings.hs @@ -77,7 +77,7 @@ exportSetting = choice , ignoredSetting "timestamp" , ignoredSetting "title" , ignoredSetting "toc" - , ignoredSetting "todo" + , booleanSetting "todo" (\val es -> es { exportWithTodoKeywords = val }) , ignoredSetting "|" ] <?> "export setting" diff --git a/src/Text/Pandoc/Readers/Org/ParserState.hs b/src/Text/Pandoc/Readers/Org/ParserState.hs index ef5f89461..38f95ca95 100644 --- a/src/Text/Pandoc/Readers/Org/ParserState.hs +++ b/src/Text/Pandoc/Readers/Org/ParserState.hs @@ -205,6 +205,7 @@ data ExportSettings = ExportSettings , exportWithAuthor :: Bool -- ^ Include author in final meta-data , exportWithCreator :: Bool -- ^ Include creator in final meta-data , exportWithEmail :: Bool -- ^ Include email in final meta-data + , exportWithTodoKeywords :: Bool -- ^ Keep TODO keywords in headers } instance Default ExportSettings where @@ -222,6 +223,7 @@ defaultExportSettings = ExportSettings , exportWithAuthor = True , exportWithCreator = True , exportWithEmail = True + , exportWithTodoKeywords = True } diff --git a/tests/Tests/Readers/Org.hs b/tests/Tests/Readers/Org.hs index 30132c795..3aa38ff0c 100644 --- a/tests/Tests/Readers/Org.hs +++ b/tests/Tests/Readers/Org.hs @@ -685,6 +685,12 @@ tests = , "#+email: no-mail-please@example.com" ] =?> Pandoc nullMeta mempty + + , "disable inclusion of todo keywords" =: + unlines [ "#+OPTIONS: todo:nil" + , "** DONE todo export" + ] =?> + headerWith ("todo-export", [], []) 2 "todo export" ] ] |