git.iko.soy/typeable/pandoc
on master help sign in
`--number-from` -> `--number-offset`
756c8d4John MacFarlane
README+5−3
@@ -397,9 +397,11 @@ Options affecting specific writers
397: Number section headings in LaTeX, ConTeXt, HTML, or EPUB output.
397: Number section headings in LaTeX, ConTeXt, HTML, or EPUB output.
398 By default, sections are not numbered.
398 By default, sections are not numbered.
399
399
400−`--number-from`=*NUMBER*
400+`--number-offset`=*NUMBER[,NUMBER,...]*,
401−: Starting number for top-level section headings in HTML output.
401+: Offset for section headings in HTML output (ignored in other
402+ output formats). The first number is added to the section number for
403+ top-level headers, the second for second-level headers, and so on.
402− Ignored in other output formats. Implies `--number-sections`.
404+ Offsets are 0 by default. Implies `--number-sections`.
403
405
404`--no-tex-ligatures`
406`--no-tex-ligatures`
405: Do not convert quotation marks, apostrophes, and dashes to
407: Do not convert quotation marks, apostrophes, and dashes to
pandoc.hs+11−11
@@ -100,7 +100,7 @@ data Opt = Opt
100 , optVariables :: [(String,String)] -- ^ Template variables to set
100 , optVariables :: [(String,String)] -- ^ Template variables to set
101 , optOutputFile :: String -- ^ Name of output file
101 , optOutputFile :: String -- ^ Name of output file
102 , optNumberSections :: Bool -- ^ Number sections in LaTeX
102 , optNumberSections :: Bool -- ^ Number sections in LaTeX
103− , optNumberFrom :: Int -- ^ Starting number for sections
103+ , optNumberOffset :: [Int] -- ^ Starting number for sections
104 , optSectionDivs :: Bool -- ^ Put sections in div tags in HTML
104 , optSectionDivs :: Bool -- ^ Put sections in div tags in HTML
105 , optIncremental :: Bool -- ^ Use incremental lists in Slidy/Slideous/S5
105 , optIncremental :: Bool -- ^ Use incremental lists in Slidy/Slideous/S5
106 , optSelfContained :: Bool -- ^ Make HTML accessible offline
106 , optSelfContained :: Bool -- ^ Make HTML accessible offline
@@ -157,7 +157,7 @@ defaultOpts = Opt
157 , optVariables = []
157 , optVariables = []
158 , optOutputFile = "-" -- "-" means stdout
158 , optOutputFile = "-" -- "-" means stdout
159 , optNumberSections = False
159 , optNumberSections = False
160− , optNumberFrom = 1
160+ , optNumberOffset = [1,1,1,1,1,1]
161 , optSectionDivs = False
161 , optSectionDivs = False
162 , optIncremental = False
162 , optIncremental = False
163 , optSelfContained = False
163 , optSelfContained = False
@@ -469,15 +469,15 @@ options =
469 (\opt -> return opt { optNumberSections = True }))
469 (\opt -> return opt { optNumberSections = True }))
470 "" -- "Number sections in LaTeX"
470 "" -- "Number sections in LaTeX"
471
471
472− , Option "" ["number-from"]
472+ , Option "" ["number-offset"]
473 (ReqArg
473 (ReqArg
474 (\arg opt ->
474 (\arg opt ->
475− case safeRead arg of
475+ case safeRead ('[':arg ++ "]") of
476− Just n -> return opt { optNumberFrom = n,
476+ Just ns -> return opt { optNumberOffset = ns,
477− optNumberSections = True }
477+ optNumberSections = True }
478− _ -> err 57 "could not parse number-from")
478+ _ -> err 57 "could not parse number-offset")
479− "NUMBER")
479+ "NUMBERS")
480− "" -- "Starting number for sections"
480+ "" -- "Starting number for sections, subsections, etc."
481
481
482 , Option "" ["no-tex-ligatures"]
482 , Option "" ["no-tex-ligatures"]
483 (NoArg
483 (NoArg
@@ -841,7 +841,7 @@ main = do
841 , optTemplate = templatePath
841 , optTemplate = templatePath
842 , optOutputFile = outputFile
842 , optOutputFile = outputFile
843 , optNumberSections = numberSections
843 , optNumberSections = numberSections
844− , optNumberFrom = numberFrom
844+ , optNumberOffset = numberFrom
845 , optSectionDivs = sectionDivs
845 , optSectionDivs = sectionDivs
846 , optIncremental = incremental
846 , optIncremental = incremental
847 , optSelfContained = selfContained
847 , optSelfContained = selfContained
@@ -1035,7 +1035,7 @@ main = do
1035 writerBiblioFiles = reffiles,
1035 writerBiblioFiles = reffiles,
1036 writerIgnoreNotes = False,
1036 writerIgnoreNotes = False,
1037 writerNumberSections = numberSections,
1037 writerNumberSections = numberSections,
1038− writerNumberFrom = numberFrom,
1038+ writerNumberOffset = numberFrom,
1039 writerSectionDivs = sectionDivs,
1039 writerSectionDivs = sectionDivs,
1040 writerReferenceLinks = referenceLinks,
1040 writerReferenceLinks = referenceLinks,
1041 writerWrapText = wrap,
1041 writerWrapText = wrap,
src/Text/Pandoc/Options.hs+2−2
@@ -270,7 +270,7 @@ data WriterOptions = WriterOptions
270 , writerHTMLMathMethod :: HTMLMathMethod -- ^ How to print math in HTML
270 , writerHTMLMathMethod :: HTMLMathMethod -- ^ How to print math in HTML
271 , writerIgnoreNotes :: Bool -- ^ Ignore footnotes (used in making toc)
271 , writerIgnoreNotes :: Bool -- ^ Ignore footnotes (used in making toc)
272 , writerNumberSections :: Bool -- ^ Number sections in LaTeX
272 , writerNumberSections :: Bool -- ^ Number sections in LaTeX
273− , writerNumberFrom :: Int -- ^ Starting section number
273+ , writerNumberOffset :: [Int] -- ^ Starting number for section, subsection, ...
274 , writerSectionDivs :: Bool -- ^ Put sections in div tags in HTML
274 , writerSectionDivs :: Bool -- ^ Put sections in div tags in HTML
275 , writerExtensions :: Set Extension -- ^ Markdown extensions that can be used
275 , writerExtensions :: Set Extension -- ^ Markdown extensions that can be used
276 , writerReferenceLinks :: Bool -- ^ Use reference links in writing markdown, rst
276 , writerReferenceLinks :: Bool -- ^ Use reference links in writing markdown, rst
@@ -314,7 +314,7 @@ instance Default WriterOptions where
314 , writerHTMLMathMethod = PlainMath
314 , writerHTMLMathMethod = PlainMath
315 , writerIgnoreNotes = False
315 , writerIgnoreNotes = False
316 , writerNumberSections = False
316 , writerNumberSections = False
317− , writerNumberFrom = 1
317+ , writerNumberOffset = [0,0,0,0,0,0]
318 , writerSectionDivs = False
318 , writerSectionDivs = False
319 , writerExtensions = pandocExtensions
319 , writerExtensions = pandocExtensions
320 , writerReferenceLinks = False
320 , writerReferenceLinks = False
src/Text/Pandoc/Writers/EPUB.hs+1−1
@@ -149,7 +149,7 @@ writeEPUB opts doc@(Pandoc meta _) = do
149 let chapToEntry :: Int -> [Block] -> Entry
149 let chapToEntry :: Int -> [Block] -> Entry
150 chapToEntry num bs = mkEntry (showChapter num)
150 chapToEntry num bs = mkEntry (showChapter num)
151 $ renderHtml
151 $ renderHtml
152− $ writeHtml opts'{ writerNumberFrom = num }
152+ $ writeHtml opts'{ writerNumberOffset = [num - 1] }
153 $ case bs of
153 $ case bs of
154 (Header _ _ xs : _) -> Pandoc (Meta xs [] []) bs
154 (Header _ _ xs : _) -> Pandoc (Meta xs [] []) bs
155 _ -> Pandoc (Meta [] [] []) bs
155 _ -> Pandoc (Meta [] [] []) bs
src/Text/Pandoc/Writers/HTML.hs+1−3
@@ -274,9 +274,7 @@ elementToHtml :: Int -> WriterOptions -> Element -> State WriterState Html
274elementToHtml _slideLevel opts (Blk block) = blockToHtml opts block
274elementToHtml _slideLevel opts (Blk block) = blockToHtml opts block
275elementToHtml slideLevel opts (Sec level num (id',classes,keyvals) title' elements) = do
275elementToHtml slideLevel opts (Sec level num (id',classes,keyvals) title' elements) = do
276 let slide = writerSlideVariant opts /= NoSlides && level <= slideLevel
276 let slide = writerSlideVariant opts /= NoSlides && level <= slideLevel
277− let num' = case num of
277+ let num' = zipWith (+) num (writerNumberOffset opts)
278− (n:ns) -> n + writerNumberFrom opts - 1 : ns
279− [] -> []
280 modify $ \st -> st{stSecNum = num'} -- update section number
278 modify $ \st -> st{stSecNum = num'} -- update section number
281 -- always use level 1 for slide titles
279 -- always use level 1 for slide titles
282 let level' = if slide then 1 else level
280 let level' = if slide then 1 else level