aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn MacFarlane <fiddlosopher@gmail.com>2013-02-23 18:11:05 -0800
committerJohn MacFarlane <fiddlosopher@gmail.com>2013-02-23 18:11:05 -0800
commit756c8d492a3793a8a0c2b750dac6005885b9a2d0 (patch)
tree9c3d2eaea3b2e8e8d487b7170f732131612abb02 /src
parenta7245b453c433ce4ed585b0097016576090f01cb (diff)
downloadpandoc-756c8d492a3793a8a0c2b750dac6005885b9a2d0.tar.gz
`--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.
Diffstat (limited to 'src')
-rw-r--r--src/Text/Pandoc/Options.hs4
-rw-r--r--src/Text/Pandoc/Writers/EPUB.hs2
-rw-r--r--src/Text/Pandoc/Writers/HTML.hs4
3 files changed, 4 insertions, 6 deletions
diff --git a/src/Text/Pandoc/Options.hs b/src/Text/Pandoc/Options.hs
index ab5cf4c43..39fa2a1b2 100644
--- a/src/Text/Pandoc/Options.hs
+++ b/src/Text/Pandoc/Options.hs
@@ -270,7 +270,7 @@ data WriterOptions = WriterOptions
, writerHTMLMathMethod :: HTMLMathMethod -- ^ How to print math in HTML
, writerIgnoreNotes :: Bool -- ^ Ignore footnotes (used in making toc)
, writerNumberSections :: Bool -- ^ Number sections in LaTeX
- , writerNumberFrom :: Int -- ^ Starting section number
+ , writerNumberOffset :: [Int] -- ^ Starting number for section, subsection, ...
, writerSectionDivs :: Bool -- ^ Put sections in div tags in HTML
, writerExtensions :: Set Extension -- ^ Markdown extensions that can be used
, writerReferenceLinks :: Bool -- ^ Use reference links in writing markdown, rst
@@ -314,7 +314,7 @@ instance Default WriterOptions where
, writerHTMLMathMethod = PlainMath
, writerIgnoreNotes = False
, writerNumberSections = False
- , writerNumberFrom = 1
+ , writerNumberOffset = [0,0,0,0,0,0]
, writerSectionDivs = False
, writerExtensions = pandocExtensions
, writerReferenceLinks = False
diff --git a/src/Text/Pandoc/Writers/EPUB.hs b/src/Text/Pandoc/Writers/EPUB.hs
index d25efa672..048f90da1 100644
--- a/src/Text/Pandoc/Writers/EPUB.hs
+++ b/src/Text/Pandoc/Writers/EPUB.hs
@@ -149,7 +149,7 @@ writeEPUB opts doc@(Pandoc meta _) = do
let chapToEntry :: Int -> [Block] -> Entry
chapToEntry num bs = mkEntry (showChapter num)
$ renderHtml
- $ writeHtml opts'{ writerNumberFrom = num }
+ $ writeHtml opts'{ writerNumberOffset = [num - 1] }
$ case bs of
(Header _ _ xs : _) -> Pandoc (Meta xs [] []) bs
_ -> Pandoc (Meta [] [] []) bs
diff --git a/src/Text/Pandoc/Writers/HTML.hs b/src/Text/Pandoc/Writers/HTML.hs
index d8da74d3a..477087166 100644
--- a/src/Text/Pandoc/Writers/HTML.hs
+++ b/src/Text/Pandoc/Writers/HTML.hs
@@ -274,9 +274,7 @@ elementToHtml :: Int -> WriterOptions -> Element -> State WriterState Html
elementToHtml _slideLevel opts (Blk block) = blockToHtml opts block
elementToHtml slideLevel opts (Sec level num (id',classes,keyvals) title' elements) = do
let slide = writerSlideVariant opts /= NoSlides && level <= slideLevel
- let num' = case num of
- (n:ns) -> n + writerNumberFrom opts - 1 : ns
- [] -> []
+ let num' = zipWith (+) num (writerNumberOffset opts)
modify $ \st -> st{stSecNum = num'} -- update section number
-- always use level 1 for slide titles
let level' = if slide then 1 else level