Skip to content

Commit

Permalink
Org reader: handle minlevel option differently. (#5190)
Browse files Browse the repository at this point in the history
When `minlevel` exceeds the original minimum level observed in the
file to be included, every heading should be shifted rightward.
  • Loading branch information
leungbk authored and jgm committed Jan 8, 2019
1 parent f9d9880 commit 9dbcf16
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
4 changes: 1 addition & 3 deletions src/Text/Pandoc/Readers/Org/Blocks.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
7 changes: 6 additions & 1 deletion test/Tests/Readers/Org/Directive.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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" ] =?>
Expand Down

0 comments on commit 9dbcf16

Please sign in to comment.