@@ -42,11 +42,14 @@ pandoc command will be executed.
4242> #do/not/include/this.md
4343> ```
4444
45- Alternatively, use the following to increase all the header numbers by one in
46- the included file.
45+ Alternatively, use one of the following to increase all the header levels in the
46+ included file. The first option is a shortcut for incrementing the level by 1.
47+ The second demonstrates an increase of 2.
4748
4849> ```include-indented
4950
51+ > ```{ .include header-change=2 }
52+
5053If the file does not exist, it will be skipped completely. No warnings, no
5154residue, nothing. Putting an # as the first character in the line will make the
5255filter skip that file.
@@ -60,6 +63,7 @@ Note: the metadata from the included source files are discarded.
6063
6164import Control.Monad
6265import Data.List
66+ import Control.Error (readMay , fromMaybe )
6367import System.Directory
6468
6569import Text.Pandoc
@@ -93,13 +97,16 @@ processFiles changeInHeaderLevel toProcess =
9397 fmap concat (getContent changeInHeaderLevel `mapM` toProcess)
9498
9599doInclude :: Block -> IO [Block ]
96- doInclude (CodeBlock (_, classes, _ ) list)
100+ doInclude (CodeBlock (_, classes, options ) list)
97101 | " include" `elem` classes = do
98102 let toProcess = getProcessableFileList list
99- processFiles 0 =<< toProcess
100- | " include-indented" `elem` classes = do
101- let toProcess = getProcessableFileList list
102- processFiles 1 =<< toProcess
103+ changeInHeaderLevel = fromMaybe 0 $ readMay =<< " header-change" `lookup` options
104+ processFiles changeInHeaderLevel =<< toProcess
105+ | " include-indented" `elem` classes =
106+ doInclude $ CodeBlock (" " , newClasses, newOptions) list
107+ where
108+ newClasses = (" include" : ) . delete " include-indented" $ classes
109+ newOptions = (" header-change" ," 1" ) : options
103110doInclude x = return [x]
104111
105112modifyHeaderLevelBlock :: Int -> Block -> Block
0 commit comments