diff options
author | John MacFarlane <jgm@berkeley.edu> | 2012-06-25 14:52:09 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2012-06-25 14:52:09 -0700 |
commit | 527be1ddf2ef23d954f59d982e7f8c432ec2f3b8 (patch) | |
tree | 37c897a5ddd649a30905dbdc7d60635b96222c71 /src/Text | |
parent | 4cf3aaecde9705069a46c23dcd19b32e60f9f3f4 (diff) | |
download | pandoc-527be1ddf2ef23d954f59d982e7f8c432ec2f3b8.tar.gz |
Don't generate empty H1 after hrule slide breaks.
We now use a slide-level header with contents [Str "\0"] to mark
an hrule break. This avoids creation of an empty H1 in these
contexts.
Closes #484.
Diffstat (limited to 'src/Text')
-rw-r--r-- | src/Text/Pandoc/Slides.hs | 5 | ||||
-rw-r--r-- | src/Text/Pandoc/Writers/HTML.hs | 4 | ||||
-rw-r--r-- | src/Text/Pandoc/Writers/LaTeX.hs | 7 |
3 files changed, 11 insertions, 5 deletions
diff --git a/src/Text/Pandoc/Slides.hs b/src/Text/Pandoc/Slides.hs index c74e99279..fe9b60720 100644 --- a/src/Text/Pandoc/Slides.hs +++ b/src/Text/Pandoc/Slides.hs @@ -49,9 +49,10 @@ prepSlides :: Int -> [Block] -> [Block] prepSlides slideLevel = ensureStartWithH . splitHrule where splitHrule (HorizontalRule : Header n xs : ys) | n == slideLevel = Header slideLevel xs : splitHrule ys - splitHrule (HorizontalRule : xs) = Header slideLevel [] : splitHrule xs + splitHrule (HorizontalRule : xs) = Header slideLevel [Str "\0"] : + splitHrule xs splitHrule (x : xs) = x : splitHrule xs splitHrule [] = [] ensureStartWithH bs@(Header n _:_) | n <= slideLevel = bs - ensureStartWithH bs = Header slideLevel [] : bs + ensureStartWithH bs = Header slideLevel [Str "\0"] : bs diff --git a/src/Text/Pandoc/Writers/HTML.hs b/src/Text/Pandoc/Writers/HTML.hs index 93ad6eb6e..b8474ee3f 100644 --- a/src/Text/Pandoc/Writers/HTML.hs +++ b/src/Text/Pandoc/Writers/HTML.hs @@ -262,7 +262,9 @@ elementToHtml slideLevel opts (Sec level num id' title' elements) = do -- always use level 1 for slide titles let level' = if slide then 1 else level let titleSlide = slide && level < slideLevel - header' <- blockToHtml opts (Header level' title') + header' <- if title' == [Str "\0"] -- marker for hrule + then return mempty + else blockToHtml opts (Header level' title') let isSec (Sec _ _ _ _ _) = True isSec (Blk _) = False innerContents <- mapM (elementToHtml slideLevel opts) diff --git a/src/Text/Pandoc/Writers/LaTeX.hs b/src/Text/Pandoc/Writers/LaTeX.hs index 836ef1b50..7beee2d42 100644 --- a/src/Text/Pandoc/Writers/LaTeX.hs +++ b/src/Text/Pandoc/Writers/LaTeX.hs @@ -243,8 +243,11 @@ elementToBeamer slideLevel (Sec lvl _num _ident tit elts) let fragile = if not $ null $ queryWith hasCodeBlock elts ++ queryWith hasCode elts then "[fragile]" else "" - let slideStart = Para $ RawInline "latex" ("\\begin{frame}" ++ fragile ++ - "\\frametitle{") : tit ++ [RawInline "latex" "}"] + let slideStart = Para $ RawInline "latex" ("\\begin{frame}" ++ fragile) : + if tit == [Str "\0"] -- marker for hrule + then [] + else (RawInline "latex" "\\frametitle{") : tit ++ + [RawInline "latex" "}"] let slideEnd = RawBlock "latex" "\\end{frame}" -- now carve up slide into blocks if there are sections inside bs <- concat `fmap` mapM (elementToBeamer slideLevel) elts |