@@ -170,6 +170,7 @@ inTemplate opts tit auths date toc body' newvars =
170170 , ("pagetitle", topTitle')
171171 , ("title", renderHtmlFragment tit)
172172 , ("date", date') ] ++
173+ [ ("html5","true") | writerHtml5 opts ] ++
173174 (case toc of
174175 Just t -> [ ("toc", renderHtmlFragment t)]
175176 Nothing -> []) ++
@@ -189,7 +190,12 @@ tableOfContents opts sects = do
189190 let tocList = catMaybes contents
190191 return $ if null tocList
191192 then Nothing
192− else Just $ thediv ! [prefixedId opts' "TOC"] $ unordList tocList
193+ else Just $
194+ if writerHtml5 opts
195+ then tag "nav" ! [prefixedId opts' "TOC"] $
196+ unordList tocList
197+ else thediv ! [prefixedId opts' "TOC"] $
198+ unordList tocList
193199
194200-- | Convert section number to string
195201showSecNum :: [Int] -> String
@@ -226,7 +232,9 @@ elementToHtml opts (Sec level num id' title' elements) = do
226232 return $ if slides -- S5 gets confused by the extra divs around sections
227233 then toHtmlFromList stuff
228234 else if writerSectionDivs opts
229− then thediv ! [prefixedId opts id'] << stuff
235+ then if writerHtml5 opts
236+ then tag "section" << stuff
237+ else thediv ! [prefixedId opts id'] << stuff
230238 else toHtmlFromList stuff
231239
232240-- | Convert list of Note blocks to a footnote <div>.
@@ -296,8 +304,11 @@ blockToHtml opts (Plain lst) = inlineListToHtml opts lst
296304blockToHtml opts (Para [Image txt (s,tit)]) = do
297305 img <- inlineToHtml opts (Image txt (s,tit))
298306 capt <- inlineListToHtml opts txt
299− return $ thediv ! [theclass "figure"] <<
300− [img, paragraph ! [theclass "caption"] << capt]
307+ return $ if writerHtml5 opts
308+ then tag "figure" <<
309+ [img, tag "figcaption" << capt]
310+ else thediv ! [theclass "figure"] <<
311+ [img, paragraph ! [theclass "caption"] << capt]
301312blockToHtml opts (Para lst) = inlineListToHtml opts lst >>= (return . paragraph)
302313blockToHtml _ (RawHtml str) = return $ primHtml str
303314blockToHtml _ (HorizontalRule) = return $ hr
@@ -368,7 +379,17 @@ blockToHtml opts (OrderedList (startnum, numstyle, _) lst) = do
368379 then [start startnum]
369380 else []) ++
370381 (if numstyle /= DefaultStyle
371− then [thestyle $ "list-style-type: " ++ numstyle' ++ ";"]
382+ then if writerHtml5 opts
383+ then [strAttr "type" $
384+ case numstyle of
385+ Decimal -> "1"
386+ LowerAlpha -> "a"
387+ UpperAlpha -> "A"
388+ LowerRoman -> "i"
389+ UpperRoman -> "I"
390+ _ -> "1"]
391+ else [thestyle $ "list-style-type: " ++
392+ numstyle']
372393 else [])
373394 return $ ordList ! attribs $ contents
374395blockToHtml opts (DefinitionList lst) = do
@@ -381,28 +402,30 @@ blockToHtml opts (DefinitionList lst) = do
381402 else []
382403 return $ dlist ! attribs << concat contents
383404blockToHtml opts (Table capt aligns widths headers rows') = do
384− let alignStrings = map alignmentToString aligns
385405 captionDoc <- if null capt
386406 then return noHtml
387407 else inlineListToHtml opts capt >>= return . caption
388408 let percent w = show (truncate (100*w) :: Integer) ++ "%"
409+ let widthAttrs w = if writerHtml5 opts
410+ then [thestyle $ "width: " ++ percent w]
411+ else [width $ percent w]
389412 let coltags = if all (== 0.0) widths
390413 then noHtml
391414 else concatHtml $ map
392− (\w -> col ! [width $ percent w] $ noHtml) widths
415+ (\w -> col ! (widthAttrs w) $ noHtml) widths
393416 head' <- if all null headers
394417 then return noHtml
395− else liftM (thead <<) $ tableRowToHtml opts alignStrings 0 headers
418+ else liftM (thead <<) $ tableRowToHtml opts aligns 0 headers
396419 body' <- liftM (tbody <<) $
397− zipWithM (tableRowToHtml opts alignStrings) [1..] rows'
420+ zipWithM (tableRowToHtml opts aligns) [1..] rows'
398421 return $ table $ captionDoc +++ coltags +++ head' +++ body'
399422
400423tableRowToHtml :: WriterOptions
401− -> [String]
424+ -> [Alignment]
402425 -> Int
403426 -> [[Block]]
404427 -> State WriterState Html
405−tableRowToHtml opts alignStrings rownum cols' = do
428+tableRowToHtml opts aligns rownum cols' = do
406429 let mkcell = if rownum == 0 then th else td
407430 let rowclass = case rownum of
408431 0 -> "header"
@@ -410,7 +433,7 @@ tableRowToHtml opts alignStrings rownum cols' = do
410433 _ -> "even"
411434 cols'' <- sequence $ zipWith
412435 (\alignment item -> tableItemToHtml opts mkcell alignment item)
413− alignStrings cols'
436+ aligns cols'
414437 return $ tr ! [theclass rowclass] $ toHtmlFromList cols''
415438
416439alignmentToString :: Alignment -> [Char]
@@ -422,12 +445,15 @@ alignmentToString alignment = case alignment of
422445
423446tableItemToHtml :: WriterOptions
424447 -> (Html -> Html)
425− -> [Char]
448+ -> Alignment
426449 -> [Block]
427450 -> State WriterState Html
428451tableItemToHtml opts tag' align' item = do
429452 contents <- blockListToHtml opts item
430− return $ tag' ! [align align'] $ contents
453+ let alignAttrs = if writerHtml5 opts
454+ then [thestyle $ "align: " ++ alignmentToString align']
455+ else [align $ alignmentToString align']
456+ return $ tag' ! alignAttrs $ contents
431457
432458blockListToHtml :: WriterOptions -> [Block] -> State WriterState Html
433459blockListToHtml opts lst =