git.iko.soy/typeable/pandoc
on master help sign in
Org reader: respect export option for tags
e1a0666Albert Krewinkel
src/Text/Pandoc/Readers/Org/DocumentTree.hs+5−1
@@ -220,12 +220,16 @@ headlineToHeaderWithContents hdln@(Headline {..}) = do
220headlineToHeader :: Monad m => Headline -> OrgParser m Blocks
220headlineToHeader :: Monad m => Headline -> OrgParser m Blocks
221headlineToHeader (Headline {..}) = do
221headlineToHeader (Headline {..}) = do
222 exportTodoKeyword <- getExportSetting exportWithTodoKeywords
222 exportTodoKeyword <- getExportSetting exportWithTodoKeywords
223+ exportTags <- getExportSetting exportWithTags
223 let todoText = if exportTodoKeyword
224 let todoText = if exportTodoKeyword
224 then case headlineTodoMarker of
225 then case headlineTodoMarker of
225 Just kw -> todoKeywordToInlines kw <> B.space
226 Just kw -> todoKeywordToInlines kw <> B.space
226 Nothing -> mempty
227 Nothing -> mempty
227 else mempty
228 else mempty
228− let text = todoText <> headlineText <> tagsToInlines headlineTags
229+ let text = todoText <> headlineText <>
230+ if exportTags
231+ then tagsToInlines headlineTags
232+ else mempty
229 let propAttr = propertiesToAttr headlineProperties
233 let propAttr = propertiesToAttr headlineProperties
230 attr <- registerHeader propAttr headlineText
234 attr <- registerHeader propAttr headlineText
231 return $ B.headerWith attr headlineLevel text
235 return $ B.headerWith attr headlineLevel text
src/Text/Pandoc/Readers/Org/ExportSettings.hs+1−1
@@ -71,7 +71,7 @@ exportSetting = choice
71 , ignoredSetting "pri"
71 , ignoredSetting "pri"
72 , ignoredSetting "prop"
72 , ignoredSetting "prop"
73 , ignoredSetting "stat"
73 , ignoredSetting "stat"
74− , ignoredSetting "tags"
74+ , booleanSetting "tags" (\val es -> es { exportWithTags = val })
75 , ignoredSetting "tasks"
75 , ignoredSetting "tasks"
76 , ignoredSetting "tex"
76 , ignoredSetting "tex"
77 , ignoredSetting "timestamp"
77 , ignoredSetting "timestamp"
src/Text/Pandoc/Readers/Org/ParserState.hs+2
@@ -240,6 +240,7 @@ data ExportSettings = ExportSettings
240 , exportWithAuthor :: Bool -- ^ Include author in final meta-data
240 , exportWithAuthor :: Bool -- ^ Include author in final meta-data
241 , exportWithCreator :: Bool -- ^ Include creator in final meta-data
241 , exportWithCreator :: Bool -- ^ Include creator in final meta-data
242 , exportWithEmail :: Bool -- ^ Include email in final meta-data
242 , exportWithEmail :: Bool -- ^ Include email in final meta-data
243+ , exportWithTags :: Bool -- ^ Keep tags as part of headlines
243 , exportWithTodoKeywords :: Bool -- ^ Keep TODO keywords in headers
244 , exportWithTodoKeywords :: Bool -- ^ Keep TODO keywords in headers
244 }
245 }
245
246
@@ -258,5 +259,6 @@ defaultExportSettings = ExportSettings
258 , exportWithAuthor = True
259 , exportWithAuthor = True
259 , exportWithCreator = True
260 , exportWithCreator = True
260 , exportWithEmail = True
261 , exportWithEmail = True
262+ , exportWithTags = True
261 , exportWithTodoKeywords = True
263 , exportWithTodoKeywords = True
262 }
264 }
test/Tests/Readers/Org.hs+6
@@ -794,6 +794,12 @@ tests =
794 , "** DONE todo export"
794 , "** DONE todo export"
795 ] =?>
795 ] =?>
796 headerWith ("todo-export", [], []) 2 "todo export"
796 headerWith ("todo-export", [], []) 2 "todo export"
797+
798+ , "remove tags from headlines" =:
799+ unlines [ "#+OPTIONS: tags:nil"
800+ , "* Headline :hello:world:"
801+ ] =?>
802+ headerWith ("headline", [], mempty) 1 "Headline"
797 ]
803 ]
798 ]
804 ]
799
805