git.iko.soy/typeable/pandoc
on master help sign in
Org reader: respect tables-excluding export setting

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

commit930b6c13705474bcf9a13997d4e0fa878d25872a authorAlbert Krewinkel <albert@zeitkraut.de> dateWed 1 Jul 2020, 09:17 (6 years ago) parentf396fc2
4 files changed+15−2
src/Text/Pandoc/Readers/Org/Blocks.hs+4−1 src/Text/Pandoc/Readers/Org/ExportSettings.hs+1−1 src/Text/Pandoc/Readers/Org/ParserState.hs+2 test/Tests/Readers/Org/Directive.hs+8
src/Text/Pandoc/Readers/Org/Blocks.hs+4−1
@@ -608,7 +608,10 @@ data OrgTable = OrgTable
608608 }
609609
610610table :: PandocMonad m => OrgParser m (F Blocks)
611−table = gridTableWith blocks True <|> orgTable
611+table = do
612+ withTables <- getExportSetting exportWithTables
613+ tbl <- gridTableWith blocks True <|> orgTable
614+ return $ if withTables then tbl else mempty
612615
613616-- | A normal org table
614617orgTable :: PandocMonad m => OrgParser m (F Blocks)
src/Text/Pandoc/Readers/Org/ExportSettings.hs+1−1
@@ -64,7 +64,7 @@ exportSetting = choice
6464 , ignoredSetting "title"
6565 , ignoredSetting "toc"
6666 , booleanSetting "todo" (\val es -> es { exportWithTodoKeywords = val })
67− , ignoredSetting "|"
67+ , booleanSetting "|" (\val es -> es { exportWithTables = val })
6868 , ignoreAndWarn
6969 ] <?> "export setting"
7070
src/Text/Pandoc/Readers/Org/ParserState.hs+2
@@ -262,6 +262,7 @@ data ExportSettings = ExportSettings
262262 , exportWithLatex :: TeXExport -- ^ Handling of raw TeX commands
263263 , exportWithPlanning :: Bool -- ^ Keep planning info after headlines
264264 , exportWithTags :: Bool -- ^ Keep tags as part of headlines
265+ , exportWithTables :: Bool -- ^ Include tables
265266 , exportWithTodoKeywords :: Bool -- ^ Keep TODO keywords in headers
266267 }
267268
@@ -286,5 +287,6 @@ defaultExportSettings = ExportSettings
286287 , exportWithLatex = TeXExport
287288 , exportWithPlanning = False
288289 , exportWithTags = True
290+ , exportWithTables = True
289291 , exportWithTodoKeywords = True
290292 }
test/Tests/Readers/Org/Directive.hs+8
@@ -280,6 +280,14 @@ tests =
280280 headerWith ("wichtig", mempty, mempty) 1 "Wichtig"
281281 ]
282282
283+ , testGroup "Option |"
284+ [ "disable export of tables" =:
285+ T.unlines [ "#+OPTIONS: |:nil"
286+ , "| chair |"
287+ ] =?>
288+ (mempty :: Blocks)
289+ ]
290+
283291 , testGroup "unknown options"
284292 [ "unknown options are ignored" =:
285293 T.unlines [ "#+OPTIONS: does-not-exist:t "] =?>