aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Text/Pandoc/Shared.hs2
-rw-r--r--src/Text/Pandoc/Writers/HTML.hs19
-rw-r--r--src/pandoc.hs9
3 files changed, 21 insertions, 9 deletions
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 <div>.
-- Assumes notes are sorted.
diff --git a/src/pandoc.hs b/src/pandoc.hs
index 9546d6026..cd4d65aa5 100644
--- a/src/pandoc.hs
+++ b/src/pandoc.hs
@@ -142,6 +142,7 @@ data Opt = Opt
, optVariables :: [(String,String)] -- ^ Template variables to set
, optOutputFile :: String -- ^ Name of output file
, optNumberSections :: Bool -- ^ Number sections in LaTeX
+ , optSectionDivs :: Bool -- ^ Put sections in div tags in HTML
, optIncremental :: Bool -- ^ Use incremental lists in Slidy/S5
, optXeTeX :: Bool -- ^ Format latex for xetex
, optSmart :: Bool -- ^ Use smart typography
@@ -182,6 +183,7 @@ defaultOpts = Opt
, optVariables = []
, optOutputFile = "-" -- "-" means stdout
, optNumberSections = False
+ , optSectionDivs = False
, optIncremental = False
, optXeTeX = False
, optSmart = False
@@ -325,6 +327,11 @@ options =
(\opt -> return opt { optNumberSections = True }))
"" -- "Number sections in LaTeX"
+ , Option "" ["section-divs"]
+ (NoArg
+ (\opt -> return opt { optSectionDivs = True }))
+ "" -- "Put sections in div tags in HTML"
+
, Option "" ["no-wrap"]
(NoArg
(\opt -> return opt { optWrapText = False }))
@@ -643,6 +650,7 @@ main = do
, optTemplate = template
, optOutputFile = outputFile
, optNumberSections = numberSections
+ , optSectionDivs = sectionDivs
, optIncremental = incremental
, optXeTeX = xetex
, optSmart = smart
@@ -782,6 +790,7 @@ main = do
writerXeTeX = xetex,
writerIgnoreNotes = False,
writerNumberSections = numberSections,
+ writerSectionDivs = sectionDivs,
writerStrictMarkdown = strict,
writerReferenceLinks = referenceLinks,
writerWrapText = wrap,