git.iko.soy/typeable/pandoc
on master help sign in
Provide explicit separate functions for HTML 4 and 5.

* Text.Pandoc.Writers.HTML: removed writeHtml, writeHtmlString, added writeHtml4, writeHtml4String, writeHtml5, writeHtml5String. * Removed writerHtml5 from WriterOptions. * Renamed default.html template to default.html4. * "html" now aliases to "html5"; to get the old HTML4 behavior, you must now specify "-t html4".

commitfce0a60f0a85d6c3a9e7633074ecd781af08c75b authorJohn MacFarlane <jgm@berkeley.edu> dateWed 25 Jan 2017, 21:51 (10 years ago) parent1105dd8
18 files changed+883−96
pandoc.cabal+5−3 pandoc.hs+2−8 src/Text/Pandoc.hs+14−13 src/Text/Pandoc/Options.hs−2 src/Text/Pandoc/Templates.hs+1 src/Text/Pandoc/Writers/CommonMark.hs+2−2 src/Text/Pandoc/Writers/EPUB.hs+6−5 src/Text/Pandoc/Writers/HTML.hs+74−43 src/Text/Pandoc/Writers/Markdown.hs+4−4 src/Text/Pandoc/Writers/OPML.hs+2−2 tests/Tests/Old.hs+4−3 tests/Tests/Writers/HTML.hs+1−1 tests/lhs-test.html+8−5 tests/lhs-test.html+lhs+8−5 tests/tables.html → tests/tables.html4 tests/tables.html5+204 tests/writer.html → tests/writer.html4 tests/writer.html5+548
pandoc.cabal+5−3
@@ -36,7 +36,7 @@ Description: Pandoc is a Haskell library for converting from one markup
3636 only adding a reader or writer.
3737Data-Files:
3838 -- templates
39− data/templates/default.html
39+ data/templates/default.html4
4040 data/templates/default.html5
4141 data/templates/default.docbook
4242 data/templates/default.docbook5
@@ -150,7 +150,8 @@ Extra-Source-Files:
150150 tests/tables.dokuwiki
151151 tests/tables.zimwiki
152152 tests/tables.icml
153− tests/tables.html
153+ tests/tables.html4
154+ tests/tables.html5
154155 tests/tables.latex
155156 tests/tables.man
156157 tests/tables.plain
@@ -172,7 +173,8 @@ Extra-Source-Files:
172173 tests/writer.context
173174 tests/writer.docbook
174175 tests/writer.docbook5
175− tests/writer.html
176+ tests/writer.html4
177+ tests/writer.html5
176178 tests/writer.man
177179 tests/writer.markdown
178180 tests/writer.plain
pandoc.hs+2−8
@@ -111,7 +111,6 @@ convertWithOpts opts args = do
111111 , optSectionDivs = sectionDivs
112112 , optIncremental = incremental
113113 , optSelfContained = selfContained
114− , optHtml5 = html5
115114 , optHtmlQTags = htmlQTags
116115 , optHighlightStyle = highlightStyle
117116 , optTopLevelDivision = topLevelDivision
@@ -188,13 +187,11 @@ convertWithOpts opts args = do
188187 (if any isURI sources
189188 then "html"
190189 else "markdown") sources
191− "html4" -> "html"
192190 x -> x
193191
194192 let writerName' = case map toLower writerName of
195193 [] -> defaultWriterName outputFile
196194 "epub2" -> "epub"
197− "html4" -> "html"
198195 x -> x
199196 let format = takeWhile (`notElem` ['+','-'])
200197 $ takeFileName writerName' -- in case path to lua script
@@ -203,7 +200,7 @@ convertWithOpts opts args = do
203200
204201 let laTeXOutput = format `elem` ["latex", "beamer"]
205202 let conTeXtOutput = format == "context"
206− let html5Output = format == "html5"
203+ let html5Output = format == "html5" || format == "html"
207204
208205 -- disabling the custom writer for now
209206 writer <- if ".lua" `isSuffixOf` format
@@ -313,7 +310,6 @@ convertWithOpts opts args = do
313310 writerIdentifierPrefix = idPrefix,
314311 writerSourceURL = sourceURL,
315312 writerUserDataDir = datadir,
316− writerHtml5 = html5,
317313 writerHtmlQTags = htmlQTags,
318314 writerTopLevelDivision = topLevelDivision,
319315 writerListings = listings,
@@ -413,7 +409,7 @@ convertWithOpts opts args = do
413409 err 43 "Error producing PDF"
414410 | otherwise -> do
415411 let htmlFormat = format `elem`
416− ["html","html5","s5","slidy","slideous","dzslides","revealjs"]
412+ ["html","html4","html5","s5","slidy","slideous","dzslides","revealjs"]
417413 selfcontain = if selfContained && htmlFormat
418414 then makeSelfContained writerOptions media
419415 else return
@@ -523,7 +519,6 @@ data Opt = Opt
523519 , optSectionDivs :: Bool -- ^ Put sections in div tags in HTML
524520 , optIncremental :: Bool -- ^ Use incremental lists in Slidy/Slideous/S5
525521 , optSelfContained :: Bool -- ^ Make HTML accessible offline
526− , optHtml5 :: Bool -- ^ Produce HTML5 in HTML
527522 , optHtmlQTags :: Bool -- ^ Use <q> tags in HTML
528523 , optHighlightStyle :: Maybe Style -- ^ Style to use for highlighted code
529524 , optTopLevelDivision :: TopLevelDivision -- ^ Type of the top-level divisions
@@ -583,7 +578,6 @@ defaultOpts = Opt
583578 , optSectionDivs = False
584579 , optIncremental = False
585580 , optSelfContained = False
586− , optHtml5 = False
587581 , optHtmlQTags = False
588582 , optHighlightStyle = Just pygments
589583 , optTopLevelDivision = TopLevelDefault
src/Text/Pandoc.hs+14−13
@@ -99,8 +99,10 @@ module Text.Pandoc
9999 , writeLaTeX
100100 , writeConTeXt
101101 , writeTexinfo
102− , writeHtml
103− , writeHtmlString
102+ , writeHtml4
103+ , writeHtml4String
104+ , writeHtml5
105+ , writeHtml5String
104106 , writeICML
105107 , writeDocbook
106108 , writeOPML
@@ -281,23 +283,21 @@ writers = [
281283 ,("epub3" , ByteStringWriter $ \o ->
282284 writeEPUB o{ writerEpubVersion = Just EPUB3 })
283285 ,("fb2" , StringWriter writeFB2)
284− ,("html" , StringWriter writeHtmlString)
285− ,("html5" , StringWriter $ \o ->
286− writeHtmlString o{ writerHtml5 = True })
286+ ,("html" , StringWriter writeHtml5String)
287+ ,("html4" , StringWriter writeHtml4String)
288+ ,("html5" , StringWriter writeHtml5String)
287289 ,("icml" , StringWriter writeICML)
288290 ,("s5" , StringWriter $ \o ->
289− writeHtmlString o{ writerSlideVariant = S5Slides
290− , writerTableOfContents = False })
291+ writeHtml4String o{ writerSlideVariant = S5Slides
292+ , writerTableOfContents = False })
291293 ,("slidy" , StringWriter $ \o ->
292− writeHtmlString o{ writerSlideVariant = SlidySlides })
294+ writeHtml4String o{ writerSlideVariant = SlidySlides })
293295 ,("slideous" , StringWriter $ \o ->
294− writeHtmlString o{ writerSlideVariant = SlideousSlides })
296+ writeHtml4String o{ writerSlideVariant = SlideousSlides })
295297 ,("dzslides" , StringWriter $ \o ->
296− writeHtmlString o{ writerSlideVariant = DZSlides
297− , writerHtml5 = True })
298+ writeHtml5String o{ writerSlideVariant = DZSlides })
298299 ,("revealjs" , StringWriter $ \o ->
299− writeHtmlString o{ writerSlideVariant = RevealJsSlides
300− , writerHtml5 = True })
300+ writeHtml5String o{ writerSlideVariant = RevealJsSlides })
301301 ,("docbook" , StringWriter writeDocbook)
302302 ,("docbook5" , StringWriter $ \o ->
303303 writeDocbook o{ writerDocbook5 = True })
@@ -342,6 +342,7 @@ getDefaultExtensions "html" = extensionsFromList
342342 [Ext_auto_identifiers,
343343 Ext_native_divs,
344344 Ext_native_spans]
345+getDefaultExtensions "html4" = getDefaultExtensions "html"
345346getDefaultExtensions "html5" = getDefaultExtensions "html"
346347getDefaultExtensions "epub" = extensionsFromList
347348 [Ext_raw_html,
src/Text/Pandoc/Options.hs−2
@@ -168,7 +168,6 @@ data WriterOptions = WriterOptions
168168 , writerUserDataDir :: Maybe FilePath -- ^ Path of user data directory
169169 , writerCiteMethod :: CiteMethod -- ^ How to print cites
170170 , writerDocbook5 :: Bool -- ^ Produce DocBook5
171− , writerHtml5 :: Bool -- ^ Produce HTML5
172171 , writerHtmlQTags :: Bool -- ^ Use @<q>@ tags for quotes in HTML
173172 , writerBeamer :: Bool -- ^ Produce beamer LaTeX slide show
174173 , writerSlideLevel :: Maybe Int -- ^ Force header level of slides
@@ -210,7 +209,6 @@ instance Default WriterOptions where
210209 , writerUserDataDir = Nothing
211210 , writerCiteMethod = Citeproc
212211 , writerDocbook5 = False
213− , writerHtml5 = False
214212 , writerHtmlQTags = False
215213 , writerBeamer = False
216214 , writerSlideLevel = Nothing
src/Text/Pandoc/Templates.hs+1
@@ -60,6 +60,7 @@ getDefaultTemplate user writer = do
6060 "docx" -> return $ Right ""
6161 "fb2" -> return $ Right ""
6262 "odt" -> getDefaultTemplate user "opendocument"
63+ "html" -> getDefaultTemplate user "html5"
6364 "markdown_strict" -> getDefaultTemplate user "markdown"
6465 "multimarkdown" -> getDefaultTemplate user "markdown"
6566 "markdown_github" -> getDefaultTemplate user "markdown"
src/Text/Pandoc/Writers/CommonMark.hs+2−2
@@ -31,7 +31,7 @@ CommonMark: <http://commonmark.org>
3131-}
3232module Text.Pandoc.Writers.CommonMark (writeCommonMark) where
3333
34−import Text.Pandoc.Writers.HTML (writeHtmlString)
34+import Text.Pandoc.Writers.HTML (writeHtml5String)
3535import Text.Pandoc.Definition
3636import Text.Pandoc.Shared (isTightList, linesToPara)
3737import Text.Pandoc.Templates (renderTemplate')
@@ -138,7 +138,7 @@ blockToNodes (DefinitionList items) ns = blockToNodes (BulletList items') ns
138138 dlToBullet (term, xs) =
139139 Para term : concat xs
140140blockToNodes t@(Table _ _ _ _ _) ns = do
141− s <- writeHtmlString def $! Pandoc nullMeta [t]
141+ s <- writeHtml5String def $! Pandoc nullMeta [t]
142142 return (node (HTML_BLOCK (T.pack $! s)) [] : ns)
143143blockToNodes Null ns = return ns
144144
src/Text/Pandoc/Writers/EPUB.hs+6−5
@@ -59,7 +59,7 @@ import Control.Monad (mplus, when, zipWithM)
5959import Text.XML.Light ( unode, Element(..), unqual, Attr(..), add_attrs
6060 , strContent, lookupAttr, Node(..), QName(..), parseXML
6161 , onlyElems, node, ppElement)
62−import Text.Pandoc.Writers.HTML ( writeHtml )
62+import Text.Pandoc.Writers.HTML ( writeHtml4, writeHtml5 )
6363import Data.Char ( toLower, isDigit, isAlphaNum )
6464import Text.Pandoc.MIME (MimeType, getMimeType, extensionFromMimeType)
6565import Text.Blaze.Html.Renderer.Utf8 (renderHtml)
@@ -361,13 +361,15 @@ pandocToEPUB opts doc@(Pandoc meta _) = do
361361 : writerVariables opts
362362 let opts' = opts{ writerEmailObfuscation = NoObfuscation
363363 , writerSectionDivs = True
364− , writerHtml5 = epub3
365364 , writerVariables = vars
366365 , writerHTMLMathMethod =
367366 if epub3
368367 then MathML Nothing
369368 else writerHTMLMathMethod opts
370369 , writerWrapText = WrapAuto }
370+ let writeHtml = if epub3
371+ then writeHtml5
372+ else writeHtml4
371373 metadata <- getEPUBMetadata opts' meta
372374
373375 -- cover page
@@ -376,7 +378,7 @@ pandocToEPUB opts doc@(Pandoc meta _) = do
376378 Nothing -> return ([],[])
377379 Just img -> do
378380 let coverImage = "media/" ++ takeFileName img
379− cpContent <- renderHtml <$> (lift $ writeHtml
381+ cpContent <- renderHtml <$> (lift $ writeHtml
380382 opts'{ writerVariables = ("coverpage","true"):vars }
381383 (Pandoc meta [RawBlock (Format "html") $ "<div id=\"cover-image\">\n<img src=\"" ++ coverImage ++ "\" alt=\"cover image\" />\n</div>"]))
382384 imgContent <- lift $ P.readFileLazy img
@@ -484,8 +486,7 @@ pandocToEPUB opts doc@(Pandoc meta _) = do
484486 Chapter mbnum $ walk fixInternalReferences bs)
485487 chapters'
486488
487− let chapToEntry :: PandocMonad m => Int -> Chapter -> m Entry
488− chapToEntry num (Chapter mbnum bs) =
489+ let chapToEntry num (Chapter mbnum bs) =
489490 (mkEntry (showChapter num) . renderHtml) <$>
490491 (writeHtml opts'{ writerNumberOffset =
491492 fromMaybe [] mbnum }
src/Text/Pandoc/Writers/HTML.hs+74−43
@@ -28,7 +28,9 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
2828
2929Conversion of 'Pandoc' documents to HTML.
3030-}
31−module Text.Pandoc.Writers.HTML ( writeHtml , writeHtmlString ) where
31+module Text.Pandoc.Writers.HTML (
32+ writeHtml4, writeHtml4String,
33+ writeHtml5, writeHtml5String ) where
3234import Text.Pandoc.Definition
3335import Text.Pandoc.Walk
3436import Data.Monoid ((<>))
@@ -80,12 +82,13 @@ data WriterState = WriterState
8082 , stHighlighting :: Bool -- ^ Syntax highlighting is used
8183 , stSecNum :: [Int] -- ^ Number of current section
8284 , stElement :: Bool -- ^ Processing an Element
85+ , stHtml5 :: Bool -- ^ Use HTML5
8386 }
8487
8588defaultWriterState :: WriterState
8689defaultWriterState = WriterState {stNotes= [], stMath = False, stQuotes = False,
8790 stHighlighting = False, stSecNum = [],
88− stElement = False}
91+ stElement = False, stHtml5 = False}
8992
9093-- Helpers to render HTML with the appropriate function.
9194
@@ -102,19 +105,35 @@ nl opts = if writerWrapText opts == WrapNone
102105 then mempty
103106 else preEscapedString "\n"
104107
105−-- | Convert Pandoc document to Html string.
106−writeHtmlString :: PandocMonad m => WriterOptions -> Pandoc -> m String
107−writeHtmlString opts d = do
108− (body, context) <- evalStateT (pandocToHtml opts d) defaultWriterState
108+-- | Convert Pandoc document to Html 5 string.
109+writeHtml5String :: PandocMonad m => WriterOptions -> Pandoc -> m String
110+writeHtml5String = writeHtmlString' True
111+
112+-- | Convert Pandoc document to Html 5 structure.
113+writeHtml5 :: PandocMonad m => WriterOptions -> Pandoc -> m Html
114+writeHtml5 = writeHtml' True
115+
116+-- | Convert Pandoc document to Html 4 string.
117+writeHtml4String :: PandocMonad m => WriterOptions -> Pandoc -> m String
118+writeHtml4String = writeHtmlString' False
119+
120+-- | Convert Pandoc document to Html 4 structure.
121+writeHtml4 :: PandocMonad m => WriterOptions -> Pandoc -> m Html
122+writeHtml4 = writeHtml' False
123+
124+writeHtmlString' :: PandocMonad m => Bool -> WriterOptions -> Pandoc -> m String
125+writeHtmlString' html5 opts d = do
126+ (body, context) <- evalStateT (pandocToHtml opts d)
127+ defaultWriterState{ stHtml5 = html5 }
109128 return $ case writerTemplate opts of
110129 Nothing -> renderHtml body
111130 Just tpl -> renderTemplate' tpl $
112131 defField "body" (renderHtml body) context
113132
114−-- | Convert Pandoc document to Html structure.
115−writeHtml :: PandocMonad m => WriterOptions -> Pandoc -> m Html
116−writeHtml opts d = do
117− (body, context) <- evalStateT (pandocToHtml opts d) defaultWriterState
133+writeHtml' :: PandocMonad m => Bool -> WriterOptions -> Pandoc -> m Html
134+writeHtml' html5 opts d = do
135+ (body, context) <- evalStateT (pandocToHtml opts d)
136+ defaultWriterState{ stHtml5 = html5 }
118137 return $ case writerTemplate opts of
119138 Nothing -> body
120139 Just tpl -> renderTemplate' tpl $
@@ -144,8 +163,8 @@ pandocToHtml opts (Pandoc meta blocks) = do
144163 blocks' <- liftM (mconcat . intersperse (nl opts)) $
145164 mapM (elementToHtml slideLevel opts) sects
146165 st <- get
147− let notes = reverse (stNotes st)
148− let thebody = blocks' >> footnoteSection opts notes
166+ notes <- footnoteSection opts (reverse (stNotes st))
167+ let thebody = blocks' >> notes
149168 let math = case writerHTMLMathMethod opts of
150169 LaTeXMathML (Just url) ->
151170 H.script ! A.src (toValue url)
@@ -172,7 +191,7 @@ pandocToHtml opts (Pandoc meta blocks) = do
172191 (H.link ! A.rel "stylesheet" ! A.href (toValue css)) <>
173192 (H.script ! A.type_ "text/javascript" $ toHtml renderKaTeX)
174193 _ -> case lookup "mathml-script" (writerVariables opts) of
175− Just s | not (writerHtml5 opts) ->
194+ Just s | not (stHtml5 st) ->
176195 H.script ! A.type_ "text/javascript"
177196 $ preEscapedString
178197 ("/*<![CDATA[*/\n" ++ s ++ "/*]]>*/\n")
@@ -199,7 +218,7 @@ pandocToHtml opts (Pandoc meta blocks) = do
199218 defField "slideous-url" ("slideous" :: String) $
200219 defField "revealjs-url" ("reveal.js" :: String) $
201220 defField "s5-url" ("s5/default" :: String) $
202− defField "html5" (writerHtml5 opts) $
221+ defField "html5" (stHtml5 st) $
203222 metadata
204223 return (thebody, context)
205224
@@ -277,6 +296,7 @@ elementToHtml slideLevel opts (Sec level num (id',classes,keyvals) title' elemen
277296 let slide = writerSlideVariant opts /= NoSlides && level <= slideLevel
278297 let num' = zipWith (+) num (writerNumberOffset opts ++ repeat 0)
279298 modify $ \st -> st{stSecNum = num'} -- update section number
299+ html5 <- gets stHtml5
280300 let titleSlide = slide && level < slideLevel
281301 header' <- if title' == [Str "\0"] -- marker for hrule
282302 then return mempty
@@ -307,10 +327,10 @@ elementToHtml slideLevel opts (Sec level num (id',classes,keyvals) title' elemen
307327 let inNl x = mconcat $ nl opts : intersperse (nl opts) x ++ [nl opts]
308328 let classes' = ["titleslide" | titleSlide] ++ ["slide" | slide] ++
309329 ["section" | (slide || writerSectionDivs opts) &&
310− not (writerHtml5 opts) ] ++
330+ not html5 ] ++
311331 ["level" ++ show level | slide || writerSectionDivs opts ]
312332 ++ classes
313− let secttag = if writerHtml5 opts
333+ let secttag = if html5
314334 then H5.section
315335 else H.div
316336 let attr = (id',classes',keyvals)
@@ -327,19 +347,22 @@ elementToHtml slideLevel opts (Sec level num (id',classes,keyvals) title' elemen
327347
328348-- | Convert list of Note blocks to a footnote <div>.
329349-- Assumes notes are sorted.
330−footnoteSection :: WriterOptions -> [Html] -> Html
331−footnoteSection opts notes =
332− if null notes
333− then mempty
334− else nl opts >> (container
335− $ nl opts >> hrtag >> nl opts >>
336− H.ol (mconcat notes >> nl opts) >> nl opts)
337− where container x = if writerHtml5 opts
338− then H5.section ! A.class_ "footnotes" $ x
339− else if writerSlideVariant opts /= NoSlides
340− then H.div ! A.class_ "footnotes slide" $ x
341− else H.div ! A.class_ "footnotes" $ x
342− hrtag = if writerHtml5 opts then H5.hr else H.hr
350+footnoteSection :: PandocMonad m
351+ => WriterOptions -> [Html] -> StateT WriterState m Html
352+footnoteSection opts notes = do
353+ html5 <- gets stHtml5
354+ let hrtag = if html5 then H5.hr else H.hr
355+ let container x = if html5
356+ then H5.section ! A.class_ "footnotes" $ x
357+ else if writerSlideVariant opts /= NoSlides
358+ then H.div ! A.class_ "footnotes slide" $ x
359+ else H.div ! A.class_ "footnotes" $ x
360+ return $
361+ if null notes
362+ then mempty
363+ else nl opts >> (container
364+ $ nl opts >> hrtag >> nl opts >>
365+ H.ol (mconcat notes >> nl opts) >> nl opts)
343366
344367-- | Parse a mailto link; return Just (name, domain) or Nothing.
345368parseMailto :: String -> Maybe (String, String)
@@ -448,13 +471,14 @@ blockToHtml opts (Plain lst) = inlineListToHtml opts lst
448471-- title beginning with fig: indicates that the image is a figure
449472blockToHtml opts (Para [Image attr txt (s,'f':'i':'g':':':tit)]) = do
450473 img <- inlineToHtml opts (Image attr txt (s,tit))
451− let tocapt = if writerHtml5 opts
474+ html5 <- gets stHtml5
475+ let tocapt = if html5
452476 then H5.figcaption
453477 else H.p ! A.class_ "caption"
454478 capt <- if null txt
455479 then return mempty
456480 else tocapt `fmap` inlineListToHtml opts txt
457− return $ if writerHtml5 opts
481+ return $ if html5
458482 then H5.figure $ mconcat
459483 [nl opts, img, capt, nl opts]
460484 else H.div ! A.class_ "figure" $ mconcat
@@ -475,12 +499,13 @@ blockToHtml opts (LineBlock lns) =
475499 htmlLines <- mconcat . intersperse lf <$> mapM (inlineListToHtml opts) lns
476500 return $ H.div ! A.style "white-space: pre-line;" $ htmlLines
477501blockToHtml opts (Div attr@(ident, classes, kvs) bs) = do
502+ html5 <- gets stHtml5
478503 let speakerNotes = "notes" `elem` classes
479504 -- we don't want incremental output inside speaker notes, see #1394
480505 let opts' = if speakerNotes then opts{ writerIncremental = False } else opts
481506 contents <- blockListToHtml opts' bs
482507 let contents' = nl opts >> contents >> nl opts
483− let (divtag, classes') = if writerHtml5 opts && "section" `elem` classes
508+ let (divtag, classes') = if html5 && "section" `elem` classes
484509 then (H5.section, filter (/= "section") classes)
485510 else (H.div, classes)
486511 return $
@@ -498,7 +523,9 @@ blockToHtml opts (RawBlock f str)
498523 allowsMathEnvironments (writerHTMLMathMethod opts) &&
499524 isMathEnvironment str = blockToHtml opts $ Plain [Math DisplayMath str]
500525 | otherwise = return mempty
501−blockToHtml opts (HorizontalRule) = return $ if writerHtml5 opts then H5.hr else H.hr
526+blockToHtml _ (HorizontalRule) = do
527+ html5 <- gets stHtml5
528+ return $ if html5 then H5.hr else H.hr
502529blockToHtml opts (CodeBlock (id',classes,keyvals) rawCode) = do
503530 let tolhs = isEnabled Ext_literate_haskell opts &&
504531 any (\c -> map toLower c == "haskell") classes &&
@@ -564,6 +591,7 @@ blockToHtml opts (BulletList lst) = do
564591 return $ unordList opts contents
565592blockToHtml opts (OrderedList (startnum, numstyle, _) lst) = do
566593 contents <- mapM (blockListToHtml opts) lst
594+ html5 <- gets stHtml5
567595 let numstyle' = case numstyle of
568596 Example -> "decimal"
569597 _ -> camelCaseToHyphenated $ show numstyle
@@ -574,7 +602,7 @@ blockToHtml opts (OrderedList (startnum, numstyle, _) lst) = do
574602 then [A.class_ "example"]
575603 else []) ++
576604 (if numstyle /= DefaultStyle
577− then if writerHtml5 opts
605+ then if html5
578606 then [A.type_ $
579607 case numstyle of
580608 Decimal -> "1"
@@ -603,6 +631,7 @@ blockToHtml opts (Table capt aligns widths headers rows') = do
603631 else do
604632 cs <- inlineListToHtml opts capt
605633 return $ H.caption cs >> nl opts
634+ html5 <- gets stHtml5
606635 let percent w = show (truncate (100*w) :: Integer) ++ "%"
607636 let coltags = if all (== 0.0) widths
608637 then mempty
@@ -610,7 +639,7 @@ blockToHtml opts (Table capt aligns widths headers rows') = do
610639 H.colgroup $ do
611640 nl opts
612641 mapM_ (\w -> do
613− if writerHtml5 opts
642+ if html5
614643 then H.col ! A.style (toValue $ "width: " ++
615644 percent w)
616645 else H.col ! A.width (toValue $ percent w)
@@ -666,8 +695,9 @@ tableItemToHtml :: PandocMonad m
666695 -> StateT WriterState m Html
667696tableItemToHtml opts tag' align' item = do
668697 contents <- blockListToHtml opts item
698+ html5 <- gets stHtml5
669699 let alignStr = alignmentToString align'
670− let attribs = if writerHtml5 opts
700+ let attribs = if html5
671701 then A.style (toValue $ "text-align: " ++ alignStr ++ ";")
672702 else A.align (toValue alignStr)
673703 let tag'' = if null alignStr
@@ -707,7 +737,8 @@ annotateMML e tex = math (unode "semantics" [cs, unode "annotation" (annotAttrs,
707737-- | Convert Pandoc inline element to HTML.
708738inlineToHtml :: PandocMonad m
709739 => WriterOptions -> Inline -> StateT WriterState m Html
710−inlineToHtml opts inline =
740+inlineToHtml opts inline = do
741+ html5 <- gets stHtml5
711742 case inline of
712743 (Str str) -> return $ strToHtml str
713744 (Space) -> return $ strToHtml " "
@@ -715,7 +746,7 @@ inlineToHtml opts inline =
715746 WrapNone -> preEscapedString " "
716747 WrapAuto -> preEscapedString " "
717748 WrapPreserve -> preEscapedString "\n"
718− (LineBreak) -> return $ (if writerHtml5 opts then H5.br else H.br)
749+ (LineBreak) -> return $ (if html5 then H5.br else H.br)
719750 <> strToHtml "\n"
720751 (Span (id',classes,kvs) ils)
721752 -> inlineListToHtml opts ils >>=
@@ -784,12 +815,12 @@ inlineToHtml opts inline =
784815 InlineMath -> H.span ! A.class_ mathClass $ m
785816 DisplayMath -> H.div ! A.class_ mathClass $ m
786817 WebTeX url -> do
787− let imtag = if writerHtml5 opts then H5.img else H.img
818+ let imtag = if html5 then H5.img else H.img
788819 let m = imtag ! A.style "vertical-align:middle"
789820 ! A.src (toValue $ url ++ urlEncode str)
790821 ! A.alt (toValue str)
791822 ! A.title (toValue str)
792− let brtag = if writerHtml5 opts then H5.br else H.br
823+ let brtag = if html5 then H5.br else H.br
793824 return $ case t of
794825 InlineMath -> m
795826 DisplayMath -> brtag >> m >> brtag
@@ -817,7 +848,7 @@ inlineToHtml opts inline =
817848 PlainMath -> do
818849 x <- lift (texMathToInlines t str) >>= inlineListToHtml opts
819850 let m = H.span ! A.class_ mathClass $ x
820− let brtag = if writerHtml5 opts then H5.br else H.br
851+ let brtag = if html5 then H5.br else H.br
821852 return $ case t of
822853 InlineMath -> m
823854 DisplayMath -> brtag >> m >> brtag
@@ -847,7 +878,7 @@ inlineToHtml opts inline =
847878 [A.title $ toValue tit | not (null tit)] ++
848879 [A.alt $ toValue alternate' | not (null txt)] ++
849880 imgAttrsToHtml opts attr
850− let tag = if writerHtml5 opts then H5.img else H.img
881+ let tag = if html5 then H5.img else H.img
851882 return $ foldl (!) tag attributes
852883 -- note: null title included, as in Markdown.pl
853884 (Image attr _ (s,tit)) -> do
@@ -880,7 +911,7 @@ inlineToHtml opts inline =
880911 (Cite cits il)-> do contents <- inlineListToHtml opts il
881912 let citationIds = unwords $ map citationId cits
882913 let result = H.span ! A.class_ "citation" $ contents
883− return $ if writerHtml5 opts
914+ return $ if html5
884915 then result ! customAttribute "data-cites" (toValue citationIds)
885916 else result
886917
src/Text/Pandoc/Writers/Markdown.hs+4−4
@@ -47,7 +47,7 @@ import Text.Pandoc.Pretty
4747import Control.Monad.Reader
4848import Control.Monad.State
4949import Control.Monad.Except (throwError)
50−import Text.Pandoc.Writers.HTML (writeHtmlString)
50+import Text.Pandoc.Writers.HTML (writeHtml5String)
5151import Text.Pandoc.Writers.Math (texMathToInlines)
5252import Text.HTML.TagSoup (parseTags, isTagText, Tag(..))
5353import Network.URI (isURI)
@@ -536,7 +536,7 @@ blockToMarkdown' opts t@(Table caption aligns widths headers rows) = do
536536 rawHeaders rawRows
537537 | isEnabled Ext_raw_html opts -> fmap (id,) $
538538 text <$>
539− (writeHtmlString def $ Pandoc nullMeta [t])
539+ (writeHtml5String def $ Pandoc nullMeta [t])
540540 | otherwise -> return $ (id, text "[TABLE]")
541541 return $ nst $ tbl $$ blankline $$ caption'' $$ blankline
542542blockToMarkdown' opts (BulletList items) = do
@@ -1072,7 +1072,7 @@ inlineToMarkdown opts lnk@(Link attr txt (src, tit))
10721072 | isEnabled Ext_raw_html opts &&
10731073 not (isEnabled Ext_link_attributes opts) &&
10741074 attr /= nullAttr = -- use raw HTML
1075− (text . trim) <$> writeHtmlString def (Pandoc nullMeta [Plain [lnk]])
1075+ (text . trim) <$> writeHtml5String def (Pandoc nullMeta [Plain [lnk]])
10761076 | otherwise = do
10771077 plain <- asks envPlain
10781078 linktext <- inlineListToMarkdown opts txt
@@ -1111,7 +1111,7 @@ inlineToMarkdown opts img@(Image attr alternate (source, tit))
11111111 | isEnabled Ext_raw_html opts &&
11121112 not (isEnabled Ext_link_attributes opts) &&
11131113 attr /= nullAttr = -- use raw HTML
1114− (text . trim) <$> writeHtmlString def (Pandoc nullMeta [Plain [img]])
1114+ (text . trim) <$> writeHtml5String def (Pandoc nullMeta [Plain [img]])
11151115 | otherwise = do
11161116 plain <- asks envPlain
11171117 let txt = if null alternate || alternate == [Str source]
src/Text/Pandoc/Writers/OPML.hs+2−2
@@ -35,7 +35,7 @@ import Text.Pandoc.Writers.Shared
3535import Text.Pandoc.Shared
3636import Text.Pandoc.Options
3737import Text.Pandoc.Templates (renderTemplate')
38−import Text.Pandoc.Writers.HTML (writeHtmlString)
38+import Text.Pandoc.Writers.HTML (writeHtml5String)
3939import Text.Pandoc.Writers.Markdown (writeMarkdown)
4040import Text.Pandoc.Pretty
4141import Text.Pandoc.Compat.Time
@@ -65,7 +65,7 @@ writeOPML opts (Pandoc meta blocks) = do
6565
6666writeHtmlInlines :: PandocMonad m => [Inline] -> m String
6767writeHtmlInlines ils =
68− trim <$> (writeHtmlString def $ Pandoc nullMeta [Plain ils])
68+ trim <$> (writeHtml5String def $ Pandoc nullMeta [Plain ils])
6969
7070-- date format: RFC 822: Thu, 14 Jul 2005 23:41:05 GMT
7171showDateTimeRFC822 :: UTCTime -> String
tests/Tests/Old.hs+4−3
@@ -81,16 +81,17 @@ tests = [ testGroup "markdown"
8181 ]
8282 ]
8383 , testGroup "html"
84− [ testGroup "writer" (writerTests "html" ++ lhsWriterTests "html")
84+ [ testGroup "writer" (writerTests "html4" ++ writerTests "html5" ++
85+ lhsWriterTests "html")
8586 , test "reader" ["-r", "html", "-w", "native", "-s"]
8687 "html-reader.html" "html-reader.native"
8788 ]
8889 , testGroup "s5"
8990 [ s5WriterTest "basic" ["-s"] "s5"
9091 , s5WriterTest "fancy" ["-s","-m","-i"] "s5"
91− , s5WriterTest "fragment" [] "html"
92+ , s5WriterTest "fragment" [] "html4"
9293 , s5WriterTest "inserts" ["-s", "-H", "insert",
93− "-B", "insert", "-A", "insert", "-c", "main.css"] "html"
94+ "-B", "insert", "-A", "insert", "-c", "main.css"] "html4"
9495 ]
9596 , testGroup "textile"
9697 [ testGroup "writer" $ writerTests "textile"
tests/Tests/Writers/HTML.hs+1−1
@@ -8,7 +8,7 @@ import Tests.Helpers
88import Text.Pandoc.Arbitrary()
99
1010html :: (ToPandoc a) => a -> String
11−html = purely (writeHtmlString def{ writerWrapText = WrapNone }) . toPandoc
11+html = purely (writeHtml4String def{ writerWrapText = WrapNone }) . toPandoc
1212
1313{-
1414 "my test" =: X =?> Y
tests/lhs-test.html+8−5
@@ -1,9 +1,9 @@
1−<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2−<html xmlns="http://www.w3.org/1999/xhtml">
1+<!DOCTYPE html>
2+<html>
33<head>
4− <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5− <meta http-equiv="Content-Style-Type" content="text/css" />
6− <meta name="generator" content="pandoc" />
4+ <meta charset="utf-8">
5+ <meta name="generator" content="pandoc">
6+ <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
77 <title></title>
88 <style type="text/css">code{white-space: pre;}</style>
99 <style type="text/css">
@@ -43,6 +43,9 @@ code > span.an { color: #60a0b0; font-weight: bold; font-style: italic; } /* Ann
4343code > span.cv { color: #60a0b0; font-weight: bold; font-style: italic; } /* CommentVar */
4444code > span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Information */
4545 </style>
46+ <!--[if lt IE 9]>
47+ <script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
48+ <![endif]-->
4649</head>
4750<body>
4851<h1 id="lhs-test">lhs test</h1>
tests/lhs-test.html+lhs+8−5
@@ -1,9 +1,9 @@
1−<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2−<html xmlns="http://www.w3.org/1999/xhtml">
1+<!DOCTYPE html>
2+<html>
33<head>
4− <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5− <meta http-equiv="Content-Style-Type" content="text/css" />
6− <meta name="generator" content="pandoc" />
4+ <meta charset="utf-8">
5+ <meta name="generator" content="pandoc">
6+ <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
77 <title></title>
88 <style type="text/css">code{white-space: pre;}</style>
99 <style type="text/css">
@@ -43,6 +43,9 @@ code > span.an { color: #60a0b0; font-weight: bold; font-style: italic; } /* Ann
4343code > span.cv { color: #60a0b0; font-weight: bold; font-style: italic; } /* CommentVar */
4444code > span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Information */
4545 </style>
46+ <!--[if lt IE 9]>
47+ <script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
48+ <![endif]-->
4649</head>
4750<body>
4851<h1 id="lhs-test">lhs test</h1>
tests/tables.html → tests/tables.html4renamed

The content is the same.

tests/tables.html5new file+204
@@ -0,0 +1,204 @@
1+<p>Simple table with caption:</p>
2+<table>
3+<caption>Demonstration of simple table syntax.</caption>
4+<thead>
5+<tr class="header">
6+<th style="text-align: right;">Right</th>
7+<th style="text-align: left;">Left</th>
8+<th style="text-align: center;">Center</th>
9+<th>Default</th>
10+</tr>
11+</thead>
12+<tbody>
13+<tr class="odd">
14+<td style="text-align: right;">12</td>
15+<td style="text-align: left;">12</td>
16+<td style="text-align: center;">12</td>
17+<td>12</td>
18+</tr>
19+<tr class="even">
20+<td style="text-align: right;">123</td>
21+<td style="text-align: left;">123</td>
22+<td style="text-align: center;">123</td>
23+<td>123</td>
24+</tr>
25+<tr class="odd">
26+<td style="text-align: right;">1</td>
27+<td style="text-align: left;">1</td>
28+<td style="text-align: center;">1</td>
29+<td>1</td>
30+</tr>
31+</tbody>
32+</table>
33+<p>Simple table without caption:</p>
34+<table>
35+<thead>
36+<tr class="header">
37+<th style="text-align: right;">Right</th>
38+<th style="text-align: left;">Left</th>
39+<th style="text-align: center;">Center</th>
40+<th>Default</th>
41+</tr>
42+</thead>
43+<tbody>
44+<tr class="odd">
45+<td style="text-align: right;">12</td>
46+<td style="text-align: left;">12</td>
47+<td style="text-align: center;">12</td>
48+<td>12</td>
49+</tr>
50+<tr class="even">
51+<td style="text-align: right;">123</td>
52+<td style="text-align: left;">123</td>
53+<td style="text-align: center;">123</td>
54+<td>123</td>
55+</tr>
56+<tr class="odd">
57+<td style="text-align: right;">1</td>
58+<td style="text-align: left;">1</td>
59+<td style="text-align: center;">1</td>
60+<td>1</td>
61+</tr>
62+</tbody>
63+</table>
64+<p>Simple table indented two spaces:</p>
65+<table>
66+<caption>Demonstration of simple table syntax.</caption>
67+<thead>
68+<tr class="header">
69+<th style="text-align: right;">Right</th>
70+<th style="text-align: left;">Left</th>
71+<th style="text-align: center;">Center</th>
72+<th>Default</th>
73+</tr>
74+</thead>
75+<tbody>
76+<tr class="odd">
77+<td style="text-align: right;">12</td>
78+<td style="text-align: left;">12</td>
79+<td style="text-align: center;">12</td>
80+<td>12</td>
81+</tr>
82+<tr class="even">
83+<td style="text-align: right;">123</td>
84+<td style="text-align: left;">123</td>
85+<td style="text-align: center;">123</td>
86+<td>123</td>
87+</tr>
88+<tr class="odd">
89+<td style="text-align: right;">1</td>
90+<td style="text-align: left;">1</td>
91+<td style="text-align: center;">1</td>
92+<td>1</td>
93+</tr>
94+</tbody>
95+</table>
96+<p>Multiline table with caption:</p>
97+<table style="width:79%;">
98+<caption>Here’s the caption. It may span multiple lines.</caption>
99+<colgroup>
100+<col style="width: 15%" />
101+<col style="width: 13%" />
102+<col style="width: 16%" />
103+<col style="width: 33%" />
104+</colgroup>
105+<thead>
106+<tr class="header">
107+<th style="text-align: center;">Centered Header</th>
108+<th style="text-align: left;">Left Aligned</th>
109+<th style="text-align: right;">Right Aligned</th>
110+<th style="text-align: left;">Default aligned</th>
111+</tr>
112+</thead>
113+<tbody>
114+<tr class="odd">
115+<td style="text-align: center;">First</td>
116+<td style="text-align: left;">row</td>
117+<td style="text-align: right;">12.0</td>
118+<td style="text-align: left;">Example of a row that spans multiple lines.</td>
119+</tr>
120+<tr class="even">
121+<td style="text-align: center;">Second</td>
122+<td style="text-align: left;">row</td>
123+<td style="text-align: right;">5.0</td>
124+<td style="text-align: left;">Here’s another one. Note the blank line between rows.</td>
125+</tr>
126+</tbody>
127+</table>
128+<p>Multiline table without caption:</p>
129+<table style="width:79%;">
130+<colgroup>
131+<col style="width: 15%" />
132+<col style="width: 13%" />
133+<col style="width: 16%" />
134+<col style="width: 33%" />
135+</colgroup>
136+<thead>
137+<tr class="header">
138+<th style="text-align: center;">Centered Header</th>
139+<th style="text-align: left;">Left Aligned</th>
140+<th style="text-align: right;">Right Aligned</th>
141+<th style="text-align: left;">Default aligned</th>
142+</tr>
143+</thead>
144+<tbody>
145+<tr class="odd">
146+<td style="text-align: center;">First</td>
147+<td style="text-align: left;">row</td>
148+<td style="text-align: right;">12.0</td>
149+<td style="text-align: left;">Example of a row that spans multiple lines.</td>
150+</tr>
151+<tr class="even">
152+<td style="text-align: center;">Second</td>
153+<td style="text-align: left;">row</td>
154+<td style="text-align: right;">5.0</td>
155+<td style="text-align: left;">Here’s another one. Note the blank line between rows.</td>
156+</tr>
157+</tbody>
158+</table>
159+<p>Table without column headers:</p>
160+<table>
161+<tbody>
162+<tr class="odd">
163+<td style="text-align: right;">12</td>
164+<td style="text-align: left;">12</td>
165+<td style="text-align: center;">12</td>
166+<td style="text-align: right;">12</td>
167+</tr>
168+<tr class="even">
169+<td style="text-align: right;">123</td>
170+<td style="text-align: left;">123</td>
171+<td style="text-align: center;">123</td>
172+<td style="text-align: right;">123</td>
173+</tr>
174+<tr class="odd">
175+<td style="text-align: right;">1</td>
176+<td style="text-align: left;">1</td>
177+<td style="text-align: center;">1</td>
178+<td style="text-align: right;">1</td>
179+</tr>
180+</tbody>
181+</table>
182+<p>Multiline table without column headers:</p>
183+<table style="width:79%;">
184+<colgroup>
185+<col style="width: 15%" />
186+<col style="width: 13%" />
187+<col style="width: 16%" />
188+<col style="width: 33%" />
189+</colgroup>
190+<tbody>
191+<tr class="odd">
192+<td style="text-align: center;">First</td>
193+<td style="text-align: left;">row</td>
194+<td style="text-align: right;">12.0</td>
195+<td>Example of a row that spans multiple lines.</td>
196+</tr>
197+<tr class="even">
198+<td style="text-align: center;">Second</td>
199+<td style="text-align: left;">row</td>
200+<td style="text-align: right;">5.0</td>
201+<td>Here’s another one. Note the blank line between rows.</td>
202+</tr>
203+</tbody>
204+</table>
tests/writer.html → tests/writer.html4renamed

The content is the same.

tests/writer.html5new file+548
@@ -0,0 +1,548 @@
1+<!DOCTYPE html>
2+<html>
3+<head>
4+ <meta charset="utf-8">
5+ <meta name="generator" content="pandoc">
6+ <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
7+ <meta name="author" content="John MacFarlane">
8+ <meta name="author" content="Anonymous">
9+ <meta name="dcterms.date" content="2006-07-17">
10+ <title>Pandoc Test Suite</title>
11+ <style type="text/css">code{white-space: pre;}</style>
12+ <!--[if lt IE 9]>
13+ <script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
14+ <![endif]-->
15+</head>
16+<body>
17+<header>
18+<h1 class="title">Pandoc Test Suite</h1>
19+<p class="author">John MacFarlane</p>
20+<p class="author">Anonymous</p>
21+<p class="date">July 17, 2006</p>
22+</header>
23+<p>This is a set of tests for pandoc. Most of them are adapted from John Gruber’s markdown test suite.</p>
24+<hr />
25+<h1 id="headers">Headers</h1>
26+<h2 id="level-2-with-an-embedded-link">Level 2 with an <a href="/url">embedded link</a></h2>
27+<h3 id="level-3-with-emphasis">Level 3 with <em>emphasis</em></h3>
28+<h4 id="level-4">Level 4</h4>
29+<h5 id="level-5">Level 5</h5>
30+<h1 id="level-1">Level 1</h1>
31+<h2 id="level-2-with-emphasis">Level 2 with <em>emphasis</em></h2>
32+<h3 id="level-3">Level 3</h3>
33+<p>with no blank line</p>
34+<h2 id="level-2">Level 2</h2>
35+<p>with no blank line</p>
36+<hr />
37+<h1 id="paragraphs">Paragraphs</h1>
38+<p>Here’s a regular paragraph.</p>
39+<p>In Markdown 1.0.0 and earlier. Version 8. This line turns into a list item. Because a hard-wrapped line in the middle of a paragraph looked like a list item.</p>
40+<p>Here’s one with a bullet. * criminey.</p>
41+<p>There should be a hard line break<br />
42+here.</p>
43+<hr />
44+<h1 id="block-quotes">Block Quotes</h1>
45+<p>E-mail style:</p>
46+<blockquote>
47+<p>This is a block quote. It is pretty short.</p>
48+</blockquote>
49+<blockquote>
50+<p>Code in a block quote:</p>
51+<pre><code>sub status {
52+ print &quot;working&quot;;
53+}</code></pre>
54+<p>A list:</p>
55+<ol type="1">
56+<li>item one</li>
57+<li>item two</li>
58+</ol>
59+<p>Nested block quotes:</p>
60+<blockquote>
61+<p>nested</p>
62+</blockquote>
63+<blockquote>
64+<p>nested</p>
65+</blockquote>
66+</blockquote>
67+<p>This should not be a block quote: 2 &gt; 1.</p>
68+<p>And a following paragraph.</p>
69+<hr />
70+<h1 id="code-blocks">Code Blocks</h1>
71+<p>Code:</p>
72+<pre><code>---- (should be four hyphens)
73+
74+sub status {
75+ print &quot;working&quot;;
76+}
77+
78+this code block is indented by one tab</code></pre>
79+<p>And:</p>
80+<pre><code> this code block is indented by two tabs
81+
82+These should not be escaped: \$ \\ \&gt; \[ \{</code></pre>
83+<hr />
84+<h1 id="lists">Lists</h1>
85+<h2 id="unordered">Unordered</h2>
86+<p>Asterisks tight:</p>
87+<ul>
88+<li>asterisk 1</li>
89+<li>asterisk 2</li>
90+<li>asterisk 3</li>
91+</ul>
92+<p>Asterisks loose:</p>
93+<ul>
94+<li><p>asterisk 1</p></li>
95+<li><p>asterisk 2</p></li>
96+<li><p>asterisk 3</p></li>
97+</ul>
98+<p>Pluses tight:</p>
99+<ul>
100+<li>Plus 1</li>
101+<li>Plus 2</li>
102+<li>Plus 3</li>
103+</ul>
104+<p>Pluses loose:</p>
105+<ul>
106+<li><p>Plus 1</p></li>
107+<li><p>Plus 2</p></li>
108+<li><p>Plus 3</p></li>
109+</ul>
110+<p>Minuses tight:</p>
111+<ul>
112+<li>Minus 1</li>
113+<li>Minus 2</li>
114+<li>Minus 3</li>
115+</ul>
116+<p>Minuses loose:</p>
117+<ul>
118+<li><p>Minus 1</p></li>
119+<li><p>Minus 2</p></li>
120+<li><p>Minus 3</p></li>
121+</ul>
122+<h2 id="ordered">Ordered</h2>
123+<p>Tight:</p>
124+<ol type="1">
125+<li>First</li>
126+<li>Second</li>
127+<li>Third</li>
128+</ol>
129+<p>and:</p>
130+<ol type="1">
131+<li>One</li>
132+<li>Two</li>
133+<li>Three</li>
134+</ol>
135+<p>Loose using tabs:</p>
136+<ol type="1">
137+<li><p>First</p></li>
138+<li><p>Second</p></li>
139+<li><p>Third</p></li>
140+</ol>
141+<p>and using spaces:</p>
142+<ol type="1">
143+<li><p>One</p></li>
144+<li><p>Two</p></li>
145+<li><p>Three</p></li>
146+</ol>
147+<p>Multiple paragraphs:</p>
148+<ol type="1">
149+<li><p>Item 1, graf one.</p>
150+<p>Item 1. graf two. The quick brown fox jumped over the lazy dog’s back.</p></li>
151+<li><p>Item 2.</p></li>
152+<li><p>Item 3.</p></li>
153+</ol>
154+<h2 id="nested">Nested</h2>
155+<ul>
156+<li>Tab
157+<ul>
158+<li>Tab
159+<ul>
160+<li>Tab</li>
161+</ul></li>
162+</ul></li>
163+</ul>
164+<p>Here’s another:</p>
165+<ol type="1">
166+<li>First</li>
167+<li>Second:
168+<ul>
169+<li>Fee</li>
170+<li>Fie</li>
171+<li>Foe</li>
172+</ul></li>
173+<li>Third</li>
174+</ol>
175+<p>Same thing but with paragraphs:</p>
176+<ol type="1">
177+<li><p>First</p></li>
178+<li><p>Second:</p>
179+<ul>
180+<li>Fee</li>
181+<li>Fie</li>
182+<li>Foe</li>
183+</ul></li>
184+<li><p>Third</p></li>
185+</ol>
186+<h2 id="tabs-and-spaces">Tabs and spaces</h2>
187+<ul>
188+<li><p>this is a list item indented with tabs</p></li>
189+<li><p>this is a list item indented with spaces</p>
190+<ul>
191+<li><p>this is an example list item indented with tabs</p></li>
192+<li><p>this is an example list item indented with spaces</p></li>
193+</ul></li>
194+</ul>
195+<h2 id="fancy-list-markers">Fancy list markers</h2>
196+<ol start="2" type="1">
197+<li>begins with 2</li>
198+<li><p>and now 3</p>
199+<p>with a continuation</p>
200+<ol start="4" type="i">
201+<li>sublist with roman numerals, starting with 4</li>
202+<li>more items
203+<ol type="A">
204+<li>a subsublist</li>
205+<li>a subsublist</li>
206+</ol></li>
207+</ol></li>
208+</ol>
209+<p>Nesting:</p>
210+<ol type="A">
211+<li>Upper Alpha
212+<ol type="I">
213+<li>Upper Roman.
214+<ol start="6" type="1">
215+<li>Decimal start with 6
216+<ol start="3" type="a">
217+<li>Lower alpha with paren</li>
218+</ol></li>
219+</ol></li>
220+</ol></li>
221+</ol>
222+<p>Autonumbering:</p>
223+<ol>
224+<li>Autonumber.</li>
225+<li>More.
226+<ol>
227+<li>Nested.</li>
228+</ol></li>
229+</ol>
230+<p>Should not be a list item:</p>
231+<p>M.A. 2007</p>
232+<p>B. Williams</p>
233+<hr />
234+<h1 id="definition-lists">Definition Lists</h1>
235+<p>Tight using spaces:</p>
236+<dl>
237+<dt>apple</dt>
238+<dd>red fruit
239+</dd>
240+<dt>orange</dt>
241+<dd>orange fruit
242+</dd>
243+<dt>banana</dt>
244+<dd>yellow fruit
245+</dd>
246+</dl>
247+<p>Tight using tabs:</p>
248+<dl>
249+<dt>apple</dt>
250+<dd>red fruit
251+</dd>
252+<dt>orange</dt>
253+<dd>orange fruit
254+</dd>
255+<dt>banana</dt>
256+<dd>yellow fruit
257+</dd>
258+</dl>
259+<p>Loose:</p>
260+<dl>
261+<dt>apple</dt>
262+<dd><p>red fruit</p>
263+</dd>
264+<dt>orange</dt>
265+<dd><p>orange fruit</p>
266+</dd>
267+<dt>banana</dt>
268+<dd><p>yellow fruit</p>
269+</dd>
270+</dl>
271+<p>Multiple blocks with italics:</p>
272+<dl>
273+<dt><em>apple</em></dt>
274+<dd><p>red fruit</p>
275+<p>contains seeds, crisp, pleasant to taste</p>
276+</dd>
277+<dt><em>orange</em></dt>
278+<dd><p>orange fruit</p>
279+<pre><code>{ orange code block }</code></pre>
280+<blockquote>
281+<p>orange block quote</p>
282+</blockquote>
283+</dd>
284+</dl>
285+<p>Multiple definitions, tight:</p>
286+<dl>
287+<dt>apple</dt>
288+<dd>red fruit
289+</dd>
290+<dd>computer
291+</dd>
292+<dt>orange</dt>
293+<dd>orange fruit
294+</dd>
295+<dd>bank
296+</dd>
297+</dl>
298+<p>Multiple definitions, loose:</p>
299+<dl>
300+<dt>apple</dt>
301+<dd><p>red fruit</p>
302+</dd>
303+<dd><p>computer</p>
304+</dd>
305+<dt>orange</dt>
306+<dd><p>orange fruit</p>
307+</dd>
308+<dd><p>bank</p>
309+</dd>
310+</dl>
311+<p>Blank line after term, indented marker, alternate markers:</p>
312+<dl>
313+<dt>apple</dt>
314+<dd><p>red fruit</p>
315+</dd>
316+<dd><p>computer</p>
317+</dd>
318+<dt>orange</dt>
319+<dd><p>orange fruit</p>
320+<ol type="1">
321+<li>sublist</li>
322+<li>sublist</li>
323+</ol>
324+</dd>
325+</dl>
326+<h1 id="html-blocks">HTML Blocks</h1>
327+<p>Simple block on one line:</p>
328+<div>
329+foo
330+</div>
331+<p>And nested without indentation:</p>
332+<div>
333+<div>
334+<div>
335+<p>foo</p>
336+</div>
337+</div>
338+<div>
339+bar
340+</div>
341+</div>
342+<p>Interpreted markdown in a table:</p>
343+<table>
344+<tr>
345+<td>
346+This is <em>emphasized</em>
347+</td>
348+<td>
349+And this is <strong>strong</strong>
350+</td>
351+</tr>
352+</table>
353+<script type="text/javascript">document.write('This *should not* be interpreted as markdown');</script>
354+<p>Here’s a simple block:</p>
355+<div>
356+<p>foo</p>
357+</div>
358+<p>This should be a code block, though:</p>
359+<pre><code>&lt;div&gt;
360+ foo
361+&lt;/div&gt;</code></pre>
362+<p>As should this:</p>
363+<pre><code>&lt;div&gt;foo&lt;/div&gt;</code></pre>
364+<p>Now, nested:</p>
365+<div>
366+<div>
367+<div>
368+foo
369+</div>
370+</div>
371+</div>
372+<p>This should just be an HTML comment:</p>
373+<!-- Comment -->
374+<p>Multiline:</p>
375+<!--
376+Blah
377+Blah
378+-->
379+<!--
380+ This is another comment.
381+-->
382+<p>Code block:</p>
383+<pre><code>&lt;!-- Comment --&gt;</code></pre>
384+<p>Just plain comment, with trailing spaces on the line:</p>
385+<!-- foo -->
386+<p>Code:</p>
387+<pre><code>&lt;hr /&gt;</code></pre>
388+<p>Hr’s:</p>
389+<hr>
390+<hr />
391+<hr />
392+<hr>
393+<hr />
394+<hr />
395+<hr class="foo" id="bar" />
396+<hr class="foo" id="bar" />
397+<hr class="foo" id="bar">
398+<hr />
399+<h1 id="inline-markup">Inline Markup</h1>
400+<p>This is <em>emphasized</em>, and so <em>is this</em>.</p>
401+<p>This is <strong>strong</strong>, and so <strong>is this</strong>.</p>
402+<p>An <em><a href="/url">emphasized link</a></em>.</p>
403+<p><strong><em>This is strong and em.</em></strong></p>
404+<p>So is <strong><em>this</em></strong> word.</p>
405+<p><strong><em>This is strong and em.</em></strong></p>
406+<p>So is <strong><em>this</em></strong> word.</p>
407+<p>This is code: <code>&gt;</code>, <code>$</code>, <code>\</code>, <code>\$</code>, <code>&lt;html&gt;</code>.</p>
408+<p><del>This is <em>strikeout</em>.</del></p>
409+<p>Superscripts: a<sup>bc</sup>d a<sup><em>hello</em></sup> a<sup>hello there</sup>.</p>
410+<p>Subscripts: H<sub>2</sub>O, H<sub>23</sub>O, H<sub>many of them</sub>O.</p>
411+<p>These should not be superscripts or subscripts, because of the unescaped spaces: a^b c^d, a~b c~d.</p>
412+<hr />
413+<h1 id="smart-quotes-ellipses-dashes">Smart quotes, ellipses, dashes</h1>
414+<p>“Hello,” said the spider. “‘Shelob’ is my name.”</p>
415+<p>‘A’, ‘B’, and ‘C’ are letters.</p>
416+<p>‘Oak,’ ‘elm,’ and ‘beech’ are names of trees. So is ‘pine.’</p>
417+<p>‘He said, “I want to go.”’ Were you alive in the 70’s?</p>
418+<p>Here is some quoted ‘<code>code</code>’ and a “<a href="http://example.com/?foo=1&amp;bar=2">quoted link</a>”.</p>
419+<p>Some dashes: one—two — three—four — five.</p>
420+<p>Dashes between numbers: 5–7, 255–66, 1987–1999.</p>
421+<p>Ellipses…and…and….</p>
422+<hr />
423+<h1 id="latex">LaTeX</h1>
424+<ul>
425+<li></li>
426+<li><span class="math inline">2 + 2 = 4</span></li>
427+<li><span class="math inline"><em>x</em> ∈ <em>y</em></span></li>
428+<li><span class="math inline"><em>α</em> ∧ <em>ω</em></span></li>
429+<li><span class="math inline">223</span></li>
430+<li><span class="math inline"><em>p</em></span>-Tree</li>
431+<li>Here’s some display math: <br /><span class="math display">$$\frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}$$</span><br /></li>
432+<li>Here’s one that has a line break in it: <span class="math inline"><em>α</em> + <em>ω</em> × <em>x</em><sup>2</sup></span>.</li>
433+</ul>
434+<p>These shouldn’t be math:</p>
435+<ul>
436+<li>To get the famous equation, write <code>$e = mc^2$</code>.</li>
437+<li>$22,000 is a <em>lot</em> of money. So is $34,000. (It worked if “lot” is emphasized.)</li>
438+<li>Shoes ($20) and socks ($5).</li>
439+<li>Escaped <code>$</code>: $73 <em>this should be emphasized</em> 23$.</li>
440+</ul>
441+<p>Here’s a LaTeX table:</p>
442+
443+<hr />
444+<h1 id="special-characters">Special Characters</h1>
445+<p>Here is some unicode:</p>
446+<ul>
447+<li>I hat: Î</li>
448+<li>o umlaut: ö</li>
449+<li>section: §</li>
450+<li>set membership: ∈</li>
451+<li>copyright: ©</li>
452+</ul>
453+<p>AT&amp;T has an ampersand in their name.</p>
454+<p>AT&amp;T is another way to write it.</p>
455+<p>This &amp; that.</p>
456+<p>4 &lt; 5.</p>
457+<p>6 &gt; 5.</p>
458+<p>Backslash: \</p>
459+<p>Backtick: `</p>
460+<p>Asterisk: *</p>
461+<p>Underscore: _</p>
462+<p>Left brace: {</p>
463+<p>Right brace: }</p>
464+<p>Left bracket: [</p>
465+<p>Right bracket: ]</p>
466+<p>Left paren: (</p>
467+<p>Right paren: )</p>
468+<p>Greater-than: &gt;</p>
469+<p>Hash: #</p>
470+<p>Period: .</p>
471+<p>Bang: !</p>
472+<p>Plus: +</p>
473+<p>Minus: -</p>
474+<hr />
475+<h1 id="links">Links</h1>
476+<h2 id="explicit">Explicit</h2>
477+<p>Just a <a href="/url/">URL</a>.</p>
478+<p><a href="/url/" title="title">URL and title</a>.</p>
479+<p><a href="/url/" title="title preceded by two spaces">URL and title</a>.</p>
480+<p><a href="/url/" title="title preceded by a tab">URL and title</a>.</p>
481+<p><a href="/url/" title="title with &quot;quotes&quot; in it">URL and title</a></p>
482+<p><a href="/url/" title="title with single quotes">URL and title</a></p>
483+<p><a href="/url/with_underscore">with_underscore</a></p>
484+<p><a href="mailto:nobody@nowhere.net">Email link</a></p>
485+<p><a href="">Empty</a>.</p>
486+<h2 id="reference">Reference</h2>
487+<p>Foo <a href="/url/">bar</a>.</p>
488+<p>Foo <a href="/url/">bar</a>.</p>
489+<p>Foo <a href="/url/">bar</a>.</p>
490+<p>With <a href="/url/">embedded [brackets]</a>.</p>
491+<p><a href="/url/">b</a> by itself should be a link.</p>
492+<p>Indented <a href="/url">once</a>.</p>
493+<p>Indented <a href="/url">twice</a>.</p>
494+<p>Indented <a href="/url">thrice</a>.</p>
495+<p>This should [not][] be a link.</p>
496+<pre><code>[not]: /url</code></pre>
497+<p>Foo <a href="/url/" title="Title with &quot;quotes&quot; inside">bar</a>.</p>
498+<p>Foo <a href="/url/" title="Title with &quot;quote&quot; inside">biz</a>.</p>
499+<h2 id="with-ampersands">With ampersands</h2>
500+<p>Here’s a <a href="http://example.com/?foo=1&amp;bar=2">link with an ampersand in the URL</a>.</p>
501+<p>Here’s a link with an amersand in the link text: <a href="http://att.com/" title="AT&amp;T">AT&amp;T</a>.</p>
502+<p>Here’s an <a href="/script?foo=1&amp;bar=2">inline link</a>.</p>
503+<p>Here’s an <a href="/script?foo=1&amp;bar=2">inline link in pointy braces</a>.</p>
504+<h2 id="autolinks">Autolinks</h2>
505+<p>With an ampersand: <a href="http://example.com/?foo=1&amp;bar=2" class="uri">http://example.com/?foo=1&amp;bar=2</a></p>
506+<ul>
507+<li>In a list?</li>
508+<li><a href="http://example.com/" class="uri">http://example.com/</a></li>
509+<li>It should.</li>
510+</ul>
511+<p>An e-mail address: <a href="mailto:nobody@nowhere.net">nobody@nowhere.net</a></p>
512+<blockquote>
513+<p>Blockquoted: <a href="http://example.com/" class="uri">http://example.com/</a></p>
514+</blockquote>
515+<p>Auto-links should not occur here: <code>&lt;http://example.com/&gt;</code></p>
516+<pre><code>or here: &lt;http://example.com/&gt;</code></pre>
517+<hr />
518+<h1 id="images">Images</h1>
519+<p>From “Voyage dans la Lune” by Georges Melies (1902):</p>
520+<figure>
521+<img src="lalune.jpg" title="Voyage dans la Lune" alt="lalune" /><figcaption>lalune</figcaption>
522+</figure>
523+<p>Here is a movie <img src="movie.jpg" alt="movie" /> icon.</p>
524+<hr />
525+<h1 id="footnotes">Footnotes</h1>
526+<p>Here is a footnote reference,<a href="#fn1" class="footnoteRef" id="fnref1"><sup>1</sup></a> and another.<a href="#fn2" class="footnoteRef" id="fnref2"><sup>2</sup></a> This should <em>not</em> be a footnote reference, because it contains a space.[^my note] Here is an inline note.<a href="#fn3" class="footnoteRef" id="fnref3"><sup>3</sup></a></p>
527+<blockquote>
528+<p>Notes can go in quotes.<a href="#fn4" class="footnoteRef" id="fnref4"><sup>4</sup></a></p>
529+</blockquote>
530+<ol type="1">
531+<li>And in list items.<a href="#fn5" class="footnoteRef" id="fnref5"><sup>5</sup></a></li>
532+</ol>
533+<p>This paragraph should not be part of the note, as it is not indented.</p>
534+<section class="footnotes">
535+<hr />
536+<ol>
537+<li id="fn1"><p>Here is the footnote. It can go anywhere after the footnote reference. It need not be placed at the end of the document.<a href="#fnref1">↩</a></p></li>
538+<li id="fn2"><p>Here’s the long note. This one contains multiple blocks.</p>
539+<p>Subsequent blocks are indented to show that they belong to the footnote (as with list items).</p>
540+<pre><code> { &lt;code&gt; }</code></pre>
541+<p>If you want, you can indent every line, but you can also be lazy and just indent the first line of each block.<a href="#fnref2">↩</a></p></li>
542+<li id="fn3"><p>This is <em>easier</em> to type. Inline notes may contain <a href="http://google.com">links</a> and <code>]</code> verbatim characters, as well as [bracketed text].<a href="#fnref3">↩</a></p></li>
543+<li id="fn4"><p>In quote.<a href="#fnref4">↩</a></p></li>
544+<li id="fn5"><p>In list.<a href="#fnref5">↩</a></p></li>
545+</ol>
546+</section>
547+</body>
548+</html>