@@ -114,6 +114,8 @@ data Opt = Opt
114114 , optEPUBStylesheet :: Maybe String -- ^ EPUB stylesheet
115115 , optEPUBMetadata :: String -- ^ EPUB metadata
116116 , optEPUBFonts :: [FilePath] -- ^ EPUB fonts to embed
117+ , optEPUBChapterLevel :: Int -- ^ Header level at which to split chapters
118+ , optEPUBTOCLevel :: Int -- ^ Number of levels to include in TOC
117119 , optDumpArgs :: Bool -- ^ Output command-line arguments
118120 , optIgnoreArgs :: Bool -- ^ Ignore command-line arguments
119121 , optReferenceLinks :: Bool -- ^ Use reference links in writing markdown, rst
@@ -166,6 +168,8 @@ defaultOpts = Opt
166168 , optEPUBStylesheet = Nothing
167169 , optEPUBMetadata = ""
168170 , optEPUBFonts = []
171+ , optEPUBChapterLevel = 1
172+ , optEPUBTOCLevel = 3
169173 , optDumpArgs = False
170174 , optIgnoreArgs = False
171175 , optReferenceLinks = False
@@ -554,6 +558,28 @@ options =
554558 "FILE")
555559 "" -- "Directory of fonts to embed"
556560
561+ , Option "" ["epub-chapter-level"]
562+ (ReqArg
563+ (\arg opt -> do
564+ case safeRead arg of
565+ Just t | t >= 1 && t <= 6 ->
566+ return opt { optEPUBChapterLevel = t }
567+ _ -> err 59 $
568+ "chapter level must be a number between 1 and 6")
569+ "NUMBER")
570+ "" -- "Header level at which to split chapters in EPUB"
571+
572+ , Option "" ["epub-toc-level"]
573+ (ReqArg
574+ (\arg opt -> do
575+ case safeRead arg of
576+ Just t | t >= 1 && t <= 6 ->
577+ return opt { optEPUBTOCLevel = t }
578+ _ -> err 57 $
579+ "TOC level must be a number between 1 and 6")
580+ "NUMBER")
581+ "" -- "Number of levels to include in EPUB TOC"
582+
557583 , Option "" ["latex-engine"]
558584 (ReqArg
559585 (\arg opt -> do
@@ -803,6 +829,8 @@ main = do
803829 , optEPUBStylesheet = epubStylesheet
804830 , optEPUBMetadata = epubMetadata
805831 , optEPUBFonts = epubFonts
832+ , optEPUBChapterLevel = epubChapterLevel
833+ , optEPUBTOCLevel = epubTOCLevel
806834 , optDumpArgs = dumpArgs
807835 , optIgnoreArgs = ignoreArgs
808836 , optReferenceLinks = referenceLinks
@@ -992,6 +1020,8 @@ main = do
9921020 writerTeXLigatures = texLigatures,
9931021 writerEpubStylesheet = epubStylesheet,
9941022 writerEpubFonts = epubFonts,
1023+ writerEpubChapterLevel = epubChapterLevel,
1024+ writerEpubTOCLevel = epubTOCLevel,
9951025 writerReferenceODT = referenceODT,
9961026 writerReferenceDocx = referenceDocx
9971027 }