Simplified slide creation in HTML writer.
A horizontal rule now gets transformed into an empty H1 header before 'hierarchicalize' is called. If the document that does not begin with an H1 header, an empty one is provided. This avoids the need for kludgy raw HTML. Also, the 'titleslide' class is added to any section containing just a title: ---- ----
This commit is contained in:
parent
c8f0bd7003
commit
072df3f5dd
3 changed files with 22 additions and 30 deletions
|
@ -106,18 +106,17 @@ pandocToHtml opts (Pandoc (Meta title' authors' date') blocks) = do
|
||||||
date <- if standalone
|
date <- if standalone
|
||||||
then inlineListToHtml opts date'
|
then inlineListToHtml opts date'
|
||||||
else return noHtml
|
else return noHtml
|
||||||
|
let splitHrule (HorizontalRule : Header 1 xs : ys)
|
||||||
|
= Header 1 xs : splitHrule ys
|
||||||
|
splitHrule (HorizontalRule : xs) = Header 1 [] : splitHrule xs
|
||||||
|
splitHrule (x : xs) = x : splitHrule xs
|
||||||
|
splitHrule [] = []
|
||||||
|
let ensureStartWithH1 bs@(Header 1 _:_) = bs
|
||||||
|
ensureStartWithH1 bs = Header 1 [] : bs
|
||||||
let sects = hierarchicalize $
|
let sects = hierarchicalize $
|
||||||
if writerSlideVariant opts == NoSlides
|
if writerSlideVariant opts == NoSlides
|
||||||
then blocks
|
then blocks
|
||||||
else case blocks of
|
else ensureStartWithH1 $ splitHrule blocks
|
||||||
(Header 1 _ : _) -> blocks
|
|
||||||
_ ->
|
|
||||||
let isL1 (Header 1 _) = True
|
|
||||||
isL1 _ = False
|
|
||||||
(preBlocks, rest) = break isL1 blocks
|
|
||||||
in (RawBlock "html" "<div class=\"slide\">" :
|
|
||||||
preBlocks) ++ (RawBlock "html" "</div>" :
|
|
||||||
rest)
|
|
||||||
toc <- if writerTableOfContents opts
|
toc <- if writerTableOfContents opts
|
||||||
then tableOfContents opts sects
|
then tableOfContents opts sects
|
||||||
else return Nothing
|
else return Nothing
|
||||||
|
@ -226,13 +225,6 @@ elementToListItem opts (Sec _ num id' headerText subsecs) = do
|
||||||
|
|
||||||
-- | Convert an Element to Html.
|
-- | Convert an Element to Html.
|
||||||
elementToHtml :: WriterOptions -> Element -> State WriterState Html
|
elementToHtml :: WriterOptions -> Element -> State WriterState Html
|
||||||
elementToHtml opts (Blk HorizontalRule)
|
|
||||||
| writerSlideVariant opts == S5Slides ||
|
|
||||||
writerSlideVariant opts == SlidySlides =
|
|
||||||
return $ primHtml "</div>" +++ nl opts +++ primHtml "<div class=\"slide\">"
|
|
||||||
elementToHtml opts (Blk HorizontalRule)
|
|
||||||
| writerSlideVariant opts == DZSlides =
|
|
||||||
return $ primHtml "</section>" +++ nl opts +++ primHtml "<section>"
|
|
||||||
elementToHtml opts (Blk block) = blockToHtml opts block
|
elementToHtml opts (Blk block) = blockToHtml opts block
|
||||||
elementToHtml opts (Sec level num id' title' elements) = do
|
elementToHtml opts (Sec level num id' title' elements) = do
|
||||||
modify $ \st -> st{stSecNum = num} -- update section number
|
modify $ \st -> st{stSecNum = num} -- update section number
|
||||||
|
@ -244,17 +236,17 @@ elementToHtml opts (Sec level num id' title' elements) = do
|
||||||
writerSlideVariant opts == S5Slides)]
|
writerSlideVariant opts == S5Slides)]
|
||||||
let stuff = header'' : innerContents
|
let stuff = header'' : innerContents
|
||||||
let slide = writerSlideVariant opts /= NoSlides && level == 1
|
let slide = writerSlideVariant opts /= NoSlides && level == 1
|
||||||
let stuff' = if (writerSlideVariant opts == S5Slides ||
|
let titleSlide = slide && null elements
|
||||||
writerSlideVariant opts == SlidySlides) && level == 1
|
let classes = [theclass "titleslide" | titleSlide] ++
|
||||||
then [thediv ! [theclass "slide"] <<
|
[theclass "slide" | slide]
|
||||||
(nl opts : intersperse (nl opts) stuff ++ [nl opts])]
|
let inNl x = nl opts : intersperse (nl opts) x ++ [nl opts]
|
||||||
else intersperse (nl opts) stuff
|
return $ if writerSectionDivs opts || slide
|
||||||
let inNl x = nl opts : x ++ [nl opts]
|
|
||||||
return $ if writerSectionDivs opts || writerSlideVariant opts == DZSlides
|
|
||||||
then if writerHtml5 opts
|
then if writerHtml5 opts
|
||||||
then tag "section" ! [prefixedId opts id'] << inNl stuff'
|
then tag "section" ! (prefixedId opts id' : classes)
|
||||||
else thediv ! [prefixedId opts id'] << inNl stuff'
|
<< inNl stuff
|
||||||
else toHtmlFromList stuff'
|
else thediv ! (prefixedId opts id' : classes)
|
||||||
|
<< inNl stuff
|
||||||
|
else toHtmlFromList $ intersperse (nl opts) stuff
|
||||||
|
|
||||||
-- | Convert list of Note blocks to a footnote <div>.
|
-- | Convert list of Note blocks to a footnote <div>.
|
||||||
-- Assumes notes are sorted.
|
-- Assumes notes are sorted.
|
||||||
|
|
|
@ -34,14 +34,14 @@
|
||||||
<h3>Sam Smith<br/>Jen Jones</h3>
|
<h3>Sam Smith<br/>Jen Jones</h3>
|
||||||
<h4>July 15, 2006</h4>
|
<h4>July 15, 2006</h4>
|
||||||
</div>
|
</div>
|
||||||
<div class="slide">
|
<div id="first-slide" class="slide">
|
||||||
<h1>First slide</h1>
|
<h1>First slide</h1>
|
||||||
<ul>
|
<ul>
|
||||||
<li>first bullet</li>
|
<li>first bullet</li>
|
||||||
<li>second bullet</li>
|
<li>second bullet</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div class="slide">
|
<div id="math" class="slide">
|
||||||
<h1>Math</h1>
|
<h1>Math</h1>
|
||||||
<ul>
|
<ul>
|
||||||
<li><span class="math">$\frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}$</span></li>
|
<li><span class="math">$\frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}$</span></li>
|
||||||
|
|
|
@ -235,14 +235,14 @@
|
||||||
<h3>Sam Smith<br/>Jen Jones</h3>
|
<h3>Sam Smith<br/>Jen Jones</h3>
|
||||||
<h4>July 15, 2006</h4>
|
<h4>July 15, 2006</h4>
|
||||||
</div>
|
</div>
|
||||||
<div class="slide">
|
<div id="first-slide" class="slide">
|
||||||
<h1>First slide</h1>
|
<h1>First slide</h1>
|
||||||
<ul class="incremental">
|
<ul class="incremental">
|
||||||
<li>first bullet</li>
|
<li>first bullet</li>
|
||||||
<li>second bullet</li>
|
<li>second bullet</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div class="slide">
|
<div id="math" class="slide">
|
||||||
<h1>Math</h1>
|
<h1>Math</h1>
|
||||||
<ul class="incremental">
|
<ul class="incremental">
|
||||||
<li><span class="LaTeX">$\frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}$</span></li>
|
<li><span class="LaTeX">$\frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}$</span></li>
|
||||||
|
|
Loading…
Reference in a new issue