git.iko.soy/typeable/pandoc
on master help sign in
Reveal.js writer: restore old behavior for 2D nesting.

The fix to #6030 actually changed behavior, so that the 2D nesting occurred at slide level N-1 and N, instead of at the top-level section. This commit restores the 2.7.3 behavior. If there are more than 2 levels, the top level is horizontal and the rest are collapsed to vertical. Closes #6032.

commit2a67b7aea9e9d70e67c0def21da78abf4ec590a1 authorJohn MacFarlane <jgm@berkeley.edu> dateTue 7 Jan 2020, 10:11 (7 years ago) parentd4651b3
2 files changed+36−12
src/Text/Pandoc/Writers/HTML.hs+17−11 test/command/6030.md+19−1
src/Text/Pandoc/Writers/HTML.hs+17−11
@@ -80,6 +80,7 @@ data WriterState = WriterState
8080 , stEPUBVersion :: Maybe EPUBVersion -- ^ EPUB version if for epub
8181 , stSlideVariant :: HTMLSlideVariant
8282 , stSlideLevel :: Int -- ^ Slide level
83+ , stInSection :: Bool -- ^ Content is in a section (revealjs)
8384 , stCodeBlockNum :: Int -- ^ Number of code block
8485 }
8586
@@ -90,6 +91,7 @@ defaultWriterState = WriterState {stNotes= [], stMath = False, stQuotes = False,
9091 stEPUBVersion = Nothing,
9192 stSlideVariant = NoSlides,
9293 stSlideLevel = 1,
94+ stInSection = False,
9395 stCodeBlockNum = 0}
9496
9597-- Helpers to render HTML with the appropriate function.
@@ -662,8 +664,6 @@ blockToHtml opts (Div (ident, "section":dclasses, dkvs)
662664 else case splitBy isPause xs of
663665 [] -> ([],[])
664666 (z:zs) -> ([],z ++ concatMap inDiv zs)
665− titleContents <- blockListToHtml opts titleBlocks
666− innerContents <- blockListToHtml opts innerSecs
667667 let classes' = ordNub $
668668 ["title-slide" | titleSlide] ++ ["slide" | slide] ++
669669 ["section" | (slide || writerSectionDivs opts) &&
@@ -674,20 +674,26 @@ blockToHtml opts (Div (ident, "section":dclasses, dkvs)
674674 then H5.section
675675 else H.div
676676 let attr = (ident, classes', dkvs)
677+ titleContents <- blockListToHtml opts titleBlocks
678+ inSection <- gets stInSection
679+ innerContents <- do
680+ modify $ \st -> st{ stInSection = True }
681+ res <- blockListToHtml opts innerSecs
682+ modify $ \st -> st{ stInSection = inSection }
683+ return res
677684 if titleSlide
678685 then do
679686 t <- addAttrs opts attr $
680687 secttag $ nl opts <> header' <> nl opts <> titleContents <> nl opts
688+ -- ensure 2D nesting for revealjs, but only for one level;
689+ -- revealjs doesn't like more than one level of nesting
681690 return $
682− -- ensure 2D nesting for revealjs, but only for one level;
683− -- revealjs doesn't like more than one level of nseting
684− (if slideVariant == RevealJsSlides && not (null innerSecs) &&
685− level == slideLevel - 1
686− then \z -> H5.section (nl opts <> z)
687− else id) $ t <> nl opts <>
688− if null innerSecs
689− then mempty
690− else innerContents <> nl opts
691+ if slideVariant == RevealJsSlides && not inSection &&
692+ not (null innerSecs)
693+ then H5.section (nl opts <> t <> nl opts <> innerContents)
694+ else t <> nl opts <> if null innerSecs
695+ then mempty
696+ else innerContents <> nl opts
691697 else if writerSectionDivs opts || slide ||
692698 (hident /= ident && not (T.null hident || T.null ident)) ||
693699 (hclasses /= dclasses) || (hkvs /= dkvs)
test/command/6030.md+19−1
@@ -15,12 +15,20 @@ Three
1515#### Four
1616
1717Four
18+
19+# New sec
20+
21+New sec
22+
23+## New sub
24+
25+New sub
1826^D
27+<section>
1928<section id="one" class="title-slide slide level1">
2029<h1>One</h1>
2130<p>One</p>
2231</section>
23−<section>
2432<section id="two" class="title-slide slide level2">
2533<h2>Two</h2>
2634<p>Two</p>
@@ -32,6 +40,16 @@ Four
3240<p>Four</p>
3341</section>
3442</section>
43+<section>
44+<section id="new-sec" class="title-slide slide level1">
45+<h1>New sec</h1>
46+<p>New sec</p>
47+</section>
48+<section id="new-sub" class="title-slide slide level2">
49+<h2>New sub</h2>
50+<p>New sub</p>
51+</section>
52+</section>
3553```
3654
3755```