git.iko.soy/typeable/pandoc
on master help sign in
`--number-from` -> `--number-offset`

Also `writerNumberFrom` -> `writeNumberOffset`. The offset is a list of numbers (0 by default). These are added to the section, subsection, etc. numbers that would have been generated automatically.

commit756c8d492a3793a8a0c2b750dac6005885b9a2d0 authorJohn MacFarlane <fiddlosopher@gmail.com> dateSat 23 Feb 2013, 18:11 (14 years ago) parenta7245b4
5 files changed+20−20
README+5−3 pandoc.hs+11−11 src/Text/Pandoc/Options.hs+2−2 src/Text/Pandoc/Writers/EPUB.hs+1−1 src/Text/Pandoc/Writers/HTML.hs+1−3
README+5−3
@@ -397,9 +397,11 @@ Options affecting specific writers
397397: Number section headings in LaTeX, ConTeXt, HTML, or EPUB output.
398398 By default, sections are not numbered.
399399
400−`--number-from`=*NUMBER*
401−: Starting number for top-level section headings in HTML output.
402− Ignored in other output formats. Implies `--number-sections`.
400+`--number-offset`=*NUMBER[,NUMBER,...]*,
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.
404+ Offsets are 0 by default. Implies `--number-sections`.
403405
404406`--no-tex-ligatures`
405407: Do not convert quotation marks, apostrophes, and dashes to
pandoc.hs+11−11
@@ -100,7 +100,7 @@ data Opt = Opt
100100 , optVariables :: [(String,String)] -- ^ Template variables to set
101101 , optOutputFile :: String -- ^ Name of output file
102102 , optNumberSections :: Bool -- ^ Number sections in LaTeX
103− , optNumberFrom :: Int -- ^ Starting number for sections
103+ , optNumberOffset :: [Int] -- ^ Starting number for sections
104104 , optSectionDivs :: Bool -- ^ Put sections in div tags in HTML
105105 , optIncremental :: Bool -- ^ Use incremental lists in Slidy/Slideous/S5
106106 , optSelfContained :: Bool -- ^ Make HTML accessible offline
@@ -157,7 +157,7 @@ defaultOpts = Opt
157157 , optVariables = []
158158 , optOutputFile = "-" -- "-" means stdout
159159 , optNumberSections = False
160− , optNumberFrom = 1
160+ , optNumberOffset = [1,1,1,1,1,1]
161161 , optSectionDivs = False
162162 , optIncremental = False
163163 , optSelfContained = False
@@ -469,15 +469,15 @@ options =
469469 (\opt -> return opt { optNumberSections = True }))
470470 "" -- "Number sections in LaTeX"
471471
472− , Option "" ["number-from"]
472+ , Option "" ["number-offset"]
473473 (ReqArg
474474 (\arg opt ->
475− case safeRead arg of
476− Just n -> return opt { optNumberFrom = n,
477− optNumberSections = True }
478− _ -> err 57 "could not parse number-from")
479− "NUMBER")
480− "" -- "Starting number for sections"
475+ case safeRead ('[':arg ++ "]") of
476+ Just ns -> return opt { optNumberOffset = ns,
477+ optNumberSections = True }
478+ _ -> err 57 "could not parse number-offset")
479+ "NUMBERS")
480+ "" -- "Starting number for sections, subsections, etc."
481481
482482 , Option "" ["no-tex-ligatures"]
483483 (NoArg
@@ -841,7 +841,7 @@ main = do
841841 , optTemplate = templatePath
842842 , optOutputFile = outputFile
843843 , optNumberSections = numberSections
844− , optNumberFrom = numberFrom
844+ , optNumberOffset = numberFrom
845845 , optSectionDivs = sectionDivs
846846 , optIncremental = incremental
847847 , optSelfContained = selfContained
@@ -1035,7 +1035,7 @@ main = do
10351035 writerBiblioFiles = reffiles,
10361036 writerIgnoreNotes = False,
10371037 writerNumberSections = numberSections,
1038− writerNumberFrom = numberFrom,
1038+ writerNumberOffset = numberFrom,
10391039 writerSectionDivs = sectionDivs,
10401040 writerReferenceLinks = referenceLinks,
10411041 writerWrapText = wrap,
src/Text/Pandoc/Options.hs+2−2
@@ -270,7 +270,7 @@ data WriterOptions = WriterOptions
270270 , writerHTMLMathMethod :: HTMLMathMethod -- ^ How to print math in HTML
271271 , writerIgnoreNotes :: Bool -- ^ Ignore footnotes (used in making toc)
272272 , writerNumberSections :: Bool -- ^ Number sections in LaTeX
273− , writerNumberFrom :: Int -- ^ Starting section number
273+ , writerNumberOffset :: [Int] -- ^ Starting number for section, subsection, ...
274274 , writerSectionDivs :: Bool -- ^ Put sections in div tags in HTML
275275 , writerExtensions :: Set Extension -- ^ Markdown extensions that can be used
276276 , writerReferenceLinks :: Bool -- ^ Use reference links in writing markdown, rst
@@ -314,7 +314,7 @@ instance Default WriterOptions where
314314 , writerHTMLMathMethod = PlainMath
315315 , writerIgnoreNotes = False
316316 , writerNumberSections = False
317− , writerNumberFrom = 1
317+ , writerNumberOffset = [0,0,0,0,0,0]
318318 , writerSectionDivs = False
319319 , writerExtensions = pandocExtensions
320320 , writerReferenceLinks = False
src/Text/Pandoc/Writers/EPUB.hs+1−1
@@ -149,7 +149,7 @@ writeEPUB opts doc@(Pandoc meta _) = do
149149 let chapToEntry :: Int -> [Block] -> Entry
150150 chapToEntry num bs = mkEntry (showChapter num)
151151 $ renderHtml
152− $ writeHtml opts'{ writerNumberFrom = num }
152+ $ writeHtml opts'{ writerNumberOffset = [num - 1] }
153153 $ case bs of
154154 (Header _ _ xs : _) -> Pandoc (Meta xs [] []) bs
155155 _ -> Pandoc (Meta [] [] []) bs
src/Text/Pandoc/Writers/HTML.hs+1−3
@@ -274,9 +274,7 @@ elementToHtml :: Int -> WriterOptions -> Element -> State WriterState Html
274274elementToHtml _slideLevel opts (Blk block) = blockToHtml opts block
275275elementToHtml slideLevel opts (Sec level num (id',classes,keyvals) title' elements) = do
276276 let slide = writerSlideVariant opts /= NoSlides && level <= slideLevel
277− let num' = case num of
278− (n:ns) -> n + writerNumberFrom opts - 1 : ns
279− [] -> []
277+ let num' = zipWith (+) num (writerNumberOffset opts)
280278 modify $ \st -> st{stSecNum = num'} -- update section number
281279 -- always use level 1 for slide titles
282280 let level' = if slide then 1 else level