diff options
| author | John MacFarlane <fiddlosopher@gmail.com> | 2013-03-16 14:48:37 -0700 | 
|---|---|---|
| committer | John MacFarlane <fiddlosopher@gmail.com> | 2013-03-16 14:48:37 -0700 | 
| commit | f8fec87f09d56b6a2d877af3a34e7af045cac29f (patch) | |
| tree | 1269b53441e56048d9f45036bb1fc5680e39f9c2 | |
| parent | 1921112bc96f2c72a195b05ca5f454dc705124e6 (diff) | |
| download | pandoc-f8fec87f09d56b6a2d877af3a34e7af045cac29f.tar.gz | |
Fixed numbering mismatch between TOC and sections in HTML.
Also made `--number-offset` affect TOC numbering as well
as section numbering, as it should have all along.
Closes #789.
| -rw-r--r-- | pandoc.hs | 6 | ||||
| -rw-r--r-- | src/Text/Pandoc/Writers/HTML.hs | 3 | 
2 files changed, 5 insertions, 4 deletions
| @@ -100,7 +100,7 @@ data Opt = Opt      , optVariables         :: [(String,String)] -- ^ Template variables to set      , optOutputFile        :: String  -- ^ Name of output file      , optNumberSections    :: Bool    -- ^ Number sections in LaTeX -    , optNumberOffset        :: [Int]   -- ^ Starting number for sections +    , optNumberOffset      :: [Int]   -- ^ Starting number for sections      , optSectionDivs       :: Bool    -- ^ Put sections in div tags in HTML      , optIncremental       :: Bool    -- ^ Use incremental lists in Slidy/Slideous/S5      , optSelfContained     :: Bool    -- ^ Make HTML accessible offline @@ -157,7 +157,7 @@ defaultOpts = Opt      , optVariables             = []      , optOutputFile            = "-"    -- "-" means stdout      , optNumberSections        = False -    , optNumberOffset          = [1,1,1,1,1,1] +    , optNumberOffset          = [0,0,0,0,0,0]      , optSectionDivs           = False      , optIncremental           = False      , optSelfContained         = False @@ -1035,7 +1035,7 @@ main = do                              writerBiblioFiles      = reffiles,                              writerIgnoreNotes      = False,                              writerNumberSections   = numberSections, -                            writerNumberOffset       = numberFrom, +                            writerNumberOffset     = numberFrom,                              writerSectionDivs      = sectionDivs,                              writerReferenceLinks   = referenceLinks,                              writerWrapText         = wrap, diff --git a/src/Text/Pandoc/Writers/HTML.hs b/src/Text/Pandoc/Writers/HTML.hs index 98d352382..1ea4442f9 100644 --- a/src/Text/Pandoc/Writers/HTML.hs +++ b/src/Text/Pandoc/Writers/HTML.hs @@ -252,10 +252,11 @@ showSecNum = concat . intersperse "." . map show  elementToListItem :: WriterOptions -> Element -> State WriterState (Maybe Html)  elementToListItem opts (Sec lev num (id',classes,_) headerText subsecs)    | lev <= writerTOCDepth opts = do +  let num' = zipWith (+) num (writerNumberOffset opts ++ repeat 0)    let sectnum = if writerNumberSections opts && not (null num) &&                     "unnumbered" `notElem` classes                     then (H.span ! A.class_ "toc-section-number" -                        $ toHtml $ showSecNum num) >> preEscapedString " " +                        $ toHtml $ showSecNum num') >> preEscapedString " "                     else mempty    txt <- liftM (sectnum >>) $ inlineListToHtml opts headerText    subHeads <- mapM (elementToListItem opts) subsecs >>= return . catMaybes | 
