From 1105dd866c3d17c8be0f36b13c0fdb562ced1844 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Wed, 25 Jan 2017 21:47:07 +0100 Subject: Rename default.html template to default.html4. --- data/templates | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'data/templates') diff --git a/data/templates b/data/templates index 8519808e4..67d601119 160000 --- a/data/templates +++ b/data/templates @@ -1 +1 @@ -Subproject commit 8519808e475a379383244e093aab2326be57c3d8 +Subproject commit 67d601119928f95c525dfb2c518ec61661f1e770 -- cgit v1.2.3 From 190943e1fd75b7fa30689387e4416dd81b584f5e Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Thu, 26 Jan 2017 20:39:32 +0100 Subject: EPUB writer: split writeEPUB into writeEPUB2, writeEPUB3. Also include explicit epub2 output format in CLI tool. --- MANUAL.txt | 23 ++++++++++++----------- data/templates | 2 +- pandoc.cabal | 2 +- src/Text/Pandoc.hs | 12 +++++++----- src/Text/Pandoc/Templates.hs | 1 + src/Text/Pandoc/Writers/EPUB.hs | 31 ++++++++++++++++++++++++------- 6 files changed, 46 insertions(+), 25 deletions(-) (limited to 'data/templates') diff --git a/MANUAL.txt b/MANUAL.txt index 3b8ac2b85..91f4bacc0 100644 --- a/MANUAL.txt +++ b/MANUAL.txt @@ -101,7 +101,7 @@ If no *input-file* is specified, input is read from *stdin*. Otherwise, the *input-files* are concatenated (with a blank line between each) and used as input. Output goes to *stdout* by default (though output to *stdout* is disabled for the `odt`, `docx`, -`epub`, and `epub3` output formats). For output to a file, use the +`epub2`, and `epub3` output formats). For output to a file, use the `-o` option: pandoc -o output.html input.txt @@ -273,7 +273,7 @@ General options (original unextended Markdown), `markdown_phpextra` (PHP Markdown Extra), `markdown_github` (GitHub-Flavored Markdown), `markdown_mmd` (MultiMarkdown), `commonmark` (CommonMark Markdown), `rst` - (reStructuredText), `html` (XHTML), `html5` (HTML5), `latex` + (reStructuredText), `html4` (XHTML4), `html` or `html5` (HTML5), `latex` (LaTeX), `beamer` (LaTeX beamer slide show), `context` (ConTeXt), `man` (groff man), `mediawiki` (MediaWiki markup), `dokuwiki` (DokuWiki markup), `zimwiki` (ZimWiki markup), @@ -281,7 +281,7 @@ General options `texinfo` (GNU Texinfo), `opml` (OPML), `docbook` (DocBook 4), `docbook5` (DocBook 5), `opendocument` (OpenDocument), `odt` (OpenOffice text document), `docx` (Word docx), `haddock` - (Haddock markup), `rtf` (rich text format), `epub` (EPUB v2 + (Haddock markup), `rtf` (rich text format), `epub` or `epub2` (EPUB v2 book), `epub3` (EPUB v3), `fb2` (FictionBook2 e-book), `asciidoc` (AsciiDoc), `icml` (InDesign ICML), `tei` (TEI Simple), `slidy` (Slidy HTML and JavaScript slide show), @@ -293,7 +293,7 @@ General options `epub`, and `epub3` output will not be directed to *stdout*; an output filename must be specified using the `-o/--output` option. If `+lhs` is appended to `markdown`, `rst`, `latex`, - `beamer`, `html`, or `html5`, the output will be rendered as + `beamer`, `html4`, or `html5`, the output will be rendered as literate Haskell source: see [Literate Haskell support], below. Markdown syntax extensions can be individually enabled or disabled by appending `+EXTENSION` or @@ -626,7 +626,7 @@ Options affecting specific writers images, and videos. The resulting file should be "self-contained," in the sense that it needs no external files and no net access to be displayed properly by a browser. This option works only with HTML output - formats, including `html`, `html5`, `html+lhs`, `html5+lhs`, `s5`, + formats, including `html4`, `html5`, `html+lhs`, `html5+lhs`, `s5`, `slidy`, `slideous`, `dzslides`, and `revealjs`. Scripts, images, and stylesheets at absolute URLs will be downloaded; those at relative URLs will be sought relative to the working directory (if the first source @@ -947,10 +947,11 @@ Math rendering in HTML `--mathml`[`=`*URL*] -: Convert TeX math to [MathML] (in `docbook`, `docbook5`, `html` and `html5`). - In standalone `html` output, a small JavaScript (or a link to such a - script if a *URL* is supplied) will be inserted that allows the MathML to - be viewed on some browsers. +: Convert TeX math to [MathML] (in `docbook`, `docbook5`, + `html4` and `html5`). In standalone HTML output, a small + JavaScript (or a link to such a script if a *URL* is + supplied) will be inserted that allows the MathML to be + viewed on some browsers. `--jsmath`[`=`*URL*] @@ -1647,7 +1648,7 @@ Note, however, that this method of providing links to sections works only in HTML, LaTeX, and ConTeXt formats. If the `--section-divs` option is specified, then each section will -be wrapped in a `div` (or a `section`, if `--html5` was specified), +be wrapped in a `div` (or a `section`, if `html5` was specified), and the identifier will be attached to the enclosing `
` (or `
`) tag rather than the header itself. This allows entire sections to be manipulated using JavaScript or treated differently in @@ -3891,7 +3892,7 @@ Literate Haskell support If you append `+lhs` (or `+literate_haskell`) to an appropriate input or output format (`markdown`, `markdown_strict`, `rst`, or `latex` for input or output; -`beamer`, `html` or `html5` for output only), pandoc will treat the document as +`beamer`, `html4` or `html5` for output only), pandoc will treat the document as literate Haskell source. This means that - In Markdown input, "bird track" sections will be parsed as Haskell diff --git a/data/templates b/data/templates index 67d601119..335360e40 160000 --- a/data/templates +++ b/data/templates @@ -1 +1 @@ -Subproject commit 67d601119928f95c525dfb2c518ec61661f1e770 +Subproject commit 335360e40c5cd395b33954906144c834783b41fd diff --git a/pandoc.cabal b/pandoc.cabal index 97e70c830..341ab5a12 100644 --- a/pandoc.cabal +++ b/pandoc.cabal @@ -66,7 +66,7 @@ Data-Files: data/templates/default.haddock data/templates/default.textile data/templates/default.org - data/templates/default.epub + data/templates/default.epub2 data/templates/default.epub3 -- source files for reference.docx data/docx/[Content_Types].xml diff --git a/src/Text/Pandoc.hs b/src/Text/Pandoc.hs index aa4cab840..449cab120 100644 --- a/src/Text/Pandoc.hs +++ b/src/Text/Pandoc.hs @@ -115,7 +115,8 @@ module Text.Pandoc , writeRTF , writeODT , writeDocx - , writeEPUB + , writeEPUB2 + , writeEPUB3 , writeFB2 , writeOrg , writeAsciiDoc @@ -278,10 +279,9 @@ writers = [ ,("json" , StringWriter $ \o d -> return $ writeJSON o d) ,("docx" , ByteStringWriter writeDocx) ,("odt" , ByteStringWriter writeODT) - ,("epub" , ByteStringWriter $ \o -> - writeEPUB o{ writerEpubVersion = Just EPUB2 }) - ,("epub3" , ByteStringWriter $ \o -> - writeEPUB o{ writerEpubVersion = Just EPUB3 }) + ,("epub" , ByteStringWriter writeEPUB2) + ,("epub2" , ByteStringWriter writeEPUB2) + ,("epub3" , ByteStringWriter writeEPUB3) ,("fb2" , StringWriter writeFB2) ,("html" , StringWriter writeHtml5String) ,("html4" , StringWriter writeHtml4String) @@ -349,6 +349,8 @@ getDefaultExtensions "epub" = extensionsFromList Ext_native_divs, Ext_native_spans, Ext_epub_html_exts] +getDefaultExtensions "epub2" = getDefaultExtensions "epub" +getDefaultExtensions "epub3" = getDefaultExtensions "epub" getDefaultExtensions "latex" = extensionsFromList [Ext_smart, Ext_auto_identifiers] diff --git a/src/Text/Pandoc/Templates.hs b/src/Text/Pandoc/Templates.hs index 03dc917e6..38d956f1f 100644 --- a/src/Text/Pandoc/Templates.hs +++ b/src/Text/Pandoc/Templates.hs @@ -61,6 +61,7 @@ getDefaultTemplate user writer = do "fb2" -> return $ Right "" "odt" -> getDefaultTemplate user "opendocument" "html" -> getDefaultTemplate user "html5" + "epub" -> getDefaultTemplate user "epub2" "markdown_strict" -> getDefaultTemplate user "markdown" "multimarkdown" -> getDefaultTemplate user "markdown" "markdown_github" -> getDefaultTemplate user "markdown" diff --git a/src/Text/Pandoc/Writers/EPUB.hs b/src/Text/Pandoc/Writers/EPUB.hs index bd95c170e..c2fc4422e 100644 --- a/src/Text/Pandoc/Writers/EPUB.hs +++ b/src/Text/Pandoc/Writers/EPUB.hs @@ -28,7 +28,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Conversion of 'Pandoc' documents to EPUB. -} -module Text.Pandoc.Writers.EPUB ( writeEPUB ) where +module Text.Pandoc.Writers.EPUB ( writeEPUB2, writeEPUB3 ) where import qualified Data.Map as M import qualified Data.Set as Set import Data.Maybe ( fromMaybe, catMaybes ) @@ -75,8 +75,9 @@ import qualified Text.Pandoc.Class as P -- in filenames, chapter0003.xhtml. data Chapter = Chapter (Maybe [Int]) [Block] -data EPUBState = EPUBState { stMediaPaths :: [(FilePath, (FilePath, Maybe Entry))] - } +data EPUBState = EPUBState { + stMediaPaths :: [(FilePath, (FilePath, Maybe Entry))] + } type E m = StateT EPUBState m @@ -336,16 +337,32 @@ metadataFromMeta opts meta = EPUBMetadata{ Just "rtl" -> Just RTL _ -> Nothing +-- | Produce an EPUB2 file from a Pandoc document. +writeEPUB2 :: PandocMonad m + => WriterOptions -- ^ Writer options + -> Pandoc -- ^ Document to convert + -> m B.ByteString +writeEPUB2 = writeEPUB EPUB2 + +-- | Produce an EPUB3 file from a Pandoc document. +writeEPUB3 :: PandocMonad m + => WriterOptions -- ^ Writer options + -> Pandoc -- ^ Document to convert + -> m B.ByteString +writeEPUB3 = writeEPUB EPUB3 + -- | Produce an EPUB file from a Pandoc document. writeEPUB :: PandocMonad m - => WriterOptions -- ^ Writer options + => EPUBVersion + -> WriterOptions -- ^ Writer options -> Pandoc -- ^ Document to convert -> m B.ByteString -writeEPUB opts doc = +writeEPUB epubVersion opts doc = let initState = EPUBState { stMediaPaths = [] } in - evalStateT (pandocToEPUB opts doc) initState + evalStateT (pandocToEPUB opts{ writerEpubVersion = Just epubVersion } doc) + initState pandocToEPUB :: PandocMonad m => WriterOptions @@ -353,7 +370,7 @@ pandocToEPUB :: PandocMonad m -> E m B.ByteString pandocToEPUB opts doc@(Pandoc meta _) = do let version = fromMaybe EPUB2 (writerEpubVersion opts) - let epub3 = version == EPUB3 + let epub3 = writerEpubVersion opts == Just EPUB3 epochtime <- floor <$> lift P.getPOSIXTime let mkEntry path content = toEntry path epochtime content let vars = ("epub3", if epub3 then "true" else "false") -- cgit v1.2.3 From b6c1d491f5379f1924657f525540766dbbc1ae0f Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Thu, 26 Jan 2017 22:40:57 +0100 Subject: Split writeDocbook into writeDocbook4, writeDocbook5. Removed writerDocbookVersion in WriterOptions. Renamed default.docbook template to default.docbook4. Allow docbook4 as an output format. But alias docbook = docbook4. --- MANUAL.txt | 10 +- data/templates | 2 +- pandoc.cabal | 6 +- src/Text/Pandoc.hs | 9 +- src/Text/Pandoc/Options.hs | 2 - src/Text/Pandoc/Templates.hs | 15 +- src/Text/Pandoc/Writers/Docbook.hs | 62 +- tests/Tests/Old.hs | 2 +- tests/Tests/Writers/Docbook.hs | 2 +- tests/tables.docbook | 432 ----------- tests/tables.docbook4 | 432 +++++++++++ tests/writer.docbook | 1422 ------------------------------------ tests/writer.docbook4 | 1422 ++++++++++++++++++++++++++++++++++++ 13 files changed, 1918 insertions(+), 1900 deletions(-) delete mode 100644 tests/tables.docbook create mode 100644 tests/tables.docbook4 delete mode 100644 tests/writer.docbook create mode 100644 tests/writer.docbook4 (limited to 'data/templates') diff --git a/MANUAL.txt b/MANUAL.txt index 91f4bacc0..5d14773a5 100644 --- a/MANUAL.txt +++ b/MANUAL.txt @@ -278,9 +278,9 @@ General options `man` (groff man), `mediawiki` (MediaWiki markup), `dokuwiki` (DokuWiki markup), `zimwiki` (ZimWiki markup), `textile` (Textile), `org` (Emacs Org mode), - `texinfo` (GNU Texinfo), `opml` (OPML), `docbook` (DocBook 4), - `docbook5` (DocBook 5), `opendocument` (OpenDocument), `odt` - (OpenOffice text document), `docx` (Word docx), `haddock` + `texinfo` (GNU Texinfo), `opml` (OPML), `docbook` or `docbook4` + (DocBook 4), `docbook5` (DocBook 5), `opendocument` (OpenDocument), + `odt` (OpenOffice text document), `docx` (Word docx), `haddock` (Haddock markup), `rtf` (rich text format), `epub` or `epub2` (EPUB v2 book), `epub3` (EPUB v3), `fb2` (FictionBook2 e-book), `asciidoc` (AsciiDoc), `icml` (InDesign ICML), `tei` (TEI @@ -569,7 +569,7 @@ General writer options : Include an automatically generated table of contents (or, in the case of `latex`, `context`, `docx`, and `rst`, an instruction to create one) in the output document. This option has no effect on `man`, - `docbook`, `docbook5`, `slidy`, `slideous`, `s5`, or `odt` output. + `docbook4`, `docbook5`, `slidy`, `slideous`, `s5`, or `odt` output. `--toc-depth=`*NUMBER* @@ -947,7 +947,7 @@ Math rendering in HTML `--mathml`[`=`*URL*] -: Convert TeX math to [MathML] (in `docbook`, `docbook5`, +: Convert TeX math to [MathML] (in `docbook4`, `docbook5`, `html4` and `html5`). In standalone HTML output, a small JavaScript (or a link to such a script if a *URL* is supplied) will be inserted that allows the MathML to be diff --git a/data/templates b/data/templates index 335360e40..c4ba8bab6 160000 --- a/data/templates +++ b/data/templates @@ -1 +1 @@ -Subproject commit 335360e40c5cd395b33954906144c834783b41fd +Subproject commit c4ba8bab6248f8999e520547f1c45f10de85db9d diff --git a/pandoc.cabal b/pandoc.cabal index 341ab5a12..194332619 100644 --- a/pandoc.cabal +++ b/pandoc.cabal @@ -38,7 +38,7 @@ Data-Files: -- templates data/templates/default.html4 data/templates/default.html5 - data/templates/default.docbook + data/templates/default.docbook4 data/templates/default.docbook5 data/templates/default.tei data/templates/default.beamer @@ -145,7 +145,7 @@ Extra-Source-Files: tests/s5-fragment.html tests/s5-inserts.html tests/tables.context - tests/tables.docbook + tests/tables.docbook4 tests/tables.docbook5 tests/tables.dokuwiki tests/tables.zimwiki @@ -171,7 +171,7 @@ Extra-Source-Files: tests/testsuite.txt tests/writer.latex tests/writer.context - tests/writer.docbook + tests/writer.docbook4 tests/writer.docbook5 tests/writer.html4 tests/writer.html5 diff --git a/src/Text/Pandoc.hs b/src/Text/Pandoc.hs index 449cab120..ea625ffa1 100644 --- a/src/Text/Pandoc.hs +++ b/src/Text/Pandoc.hs @@ -104,7 +104,8 @@ module Text.Pandoc , writeHtml5 , writeHtml5String , writeICML - , writeDocbook + , writeDocbook4 + , writeDocbook5 , writeOPML , writeOpenDocument , writeMan @@ -298,9 +299,9 @@ writers = [ writeHtml5String o{ writerSlideVariant = DZSlides }) ,("revealjs" , StringWriter $ \o -> writeHtml5String o{ writerSlideVariant = RevealJsSlides }) - ,("docbook" , StringWriter writeDocbook) - ,("docbook5" , StringWriter $ \o -> - writeDocbook o{ writerDocbook5 = True }) + ,("docbook" , StringWriter writeDocbook5) + ,("docbook4" , StringWriter writeDocbook4) + ,("docbook5" , StringWriter writeDocbook5) ,("opml" , StringWriter writeOPML) ,("opendocument" , StringWriter writeOpenDocument) ,("latex" , StringWriter writeLaTeX) diff --git a/src/Text/Pandoc/Options.hs b/src/Text/Pandoc/Options.hs index 6cb2d883a..39fee298d 100644 --- a/src/Text/Pandoc/Options.hs +++ b/src/Text/Pandoc/Options.hs @@ -167,7 +167,6 @@ data WriterOptions = WriterOptions , writerSourceURL :: Maybe String -- ^ Absolute URL + directory of 1st source file , writerUserDataDir :: Maybe FilePath -- ^ Path of user data directory , writerCiteMethod :: CiteMethod -- ^ How to print cites - , writerDocbook5 :: Bool -- ^ Produce DocBook5 , writerHtmlQTags :: Bool -- ^ Use @@ tags for quotes in HTML , writerBeamer :: Bool -- ^ Produce beamer LaTeX slide show , writerSlideLevel :: Maybe Int -- ^ Force header level of slides @@ -208,7 +207,6 @@ instance Default WriterOptions where , writerSourceURL = Nothing , writerUserDataDir = Nothing , writerCiteMethod = Citeproc - , writerDocbook5 = False , writerHtmlQTags = False , writerBeamer = False , writerSlideLevel = Nothing diff --git a/src/Text/Pandoc/Templates.hs b/src/Text/Pandoc/Templates.hs index 38d956f1f..ddb073409 100644 --- a/src/Text/Pandoc/Templates.hs +++ b/src/Text/Pandoc/Templates.hs @@ -55,13 +55,14 @@ getDefaultTemplate :: (Maybe FilePath) -- ^ User data directory to search first getDefaultTemplate user writer = do let format = takeWhile (`notElem` ("+-" :: String)) writer -- strip off extensions case format of - "native" -> return $ Right "" - "json" -> return $ Right "" - "docx" -> return $ Right "" - "fb2" -> return $ Right "" - "odt" -> getDefaultTemplate user "opendocument" - "html" -> getDefaultTemplate user "html5" - "epub" -> getDefaultTemplate user "epub2" + "native" -> return $ Right "" + "json" -> return $ Right "" + "docx" -> return $ Right "" + "fb2" -> return $ Right "" + "odt" -> getDefaultTemplate user "opendocument" + "html" -> getDefaultTemplate user "html5" + "docbook" -> getDefaultTemplate user "docbook5" + "epub" -> getDefaultTemplate user "epub2" "markdown_strict" -> getDefaultTemplate user "markdown" "multimarkdown" -> getDefaultTemplate user "markdown" "markdown_github" -> getDefaultTemplate user "markdown" diff --git a/src/Text/Pandoc/Writers/Docbook.hs b/src/Text/Pandoc/Writers/Docbook.hs index 32695e128..53618d173 100644 --- a/src/Text/Pandoc/Writers/Docbook.hs +++ b/src/Text/Pandoc/Writers/Docbook.hs @@ -28,7 +28,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Conversion of 'Pandoc' documents to Docbook XML. -} -module Text.Pandoc.Writers.Docbook ( writeDocbook) where +module Text.Pandoc.Writers.Docbook ( writeDocbook4, writeDocbook5 ) where import Text.Pandoc.Definition import Text.Pandoc.XML import Text.Pandoc.Shared @@ -48,9 +48,15 @@ import Text.TeXMath import qualified Text.XML.Light as Xml import Data.Generics (everywhere, mkT) import Text.Pandoc.Class (PandocMonad) +import Control.Monad.Reader + +data DocBookVersion = DocBook4 | DocBook5 + deriving (Eq, Show) + +type DB = ReaderT DocBookVersion -- | Convert list of authors to a docbook section -authorToDocbook :: PandocMonad m => WriterOptions -> [Inline] -> m B.Inlines +authorToDocbook :: PandocMonad m => WriterOptions -> [Inline] -> DB m B.Inlines authorToDocbook opts name' = do name <- render Nothing <$> inlinesToDocbook opts name' let colwidth = if writerWrapText opts == WrapAuto @@ -73,8 +79,16 @@ authorToDocbook opts name' = do in inTagsSimple "firstname" (text $ escapeStringForXML firstname) $$ inTagsSimple "surname" (text $ escapeStringForXML lastname) +writeDocbook4 :: PandocMonad m => WriterOptions -> Pandoc -> m String +writeDocbook4 opts d = + runReaderT (writeDocbook opts d) DocBook4 + +writeDocbook5 :: PandocMonad m => WriterOptions -> Pandoc -> m String +writeDocbook5 opts d = + runReaderT (writeDocbook opts d) DocBook5 + -- | Convert Pandoc document to string in Docbook format. -writeDocbook :: PandocMonad m => WriterOptions -> Pandoc -> m String +writeDocbook :: PandocMonad m => WriterOptions -> Pandoc -> DB m String writeDocbook opts (Pandoc meta blocks) = do let elements = hierarchicalize blocks let colwidth = if writerWrapText opts == WrapAuto @@ -100,7 +114,7 @@ writeDocbook opts (Pandoc meta blocks) = do hierarchicalize)) (fmap (render colwidth) . inlinesToDocbook opts') meta' - main <- (render' . vcat) <$> mapM (elementToDocbook opts' startLvl) elements + main <- (render' . vcat) <$> (mapM (elementToDocbook opts' startLvl) elements) let context = defField "body" main $ defField "mathml" (case writerHTMLMathMethod opts of MathML _ -> True @@ -111,9 +125,10 @@ writeDocbook opts (Pandoc meta blocks) = do Just tpl -> renderTemplate' tpl context -- | Convert an Element to Docbook. -elementToDocbook :: PandocMonad m => WriterOptions -> Int -> Element -> m Doc +elementToDocbook :: PandocMonad m => WriterOptions -> Int -> Element -> DB m Doc elementToDocbook opts _ (Blk block) = blockToDocbook opts block elementToDocbook opts lvl (Sec _ _num (id',_,_) title elements) = do + version <- ask -- Docbook doesn't allow sections with no content, so insert some if needed let elements' = if null elements then [Blk (Para [])] @@ -121,15 +136,15 @@ elementToDocbook opts lvl (Sec _ _num (id',_,_) title elements) = do tag = case lvl of -1 -> "part" 0 -> "chapter" - n | n >= 1 && n <= 5 -> if writerDocbook5 opts + n | n >= 1 && n <= 5 -> if version == DocBook5 then "section" else "sect" ++ show n _ -> "simplesect" - idName = if writerDocbook5 opts + idName = if version == DocBook5 then "xml:id" else "id" idAttr = [(idName, writerIdentifierPrefix opts ++ id') | not (null id')] - nsAttr = if writerDocbook5 opts && lvl == 0 then [("xmlns", "http://docbook.org/ns/docbook"),("xmlns:xlink", "http://www.w3.org/1999/xlink")] + nsAttr = if version == DocBook5 && lvl == 0 then [("xmlns", "http://docbook.org/ns/docbook"),("xmlns:xlink", "http://www.w3.org/1999/xlink")] else [] attribs = nsAttr ++ idAttr contents <- mapM (elementToDocbook opts (lvl + 1)) elements' @@ -138,7 +153,7 @@ elementToDocbook opts lvl (Sec _ _num (id',_,_) title elements) = do inTagsSimple "title" title' $$ vcat contents -- | Convert a list of Pandoc blocks to Docbook. -blocksToDocbook :: PandocMonad m => WriterOptions -> [Block] -> m Doc +blocksToDocbook :: PandocMonad m => WriterOptions -> [Block] -> DB m Doc blocksToDocbook opts = fmap vcat . mapM (blockToDocbook opts) -- | Auxiliary function to convert Plain block to Para. @@ -149,13 +164,13 @@ plainToPara x = x -- | Convert a list of pairs of terms and definitions into a list of -- Docbook varlistentrys. deflistItemsToDocbook :: PandocMonad m - => WriterOptions -> [([Inline],[[Block]])] -> m Doc + => WriterOptions -> [([Inline],[[Block]])] -> DB m Doc deflistItemsToDocbook opts items = vcat <$> mapM (\(term, defs) -> deflistItemToDocbook opts term defs) items -- | Convert a term and a list of blocks into a Docbook varlistentry. deflistItemToDocbook :: PandocMonad m - => WriterOptions -> [Inline] -> [[Block]] -> m Doc + => WriterOptions -> [Inline] -> [[Block]] -> DB m Doc deflistItemToDocbook opts term defs = do term' <- inlinesToDocbook opts term def' <- blocksToDocbook opts $ concatMap (map plainToPara) defs @@ -164,11 +179,11 @@ deflistItemToDocbook opts term defs = do inTagsIndented "listitem" def' -- | Convert a list of lists of blocks to a list of Docbook list items. -listItemsToDocbook :: PandocMonad m => WriterOptions -> [[Block]] -> m Doc +listItemsToDocbook :: PandocMonad m => WriterOptions -> [[Block]] -> DB m Doc listItemsToDocbook opts items = vcat <$> mapM (listItemToDocbook opts) items -- | Convert a list of blocks into a Docbook list item. -listItemToDocbook :: PandocMonad m => WriterOptions -> [Block] -> m Doc +listItemToDocbook :: PandocMonad m => WriterOptions -> [Block] -> DB m Doc listItemToDocbook opts item = inTagsIndented "listitem" <$> blocksToDocbook opts (map plainToPara item) @@ -182,7 +197,7 @@ imageToDocbook _ attr src = selfClosingTag "imagedata" $ Nothing -> [] -- | Convert a Pandoc block element to Docbook. -blockToDocbook :: PandocMonad m => WriterOptions -> Block -> m Doc +blockToDocbook :: PandocMonad m => WriterOptions -> Block -> DB m Doc blockToDocbook _ Null = return empty -- Add ids to paragraphs in divs with ids - this is needed for -- pandoc-citeproc to get link anchors in bibliographies: @@ -260,9 +275,11 @@ blockToDocbook opts (OrderedList (start, numstyle, _) (first:rest)) = do blockToDocbook opts (DefinitionList lst) = do let attribs = [("spacing", "compact") | isTightList $ concatMap snd lst] inTags True "variablelist" attribs <$> deflistItemsToDocbook opts lst -blockToDocbook opts (RawBlock f str) +blockToDocbook _ (RawBlock f str) | f == "docbook" = return $ text str -- raw XML block - | f == "html" = if writerDocbook5 opts + | f == "html" = do + version <- ask + if version == DocBook5 then return empty -- No html in Docbook5 else return $ text str -- allow html for backwards compatibility | otherwise = return empty @@ -306,23 +323,23 @@ alignmentToString alignment = case alignment of tableRowToDocbook :: PandocMonad m => WriterOptions -> [[Block]] - -> m Doc + -> DB m Doc tableRowToDocbook opts cols = (inTagsIndented "row" . vcat) <$> mapM (tableItemToDocbook opts) cols tableItemToDocbook :: PandocMonad m => WriterOptions -> [Block] - -> m Doc + -> DB m Doc tableItemToDocbook opts item = (inTags True "entry" [] . vcat) <$> mapM (blockToDocbook opts) item -- | Convert a list of inline elements to Docbook. -inlinesToDocbook :: PandocMonad m => WriterOptions -> [Inline] -> m Doc +inlinesToDocbook :: PandocMonad m => WriterOptions -> [Inline] -> DB m Doc inlinesToDocbook opts lst = hcat <$> mapM (inlineToDocbook opts) lst -- | Convert an inline element to Docbook. -inlineToDocbook :: PandocMonad m => WriterOptions -> Inline -> m Doc +inlineToDocbook :: PandocMonad m => WriterOptions -> Inline -> DB m Doc inlineToDocbook _ (Str str) = return $ text $ escapeStringForXML str inlineToDocbook opts (Emph lst) = inTagsSimple "emphasis" <$> inlinesToDocbook opts lst @@ -385,10 +402,11 @@ inlineToDocbook opts (Link attr txt (src, _)) _ -> do contents <- inlinesToDocbook opts txt return $ contents <+> char '(' <> emailLink <> char ')' - | otherwise = + | otherwise = do + version <- ask (if isPrefixOf "#" src then inTags False "link" $ ("linkend", drop 1 src) : idAndRole attr - else if writerDocbook5 opts + else if version == DocBook5 then inTags False "link" $ ("xlink:href", src) : idAndRole attr else inTags False "ulink" $ ("url", src) : idAndRole attr ) <$> inlinesToDocbook opts txt diff --git a/tests/Tests/Old.hs b/tests/Tests/Old.hs index a46ac2260..f22636747 100644 --- a/tests/Tests/Old.hs +++ b/tests/Tests/Old.hs @@ -99,7 +99,7 @@ tests = [ testGroup "markdown" "textile-reader.textile" "textile-reader.native" ] , testGroup "docbook" - [ testGroup "writer" $ writerTests "docbook" + [ testGroup "writer" $ writerTests "docbook4" , test "reader" ["-r", "docbook", "-w", "native", "-s"] "docbook-reader.docbook" "docbook-reader.native" , test "reader" ["-r", "docbook", "-w", "native", "-s"] diff --git a/tests/Tests/Writers/Docbook.hs b/tests/Tests/Writers/Docbook.hs index adf6e9050..f34f2495c 100644 --- a/tests/Tests/Writers/Docbook.hs +++ b/tests/Tests/Writers/Docbook.hs @@ -11,7 +11,7 @@ docbook :: (ToPandoc a) => a -> String docbook = docbookWithOpts def{ writerWrapText = WrapNone } docbookWithOpts :: ToPandoc a => WriterOptions -> a -> String -docbookWithOpts opts = purely (writeDocbook opts) . toPandoc +docbookWithOpts opts = purely (writeDocbook4 opts) . toPandoc {- "my test" =: X =?> Y diff --git a/tests/tables.docbook b/tests/tables.docbook deleted file mode 100644 index f86b1c390..000000000 --- a/tests/tables.docbook +++ /dev/null @@ -1,432 +0,0 @@ - - Simple table with caption: - - - - Demonstration of simple table syntax. - - - - - - - - - - Right - - - Left - - - Center - - - Default - - - - - - - 12 - - - 12 - - - 12 - - - 12 - - - - - 123 - - - 123 - - - 123 - - - 123 - - - - - 1 - - - 1 - - - 1 - - - 1 - - - - -
- - Simple table without caption: - - - - - - - - - - - Right - - - Left - - - Center - - - Default - - - - - - - 12 - - - 12 - - - 12 - - - 12 - - - - - 123 - - - 123 - - - 123 - - - 123 - - - - - 1 - - - 1 - - - 1 - - - 1 - - - - - - - Simple table indented two spaces: - - - - Demonstration of simple table syntax. - - - - - - - - - - Right - - - Left - - - Center - - - Default - - - - - - - 12 - - - 12 - - - 12 - - - 12 - - - - - 123 - - - 123 - - - 123 - - - 123 - - - - - 1 - - - 1 - - - 1 - - - 1 - - - - -
- - Multiline table with caption: - - - - Here’s the caption. It may span multiple lines. - - - - - - - - - - Centered Header - - - Left Aligned - - - Right Aligned - - - Default aligned - - - - - - - First - - - row - - - 12.0 - - - Example of a row that spans multiple lines. - - - - - Second - - - row - - - 5.0 - - - Here’s another one. Note the blank line between rows. - - - - -
- - Multiline table without caption: - - - - - - - - - - - Centered Header - - - Left Aligned - - - Right Aligned - - - Default aligned - - - - - - - First - - - row - - - 12.0 - - - Example of a row that spans multiple lines. - - - - - Second - - - row - - - 5.0 - - - Here’s another one. Note the blank line between rows. - - - - - - - Table without column headers: - - - - - - - - - - - 12 - - - 12 - - - 12 - - - 12 - - - - - 123 - - - 123 - - - 123 - - - 123 - - - - - 1 - - - 1 - - - 1 - - - 1 - - - - - - - Multiline table without column headers: - - - - - - - - - - - First - - - row - - - 12.0 - - - Example of a row that spans multiple lines. - - - - - Second - - - row - - - 5.0 - - - Here’s another one. Note the blank line between rows. - - - - - diff --git a/tests/tables.docbook4 b/tests/tables.docbook4 new file mode 100644 index 000000000..f86b1c390 --- /dev/null +++ b/tests/tables.docbook4 @@ -0,0 +1,432 @@ + + Simple table with caption: + + + + Demonstration of simple table syntax. + + + + + + + + + + Right + + + Left + + + Center + + + Default + + + + + + + 12 + + + 12 + + + 12 + + + 12 + + + + + 123 + + + 123 + + + 123 + + + 123 + + + + + 1 + + + 1 + + + 1 + + + 1 + + + + +
+ + Simple table without caption: + + + + + + + + + + + Right + + + Left + + + Center + + + Default + + + + + + + 12 + + + 12 + + + 12 + + + 12 + + + + + 123 + + + 123 + + + 123 + + + 123 + + + + + 1 + + + 1 + + + 1 + + + 1 + + + + + + + Simple table indented two spaces: + + + + Demonstration of simple table syntax. + + + + + + + + + + Right + + + Left + + + Center + + + Default + + + + + + + 12 + + + 12 + + + 12 + + + 12 + + + + + 123 + + + 123 + + + 123 + + + 123 + + + + + 1 + + + 1 + + + 1 + + + 1 + + + + +
+ + Multiline table with caption: + + + + Here’s the caption. It may span multiple lines. + + + + + + + + + + Centered Header + + + Left Aligned + + + Right Aligned + + + Default aligned + + + + + + + First + + + row + + + 12.0 + + + Example of a row that spans multiple lines. + + + + + Second + + + row + + + 5.0 + + + Here’s another one. Note the blank line between rows. + + + + +
+ + Multiline table without caption: + + + + + + + + + + + Centered Header + + + Left Aligned + + + Right Aligned + + + Default aligned + + + + + + + First + + + row + + + 12.0 + + + Example of a row that spans multiple lines. + + + + + Second + + + row + + + 5.0 + + + Here’s another one. Note the blank line between rows. + + + + + + + Table without column headers: + + + + + + + + + + + 12 + + + 12 + + + 12 + + + 12 + + + + + 123 + + + 123 + + + 123 + + + 123 + + + + + 1 + + + 1 + + + 1 + + + 1 + + + + + + + Multiline table without column headers: + + + + + + + + + + + First + + + row + + + 12.0 + + + Example of a row that spans multiple lines. + + + + + Second + + + row + + + 5.0 + + + Here’s another one. Note the blank line between rows. + + + + + diff --git a/tests/writer.docbook b/tests/writer.docbook deleted file mode 100644 index eee19cdd9..000000000 --- a/tests/writer.docbook +++ /dev/null @@ -1,1422 +0,0 @@ - - -
- - Pandoc Test Suite - - - John - MacFarlane - - - - Anonymous - - - July 17, 2006 - - - This is a set of tests for pandoc. Most of them are adapted from John - Gruber’s markdown test suite. - - - Headers - - Level 2 with an <ulink url="/url">embedded link</ulink> - - Level 3 with <emphasis>emphasis</emphasis> - - Level 4 - - Level 5 - - - - - - - - - Level 1 - - Level 2 with <emphasis>emphasis</emphasis> - - Level 3 - - with no blank line - - - - - Level 2 - - with no blank line - - - - - Paragraphs - - Here’s a regular paragraph. - - - 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. - - - Here’s one with a bullet. * criminey. - -There should be a hard line break -here. - - - Block Quotes - - E-mail style: - -
- - This is a block quote. It is pretty short. - -
-
- - Code in a block quote: - - -sub status { - print "working"; -} - - - A list: - - - - - item one - - - - - item two - - - - - Nested block quotes: - -
- - nested - -
-
- - nested - -
-
- - This should not be a block quote: 2 > 1. - - - And a following paragraph. - -
- - Code Blocks - - Code: - - ----- (should be four hyphens) - -sub status { - print "working"; -} - -this code block is indented by one tab - - - And: - - - this code block is indented by two tabs - -These should not be escaped: \$ \\ \> \[ \{ - - - - Lists - - Unordered - - Asterisks tight: - - - - - asterisk 1 - - - - - asterisk 2 - - - - - asterisk 3 - - - - - Asterisks loose: - - - - - asterisk 1 - - - - - asterisk 2 - - - - - asterisk 3 - - - - - Pluses tight: - - - - - Plus 1 - - - - - Plus 2 - - - - - Plus 3 - - - - - Pluses loose: - - - - - Plus 1 - - - - - Plus 2 - - - - - Plus 3 - - - - - Minuses tight: - - - - - Minus 1 - - - - - Minus 2 - - - - - Minus 3 - - - - - Minuses loose: - - - - - Minus 1 - - - - - Minus 2 - - - - - Minus 3 - - - - - - Ordered - - Tight: - - - - - First - - - - - Second - - - - - Third - - - - - and: - - - - - One - - - - - Two - - - - - Three - - - - - Loose using tabs: - - - - - First - - - - - Second - - - - - Third - - - - - and using spaces: - - - - - One - - - - - Two - - - - - Three - - - - - Multiple paragraphs: - - - - - Item 1, graf one. - - - Item 1. graf two. The quick brown fox jumped over the lazy dog’s - back. - - - - - Item 2. - - - - - Item 3. - - - - - - Nested - - - - Tab - - - - - Tab - - - - - Tab - - - - - - - - - Here’s another: - - - - - First - - - - - Second: - - - - - Fee - - - - - Fie - - - - - Foe - - - - - - - Third - - - - - Same thing but with paragraphs: - - - - - First - - - - - Second: - - - - - Fee - - - - - Fie - - - - - Foe - - - - - - - Third - - - - - - Tabs and spaces - - - - this is a list item indented with tabs - - - - - this is a list item indented with spaces - - - - - this is an example list item indented with tabs - - - - - this is an example list item indented with spaces - - - - - - - - Fancy list markers - - - - begins with 2 - - - - - and now 3 - - - with a continuation - - - - - sublist with roman numerals, starting with 4 - - - - - more items - - - - - a subsublist - - - - - a subsublist - - - - - - - - - Nesting: - - - - - Upper Alpha - - - - - Upper Roman. - - - - - Decimal start with 6 - - - - - Lower alpha with paren - - - - - - - - - - - Autonumbering: - - - - - Autonumber. - - - - - More. - - - - - Nested. - - - - - - - Should not be a list item: - - - M.A. 2007 - - - B. Williams - - - - - Definition Lists - - Tight using spaces: - - - - - apple - - - - red fruit - - - - - - orange - - - - orange fruit - - - - - - banana - - - - yellow fruit - - - - - - Tight using tabs: - - - - - apple - - - - red fruit - - - - - - orange - - - - orange fruit - - - - - - banana - - - - yellow fruit - - - - - - Loose: - - - - - apple - - - - red fruit - - - - - - orange - - - - orange fruit - - - - - - banana - - - - yellow fruit - - - - - - Multiple blocks with italics: - - - - - apple - - - - red fruit - - - contains seeds, crisp, pleasant to taste - - - - - - orange - - - - orange fruit - - -{ orange code block } - -
- - orange block quote - -
-
-
-
- - Multiple definitions, tight: - - - - - apple - - - - red fruit - - - computer - - - - - - orange - - - - orange fruit - - - bank - - - - - - Multiple definitions, loose: - - - - - apple - - - - red fruit - - - computer - - - - - - orange - - - - orange fruit - - - bank - - - - - - Blank line after term, indented marker, alternate markers: - - - - - apple - - - - red fruit - - - computer - - - - - - orange - - - - orange fruit - - - - - sublist - - - - - sublist - - - - - - -
- - HTML Blocks - - Simple block on one line: - - - foo - - - And nested without indentation: - - - foo - - - bar - - - Interpreted markdown in a table: - - - - - - -
- This is emphasized - - And this is strong -
- - - Here’s a simple block: - - - foo - - - This should be a code block, though: - - -<div> - foo -</div> - - - As should this: - - -<div>foo</div> - - - Now, nested: - - - foo - - - This should just be an HTML comment: - - - - Multiline: - - - - - Code block: - - -<!-- Comment --> - - - Just plain comment, with trailing spaces on the line: - - - - Code: - - -<hr /> - - - Hr’s: - -
-
-
-
-
-
-
-
-
-
- - Inline Markup - - This is emphasized, and so is - this. - - - This is strong, and so - is this. - - - An emphasized link. - - - This is strong and - em. - - - So is this word. - - - This is strong and - em. - - - So is this word. - - - This is code: >, $, - \, \$, - <html>. - - - This is - strikeout. - - - Superscripts: abcd - ahello - ahello there. - - - Subscripts: H2O, H23O, - Hmany of themO. - - - These should not be superscripts or subscripts, because of the unescaped - spaces: a^b c^d, a~b c~d. - - - - Smart quotes, ellipses, dashes - - Hello, said the spider. Shelob is my - name. - - - A, B, and C are letters. - - - Oak, elm, and beech are names - of trees. So is pine. - - - He said, I want to go. Were you alive in the - 70’s? - - - Here is some quoted code and a - quoted - link. - - - Some dashes: one—two — three—four — five. - - - Dashes between numbers: 5–7, 255–66, 1987–1999. - - - Ellipses…and…and…. - - - - LaTeX - - - - - - - - 2 + 2 = 4 - - - - - x ∈ y - - - - - α ∧ ω - - - - - 223 - - - - - p-Tree - - - - - Here’s some display math: - $$\frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}$$ - - - - - Here’s one that has a line break in it: - α + ω × x2. - - - - - These shouldn’t be math: - - - - - To get the famous equation, write $e = mc^2$. - - - - - $22,000 is a lot of money. So is $34,000. (It - worked if lot is emphasized.) - - - - - Shoes ($20) and socks ($5). - - - - - Escaped $: $73 this should be - emphasized 23$. - - - - - Here’s a LaTeX table: - - - - Special Characters - - Here is some unicode: - - - - - I hat: Î - - - - - o umlaut: ö - - - - - section: § - - - - - set membership: ∈ - - - - - copyright: © - - - - - AT&T has an ampersand in their name. - - - AT&T is another way to write it. - - - This & that. - - - 4 < 5. - - - 6 > 5. - - - Backslash: \ - - - Backtick: ` - - - Asterisk: * - - - Underscore: _ - - - Left brace: { - - - Right brace: } - - - Left bracket: [ - - - Right bracket: ] - - - Left paren: ( - - - Right paren: ) - - - Greater-than: > - - - Hash: # - - - Period: . - - - Bang: ! - - - Plus: + - - - Minus: - - - - - Links - - Explicit - - Just a URL. - - - URL and title. - - - URL and title. - - - URL and title. - - - URL and title - - - URL and title - - - with_underscore - - - Email link (nobody@nowhere.net) - - - Empty. - - - - Reference - - Foo bar. - - - Foo bar. - - - Foo bar. - - - With embedded [brackets]. - - - b by itself should be a link. - - - Indented once. - - - Indented twice. - - - Indented thrice. - - - This should [not][] be a link. - - -[not]: /url - - - Foo bar. - - - Foo biz. - - - - With ampersands - - Here’s a link with an - ampersand in the URL. - - - Here’s a link with an amersand in the link text: - AT&T. - - - Here’s an inline link. - - - Here’s an inline link in pointy - braces. - - - - Autolinks - - With an ampersand: - http://example.com/?foo=1&bar=2 - - - - - In a list? - - - - - http://example.com/ - - - - - It should. - - - - - An e-mail address: nobody@nowhere.net - -
- - Blockquoted: - http://example.com/ - -
- - Auto-links should not occur here: - <http://example.com/> - - -or here: <http://example.com/> - -
-
- - Images - - From Voyage dans la Lune by Georges Melies (1902): - -
- lalune - - - - - lalune - -
- - Here is a movie - - - - icon. - -
- - Footnotes - - Here is a footnote reference, - - Here is the footnote. It can go anywhere after the footnote reference. - It need not be placed at the end of the document. - - and another. - - Here’s the long note. This one contains multiple blocks. - - - Subsequent blocks are indented to show that they belong to the - footnote (as with list items). - - - { <code> } - - - If you want, you can indent every line, but you can also be lazy and - just indent the first line of each block. - - This should not be a footnote reference, - because it contains a space.[^my note] Here is an inline note. - - This is easier to type. Inline notes may contain - links and ] - verbatim characters, as well as [bracketed text]. - - - -
- - Notes can go in quotes. - - In quote. - - - -
- - - - And in list items. - - In list. - - - - - - - This paragraph should not be part of the note, as it is not indented. - -
-
diff --git a/tests/writer.docbook4 b/tests/writer.docbook4 new file mode 100644 index 000000000..eee19cdd9 --- /dev/null +++ b/tests/writer.docbook4 @@ -0,0 +1,1422 @@ + + +
+ + Pandoc Test Suite + + + John + MacFarlane + + + + Anonymous + + + July 17, 2006 + + + This is a set of tests for pandoc. Most of them are adapted from John + Gruber’s markdown test suite. + + + Headers + + Level 2 with an <ulink url="/url">embedded link</ulink> + + Level 3 with <emphasis>emphasis</emphasis> + + Level 4 + + Level 5 + + + + + + + + + Level 1 + + Level 2 with <emphasis>emphasis</emphasis> + + Level 3 + + with no blank line + + + + + Level 2 + + with no blank line + + + + + Paragraphs + + Here’s a regular paragraph. + + + 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. + + + Here’s one with a bullet. * criminey. + +There should be a hard line break +here. + + + Block Quotes + + E-mail style: + +
+ + This is a block quote. It is pretty short. + +
+
+ + Code in a block quote: + + +sub status { + print "working"; +} + + + A list: + + + + + item one + + + + + item two + + + + + Nested block quotes: + +
+ + nested + +
+
+ + nested + +
+
+ + This should not be a block quote: 2 > 1. + + + And a following paragraph. + +
+ + Code Blocks + + Code: + + +---- (should be four hyphens) + +sub status { + print "working"; +} + +this code block is indented by one tab + + + And: + + + this code block is indented by two tabs + +These should not be escaped: \$ \\ \> \[ \{ + + + + Lists + + Unordered + + Asterisks tight: + + + + + asterisk 1 + + + + + asterisk 2 + + + + + asterisk 3 + + + + + Asterisks loose: + + + + + asterisk 1 + + + + + asterisk 2 + + + + + asterisk 3 + + + + + Pluses tight: + + + + + Plus 1 + + + + + Plus 2 + + + + + Plus 3 + + + + + Pluses loose: + + + + + Plus 1 + + + + + Plus 2 + + + + + Plus 3 + + + + + Minuses tight: + + + + + Minus 1 + + + + + Minus 2 + + + + + Minus 3 + + + + + Minuses loose: + + + + + Minus 1 + + + + + Minus 2 + + + + + Minus 3 + + + + + + Ordered + + Tight: + + + + + First + + + + + Second + + + + + Third + + + + + and: + + + + + One + + + + + Two + + + + + Three + + + + + Loose using tabs: + + + + + First + + + + + Second + + + + + Third + + + + + and using spaces: + + + + + One + + + + + Two + + + + + Three + + + + + Multiple paragraphs: + + + + + Item 1, graf one. + + + Item 1. graf two. The quick brown fox jumped over the lazy dog’s + back. + + + + + Item 2. + + + + + Item 3. + + + + + + Nested + + + + Tab + + + + + Tab + + + + + Tab + + + + + + + + + Here’s another: + + + + + First + + + + + Second: + + + + + Fee + + + + + Fie + + + + + Foe + + + + + + + Third + + + + + Same thing but with paragraphs: + + + + + First + + + + + Second: + + + + + Fee + + + + + Fie + + + + + Foe + + + + + + + Third + + + + + + Tabs and spaces + + + + this is a list item indented with tabs + + + + + this is a list item indented with spaces + + + + + this is an example list item indented with tabs + + + + + this is an example list item indented with spaces + + + + + + + + Fancy list markers + + + + begins with 2 + + + + + and now 3 + + + with a continuation + + + + + sublist with roman numerals, starting with 4 + + + + + more items + + + + + a subsublist + + + + + a subsublist + + + + + + + + + Nesting: + + + + + Upper Alpha + + + + + Upper Roman. + + + + + Decimal start with 6 + + + + + Lower alpha with paren + + + + + + + + + + + Autonumbering: + + + + + Autonumber. + + + + + More. + + + + + Nested. + + + + + + + Should not be a list item: + + + M.A. 2007 + + + B. Williams + + + + + Definition Lists + + Tight using spaces: + + + + + apple + + + + red fruit + + + + + + orange + + + + orange fruit + + + + + + banana + + + + yellow fruit + + + + + + Tight using tabs: + + + + + apple + + + + red fruit + + + + + + orange + + + + orange fruit + + + + + + banana + + + + yellow fruit + + + + + + Loose: + + + + + apple + + + + red fruit + + + + + + orange + + + + orange fruit + + + + + + banana + + + + yellow fruit + + + + + + Multiple blocks with italics: + + + + + apple + + + + red fruit + + + contains seeds, crisp, pleasant to taste + + + + + + orange + + + + orange fruit + + +{ orange code block } + +
+ + orange block quote + +
+
+
+
+ + Multiple definitions, tight: + + + + + apple + + + + red fruit + + + computer + + + + + + orange + + + + orange fruit + + + bank + + + + + + Multiple definitions, loose: + + + + + apple + + + + red fruit + + + computer + + + + + + orange + + + + orange fruit + + + bank + + + + + + Blank line after term, indented marker, alternate markers: + + + + + apple + + + + red fruit + + + computer + + + + + + orange + + + + orange fruit + + + + + sublist + + + + + sublist + + + + + + +
+ + HTML Blocks + + Simple block on one line: + + + foo + + + And nested without indentation: + + + foo + + + bar + + + Interpreted markdown in a table: + + + + + + +
+ This is emphasized + + And this is strong +
+ + + Here’s a simple block: + + + foo + + + This should be a code block, though: + + +<div> + foo +</div> + + + As should this: + + +<div>foo</div> + + + Now, nested: + + + foo + + + This should just be an HTML comment: + + + + Multiline: + + + + + Code block: + + +<!-- Comment --> + + + Just plain comment, with trailing spaces on the line: + + + + Code: + + +<hr /> + + + Hr’s: + +
+
+
+
+
+
+
+
+
+
+ + Inline Markup + + This is emphasized, and so is + this. + + + This is strong, and so + is this. + + + An emphasized link. + + + This is strong and + em. + + + So is this word. + + + This is strong and + em. + + + So is this word. + + + This is code: >, $, + \, \$, + <html>. + + + This is + strikeout. + + + Superscripts: abcd + ahello + ahello there. + + + Subscripts: H2O, H23O, + Hmany of themO. + + + These should not be superscripts or subscripts, because of the unescaped + spaces: a^b c^d, a~b c~d. + + + + Smart quotes, ellipses, dashes + + Hello, said the spider. Shelob is my + name. + + + A, B, and C are letters. + + + Oak, elm, and beech are names + of trees. So is pine. + + + He said, I want to go. Were you alive in the + 70’s? + + + Here is some quoted code and a + quoted + link. + + + Some dashes: one—two — three—four — five. + + + Dashes between numbers: 5–7, 255–66, 1987–1999. + + + Ellipses…and…and…. + + + + LaTeX + + + + + + + + 2 + 2 = 4 + + + + + x ∈ y + + + + + α ∧ ω + + + + + 223 + + + + + p-Tree + + + + + Here’s some display math: + $$\frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}$$ + + + + + Here’s one that has a line break in it: + α + ω × x2. + + + + + These shouldn’t be math: + + + + + To get the famous equation, write $e = mc^2$. + + + + + $22,000 is a lot of money. So is $34,000. (It + worked if lot is emphasized.) + + + + + Shoes ($20) and socks ($5). + + + + + Escaped $: $73 this should be + emphasized 23$. + + + + + Here’s a LaTeX table: + + + + Special Characters + + Here is some unicode: + + + + + I hat: Î + + + + + o umlaut: ö + + + + + section: § + + + + + set membership: ∈ + + + + + copyright: © + + + + + AT&T has an ampersand in their name. + + + AT&T is another way to write it. + + + This & that. + + + 4 < 5. + + + 6 > 5. + + + Backslash: \ + + + Backtick: ` + + + Asterisk: * + + + Underscore: _ + + + Left brace: { + + + Right brace: } + + + Left bracket: [ + + + Right bracket: ] + + + Left paren: ( + + + Right paren: ) + + + Greater-than: > + + + Hash: # + + + Period: . + + + Bang: ! + + + Plus: + + + + Minus: - + + + + Links + + Explicit + + Just a URL. + + + URL and title. + + + URL and title. + + + URL and title. + + + URL and title + + + URL and title + + + with_underscore + + + Email link (nobody@nowhere.net) + + + Empty. + + + + Reference + + Foo bar. + + + Foo bar. + + + Foo bar. + + + With embedded [brackets]. + + + b by itself should be a link. + + + Indented once. + + + Indented twice. + + + Indented thrice. + + + This should [not][] be a link. + + +[not]: /url + + + Foo bar. + + + Foo biz. + + + + With ampersands + + Here’s a link with an + ampersand in the URL. + + + Here’s a link with an amersand in the link text: + AT&T. + + + Here’s an inline link. + + + Here’s an inline link in pointy + braces. + + + + Autolinks + + With an ampersand: + http://example.com/?foo=1&bar=2 + + + + + In a list? + + + + + http://example.com/ + + + + + It should. + + + + + An e-mail address: nobody@nowhere.net + +
+ + Blockquoted: + http://example.com/ + +
+ + Auto-links should not occur here: + <http://example.com/> + + +or here: <http://example.com/> + +
+
+ + Images + + From Voyage dans la Lune by Georges Melies (1902): + +
+ lalune + + + + + lalune + +
+ + Here is a movie + + + + icon. + +
+ + Footnotes + + Here is a footnote reference, + + Here is the footnote. It can go anywhere after the footnote reference. + It need not be placed at the end of the document. + + and another. + + Here’s the long note. This one contains multiple blocks. + + + Subsequent blocks are indented to show that they belong to the + footnote (as with list items). + + + { <code> } + + + If you want, you can indent every line, but you can also be lazy and + just indent the first line of each block. + + This should not be a footnote reference, + because it contains a space.[^my note] Here is an inline note. + + This is easier to type. Inline notes may contain + links and ] + verbatim characters, as well as [bracketed text]. + + + +
+ + Notes can go in quotes. + + In quote. + + + +
+ + + + And in list items. + + In list. + + + + + + + This paragraph should not be part of the note, as it is not indented. + +
+
-- cgit v1.2.3 From a62550f46eeb5f1228548beac9aed43ce2b1f21a Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sun, 29 Jan 2017 22:07:10 +0100 Subject: Use latest master HEAD for templates. --- data/templates | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'data/templates') diff --git a/data/templates b/data/templates index c4ba8bab6..ab6b3f060 160000 --- a/data/templates +++ b/data/templates @@ -1 +1 @@ -Subproject commit c4ba8bab6248f8999e520547f1c45f10de85db9d +Subproject commit ab6b3f060dd1559381dcba05aca1669f4cbe8e0e -- cgit v1.2.3