@@ -105,23 +105,18 @@ pandocToHtml opts (Pandoc (Meta title' authors' date') blocks) = do
105105 date <- if standalone
106106 then inlineListToHtml opts date'
107107 else return noHtml
108− let startSlide = RawBlock "html" "<div class=\"slide\">\n"
109− endSlide = RawBlock "html" "</div>\n"
110− let cutUp (HorizontalRule : Header 1 ys : xs) = cutUp (Header 1 ys : xs)
111− cutUp (HorizontalRule : xs) = [endSlide, startSlide] ++ cutUp xs
112− cutUp (Header 1 ys : xs) = [endSlide, startSlide] ++
113− (Header 1 ys : cutUp xs)
114− cutUp (x:xs) = x : cutUp xs
115− cutUp [] = []
116− let slides = case blocks of
117− (HorizontalRule : xs) -> [startSlide] ++ cutUp xs ++ [endSlide]
118− (Header 1 ys : xs) -> [startSlide, Header 1 ys] ++
119− cutUp xs ++ [endSlide]
120− _ -> [startSlide] ++ cutUp blocks ++
121− [endSlide]
122− let sects = if writerSlideVariant opts `elem` [SlidySlides, S5Slides]
123− then hierarchicalize slides
124− else hierarchicalize blocks
108+ let sects = hierarchicalize $
109+ if writerSlideVariant opts == NoSlides
110+ then blocks
111+ else case blocks of
112+ (Header 1 _ : _) -> blocks
113+ _ ->
114+ let isL1 (Header 1 _) = True
115+ isL1 _ = False
116+ (preBlocks, rest) = break isL1 blocks
117+ in (RawBlock "html" "<div class=\"slide\">" :
118+ preBlocks) ++ (RawBlock "html" "</div>" :
119+ rest)
125120 toc <- if writerTableOfContents opts
126121 then tableOfContents opts sects
127122 else return Nothing
@@ -233,27 +228,29 @@ elementToListItem opts (Sec _ num id' headerText subsecs) = do
233228
234229-- | Convert an Element to Html.
235230elementToHtml :: WriterOptions -> Element -> State WriterState Html
231+elementToHtml opts (Blk HorizontalRule) | writerSlideVariant opts /= NoSlides =
232+ return $ primHtml "</div>" +++ nl opts +++ primHtml "<div class=\"slide\""
236233elementToHtml opts (Blk block) = blockToHtml opts block
237234elementToHtml opts (Sec level num id' title' elements) = do
238235 modify $ \st -> st{stSecNum = num} -- update section number
239236 header' <- blockToHtml opts (Header level title')
240237 innerContents <- mapM (elementToHtml opts) elements
241− let s5 = writerSlideVariant opts == S5Slides
242238 let header'' = header' ! [prefixedId opts id' |
243239 not (writerStrictMarkdown opts ||
244− writerSectionDivs opts || s5)]
240+ writerSectionDivs opts ||
241+ writerSlideVariant opts == S5Slides)]
245242 let stuff = header'' : innerContents
246− return $ if s5 -- S5 gets confused by the extra divs around sections
247− then toHtmlFromList $ intersperse (nl opts) stuff
248− else if writerSectionDivs opts
249− then if writerHtml5 opts
250− then tag "section" ! [prefixedId opts id']
251− << (nl opts : (intersperse (nl opts) stuff
252− ++ [nl opts]))
253− else thediv ! [prefixedId opts id'] <<
254− (nl opts : (intersperse (nl opts) stuff
255− ++ [nl opts]))
256− else toHtmlFromList $ intersperse (nl opts) stuff
243+ let slide = writerSlideVariant opts /= NoSlides && level == 1
244+ let stuff' = if slide
245+ then [thediv ! [theclass "slide"] <<
246+ (nl opts : intersperse (nl opts) stuff ++ [nl opts])]
247+ else intersperse (nl opts) stuff
248+ let inNl x = nl opts : x ++ [nl opts]
249+ return $ if writerSectionDivs opts
250+ then if writerHtml5 opts
251+ then tag "section" ! [prefixedId opts id'] << inNl stuff'
252+ else thediv ! [prefixedId opts id'] << inNl stuff'
253+ else toHtmlFromList stuff'
257254
258255-- | Convert list of Note blocks to a footnote <div>.
259256-- Assumes notes are sorted.