@@ -72,7 +72,7 @@ import qualified Text.Pandoc.Shared as Shared -- so we don't overlap "Element"
7272import Text.Pandoc.Writers.Shared (metaValueToInlines)
7373import qualified Data.Map as M
7474import qualified Data.Set as S
75−import Data.Maybe (maybeToList)
75+import Data.Maybe (maybeToList, fromMaybe)
7676import Text.Pandoc.Highlighting
7777import qualified Data.Text as T
7878import Control.Applicative ((<|>))
@@ -136,7 +136,7 @@ reservedSlideIds = S.fromList [ metadataSlideId
136136
137137uniqueSlideId' :: Integer -> S.Set SlideId -> String -> SlideId
138138uniqueSlideId' n idSet s =
139− let s' = if n == 0 then s else (s ++ "-" ++ show n)
139+ let s' = if n == 0 then s else s ++ "-" ++ show n
140140 in if SlideId s' `S.member` idSet
141141 then uniqueSlideId' (n+1) idSet s
142142 else SlideId s'
@@ -152,7 +152,7 @@ runUniqueSlideId s = do
152152 return sldId
153153
154154addLogMessage :: LogMessage -> Pres ()
155−addLogMessage msg = modify $ \st -> st{stLog = msg : (stLog st)}
155+addLogMessage msg = modify $ \st -> st{stLog = msg : stLog st}
156156
157157type Pres = ReaderT WriterEnv (State WriterState)
158158
@@ -180,7 +180,7 @@ data DocProps = DocProps { dcTitle :: Maybe String
180180
181181data Slide = Slide { slideId :: SlideId
182182 , slideLayout :: Layout
183− , slideNotes :: (Maybe Notes)
183+ , slideNotes :: Maybe Notes
184184 } deriving (Show, Eq)
185185
186186newtype SlideId = SlideId String
@@ -345,12 +345,12 @@ inlineToParElems (SmallCaps ils) =
345345inlineToParElems Space = inlineToParElems (Str " ")
346346inlineToParElems SoftBreak = inlineToParElems (Str " ")
347347inlineToParElems LineBreak = return [Break]
348−inlineToParElems (Link _ ils (url, title)) = do
348+inlineToParElems (Link _ ils (url, title)) =
349349 local (\r ->r{envRunProps = (envRunProps r){rLink = Just $ ExternalTarget (url, title)}}) $
350− inlinesToParElems ils
351−inlineToParElems (Code _ str) = do
350+ inlinesToParElems ils
351+inlineToParElems (Code _ str) =
352352 local (\r ->r{envRunProps = (envRunProps r){rPropCode = True}}) $
353− inlineToParElems $ Str str
353+ inlineToParElems $ Str str
354354inlineToParElems (Math mathtype str) =
355355 return [MathElem mathtype (TeXString str)]
356356inlineToParElems (Note blks) = do
@@ -409,7 +409,7 @@ blockToParagraphs (CodeBlock attr str) =
409409 Just sty ->
410410 case highlight synMap (formatSourceLines sty) attr str of
411411 Right pElems -> do pProps <- asks envParaProps
412− return $ [Paragraph pProps pElems]
412+ return [Paragraph pProps pElems]
413413 Left _ -> blockToParagraphs $ Para [Str str]
414414 Nothing -> blockToParagraphs $ Para [Str str]
415415-- We can't yet do incremental lists, but we should render a
@@ -463,7 +463,7 @@ blockToParagraphs (DefinitionList entries) = do
463463 definition <- concatMapM (blockToParagraphs . BlockQuote) blksLst
464464 return $ term ++ definition
465465 concatMapM go entries
466−blockToParagraphs (Div (_, ("notes" : []), _) _) = return []
466+blockToParagraphs (Div (_, "notes" : [], _) _) = return []
467467blockToParagraphs (Div _ blks) = concatMapM blockToParagraphs blks
468468blockToParagraphs blk = do
469469 addLogMessage $ BlockNotRendered blk
@@ -481,7 +481,7 @@ multiParBullet (b:bs) = do
481481
482482cellToParagraphs :: Alignment -> TableCell -> Pres [Paragraph]
483483cellToParagraphs algn tblCell = do
484− paras <- mapM (blockToParagraphs) tblCell
484+ paras <- mapM blockToParagraphs tblCell
485485 let alignment = case algn of
486486 AlignLeft -> Just AlgnLeft
487487 AlignRight -> Just AlgnRight
@@ -494,7 +494,7 @@ rowToParagraphs :: [Alignment] -> [TableCell] -> Pres [[Paragraph]]
494494rowToParagraphs algns tblCells = do
495495 -- We have to make sure we have the right number of alignments
496496 let pairs = zip (algns ++ repeat AlignDefault) tblCells
497− mapM (\(a, tc) -> cellToParagraphs a tc) pairs
497+ mapM (uncurry cellToParagraphs) pairs
498498
499499withAttr :: Attr -> Shape -> Shape
500500withAttr attr (Pic picPr url caption) =
@@ -507,17 +507,17 @@ withAttr _ sp = sp
507507
508508blockToShape :: Block -> Pres Shape
509509blockToShape (Plain (il:_)) | Image attr ils (url, _) <- il =
510− (withAttr attr . Pic def url) <$> (inlinesToParElems ils)
510+ (withAttr attr . Pic def url) <$> inlinesToParElems ils
511511blockToShape (Para (il:_)) | Image attr ils (url, _) <- il =
512− (withAttr attr . Pic def url) <$> (inlinesToParElems ils)
512+ (withAttr attr . Pic def url) <$> inlinesToParElems ils
513513blockToShape (Plain (il:_)) | Link _ (il':_) target <- il
514514 , Image attr ils (url, _) <- il' =
515515 (withAttr attr . Pic def {picPropLink = Just $ ExternalTarget target} url) <$>
516− (inlinesToParElems ils)
516+ inlinesToParElems ils
517517blockToShape (Para (il:_)) | Link _ (il':_) target <- il
518518 , Image attr ils (url, _) <- il' =
519519 (withAttr attr . Pic def{picPropLink = Just $ ExternalTarget target} url) <$>
520− (inlinesToParElems ils)
520+ inlinesToParElems ils
521521blockToShape (Table caption algn _ hdrCells rows) = do
522522 caption' <- inlinesToParElems caption
523523 hdrCells' <- rowToParagraphs algn hdrCells
@@ -537,11 +537,11 @@ blockToShape blk = do paras <- blockToParagraphs blk
537537
538538combineShapes :: [Shape] -> [Shape]
539539combineShapes [] = []
540−combineShapes (s : []) = [s]
541−combineShapes (pic@(Pic _ _ _) : ss) = pic : combineShapes ss
542−combineShapes ((TextBox []) : ss) = combineShapes ss
540+combineShapes[s] = [s]
541+combineShapes (pic@(Pic{}) : ss) = pic : combineShapes ss
542+combineShapes (TextBox [] : ss) = combineShapes ss
543543combineShapes (s : TextBox [] : ss) = combineShapes (s : ss)
544−combineShapes ((TextBox (p:ps)) : (TextBox (p':ps')) : ss) =
544+combineShapes (TextBox (p:ps) : TextBox (p':ps') : ss) =
545545 combineShapes $ TextBox ((p:ps) ++ (p':ps')) : ss
546546combineShapes (s:ss) = s : combineShapes ss
547547
@@ -549,8 +549,8 @@ blocksToShapes :: [Block] -> Pres [Shape]
549549blocksToShapes blks = combineShapes <$> mapM blockToShape blks
550550
551551isImage :: Inline -> Bool
552−isImage (Image _ _ _) = True
553−isImage (Link _ ((Image _ _ _) : _) _) = True
552+isImage (Image{}) = True
553+isImage (Link _ (Image _ _ _ : _) _) = True
554554isImage _ = False
555555
556556splitBlocks' :: [Block] -> [[Block]] -> [Block] -> Pres [[Block]]
@@ -565,27 +565,27 @@ splitBlocks' cur acc (h@(Header n _ _) : blks) = do
565565 GT -> splitBlocks' (cur ++ [h]) acc blks
566566-- `blockToParagraphs` treats Plain and Para the same, so we can save
567567-- some code duplication by treating them the same here.
568−splitBlocks' cur acc ((Plain ils) : blks) = splitBlocks' cur acc ((Para ils) : blks)
569−splitBlocks' cur acc ((Para (il:ils)) : blks) | isImage il = do
568+splitBlocks' cur acc (Plain ils : blks) = splitBlocks' cur acc (Para ils : blks)
569+splitBlocks' cur acc (Para (il:ils) : blks) | isImage il = do
570570 slideLevel <- asks envSlideLevel
571571 case cur of
572− (Header n _ _) : [] | n == slideLevel ->
572+ [(Header n _ _)] | n == slideLevel ->
573573 splitBlocks' []
574574 (acc ++ [cur ++ [Para [il]]])
575− (if null ils then blks else (Para ils) : blks)
575+ (if null ils then blks else Para ils : blks)
576576 _ -> splitBlocks' []
577577 (acc ++ (if null cur then [] else [cur]) ++ [[Para [il]]])
578− (if null ils then blks else (Para ils) : blks)
579−splitBlocks' cur acc (tbl@(Table _ _ _ _ _) : blks) = do
578+ (if null ils then blks else Para ils : blks)
579+splitBlocks' cur acc (tbl@(Table{}) : blks) = do
580580 slideLevel <- asks envSlideLevel
581581 case cur of
582− (Header n _ _) : [] | n == slideLevel ->
582+ [(Header n _ _)] | n == slideLevel ->
583583 splitBlocks' [] (acc ++ [cur ++ [tbl]]) blks
584584 _ -> splitBlocks' [] (acc ++ (if null cur then [] else [cur]) ++ [[tbl]]) blks
585585splitBlocks' cur acc (d@(Div (_, classes, _) _): blks) | "columns" `elem` classes = do
586586 slideLevel <- asks envSlideLevel
587587 case cur of
588− (Header n _ _) : [] | n == slideLevel ->
588+ [(Header n _ _)] | n == slideLevel ->
589589 splitBlocks' [] (acc ++ [cur ++ [d]]) blks
590590 _ -> splitBlocks' [] (acc ++ (if null cur then [] else [cur]) ++ [[d]]) blks
591591splitBlocks' cur acc (blk : blks) = splitBlocks' (cur ++ [blk]) acc blks
@@ -594,12 +594,12 @@ splitBlocks :: [Block] -> Pres [[Block]]
594594splitBlocks = splitBlocks' [] []
595595
596596blocksToSlide' :: Int -> [Block] -> Pres Slide
597−blocksToSlide' lvl ((Header n (ident, _, _) ils) : blks)
597+blocksToSlide' lvl (Header n (ident, _, _) ils : blks)
598598 | n < lvl = do
599599 registerAnchorId ident
600600 sldId <- asks envCurSlideId
601601 hdr <- inlinesToParElems ils
602− return $ Slide sldId (TitleSlide {titleSlideHeader = hdr}) Nothing
602+ return $ Slide sldId TitleSlide {titleSlideHeader = hdr} Nothing
603603 | n == lvl = do
604604 registerAnchorId ident
605605 hdr <- inlinesToParElems ils
@@ -614,7 +614,7 @@ blocksToSlide' lvl ((Header n (ident, _, _) ils) : blks)
614614blocksToSlide' _ (blk : blks)
615615 | Div (_, classes, _) divBlks <- blk
616616 , "columns" `elem` classes
617− , (Div (_, clsL, _) blksL) : (Div (_, clsR, _) blksR) : remaining <- divBlks
617+ , Div (_, clsL, _) blksL : Div (_, clsR, _) blksR : remaining <- divBlks
618618 , "column" `elem` clsL, "column" `elem` clsR = do
619619 unless (null blks)
620620 (mapM (addLogMessage . BlockNotRendered) blks >> return ())
@@ -672,7 +672,7 @@ makeNoteEntry n blks =
672672 in
673673 case blks of
674674 (Para ils : blks') -> (Para $ enum : Space : ils) : blks'
675− _ -> (Para [enum]) : blks
675+ _ -> Para [enum] : blks
676676
677677forceFontSize :: Pixels -> Pres a -> Pres a
678678forceFontSize px x = do
@@ -860,7 +860,7 @@ blocksToPresentationSlides blks = do
860860 (\env -> env { envCurSlideId = endNotesSlideId
861861 , envInNoteSlide = True
862862 })
863− (blocksToSlide $ endNotesSlideBlocks)
863+ (blocksToSlide endNotesSlideBlocks)
864864 return [endNotesSlide]
865865
866866 let slides = metadataslides ++ tocSlides ++ bodyslides ++ endNotesSlides
@@ -889,9 +889,7 @@ documentToPresentation :: WriterOptions
889889documentToPresentation opts (Pandoc meta blks) =
890890 let env = def { envOpts = opts
891891 , envMetadata = meta
892− , envSlideLevel = case writerSlideLevel opts of
893− Just lvl -> lvl
894− Nothing -> getSlideLevel blks
892+ , envSlideLevel = fromMaybe (getSlideLevel blks) (writerSlideLevel opts)
895893 }
896894 (presSlides, msgs) = runPres env def $ blocksToPresentationSlides blks
897895 docProps = metaToDocProps meta