From 9dbcf1616158274b0a2c0000b0a6a261080f0006 Mon Sep 17 00:00:00 2001 From: Brian Leung Date: Tue, 8 Jan 2019 05:28:47 +0100 Subject: Org reader: handle `minlevel` option differently. (#5190) When `minlevel` exceeds the original minimum level observed in the file to be included, every heading should be shifted rightward. --- src/Text/Pandoc/Readers/Org/Blocks.hs | 4 +--- test/Tests/Readers/Org/Directive.hs | 7 ++++++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Text/Pandoc/Readers/Org/Blocks.hs b/src/Text/Pandoc/Readers/Org/Blocks.hs index 1c52c3477..d3702687c 100644 --- a/src/Text/Pandoc/Readers/Org/Blocks.hs +++ b/src/Text/Pandoc/Readers/Org/Blocks.hs @@ -547,9 +547,7 @@ include = try $ do shiftHeader :: Int -> Block -> Block shiftHeader shift blk = - if shift <= 0 - then blk - else case blk of + case blk of (Header lvl attr content) -> Header (lvl - shift) attr content _ -> blk diff --git a/test/Tests/Readers/Org/Directive.hs b/test/Tests/Readers/Org/Directive.hs index 87abb714d..bf4c2800d 100644 --- a/test/Tests/Readers/Org/Directive.hs +++ b/test/Tests/Readers/Org/Directive.hs @@ -192,10 +192,15 @@ tests = headerWith ("level3", [], []) 3 "Level3") , testWithFiles [("./level3.org", "*** Level3\n\n")] - "Minlevel shifts level" + "Minlevel shifts level leftward" (T.unlines [ "#+include: \"level3.org\" :minlevel 1" ] =?> headerWith ("level3", [], []) 1 "Level3") + , testWithFiles [("./level1.org", "* Level1\n\n")] + "Minlevel shifts level rightward" + (T.unlines [ "#+include: \"level1.org\" :minlevel 3" ] =?> + headerWith ("level1", [], []) 3 "Level1") + , testWithFiles [("./src.hs", "putStrLn outString\n")] "Include file as source code snippet" (T.unlines [ "#+include: \"src.hs\" src haskell" ] =?> -- cgit v1.2.3