Added --section-divs option.
+ Header identifiers now get attached to the headers, unless --section-divs is specified, in which case they are added to enclosing divs. By default, the divs are not added. + Resolves Issue #230, #239.
This commit is contained in:
parent
57a91f3b6a
commit
9be9bccfcf
8 changed files with 1039 additions and 1082 deletions
11
README
11
README
|
@ -400,6 +400,11 @@ For further documentation, see the `pandoc(1)` man page.
|
|||
: causes sections to be numbered in LaTeX, ConTeXt, or HTML output.
|
||||
By default, sections are not numbered.
|
||||
|
||||
`--section-divs`
|
||||
: causes sections to be wrapped in `<div>` tags. In this case,
|
||||
[section identifiers](#header-identifiers-in-html)
|
||||
are attached to the enclosing `<div>` rather than the header itself.
|
||||
|
||||
`--no-wrap`
|
||||
: disables text-wrapping in output. By default, text is wrapped
|
||||
appropriately for the output format.
|
||||
|
@ -1170,6 +1175,12 @@ another. A link to this section, for example, might look like this:
|
|||
Note, however, that this method of providing links to sections works
|
||||
only in HTML.
|
||||
|
||||
If the `--section-divs` option is specified, then each section will
|
||||
be wrapped in a `div`, and the identifier will be attached to the
|
||||
enclosing `<div>` tag rather than the header itself. This allows entire
|
||||
sections to be manipulated using javascript or treated differently in
|
||||
CSS.
|
||||
|
||||
Blank lines before headers and blockquotes
|
||||
------------------------------------------
|
||||
|
||||
|
|
|
@ -151,6 +151,10 @@ should pipe input and output through `iconv`:
|
|||
: Number section headings in LaTeX, ConTeXt, or HTML output.
|
||||
(Default is not to number them.)
|
||||
|
||||
\--section-divs
|
||||
: Wrap sections in `<div>` tags, and attach identifiers to the
|
||||
enclosing `<div>` rather than the header itself.
|
||||
|
||||
\--no-wrap
|
||||
: Disable text wrapping in output. (Default is to wrap text.)
|
||||
|
||||
|
|
|
@ -487,6 +487,7 @@ data WriterOptions = WriterOptions
|
|||
, writerHTMLMathMethod :: HTMLMathMethod -- ^ How to print math in HTML
|
||||
, writerIgnoreNotes :: Bool -- ^ Ignore footnotes (used in making toc)
|
||||
, writerNumberSections :: Bool -- ^ Number sections in LaTeX
|
||||
, writerSectionDivs :: Bool -- ^ Put sections in div tags in HTML
|
||||
, writerStrictMarkdown :: Bool -- ^ Use strict markdown syntax
|
||||
, writerReferenceLinks :: Bool -- ^ Use reference links in writing markdown, rst
|
||||
, writerWrapText :: Bool -- ^ Wrap text to line length
|
||||
|
@ -512,6 +513,7 @@ defaultWriterOptions =
|
|||
, writerHTMLMathMethod = PlainMath
|
||||
, writerIgnoreNotes = False
|
||||
, writerNumberSections = False
|
||||
, writerSectionDivs = True
|
||||
, writerStrictMarkdown = False
|
||||
, writerReferenceLinks = False
|
||||
, writerWrapText = True
|
||||
|
|
|
@ -208,15 +208,16 @@ elementToHtml opts (Sec level num id' title' elements) = do
|
|||
innerContents <- mapM (elementToHtml opts) elements
|
||||
modify $ \st -> st{stSecNum = num} -- update section number
|
||||
header' <- blockToHtml opts (Header level title')
|
||||
let stuff = header' : innerContents
|
||||
return $ case writerSlideVariant opts of
|
||||
SlidySlides -> toHtmlFromList stuff
|
||||
S5Slides -> toHtmlFromList stuff
|
||||
-- S5 gets confused by the extra divs around sections
|
||||
_ | (writerStrictMarkdown opts &&
|
||||
not (writerTableOfContents opts)) ->
|
||||
toHtmlFromList stuff
|
||||
_ -> thediv ! [prefixedId opts id'] << stuff
|
||||
let slides = writerSlideVariant opts `elem` [SlidySlides, S5Slides]
|
||||
let header'' = header' ! [prefixedId opts id' |
|
||||
not (writerStrictMarkdown opts ||
|
||||
writerSectionDivs opts || slides)]
|
||||
let stuff = header'' : innerContents
|
||||
return $ if slides -- S5 gets confused by the extra divs around sections
|
||||
then toHtmlFromList stuff
|
||||
else if writerSectionDivs opts
|
||||
then thediv ! [prefixedId opts id'] << stuff
|
||||
else toHtmlFromList stuff
|
||||
|
||||
-- | Convert list of Note blocks to a footnote <div>.
|
||||
-- Assumes notes are sorted.
|
||||
|
|
|
@ -142,6 +142,7 @@ data Opt = Opt
|
|||
, optVariables :: [(String,String)] -- ^ Template variables to set
|
||||
, optOutputFile :: String -- ^ Name of output file
|
||||
, optNumberSections :: Bool -- ^ Number sections in LaTeX
|
||||
, optSectionDivs :: Bool -- ^ Put sections in div tags in HTML
|
||||
, optIncremental :: Bool -- ^ Use incremental lists in Slidy/S5
|
||||
, optXeTeX :: Bool -- ^ Format latex for xetex
|
||||
, optSmart :: Bool -- ^ Use smart typography
|
||||
|
@ -182,6 +183,7 @@ defaultOpts = Opt
|
|||
, optVariables = []
|
||||
, optOutputFile = "-" -- "-" means stdout
|
||||
, optNumberSections = False
|
||||
, optSectionDivs = False
|
||||
, optIncremental = False
|
||||
, optXeTeX = False
|
||||
, optSmart = False
|
||||
|
@ -325,6 +327,11 @@ options =
|
|||
(\opt -> return opt { optNumberSections = True }))
|
||||
"" -- "Number sections in LaTeX"
|
||||
|
||||
, Option "" ["section-divs"]
|
||||
(NoArg
|
||||
(\opt -> return opt { optSectionDivs = True }))
|
||||
"" -- "Put sections in div tags in HTML"
|
||||
|
||||
, Option "" ["no-wrap"]
|
||||
(NoArg
|
||||
(\opt -> return opt { optWrapText = False }))
|
||||
|
@ -643,6 +650,7 @@ main = do
|
|||
, optTemplate = template
|
||||
, optOutputFile = outputFile
|
||||
, optNumberSections = numberSections
|
||||
, optSectionDivs = sectionDivs
|
||||
, optIncremental = incremental
|
||||
, optXeTeX = xetex
|
||||
, optSmart = smart
|
||||
|
@ -782,6 +790,7 @@ main = do
|
|||
writerXeTeX = xetex,
|
||||
writerIgnoreNotes = False,
|
||||
writerNumberSections = numberSections,
|
||||
writerSectionDivs = sectionDivs,
|
||||
writerStrictMarkdown = strict,
|
||||
writerReferenceLinks = referenceLinks,
|
||||
writerWrapText = wrap,
|
||||
|
|
|
@ -1,21 +1,17 @@
|
|||
<div id="first-slide"
|
||||
><h1
|
||||
>First slide</h1
|
||||
><ul
|
||||
<h1 id="first-slide"
|
||||
>First slide</h1
|
||||
><ul
|
||||
><li
|
||||
>first bullet</li
|
||||
><li
|
||||
>first bullet</li
|
||||
><li
|
||||
>second bullet</li
|
||||
></ul
|
||||
></div
|
||||
><div id="math"
|
||||
><h1
|
||||
>Math</h1
|
||||
><ul
|
||||
><li
|
||||
><span class="math"
|
||||
>$\frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}$</span
|
||||
></li
|
||||
></ul
|
||||
></div
|
||||
>second bullet</li
|
||||
></ul
|
||||
><h1 id="math"
|
||||
>Math</h1
|
||||
><ul
|
||||
><li
|
||||
><span class="math"
|
||||
>$\frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}$</span
|
||||
></li
|
||||
></ul
|
||||
>
|
||||
|
|
|
@ -13,26 +13,22 @@
|
|||
<body>
|
||||
STUFF INSERTED
|
||||
<h1 class="title">My S5 Document</h1>
|
||||
<div id="first-slide"
|
||||
><h1
|
||||
>First slide</h1
|
||||
><ul
|
||||
<h1 id="first-slide"
|
||||
>First slide</h1
|
||||
><ul
|
||||
><li
|
||||
>first bullet</li
|
||||
><li
|
||||
>first bullet</li
|
||||
><li
|
||||
>second bullet</li
|
||||
></ul
|
||||
></div
|
||||
><div id="math"
|
||||
><h1
|
||||
>Math</h1
|
||||
><ul
|
||||
><li
|
||||
><span class="math"
|
||||
>$\frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}$</span
|
||||
></li
|
||||
></ul
|
||||
></div
|
||||
>second bullet</li
|
||||
></ul
|
||||
><h1 id="math"
|
||||
>Math</h1
|
||||
><ul
|
||||
><li
|
||||
><span class="math"
|
||||
>$\frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}$</span
|
||||
></li
|
||||
></ul
|
||||
>
|
||||
STUFF INSERTED
|
||||
</body>
|
||||
|
|
2008
tests/writer.html
2008
tests/writer.html
File diff suppressed because it is too large
Load diff
Loading…
Add table
Reference in a new issue