diff options
| author | John MacFarlane <jgm@berkeley.edu> | 2023-01-12 09:01:56 -0800 |
|---|---|---|
| committer | John MacFarlane <jgm@berkeley.edu> | 2023-01-12 09:04:29 -0800 |
| commit | d7960212c0d3bf57659f5f6d3ad054eda2d20746 (patch) | |
| tree | 97c92b385c5a136c267c9d611741add22494dd38 /src | |
| parent | 2101dcf54ce5d3d2ecce300ca97dba47c5d61f02 (diff) | |
Replace `--epub-chapter-level` with `--split-level`.
Rationale: we need this splitting level now not just in
EPUB but in chunked HTML.
`--epub-chapter-level` will still function as a deprecated
synonynm. `epub-chapter-level` will also continue to work in
defaults files, ande `epub_chapter_level` will still work for
Lua marshalling.
[API changes]
Text.Pandoc.App.Opt: remove `optEpubChapterLevel`, add
`optSplitLevel`.
Text.Pandoc.Options: remove `writerEpubChapterLevel`, add
`writerSplitLevel`.
Diffstat (limited to 'src')
| -rw-r--r-- | src/Text/Pandoc/App/CommandLineOptions.hs | 21 | ||||
| -rw-r--r-- | src/Text/Pandoc/App/Opt.hs | 11 | ||||
| -rw-r--r-- | src/Text/Pandoc/App/OutputSettings.hs | 2 | ||||
| -rw-r--r-- | src/Text/Pandoc/Options.hs | 4 | ||||
| -rw-r--r-- | src/Text/Pandoc/Writers/ChunkedHTML.hs | 2 | ||||
| -rw-r--r-- | src/Text/Pandoc/Writers/EPUB.hs | 2 |
6 files changed, 29 insertions, 13 deletions
diff --git a/src/Text/Pandoc/App/CommandLineOptions.hs b/src/Text/Pandoc/App/CommandLineOptions.hs index d2a82b5a4..fc636e438 100644 --- a/src/Text/Pandoc/App/CommandLineOptions.hs +++ b/src/Text/Pandoc/App/CommandLineOptions.hs @@ -782,16 +782,29 @@ options = "FILE") "" -- "Directory of fonts to embed" - , Option "" ["epub-chapter-level"] + , Option "" ["split-level"] (ReqArg (\arg opt -> case safeStrRead arg of Just t | t >= 1 && t <= 6 -> - return opt { optEpubChapterLevel = t } + return opt { optSplitLevel = t } + _ -> optError $ PandocOptionError + "split level must be a number between 1 and 6") + "NUMBER") + "" -- "Header level at which to split documents in chunked HTML or EPUB" + + , Option "" ["epub-chapter-level"] + (ReqArg + (\arg opt -> do + deprecatedOption "--epub-chapter-level" + "use --split-level" + case safeStrRead arg of + Just t | t >= 1 && t <= 6 -> + return opt { optSplitLevel = t } _ -> optError $ PandocOptionError - "chapter level must be a number between 1 and 6") + "split level must be a number between 1 and 6") "NUMBER") - "" -- "Header level at which to split chapters in EPUB" + "" -- "Header level at which to split documents in chunked HTML or EPUB" , Option "" ["ipynb-output"] (ReqArg diff --git a/src/Text/Pandoc/App/Opt.hs b/src/Text/Pandoc/App/Opt.hs index d106d9d15..762305170 100644 --- a/src/Text/Pandoc/App/Opt.hs +++ b/src/Text/Pandoc/App/Opt.hs @@ -126,10 +126,10 @@ data Opt = Opt , optHTMLMathMethod :: HTMLMathMethod -- ^ Method to print HTML math , optAbbreviations :: Maybe FilePath -- ^ Path to abbrevs file , optReferenceDoc :: Maybe FilePath -- ^ Path of reference doc + , optSplitLevel :: Int -- ^ Header level at which to split documents in epub and chunkedhtml , optEpubSubdirectory :: String -- ^ EPUB subdir in OCF container , optEpubMetadata :: Maybe FilePath -- ^ EPUB metadata , optEpubFonts :: [FilePath] -- ^ EPUB fonts to embed - , optEpubChapterLevel :: Int -- ^ Header level at which to split chapters , optEpubCoverImage :: Maybe FilePath -- ^ Cover image for epub , optEpubTitlePage :: Bool -- ^ INclude title page in EPUB , optTOCDepth :: Int -- ^ Number of levels to include in TOC @@ -207,10 +207,11 @@ instance FromJSON Opt where <*> o .:? "html-math-method" .!= optHTMLMathMethod defaultOpts <*> o .:? "abbreviations" <*> o .:? "reference-doc" + <*> ((o .:? "split-level") <|> (o .:? "epub-chapter-level")) + .!= optSplitLevel defaultOpts <*> o .:? "epub-subdirectory" .!= optEpubSubdirectory defaultOpts <*> o .:? "epub-metadata" <*> o .:? "epub-fonts" .!= optEpubFonts defaultOpts - <*> o .:? "epub-chapter-level" .!= optEpubChapterLevel defaultOpts <*> o .:? "epub-cover-image" <*> o .:? "epub-title-page" .!= optEpubTitlePage defaultOpts <*> o .:? "toc-depth" .!= optTOCDepth defaultOpts @@ -559,7 +560,9 @@ doOpt (k,v) = do parseJSON v >>= \x -> return (\o -> o{ optEpubFonts = optEpubFonts o <> map unpack x }) "epub-chapter-level" -> - parseJSON v >>= \x -> return (\o -> o{ optEpubChapterLevel = x }) + parseJSON v >>= \x -> return (\o -> o{ optSplitLevel = x }) + "split-level" -> + parseJSON v >>= \x -> return (\o -> o{ optSplitLevel = x }) "epub-cover-image" -> parseJSON v >>= \x -> return (\o -> o{ optEpubCoverImage = unpack <$> x }) @@ -736,10 +739,10 @@ defaultOpts = Opt , optHTMLMathMethod = PlainMath , optAbbreviations = Nothing , optReferenceDoc = Nothing + , optSplitLevel = 1 , optEpubSubdirectory = "EPUB" , optEpubMetadata = Nothing , optEpubFonts = [] - , optEpubChapterLevel = 1 , optEpubCoverImage = Nothing , optEpubTitlePage = True , optTOCDepth = 3 diff --git a/src/Text/Pandoc/App/OutputSettings.hs b/src/Text/Pandoc/App/OutputSettings.hs index 8e41e51fb..4fd30ff66 100644 --- a/src/Text/Pandoc/App/OutputSettings.hs +++ b/src/Text/Pandoc/App/OutputSettings.hs @@ -249,8 +249,8 @@ optToOutputSettings scriptingEngine opts = do , writerEpubSubdirectory = T.pack $ optEpubSubdirectory opts , writerEpubMetadata = epubMetadata , writerEpubFonts = optEpubFonts opts - , writerEpubChapterLevel = optEpubChapterLevel opts , writerEpubTitlePage = optEpubTitlePage opts + , writerSplitLevel = optSplitLevel opts , writerTOCDepth = optTOCDepth opts , writerReferenceDoc = optReferenceDoc opts , writerSyntaxMap = syntaxMap diff --git a/src/Text/Pandoc/Options.hs b/src/Text/Pandoc/Options.hs index dbebb799c..f671dd279 100644 --- a/src/Text/Pandoc/Options.hs +++ b/src/Text/Pandoc/Options.hs @@ -316,8 +316,8 @@ data WriterOptions = WriterOptions , writerEpubSubdirectory :: Text -- ^ Subdir for epub in OCF , writerEpubMetadata :: Maybe Text -- ^ Metadata to include in EPUB , writerEpubFonts :: [FilePath] -- ^ Paths to fonts to embed - , writerEpubChapterLevel :: Int -- ^ Header level for chapters (separate files) , writerEpubTitlePage :: Bool -- ^ Include title page in epub + , writerSplitLevel :: Int -- ^ Header level at which to split EPUB or chunked HTML into separate files , writerTOCDepth :: Int -- ^ Number of levels to include in TOC , writerReferenceDoc :: Maybe FilePath -- ^ Path to reference document if specified , writerReferenceLocation :: ReferenceLocation -- ^ Location of footnotes and references for writing markdown @@ -353,8 +353,8 @@ instance Default WriterOptions where , writerEpubSubdirectory = "EPUB" , writerEpubMetadata = Nothing , writerEpubFonts = [] - , writerEpubChapterLevel = 1 , writerEpubTitlePage = True + , writerSplitLevel = 1 , writerTOCDepth = 3 , writerReferenceDoc = Nothing , writerReferenceLocation = EndOfDocument diff --git a/src/Text/Pandoc/Writers/ChunkedHTML.hs b/src/Text/Pandoc/Writers/ChunkedHTML.hs index f58733588..d71abe5e0 100644 --- a/src/Text/Pandoc/Writers/ChunkedHTML.hs +++ b/src/Text/Pandoc/Writers/ChunkedHTML.hs @@ -57,7 +57,7 @@ writeChunkedHTML opts (Pandoc meta blocks) = do let chunkedDoc = splitIntoChunks "%s-%i.html" True (Just 1) - (writerEpubChapterLevel opts) + (writerSplitLevel opts) (Pandoc meta blocks) let topChunk = Chunk diff --git a/src/Text/Pandoc/Writers/EPUB.hs b/src/Text/Pandoc/Writers/EPUB.hs index 09eac0d75..832ddb0b2 100644 --- a/src/Text/Pandoc/Writers/EPUB.hs +++ b/src/Text/Pandoc/Writers/EPUB.hs @@ -541,7 +541,7 @@ pandocToEPUB version opts doc = do let chunkedDoc = splitIntoChunks "ch%n.xhtml" (writerNumberSections opts) Nothing - (writerEpubChapterLevel opts) + (writerSplitLevel opts) (Pandoc meta blocks') |
