2Copyright (C) 2012-2016 John MacFarlane <jgm@berkeley.edu>
4This program is free software; you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation; either version 2 of the License, or
7(at your option) any later version.
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
14You should have received a copy of the GNU General Public License
15along with this program; if not, write to the Free Software
16Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 Module : Text.Pandoc.Slides
21 Copyright : Copyright (C) 2012-2016 John MacFarlane
22 License : GNU GPL, version 2 or above
24 Maintainer : John MacFarlane <jgm@berkeley.edu>
26 Portability : portable
28Utility functions for splitting documents into slides for slide
29show formats (dzslides, revealjs, s5, slidy, slideous, beamer).
31module Text.Pandoc.Slides ( getSlideLevel, prepSlides ) where
32import Text.Pandoc.Definition
34-- | Find level of header that starts slides (defined as the least header
35-- level that occurs before a non-header/non-hrule in the blocks).
36getSlideLevel :: [Block] -> Int
38 where go least (Header n _ _ : x : xs)
39 | n < least && nonHOrHR x = go n xs
40 | otherwise = go least (x:xs)
41 go least (_ : xs) = go least xs
43 nonHOrHR (Header{}) = False
44 nonHOrHR (HorizontalRule) = False
47-- | Prepare a block list to be passed to hierarchicalize.
48prepSlides :: Int -> [Block] -> [Block]
49prepSlides slideLevel = ensureStartWithH . splitHrule . extractRefsHeader
50 where splitHrule (HorizontalRule : Header n attr xs : ys)
51 | n == slideLevel = Header slideLevel attr xs : splitHrule ys
52 splitHrule (HorizontalRule : xs) = Header slideLevel nullAttr [Str "\0"] :
54 splitHrule (x : xs) = x : splitHrule xs
56 extractRefsHeader bs =
58 (Div ("",["references"],[]) (Header n attrs xs : ys) : zs)
59 -> reverse zs ++ (Header n attrs xs : [Div ("",["references"],[]) ys])
61 ensureStartWithH bs@(Header n _ _:_)
62 | n <= slideLevel = bs
63 ensureStartWithH bs = Header slideLevel nullAttr [Str "\0"] : bs
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list