@@ -53,7 +53,7 @@ data WriterState =
5353 , stInQuote :: Bool -- true if in a blockquote
5454 , stExternalNotes :: Bool -- true if in context where
5555 -- we need to store footnotes
56− , stInMinipage :: Bool -- true if in minipage
56+ , stInMinipage :: Bool -- true if in minipage
5757 , stInHeading :: Bool -- true if in a section heading
5858 , stInItem :: Bool -- true if in \item[..]
5959 , stNotes :: [Doc Text] -- notes in a minipage
@@ -455,11 +455,21 @@ toSlides bs = do
455455
456456-- this creates section slides and marks slides with class "slide","block"
457457elementToBeamer :: PandocMonad m => Int -> Block -> LW m Block
458−elementToBeamer slideLevel d@(Div (ident,dclasses,dkvs)
459− xs@(Header lvl _ _ : _))
460− | lvl > slideLevel = return $ Div (ident,"block":dclasses,dkvs) xs
461− | lvl < slideLevel = return d
462− | otherwise = return $ Div (ident,"slide":dclasses,dkvs) xs
458+elementToBeamer slideLevel (Div (ident,"section":dclasses,dkvs)
459+ xs@(h@(Header lvl _ _) : ys))
460+ | lvl > slideLevel
461+ = return $ Div (ident,"block":dclasses,dkvs) xs
462+ | lvl < slideLevel
463+ = do let isDiv (Div{}) = True
464+ isDiv _ = False
465+ let (titleBs, slideBs) = break isDiv ys
466+ return $
467+ if null titleBs
468+ then Div (ident,dclasses,dkvs) xs
469+ else Div (ident,dclasses,dkvs)
470+ (h : Div ("","slide":dclasses,dkvs) (h:titleBs) : slideBs)
471+ | otherwise
472+ = return $ Div (ident,"slide":dclasses,dkvs) xs
463473elementToBeamer _ x = return x
464474
465475isListBlock :: Block -> Bool
@@ -516,8 +526,7 @@ blockToLaTeX (Div (identifier,"slide":dclasses,dkvs)
516526 braces (literal ref) <> braces empty
517527 contents <- blockListToLaTeX bs >>= wrapDiv (identifier,classes,kvs)
518528 return $ ("\\begin{frame}" <> options <> slideTitle <> slideAnchor) $$
519− contents $$
520− "\\end{frame}"
529+ contents $$ "\\end{frame}"
521530blockToLaTeX (Div (identifier@(T.uncons -> Just (_,_)),dclasses,dkvs)
522531 (Header lvl ("",hclasses,hkvs) ils : bs)) =
523532 -- move identifier from div to header