From 9be9bccfcfc2c46459b3da963bc59a37f841fe8a Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Thu, 15 Jul 2010 19:01:00 -0700 Subject: Added --section-divs option. + Header identifiers now get attached to the headers, unless --section-divs is specified, in which case they are added to enclosing divs. By default, the divs are not added. + Resolves Issue #230, #239. --- src/Text/Pandoc/Shared.hs | 2 ++ src/Text/Pandoc/Writers/HTML.hs | 19 ++++++++++--------- 2 files changed, 12 insertions(+), 9 deletions(-) (limited to 'src/Text') diff --git a/src/Text/Pandoc/Shared.hs b/src/Text/Pandoc/Shared.hs index b8eb14177..633708046 100644 --- a/src/Text/Pandoc/Shared.hs +++ b/src/Text/Pandoc/Shared.hs @@ -487,6 +487,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 + , writerSectionDivs :: Bool -- ^ Put sections in div tags in HTML , writerStrictMarkdown :: Bool -- ^ Use strict markdown syntax , writerReferenceLinks :: Bool -- ^ Use reference links in writing markdown, rst , writerWrapText :: Bool -- ^ Wrap text to line length @@ -512,6 +513,7 @@ defaultWriterOptions = , writerHTMLMathMethod = PlainMath , writerIgnoreNotes = False , writerNumberSections = False + , writerSectionDivs = True , writerStrictMarkdown = False , writerReferenceLinks = False , writerWrapText = True diff --git a/src/Text/Pandoc/Writers/HTML.hs b/src/Text/Pandoc/Writers/HTML.hs index 20022e182..e9006a39b 100644 --- a/src/Text/Pandoc/Writers/HTML.hs +++ b/src/Text/Pandoc/Writers/HTML.hs @@ -208,15 +208,16 @@ elementToHtml opts (Sec level num id' title' elements) = do innerContents <- mapM (elementToHtml opts) elements modify $ \st -> st{stSecNum = num} -- update section number header' <- blockToHtml opts (Header level title') - let stuff = header' : innerContents - return $ case writerSlideVariant opts of - SlidySlides -> toHtmlFromList stuff - S5Slides -> toHtmlFromList stuff - -- S5 gets confused by the extra divs around sections - _ | (writerStrictMarkdown opts && - not (writerTableOfContents opts)) -> - toHtmlFromList stuff - _ -> thediv ! [prefixedId opts id'] << stuff + let slides = writerSlideVariant opts `elem` [SlidySlides, S5Slides] + let header'' = header' ! [prefixedId opts id' | + not (writerStrictMarkdown opts || + writerSectionDivs opts || slides)] + let stuff = header'' : innerContents + return $ if slides -- S5 gets confused by the extra divs around sections + then toHtmlFromList stuff + else if writerSectionDivs opts + then thediv ! [prefixedId opts id'] << stuff + else toHtmlFromList stuff -- | Convert list of Note blocks to a footnote
. -- Assumes notes are sorted. -- cgit v1.2.3