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.
This commit is contained in:
parent
d4651b3a5b
commit
2a67b7aea9
2 changed files with 36 additions and 12 deletions
|
@ -80,6 +80,7 @@ data WriterState = WriterState
|
||||||
, stEPUBVersion :: Maybe EPUBVersion -- ^ EPUB version if for epub
|
, stEPUBVersion :: Maybe EPUBVersion -- ^ EPUB version if for epub
|
||||||
, stSlideVariant :: HTMLSlideVariant
|
, stSlideVariant :: HTMLSlideVariant
|
||||||
, stSlideLevel :: Int -- ^ Slide level
|
, stSlideLevel :: Int -- ^ Slide level
|
||||||
|
, stInSection :: Bool -- ^ Content is in a section (revealjs)
|
||||||
, stCodeBlockNum :: Int -- ^ Number of code block
|
, stCodeBlockNum :: Int -- ^ Number of code block
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,6 +91,7 @@ defaultWriterState = WriterState {stNotes= [], stMath = False, stQuotes = False,
|
||||||
stEPUBVersion = Nothing,
|
stEPUBVersion = Nothing,
|
||||||
stSlideVariant = NoSlides,
|
stSlideVariant = NoSlides,
|
||||||
stSlideLevel = 1,
|
stSlideLevel = 1,
|
||||||
|
stInSection = False,
|
||||||
stCodeBlockNum = 0}
|
stCodeBlockNum = 0}
|
||||||
|
|
||||||
-- Helpers to render HTML with the appropriate function.
|
-- Helpers to render HTML with the appropriate function.
|
||||||
|
@ -662,8 +664,6 @@ blockToHtml opts (Div (ident, "section":dclasses, dkvs)
|
||||||
else case splitBy isPause xs of
|
else case splitBy isPause xs of
|
||||||
[] -> ([],[])
|
[] -> ([],[])
|
||||||
(z:zs) -> ([],z ++ concatMap inDiv zs)
|
(z:zs) -> ([],z ++ concatMap inDiv zs)
|
||||||
titleContents <- blockListToHtml opts titleBlocks
|
|
||||||
innerContents <- blockListToHtml opts innerSecs
|
|
||||||
let classes' = ordNub $
|
let classes' = ordNub $
|
||||||
["title-slide" | titleSlide] ++ ["slide" | slide] ++
|
["title-slide" | titleSlide] ++ ["slide" | slide] ++
|
||||||
["section" | (slide || writerSectionDivs opts) &&
|
["section" | (slide || writerSectionDivs opts) &&
|
||||||
|
@ -674,18 +674,24 @@ blockToHtml opts (Div (ident, "section":dclasses, dkvs)
|
||||||
then H5.section
|
then H5.section
|
||||||
else H.div
|
else H.div
|
||||||
let attr = (ident, classes', dkvs)
|
let attr = (ident, classes', dkvs)
|
||||||
|
titleContents <- blockListToHtml opts titleBlocks
|
||||||
|
inSection <- gets stInSection
|
||||||
|
innerContents <- do
|
||||||
|
modify $ \st -> st{ stInSection = True }
|
||||||
|
res <- blockListToHtml opts innerSecs
|
||||||
|
modify $ \st -> st{ stInSection = inSection }
|
||||||
|
return res
|
||||||
if titleSlide
|
if titleSlide
|
||||||
then do
|
then do
|
||||||
t <- addAttrs opts attr $
|
t <- addAttrs opts attr $
|
||||||
secttag $ nl opts <> header' <> nl opts <> titleContents <> nl opts
|
secttag $ nl opts <> header' <> nl opts <> titleContents <> nl opts
|
||||||
return $
|
|
||||||
-- ensure 2D nesting for revealjs, but only for one level;
|
-- ensure 2D nesting for revealjs, but only for one level;
|
||||||
-- revealjs doesn't like more than one level of nseting
|
-- revealjs doesn't like more than one level of nesting
|
||||||
(if slideVariant == RevealJsSlides && not (null innerSecs) &&
|
return $
|
||||||
level == slideLevel - 1
|
if slideVariant == RevealJsSlides && not inSection &&
|
||||||
then \z -> H5.section (nl opts <> z)
|
not (null innerSecs)
|
||||||
else id) $ t <> nl opts <>
|
then H5.section (nl opts <> t <> nl opts <> innerContents)
|
||||||
if null innerSecs
|
else t <> nl opts <> if null innerSecs
|
||||||
then mempty
|
then mempty
|
||||||
else innerContents <> nl opts
|
else innerContents <> nl opts
|
||||||
else if writerSectionDivs opts || slide ||
|
else if writerSectionDivs opts || slide ||
|
||||||
|
|
|
@ -15,12 +15,20 @@ Three
|
||||||
#### Four
|
#### Four
|
||||||
|
|
||||||
Four
|
Four
|
||||||
|
|
||||||
|
# New sec
|
||||||
|
|
||||||
|
New sec
|
||||||
|
|
||||||
|
## New sub
|
||||||
|
|
||||||
|
New sub
|
||||||
^D
|
^D
|
||||||
|
<section>
|
||||||
<section id="one" class="title-slide slide level1">
|
<section id="one" class="title-slide slide level1">
|
||||||
<h1>One</h1>
|
<h1>One</h1>
|
||||||
<p>One</p>
|
<p>One</p>
|
||||||
</section>
|
</section>
|
||||||
<section>
|
|
||||||
<section id="two" class="title-slide slide level2">
|
<section id="two" class="title-slide slide level2">
|
||||||
<h2>Two</h2>
|
<h2>Two</h2>
|
||||||
<p>Two</p>
|
<p>Two</p>
|
||||||
|
@ -32,6 +40,16 @@ Four
|
||||||
<p>Four</p>
|
<p>Four</p>
|
||||||
</section>
|
</section>
|
||||||
</section>
|
</section>
|
||||||
|
<section>
|
||||||
|
<section id="new-sec" class="title-slide slide level1">
|
||||||
|
<h1>New sec</h1>
|
||||||
|
<p>New sec</p>
|
||||||
|
</section>
|
||||||
|
<section id="new-sub" class="title-slide slide level2">
|
||||||
|
<h2>New sub</h2>
|
||||||
|
<p>New sub</p>
|
||||||
|
</section>
|
||||||
|
</section>
|
||||||
```
|
```
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
Loading…
Reference in a new issue