git.iko.soy/typeable/pandoc
on master help sign in
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.

commit9dbcf1616158274b0a2c0000b0a6a261080f0006 authorBrian Leung <bkleung89@gmail.com> dateTue 8 Jan 2019, 05:28 (8 years ago) parentf9d9880
2 files changed+7−4
src/Text/Pandoc/Readers/Org/Blocks.hs+1−3 test/Tests/Readers/Org/Directive.hs+6−1
src/Text/Pandoc/Readers/Org/Blocks.hs+1−3
@@ -547,9 +547,7 @@ include = try $ do
547547
548548 shiftHeader :: Int -> Block -> Block
549549 shiftHeader shift blk =
550− if shift <= 0
551− then blk
552− else case blk of
550+ case blk of
553551 (Header lvl attr content) -> Header (lvl - shift) attr content
554552 _ -> blk
555553
test/Tests/Readers/Org/Directive.hs+6−1
@@ -192,10 +192,15 @@ tests =
192192 headerWith ("level3", [], []) 3 "Level3")
193193
194194 , testWithFiles [("./level3.org", "*** Level3\n\n")]
195− "Minlevel shifts level"
195+ "Minlevel shifts level leftward"
196196 (T.unlines [ "#+include: \"level3.org\" :minlevel 1" ] =?>
197197 headerWith ("level3", [], []) 1 "Level3")
198198
199+ , testWithFiles [("./level1.org", "* Level1\n\n")]
200+ "Minlevel shifts level rightward"
201+ (T.unlines [ "#+include: \"level1.org\" :minlevel 3" ] =?>
202+ headerWith ("level1", [], []) 3 "Level1")
203+
199204 , testWithFiles [("./src.hs", "putStrLn outString\n")]
200205 "Include file as source code snippet"
201206 (T.unlines [ "#+include: \"src.hs\" src haskell" ] =?>