Preliminary support for HTML5.
+ Added writerHtml5 writer option. + Added --html5 option. + Added support for lang in html tag (so you can do 'pandoc -s --V lang=en', for example). + Updated html template with conditionals for HTML5. + When HTML5 selected, use <header> tag around title in document, and use <section> tags instead of <div>s if --section-divs specified.
This commit is contained in:
parent
6b1407d209
commit
e8ad4ba43c
5 changed files with 45 additions and 8 deletions
16
README
16
README
|
@ -208,6 +208,10 @@ Options
|
|||
`markdown` or `textile`. It is selected automatically when the input
|
||||
format is `textile` or the output format is `latex` or `context`.)
|
||||
|
||||
`-5`, `--html5`
|
||||
: Produce HTML5 instead of HTML4. This option has no effect for writers
|
||||
other than `html`, `epub`, `s5`, and `slidy`.
|
||||
|
||||
`-m` *URL*, `--latexmathml=`*URL*
|
||||
: Use the [LaTeXMathML] script to display embedded TeX math in HTML output.
|
||||
To insert a link to a local copy of the `LaTeXMathML.js` script,
|
||||
|
@ -262,8 +266,9 @@ Options
|
|||
By default, sections are not numbered.
|
||||
|
||||
`--section-divs`
|
||||
: Wrap sections in `<div>` tags, and attach identifiers to the
|
||||
enclosing `<div>` rather than the header itself.
|
||||
: Wrap sections in `<div>` tags (or `<section>` tags in HTML5),
|
||||
and attach identifiers to the enclosing `<div>` (or `<section>`)
|
||||
rather than the header itself.
|
||||
See [Section identifiers](#header-identifiers-in-html), below.
|
||||
|
||||
`--no-wrap`
|
||||
|
@ -504,6 +509,8 @@ depending on the output format, but include:
|
|||
multiple values)
|
||||
`date`
|
||||
: date of document, as specified in title block
|
||||
`lang`
|
||||
: language code for HTML documents
|
||||
|
||||
Variables may be set at the command line using the `-V/--variable`
|
||||
option. This allows users to include custom variables in their
|
||||
|
@ -1143,8 +1150,9 @@ 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
|
||||
be wrapped in a `div` (or a `section`, if `--html5` was specified),
|
||||
and the identifier will be attached to the enclosing `<div>`
|
||||
(or `<section>`) tag rather than the header itself. This allows entire
|
||||
sections to be manipulated using javascript or treated differently in
|
||||
CSS.
|
||||
|
||||
|
|
|
@ -481,6 +481,7 @@ data WriterOptions = WriterOptions
|
|||
, writerUserDataDir :: Maybe FilePath -- ^ Path of user data directory
|
||||
, writerCiteMethod :: CiteMethod -- ^ How to print cites
|
||||
, writerBiblioFiles :: [FilePath] -- ^ Biblio files to use for citations
|
||||
, writerHtml5 :: Bool -- ^ Produce HTML5
|
||||
} deriving Show
|
||||
|
||||
-- | Default writer options.
|
||||
|
@ -510,6 +511,7 @@ defaultWriterOptions =
|
|||
, writerUserDataDir = Nothing
|
||||
, writerCiteMethod = Citeproc
|
||||
, writerBiblioFiles = []
|
||||
, writerHtml5 = False
|
||||
}
|
||||
|
||||
--
|
||||
|
|
|
@ -170,6 +170,7 @@ inTemplate opts tit auths date toc body' newvars =
|
|||
, ("pagetitle", topTitle')
|
||||
, ("title", renderHtmlFragment tit)
|
||||
, ("date", date') ] ++
|
||||
[ ("html5","true") | writerHtml5 opts ] ++
|
||||
(case toc of
|
||||
Just t -> [ ("toc", renderHtmlFragment t)]
|
||||
Nothing -> []) ++
|
||||
|
@ -226,7 +227,9 @@ elementToHtml opts (Sec level num id' title' elements) = do
|
|||
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
|
||||
then if writerHtml5 opts
|
||||
then tag "section" << stuff
|
||||
else thediv ! [prefixedId opts id'] << stuff
|
||||
else toHtmlFromList stuff
|
||||
|
||||
-- | Convert list of Note blocks to a footnote <div>.
|
||||
|
|
|
@ -102,6 +102,7 @@ data Opt = Opt
|
|||
, optOffline :: Bool -- ^ Make slideshow accessible offline
|
||||
, optXeTeX :: Bool -- ^ Format latex for xetex
|
||||
, optSmart :: Bool -- ^ Use smart typography
|
||||
, optHtml5 :: Bool -- ^ Produce HTML5 in HTML
|
||||
, optHTMLMathMethod :: HTMLMathMethod -- ^ Method to print HTML math
|
||||
, optReferenceODT :: Maybe FilePath -- ^ Path of reference.odt
|
||||
, optEPUBStylesheet :: Maybe String -- ^ EPUB stylesheet
|
||||
|
@ -142,6 +143,7 @@ defaultOpts = Opt
|
|||
, optOffline = False
|
||||
, optXeTeX = False
|
||||
, optSmart = False
|
||||
, optHtml5 = False
|
||||
, optHTMLMathMethod = PlainMath
|
||||
, optReferenceODT = Nothing
|
||||
, optEPUBStylesheet = Nothing
|
||||
|
@ -226,6 +228,11 @@ options =
|
|||
(\opt -> return opt { optSmart = True }))
|
||||
"" -- "Use smart quotes, dashes, and ellipses"
|
||||
|
||||
, Option "5" ["html5"]
|
||||
(NoArg
|
||||
(\opt -> return opt { optHtml5 = True }))
|
||||
"" -- "Produce HTML5 in HTML output"
|
||||
|
||||
, Option "m" ["latexmathml", "asciimathml"]
|
||||
(OptArg
|
||||
(\arg opt ->
|
||||
|
@ -629,6 +636,7 @@ main = do
|
|||
, optOffline = offline
|
||||
, optXeTeX = xetex
|
||||
, optSmart = smart
|
||||
, optHtml5 = html5
|
||||
, optHTMLMathMethod = mathMethod
|
||||
, optReferenceODT = referenceODT
|
||||
, optEPUBStylesheet = epubStylesheet
|
||||
|
@ -771,7 +779,8 @@ main = do
|
|||
else obfuscationMethod,
|
||||
writerIdentifierPrefix = idPrefix,
|
||||
writerSourceDirectory = sourceDir,
|
||||
writerUserDataDir = datadir }
|
||||
writerUserDataDir = datadir,
|
||||
writerHtml5 = html5 }
|
||||
|
||||
when (isNonTextOutput writerName' && outputFile == "-") $
|
||||
do UTF8.hPutStrLn stderr ("Error: Cannot write " ++ writerName ++ " output to stdout.\n" ++
|
||||
|
|
|
@ -1,8 +1,17 @@
|
|||
$if(html5)$
|
||||
<!DOCTYPE html>
|
||||
<html$if(lang)$ lang="$lang$"$endif$>
|
||||
$else$
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml"$if(lang)$ lang="$lang$" xml:lang="$lang$"$endif$>
|
||||
$endif$
|
||||
<head>
|
||||
<title>$if(title-prefix)$$title-prefix$ - $endif$$if(pagetitle)$$pagetitle$$endif$</title>
|
||||
$if(html5)$
|
||||
<meta charset="utf-8" />
|
||||
$else$
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
$endif$
|
||||
<meta name="generator" content="pandoc" />
|
||||
$for(author)$
|
||||
<meta name="author" content="$author$" />
|
||||
|
@ -16,7 +25,7 @@ $highlighting-css$
|
|||
</style>
|
||||
$endif$
|
||||
$for(css)$
|
||||
<link rel="stylesheet" href="$css$" type="text/css" />
|
||||
<link rel="stylesheet" href="$css$" $if(html5)$$else$type="text/css" $endif$/>
|
||||
$endfor$
|
||||
$if(math)$
|
||||
$math$
|
||||
|
@ -30,7 +39,13 @@ $for(include-before)$
|
|||
$include-before$
|
||||
$endfor$
|
||||
$if(title)$
|
||||
$if(html5)$
|
||||
<header>
|
||||
$endif$
|
||||
<h1 class="title">$title$</h1>
|
||||
$if(html5)$
|
||||
</header>
|
||||
$endif$
|
||||
$endif$
|
||||
$if(toc)$
|
||||
$toc$
|
||||
|
|
Loading…
Add table
Reference in a new issue