Added --slide-level option to override default.
This allows users to select a slide level below the first header level with content. Note that content under sections above the slide level will not appear in slides (either in beamer or in HTML slide shows). This is primarily useful for creating documents that can be made into both slides and handouts (which contain additional content outside the slides).
This commit is contained in:
parent
2c4a55d160
commit
60bf741d68
6 changed files with 53 additions and 13 deletions
29
README
29
README
|
@ -306,6 +306,15 @@ Options
|
|||
: Produce LaTeX output for the `beamer` document class.
|
||||
This has an effect only for `latex` or `pdf` output.
|
||||
|
||||
`--slide-level`=*NUMBER*
|
||||
: Specifies that headers with the specified level create
|
||||
slides (for `beamer`, `s5`, `slidy`, `dzslides`). Headers
|
||||
above this level in the hierarchy are used to divide the
|
||||
slide show into sections; headers below this level create
|
||||
subheads within a slide. The default is to set the slide level
|
||||
based on the contents of the document; see
|
||||
[Structuring the slide show](#structuring-the-slide-show), below.
|
||||
|
||||
`--section-divs`
|
||||
: Wrap sections in `<div>` tags (or `<section>` tags in HTML5),
|
||||
and attach identifiers to the enclosing `<div>` (or `<section>`)
|
||||
|
@ -2006,20 +2015,24 @@ slide show, including linked scripts, stylesheets, images, and videos.
|
|||
Structuring the slide show
|
||||
--------------------------
|
||||
|
||||
By default, the *slide level* is the highest header level in
|
||||
the hierarchy that is followed immediately by content, and not another
|
||||
header, somewhere in the document. In the example above, level 1 headers
|
||||
are always followed by level 2 headers, which are followed by content,
|
||||
so 2 is the slide level. This default can be overridden using
|
||||
the `--slide-level` option.
|
||||
|
||||
The document is carved up into slides according to the following
|
||||
rules. The *content level* is the the highest header level in the hierarchy
|
||||
that is followed immediately by content, and not another header, somewhere in
|
||||
the document. In the example above, level 1 headers are always followed by
|
||||
level 2 headers, which are followed by content, so 2 is the content level.
|
||||
rules:
|
||||
|
||||
* A horizontal rule always starts a new slide.
|
||||
|
||||
* A header at the content level always starts a new slide.
|
||||
* A header at the slide level always starts a new slide.
|
||||
|
||||
* Headers *below* the content level in the hierarchy create
|
||||
* Headers *below* the slide level in the hierarchy create
|
||||
headers *within* a slide.
|
||||
|
||||
* Headers *above* the content level in the hierarchy create
|
||||
* Headers *above* the slide level in the hierarchy create
|
||||
"title slides," which just contain the section title
|
||||
and help to break the slide show into sections.
|
||||
|
||||
|
@ -2030,7 +2043,7 @@ level 2 headers, which are followed by content, so 2 is the content level.
|
|||
These rules are designed to support many different styles of slide show. If
|
||||
you don't care about structuring your slides into sections and subsections,
|
||||
you can just use level 1 headers for all each slide. (In that case, level 1
|
||||
will be the content level.) But you can also structure the slide show into
|
||||
will be the slide level.) But you can also structure the slide show into
|
||||
sections, as in the example above.
|
||||
|
||||
For Slidy and S5, the file produced by pandoc with the `-s/--standalone`
|
||||
|
|
|
@ -478,6 +478,7 @@ data WriterOptions = WriterOptions
|
|||
, writerBiblioFiles :: [FilePath] -- ^ Biblio files to use for citations
|
||||
, writerHtml5 :: Bool -- ^ Produce HTML5
|
||||
, writerBeamer :: Bool -- ^ Produce beamer LaTeX slide show
|
||||
, writerSlideLevel :: Maybe Int -- ^ Force header level of slides
|
||||
, writerChapters :: Bool -- ^ Use "chapter" for top-level sects
|
||||
, writerListings :: Bool -- ^ Use listings package for code
|
||||
, writerHighlight :: Bool -- ^ Highlight source code
|
||||
|
@ -514,6 +515,7 @@ defaultWriterOptions =
|
|||
, writerBiblioFiles = []
|
||||
, writerHtml5 = False
|
||||
, writerBeamer = False
|
||||
, writerSlideLevel = Nothing
|
||||
, writerChapters = False
|
||||
, writerListings = False
|
||||
, writerHighlight = False
|
||||
|
|
|
@ -115,7 +115,7 @@ pandocToHtml opts (Pandoc (Meta title' authors' date') blocks) = do
|
|||
date <- if standalone
|
||||
then inlineListToHtml opts date'
|
||||
else return mempty
|
||||
let slideLevel = getSlideLevel blocks
|
||||
let slideLevel = maybe (getSlideLevel blocks) id $ writerSlideLevel opts
|
||||
let sects = hierarchicalize $
|
||||
if writerSlideVariant opts == NoSlides
|
||||
then blocks
|
||||
|
@ -252,15 +252,21 @@ elementToHtml slideLevel opts (Sec level num id' title' elements) = do
|
|||
modify $ \st -> st{stSecNum = num} -- update section number
|
||||
-- always use level 1 for slide titles
|
||||
let level' = if slide then 1 else level
|
||||
let titleSlide = slide && level < slideLevel
|
||||
header' <- blockToHtml opts (Header level' title')
|
||||
innerContents <- mapM (elementToHtml slideLevel opts) elements
|
||||
let isSec (Sec _ _ _ _ _) = True
|
||||
isSec (Blk _) = False
|
||||
innerContents <- mapM (elementToHtml slideLevel opts)
|
||||
$ if titleSlide
|
||||
-- title slides have no content of their own
|
||||
then filter isSec elements
|
||||
else elements
|
||||
let header'' = if (writerStrictMarkdown opts ||
|
||||
writerSectionDivs opts ||
|
||||
writerSlideVariant opts == S5Slides)
|
||||
then header'
|
||||
else header' ! prefixedId opts id'
|
||||
let inNl x = mconcat $ nl opts : intersperse (nl opts) x ++ [nl opts]
|
||||
let titleSlide = slide && level < slideLevel
|
||||
let classes = ["titleslide" | titleSlide] ++ ["slide" | slide] ++
|
||||
["level" ++ show level]
|
||||
let secttag = if writerHtml5 opts
|
||||
|
|
|
@ -201,7 +201,8 @@ inCmd cmd contents = char '\\' <> text cmd <> braces contents
|
|||
|
||||
toSlides :: [Block] -> State WriterState [Block]
|
||||
toSlides bs = do
|
||||
let slideLevel = getSlideLevel bs
|
||||
opts <- gets stOptions
|
||||
let slideLevel = maybe (getSlideLevel bs) id $ writerSlideLevel opts
|
||||
let bs' = prepSlides slideLevel bs
|
||||
concat `fmap` (mapM (elementToBeamer slideLevel) $ hierarchicalize bs')
|
||||
|
||||
|
@ -214,7 +215,10 @@ elementToBeamer slideLevel (Sec lvl _num _ident tit elts)
|
|||
: tit ++ [RawInline "latex" "}"] )
|
||||
: bs ++ [RawBlock "latex" "\\end{block}"]
|
||||
| lvl < slideLevel = do
|
||||
let isSec (Sec _ _ _ _ _) = True
|
||||
isSec (Blk _) = False
|
||||
bs <- concat `fmap` mapM (elementToBeamer slideLevel) elts
|
||||
-- (filter isSec elts)
|
||||
return $ (Header lvl tit) : bs
|
||||
| otherwise = do -- lvl == slideLevel
|
||||
-- note: [fragile] is required or verbatim breaks
|
||||
|
|
|
@ -131,6 +131,7 @@ data Opt = Opt
|
|||
, optListings :: Bool -- ^ Use listings package for code blocks
|
||||
, optLaTeXEngine :: String -- ^ Program to use for latex -> pdf
|
||||
, optBeamer :: Bool -- ^ Produce latex output for beamer class
|
||||
, optSlideLevel :: Maybe Int -- ^ Header level that creates slides
|
||||
}
|
||||
|
||||
-- | Defaults for command-line options.
|
||||
|
@ -180,6 +181,7 @@ defaultOpts = Opt
|
|||
, optListings = False
|
||||
, optLaTeXEngine = "pdflatex"
|
||||
, optBeamer = False
|
||||
, optSlideLevel = Nothing
|
||||
}
|
||||
|
||||
-- | A list of functions, each transforming the options data structure
|
||||
|
@ -381,6 +383,17 @@ options =
|
|||
(\opt -> return opt { optBeamer = True }))
|
||||
"" -- "Produce latex output for beamer class"
|
||||
|
||||
, Option "" ["slide-level"]
|
||||
(ReqArg
|
||||
(\arg opt -> do
|
||||
case reads arg of
|
||||
[(t,"")] | t >= 1 && t <= 6 ->
|
||||
return opt { optSlideLevel = Just t }
|
||||
_ -> err 39 $
|
||||
"slide level must be a number between 1 and 6")
|
||||
"NUMBER")
|
||||
"" -- "Force header level for slides"
|
||||
|
||||
, Option "" ["section-divs"]
|
||||
(NoArg
|
||||
(\opt -> return opt { optSectionDivs = True }))
|
||||
|
@ -795,6 +808,7 @@ main = do
|
|||
, optListings = listings
|
||||
, optLaTeXEngine = latexEngine
|
||||
, optBeamer = beamer
|
||||
, optSlideLevel = slideLevel
|
||||
} = opts
|
||||
|
||||
when dumpArgs $
|
||||
|
@ -943,6 +957,7 @@ main = do
|
|||
writerChapters = chapters,
|
||||
writerListings = listings,
|
||||
writerBeamer = beamer,
|
||||
writerSlideLevel = slideLevel,
|
||||
writerHighlight = highlight,
|
||||
writerHighlightStyle = highlightStyle }
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit dc936548c2b07617a799611b0968b503614be9f3
|
||||
Subproject commit c6ffb2602f792309509ee72dc283e222e09c71ff
|
Loading…
Add table
Reference in a new issue