git.iko.soy/typeable/pandoc
on master help sign in
Beamer writer: support exampleblock and alertblock.
76a4e71John MacFarlane
MANUAL.txt+5−1
@@ -5666,7 +5666,11 @@ rules:
5666 * A heading at the slide level always starts a new slide.
5666 * A heading at the slide level always starts a new slide.
5667
5667
5668 * Headings *below* the slide level in the hierarchy create
5668 * Headings *below* the slide level in the hierarchy create
5669− headings *within* a slide.
5669+ headings *within* a slide. (In beamer, a "block" will be
5670+ created. If the heading has the class `example`, an
5671+ `exampleblock` environment will be used; if it has the class
5672+ `alert`, an `alertblock` will be used; otherwise a regular
5673+ `block` will be used.)
5670
5674
5671 * Headings *above* the slide level in the hierarchy create
5675 * Headings *above* the slide level in the hierarchy create
5672 "title slides," which just contain the section title
5676 "title slides," which just contain the section title
src/Text/Pandoc/Writers/LaTeX.hs+8−3
@@ -290,7 +290,12 @@ blockToLaTeX :: PandocMonad m
290 => Block -- ^ Block to convert
290 => Block -- ^ Block to convert
291 -> LW m (Doc Text)
291 -> LW m (Doc Text)
292blockToLaTeX Null = return empty
292blockToLaTeX Null = return empty
293−blockToLaTeX (Div attr@(identifier,"block":_,_) (Header _ _ ils : bs)) = do
293+blockToLaTeX (Div attr@(identifier,"block":dclasses,_)
294+ (Header _ _ ils : bs)) = do
295+ let blockname
296+ | "example" `elem` dclasses = "exampleblock"
297+ | "alert" `elem` dclasses = "alertblock"
298+ | otherwise = "block"
294 ref <- toLabel identifier
299 ref <- toLabel identifier
295 let anchor = if T.null identifier
300 let anchor = if T.null identifier
296 then empty
301 then empty
@@ -298,8 +303,8 @@ blockToLaTeX (Div attr@(identifier,"block":_,_) (Header _ _ ils : bs)) = do
298 braces (literal ref) <> braces empty
303 braces (literal ref) <> braces empty
299 title' <- inlineListToLaTeX ils
304 title' <- inlineListToLaTeX ils
300 contents <- blockListToLaTeX bs
305 contents <- blockListToLaTeX bs
301− wrapDiv attr $ ("\\begin{block}" <> braces title' <> anchor) $$
306+ wrapDiv attr $ ("\\begin" <> braces blockname <> braces title' <> anchor) $$
302− contents $$ "\\end{block}"
307+ contents $$ "\\end" <> braces blockname
303blockToLaTeX (Div (identifier,"slide":dclasses,dkvs)
308blockToLaTeX (Div (identifier,"slide":dclasses,dkvs)
304 (Header _ (_,hclasses,hkvs) ils : bs)) = do
309 (Header _ (_,hclasses,hkvs) ils : bs)) = do
305 -- note: [fragile] is required or verbatim breaks
310 -- note: [fragile] is required or verbatim breaks
test/command/7278.mdnew file+38
@@ -0,0 +1,38 @@
1+```
2+% pandoc -t beamer
3+# Slide
4+
5+Some blocks:
6+
7+## example block title {.example}
8+
9+text in block
10+
11+## alert block title {.alert}
12+
13+text in block
14+
15+## block title
16+
17+text in block
18+^D
19+\begin{frame}{Slide}
20+\protect\hypertarget{slide}{}
21+Some blocks:
22+
23+\begin{exampleblock}{example block title}
24+\protect\hypertarget{example-block-title}{}
25+text in block
26+\end{exampleblock}
27+
28+\begin{alertblock}{alert block title}
29+\protect\hypertarget{alert-block-title}{}
30+text in block
31+\end{alertblock}
32+
33+\begin{block}{block title}
34+\protect\hypertarget{block-title}{}
35+text in block
36+\end{block}
37+\end{frame}
38+```