git.iko.soy/typeable/pandoc
on master help sign in
Special-case .stretch class for images in reveal.js.
4739620John MacFarlane
MANUAL.txt+4
@@ -3072,6 +3072,10 @@ nonbreaking space after the image:
3072
3072
3073 ![This image won't be a figure](/url/of/image.png)\
3073 ![This image won't be a figure](/url/of/image.png)\
3074
3074
3075+Note that in reveal.js slide shows, an image in a paragraph
3076+by itself that has the `stretch` class will fill the screen,
3077+and the caption and figure tags will be omitted.
3078+
3075#### Extension: `link_attributes` ####
3079#### Extension: `link_attributes` ####
3076
3080
3077Attributes can be set on links and images:
3081Attributes can be set on links and images:
src/Text/Pandoc/Writers/HTML.hs+21−6
@@ -533,12 +533,10 @@ treatAsImage fp =
533 ext = map toLower $ drop 1 $ takeExtension path
533 ext = map toLower $ drop 1 $ takeExtension path
534 in null ext || ext `elem` imageExts
534 in null ext || ext `elem` imageExts
535
535
536−-- | Convert Pandoc block element to HTML.
536+figure :: PandocMonad m
537+ => WriterOptions -> Attr -> [Inline] -> (String, String)
537−blockToHtml :: PandocMonad m => WriterOptions -> Block -> StateT WriterState m Html
538+ -> StateT WriterState m Html
538−blockToHtml _ Null = return mempty
539−blockToHtml opts (Plain lst) = inlineListToHtml opts lst
540−-- title beginning with fig: indicates that the image is a figure
541−blockToHtml opts (Para [Image attr txt (s,'f':'i':'g':':':tit)]) = do
539+figure opts attr txt (s,tit) = do
542 img <- inlineToHtml opts (Image attr txt (s,tit))
540 img <- inlineToHtml opts (Image attr txt (s,tit))
543 html5 <- gets stHtml5
541 html5 <- gets stHtml5
544 let tocapt = if html5
542 let tocapt = if html5
@@ -552,6 +550,23 @@ blockToHtml opts (Para [Image attr txt (s,'f':'i':'g':':':tit)]) = do
552 [nl opts, img, capt, nl opts]
550 [nl opts, img, capt, nl opts]
553 else H.div ! A.class_ "figure" $ mconcat
551 else H.div ! A.class_ "figure" $ mconcat
554 [nl opts, img, nl opts, capt, nl opts]
552 [nl opts, img, nl opts, capt, nl opts]
553+
554+-- | Convert Pandoc block element to HTML.
555+blockToHtml :: PandocMonad m => WriterOptions -> Block -> StateT WriterState m Html
556+blockToHtml _ Null = return mempty
557+blockToHtml opts (Plain lst) = inlineListToHtml opts lst
558+blockToHtml opts (Para [Image attr@(_,classes,_) txt (src,tit)])
559+ | "stretch" `elem` classes = do
560+ slideVariant <- gets stSlideVariant
561+ case slideVariant of
562+ RevealJsSlides ->
563+ -- a "stretched" image in reveal.js must be a direct child
564+ -- of the slide container
565+ inlineToHtml opts (Image attr txt (src, tit))
566+ _ -> figure opts attr txt (src, tit)
567+-- title beginning with fig: indicates that the image is a figure
568+blockToHtml opts (Para [Image attr txt (s,'f':'i':'g':':':tit)]) =
569+ figure opts attr txt (s,tit)
555blockToHtml opts (Para lst)
570blockToHtml opts (Para lst)
556 | isEmptyRaw lst = return mempty
571 | isEmptyRaw lst = return mempty
557 | otherwise = do
572 | otherwise = do