@@ -442,54 +442,75 @@ blockToLaTeX :: PandocMonad m
442442 => Block -- ^ Block to convert
443443 -> LW m Doc
444444blockToLaTeX Null = return empty
445−blockToLaTeX (Div (identifier,classes,kvs) bs) = do
446− beamer <- gets stBeamer
447− linkAnchor' <- hypertarget True identifier empty
448− -- see #2704 for the motivation for adding \leavevmode:
449− let linkAnchor =
450− case bs of
451− Para _ : _
452− | not (isEmpty linkAnchor')
453− -> "\\leavevmode" <> linkAnchor' <> "%"
454− _ -> linkAnchor'
455− let align dir txt = inCmd "begin" dir $$ txt $$ inCmd "end" dir
456− lang <- toLang $ lookup "lang" kvs
457− let wrapColumns = if "columns" `elem` classes
458− then \contents ->
459− inCmd "begin" "columns" <> brackets "T"
460− $$ contents
461− $$ inCmd "end" "columns"
462− else id
463− wrapColumn = if "column" `elem` classes
464− then \contents ->
465− let fromPct xs =
466− case reverse xs of
467− '%':ds -> '0':'.': reverse ds
468− _ -> xs
469− w = maybe "0.48" fromPct (lookup "width" kvs)
470− in inCmd "begin" "column" <>
471− braces (text w <> "\\textwidth")
472− $$ contents
473− $$ inCmd "end" "column"
474− else id
475− wrapDir = case lookup "dir" kvs of
476− Just "rtl" -> align "RTL"
477− Just "ltr" -> align "LTR"
478− _ -> id
479− wrapLang txt = case lang of
480− Just lng -> let (l, o) = toPolyglossiaEnv lng
481− ops = if null o
482− then ""
483− else brackets $ text o
484− in inCmd "begin" (text l) <> ops
485− $$ blankline <> txt <> blankline
486− $$ inCmd "end" (text l)
487− Nothing -> txt
488− wrapNotes txt = if beamer && "notes" `elem` classes
445+blockToLaTeX (Div (identifier,classes,kvs) bs)
446+ | "incremental" `elem` classes = do
447+ let classes' = filter ("incremental"/=) classes
448+ beamer <- gets stBeamer
449+ if beamer
450+ then do oldIncremental <- gets stIncremental
451+ modify $ \s -> s{ stIncremental = True }
452+ result <- blockToLaTeX $ Div (identifier,classes',kvs) bs
453+ modify $ \s -> s{ stIncremental = oldIncremental }
454+ return result
455+ else blockToLaTeX $ Div (identifier,classes',kvs) bs
456+ | "nonincremental" `elem` classes = do
457+ let classes' = filter ("nonincremental"/=) classes
458+ beamer <- gets stBeamer
459+ if beamer
460+ then do oldIncremental <- gets stIncremental
461+ modify $ \s -> s{ stIncremental = False }
462+ result <- blockToLaTeX $ Div (identifier,classes',kvs) bs
463+ modify $ \s -> s{ stIncremental = oldIncremental }
464+ return result
465+ else blockToLaTeX $ Div (identifier,classes',kvs) bs
466+ | otherwise = do
467+ beamer <- gets stBeamer
468+ linkAnchor' <- hypertarget True identifier empty
469+ -- see #2704 for the motivation for adding \leavevmode:
470+ let linkAnchor =
471+ case bs of
472+ Para _ : _
473+ | not (isEmpty linkAnchor')
474+ -> "\\leavevmode" <> linkAnchor' <> "%"
475+ _ -> linkAnchor'
476+ let align dir txt = inCmd "begin" dir $$ txt $$ inCmd "end" dir
477+ lang <- toLang $ lookup "lang" kvs
478+ let wrapColumns = if "columns" `elem` classes
479+ then \contents ->
480+ inCmd "begin" "columns" <> brackets "T"
481+ $$ contents
482+ $$ inCmd "end" "columns"
483+ else id
484+ wrapColumn = if "column" `elem` classes
485+ then \contents ->
486+ let fromPct xs =
487+ case reverse xs of
488+ '%':ds -> '0':'.': reverse ds
489+ _ -> xs
490+ w = maybe "0.48" fromPct (lookup "width" kvs)
491+ in inCmd "begin" "column" <>
492+ braces (text w <> "\\textwidth")
493+ $$ contents
494+ $$ inCmd "end" "column"
495+ else id
496+ wrapDir = case lookup "dir" kvs of
497+ Just "rtl" -> align "RTL"
498+ Just "ltr" -> align "LTR"
499+ _ -> id
500+ wrapLang txt = case lang of
501+ Just lng -> let (l, o) = toPolyglossiaEnv lng
502+ ops = if null o
503+ then ""
504+ else brackets $ text o
505+ in inCmd "begin" (text l) <> ops
506+ $$ blankline <> txt <> blankline
507+ $$ inCmd "end" (text l)
508+ Nothing -> txt
509+ wrapNotes txt = if beamer && "notes" `elem` classes
489510 then "\\note" <> braces txt -- speaker notes
490511 else linkAnchor $$ txt
491− (wrapColumns . wrapColumn . wrapDir . wrapLang . wrapNotes)
492− <$> blockListToLaTeX bs
512+ (wrapColumns . wrapColumn . wrapDir . wrapLang . wrapNotes)
513+ <$> blockListToLaTeX bs
493514blockToLaTeX (Plain lst) =
494515 inlineListToLaTeX $ dropWhile isLineBreakOrSpace lst
495516-- title beginning with fig: indicates that the image is a figure