aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README29
-rw-r--r--src/Text/Pandoc/Shared.hs2
-rw-r--r--src/Text/Pandoc/Writers/HTML.hs12
-rw-r--r--src/Text/Pandoc/Writers/LaTeX.hs6
-rw-r--r--src/pandoc.hs15
m---------templates12
6 files changed, 57 insertions, 19 deletions
diff --git a/README b/README
index 2034783f0..eab0f1bcb 100644
--- a/README
+++ b/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`
diff --git a/src/Text/Pandoc/Shared.hs b/src/Text/Pandoc/Shared.hs
index ba007f5e4..8a4850ed3 100644
--- a/src/Text/Pandoc/Shared.hs
+++ b/src/Text/Pandoc/Shared.hs
@@ -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
diff --git a/src/Text/Pandoc/Writers/HTML.hs b/src/Text/Pandoc/Writers/HTML.hs
index adf59ae4d..5530247a2 100644
--- a/src/Text/Pandoc/Writers/HTML.hs
+++ b/src/Text/Pandoc/Writers/HTML.hs
@@ -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
diff --git a/src/Text/Pandoc/Writers/LaTeX.hs b/src/Text/Pandoc/Writers/LaTeX.hs
index bf1ad91d9..140ef171d 100644
--- a/src/Text/Pandoc/Writers/LaTeX.hs
+++ b/src/Text/Pandoc/Writers/LaTeX.hs
@@ -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
diff --git a/src/pandoc.hs b/src/pandoc.hs
index fac615a8d..08b5dec57 100644
--- a/src/pandoc.hs
+++ b/src/pandoc.hs
@@ -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 }
diff --git a/templates b/templates
-Subproject dc936548c2b07617a799611b0968b503614be9f
+Subproject c6ffb2602f792309509ee72dc283e222e09c71f