pandoc 1.9.4.5 → 1.10
raw patch · 208 files changed
+15752/−10565 lines, 208 filesdep +Diffdep +HUnitdep +QuickCheckdep −utf8-stringdep ~basedep ~blaze-htmldep ~bytestringsetup-changedbinary-addedPVP ok
version bump matches the API change (PVP)
Dependencies added: Diff, HUnit, QuickCheck, ansi-terminal, criterion, data-default, file-embed, template-haskell, test-framework, test-framework-hunit, test-framework-quickcheck2, text
Dependencies removed: utf8-string
Dependency ranges changed: base, blaze-html, bytestring, citeproc-hs, pandoc-types
API changes (from Hackage documentation)
Files
- BUGS +1/−1
- Benchmark.hs +0/−45
- COPYRIGHT +1/−1
- INSTALL +40/−41
- README +406/−122
- Setup.hs +5/−3
- benchmark/benchmark-pandoc.hs +46/−0
- changelog +709/−18
- data/default.csl +422/−0
- data/dzslides/template.html +585/−0
- data/epub.css +31/−0
- data/reference.docx binary
- data/reference.odt binary
- data/s5/default/blank.gif binary
- data/s5/default/bodybg.gif binary
- data/s5/default/framing.css +23/−0
- data/s5/default/iepngfix.htc +42/−0
- data/s5/default/opera.css +7/−0
- data/s5/default/outline.css +15/−0
- data/s5/default/pretty.css +86/−0
- data/s5/default/print.css +24/−0
- data/s5/default/s5-core.css +9/−0
- data/s5/default/slides.css +3/−0
- data/s5/default/slides.js +553/−0
- data/slideous/slideous.css +95/−0
- data/slideous/slideous.js +321/−0
- data/slidy/graphics/fold-dim.gif binary
- data/slidy/graphics/fold.gif binary
- data/slidy/graphics/nofold-dim.gif binary
- data/slidy/graphics/unfold-dim.gif binary
- data/slidy/graphics/unfold.gif binary
- data/slidy/scripts/slidy.js.gz binary
- data/slidy/styles/slidy.css +405/−0
- data/templates/default.asciidoc +26/−0
- data/templates/default.beamer +152/−0
- data/templates/default.context +81/−0
- data/templates/default.docbook +28/−0
- data/templates/default.dzslides +120/−0
- data/templates/default.epub +32/−0
- data/templates/default.epub3 +36/−0
- data/templates/default.html +58/−0
- data/templates/default.html5 +60/−0
- data/templates/default.latex +167/−0
- data/templates/default.man +18/−0
- data/templates/default.markdown +21/−0
- data/templates/default.mediawiki +13/−0
- data/templates/default.opendocument +27/−0
- data/templates/default.org +24/−0
- data/templates/default.plain +21/−0
- data/templates/default.rst +42/−0
- data/templates/default.rtf +30/−0
- data/templates/default.s5 +67/−0
- data/templates/default.slideous +76/−0
- data/templates/default.slidy +60/−0
- data/templates/default.texinfo +64/−0
- data/templates/default.textile +9/−0
- default.csl +0/−422
- dzslides/template.html +0/−585
- epub.css +0/−31
- man/make-pandoc-man-pages.hs +8/−9
- man/man1/pandoc.1 +460/−305
- man/man5/pandoc_markdown.5 +427/−195
- pandoc.cabal +154/−174
- pandoc.hs +1093/−0
- reference.docx binary
- reference.odt binary
- s5/default/blank.gif binary
- s5/default/bodybg.gif binary
- s5/default/framing.css +0/−23
- s5/default/iepngfix.htc +0/−42
- s5/default/opera.css +0/−7
- s5/default/outline.css +0/−15
- s5/default/pretty.css +0/−86
- s5/default/print.css +0/−24
- s5/default/s5-core.css +0/−9
- s5/default/slides.css +0/−3
- s5/default/slides.js +0/−553
- slideous/slideous.css +0/−95
- slideous/slideous.js +0/−321
- slidy/graphics/fold-dim.gif binary
- slidy/graphics/fold.gif binary
- slidy/graphics/nofold-dim.gif binary
- slidy/graphics/unfold-dim.gif binary
- slidy/graphics/unfold.gif binary
- slidy/scripts/slidy.js.gz binary
- slidy/styles/slidy.css +0/−405
- src/Text/Pandoc.hs +151/−82
- src/Text/Pandoc/Biblio.hs +27/−40
- src/Text/Pandoc/Highlighting.hs +4/−3
- src/Text/Pandoc/ImageSize.hs +3/−6
- src/Text/Pandoc/MIME.hs +5/−1
- src/Text/Pandoc/Options.hs +347/−0
- src/Text/Pandoc/Parsing.hs +403/−271
- src/Text/Pandoc/Pretty.hs +9/−8
- src/Text/Pandoc/Readers/DocBook.hs +31/−16
- src/Text/Pandoc/Readers/HTML.hs +69/−73
- src/Text/Pandoc/Readers/LaTeX.hs +115/−74
- src/Text/Pandoc/Readers/Markdown.hs +1721/−1361
- src/Text/Pandoc/Readers/MediaWiki.hs +593/−0
- src/Text/Pandoc/Readers/Native.hs +17/−16
- src/Text/Pandoc/Readers/RST.hs +464/−393
- src/Text/Pandoc/Readers/TeXMath.hs +1/−1
- src/Text/Pandoc/Readers/Textile.hs +159/−123
- src/Text/Pandoc/SelfContained.hs +17/−49
- src/Text/Pandoc/Shared.hs +153/−160
- src/Text/Pandoc/Slides.hs +7/−7
- src/Text/Pandoc/Templates.hs +35/−31
- src/Text/Pandoc/UTF8.hs +35/−49
- src/Text/Pandoc/Writers/AsciiDoc.hs +9/−7
- src/Text/Pandoc/Writers/ConTeXt.hs +51/−35
- src/Text/Pandoc/Writers/Docbook.hs +47/−42
- src/Text/Pandoc/Writers/Docx.hs +169/−154
- src/Text/Pandoc/Writers/EPUB.hs +215/−117
- src/Text/Pandoc/Writers/FB2.hs +618/−0
- src/Text/Pandoc/Writers/HTML.hs +76/−35
- src/Text/Pandoc/Writers/LaTeX.hs +182/−80
- src/Text/Pandoc/Writers/Man.hs +45/−44
- src/Text/Pandoc/Writers/Markdown.hs +272/−125
- src/Text/Pandoc/Writers/MediaWiki.hs +33/−30
- src/Text/Pandoc/Writers/Native.hs +5/−5
- src/Text/Pandoc/Writers/ODT.hs +52/−39
- src/Text/Pandoc/Writers/OpenDocument.hs +2/−2
- src/Text/Pandoc/Writers/Org.hs +36/−31
- src/Text/Pandoc/Writers/RST.hs +83/−57
- src/Text/Pandoc/Writers/RTF.hs +56/−46
- src/Text/Pandoc/Writers/Texinfo.hs +52/−29
- src/Text/Pandoc/Writers/Textile.hs +25/−19
- src/pandoc.hs +0/−1075
- templates/default.asciidoc +0/−26
- templates/default.beamer +0/−133
- templates/default.context +0/−80
- templates/default.docbook +0/−28
- templates/default.dzslides +0/−119
- templates/default.html +0/−54
- templates/default.html5 +0/−61
- templates/default.latex +0/−174
- templates/default.man +0/−18
- templates/default.markdown +0/−23
- templates/default.mediawiki +0/−13
- templates/default.opendocument +0/−27
- templates/default.org +0/−24
- templates/default.plain +0/−23
- templates/default.rst +0/−41
- templates/default.rtf +0/−27
- templates/default.s5 +0/−66
- templates/default.slideous +0/−75
- templates/default.slidy +0/−59
- templates/default.texinfo +0/−64
- templates/default.textile +0/−9
- templates/epub-coverimage.html +0/−14
- templates/epub-page.html +0/−18
- templates/epub-titlepage.html +0/−22
- tests/Tests/Arbitrary.hs +1/−1
- tests/Tests/Helpers.hs +19/−23
- tests/Tests/Old.hs +49/−16
- tests/Tests/Readers/LaTeX.hs +3/−2
- tests/Tests/Readers/Markdown.hs +104/−5
- tests/Tests/Readers/RST.hs +3/−3
- tests/Tests/Writers/ConTeXt.hs +13/−13
- tests/Tests/Writers/HTML.hs +1/−1
- tests/Tests/Writers/LaTeX.hs +5/−1
- tests/Tests/Writers/Markdown.hs +1/−1
- tests/Tests/Writers/Native.hs +2/−2
- tests/docbook-reader.docbook +3/−3
- tests/docbook-reader.native +35/−35
- tests/html-reader.native +30/−30
- tests/latex-reader.latex +6/−1
- tests/latex-reader.native +36/−35
- tests/lhs-test-markdown.native +8/−0
- tests/lhs-test.html +3/−2
- tests/lhs-test.html+lhs +3/−2
- tests/lhs-test.latex +3/−1
- tests/lhs-test.latex+lhs +2/−0
- tests/lhs-test.native +4/−4
- tests/markdown-reader-more.native +37/−27
- tests/markdown-reader-more.txt +29/−0
- tests/mediawiki-reader.native +241/−0
- tests/mediawiki-reader.wiki +369/−0
- tests/pipe-tables.native +70/−0
- tests/pipe-tables.txt +42/−0
- tests/rst-reader.native +136/−133
- tests/rst-reader.rst +15/−4
- tests/s5.basic.html +1/−0
- tests/s5.fancy.html +1/−0
- tests/s5.inserts.html +1/−0
- tests/s5.native +2/−2
- tests/tables-rstsubset.native +22/−22
- tests/tables.latex +91/−97
- tests/tables.native +22/−22
- tests/tables.rtf +0/−1
- tests/test-pandoc.hs +4/−2
- tests/testsuite.native +166/−166
- tests/textile-reader.native +38/−30
- tests/textile-reader.textile +19/−2
- tests/writer.asciidoc +31/−0
- tests/writer.context +27/−27
- tests/writer.docbook +3/−3
- tests/writer.html +14/−8
- tests/writer.latex +68/−28
- tests/writer.man +10/−10
- tests/writer.mediawiki +8/−9
- tests/writer.native +166/−166
- tests/writer.opendocument +50/−58
- tests/writer.org +1/−1
- tests/writer.rst +30/−31
- tests/writer.rtf +4/−4
- tests/writer.texinfo +68/−27
- tests/writer.textile +35/−35
@@ -1,2 +1,2 @@ To view a list of known bugs, or to enter a bug report, please use-Pandoc's issue tracker: <http://code.google.com/p/pandoc/issues/list>+Pandoc's issue tracker: <https://github.com/jgm/pandoc/issues>
@@ -1,45 +0,0 @@-import Text.Pandoc-import Text.Pandoc.Shared (readDataFile, normalize)-import Criterion.Main-import Data.List (isSuffixOf)-import Text.JSON.Generic--readerBench :: Pandoc- -> (String, ParserState -> String -> Pandoc)- -> Benchmark-readerBench doc (name, reader) =- let writer = case lookup name writers of- Just w -> w- Nothing -> error $ "Could not find writer for " ++ name- inp = writer defaultWriterOptions{ writerWrapText = True- , writerLiterateHaskell =- "+lhs" `isSuffixOf` name } doc- -- we compute the length to force full evaluation- getLength (Pandoc (Meta a b c) d) =- length a + length b + length c + length d- in bench (name ++ " reader") $ whnf (getLength .- reader defaultParserState{ stateSmart = True- , stateStandalone = True- , stateLiterateHaskell =- "+lhs" `isSuffixOf` name }) inp--writerBench :: Pandoc- -> (String, WriterOptions -> Pandoc -> String)- -> Benchmark-writerBench doc (name, writer) = bench (name ++ " writer") $ nf- (writer defaultWriterOptions{- writerWrapText = True- , writerLiterateHaskell = "+lhs" `isSuffixOf` name }) doc--normalizeBench :: Pandoc -> [Benchmark]-normalizeBench doc = [ bench "normalize - with" $ nf (encodeJSON . normalize) doc- , bench "normalize - without" $ nf encodeJSON doc- ]--main = do- inp <- readDataFile (Just ".") "README"- let ps = defaultParserState{ stateSmart = True }- let doc = readMarkdown ps inp- let readerBs = map (readerBench doc) readers- defaultMain $ map (writerBench doc) writers ++ readerBs ++ normalizeBench doc-
@@ -1,5 +1,5 @@ Pandoc-Copyright (C) 2006-2012 John MacFarlane <jgm at berkeley dot edu>+Copyright (C) 2006-2013 John MacFarlane <jgm at berkeley dot edu> This code is released under the [GPL], version 2 or later:
@@ -62,15 +62,8 @@ preceded by a `-` (to force the flag to `false`), and separated by spaces. Pandoc's flags include: - - `executable`: build the pandoc executable (default yes)- - `library`: build the pandoc library (default yes)-- So, for example,-- --flags="-executable"-- tells Cabal to build the library but not the executables,- and to compile with syntax highlighting support.+ - `blaze_html_0_5`: Use blaze-html >= 0.5 (default yes)+ - `embed_data_files`: embed all data files into the binary (default no) 3. Build: @@ -94,37 +87,19 @@ generate a script that can be run to register the package at install time. -Creating a relocatable Windows binary--------------------------------------+Creating a relocatable binary+----------------------------- -On Windows it is possible to compile pandoc such that it-(and its data files) are "relocatable." You can put the relocatable-binary in any directory (even on a USB drive), and it will look for its-data files there.+It is possible to compile pandoc such that the data files+pandoc uses are embedded in the binary. The resulting binary+can be run from any directory and is completely self-contained. cabal install --flags="embed_data_files" citeproc-hs- cabal install --flags="executable -library" --datasubdir=--You can find `pandoc.exe` in `dist/build/pandoc`. Copy this wherever-you please, and copy the following data files to the same place:-- README- COPYRIGHT- COPYING- reference.odt- reference.docx- epub.css- default.csl- templates/- data/- s5/- slidy/- slideous/- dzslides/- pcre-license.txt- pcre3.dll+ cabal configure --flags="embed_data_files"+ cabal build -This is essentially what the binary installer does.+You can find the pandoc executable in `dist/build/pandoc`. Copy this wherever+you please. [zip-archive]: http://hackage.haskell.org/package/zip-archive [highlighting-kate]: http://hackage.haskell.org/package/highlighting-kate@@ -136,9 +111,9 @@ ------------- Pandoc comes with an automated test suite integrated to cabal.-To enable the tests, compile pandoc with the `--enable-tests` option:+To build the tests: - cabal install --enable-tests+ cabal configure --enable-tests && cabal build Note: If you obtained the source via git, you should first do @@ -151,11 +126,35 @@ cabal test +To run particular tests (pattern-matching on their names), use+the `-t` option:++ cabal test --test-options='-t markdown'+ If you add a new feature to pandoc, please add tests as well, following the pattern of the existing tests. The test suite code is in-`src/test-pandoc.hs`. If you are adding a new reader or writer, it is+`tests/test-pandoc.hs`. If you are adding a new reader or writer, it is probably easiest to add some data files to the `tests` directory, and-modify `src/Tests/Old.hs`. Otherwise, it is better to modify the module-under the `src/Tests` hierarchy corresponding to the pandoc module you+modify `tests/Tests/Old.hs`. Otherwise, it is better to modify the module+under the `tests/Tests` hierarchy corresponding to the pandoc module you are changing.++Running benchmarks+------------------++To build the benchmarks:++ cabal configure --enable-benchmarks && cabal build++To run the benchmarks:++ cabal bench++To use a smaller sample size so the benchmarks run faster:++ cabal bench --benchmark-options='-s 20'++To run just the markdown benchmarks:++ cabal bench --benchmark-options='markdown'
@@ -1,6 +1,6 @@ % Pandoc User's Guide % John MacFarlane-% January 27, 2012+% January 19, 2013 Synopsis ========@@ -13,21 +13,22 @@ Pandoc is a [Haskell] library for converting from one markup format to another, and a command-line tool that uses this library. It can read [markdown] and (subsets of) [Textile], [reStructuredText], [HTML],-[LaTeX], and [DocBook XML]; and it can write plain text, [markdown],-[reStructuredText], [XHTML], [HTML 5], [LaTeX] (including [beamer]-slide shows), [ConTeXt], [RTF], [DocBook XML], [OpenDocument XML],-[ODT], [Word docx], [GNU Texinfo], [MediaWiki markup], [EPUB],-[Textile], [groff man] pages, [Emacs Org-Mode], [AsciiDoc], and [Slidy],-[Slideous], [DZSlides], or [S5] HTML slide shows. It can also produce-[PDF] output on systems where LaTeX is installed.+[LaTeX], [MediaWiki markup], and [DocBook XML]; and it can write plain+text, [markdown], [reStructuredText], [XHTML], [HTML 5], [LaTeX]+(including [beamer] slide shows), [ConTeXt], [RTF], [DocBook XML],+[OpenDocument XML], [ODT], [Word docx], [GNU Texinfo], [MediaWiki+markup], [EPUB] (v2 or v3), [FictionBook2], [Textile], [groff man] pages, [Emacs+Org-Mode], [AsciiDoc], and [Slidy], [Slideous], [DZSlides], or [S5] HTML+slide shows. It can also produce [PDF] output on systems where LaTeX is+installed. Pandoc's enhanced version of markdown includes syntax for footnotes,-tables, flexible ordered lists, definition lists, delimited code blocks,+tables, flexible ordered lists, definition lists, fenced code blocks, superscript, subscript, strikeout, title blocks, automatic tables of contents, embedded LaTeX math, citations, and markdown inside HTML block elements. (These enhancements, described below under-[Pandoc's markdown](#pandocs-markdown), can be disabled using the `--strict`-option.)+[Pandoc's markdown](#pandocs-markdown), can be disabled using the+`markdown_strict` input or output format.) In contrast to most existing tools for converting markdown to HTML, which use regex substitutions, Pandoc has a modular design: it consists of a@@ -43,7 +44,7 @@ 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`,-and `epub` output formats). For output to a file, use the+`epub`, and `epub3` output formats). For output to a file, use the `-o` option: pandoc -o output.html input.txt@@ -107,7 +108,7 @@ Production of a PDF requires that a LaTeX engine be installed (see `--latex-engine`, below), and assumes that the following LaTeX packages are available: `amssymb`, `amsmath`, `ifxetex`, `ifluatex`, `listings` (if the-`--listings` option is used), `fancyvrb`, `enumerate`, `ctable`, `url`,+`--listings` option is used), `fancyvrb`, `longtable`, `url`, `graphicx`, `hyperref`, `ulem`, `babel` (if the `lang` variable is set), `fontspec` (if `xelatex` or `lualatex` is used as the LaTeX engine), `xltxtra` and `xunicode` (if `xelatex` is used).@@ -117,12 +118,13 @@ A user who wants a drop-in replacement for `Markdown.pl` may create a symbolic link to the `pandoc` executable called `hsmarkdown`. When-invoked under the name `hsmarkdown`, `pandoc` will behave as if the-`--strict` flag had been selected, and no command-line options will be-recognized. However, this approach does not work under Cygwin, due to-problems with its simulation of symbolic links.+invoked under the name `hsmarkdown`, `pandoc` will behave as if+invoked with `-f markdown_strict --email-obfuscation=references`,+and all command-line options will be treated as regular arguments.+However, this approach does not work under Cygwin, due to problems with+its simulation of symbolic links. -[Cygwin]: http://www.cygwin.com/ +[Cygwin]: http://www.cygwin.com/ [`iconv`]: http://www.gnu.org/software/libiconv/ [CTAN]: http://www.ctan.org "Comprehensive TeX Archive Network" [TeX Live]: http://www.tug.org/texlive/@@ -136,36 +138,52 @@ `-f` *FORMAT*, `-r` *FORMAT*, `--from=`*FORMAT*, `--read=`*FORMAT* : Specify input format. *FORMAT* can be `native` (native Haskell),- `json` (JSON version of native AST), `markdown` (markdown),+ `json` (JSON version of native AST), `markdown` (pandoc's+ extended markdown), `markdown_strict` (original unextended markdown),+ `markdown_phpextra` (PHP Markdown Extra extended markdown),+ `markdown_github` (github extended markdown), `textile` (Textile), `rst` (reStructuredText), `html` (HTML),- `docbook` (DocBook XML), or `latex` (LaTeX). If `+lhs` is- appended to `markdown`, `rst`, `latex`, the input will be- treated as literate Haskell source: see [Literate Haskell- support](#literate-haskell-support), below.+ `docbook` (DocBook XML), `mediawiki` (MediaWiki markup),+ or `latex` (LaTeX). If `+lhs` is appended to `markdown`, `rst`,+ `latex`, the input will be treated as literate Haskell source:+ see [Literate Haskell support](#literate-haskell-support), below.+ Markdown syntax extensions can be individually enabled or disabled+ by appending `+EXTENSION` or `-EXTENSION` to the format name.+ So, for example, `markdown_strict+footnotes+definition_lists`+ is strict markdown with footnotes and definition lists enabled,+ and `markdown-pipe_tables+hard_line_breaks` is pandoc's markdown+ without pipe tables and with hard line breaks. See [Pandoc's+ markdown](#pandocs-markdown), below, for a list of extensions and+ their names. `-t` *FORMAT*, `-w` *FORMAT*, `--to=`*FORMAT*, `--write=`*FORMAT* : Specify output format. *FORMAT* can be `native` (native Haskell), `json` (JSON version of native AST), `plain` (plain text),- `markdown` (markdown), `rst` (reStructuredText), `html` (XHTML 1),- `html5` (HTML 5), `latex` (LaTeX), `beamer` (LaTeX beamer slide show),+ `markdown` (pandoc's extended markdown), `markdown_strict` (original+ unextended markdown), `markdown_phpextra` (PHP Markdown extra+ extended markdown), `markdown_github` (github extended markdown),+ `rst` (reStructuredText), `html` (XHTML+ 1), `html5` (HTML 5), `latex` (LaTeX), `beamer` (LaTeX beamer slide show), `context` (ConTeXt), `man` (groff man), `mediawiki` (MediaWiki markup), `textile` (Textile), `org` (Emacs Org-Mode), `texinfo` (GNU Texinfo), `docbook` (DocBook XML), `opendocument` (OpenDocument XML), `odt`- (OpenOffice text document), `docx` (Word docx), `epub` (EPUB book),- `asciidoc` (AsciiDoc), `slidy` (Slidy HTML and javascript slide show),- `slideous` (Slideous HTML and javascript slide show),- `dzslides` (HTML5 + javascript slide show), `s5` (S5 HTML and javascript- slide show), or `rtf` (rich text format). Note that `odt` and `epub`- 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 literate Haskell source: see [Literate Haskell- support](#literate-haskell-support), below.+ (OpenOffice text document), `docx` (Word docx), `epub` (EPUB book), `epub3`+ (EPUB v3), `fb2` (FictionBook2 e-book), `asciidoc` (AsciiDoc), `slidy`+ (Slidy HTML and javascript slide show), `slideous` (Slideous HTML and+ javascript slide show), `dzslides` (HTML5 + javascript slide show), `s5`+ (S5 HTML and javascript slide show), or `rtf` (rich text format). Note that+ `odt`, `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 literate Haskell source: see [Literate Haskell+ support](#literate-haskell-support), below. Markdown syntax extensions can+ be individually enabled or disabled by appending `+EXTENSION` or+ `-EXTENSION` to the format name, as described above under `-f`. `-o` *FILE*, `--output=`*FILE* : Write output to *FILE* instead of *stdout*. If *FILE* is `-`, output will go to *stdout*. (Exception: if the output- format is `odt`, `docx`, or `epub`, output to stdout is disabled.)+ format is `odt`, `docx`, `epub`, or `epub3`, output to stdout is disabled.) `--data-dir=`*DIRECTORY* : Specify the user data directory to search for pandoc data files.@@ -191,12 +209,6 @@ Reader options -------------- -`--strict`-: Use strict markdown syntax, with no pandoc extensions or variants.- When the input format is HTML, this means that constructs that have no- equivalents in standard markdown (e.g. definition lists or strikeout- text) will be parsed as raw HTML.- `-R`, `--parse-raw` : Parse untranslatable HTML codes and LaTeX environments as raw HTML or LaTeX, instead of ignoring them. Affects only HTML and LaTeX@@ -213,9 +225,10 @@ to curly quotes, `---` to em-dashes, `--` to en-dashes, and `...` to ellipses. Nonbreaking spaces are inserted after certain abbreviations, such as "Mr." (Note: This option is significant only when- the input format is `markdown` or `textile`. It is selected automatically- when the input format is `textile` or the output format is `latex` or- `context`, unless `--no-tex-ligatures` is used.)+ the input format is `markdown`, `markdown_strict`, or `textile`. It+ is selected automatically when the input format is `textile` or the+ output format is `latex` or `context`, unless `--no-tex-ligatures`+ is used.) `--old-dashes` : Selects the pandoc <= 1.8.2.1 behavior for parsing smart dashes: `-` before@@ -236,6 +249,8 @@ `-p`, `--preserve-tabs` : Preserve tabs instead of converting them to spaces (the default).+ Note that this will only affect tabs in literal code spans and code+ blocks; tabs in regular text will be treated as spaces. `--tab-stop=`*NUMBER* : Specify the number of spaces per tab (default is 4).@@ -246,7 +261,8 @@ `-s`, `--standalone` : Produce output with an appropriate header and footer (e.g. a standalone HTML, LaTeX, or RTF file, not a fragment). This option- is set automatically for `pdf`, `epub`, `docx`, and `odt` output.+ is set automatically for `pdf`, `epub`, `epub3`, `fb2`, `docx`, and `odt`+ output. `--template=`*FILE* : Use *FILE* as a custom template for the generated document. Implies@@ -284,6 +300,11 @@ one) in the output document. This option has no effect on `man`, `docbook`, `slidy`, `slideous`, or `s5` output. +`--toc-depth=`*NUMBER*+: Specify the number of section levels to include in the table+ of contents. The default is 3 (which means that level 1, 2, and 3+ headers will be listed in the contents). Implies `--toc`.+ `--no-highlight` : Disables syntax highlighting for code blocks and inlines, even when a language attribute is given.@@ -338,6 +359,9 @@ : Produce HTML5 instead of HTML4. This option has no effect for writers other than `html`. (*Deprecated:* Use the `html5` output format instead.) +`--html-q-tags`+: Use `<q>` tags for quotes in HTML.+ `--ascii` : Use only ascii characters in output. Currently supported only for HTML output (which uses numerical entities instead of@@ -399,13 +423,12 @@ *none* leaves `mailto:` links as they are. *javascript* obfuscates them using javascript. *references* obfuscates them by printing their letters as decimal or hexadecimal character references.- If `--strict` is specified, *references* is used regardless of the- presence of this option. `--id-prefix`=*STRING* : Specify a prefix to be added to all automatically generated identifiers- in HTML output. This is useful for preventing duplicate identifiers- when generating fragments to be included in other pages.+ in HTML and DocBook output, and to footnote numbers in markdown output.+ This is useful for preventing duplicate identifiers when generating+ fragments to be included in other pages. `-T` *STRING*, `--title-prefix=`*STRING* : Specify *STRING* as a prefix at the beginning of the title@@ -414,7 +437,8 @@ `--standalone`. `-c` *URL*, `--css=`*URL*-: Link to a CSS style sheet.+: Link to a CSS style sheet. This option can be be used repeatedly to+ include multiple files. They will be included in the order specified. `--reference-odt=`*FILE* : Use the specified file as a style reference in producing an ODT.@@ -434,7 +458,12 @@ reference docx is specified on the command line, pandoc will look for a file `reference.docx` in the user data directory (see `--data-dir`). If this is not found either, sensible defaults will be- used.+ used. The following styles are used by pandoc: [paragraph]+ Normal, Title, Authors, Date, Heading 1, Heading 2, Heading 3,+ Heading 4, Heading 5, Block Quote, Definition Term, Definition,+ Body Text, Table Caption, Image Caption; [character] Default+ Paragraph Font, Body Text Char, Verbatim Char, Footnote Reference,+ Hyperlink. `--epub-stylesheet=`*FILE* : Use the specified CSS file to style the EPUB. If no stylesheet@@ -495,19 +524,29 @@ } body { font-family: "DejaVuSans"; } +`--epub-chapter-level=`*NUMBER*+: Specify the header level at which to split the EPUB into separate+ "chapter" files. The default is to split into chapters at level 1+ headers. This option only affects the internal composition of the+ EPUB, not the way chapters and sections are displayed to users. Some+ readers may be slow if the chapter files are too large, so for large+ documents with few level 1 headers, one might want to use a chapter+ level of 2 or 3.+ `--latex-engine=`*pdflatex|lualatex|xelatex* : Use the specified LaTeX engine when producing PDF output. The default is `pdflatex`. If the engine is not in your PATH, the full path of the engine may be specified here. -Citations----------+Citation rendering+------------------ `--bibliography=`*FILE* : Specify bibliography database to be used in resolving citations. The database type will be determined from the extension of *FILE*, which may be `.mods` (MODS format),- `.bib` (BibTeX/BibLaTeX format),+ `.bib` (BibLaTeX format, which will normally work for BibTeX+ files as well), `.bibtex` (BibTeX format), `.ris` (RIS format), `.enl` (EndNote format), `.xml` (EndNote XML format), `.wos` (ISI format), `.medline` (MEDLINE format), `.copac` (Copac format),@@ -587,7 +626,7 @@ `--gladtex` : Enclose TeX math in `<eq>` tags in HTML output. These can then be processed by [gladTeX] to produce links to images of the typeset- formulas. + formulas. `--mimetex`[=*URL*] : Render TeX math using the [mimeTeX] CGI script. If *URL* is not@@ -624,8 +663,8 @@ [LaTeXMathML]: http://math.etsu.edu/LaTeXMathML/ [jsMath]: http://www.math.union.edu/~dpvc/jsmath/ [MathJax]: http://www.mathjax.org/-[gladTeX]: http://www.math.uio.no/~martingu/gladtex/index.html-[mimeTeX]: http://www.forkosh.com/mimetex.html +[gladTeX]: http://ans.hsh.no/home/mgg/gladtex/+[mimeTeX]: http://www.forkosh.com/mimetex.html [CSL]: http://CitationStyles.org Templates@@ -643,9 +682,7 @@ by putting a file `templates/default.FORMAT` in the user data directory (see `--data-dir`, above). *Exceptions:* For `odt` output, customize the `default.opendocument` template. For `pdf` output,-customize the `default.latex` template. For `epub` output, customize-the `epub-page.html`, `epub-coverimage.html`, and `epub-titlepage.html`-templates.+customize the `default.latex` template. Templates may contain *variables*. Variable names are sequences of alphanumerics, `-`, and `_`, starting with a letter. A variable name@@ -754,8 +791,12 @@ Pandoc understands an extended and slightly revised version of John Gruber's [markdown] syntax. This document explains the syntax, noting differences from standard markdown. Except where noted, these-differences can be suppressed by specifying the `--strict` command-line-option.+differences can be suppressed by using the `markdown_strict` format instead+of `markdown`. An extensions can be enabled by adding `+EXTENSION`+to the format name and disabled by adding `-EXTENSION`. For example,+`markdown_strict+footnotes` is strict markdown with footnotes+enabled, while `markdown-footnotes-pipe_tables` is pandoc's+markdown without footnotes or pipe tables. Philosophy ----------@@ -784,9 +825,12 @@ A paragraph is one or more lines of text followed by one or more blank line. Newlines are treated as spaces, so you can reflow your paragraphs as you like.-If you need a hard line break, put two or more spaces at the end of a line,-or type a backslash followed by a newline.+If you need a hard line break, put two or more spaces at the end of a line. +**Extension: `escaped_line_breaks`**++A backslash followed by a newline is also a hard line break.+ Headers ------- @@ -821,6 +865,8 @@ # A level-one header with a [link](/url) and *emphasis* +**Extension: `blank_before_header`**+ Standard markdown syntax does not require a blank line before a header. Pandoc does require this (except, of course, at the beginning of the document). The reason for the requirement is that it is all too easy for a@@ -833,10 +879,31 @@ ### Header identifiers in HTML, LaTeX, and ConTeXt ### -*Pandoc extension*.+**Extension: `header_attributes`** -Each header element in pandoc's HTML and ConTeXt output is given a-unique identifier. This identifier is based on the text of the header.+Headers can be assigned attributes using this syntax at the end+of the line containing the header text:++ {#identifier .class .class key=value key=value}++Although this syntax allows assignment of classes and key/value attributes,+only identifiers currently have any affect in the writers (and only in some+writers: HTML, LaTeX, ConTeXt, Textile, AsciiDoc). Thus, for example,+the following headers will all be assigned the identifier `foo`:++ # My header {#foo}++ ## My header ## {#foo}++ My other header {#foo}+ ---------------++(This syntax is compatible with [PHP Markdown Extra].)++**Extension: `auto_identifiers`**++A header without an explicitly specified identifier will be+automatically assigned a unique identifier based on the header text. To derive the identifier from the header text, - Remove all formatting, links, etc.@@ -881,7 +948,34 @@ sections to be manipulated using javascript or treated differently in CSS. +**Extension: `implicit_header_references`** +Pandoc behaves as if reference links have been defined for each header.+So, instead of++ [header identifiers](#header-identifiers-in-html)++you can simply write++ [header identifiers]++or++ [header identifiers][]++or++ [the section on header identifiers][header identifiers]++If there are multiple headers with identical text, the corresponding+reference will link to the first one only, and you will need to use explicit+links to link to the others, as described above.++Unlike regular reference links, these references are case-sensitive.++Note: if you have defined an explicit identifier for a header,+then implicit references to it will not work.+ Block quotations ---------------- @@ -913,12 +1007,14 @@ > > > A block quote within a block quote. +**Extension: `blank_line_before_blockquote`**+ Standard markdown syntax does not require a blank line before a block quote. Pandoc does require this (except, of course, at the beginning of the document). The reason for the requirement is that it is all too easy for a `>` to end up at the beginning of a line by accident (perhaps through line-wrapping). So, unless `--strict` is used, the following does not produce-a nested block quote in pandoc:+wrapping). So, unless the `markdown_strict` format is used, the following does+not produce a nested block quote in pandoc: > This is a block quote. >> Nested.@@ -943,12 +1039,12 @@ Note: blank lines in the verbatim text need not begin with four spaces. -### Delimited code blocks ###+### Fenced code blocks ### -*Pandoc extension*.+**Extension: `fenced_code_blocks`** In addition to standard indented code blocks, Pandoc supports-*delimited* code blocks. These begin with a row of three or more+*fenced* code blocks. These begin with a row of three or more tildes (`~`) or backticks (`` ` ``) and end with a row of tildes or backticks that must be at least as long as the starting row. Everything between these lines is treated as code. No indentation is necessary:@@ -959,7 +1055,7 @@ } ~~~~~~~ -Like regular code blocks, delimited code blocks must be separated+Like regular code blocks, fenced code blocks must be separated from surrounding text by blank lines. If the code itself contains a row of tildes or backticks, just use a longer@@ -1010,6 +1106,35 @@ To prevent all highlighting, use the `--no-highlight` flag. To set the highlighting style, use `--highlight-style`. +Line blocks+-----------++**Extension: `line_blocks`**++A line block is a sequence of lines beginning with a vertical bar (`|`)+followed by a space. The division into lines will be preserved in+the output, as will any leading spaces; otherwise, the lines will+be formatted as markdown. This is useful for verse and addresses:++ | The limerick packs laughs anatomical+ | In space that is quite economical.+ | But the good ones I've seen+ | So seldom are clean+ | And the clean ones so seldom are comical++ | 200 Main St.+ | Berkeley, CA 94718++The lines can be hard-wrapped if needed, but the continuation+line must begin with a space.++ | The Right Honorable Most Venerable and Righteous Samuel L.+ Constable, Jr.+ | 200 Main St.+ | Berkeley, CA 94718++This syntax is borrowed from [reStructuredText].+ Lists ----- @@ -1126,7 +1251,7 @@ 7. two 1. three -*Pandoc extension*.+**Extension: `fancy_lists`** Unlike standard markdown, Pandoc allows ordered list items to be marked with uppercase and lowercase letters and roman numerals, in addition to@@ -1151,6 +1276,8 @@ (C\) 2007 Joe Smith +**Extension: `startnum`**+ Pandoc also pays attention to the type of list marker used, and to the starting number, and both of these are preserved where possible in the output format. Thus, the following yields a list with numbers followed@@ -1181,7 +1308,7 @@ ### Definition lists ### -*Pandoc extension*.+**Extension: `definition_lists`** Pandoc supports definition lists, using a syntax inspired by [PHP Markdown Extra] and [reStructuredText]:[^3]@@ -1226,7 +1353,7 @@ ### Numbered example lists ### -*Pandoc extension*.+**Extension: `example_lists`** The special list marker `@` can be used for sequentially numbered examples. The first list item with a `@` marker will be numbered '1',@@ -1255,7 +1382,7 @@ ### Compact and loose lists ### Pandoc behaves differently from `Markdown.pl` on some "edge-cases" involving lists. Consider this source: +cases" involving lists. Consider this source: + First + Second:@@ -1272,7 +1399,7 @@ a blank line, it is treated as a paragraph. Since "Second" is followed by a list, and not a blank line, it isn't treated as a paragraph. The fact that the list is followed by a blank line is irrelevant. (Note:-Pandoc works this way even when the `--strict` option is specified. This+Pandoc works this way even when the `markdown_strict` format is specified. This behavior is consistent with the official markdown syntax description, even though it is different from that of `Markdown.pl`.) @@ -1328,13 +1455,17 @@ Tables ------ -*Pandoc extension*.+**Extension: `simple_tables`, `multiline_tables`, `grid_tables`,+`pipe_tables`, `table_captions`** -Three kinds of tables may be used. All three kinds presuppose the use of-a fixed-width font, such as Courier.+Four kinds of tables may be used. The first three kinds presuppose the use of+a fixed-width font, such as Courier. The fourth kind can be used with+proportionally spaced fonts, as it does not require lining up columns. -**Simple tables** look like this:+### Simple tables +Simple tables look like this:+ Right Left Center Default ------- ------ ---------- ------- 12 12 12 12@@ -1349,7 +1480,7 @@ - If the dashed line is flush with the header text on the right side but extends beyond it on the left, the column is right-aligned.- - If the dashed line is flush with the header text on the left side + - If the dashed line is flush with the header text on the left side but extends beyond it on the right, the column is left-aligned. - If the dashed line extends beyond the header text on both sides, the column is centered.@@ -1378,7 +1509,9 @@ of the first line of the table body. So, in the tables above, the columns would be right, left, center, and right aligned, respectively. -**Multiline tables** allow headers and table rows to span multiple lines+### Multiline tables++Multiline tables allow headers and table rows to span multiple lines of text (but cells that span multiple columns or rows of the table are not supported). Here is an example: @@ -1418,7 +1551,7 @@ Second row 5.0 Here's another one. Note the blank line between rows.- -------------------------------------------------------------+ ----------- ------- --------------- ------------------------- : Here's a multiline table without headers. @@ -1426,8 +1559,10 @@ should be followed by a blank line (and then the row of dashes that ends the table), or the table may be interpreted as a simple table. -**Grid tables** look like this:+### Grid tables +Grid tables look like this:+ : Sample grid table. +---------------+---------------+--------------------+@@ -1448,11 +1583,56 @@ [Emacs table mode]: http://table.sourceforge.net/ +### Pipe tables +Pipe tables look like this:++ | Right | Left | Default | Center |+ |------:|:-----|---------|:------:|+ | 12 | 12 | 12 | 12 |+ | 123 | 123 | 123 | 123 |+ | 1 | 1 | 1 | 1 |++ : Demonstration of simple table syntax.++The syntax is [the same as in PHP markdown extra]. The beginning and+ending pipe characters are optional, but pipes are required between all+columns. The colons indicate column alignment as shown. The header+can be omitted, but the horizontal line must still be included, as+it defines column alignments.++Since the pipes indicate column boundaries, columns need not be vertically+aligned, as they are in the above example. So, this is a perfectly+legal (though ugly) pipe table:++ fruit| price+ -----|-----:+ apple|2.05+ pear|1.37+ orange|3.09++The cells of pipe tables cannot contain block elements like paragraphs+and lists, and cannot span multiple lines.++ [the same as in PHP markdown extra]:+ http://michelf.ca/projects/php-markdown/extra/#table++Note: Pandoc also recognizes pipe tables of the following+form, as can produced by Emacs' orgtbl-mode:++ | One | Two |+ |-----+-------|+ | my | table |+ | is | nice |++The difference is that `+` is used instead of `|`. Other orgtbl features+are not supported. In particular, to get non-default column alignment,+you'll need to add colons as above.+ Title block ----------- -*Pandoc extension*.+**Extension: `pandoc_title_block`** If the file begins with a title block @@ -1532,6 +1712,8 @@ Backslash escapes ----------------- +**Extension: `all_symbols_escapable`**+ Except inside a code block or inline code, any punctuation or space character preceded by a backslash will be treated literally, even if it would normally indicate formatting. Thus, for example, if one writes@@ -1551,8 +1733,8 @@ \`*_{}[]()>#+-.! -(However, if the `--strict` option is supplied, the standard-markdown rule will be used.)+(However, if the `markdown_strict` format is used, the standard markdown rule+will be used.) A backslash-escaped space is parsed as a nonbreaking space. It will appear in TeX output as `~` and in HTML and XML as `\ ` or@@ -1569,7 +1751,7 @@ Smart punctuation ----------------- -*Pandoc extension*.+**Extension** If the `--smart` option is specified, pandoc will produce typographically correct output, converting straight quotes to curly quotes, `---` to@@ -1598,6 +1780,8 @@ This is * not emphasized *, and \*neither is this\*. +**Extension: `intraword_underscores`**+ Because `_` is sometimes used inside words and identifiers, pandoc does not interpret a `_` surrounded by alphanumeric characters as an emphasis marker. If you want to emphasize@@ -1608,7 +1792,7 @@ ### Strikeout ### -*Pandoc extension*.+**Extension: `strikeout`** To strikeout a section of text with a horizontal line, begin and end it with `~~`. Thus, for example,@@ -1618,7 +1802,7 @@ ### Superscripts and subscripts ### -*Pandoc extension*.+**Extension: `superscript`, `subscript`** Superscripts may be written by surrounding the superscripted text by `^` characters; subscripts may be written by surrounding the subscripted@@ -1656,15 +1840,17 @@ This is a backslash followed by an asterisk: `\*`. +**Extension: `inline_code_attributes`**+ Attributes can be attached to verbatim text, just as with-[delimited code blocks](#delimited-code-blocks):+[fenced code blocks](#fenced-code-blocks): `<$>`{.haskell} Math ---- -*Pandoc extension*.+**Extension: `tex_math_dollars`** Anything between two `$` characters will be treated as TeX math. The opening `$` must have a character immediately to its right, while the@@ -1710,7 +1896,12 @@ Docx ~ It will be rendered using OMML math markup. -HTML, Slidy, Slideous, DZSlides, S5, EPUB+FictionBook2+ ~ If the `--webtex` option is used, formulas are rendered as images+ using Google Charts or other compatible web service, downloaded+ and embedded in the e-book. Otherwise, they will appear verbatim.++HTML, Slidy, DZSlides, S5, EPUB ~ The way math is rendered in HTML will depend on the command-line options selected: @@ -1720,11 +1911,11 @@ styled differently from the surrounding text if needed. 2. If the `--latexmathml` option is used, TeX math will be displayed- between $ or $$ characters and put in `<span>` tags with class `LaTeX`.+ between `$` or `$$` characters and put in `<span>` tags with class `LaTeX`. The [LaTeXMathML] script will be used to render it as formulas. (This trick does not work in all browsers, but it works in Firefox. In browsers that do not support LaTeXMathML, TeX math will appear- verbatim between $ characters.)+ verbatim between `$` characters.) 3. If the `--jsmath` option is used, TeX math will be put inside `<span>` tags (for inline math) or `<div>` tags (for display math)@@ -1753,19 +1944,27 @@ with the URL provided. If no URL is specified, the Google Chart API will be used (`http://chart.apis.google.com/chart?cht=tx&chl=`). + 7. If the `--mathjax` option is used, TeX math will be displayed+ between `\(...\)` (for inline math) or `\[...\]` (for display+ math) and put in `<span>` tags with class `math`.+ The [MathJax] script will be used to render it as formulas. Raw HTML -------- +**Extension: `raw_html`**+ Markdown allows you to insert raw HTML (or DocBook) anywhere in a document (except verbatim contexts, where `<`, `>`, and `&` are interpreted-literally).+literally). (Techncially this is not an extension, since standard+markdown allows it, but it has been made an extension so that it can+be disabled if desired.) The raw HTML is passed through unchanged in HTML, S5, Slidy, Slideous,-DZSlides, EPUB,-Markdown, and Textile output, and suppressed in other formats.+DZSlides, EPUB, Markdown, and Textile output, and suppressed in other+formats. -*Pandoc extension*.+**Extension: `markdown_in_html_blocks`** Standard markdown allows you to include HTML "blocks": blocks of HTML between balanced tags that are separated from the surrounding text@@ -1773,8 +1972,8 @@ these blocks, everything is interpreted as HTML, not markdown; so (for example), `*` does not signify emphasis. -Pandoc behaves this way when `--strict` is specified; but by default,-pandoc interprets material between HTML block tags as markdown.+Pandoc behaves this way when the `markdown_strict` format is used; but+by default, pandoc interprets material between HTML block tags as markdown. Thus, for example, Pandoc will turn <table>@@ -1806,7 +2005,7 @@ Raw TeX ------- -*Pandoc extension*.+**Extension: `raw_tex`** In addition to raw HTML, pandoc allows raw LaTeX, TeX, and ConTeXt to be included in a document. Inline TeX commands will be preserved and passed@@ -1820,7 +2019,7 @@ \begin{tabular}{|l|l|}\hline Age & Frequency \\ \hline 18--25 & 15 \\- 26--35 & 33 \\ + 26--35 & 33 \\ 36--45 & 22 \\ \hline \end{tabular} @@ -1830,8 +2029,11 @@ Inline LaTeX is ignored in output formats other than Markdown, LaTeX, and ConTeXt. -### Macros ###+LaTeX macros+------------ +**Extension: `latex_macros`**+ For output formats other than LaTeX, pandoc will parse LaTeX `\newcommand` and `\renewcommand` definitions and apply the resulting macros to all LaTeX math. So, for example, the following will work in all output formats,@@ -1858,7 +2060,6 @@ <http://google.com> <sam@green.eggs.ham> - ### Inline links ### An inline link consists of the link text in square brackets,@@ -1880,7 +2081,6 @@ The link consists of link text in square brackets, followed by a label in square brackets. (There can be space between the two.) The link definition-must begin at the left margin or indented no more than three spaces. It consists of the bracketed label, followed by a colon and a space, followed by the URL, and optionally (after a space) a link title either in quotes or in parentheses.@@ -1914,6 +2114,16 @@ [my website]: http://foo.bar.baz +Note: In `Markdown.pl` and most other markdown implementations,+reference link definitions cannot occur in nested constructions+such as list items or block quotes. Pandoc lifts this arbitrary+seeming restriction. So the following is fine in pandoc, though+not in most other implementations:++ > My block [quote].+ >+ > [quote]: /foo+ ### Internal links To link to another section of the same document, use the automatically@@ -1946,7 +2156,7 @@ ### Pictures with captions ### -*Pandoc extension*.+**Extension: `implicit_figures`** An image occurring by itself in a paragraph will be rendered as a figure with a caption.[^5] (In LaTeX, a figure environment will be@@ -1964,13 +2174,13 @@ the only thing in the paragraph. One way to do this is to insert a nonbreaking space after the image: - \ + \ Footnotes --------- -*Pandoc extension*.+**Extension: `footnotes`** Pandoc's markdown allows footnotes, using the following syntax: @@ -1980,7 +2190,7 @@ [^longnote]: Here's one with multiple blocks. - Subsequent paragraphs are indented to show that they + Subsequent paragraphs are indented to show that they belong to the previous footnote. { some.code }@@ -2001,6 +2211,8 @@ document. They may appear anywhere except inside other block elements (lists, block quotes, tables, etc.). +**Extension: `inline_notes`**+ Inline footnotes are also allowed (though, unlike regular notes, they cannot contain multiple paragraphs). The syntax is as follows: @@ -2014,7 +2226,7 @@ Citations --------- -*Pandoc extension*.+**Extension: `citations`** Pandoc can automatically generate citations and a bibliography in a number of styles (using Andrea Rossato's `hs-citeproc`). In order to use this feature,@@ -2023,7 +2235,8 @@ Format File extension ------------ -------------- MODS .mods- BibTeX/BibLaTeX .bib+ BibLaTeX .bib+ BibTeX .bibtex RIS .ris EndNote .enl EndNote XML .xml@@ -2032,6 +2245,9 @@ Copac .copac JSON citeproc .json +Note that `.bib` can generally be used with both BibTeX and BibLaTeX+files, but you can use `.bibtex` to force BibTeX.+ You will need to specify the bibliography file using the `--bibliography` command-line option (which may be repeated if you have several bibliographies).@@ -2078,7 +2294,73 @@ The bibliography will be inserted after this header. +Non-pandoc extensions+===================== +The following markdown syntax extensions are not enabled by default+in pandoc, but may be enabled by adding `+EXTENSION` to the format+name, where `EXTENSION` is the name of the extension. Thus, for+example, `markdown+hard_line_breaks` is markdown with hard line breaks.++**Extension: `hard_line_breaks`**\+Causes all newlines within a paragraph to be interpreted as hard line+breaks instead of spaces.++**Extension: `tex_math_single_backslash`**\+Causes anything between `\(` and `\)` to be interpreted as inline+TeX math, and anything between `\[` and `\]` to be interpreted+as display TeX math. Note: a drawback of this extension is that+it precludes escaping `(` and `[`.++**Extension: `tex_math_double_backslash`**\+Causes anything between `\\(` and `\\)` to be interpreted as inline+TeX math, and anything between `\\[` and `\\]` to be interpreted+as display TeX math.++**Extension: `markdown_attribute`**\+By default, pandoc interprets material inside block-level tags as markdown.+This extension changes the behavior so that markdown is only parsed+inside block-level tags if the tags have the attribute `markdown=1`.++**Extension: `mmd_title_block`**\+Enables a [MultiMarkdown] style title block at the top of+the document, for example:++ Title: My title+ Author: John Doe+ Date: September 1, 2008+ Comment: This is a sample mmd title block, with+ a field spanning multiple lines.++See the MultiMarkdown documentation for details. Note that only title,+author, and date are recognized; other fields are simply ignored by+pandoc. If `pandoc_title_block` is enabled, it will take precedence over+`mmd_title_block`.++ [MultiMarkdown]: http://fletcherpenney.net/multimarkdown/++**Extension: `abbrevations`**\+Parses PHP Markdown Extra abbreviation keys, like++ *[HTML]: Hyper Text Markup Language++Note that the pandoc document model does not support+abbreviations, so if this extension is enabled, abbreviation keys are+simply skipped (as opposed to being parsed as paragraphs).++**Extension: `autolink_bare_uris`**\+Makes all absolute URIs into links, even when not surrounded by+pointy braces `<...>`.++**Extension: `link_attributes`**\+Parses multimarkdown style key-value attributes on link and image references.+Note that pandoc's internal document model provides nowhere to put+these, so they are presently just ignored.++**Extension: `mmd_header_identifiers`**\+Parses multimarkdown style header identifiers (in square brackets,+after the header but before any trailing `#`s in an ATX header).+ Producing slide shows with Pandoc ================================= @@ -2228,10 +2510,10 @@ Literate Haskell support ======================== -If you append `+lhs` to an appropriate input or output format (`markdown`,-`rst`, or `latex` for input or output; `beamer`, `html` or `html5` for-output only), pandoc will treat the document as literate Haskell source.-This means that+If you append `+lhs` (or `+literate_haskell`) to an appropriate input or output+format (`markdown`, `mardkown_strict`, `rst`, or `latex` for input or output;+`beamer`, `html` 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 code rather than block quotations. Text between `\begin{code}`@@ -2282,7 +2564,8 @@ Puneeth Chaganti, Paul Rivier, rodja.trappe, Bradley Kuhn, thsutton, Nathan Gass, Jonathan Daugherty, Jérémy Bobbio, Justin Bogner, qerub, Christopher Sawicki, Kelsey Hightower, Masayoshi Takahashi, Antoine-Latter, Ralf Stephan, Eric Seidel, B. Scott Michel, Gavin Beatty.+Latter, Ralf Stephan, Eric Seidel, B. Scott Michel, Gavin Beatty,+Sergey Astanin, Arlo O'Keeffe, Denis Laxalde, Brent Yorgey. [markdown]: http://daringfireball.net/projects/markdown/ [reStructuredText]: http://docutils.sourceforge.net/docs/ref/rst/introduction.html@@ -2294,10 +2577,10 @@ [XHTML]: http://www.w3.org/TR/xhtml1/ [LaTeX]: http://www.latex-project.org/ [beamer]: http://www.tex.ac.uk/CTAN/macros/latex/contrib/beamer-[ConTeXt]: http://www.pragma-ade.nl/ +[ConTeXt]: http://www.pragma-ade.nl/ [RTF]: http://en.wikipedia.org/wiki/Rich_Text_Format [DocBook XML]: http://www.docbook.org/-[OpenDocument XML]: http://opendocument.xml.org/ +[OpenDocument XML]: http://opendocument.xml.org/ [ODT]: http://en.wikipedia.org/wiki/OpenDocument [Textile]: http://redcloth.org/textile [MediaWiki markup]: http://www.mediawiki.org/wiki/Help:Formatting@@ -2312,3 +2595,4 @@ [ISO 8601 format]: http://www.w3.org/TR/NOTE-datetime [Word docx]: http://www.microsoft.com/interop/openup/openxml/default.aspx [PDF]: http://www.adobe.com/pdf/+[FictionBook2]: http://www.fictionbook.org/index.php/Eng:XML_Schema_Fictionbook_2.1
@@ -1,4 +1,5 @@-{-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE CPP #-}+ import Distribution.Simple import Distribution.Simple.Setup (copyDest, copyVerbosity, fromFlag, installVerbosity, BuildFlags(..))@@ -33,10 +34,10 @@ -- | Build man pages from markdown sources in man/ makeManPages :: Args -> BuildFlags -> PackageDescription -> LocalBuildInfo -> IO ()-makeManPages _ flags _ _ = do+makeManPages _ flags _ lbi = do let verbosity = fromFlag $ buildVerbosity flags let args = ["--verbose" | verbosity /= silent]- rawSystem ("dist" </> "build" </> "make-pandoc-man-pages" </> "make-pandoc-man-pages")+ rawSystem (buildDir lbi </> "make-pandoc-man-pages" </> "make-pandoc-man-pages") args >>= exitWith manpages :: [FilePath]@@ -51,3 +52,4 @@ installManpages pkg lbi verbosity copy = installOrdinaryFiles verbosity (mandir (absoluteInstallDirs pkg lbi copy)) (zip (repeat manDir) manpages)+
@@ -0,0 +1,46 @@+import Text.Pandoc+import Text.Pandoc.Shared (normalize)+import Criterion.Main+import Criterion.Config+import Text.JSON.Generic+import System.Environment (getArgs)+import Data.Monoid++readerBench :: Pandoc+ -> (String, ReaderOptions -> String -> IO Pandoc)+ -> Benchmark+readerBench doc (name, reader) =+ let writer = case lookup name writers of+ Just (PureStringWriter w) -> w+ _ -> error $ "Could not find writer for " ++ name+ inp = writer def{ writerWrapText = True } doc+ -- we compute the length to force full evaluation+ getLength (Pandoc (Meta a b c) d) =+ length a + length b + length c + length d+ in bench (name ++ " reader") $ whnfIO $ getLength `fmap`+ (reader def{ readerSmart = True }) inp++writerBench :: Pandoc+ -> (String, WriterOptions -> Pandoc -> String)+ -> Benchmark+writerBench doc (name, writer) = bench (name ++ " writer") $ nf+ (writer def{ writerWrapText = True }) doc++normalizeBench :: Pandoc -> [Benchmark]+normalizeBench doc = [ bench "normalize - with" $ nf (encodeJSON . normalize) doc+ , bench "normalize - without" $ nf encodeJSON doc+ ]++main :: IO ()+main = do+ args <- getArgs+ (conf,_) <- parseArgs defaultConfig{ cfgSamples = Last $ Just 20 } defaultOptions args+ inp <- readFile "README"+ inp2 <- readFile "tests/testsuite.txt"+ let opts = def{ readerSmart = True }+ let doc = readMarkdown opts $ inp ++ unlines (drop 3 $ lines inp2)+ let readerBs = map (readerBench doc) readers+ let writers' = [(n,w) | (n, PureStringWriter w) <- writers]+ defaultMainWith conf (return ()) $+ map (writerBench doc) writers' ++ readerBs ++ normalizeBench doc+
@@ -1,29 +1,720 @@-pandoc (1.9.4.5)+pandoc (1.10) - * Raised version bounds on network, base64-bytestring, json,- and template-haskell.+ [new features] -pandoc (1.9.4.4)+ * New input formats: `mediawiki` (MediaWiki markup). - * Removed `tests` flag and made test suite into a proper cabal- test suite, which can now be enabled using `--enable-tests`- and run with `cabal test`.+ * New output formats: `epub3` (EPUB v3 with MathML),+ `fb2` (FictionBook2 ebooks). - * Moved man page creation out of `Setup.hs` and into an- executable built by Cabal, but never installed. This- allows dependencies to be specified, and solves a problem- with 1.9.4.3, which could only be installed if `data-default`- had already been installed.+ * New `--toc-depth` option, specifying how many levels of+ headers to include in a table of contents. - * Updated `lhs-latex.tex` test for latest highlighting-kate- representation of backticks.+ * New `--epub-chapter-level` option, specifying the header+ level at which to divide EPUBs into separate files.+ Note that this normally affects only performance, not the+ visual presentation of the EPUB in a reader. -pandoc (1.9.4.3)+ * Removed the `--strict` option. Instead of using `--strict`,+ one can now use the format name `markdown_strict` for either input+ or output. This gives more fine-grained control that `--strict`+ did, allowing one to convert from pandoc's markdown to strict+ markdown or vice versa. - * Removed `-threaded` from default compile flags.+ * It is now possible to enable or disable specific syntax+ extensions by appending them (with `+` or `-`) to the writer+ or reader name. For example, - * Modified modules to compile with GHC 7.6 and latest version of time- package.+ pandoc -f markdown-footnotes+hard_line_breaks++ disables footnotes and enables treating newlines as hard+ line breaks. The literate Haskell extensions are now implemented+ this way as well, using either `+lhs` or `+literate_haskell`.+ For a list of extension names, see the README under+ "Pandoc's Markdown."++ * The following aliases have been introduced for specific+ combinations of markdown extensions: `markdown_phpextra`,+ `markdown_github`, `markdown_mmd`, `markdown_strict`. These aliases+ work just like regular reader and writer names, and can be modified+ with extension modifiers as described above. (Note that conversion+ from one markdown dialect to another does not work perfectly,+ because there are differences in markdown parsers besides+ just the extensions, and because pandoc's internal document model is+ not rich enough to capture all of the extensions.)++ * New `--html-q-tags` option. The previous default was to use `<q>`+ tags for smart quotes in HTML5. But `<q>` tags are also valid HTML4.+ Moreover, they are not a robust way of typesetting quotes, since+ some user agents don't support them, and some CSS resets (e.g.+ bootstrap) prevent pandoc's quotes CSS from working properly.+ We now just insert literal quote characters by default in both+ `html` and `html5` output, but this option is provided for+ those who still want `<q>` tags.++ * The markdown reader now prints warnings (to stderr) about+ duplicate link and note references. Closes #375.++ * Markdown syntax extensions:++ + Added pipe tables. Thanks to François Gannaz for the initial patch.+ These conform to PHP Markdown Extra's pipe table syntax. A subset+ of org-mode table syntax is also supported, which means that you can+ use org-mode's nice table editor to create tables.++ + Added support for RST-style line blocks. These are+ useful for verse and addresses.++ + Attributes can now be specified for headers, using the same+ syntax as in code blocks. (However, currently only the+ identifier has any effect in most writers.) For example,++ # My header {#foo}++ See [the header above](#foo).++ + Pandoc will now act as if link references have been defined+ for all headers without explicit identifiers.+ So, you can do this:++ # My header++ Link to [My header].+ Another link to [it][My header].++ Closes #691.++ * LaTeX reader:++ + Command macros now work everywhere, including non-math.+ Environment macros still not supported.+ + `\input` now works, as well as `\include`. TEXINPUTS is used.+ Pandoc looks recursively into included files for more included files.++ [behavior changes]++ * The Markdown reader no longer puts the text of autolinks in a+ `Code` inline. This means that autolinks will no longer appear+ in a monospace font.++ * The character `/` can now appear in markdown citation keys.++ * HTML blocks in strict_markdown are no longer required to begin+ at the left margin. Technically this is required, according to+ the markdown syntax document, but `Markdown.pl` and other markdown+ processors are more liberal.++ * The `-V` option has been changed so that if there are duplicate+ variables, those specified later on the command line take precedence.++ * Tight lists now work in LaTeX and ConTeXt output.++ * The LaTeX writer no longer relien on the `enumerate` package.+ Instead, it uses standard LaTeX commands to change the list numbering+ style.++ * The LaTeX writer now uses `longtable` instead of `ctable`. This allows+ tables to be split over page boundaries.++ * The RST writer now uses a line block to render paragraphs containing+ linebreaks (which previously weren't supported at all).++ * The markdown writer now applies the `--id-prefix` to footnote IDs.+ Closes #614.++ * The plain writer no longer uses backslash-escaped line breaks+ (which are not very "plain").++ * `Text.Pandoc.UTF8`: Better error message for invalid UTF8.+ Read bytestring and use `Text`'s decodeUtf8 instead of using+ `System.IO.hGetContents`. This way you get a message saying+ "invalid UTF-8 stream" instead of "invalid byte sequence."+ You are also told which byte caused the problem.++ * Docx, ODT, and EPUB writers now download images specified by a URL+ instead of skipping them or raising an error.++ * EPUB writer:++ + The default CSS now left-aligns headers by default, instead of+ centering. This is more consistent with the rest of the writers.+ + A proper multi-level table of contents is now used in `toc.ncx`.+ There is no longer a subsidiary table of contents at the beginning+ of each chapter.+ + Code highlighting now works by default.+ + Section divs are used by default for better semantic markup.+ + The title is used instead of "Title Page" in the table of contents.+ Otherwise we have a hard-coded English string, which looks+ strange in ebooks written in other languages. Closes #572.++ * HTML writer:++ + Put mathjax in span with class "math". Closes #562.+ + Put citations in a span with class "citation." In HTML5, also include+ a `data-cite` attribute with a space-separated list of citation+ keys.++ * `Text.Pandoc.UTF8`: use universalNewlineMode in reading.+ This treats both `\r\n` and `\n` as `\n` on input, no matter+ what platform we're running on.++ * Citation processing is now done in the Markdown and LaTeX+ readers, not in `pandoc.hs`. This makes it easier for library users+ to use citations.++ [template changes]++ * HTML: Added css to template to preserve spaces in `<code>` tags.+ Thanks to Dirk Laurie.++ * Beamer: Remove English-centric strings in section pages.+ Section pages used to have "Section" and a number as well as the+ section title. Now they just have the title. Similarly for part+ and subsection. Closes #566.++ * LaTeX, ConTeXt: Added papersize variable.++ * LaTeX, Beamer templates: Use longtable instead of ctable.++ * LaTeX, Beamer templates: Don't require 'float' package for tables.+ We don't actually seem to use the '[H]' option.++ * LaTeX: Use `upquote` package if it is available. This fixes+ straight quotes in verbatim environments.++ * Markdown, plain: Fixed titleblock so it is just a single string.+ Previously separate title, author, and date variables were used,+ but this didn't allow different kinds of title blocks.++ * EPUB:++ + Rationalized templates. Previously there were three different+ templates involved in epub production. There is now just one+ template, `default.epub` or `default.epub3`. It can now be+ overridden using `--template`, just like other templates.+ The titlepage is now folded into the default template.+ A `titlepage` variable selects it.+ + UTF-8, lang tag, meta tags, title element.++ * Added scale-to-width feature to beamer template++ [API changes]++ * `Text.Pandoc.Definition`: Added `Attr` field to `Header`.+ Previously header identifers were autogenerated by the writers.+ Now they are added in the readers (either automatically or explicitly).++ * `Text.Pandoc.Builder`:++ + `Inlines` and `Blocks` are now synonyms for `Many Inline` and+ `Many Block`. `Many` is a newtype wrapper around `Seq`, with+ custom Monoid instances for `Many Inline` and `Many Block. This+ allows `Many` to be made an instance of `Foldable` and `Traversable`.+ + The old `Listable` class has been removed.+ + The module now exports `isNull`, `toList`, `fromList`.+ + The old `Read` and `Show` instances have been removed; derived+ instances are now used.+ + Added `headerWith`.++ * The readers now take a `ReaderOptions` rather than a `ParserState`+ as a parameter. Indeed, not all parsers use the `ParserState` type;+ some have a custom state. The motivation for this change was to separate+ user-specifiable options from the accounting functions of parser state.++ * New module `Text.Pandoc.Options`. This includes the `WriterOptions`+ formerly in `Text.Pandoc.Shared`, and its associated+ data types. It also includes a new type `ReaderOptions`, which+ contains many options formerly in `ParserState`, and its associated+ data types:++ + `ParserState.stateParseRaw` -> `ReaderOptions.readerParseRaw`.+ + `ParserState.stateColumns` -> `ReaderOptions.readerColumns`.+ + `ParserState.stateTabStop` -> `ReaderOptions.readerTabStop`.+ + `ParserState.stateOldDashes` -> `ReaderOptions.readerOldDashes`.+ + `ParserState.stateLiterateHaskell` -> `ReaderOptions.readerLiterateHaskell`.+ + `ParserState.stateCitations` -> `ReaderOptions.readerReferences`.+ + `ParserState.stateApplyMacros` -> `ReaderOptions.readerApplyMacros`.+ + `ParserState.stateIndentedCodeClasses` ->+ `ReaderOptions.readerIndentedCodeClasses`.+ + Added `ReaderOptions.readerCitationStyle`.++ * `WriterOptions` now includes `writerEpubVersion`, `writerEpubChapterLevel`,+ `writerEpubStylesheet`, `writerEpubFonts`, `writerReferenceODT`,+ `writerReferenceDocx`, and `writerTOCDepth`. `writerEPUBMetadata` has+ been renamed `writerEpubMetadata` for consistency.++ * Changed signatures of `writeODT`, `writeDocx`, `writeEPUB`, since they no+ longer stylesheet, fonts, reference files as separate parameters.++ * Removed `writerLiterateHaskell` from `WriterOptions`, and+ `readerLiterateHaskell` from `ReaderOptions`. LHS is now handled+ by an extension (`Ext_literate_haskell`).++ * Removed deprecated `writerXeTeX`.++ * Removed `writerStrict` from `WriterOptions`. Added `writerExtensions`.+ Strict is now handled through extensions.++ * `Text.Pandoc.Options` exports `pandocExtensions`, `strictExtensions`,+ `phpMarkdownExtraExtensions`, `githubMarkdownExtensions`,+ and `multimarkdownExtensions`, as well as the `Extensions` type.++ * New `Text.Pandoc.Readers.MediaWiki` module, exporting+ `readMediaWiki`.++ * New `Text.Pandoc.Writers.FB2` module, exporting `writeFB2`+ (thanks to Sergey Astanin).++ * `Text.Pandoc`:++ + Added `getReader`, `getWriter` to `Text.Pandoc`.+ + `writers` is now an association list `(String, Writer)`.+ A `Writer` can be a `PureStringWriter`, an `IOStringWriter`, or+ an `IOByteStringWriter`. ALL writers are now in the 'writers'+ list, including the binary writers and FB2 writer. This allows+ code in `pandoc.hs` to be simplified.+ + Changed type of `readers`, so all readers are in IO.+ Users who want pure readers can still get them form the reader+ modules; this just affects the function `getReader` that looks up+ a reader based on the format name. The point of this change is to+ make it possible to print warnings from the parser.++ * `Text.Pandoc.Parsing`:++ + `Text.Parsec` now exports all Parsec functions used in pandoc code.+ No other module directly imports Parsec. This will make it easier+ to change the parsing backend in the future, if we want to.+ + `Text.Parsec` is used instead of `Text.ParserCombinators.Parsec`.+ + Export the type synonym `Parser`.+ + Export `widthsFromIndices`, `NoteTable'`, `KeyTable'`, `Key'`, `toKey'`,+ `withQuoteContext`, `singleQuoteStart`, `singleQuoteEnd`,+ `doubleQuoteStart`, `doubleQuoteEnd`, `ellipses`, `apostrophe`,+ `dash`, `nested`, `F(..)`, `askF`, `asksF`, `runF`, `lineBlockLines`.+ + `ParserState` is no longer an instance of `Show`.+ + Added `stateSubstitutions` and `stateWarnings` to `ParserState`.+ + Generalized type of `withQuoteContext`.+ + Added `guardEnabled`, `guardDisabled`, `getOption`.+ + Removed `failIfStrict`.+ + `lookupKeySrc` and `fromKey` are no longer exported.++ * `Data.Default` instances are now provided for `ReaderOptions`,+ `WriterOptions`, and `ParserState`. `Text.Pandoc` re-exports `def`.+ Now you can use `def` (which is re-exported by `Text.Pandoc`) instead+ of `defaultWriterOptions` (which is still defined). Closes #546.++ * `Text.Pandoc.Shared`:++ + Added `safeRead`.+ + Renamed `removedLeadingTrailingSpace` to `trim`,+ `removeLeadingSpace` to `triml`, and `removeTrailingSpace` to `trimr`.+ + Count `\r` as space in `trim` functions.+ + Moved `renderTags'` from HTML reader and `Text.Pandoc.SelfContained`+ to `Shared`.+ + Removed `failUnlessLHS`.+ + Export `compactify'`, formerly in Markdown reader.+ + Export `isTightList`.+ + Do not export `findDataFile`.+ + `readDataFile` now returns a strict ByteString.+ + Export `readDataFileUTF8` which returns a String, like the+ old `readDataFile`.+ + Export `fetchItem` and `openURL`.++ * `Text.Pandoc.ImageSize`: Use strict, not lazy bytestrings.+ Removed `readImageSize`.++ * `Text.Pandoc.UTF8`: Export `encodePath`, `decodePath`,+ `decodeArg`, `toString`, `fromString`, `toStringLazy`,+ `fromStringLazy`.++ * `Text.Pandoc.UTF8` is now an exposed module.++ * `Text.Pandoc.Biblio`:++ + csl parameter now a `String` rather than a `FilePath`.+ + Changed type of `processBiblio`. It is no longer in the IO monad.+ It now takes a `Maybe Style` argument rather than parameters for CSL+ and abbrev filenames. (`pandoc.hs` now calls the functions to parse+ the style file and add abbreviations.)++ * Markdown reader now exports `readMarkdownWithWarnings`.++ * `Text.Pandoc.RTF` now exports `writeRTFWithEmbeddedImages` instead of+ `rtfEmbedImage`.++ [bug fixes]++ * Make `--ascii` work properly with `--self-contained`. Closes #568.++ * Markdown reader:++ + Fixed link parser to avoid exponential slowdowns. Closes #620.+ Previously the parser would hang on input like this:++ [[[[[[[[[[[[[[[[[[hi++ We fixed this by making the link parser parser characters+ between balanced brackets (skipping brackets in inline code spans),+ then parsing the result as an inline list. One change is that++ [hi *there]* bud](/url)++ is now no longer parsed as a link. But in this respect pandoc behaved+ differently from most other implementations anyway, so that seems okay.++ + Look for raw html/latex blocks before tables.+ Otherwise the following gets parsed as a table:++ \begin{code}+ --------------+ -- My comment.+ \end{code}++ Closes #578.++ * RST reader:++ + Added support for `:target:` on `.. image::` blocks+ and substitutions.+ + Field list fixes:++ - Fixed field lists items with body beginning after a new line+ (Denis Laxalde).+ - Allow any char but ':' in names of field lists in RST reader+ (Denis Laxalde).+ - Don't allow line breaks in field names.+ - Require whitespace after field list field names.+ - Don't create empty definition list for metadata field lists.+ Previously a field list consisting only of metadata fields (author,+ title, date) would be parsed as an empty DefinitionList, which is+ not legal in LaTeX and not needed in any format.++ + Don't recognize inline-markup starts inside words.+ For example, `2*2 = 4*1` should not contain an emphasized+ section. Added test case for "Literal symbols". Closes #569.+ + Allow dashes as separator in simple tables. Closes #555.+ + Added support for `container`, `compound`, `epigraph`,+ `rubric`, `highlights`, `pull-quote`.+ + Added support for `.. code::`.+ + Made directive labels case-insensitive.+ + Removed requirement that directives begin at left margin.+ This was (correctly) not in earlier releases; docutils doesn't+ make the requirement.+ + Added support for `replace::` and `unicode::` substitutions.+ + Ignore unknown interpreted roles.+ + Renamed image parser to `subst`, since it now handles all+ substitution references.++ * Textile reader:++ + Allow newlines before pipes in table. Closes #654.+ + Fixed bug with list items containing line breaks.+ Now pandoc correctly handles hard line breaks inside list items.+ Previously they broke list parsing.+ + Implemented comment blocks.+ + Fixed bug affected words ending in hyphen.+ + Properly handle links with surrounding brackets.+ Square brackets need to be used when the link isn't surrounded by+ spaces or punctuation, or when the URL ending may be ambiguous.+ Closes #564.+ + Removed nullBlock. Better to know about parsing problems than+ to skip stuff when we get stuck.+ + Allow ID attributes on headers.+ + Textile reader: Avoid parsing dashes as strikeout.+ Previously the input++ text--+ text--+ text--+ text--++ would be parsed with strikeouts rather than dashes. This fixes+ the problem by requiring that a strikeout delimiting - not be+ followed by a -. Closes #631.+ + Expanded list of `stringBreakers`.+ This fixes a bug on input like "(_hello_)" which should+ be a parenthesized emphasized "hello".+ The new list is taken from the PHP source of textile 2.4.+ + Fixed autolinks. Previously the textile reader and writer+ incorrectly implented RST-style autolinks for URLs and email+ addresses. This has been fixed. Now an autolink is done this way:+ `"$":http://myurl.com`.+ + Fixed footnotes bug in textile. This affected notes occuring+ before punctuation, e.g. `foo[1].`. Closes #518.++ * LaTeX reader:++ + Better handling of citation commands.+ + Better handling of `\noindent`.+ + Added a 'try' in rawLaTeXBlock, so we can handle `\begin` without `{`.+ Closes #622.+ + Made `rawLaTeXInline` try to parse block commands as well. This+ is usually what we want, given how `rawLaTeXInline` is used in+ the markdown and textile readers. If a block-level LaTeX command+ is used in the middle of a paragraph (e.g. `\subtitle` inside a title),+ we can treat it as raw inline LaTeX.+ + Handle \slash command. Closes #605.+ + Basic `\enquote` support.+ + Fixed parsing of paragraphs beginning with a group. Closes #606.+ + Use curly quotes for bare straight quotes.+ + Support obeylines environment. Closes #604.+ + Guard against "begin", "end" in inlineCommand and+ blockCommand.+ + Better error messages for environments. Now it should tell you that+ it was looking for \end{env}, instead of giving "unknown parse error."++ * HTML reader:++ + Added HTML 5 tags to list of block-level tags.+ + HTML reader: Fixed bug in `htmlBalanced`, which+ caused hangs in parsing certain markdown input using+ strict mode.+ + Parse `<q>` as `Quoted DoubleQuote`.+ + Handle nested `<q>` tags properly.+ + Modified `htmlTag` for fewer false positives.+ A tag must start with `<` followed by `!`,`?`, `/`, or a letter.+ This makes it more useful in the wikimedia and markdown parsers.++ * DocBook reader: Support title in "figure" element. Closes #650.++ * MediaWiki writer:++ + Remove newline after `<br/>` in translation of `LineBreak`+ There's no particular need for a newline (other than making the+ generated MediaWiki source look nice to a human), and in fact+ sometimes it is incorrect: in particular, inside an enumeration, list+ items cannot have embedded newline characters. (Brent Yorgey)+ + Use `<code>` not `<tt>` for Code.++ * Man writer: Escape `-` as `\-`.+ Unescaped `-`'s become hyphens, while `\-`'s are left as ascii minus+ signs. That is preferable for use with command-line options. See+ <http://lintian.debian.org/tags/hyphen-used-as-minus-sign.html>. Thanks+ to Andrea Bolognani for bringing the issue to our attention.++ * RST writer:++ + Improved line block output. Use nonbreaking spaces for+ initial indent (otherwise lost in HTML and LaTeX).+ Allow multiple paragraphs in a single line block.+ Allow soft breaks w continuations in line blocks.+ + Properly handle images with no alt text. Closes #678.+ + Fixed bug with links with duplicate text. We now (a) use anonymous+ links for links with inline URLs, and (b) use an inline link instead+ of a reference link if the reference link would require a label that+ has already been used for a different link. Closes #511.+ + Fixed hyperlinked images. Closes #611. Use `:target:`+ field when you have a simple linked image.+ + Don't add `:align: center` to figures.++ * Texinfo writer: Fixed internal cross-references.+ Now we insert anchors after each header, and use `@ref` instead of `@uref`+ for links. Commas are now escaped as `@comma{}` only when needed;+ previously all commas were escaped. (This change is needed, in part,+ because `@ref` commands must be followed by a real comma or period.) Also+ insert a blank line in from of `@verbatim` environments.++ * DocBook writer:++ + Made --id-prefix work in DocBook as well as HTML.+ Closes #607.+ + Don't include empty captions in figures. Closes #581.++ * LaTeX writer:++ + Use `\hspace*` for nonbreaking space after line break,+ since `~` spaces after a line break are just ignored.+ Closes #687.+ + Don't escape `_` in URLs or hyperref identifiers.+ + Properly escape strings inside \url{}. Closes #576.+ + Use `[fragile]` only for slides containing code rendered+ using listings. Closes #649.+ + Escape `|` as `\vert` in LaTeX math. This avoids a clash with+ highlighting-kate's macros, which redefine `|` as a short verbatim+ delimiter. Thanks to Björn Peemöller for raising this issue.+ + Use minipage rather than parbox for block containers in tables.+ This allows verbatim code to be included in grid tables.+ Closes #663.+ + Prevent paragraphs containing only linebreaks or spaces.++ * HTML writer:++ + Included `highlighting-css` for code spans, too.+ Previously it was only included if used in a code block. Closes #653.+ + Improved line breaks with `<dd>` tags. We now put a newline between+ `</dd>` and `<dd>` when there are multiple definitions.+ + Changed mathjax cdn url so it doesn't use https. (This caused+ problems when used with `--self-contained`.) See #609.++ * EPUB writer:++ + `--number-sections` now works properly.+ + Don't strip meta and link elements in epub metadata.+ Patch from aberrancy. Closes #589.+ + Fixed a couple validation bugs.+ + Use ch001, ch002, etc. for chapter filenames. This improves sorting+ of chapters in some readers, which apparently sort ch2 after ch10.+ Closes #610.++ * ODT writer: properly set title property (Arlo O'Keeffe).++ * Docx writer:++ + Fixed bug with nested lists. Previously a list like++ 1. one+ - a+ - b+ 2. two++ would come out with a bullet instead of "2."+ Thanks to Russell Allen for reporting the bug.+ + Use `w:cr` in `w:r` instead of `w:br` for linebreaks.+ This seems to fix a problem viewing pandoc-generated+ docx files in LibreOffice.+ + Use integer ids for bookmarks. Closes #626.+ + Added nsid to abstractNum elements. This helps when merging+ word documents with numbered or bulleted lists. Closes #627.+ + Use separate footnotes.xml for notes.+ This seems to help LibreOffice convert the file, even though+ it was valid docx before. Closes #637.+ + Use rIdNN identifiers for r:embed in images.+ + Avoid reading image files again when we've already processed them.+ + Fixed typo in `referenc.docx` that prevented image captions from+ working. Thanks to Huashan Chen.++ * `Text.Pandoc.Parsing`:++ + Fixed bug in `withRaw`, which didn't correctly handle the case+ where nothing is parsed.+ + Made `emailAddress` parser more correct. Now it is based on RFC 822,+ though it still doesn't implement quoted strings in email addresses.+ + Revised URI parser. It now allows many more schemes, allows+ uppercase URIs, and better handles trailing punctuation and+ trailing slashes in bare URIs. Added many tests.+ + Simplified and improved singleQuoteStart. This makes `'s'`, `'l'`,+ etc. parse properly. Formerly we had some English-centric heuristics,+ but they are no longer needed. Closes #698.++ * `Text.Pandoc.Pretty`: Added wide punctuation range to `charWidth`.+ This fixes bug with Chinese commas in markdown and reST tables, and+ a bug that caused combining characters to be dropped.++ * `Text.Pandoc.MIME`: Added MIME types for .wof and .eot. Closes #640.++ * `Text.Pandoc.Biblio`:++ + Run `mvPunc` and `deNote` on metadata too.+ This fixed a bug with notes on titles using footnote styles.+ + Fixed bug in fetching CSL files from CSL data directory.++ * `pandoc.hs`: Give correct value to `writerSourceDirectory` when a URL+ is provided. It should be the URL up to the path.++ * Fixed/simplified diff output for tests.+ Biblio: Make sure mvPunc and deNote run on metadata too.+ This fixed a bug with notes on titles using footnote styles.++ [under the hood improvements]++ * We no longer depend on `utf8-string`. Instead we use functions+ defined in `Text.Pandoc.UTF8` that use `Data.Text`'s conversions.++ * Use `safeRead` instead of using `reads` directly (various modules).++ * "Implicit figures" (images alone in a paragraph) are now handled+ differently. The markdown reader gives their titles the prefix `fig:`; the+ writers look for this before treating the image as a figure. Though this+ is a bit of a hack, it has two advantages: (i) implicit figures can be+ limited to the markdown reader, and (ii) they can be deactivated by turning+ off the `implicit_figures` extension.++ * `catch` from `Control.Exception` is now used instead of the+ old Preface `catch`.++ * `Text.Pandoc.Shared`: Improved algorithm for `normalizeSpaces`+ and `oneOfStrings` (which is now non-backtracking).++ * `Text.Pandoc.Biblio`: Remove workaround for `toCapital`.+ Now citeproc-hs is fixed upstream, so this is no longer needed.+ Closes #531.++ * Textile reader: Improved speed of `hyphenedWords`.+ This speeds up the textile reader by about a factor of 4.++ * Use `Text.Pandoc.Builder` in RST reader, for more flexibility,+ better performance, and automatic normalization.++ * Major rewrite of markdown reader:++ + Use `Text.Pandoc.Builder` instead of lists. This also+ means that everything is normalized automatically.+ + Move to a one-pass parsing strategy, returning values in the reader+ monad, which are then run (at the end of parsing) against the final+ parser state.++ * In HTML writer, we now use `toHtml` instead of pre-escaping.+ We work around the problem that blaze-html unnecessarily escapes `'`+ by pre-escaping just the `'` characters, instead of the whole string.+ If blaze-html later stops escaping `'` characters, we can simplify+ `strToHtml` to `toHtml`. Closes #629.++ * Moved code for embedding images in RTFs from `pandoc.hs` to the+ RTF writer (which now exports `writeRTFWithEmbeddedImages`).++ * Moved citation processing from `pandoc.hs` into the readers.+ This makes things more convenient for library users.++ * The man pages are now built by an executable `make-pandoc-man-pages`,+ which has its own stanza in the cabal file so that dependencies can be+ handled by Cabal. Special treatment in `Setup.hs` ensures that this+ executable never gets installed; it is only used to create the man pages.++ * The cabal file has been modified so that the pandoc library is used+ in building the pandoc executable. (This required moving `pandoc.hs`+ from `src` to `.`.) This cuts compile time in half.++ * `-O2` is no longer used in building pandoc. The performance improvement+ it yields is so slight that it is not worth it. (Measured with+ benchmarks on ghc 7.4.)++ * The `executable` and `library` flags have been removed.++ * `-threaded` has been removed from ghc-options.++ * Version bounds of dependencies have been raised, and the+ `blaze_html_0_5` flag now defaults to True. Pandoc now compiles on+ GHC 7.6.++ * We now require base >= 4.2.++ * Integrated the benchmark program into cabal. One can now do:++ cabal configure --enable-benchmarks && cabal build+ cabal bench --benchmark-option='markdown' --benchmark-option='-s 20'++ The benchmark now uses README + testsuite, so benchmark results+ from older versions aren't comparable.++ * Integrated test suite with cabal.+ To run tests, configure with `--enable-tests`, then `cabal test`.+ You can specify particular tests using `--test-options='-t markdown'`.+ No output is shown unless tests fail. The Haskell test modules+ have been moved from `src/` to `tests/`.++ * Moved all data files and templates to the `data/` subdirectory.++ * Added an `embed_data_files` cabal flag. This causes all+ data files to be embedded in the binary, so that the binary+ is self-sufficient and can be relocated anywhere, copied on+ a USB key, etc. The Windows installer now uses this.+ (Since we no longer have the option to build the executable+ without the library, this is the only way to get a relocatable+ binary on Windows.)++ * Removed pcre3.dll from windows package.+ It isn't needed unless highlighting-kate is compilled with the+ `pcre-light` flag. By default, regex-prce-builtin is used.+ pandoc (1.9.4.2)
@@ -0,0 +1,422 @@+<?xml version="1.0" encoding="utf-8"?>+<style xmlns="http://purl.org/net/xbiblio/csl" class="in-text" version="1.0" demote-non-dropping-particle="sort-only">+ <info>+ <title>Chicago Manual of Style (Author-Date format)</title>+ <id>http://www.zotero.org/styles/chicago-author-date</id>+ <link href="http://www.zotero.org/styles/chicago-author-date" rel="self"/>+ <author>+ <name>Julian Onions</name>+ <email>julian.onions@gmail.com</email>+ </author>+ <contributor>+ <name>Sebastian Karcher</name>+ </contributor>+ <category citation-format="author-date"/>+ <category field="generic-base"/>+ <updated>2011-11-17T22:01:05+00:00</updated>+ <summary>The author-date variant of the Chicago style</summary>+ <link href="http://www.chicagomanualofstyle.org/tools_citationguide.html" rel="documentation"/>+ <rights>This work is licensed under a Creative Commons Attribution-Share Alike 3.0 License: http://creativecommons.org/licenses/by-sa/3.0/</rights>+ </info>+ <macro name="secondary-contributors">+ <choose>+ <if type="chapter paper-conference" match="none">+ <group delimiter=". ">+ <choose>+ <if variable="author">+ <names variable="editor">+ <label form="verb-short" text-case="capitalize-first" suffix=". " strip-periods="true"/>+ <name and="text" delimiter=", "/>+ </names>+ </if>+ </choose>+ <choose>+ <if variable="author editor" match="any">+ <names variable="translator">+ <label form="verb-short" text-case="capitalize-first" suffix=". " strip-periods="true"/>+ <name and="text" delimiter=", "/>+ </names>+ </if>+ </choose>+ </group>+ </if>+ </choose>+ </macro>+ <macro name="container-contributors">+ <choose>+ <if type="chapter paper-conference" match="any">+ <group prefix="," delimiter=", ">+ <choose>+ <if variable="author">+ <names variable="editor">+ <label form="verb-short" prefix=" " text-case="lowercase" suffix=". " strip-periods="true"/>+ <name and="text" delimiter=", "/>+ </names>+ <choose>+ <if variable="container-author">+ <group>+ <names variable="container-author">+ <label form="verb-short" prefix=" " text-case="lowercase" suffix=" " strip-periods="true"/>+ <name and="text" delimiter=", "/>+ </names>+ </group>+ </if>+ </choose>+ </if>+ </choose>+ <choose>+ <if variable="author editor" match="any">+ <names variable="translator">+ <label form="verb-short" prefix=" " text-case="lowercase" suffix=". " strip-periods="true"/>+ <name and="text" delimiter=", "/>+ </names>+ </if>+ </choose>+ </group>+ </if>+ </choose>+ </macro>+ <macro name="anon">+ <text term="anonymous" form="short" text-case="capitalize-first" suffix="." strip-periods="true"/>+ </macro>+ <macro name="editor">+ <names variable="editor">+ <name name-as-sort-order="first" and="text" sort-separator=", " delimiter=", " delimiter-precedes-last="always"/>+ <label form="short" prefix=", " suffix="." strip-periods="true"/>+ </names>+ </macro>+ <macro name="translator">+ <names variable="translator">+ <name name-as-sort-order="first" and="text" sort-separator=", " delimiter=", " delimiter-precedes-last="always"/>+ <label form="verb-short" prefix=", " suffix="." strip-periods="true"/>+ </names>+ </macro>+ <macro name="recipient">+ <choose>+ <if type="personal_communication">+ <choose>+ <if variable="genre">+ <text variable="genre" text-case="capitalize-first"/>+ </if>+ <else>+ <text term="letter" text-case="capitalize-first"/>+ </else>+ </choose>+ </if>+ </choose>+ <names variable="recipient" delimiter=", ">+ <label form="verb" prefix=" " text-case="lowercase" suffix=" "/>+ <name and="text" delimiter=", "/>+ </names>+ </macro>+ <macro name="contributors">+ <names variable="author">+ <name and="text" name-as-sort-order="first" sort-separator=", " delimiter=", " delimiter-precedes-last="always"/>+ <label form="verb-short" prefix=", " suffix="." text-case="lowercase" strip-periods="true"/>+ <substitute>+ <text macro="editor"/>+ <text macro="translator"/>+ <text macro="anon"/>+ </substitute>+ </names>+ <text macro="recipient"/>+ </macro>+ <macro name="contributors-short">+ <names variable="author">+ <name form="short" and="text" delimiter=", " initialize-with=". "/>+ <substitute>+ <names variable="editor"/>+ <names variable="translator"/>+ <text macro="anon"/>+ </substitute>+ </names>+ </macro>+ <macro name="interviewer">+ <names variable="interviewer" delimiter=", ">+ <label form="verb" prefix=" " text-case="capitalize-first" suffix=" "/>+ <name and="text" delimiter=", "/>+ </names>+ </macro>+ <macro name="archive">+ <group delimiter=". ">+ <text variable="archive_location" text-case="capitalize-first"/>+ <text variable="archive"/>+ <text variable="archive-place"/>+ </group>+ </macro>+ <macro name="access">+ <group delimiter=". ">+ <choose>+ <if type="graphic report" match="any">+ <text macro="archive"/>+ </if>+ <else-if type="bill book graphic legal_case motion_picture report song article-magazine article-newspaper thesis chapter paper-conference" match="none">+ <text macro="archive"/>+ </else-if>+ </choose>+ <text variable="DOI" prefix="doi:"/>+ <choose>+ <if type="legal_case" match="none">+ <text variable="URL"/>+ </if>+ </choose>+ </group>+ </macro>+ <macro name="title">+ <choose>+ <if variable="title" match="none">+ <choose>+ <if type="personal_communication" match="none">+ <text variable="genre" text-case="capitalize-first"/>+ </if>+ </choose>+ </if>+ <else-if type="bill book graphic legal_case motion_picture report song" match="any">+ <text variable="title" font-style="italic"/>+ </else-if>+ <else>+ <text variable="title" quotes="true"/>+ </else>+ </choose>+ </macro>+ <macro name="edition">+ <choose>+ <if type="bill book graphic legal_case motion_picture report song chapter paper-conference" match="any">+ <choose>+ <if is-numeric="edition">+ <group delimiter=" ">+ <number variable="edition" form="ordinal"/>+ <text term="edition" form="short" suffix="." strip-periods="true"/>+ </group>+ </if>+ <else>+ <text variable="edition" suffix="."/>+ </else>+ </choose>+ </if>+ </choose>+ </macro>+ <macro name="locators">+ <choose>+ <if type="article-journal">+ <text variable="volume" prefix=" "/>+ <text variable="issue" prefix=" (" suffix=")"/>+ </if>+ <else-if type="legal_case">+ <text variable="volume" prefix=", "/>+ <text variable="container-title" prefix=" "/>+ <text variable="page" prefix=" "/>+ </else-if>+ <else-if type="bill book graphic legal_case motion_picture report song" match="any">+ <group prefix=". " delimiter=". ">+ <group>+ <text term="volume" form="short" text-case="capitalize-first" suffix=". " strip-periods="true"/>+ <number variable="volume" form="numeric"/>+ </group>+ <group>+ <number variable="number-of-volumes" form="numeric"/>+ <text term="volume" form="short" prefix=" " suffix="." plural="true" strip-periods="true"/>+ </group>+ </group>+ </else-if>+ <else-if type="chapter paper-conference" match="any">+ <choose>+ <if variable="page" match="none">+ <group prefix=". ">+ <text term="volume" form="short" text-case="capitalize-first" suffix=". " strip-periods="true"/>+ <number variable="volume" form="numeric"/>+ </group>+ </if>+ </choose>+ </else-if>+ </choose>+ </macro>+ <macro name="locators-chapter">+ <choose>+ <if type="chapter paper-conference" match="any">+ <choose>+ <if variable="page">+ <group prefix=", ">+ <text variable="volume" suffix=":"/>+ <text variable="page"/>+ </group>+ </if>+ </choose>+ </if>+ </choose>+ </macro>+ <macro name="locators-article">+ <choose>+ <if type="article-newspaper">+ <group prefix=", " delimiter=", ">+ <group>+ <text variable="edition" suffix=" "/>+ <text term="edition" prefix=" "/>+ </group>+ <group>+ <text term="section" form="short" suffix=". " strip-periods="true"/>+ <text variable="section"/>+ </group>+ </group>+ </if>+ <else-if type="article-journal">+ <text variable="page" prefix=": "/>+ </else-if>+ </choose>+ </macro>+ <macro name="point-locators">+ <choose>+ <if variable="locator">+ <choose>+ <if locator="page" match="none">+ <choose>+ <if type="bill book graphic legal_case motion_picture report song" match="any">+ <choose>+ <if variable="volume">+ <group>+ <text term="volume" form="short" text-case="lowercase" suffix=". " strip-periods="true"/>+ <number variable="volume" form="numeric"/>+ <label variable="locator" form="short" prefix=", " suffix=" "/>+ </group>+ </if>+ <else>+ <label variable="locator" form="short" suffix=" "/>+ </else>+ </choose>+ </if>+ </choose>+ </if>+ <else-if type="bill book graphic legal_case motion_picture report song" match="any">+ <number variable="volume" form="numeric" suffix=":"/>+ </else-if>+ </choose>+ <text variable="locator"/>+ </if>+ </choose>+ </macro>+ <macro name="container-prefix">+ <text term="in" text-case="capitalize-first"/>+ </macro>+ <macro name="container-title">+ <choose>+ <if type="chapter paper-conference" match="any">+ <text macro="container-prefix" suffix=" "/>+ </if>+ </choose>+ <choose>+ <if type="legal_case" match="none">+ <text variable="container-title" font-style="italic"/>+ </if>+ </choose>+ </macro>+ <macro name="publisher">+ <group delimiter=": ">+ <text variable="publisher-place"/>+ <text variable="publisher"/>+ </group>+ </macro>+ <macro name="date">+ <date variable="issued">+ <date-part name="year"/>+ </date>+ </macro>+ <macro name="day-month">+ <date variable="issued">+ <date-part name="month"/>+ <date-part name="day" prefix=" "/>+ </date>+ </macro>+ <macro name="collection-title">+ <text variable="collection-title"/>+ <text variable="collection-number" prefix=" "/>+ </macro>+ <macro name="event">+ <group>+ <text term="presented at" suffix=" "/>+ <text variable="event"/>+ </group>+ </macro>+ <macro name="description">+ <choose>+ <if type="interview">+ <group delimiter=". ">+ <text macro="interviewer"/>+ <text variable="medium" text-case="capitalize-first"/>+ </group>+ </if>+ <else>+ <text variable="medium" text-case="capitalize-first" prefix=". "/>+ </else>+ </choose>+ <choose>+ <if variable="title" match="none"/>+ <else-if type="thesis"/>+ <else>+ <text variable="genre" text-case="capitalize-first" prefix=". "/>+ </else>+ </choose>+ </macro>+ <macro name="issue">+ <choose>+ <if type="article-journal">+ <text macro="day-month" prefix=" (" suffix=")"/>+ </if>+ <else-if type="legal_case">+ <text variable="authority" prefix=". "/>+ </else-if>+ <else-if type="speech">+ <group prefix=" " delimiter=", ">+ <text macro="event"/>+ <text macro="day-month"/>+ <text variable="event-place"/>+ </group>+ </else-if>+ <else-if type="article-newspaper article-magazine" match="any">+ <text macro="day-month" prefix=", "/>+ </else-if>+ <else>+ <group prefix=". " delimiter=", ">+ <choose>+ <if type="thesis">+ <text variable="genre" text-case="capitalize-first"/>+ </if>+ </choose>+ <text macro="publisher"/>+ </group>+ </else>+ </choose>+ </macro>+ <citation et-al-min="4" et-al-use-first="1" disambiguate-add-year-suffix="true" disambiguate-add-names="true" disambiguate-add-givenname="true" givenname-disambiguation-rule="primary-name">+ <layout prefix="(" suffix=")" delimiter="; ">+ <group delimiter=", ">+ <group delimiter=" ">+ <text macro="contributors-short"/>+ <text macro="date"/>+ </group>+ <text macro="point-locators"/>+ </group>+ </layout>+ </citation>+ <bibliography hanging-indent="true" et-al-min="11" et-al-use-first="7" subsequent-author-substitute="———" entry-spacing="0">+ <sort>+ <key macro="contributors"/>+ <key variable="issued"/>+ </sort>+ <layout suffix=".">+ <text macro="contributors" suffix=". "/>+ <text macro="date" suffix=". "/>+ <text macro="title"/>+ <text macro="description"/>+ <text macro="secondary-contributors" prefix=". "/>+ <text macro="container-title" prefix=". "/>+ <text macro="container-contributors"/>+ <text macro="locators-chapter"/>+ <text macro="edition" prefix=". "/>+ <text macro="locators"/>+ <text macro="collection-title" prefix=". "/>+ <text macro="issue"/>+ <text macro="locators-article"/>+ <text macro="access" prefix=". "/>+ </layout>+ </bibliography>+</style>
@@ -0,0 +1,585 @@+<!DOCTYPE html>++<meta charset="utf-8">+<title>The Title Of Your Presentation</title>++<!-- Your Slides -->+<!-- One section is one slide -->++<section>+ <!-- This is the first slide -->+ <h1>My Presentation</h1>+ <footer>by John Doe</footer>+</section>++<section>+ <p>Some random text: But I've never been to the moon! You can see how I lived before I met you. Also Zoidberg.+ I could if you hadn't turned on the light and shut off my stereo.</p>+</section>++<section>+ <h3>An incremental list</h3>+ <ul class="incremental">+ <li>Item 1+ <li>Item 2+ <li>Item 3+ </ul>+ <details>Some notes. They are only visible using onstage shell.</details>+</section>++<section>+ <q>+ Who's brave enough to fly into something we all keep calling a death sphere?+ </q>+</section>++<section>+ <h2>Part two</h2>+</section>++<section>+ <figure> <!-- Figures are used to display images and videos fullpage -->+ <img src="http://placekitten.com/g/800/600">+ <figcaption>An image</figcaption>+ </figure>+ <details>Kittens are so cute!</details>+</section>++<section>+ <figure> <!-- Videos are automatically played -->+ <video src="http://videos-cdn.mozilla.net/brand/Mozilla_Firefox_Manifesto_v0.2_640.webm" poster="http://www.mozilla.org/images/about/poster.jpg"></video>+ <figcaption>A video</figcaption>+ </figure>+</section>++<section>+ <h2>End!</h2>+</section>++<!-- Your Style -->+<!-- Define the style of your presentation -->++<!-- Maybe a font from http://www.google.com/webfonts ? -->+<link href='http://fonts.googleapis.com/css?family=Oswald' rel='stylesheet'>++<style>+ html { background-color: black; }+ body { background-color: white; border-radius: 12px}+ /* A section is a slide. It's size is 800x600, and this will never change */+ section {+ /* The font from Google */+ font-family: 'Oswald', arial, serif;+ font-size: 30px;+ }+ h1, h2 {+ margin-top: 200px;+ text-align: center;+ font-size: 80px;+ }+ h3 {+ margin: 100px 0 50px 100px;+ }++ ul {+ margin: 50px 200px;+ }++ p {+ margin: 75px;+ font-size: 50px;+ }++ q {+ display: block;+ width: 100%;+ height: 100%;+ background-color: black;+ color: white;+ font-size: 60px;+ padding: 50px;+ }++ /* Figures are displayed full-page, with the caption+ on top of the image/video */+ figure {+ background-color: black;+ }+ figcaption {+ margin: 70px;+ font-size: 50px;+ }++ footer {+ position: absolute;+ bottom: 0;+ width: 100%;+ padding: 40px;+ text-align: right;+ background-color: #F3F4F8;+ border-top: 1px solid #CCC;+ }++ /* Transition effect */+ /* Feel free to change the transition effect for original+ animations. See here:+ https://developer.mozilla.org/en/CSS/CSS_transitions+ How to use CSS3 Transitions: */+ section {+ -moz-transition: left 400ms linear 0s;+ -webkit-transition: left 400ms linear 0s;+ -ms-transition: left 400ms linear 0s;+ transition: left 400ms linear 0s;+ }++ /* Before */+ section { left: -150%; }+ /* Now */+ section[aria-selected] { left: 0; }+ /* After */+ section[aria-selected] ~ section { left: +150%; }++ /* Incremental elements */++ /* By default, visible */+ .incremental > * { opacity: 1; }++ /* The current item */+ .incremental > *[aria-selected] { opacity: 1; }++ /* The items to-be-selected */+ .incremental > *[aria-selected] ~ * { opacity: 0; }++ /* The progressbar, at the bottom of the slides, show the global+ progress of the presentation. */+ #progress-bar {+ height: 2px;+ background: #AAA;+ }+</style>++<!-- {{{{ dzslides core+#+#+# __ __ __ . __ ___ __+# | \ / /__` | | | \ |__ /__`+# |__/ /_ .__/ |___ | |__/ |___ .__/ core :€+#+#+# The following block of code is not supposed to be edited.+# But if you want to change the behavior of these slides,+# feel free to hack it!+#+-->++<div id="progress-bar"></div>++<!-- Default Style -->+<style>+ * { margin: 0; padding: 0; -moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box; }+ details { display: none; }+ body {+ width: 800px; height: 600px;+ margin-left: -400px; margin-top: -300px;+ position: absolute; top: 50%; left: 50%;+ overflow: hidden;+ }+ section {+ position: absolute;+ pointer-events: none;+ width: 100%; height: 100%;+ }+ section[aria-selected] { pointer-events: auto; }+ html { overflow: hidden; }+ body { display: none; }+ body.loaded { display: block; }+ .incremental {visibility: hidden; }+ .incremental[active] {visibility: visible; }+ #progress-bar{+ bottom: 0;+ position: absolute;+ -moz-transition: width 400ms linear 0s;+ -webkit-transition: width 400ms linear 0s;+ -ms-transition: width 400ms linear 0s;+ transition: width 400ms linear 0s;+ }+ figure {+ width: 100%;+ height: 100%;+ }+ figure > * {+ position: absolute;+ }+ figure > img, figure > video {+ width: 100%; height: 100%;+ }+</style>++<script>+ var Dz = {+ remoteWindows: [],+ idx: -1,+ step: 0,+ slides: null,+ progressBar : null,+ params: {+ autoplay: "1"+ }+ };++ Dz.init = function() {+ document.body.className = "loaded";+ this.slides = $$("body > section");+ this.progressBar = $("#progress-bar");+ this.setupParams();+ this.onhashchange();+ this.setupTouchEvents();+ this.onresize();+ }+ + Dz.setupParams = function() {+ var p = window.location.search.substr(1).split('&');+ p.forEach(function(e, i, a) {+ var keyVal = e.split('=');+ Dz.params[keyVal[0]] = decodeURIComponent(keyVal[1]);+ });+ // Specific params handling+ if (!+this.params.autoplay)+ $$.forEach($$("video"), function(v){ v.controls = true });+ }++ Dz.onkeydown = function(aEvent) {+ // Don't intercept keyboard shortcuts+ if (aEvent.altKey+ || aEvent.ctrlKey+ || aEvent.metaKey+ || aEvent.shiftKey) {+ return;+ }+ if ( aEvent.keyCode == 37 // left arrow+ || aEvent.keyCode == 38 // up arrow+ || aEvent.keyCode == 33 // page up+ ) {+ aEvent.preventDefault();+ this.back();+ }+ if ( aEvent.keyCode == 39 // right arrow+ || aEvent.keyCode == 40 // down arrow+ || aEvent.keyCode == 34 // page down+ ) {+ aEvent.preventDefault();+ this.forward();+ }+ if (aEvent.keyCode == 35) { // end+ aEvent.preventDefault();+ this.goEnd();+ }+ if (aEvent.keyCode == 36) { // home+ aEvent.preventDefault();+ this.goStart();+ }+ if (aEvent.keyCode == 32) { // space+ aEvent.preventDefault();+ this.toggleContent();+ }+ if (aEvent.keyCode == 70) { // f+ aEvent.preventDefault();+ this.goFullscreen();+ }+ }++ /* Touch Events */++ Dz.setupTouchEvents = function() {+ var orgX, newX;+ var tracking = false;++ var db = document.body;+ db.addEventListener("touchstart", start.bind(this), false);+ db.addEventListener("touchmove", move.bind(this), false);++ function start(aEvent) {+ aEvent.preventDefault();+ tracking = true;+ orgX = aEvent.changedTouches[0].pageX;+ }++ function move(aEvent) {+ if (!tracking) return;+ newX = aEvent.changedTouches[0].pageX;+ if (orgX - newX > 100) {+ tracking = false;+ this.forward();+ } else {+ if (orgX - newX < -100) {+ tracking = false;+ this.back();+ }+ }+ }+ }++ /* Adapt the size of the slides to the window */++ Dz.onresize = function() {+ var db = document.body;+ var sx = db.clientWidth / window.innerWidth;+ var sy = db.clientHeight / window.innerHeight;+ var transform = "scale(" + (1/Math.max(sx, sy)) + ")";++ db.style.MozTransform = transform;+ db.style.WebkitTransform = transform;+ db.style.OTransform = transform;+ db.style.msTransform = transform;+ db.style.transform = transform;+ }+++ Dz.getDetails = function(aIdx) {+ var s = $("section:nth-of-type(" + aIdx + ")");+ var d = s.$("details");+ return d ? d.innerHTML : "";+ }++ Dz.onmessage = function(aEvent) {+ var argv = aEvent.data.split(" "), argc = argv.length;+ argv.forEach(function(e, i, a) { a[i] = decodeURIComponent(e) });+ var win = aEvent.source;+ if (argv[0] === "REGISTER" && argc === 1) {+ this.remoteWindows.push(win);+ this.postMsg(win, "REGISTERED", document.title, this.slides.length);+ this.postMsg(win, "CURSOR", this.idx + "." + this.step);+ return;+ }+ if (argv[0] === "BACK" && argc === 1)+ this.back();+ if (argv[0] === "FORWARD" && argc === 1)+ this.forward();+ if (argv[0] === "START" && argc === 1)+ this.goStart();+ if (argv[0] === "END" && argc === 1)+ this.goEnd();+ if (argv[0] === "TOGGLE_CONTENT" && argc === 1)+ this.toggleContent();+ if (argv[0] === "SET_CURSOR" && argc === 2)+ window.location.hash = "#" + argv[1];+ if (argv[0] === "GET_CURSOR" && argc === 1)+ this.postMsg(win, "CURSOR", this.idx + "." + this.step);+ if (argv[0] === "GET_NOTES" && argc === 1)+ this.postMsg(win, "NOTES", this.getDetails(this.idx));+ }++ Dz.toggleContent = function() {+ // If a Video is present in this new slide, play it.+ // If a Video is present in the previous slide, stop it.+ var s = $("section[aria-selected]");+ if (s) {+ var video = s.$("video");+ if (video) {+ if (video.ended || video.paused) {+ video.play();+ } else {+ video.pause();+ }+ }+ }+ }++ Dz.setCursor = function(aIdx, aStep) {+ // If the user change the slide number in the URL bar, jump+ // to this slide.+ aStep = (aStep != 0 && typeof aStep !== "undefined") ? "." + aStep : ".0";+ window.location.hash = "#" + aIdx + aStep;+ }++ Dz.onhashchange = function() {+ var cursor = window.location.hash.split("#"),+ newidx = 1,+ newstep = 0;+ if (cursor.length == 2) {+ newidx = ~~cursor[1].split(".")[0];+ newstep = ~~cursor[1].split(".")[1];+ if (newstep > Dz.slides[newidx - 1].$$('.incremental > *').length) {+ newstep = 0;+ newidx++;+ }+ }+ this.setProgress(newidx, newstep);+ if (newidx != this.idx) {+ this.setSlide(newidx);+ }+ if (newstep != this.step) {+ this.setIncremental(newstep);+ }+ for (var i = 0; i < this.remoteWindows.length; i++) {+ this.postMsg(this.remoteWindows[i], "CURSOR", this.idx + "." + this.step);+ }+ }++ Dz.back = function() {+ if (this.idx == 1 && this.step == 0) {+ return;+ }+ if (this.step == 0) {+ this.setCursor(this.idx - 1,+ this.slides[this.idx - 2].$$('.incremental > *').length);+ } else {+ this.setCursor(this.idx, this.step - 1);+ }+ }++ Dz.forward = function() {+ if (this.idx >= this.slides.length &&+ this.step >= this.slides[this.idx - 1].$$('.incremental > *').length) {+ return;+ }+ if (this.step >= this.slides[this.idx - 1].$$('.incremental > *').length) {+ this.setCursor(this.idx + 1, 0);+ } else {+ this.setCursor(this.idx, this.step + 1);+ }+ }++ Dz.goStart = function() {+ this.setCursor(1, 0);+ }++ Dz.goEnd = function() {+ var lastIdx = this.slides.length;+ var lastStep = this.slides[lastIdx - 1].$$('.incremental > *').length;+ this.setCursor(lastIdx, lastStep);+ }++ Dz.setSlide = function(aIdx) {+ this.idx = aIdx;+ var old = $("section[aria-selected]");+ var next = $("section:nth-of-type("+ this.idx +")");+ if (old) {+ old.removeAttribute("aria-selected");+ var video = old.$("video");+ if (video) {+ video.pause();+ }+ }+ if (next) {+ next.setAttribute("aria-selected", "true");+ var video = next.$("video");+ if (video && !!+this.params.autoplay) {+ video.play();+ }+ } else {+ // That should not happen+ this.idx = -1;+ // console.warn("Slide doesn't exist.");+ }+ }++ Dz.setIncremental = function(aStep) {+ this.step = aStep;+ var old = this.slides[this.idx - 1].$('.incremental > *[aria-selected]');+ if (old) {+ old.removeAttribute('aria-selected');+ }+ var incrementals = $$('.incremental');+ if (this.step <= 0) {+ $$.forEach(incrementals, function(aNode) {+ aNode.removeAttribute('active');+ });+ return;+ }+ var next = this.slides[this.idx - 1].$$('.incremental > *')[this.step - 1];+ if (next) {+ next.setAttribute('aria-selected', true);+ next.parentNode.setAttribute('active', true);+ var found = false;+ $$.forEach(incrementals, function(aNode) {+ if (aNode != next.parentNode)+ if (found)+ aNode.removeAttribute('active');+ else+ aNode.setAttribute('active', true);+ else+ found = true;+ });+ } else {+ setCursor(this.idx, 0);+ }+ return next;+ }++ Dz.goFullscreen = function() {+ var html = $('html'),+ requestFullscreen = html.requestFullscreen || html.requestFullScreen || html.mozRequestFullScreen || html.webkitRequestFullScreen;+ if (requestFullscreen) {+ requestFullscreen.apply(html);+ }+ }+ + Dz.setProgress = function(aIdx, aStep) {+ var slide = $("section:nth-of-type("+ aIdx +")");+ if (!slide)+ return;+ var steps = slide.$$('.incremental > *').length + 1,+ slideSize = 100 / (this.slides.length - 1),+ stepSize = slideSize / steps;+ this.progressBar.style.width = ((aIdx - 1) * slideSize + aStep * stepSize) + '%';+ }+ + Dz.postMsg = function(aWin, aMsg) { // [arg0, [arg1...]]+ aMsg = [aMsg];+ for (var i = 2; i < arguments.length; i++)+ aMsg.push(encodeURIComponent(arguments[i]));+ aWin.postMessage(aMsg.join(" "), "*");+ }+ + function init() {+ Dz.init();+ window.onkeydown = Dz.onkeydown.bind(Dz);+ window.onresize = Dz.onresize.bind(Dz);+ window.onhashchange = Dz.onhashchange.bind(Dz);+ window.onmessage = Dz.onmessage.bind(Dz);+ }++ window.onload = init;+</script>+++<script> // Helpers+ if (!Function.prototype.bind) {+ Function.prototype.bind = function (oThis) {++ // closest thing possible to the ECMAScript 5 internal IsCallable+ // function + if (typeof this !== "function")+ throw new TypeError(+ "Function.prototype.bind - what is trying to be fBound is not callable"+ );++ var aArgs = Array.prototype.slice.call(arguments, 1),+ fToBind = this,+ fNOP = function () {},+ fBound = function () {+ return fToBind.apply( this instanceof fNOP ? this : oThis || window,+ aArgs.concat(Array.prototype.slice.call(arguments)));+ };++ fNOP.prototype = this.prototype;+ fBound.prototype = new fNOP();++ return fBound;+ };+ }++ var $ = (HTMLElement.prototype.$ = function(aQuery) {+ return this.querySelector(aQuery);+ }).bind(document);++ var $$ = (HTMLElement.prototype.$$ = function(aQuery) {+ return this.querySelectorAll(aQuery);+ }).bind(document);++ $$.forEach = function(nodeList, fun) {+ Array.prototype.forEach.call(nodeList, fun);+ }++</script>+<!-- vim: set fdm=marker: }}} -->
@@ -0,0 +1,31 @@+/* This defines styles and classes used in the book */+body { margin-left: 5%; margin-right: 5%; margin-top: 5%; margin-bottom: 5%; text-align: justify; font-size: medium; }+code { font-family: monospace; }+h1 { text-align: left; }+h2 { text-align: left; }+h3 { text-align: left; }+h4 { text-align: left; }+h5 { text-align: left; }+h6 { text-align: left; }+h1.title { }+h2.author { }+h3.date { }+/* For source-code highlighting */+table.sourceCode, tr.sourceCode, td.lineNumbers, td.sourceCode, table.sourceCode pre+ { margin: 0; padding: 0; border: 0; vertical-align: baseline; border: none; }+td.lineNumbers { border-right: 1px solid #AAAAAA; text-align: right; color: #AAAAAA; padding-right: 5px; padding-left: 5px; }+td.sourceCode { padding-left: 5px; }+pre.sourceCode { }+code.sourceCode span.kw { color: #007020; font-weight: bold; }+code.sourceCode span.dt { color: #902000; }+code.sourceCode span.dv { color: #40a070; }+code.sourceCode span.bn { color: #40a070; }+code.sourceCode span.fl { color: #40a070; }+code.sourceCode span.ch { color: #4070a0; }+code.sourceCode span.st { color: #4070a0; }+code.sourceCode span.co { color: #60a0b0; font-style: italic; }+code.sourceCode span.ot { color: #007020; }+code.sourceCode span.al { color: red; font-weight: bold; }+code.sourceCode span.fu { color: #06287e; }+code.sourceCode span.re { }+code.sourceCode span.er { color: red; font-weight: bold; }
binary file changed (absent → 9748 bytes)
binary file changed (absent → 7058 bytes)
binary file changed (absent → 49 bytes)
binary file changed (absent → 10119 bytes)
@@ -0,0 +1,23 @@+/* The following styles size, place, and layer the slide components.+ Edit these if you want to change the overall slide layout.+ The commented lines can be uncommented (and modified, if necessary) + to help you with the rearrangement process. */++/* target = 1024x768 */++div#header, div#footer, .slide {width: 100%; top: 0; left: 0;}+div#header {top: 0; height: 3em; z-index: 1;}+div#footer {top: auto; bottom: 0; height: 2.5em; z-index: 5;}+.slide {top: 0; width: 92%; padding: 3.5em 4% 4%; z-index: 2; list-style: none;}+div#controls {left: 50%; bottom: 0; width: 50%; z-index: 100;}+div#controls form {position: absolute; bottom: 0; right: 0; width: 100%;+ margin: 0;}+#currentSlide {position: absolute; width: 10%; left: 45%; bottom: 1em; z-index: 10;}+html>body #currentSlide {position: fixed;}++/*+div#header {background: #FCC;}+div#footer {background: #CCF;}+div#controls {background: #BBD;}+div#currentSlide {background: #FFC;}+*/
@@ -0,0 +1,42 @@+<public:component> +<public:attach event="onpropertychange" onevent="doFix()" /> + +<script> + +// IE5.5+ PNG Alpha Fix v1.0 by Angus Turnbull http://www.twinhelix.com +// Free usage permitted as long as this notice remains intact. + +// This must be a path to a blank image. That's all the configuration you need here. +var blankImg = 'ui/default/blank.gif'; + +var f = 'DXImageTransform.Microsoft.AlphaImageLoader'; + +function filt(s, m) { + if (filters[f]) { + filters[f].enabled = s ? true : false; + if (s) with (filters[f]) { src = s; sizingMethod = m } + } else if (s) style.filter = 'progid:'+f+'(src="'+s+'",sizingMethod="'+m+'")'; +} + +function doFix() { + if ((parseFloat(navigator.userAgent.match(/MSIE (\S+)/)[1]) < 5.5) || + (event && !/(background|src)/.test(event.propertyName))) return; + + if (tagName == 'IMG') { + if ((/\.png$/i).test(src)) { + filt(src, 'image'); // was 'scale' + src = blankImg; + } else if (src.indexOf(blankImg) < 0) filt(); + } else if (style.backgroundImage) { + if (style.backgroundImage.match(/^url[("']+(.*\.png)[)"']+$/i)) { + var s = RegExp.$1; + style.backgroundImage = ''; + filt(s, 'crop'); + } else filt(); + } +} + +doFix(); + +</script> +</public:component>
@@ -0,0 +1,7 @@+/* DO NOT CHANGE THESE unless you really want to break Opera Show */+.slide {+ visibility: visible !important;+ position: static !important;+ page-break-before: always;+}+#slide0 {page-break-before: avoid;}
@@ -0,0 +1,15 @@+/* don't change this unless you want the layout stuff to show up in the outline view! */++.layout div, #footer *, #controlForm * {display: none;}+#footer, #controls, #controlForm, #navLinks, #toggle {+ display: block; visibility: visible; margin: 0; padding: 0;}+#toggle {float: right; padding: 0.5em;}+html>body #toggle {position: fixed; top: 0; right: 0;}++/* making the outline look pretty-ish */++#slide0 h1, #slide0 h2, #slide0 h3, #slide0 h4 {border: none; margin: 0;}+#slide0 h1 {padding-top: 1.5em;}+.slide h1 {margin: 1.5em 0 0; padding-top: 0.25em;+ border-top: 1px solid #888; border-bottom: 1px solid #AAA;}+#toggle {border: 1px solid; border-width: 0 0 1px 1px; background: #FFF;}
@@ -0,0 +1,86 @@+/* Following are the presentation styles -- edit away! */++body {background: #FFF url(bodybg.gif) -16px 0 no-repeat; color: #000; font-size: 2em;}+:link, :visited {text-decoration: none; color: #00C;}+#controls :active {color: #88A !important;}+#controls :focus {outline: 1px dotted #227;}+h1, h2, h3, h4 {font-size: 100%; margin: 0; padding: 0; font-weight: inherit;}+ul, pre {margin: 0; line-height: 1em;}+html, body {margin: 0; padding: 0;}++blockquote, q {font-style: italic;}+blockquote {padding: 0 2em 0.5em; margin: 0 1.5em 0.5em; text-align: center; font-size: 1em;}+blockquote p {margin: 0;}+blockquote i {font-style: normal;}+blockquote b {display: block; margin-top: 0.5em; font-weight: normal; font-size: smaller; font-style: normal;}+blockquote b i {font-style: italic;}++kbd {font-weight: bold; font-size: 1em;}+sup {font-size: smaller; line-height: 1px;}++.slide code {padding: 2px 0.25em; font-weight: bold; color: #533;}+.slide code.bad, code del {color: red;}+.slide code.old {color: silver;}+.slide pre {padding: 0; margin: 0.25em 0 0.5em 0.5em; color: #533; font-size: 90%;}+.slide pre code {display: block;}+.slide ul {margin-left: 5%; margin-right: 7%; list-style: disc;}+.slide li {margin-top: 0.75em; margin-right: 0;}+.slide ul ul {line-height: 1;}+.slide ul ul li {margin: .2em; font-size: 85%; list-style: square;}+.slide img.leader {display: block; margin: 0 auto;}++div#header, div#footer {background: #005; color: #AAB;+ font-family: Verdana, Helvetica, sans-serif;}+div#header {background: #005 url(bodybg.gif) -16px 0 no-repeat;+ line-height: 1px;}+div#footer {font-size: 0.5em; font-weight: bold; padding: 1em 0;}+#footer h1, #footer h2 {display: block; padding: 0 1em;}+#footer h2 {font-style: italic;}++div.long {font-size: 0.75em;}+.slide h1 {position: absolute; top: 0.7em; left: 87px; z-index: 1;+ margin: 0; padding: 0.3em 0 0 50px; white-space: nowrap;+ font: bold 150%/1em Helvetica, sans-serif; text-transform: capitalize;+ color: #DDE; background: #005;}+.slide h3 {font-size: 130%;}+h1 abbr {font-variant: small-caps;}++div#controls {position: absolute; left: 50%; bottom: 0;+ width: 50%;+ text-align: right; font: bold 0.9em Verdana, Helvetica, sans-serif;}+html>body div#controls {position: fixed; padding: 0 0 1em 0;+ top: auto;}+div#controls form {position: absolute; bottom: 0; right: 0; width: 100%;+ margin: 0; padding: 0;}+#controls #navLinks a {padding: 0; margin: 0 0.5em; + background: #005; border: none; color: #779; + cursor: pointer;}+#controls #navList {height: 1em;}+#controls #navList #jumplist {position: absolute; bottom: 0; right: 0; background: #DDD; color: #227;}++#currentSlide {text-align: center; font-size: 0.5em; color: #449;}++#slide0 {padding-top: 3.5em; font-size: 90%;}+#slide0 h1 {position: static; margin: 1em 0 0; padding: 0;+ font: bold 2em Helvetica, sans-serif; white-space: normal;+ color: #000; background: transparent;}+#slide0 h2 {font: bold italic 1em Helvetica, sans-serif; margin: 0.25em;}+#slide0 h3 {margin-top: 1.5em; font-size: 1.5em;}+#slide0 h4 {margin-top: 0; font-size: 1em;}++ul.urls {list-style: none; display: inline; margin: 0;}+.urls li {display: inline; margin: 0;}+.note {display: none;}+.external {border-bottom: 1px dotted gray;}+html>body .external {border-bottom: none;}+.external:after {content: " \274F"; font-size: smaller; color: #77B;}++.incremental, .incremental *, .incremental *:after {color: #DDE; visibility: visible;}+img.incremental {visibility: hidden;}+.slide .current {color: #B02;}+++/* diagnostics++li:after {content: " [" attr(class) "]"; color: #F88;}+*/
@@ -0,0 +1,24 @@+/* The following rule is necessary to have all slides appear in print! DO NOT REMOVE IT! */+.slide, ul {page-break-inside: avoid; visibility: visible !important;}+h1 {page-break-after: avoid;}++body {font-size: 12pt; background: white;}+* {color: black;}++#slide0 h1 {font-size: 200%; border: none; margin: 0.5em 0 0.25em;}+#slide0 h3 {margin: 0; padding: 0;}+#slide0 h4 {margin: 0 0 0.5em; padding: 0;}+#slide0 {margin-bottom: 3em;}++h1 {border-top: 2pt solid gray; border-bottom: 1px dotted silver;}+.extra {background: transparent !important;}+div.extra, pre.extra, .example {font-size: 10pt; color: #333;}+ul.extra a {font-weight: bold;}+p.example {display: none;}++#header {display: none;}+#footer h1 {margin: 0; border-bottom: 1px solid; color: gray; font-style: italic;}+#footer h2, #controls {display: none;}++/* The following rule keeps the layout stuff out of print. Remove at your own risk! */+.layout, .layout * {display: none !important;}
@@ -0,0 +1,9 @@+/* Do not edit or override these styles! The system will likely break if you do. */++div#header, div#footer, div#controls, .slide {position: absolute;}+html>body div#header, html>body div#footer, + html>body div#controls, html>body .slide {position: fixed;}+.handout {display: none;}+.layout {display: block;}+.slide, .hideme, .incremental {visibility: hidden;}+#slide0 {visibility: visible;}
@@ -0,0 +1,3 @@+@import url(s5-core.css); /* required to make the slide show run at all */+@import url(framing.css); /* sets basic placement and size of slide components */+@import url(pretty.css); /* stuff that makes the slides look better than blah */
@@ -0,0 +1,553 @@+// S5 v1.1 slides.js -- released into the Public Domain+//+// Please see http://www.meyerweb.com/eric/tools/s5/credits.html for information +// about all the wonderful and talented contributors to this code!++var undef;+var slideCSS = '';+var snum = 0;+var smax = 1;+var incpos = 0;+var number = undef;+var s5mode = true;+var defaultView = 'slideshow';+var controlVis = 'visible';++var isIE = navigator.appName == 'Microsoft Internet Explorer' && navigator.userAgent.indexOf('Opera') < 1 ? 1 : 0;+var isOp = navigator.userAgent.indexOf('Opera') > -1 ? 1 : 0;+var isGe = navigator.userAgent.indexOf('Gecko') > -1 && navigator.userAgent.indexOf('Safari') < 1 ? 1 : 0;++function hasClass(object, className) {+ if (!object.className) return false;+ return (object.className.search('(^|\\s)' + className + '(\\s|$)') != -1);+}++function hasValue(object, value) {+ if (!object) return false;+ return (object.search('(^|\\s)' + value + '(\\s|$)') != -1);+}++function removeClass(object,className) {+ if (!object) return;+ object.className = object.className.replace(new RegExp('(^|\\s)'+className+'(\\s|$)'), RegExp.$1+RegExp.$2);+}++function addClass(object,className) {+ if (!object || hasClass(object, className)) return;+ if (object.className) {+ object.className += ' '+className;+ } else {+ object.className = className;+ }+}++function GetElementsWithClassName(elementName,className) {+ var allElements = document.getElementsByTagName(elementName);+ var elemColl = new Array();+ for (var i = 0; i< allElements.length; i++) {+ if (hasClass(allElements[i], className)) {+ elemColl[elemColl.length] = allElements[i];+ }+ }+ return elemColl;+}++function isParentOrSelf(element, id) {+ if (element == null || element.nodeName=='BODY') return false;+ else if (element.id == id) return true;+ else return isParentOrSelf(element.parentNode, id);+}++function nodeValue(node) {+ var result = "";+ if (node.nodeType == 1) {+ var children = node.childNodes;+ for (var i = 0; i < children.length; ++i) {+ result += nodeValue(children[i]);+ } + }+ else if (node.nodeType == 3) {+ result = node.nodeValue;+ }+ return(result);+}++function slideLabel() {+ var slideColl = GetElementsWithClassName('*','slide');+ var list = document.getElementById('jumplist');+ smax = slideColl.length;+ for (var n = 0; n < smax; n++) {+ var obj = slideColl[n];++ var did = 'slide' + n.toString();+ obj.setAttribute('id',did);+ if (isOp) continue;++ var otext = '';+ var menu = obj.firstChild;+ if (!menu) continue; // to cope with empty slides+ while (menu && menu.nodeType == 3) {+ menu = menu.nextSibling;+ }+ if (!menu) continue; // to cope with slides with only text nodes++ var menunodes = menu.childNodes;+ for (var o = 0; o < menunodes.length; o++) {+ otext += nodeValue(menunodes[o]);+ }+ list.options[list.length] = new Option(n + ' : ' + otext, n);+ }+}++function currentSlide() {+ var cs;+ if (document.getElementById) {+ cs = document.getElementById('currentSlide');+ } else {+ cs = document.currentSlide;+ }+ cs.innerHTML = '<span id="csHere">' + snum + '<\/span> ' + + '<span id="csSep">\/<\/span> ' + + '<span id="csTotal">' + (smax-1) + '<\/span>';+ if (snum == 0) {+ cs.style.visibility = 'hidden';+ } else {+ cs.style.visibility = 'visible';+ }+}++function go(step) {+ if (document.getElementById('slideProj').disabled || step == 0) return;+ var jl = document.getElementById('jumplist');+ var cid = 'slide' + snum;+ var ce = document.getElementById(cid);+ if (incrementals[snum].length > 0) {+ for (var i = 0; i < incrementals[snum].length; i++) {+ removeClass(incrementals[snum][i], 'current');+ removeClass(incrementals[snum][i], 'incremental');+ }+ }+ if (step != 'j') {+ snum += step;+ lmax = smax - 1;+ if (snum > lmax) snum = lmax;+ if (snum < 0) snum = 0;+ } else+ snum = parseInt(jl.value);+ var nid = 'slide' + snum;+ var ne = document.getElementById(nid);+ if (!ne) {+ ne = document.getElementById('slide0');+ snum = 0;+ }+ if (step < 0) {incpos = incrementals[snum].length} else {incpos = 0;}+ if (incrementals[snum].length > 0 && incpos == 0) {+ for (var i = 0; i < incrementals[snum].length; i++) {+ if (hasClass(incrementals[snum][i], 'current'))+ incpos = i + 1;+ else+ addClass(incrementals[snum][i], 'incremental');+ }+ }+ if (incrementals[snum].length > 0 && incpos > 0)+ addClass(incrementals[snum][incpos - 1], 'current');+ ce.style.visibility = 'hidden';+ ne.style.visibility = 'visible';+ jl.selectedIndex = snum;+ currentSlide();+ number = 0;+}++function goTo(target) {+ if (target >= smax || target == snum) return;+ go(target - snum);+}++function subgo(step) {+ if (step > 0) {+ removeClass(incrementals[snum][incpos - 1],'current');+ removeClass(incrementals[snum][incpos], 'incremental');+ addClass(incrementals[snum][incpos],'current');+ incpos++;+ } else {+ incpos--;+ removeClass(incrementals[snum][incpos],'current');+ addClass(incrementals[snum][incpos], 'incremental');+ addClass(incrementals[snum][incpos - 1],'current');+ }+}++function toggle() {+ var slideColl = GetElementsWithClassName('*','slide');+ var slides = document.getElementById('slideProj');+ var outline = document.getElementById('outlineStyle');+ if (!slides.disabled) {+ slides.disabled = true;+ outline.disabled = false;+ s5mode = false;+ fontSize('1em');+ for (var n = 0; n < smax; n++) {+ var slide = slideColl[n];+ slide.style.visibility = 'visible';+ }+ } else {+ slides.disabled = false;+ outline.disabled = true;+ s5mode = true;+ fontScale();+ for (var n = 0; n < smax; n++) {+ var slide = slideColl[n];+ slide.style.visibility = 'hidden';+ }+ slideColl[snum].style.visibility = 'visible';+ }+}++function showHide(action) {+ var obj = GetElementsWithClassName('*','hideme')[0];+ switch (action) {+ case 's': obj.style.visibility = 'visible'; break;+ case 'h': obj.style.visibility = 'hidden'; break;+ case 'k':+ if (obj.style.visibility != 'visible') {+ obj.style.visibility = 'visible';+ } else {+ obj.style.visibility = 'hidden';+ }+ break;+ }+}++// 'keys' code adapted from MozPoint (http://mozpoint.mozdev.org/)+function keys(key) {+ if (!key) {+ key = event;+ key.which = key.keyCode;+ }+ if (key.which == 84) {+ toggle();+ return;+ }+ if (s5mode) {+ switch (key.which) {+ case 10: // return+ case 13: // enter+ if (window.event && isParentOrSelf(window.event.srcElement, 'controls')) return;+ if (key.target && isParentOrSelf(key.target, 'controls')) return;+ if(number != undef) {+ goTo(number);+ break;+ }+ case 32: // spacebar+ case 34: // page down+ case 39: // rightkey+ case 40: // downkey+ if(number != undef) {+ go(number);+ } else if (!incrementals[snum] || incpos >= incrementals[snum].length) {+ go(1);+ } else {+ subgo(1);+ }+ break;+ case 33: // page up+ case 37: // leftkey+ case 38: // upkey+ if(number != undef) {+ go(-1 * number);+ } else if (!incrementals[snum] || incpos <= 0) {+ go(-1);+ } else {+ subgo(-1);+ }+ break;+ case 36: // home+ goTo(0);+ break;+ case 35: // end+ goTo(smax-1);+ break;+ case 67: // c+ showHide('k');+ break;+ }+ if (key.which < 48 || key.which > 57) {+ number = undef;+ } else {+ if (window.event && isParentOrSelf(window.event.srcElement, 'controls')) return;+ if (key.target && isParentOrSelf(key.target, 'controls')) return;+ number = (((number != undef) ? number : 0) * 10) + (key.which - 48);+ }+ }+ return false;+}++function clicker(e) {+ number = undef;+ var target;+ if (window.event) {+ target = window.event.srcElement;+ e = window.event;+ } else target = e.target;+ if (target.getAttribute('href') != null || hasValue(target.rel, 'external') || isParentOrSelf(target, 'controls') || isParentOrSelf(target,'embed') || isParentOrSelf(target,'object')) return true;+ if (!e.which || e.which == 1) {+ if (!incrementals[snum] || incpos >= incrementals[snum].length) {+ go(1);+ } else {+ subgo(1);+ }+ }+}++function findSlide(hash) {+ var target = null;+ var slides = GetElementsWithClassName('*','slide');+ for (var i = 0; i < slides.length; i++) {+ var targetSlide = slides[i];+ if ( (targetSlide.name && targetSlide.name == hash)+ || (targetSlide.id && targetSlide.id == hash) ) {+ target = targetSlide;+ break;+ }+ }+ while(target != null && target.nodeName != 'BODY') {+ if (hasClass(target, 'slide')) {+ return parseInt(target.id.slice(5));+ }+ target = target.parentNode;+ }+ return null;+}++function slideJump() {+ if (window.location.hash == null) return;+ var sregex = /^#slide(\d+)$/;+ var matches = sregex.exec(window.location.hash);+ var dest = null;+ if (matches != null) {+ dest = parseInt(matches[1]);+ } else {+ dest = findSlide(window.location.hash.slice(1));+ }+ if (dest != null)+ go(dest - snum);+}++function fixLinks() {+ var thisUri = window.location.href;+ thisUri = thisUri.slice(0, thisUri.length - window.location.hash.length);+ var aelements = document.getElementsByTagName('A');+ for (var i = 0; i < aelements.length; i++) {+ var a = aelements[i].href;+ var slideID = a.match('\#slide[0-9]{1,2}');+ if ((slideID) && (slideID[0].slice(0,1) == '#')) {+ var dest = findSlide(slideID[0].slice(1));+ if (dest != null) {+ if (aelements[i].addEventListener) {+ aelements[i].addEventListener("click", new Function("e",+ "if (document.getElementById('slideProj').disabled) return;" ++ "go("+dest+" - snum); " ++ "if (e.preventDefault) e.preventDefault();"), true);+ } else if (aelements[i].attachEvent) {+ aelements[i].attachEvent("onclick", new Function("",+ "if (document.getElementById('slideProj').disabled) return;" ++ "go("+dest+" - snum); " ++ "event.returnValue = false;"));+ }+ }+ }+ }+}++function externalLinks() {+ if (!document.getElementsByTagName) return;+ var anchors = document.getElementsByTagName('a');+ for (var i=0; i<anchors.length; i++) {+ var anchor = anchors[i];+ if (anchor.getAttribute('href') && hasValue(anchor.rel, 'external')) {+ anchor.target = '_blank';+ addClass(anchor,'external');+ }+ }+}++function createControls() {+ var controlsDiv = document.getElementById("controls");+ if (!controlsDiv) return;+ var hider = ' onmouseover="showHide(\'s\');" onmouseout="showHide(\'h\');"';+ var hideDiv, hideList = '';+ if (controlVis == 'hidden') {+ hideDiv = hider;+ } else {+ hideList = hider;+ }+ controlsDiv.innerHTML = '<form action="#" id="controlForm"' + hideDiv + '>' ++ '<div id="navLinks">' ++ '<a accesskey="t" id="toggle" href="javascript:toggle();">Ø<\/a>' ++ '<a accesskey="z" id="prev" href="javascript:go(-1);">«<\/a>' ++ '<a accesskey="x" id="next" href="javascript:go(1);">»<\/a>' ++ '<div id="navList"' + hideList + '><select id="jumplist" onchange="go(\'j\');"><\/select><\/div>' ++ '<\/div><\/form>';+ if (controlVis == 'hidden') {+ var hidden = document.getElementById('navLinks');+ } else {+ var hidden = document.getElementById('jumplist');+ }+ addClass(hidden,'hideme');+}++function fontScale() { // causes layout problems in FireFox that get fixed if browser's Reload is used; same may be true of other Gecko-based browsers+ if (!s5mode) return false;+ var vScale = 22; // both yield 32 (after rounding) at 1024x768+ var hScale = 32; // perhaps should auto-calculate based on theme's declared value?+ if (window.innerHeight) {+ var vSize = window.innerHeight;+ var hSize = window.innerWidth;+ } else if (document.documentElement.clientHeight) {+ var vSize = document.documentElement.clientHeight;+ var hSize = document.documentElement.clientWidth;+ } else if (document.body.clientHeight) {+ var vSize = document.body.clientHeight;+ var hSize = document.body.clientWidth;+ } else {+ var vSize = 700; // assuming 1024x768, minus chrome and such+ var hSize = 1024; // these do not account for kiosk mode or Opera Show+ }+ var newSize = Math.min(Math.round(vSize/vScale),Math.round(hSize/hScale));+ fontSize(newSize + 'px');+ if (isGe) { // hack to counter incremental reflow bugs+ var obj = document.getElementsByTagName('body')[0];+ obj.style.display = 'none';+ obj.style.display = 'block';+ }+}++function fontSize(value) {+ if (!(s5ss = document.getElementById('s5ss'))) {+ if (!isIE) {+ document.getElementsByTagName('head')[0].appendChild(s5ss = document.createElement('style'));+ s5ss.setAttribute('media','screen, projection');+ s5ss.setAttribute('id','s5ss');+ } else {+ document.createStyleSheet();+ document.s5ss = document.styleSheets[document.styleSheets.length - 1];+ }+ }+ if (!isIE) {+ while (s5ss.lastChild) s5ss.removeChild(s5ss.lastChild);+ s5ss.appendChild(document.createTextNode('body {font-size: ' + value + ' !important;}'));+ } else {+ document.s5ss.addRule('body','font-size: ' + value + ' !important;');+ }+}++function notOperaFix() {+ slideCSS = document.getElementById('slideProj').href;+ var slides = document.getElementById('slideProj');+ var outline = document.getElementById('outlineStyle');+ slides.setAttribute('media','screen');+ outline.disabled = true;+ if (isGe) {+ slides.setAttribute('href','null'); // Gecko fix+ slides.setAttribute('href',slideCSS); // Gecko fix+ }+ if (isIE && document.styleSheets && document.styleSheets[0]) {+ document.styleSheets[0].addRule('img', 'behavior: url(ui/default/iepngfix.htc)');+ document.styleSheets[0].addRule('div', 'behavior: url(ui/default/iepngfix.htc)');+ document.styleSheets[0].addRule('.slide', 'behavior: url(ui/default/iepngfix.htc)');+ }+}++function getIncrementals(obj) {+ var incrementals = new Array();+ if (!obj) + return incrementals;+ var children = obj.childNodes;+ for (var i = 0; i < children.length; i++) {+ var child = children[i];+ if (hasClass(child, 'incremental')) {+ if (child.nodeName == 'OL' || child.nodeName == 'UL') {+ removeClass(child, 'incremental');+ for (var j = 0; j < child.childNodes.length; j++) {+ if (child.childNodes[j].nodeType == 1) {+ addClass(child.childNodes[j], 'incremental');+ }+ }+ } else {+ incrementals[incrementals.length] = child;+ removeClass(child,'incremental');+ }+ }+ if (hasClass(child, 'show-first')) {+ if (child.nodeName == 'OL' || child.nodeName == 'UL') {+ removeClass(child, 'show-first');+ if (child.childNodes[isGe].nodeType == 1) {+ removeClass(child.childNodes[isGe], 'incremental');+ }+ } else {+ incrementals[incrementals.length] = child;+ }+ }+ incrementals = incrementals.concat(getIncrementals(child));+ }+ return incrementals;+}++function createIncrementals() {+ var incrementals = new Array();+ for (var i = 0; i < smax; i++) {+ incrementals[i] = getIncrementals(document.getElementById('slide'+i));+ }+ return incrementals;+}++function defaultCheck() {+ var allMetas = document.getElementsByTagName('meta');+ for (var i = 0; i< allMetas.length; i++) {+ if (allMetas[i].name == 'defaultView') {+ defaultView = allMetas[i].content;+ }+ if (allMetas[i].name == 'controlVis') {+ controlVis = allMetas[i].content;+ }+ }+}++// Key trap fix, new function body for trap()+function trap(e) {+ if (!e) {+ e = event;+ e.which = e.keyCode;+ }+ try {+ modifierKey = e.ctrlKey || e.altKey || e.metaKey;+ }+ catch(e) {+ modifierKey = false;+ }+ return modifierKey || e.which == 0;+}++function startup() {+ defaultCheck();+ if (!isOp) + createControls();+ slideLabel();+ fixLinks();+ externalLinks();+ fontScale();+ if (!isOp) {+ notOperaFix();+ incrementals = createIncrementals();+ slideJump();+ if (defaultView == 'outline') {+ toggle();+ }+ document.onkeyup = keys;+ document.onkeypress = trap;+ document.onclick = clicker;+ }+}++window.onload = startup;+window.onresize = function(){setTimeout('fontScale()', 50);}
@@ -0,0 +1,95 @@+/* This work is licensed under Creative Commons GNU LGPL License.++ License: http://creativecommons.org/licenses/LGPL/2.1/+ Version: 1.0++ Author: Stefan Goessner/2005+ Web: http://goessner.net/ +*/+@media screen, projection {+body {+ background-color: #e3eee7;+ padding: 0;+ margin: 0;+ color: #132; + border-color: #678; + font-size: 125%;+}+#statusbar {+ display: none;+ position: absolute; z-index: 10;+ top: auto; bottom: 0; left: 0; right: 0;+ height: 2em;+ background-color: #f0fff8;+ color: #132;+ font-size: 75%;+ padding: 0.5em 0.5em 0 2px;+ border-top: solid 1px #000;+}+#statusbar button, #tocbox {+ cursor: pointer; + color: #031;+ background-color: #e0eee7;+ margin: 1px;+ padding: 0 0.5em;+ border: inset 1px black;+}+#statusbar button:hover, #tocbox:hover {+ color: #031;+ background-color: #c0ccc6;+ border: outset 1px black;+}+#tocbox {+ width: 15em;+}+#eos {+ visibility: hidden;+ color: #021;+ background-color: #fffafa;+ border: inset 1px black;+ font-size: 120%;+}+div.slide {+ display: block;+ margin: 0 0 2em 0;+ padding: 0 150px;+}++div.slide h1 {+ background: #a0aaa4;+ color: #f0fff8;+ padding: 0 0.5em 0 0.5em;+ margin: 0 -150px;+ font-size: 120%;+ border-bottom: solid 1px black;+}++div.slide h1:before { content: "# "; }+div.handout { display: block; }+ +body>#statusbar { /* ie6 hack for fixing the statusbar - in quirks mode */+ position: fixed; /* thanks to Anne van Kesteren and Arthur Steiner */+} /* see http://limpid.nl/lab/css/fixed/footer */+* html body {+ overflow: hidden;+}+* html div.slide {+ height: 100%;+ padding-bottom: 2em;+ overflow: auto;+} /* end ie6-hack */++} /* @media screen, projection */++@media print {+body {+ color: black;+ font-family: sans-serif;+ font-size: 11pt;+}++#statusbar { display: none; }+div.slide { page-break-after: always; }+div.handout { display: block; }++} /* @media print */
@@ -0,0 +1,321 @@+/* This work is licensed under Creative Commons GNU LGPL License.++ License: http://creativecommons.org/licenses/LGPL/2.1/++ Author: Stefan Goessner/2005-2006+ Web: http://goessner.net/ +*/+var Slideous = {+ version: 1.0,+ // == user customisable ===+ clickables: { a: true, button: true, img: true, input: true, object: true, textarea: true, select: true, option: true },+ incrementables: { blockquote: { filter: "self, parent" }, + dd: { filter: "self, parent" },+ dt: { filter: "self, parent" },+ h2: { filter: "self, parent" },+ h3: { filter: "self, parent" },+ h4: { filter: "self, parent" },+ h5: { filter: "self, parent" },+ h6: { filter: "self, parent" },+ li: { filter: "self, parent" },+ p: { filter: "self" }, + pre: { filter: "self" }, + img: { filter: "self, parent" }, + object: { filter: "self, parent" },+ table: { filter: "self, parent" },+ td: { filter: "self, parent" },+ th: { filter: "self, parent" },+ tr: { filter: "parent, grandparent" }+ },+ autoincrementables: { ol: true, ul: true, dl: true },+ autoincrement: false,+ statusbar: true,+ navbuttons: { incfontbutton: function(){Slideous.changefontsize(+Slideous.fontdelta);},+ decfontbutton: function(){Slideous.changefontsize(-Slideous.fontdelta);},+ contentbutton: function(){Slideous.gotoslide(Slideous.tocidx(), true, true);},+ homebutton: function(){Slideous.gotoslide(1, true, true);},+ prevslidebutton: function(){Slideous.previous(false);},+ previtembutton: function(){Slideous.previous(true);},+ nextitembutton: function(){Slideous.next(true);},+ nextslidebutton: function(){Slideous.next(false);},+ endbutton: function(){Slideous.gotoslide(Slideous.count,true,true);} },+ fontsize: 125, // in percent, corresponding to body.font-size in css file+ fontdelta: 5, // increase/decrease fontsize by this value+ mousesensitive: true,+ tocidx: 0,+ tocitems: { toc: "<li><a href=\"#s{\$slideidx}\">{\$slidetitle}</a></li>",+ tocbox: "<option value=\"#s{\$slideidx}\" title=\"{\$slidetitle}\">{\$slidetitle}</option>" },+ keydown: function(evt) {+ evt = evt || window.event;+ var key = evt.keyCode || evt.which;+ if (key && !evt.ctrlKey && !evt.altKey) {+ switch (key) {+ case 33: // page up ... previous slide+ Slideous.previous(false); evt.cancel = !Slideous.showall; break;+ case 37: // left arrow ... previous item+ Slideous.previous(true); evt.cancel = !Slideous.showall; break;+ case 32: // space bar+ case 39: // right arrow+ Slideous.next(true); evt.cancel = !Slideous.showall; break;+ case 13: // carriage return ... next slide+ case 34: // page down+ Slideous.next(false); evt.cancel = !Slideous.showall; break;+ case 35: // end ... last slide (not recognised by opera)+ Slideous.gotoslide(Slideous.count, true, true); evt.cancel = !Slideous.showall; break;+ case 36: // home ... first slide (not recognised by opera)+ Slideous.gotoslide(1, true, true); evt.cancel = !Slideous.showall; break;+ case 65: // A ... show All+ case 80: // P ... Print mode+ Slideous.toggleshowall(!Slideous.showall); evt.cancel = true; break;+ case 67: // C ... goto contents+ Slideous.gotoslide(Slideous.tocidx, true, true); evt.cancel = true; break;+ case 77: // M ... toggle mouse sensitivity+ Slideous.mousenavigation(Slideous.mousesensitive = !Slideous.mousesensitive); evt.cancel = true; break;+ case 83: // S ... toggle statusbar+ Slideous.togglestatusbar(); evt.cancel = true; break;+ case 61: // + ... increase fontsize+ case 107:+ Slideous.changefontsize(+Slideous.fontdelta); evt.cancel = true; break;+ case 109: // - ... decrease fontsize+ Slideous.changefontsize(-Slideous.fontdelta); evt.cancel = true; break;+ default: break;+ }+ if (evt.cancel) evt.returnValue = false;+ }+ return !evt.cancel;+ },++ // == program logic ===+ count: 0, // # of slides ..+ curidx: 0, // current slide index ..+ mousedownpos: null, // last mouse down position ..+ contentselected: false, // indicates content selection ..+ showall: true,+ init: function() {+ Slideous.curidx = 1;+ Slideous.importproperties();+ Slideous.registerslides();+ document.body.innerHTML = Slideous.injectproperties(document.body.innerHTML);+ Slideous.buildtocs();+ Slideous.registeranchors();+ Slideous.toggleshowall(false);+ Slideous.updatestatus();+ document.body.style.fontSize = Slideous.fontsize+"%";+ document.getElementById("s1").style.display = "block";+ document.onkeydown = Slideous.keydown;+ Slideous.mousenavigation(Slideous.mousesensitive);+ Slideous.registerbuttons();+ if (window.location.hash)+ Slideous.gotoslide(window.location.hash.substr(2), true, true);+ },+ registerslides: function() {+ var div = document.getElementsByTagName("div");+ Slideous.count = 0;+ for (var i in div)+ if (Slideous.hasclass(div[i], "slide"))+ div[i].setAttribute("id", "s"+(++Slideous.count));+ },+ registeranchors: function() {+ var a = document.getElementsByTagName("a"),+ loc = (window.location.hostname+window.location.pathname).replace(/\\/g, "/");+ for (var i in a) {+ if (a[i].href && a[i].href.indexOf(loc) >= 0 && a[i].href.lastIndexOf("#") >= 0) {+ a[i].href = "javascript:Slideous.gotoslide(" + a[i].href.substr(a[i].href.lastIndexOf("#")+2)+",true,true)";+ }+ }+ },+ registerbuttons: function() {+ var button;+ for (var b in Slideous.navbuttons)+ if (button = document.getElementById(b))+ button.onclick = Slideous.navbuttons[b];+ },+ importproperties: function() { // from html meta section ..+ var meta = document.getElementsByTagName("meta"), elem;+ for (var i in meta)+ if (meta[i].attributes && meta[i].attributes["name"] && meta[i].attributes["name"].value in Slideous)+ switch (typeof(Slideous[meta[i].attributes["name"].value])) {+ case "number": Slideous[meta[i].attributes["name"].value] = parseInt(meta[i].attributes["content"].value); break;+ case "boolean": Slideous[meta[i].attributes["name"].value] = meta[i].attributes["content"].value == "true" ? true : false; break;+ default: Slideous[meta[i].attributes["name"].value] = meta[i].attributes["content"].value; break;+ }+ },+ injectproperties: function(str) {+ var meta = document.getElementsByTagName("meta"), elem;+ for (var i in meta) {+ if (meta[i].attributes && meta[i].attributes["name"])+ str = str.replace(new RegExp("{\\$"+meta[i].attributes["name"].value+"}","g"), meta[i].attributes["content"].value);+ }+ return str = str.replace(/{\$generator}/g, "Slideous")+ .replace(/{\$version}/g, Slideous.version)+ .replace(/{\$title}/g, document.title)+ .replace(/{\$slidecount}/g, Slideous.count);+ },+ buildtocs: function() {+ var toc = document.getElementById("toc"), list = "",+ tocbox = document.getElementById("tocbox");+ if (toc) {+ for (var i=0; i<Slideous.count; i++)+ list += Slideous.tocitems.toc.replace(/{\$slideidx}/g, i+1).replace(/{\$slidetitle}/, document.getElementById("s"+(i+1)).getElementsByTagName("h1")[0].innerHTML);+ toc.innerHTML = list;+ while (toc && !Slideous.hasclass(toc, "slide")) toc = toc.parentNode;+ if (toc) Slideous.tocidx = toc.getAttribute("id").substr(1);+ }+ if (tocbox) {+ tocbox.innerHTML = "";+ for (var i=0; i<Slideous.count; i++)+ tocbox.options[tocbox.length] = new Option((i+1)+". "+document.getElementById("s"+(i+1)).getElementsByTagName("h1")[0].innerHTML, "#s"+(i+1));+ tocbox.onchange = function() { Slideous.gotoslide(this.selectedIndex+1, true, true); };+ }+ },+ next: function(deep) {+ if (!Slideous.showall) {+ var slide = document.getElementById("s"+Slideous.curidx),+ item = Slideous.firstitem(slide, Slideous.isitemhidden);+ if (deep) { // next item+ if (item)+ Slideous.displayitem(item, true);+ else+ Slideous.gotoslide(Slideous.curidx+1, false, false);+ }+ else if (item) // complete slide ..+ while (item = Slideous.firstitem(slide, Slideous.isitemhidden))+ Slideous.displayitem(item, true);+ else // next slide+ Slideous.gotoslide(Slideous.curidx+1, true, false);+ Slideous.updatestatus();+ }+ },+ previous: function(deep) {+ if (!Slideous.showall) {+ var slide = document.getElementById("s"+Slideous.curidx);+ if (deep) {+ var item = Slideous.lastitem(slide, Slideous.isitemvisible);+ if (item)+ Slideous.displayitem(item, false);+ else+ Slideous.gotoslide(Slideous.curidx-1, true, false);+ }+ else+ Slideous.gotoslide(Slideous.curidx-1, true, false);+ Slideous.updatestatus();+ }+ },+ gotoslide: function(i, showitems, updatestatus) {+ if (!Slideous.showall && i > 0 && i <= Slideous.count && i != Slideous.curidx) {+ document.getElementById("s"+Slideous.curidx).style.display = "none";+ var slide = document.getElementById("s"+(Slideous.curidx=i)), item;+ while (item = Slideous.firstitem(slide, showitems ? Slideous.isitemhidden : Slideous.isitemvisible))+ Slideous.displayitem(item, showitems);+ slide.style.display = "block";+ if (updatestatus)+ Slideous.updatestatus();+ }+ },+ firstitem: function(root, filter) {+ var found = filter(root);+ for (var node=root.firstChild; node!=null && !found; node = node.nextSibling)+ found = Slideous.firstitem(node, filter);+ return found;+ },+ lastitem: function(root, filter) {+ var found = null;+ for (var node=root.lastChild; node!=null && !found; node = node.previousSibling)+ found = Slideous.lastitem(node, filter);+ return found || filter(root);+ },+ isitem: function(node, visible) {+ var nodename;+ return node && node.nodeType == 1 // elements only ..+ && (nodename=node.nodeName.toLowerCase()) in Slideous.incrementables+ && ( Slideous.incrementables[nodename].filter.match("\\bself\\b") && (Slideous.hasclass(node, "incremental") || (Slideous.autoincrement && nodename in Slideous.autoincrementables))+ || Slideous.incrementables[nodename].filter.match("\\bparent\\b") && (Slideous.hasclass(node.parentNode, "incremental") || (Slideous.autoincrement && node.parentNode.nodeName.toLowerCase() in Slideous.autoincrementables))+ || Slideous.incrementables[nodename].filter.match("\\bgrandparent\\b") && (Slideous.hasclass(node.parentNode.parentNode, "incremental") || (Slideous.autoincrement && node.parentNode.parentNode.nodeName.toLowerCase() in Slideous.autoincrementables))+ )+ && (visible ? (node.style.visibility != "hidden")+ : (node.style.visibility == "hidden"))+ ? node : null;+ },+ isitemvisible: function(node) { return Slideous.isitem(node, true); },+ isitemhidden: function(node) { return Slideous.isitem(node, false); },+ displayitem: function(item, show) {+ if (item) item.style.visibility = (show ? "visible" : "hidden");+ },+ updatestatus: function() {+ if (Slideous.statusbar) {+ var eos = document.getElementById("eos"), + idx = document.getElementById("slideidx"),+ tocbox = document.getElementById("tocbox");+ if (eos) + eos.style.visibility = Slideous.firstitem(document.getElementById("s"+Slideous.curidx), Slideous.isitemhidden) != null+ ? "visible" : "hidden";+ if (idx) + idx.innerHTML = Slideous.curidx;+ if (tocbox)+ tocbox.selectedIndex = Slideous.curidx-1;+ }+ },+ changefontsize: function(delta) {+ document.body.style.fontSize = (Slideous.fontsize+=delta)+"%";+ },+ togglestatusbar: function() {+ document.getElementById("statusbar").style.display = (Slideous.statusbar = !Slideous.statusbar) ? "block" : "none";+ },+ toggleshowall: function(showall) {+ var slide, item;+ for (var i=0; i<Slideous.count; i++) {+ slide = document.getElementById("s"+(i+1));+ slide.style.display = showall ? "block" : "none";+ while (item = Slideous.firstitem(slide, showall ? Slideous.isitemhidden : Slideous.isitemvisible)) + Slideous.displayitem(item, showall);+ var divs = slide.getElementsByTagName("div");+ for (var j in divs)+ if (Slideous.hasclass(divs[j], "handout"))+ divs[j].style.display = showall ? "block" : "none";+ }+ if (!showall)+ document.getElementById("s"+Slideous.curidx).style.display = "block";+ if (Slideous.statusbar) + document.getElementById("statusbar").style.display = showall ? "none" : "block";+ Slideous.showall = showall;+ },+ hasclass: function(elem, classname) {+ var classattr = null;+ return (classattr=(elem.attributes && elem.attributes["class"])) + && classattr.nodeValue.match("\\b"+classname+"\\b");+ },+ selectedcontent: function() {+ return window.getSelection ? window.getSelection().toString() + : document.getSelection ? document.getSelection() + : document.selection ? document.selection.createRange().text+ : "";+ },+ mousenavigation: function(on) {+ if (on) {+ document.onmousedown = Slideous.mousedown;+ document.onmouseup = Slideous.mouseup;+ }+ else+ document.onmousedown = document.onmouseup = null;+ },+ mousepos: function(e) {+ return e.pageX ? {x: e.pageX, y: e.pageY} + : {x: e.x+document.body.scrollLeft, y: e.y+document.body.scrollTop};+ },+ mousedown: function(evt) {+ evt = evt||window.event;+ Slideous.mousedownpos = Slideous.mousepos(evt);+ Slideous.contentselected = !!Slideous.selectedcontent() || ((evt.target || evt.srcElement).nodeName.toLowerCase() in Slideous.clickables);+ return true;+ },+ mouseup: function(evt) {+ evt = evt||window.event;+ var pos = Slideous.mousepos(evt);+ if (pos.x == Slideous.mousedownpos.x && pos.y == Slideous.mousedownpos.y && !Slideous.contentselected) {+ Slideous.next(true);+ return evt.returnValue = !(evt.cancel = true);+ }+ return false;+ }+};+window.onload = Slideous.init;
binary file changed (absent → 56 bytes)
binary file changed (absent → 56 bytes)
binary file changed (absent → 48 bytes)
binary file changed (absent → 59 bytes)
binary file changed (absent → 59 bytes)
binary file changed (absent → 12801 bytes)
@@ -0,0 +1,405 @@+/* slidy.css++ Copyright (c) 2005-2010 W3C (MIT, ERCIM, Keio), All Rights Reserved.+ W3C liability, trademark, document use and software licensing+ rules apply, see:++ http://www.w3.org/Consortium/Legal/copyright-documents+ http://www.w3.org/Consortium/Legal/copyright-software+*/+body+{+ margin: 0 0 0 0;+ padding: 0 0 0 0;+ width: 100%;+ height: 100%;+ color: black;+ background-color: white;+ font-family: "Gill Sans MT", "Gill Sans", GillSans, sans-serif;+ font-size: 14pt;+}++div.toolbar {+ position: fixed; z-index: 200;+ top: auto; bottom: 0; left: 0; right: 0;+ height: 1.2em; text-align: right;+ padding-left: 1em;+ padding-right: 1em; + font-size: 60%;+ color: red;+ background-color: rgb(240,240,240);+ border-top: solid 1px rgb(180,180,180);+}++div.toolbar span.copyright {+ color: black;+ margin-left: 0.5em;+}++div.initial_prompt {+ position: absolute;+ z-index: 1000;+ bottom: 1.2em;+ width: 100%;+ background-color: rgb(200,200,200);+ opacity: 0.35;+ background-color: rgb(200,200,200, 0.35);+ cursor: pointer;+}++div.initial_prompt p.help {+ text-align: center;+}++div.initial_prompt p.close {+ text-align: right;+ font-style: italic;+}++div.slidy_toc {+ position: absolute;+ z-index: 300;+ width: 60%;+ max-width: 30em;+ height: 30em;+ overflow: auto;+ top: auto;+ right: auto;+ left: 4em;+ bottom: 4em;+ padding: 1em;+ background: rgb(240,240,240);+ border-style: solid;+ border-width: 2px;+ font-size: 60%;+}++div.slidy_toc .toc_heading {+ text-align: center;+ width: 100%;+ margin: 0;+ margin-bottom: 1em;+ border-bottom-style: solid;+ border-bottom-color: rgb(180,180,180);+ border-bottom-width: 1px;+}++div.slide {+ z-index: 20;+ margin: 0 0 0 0;+ padding-top: 0;+ padding-bottom: 0;+ padding-left: 20px;+ padding-right: 20px;+ border-width: 0;+ clear: both;+ top: 0;+ bottom: 0;+ left: 0;+ right: 0;+ line-height: 120%;+ background-color: transparent;+}++div.background {+ display: none;+}++div.handout {+ margin-left: 20px;+ margin-right: 20px;+}++div.slide.titlepage {+ text-align: center;+}++div.slide.titlepage h1 {+ padding-top: 10%;+ margin-right: 0;+}++div.slide h1 {+ padding-left: 0;+ padding-right: 20pt;+ padding-top: 4pt;+ padding-bottom: 4pt;+ margin-top: 0;+ margin-left: 0;+ margin-right: 60pt;+ margin-bottom: 0.5em;+ display: block; + font-size: 160%;+ line-height: 1.2em;+ background: transparent;+}++div.toc {+ position: absolute;+ top: auto;+ bottom: 4em;+ left: 4em;+ right: auto;+ width: 60%;+ max-width: 30em;+ height: 30em;+ border: solid thin black;+ padding: 1em;+ background: rgb(240,240,240);+ color: black;+ z-index: 300;+ overflow: auto;+ display: block;+ visibility: visible;+}++div.toc-heading {+ width: 100%;+ border-bottom: solid 1px rgb(180,180,180);+ margin-bottom: 1em;+ text-align: center;+}++img {+ image-rendering: optimize-quality;+}++pre {+ font-size: 80%;+ font-weight: bold;+ line-height: 120%;+ padding-top: 0.2em;+ padding-bottom: 0.2em;+ padding-left: 1em;+ padding-right: 1em;+ border-style: solid;+ border-left-width: 1em;+ border-top-width: thin;+ border-right-width: thin;+ border-bottom-width: thin;+ border-color: #95ABD0;+ color: #00428C;+ background-color: #E4E5E7;+}++li pre { margin-left: 0; }++blockquote { font-style: italic }++img { background-color: transparent }++p.copyright { font-size: smaller }++.center { text-align: center }+.footnote { font-size: smaller; margin-left: 2em; }++a img { border-width: 0; border-style: none }++a:visited { color: navy }+a:link { color: navy }+a:hover { color: red; text-decoration: underline }+a:active { color: red; text-decoration: underline }++a {text-decoration: none}+.navbar a:link {color: white}+.navbar a:visited {color: yellow}+.navbar a:active {color: red}+.navbar a:hover {color: red}++ul { list-style-type: square; }+ul ul { list-style-type: disc; }+ul ul ul { list-style-type: circle; }+ul ul ul ul { list-style-type: disc; }+li { margin-left: 0.5em; margin-top: 0.5em; }+li li { font-size: 85%; font-style: italic }+li li li { font-size: 85%; font-style: normal }++div dt+{+ margin-left: 0;+ margin-top: 1em;+ margin-bottom: 0.5em;+ font-weight: bold;+}+div dd+{+ margin-left: 2em;+ margin-bottom: 0.5em;+}+++p,pre,ul,ol,blockquote,h2,h3,h4,h5,h6,dl,table {+ margin-left: 1em;+ margin-right: 1em;+}++p.subhead { font-weight: bold; margin-top: 2em; }++.smaller { font-size: smaller }+.bigger { font-size: 130% }++td,th { padding: 0.2em }++ul {+ margin: 0.5em 1.5em 0.5em 1.5em;+ padding: 0;+}++ol {+ margin: 0.5em 1.5em 0.5em 1.5em;+ padding: 0;+}++ul { list-style-type: square; }+ul ul { list-style-type: disc; }+ul ul ul { list-style-type: circle; }+ul ul ul ul { list-style-type: disc; }++ul li { + list-style: square;+ margin: 0.1em 0em 0.6em 0;+ padding: 0 0 0 0;+ line-height: 140%;+}++ol li { + margin: 0.1em 0em 0.6em 1.5em;+ padding: 0 0 0 0px;+ line-height: 140%;+ list-style-type: decimal;+}++li ul li { + font-size: 85%; + font-style: italic;+ list-style-type: disc;+ background: transparent;+ padding: 0 0 0 0;+}+li li ul li { + font-size: 85%; + font-style: normal;+ list-style-type: circle;+ background: transparent;+ padding: 0 0 0 0;+}+li li li ul li {+ list-style-type: disc;+ background: transparent;+ padding: 0 0 0 0;+}++li ol li {+ list-style-type: decimal;+}+++li li ol li {+ list-style-type: decimal;+}++/*+ setting class="outline on ol or ul makes it behave as an+ ouline list where blocklevel content in li elements is+ hidden by default and can be expanded or collapsed with+ mouse click. Set class="expand" on li to override default+*/++ol.outline li:hover { cursor: pointer }+ol.outline li.nofold:hover { cursor: default }++ul.outline li:hover { cursor: pointer }+ul.outline li.nofold:hover { cursor: default }++ol.outline { list-style:decimal; }+ol.outline ol { list-style-type:lower-alpha }++ol.outline li.nofold {+ padding: 0 0 0 20px;+ background: transparent url(../graphics/nofold-dim.gif) no-repeat 0px 0.5em;+}+ol.outline li.unfolded {+ padding: 0 0 0 20px;+ background: transparent url(../graphics/fold-dim.gif) no-repeat 0px 0.5em;+}+ol.outline li.folded {+ padding: 0 0 0 20px;+ background: transparent url(../graphics/unfold-dim.gif) no-repeat 0px 0.5em;+}+ol.outline li.unfolded:hover {+ padding: 0 0 0 20px;+ background: transparent url(../graphics/fold.gif) no-repeat 0px 0.5em;+}+ol.outline li.folded:hover {+ padding: 0 0 0 20px;+ background: transparent url(../graphics/unfold.gif) no-repeat 0px 0.5em;+}++ul.outline li.nofold {+ padding: 0 0 0 20px;+ background: transparent url(../graphics/nofold-dim.gif) no-repeat 0px 0.5em;+}+ul.outline li.unfolded {+ padding: 0 0 0 20px;+ background: transparent url(../graphics/fold-dim.gif) no-repeat 0px 0.5em;+}+ul.outline li.folded {+ padding: 0 0 0 20px;+ background: transparent url(../graphics/unfold-dim.gif) no-repeat 0px 0.5em;+}+ul.outline li.unfolded:hover {+ padding: 0 0 0 20px;+ background: transparent url(../graphics/fold.gif) no-repeat 0px 0.5em;+}+ul.outline li.folded:hover {+ padding: 0 0 0 20px;+ background: transparent url(../graphics/unfold.gif) no-repeat 0px 0.5em;+}++/* for slides with class "title" in table of contents */+a.titleslide { font-weight: bold; font-style: italic }++/*+ hide images for work around for save as bug+ where browsers fail to save images used by CSS+*/+img.hidden { display: none; visibility: hidden }+div.initial_prompt { display: none; visibility: hidden }++ div.slide {+ visibility: visible;+ position: inherit;+ }+ div.handout {+ border-top-style: solid;+ border-top-width: thin;+ border-top-color: black;+ }++@media screen {+ .hidden { display: none; visibility: visible }++ div.slide.hidden { display: block; visibility: visible }+ div.handout.hidden { display: block; visibility: visible }+ div.background { display: none; visibility: hidden }+ body.single_slide div.initial_prompt { display: block; visibility: visible }+ body.single_slide div.background { display: block; visibility: visible }+ body.single_slide div.background.hidden { display: none; visibility: hidden }+ body.single_slide .invisible { visibility: hidden }+ body.single_slide .hidden { display: none; visibility: hidden }+ body.single_slide div.slide { position: absolute }+ body.single_slide div.handout { display: none; visibility: hidden }+}++@media print {+ .hidden { display: block; visibility: visible }++ div.slide pre { font-size: 60%; padding-left: 0.5em; }+ div.toolbar { display: none; visibility: hidden; }+ div.slidy_toc { display: none; visibility: hidden; }+ div.background { display: none; visibility: hidden; }+ div.slide { page-break-before: always }+ /* :first-child isn't reliable for print media */+ div.slide.first-slide { page-break-before: avoid }+}+
@@ -0,0 +1,26 @@+$if(titleblock)$+$title$+$for(author)$+:author: $author$+$endfor$+$if(date)$+:date: $date$+$endif$+$if(toc)$+:toc:+$endif$++$endif$+$for(header-includes)$+$header-includes$++$endfor$+$for(include-before)$+$include-before$++$endfor$+$body$+$for(include-after)$++$include-after$+$endfor$
@@ -0,0 +1,152 @@+\documentclass[$if(fontsize)$$fontsize$,$endif$$if(handout)$handout,$endif$$if(beamer)$ignorenonframetext,$endif$]{$documentclass$}+$if(theme)$+\usetheme{$theme$}+$endif$+$if(colortheme)$+\usecolortheme{$colortheme$}+$endif$+\usepackage{amssymb,amsmath}+\usepackage{ifxetex,ifluatex}+\usepackage{fixltx2e} % provides \textsubscript+\ifxetex+ \usepackage{fontspec,xltxtra,xunicode}+ \defaultfontfeatures{Mapping=tex-text,Scale=MatchLowercase}+\else+ \ifluatex+ \usepackage{fontspec}+ \defaultfontfeatures{Mapping=tex-text,Scale=MatchLowercase}+ \else+ \usepackage[utf8]{inputenc}+ \fi+\fi+$if(natbib)$+\usepackage{natbib}+\bibliographystyle{plainnat}+$endif$+$if(biblatex)$+\usepackage{biblatex}+$if(biblio-files)$+\bibliography{$biblio-files$}+$endif$+$endif$+$if(listings)$+\usepackage{listings}+$endif$+$if(lhs)$+\lstnewenvironment{code}{\lstset{language=Haskell,basicstyle=\small\ttfamily}}{}+$endif$+$if(highlighting-macros)$+$highlighting-macros$+$endif$+$if(verbatim-in-note)$+\usepackage{fancyvrb}+$endif$+$if(tables)$+\usepackage{longtable}+$endif$+$if(url)$+\usepackage{url}+$endif$+$if(graphics)$+\usepackage{graphicx}+\makeatletter+\def\ScaleIfNeeded{%+ \ifdim\Gin@nat@width>\linewidth+ \linewidth+ \else+ \Gin@nat@width+ \fi+}+\makeatother+\setkeys{Gin}{width=\ScaleIfNeeded}+$endif$++% Comment these out if you don't want a slide with just the+% part/section/subsection/subsubsection title:+\AtBeginPart{+ \let\insertpartnumber\relax+ \let\partname\relax+ \frame{\partpage}+}+\AtBeginSection{+ \let\insertsectionnumber\relax+ \let\sectionname\relax+ \frame{\sectionpage}+}+\AtBeginSubsection{+ \let\insertsubsectionnumber\relax+ \let\subsectionname\relax+ \frame{\subsectionpage}+}++$if(strikeout)$+\usepackage[normalem]{ulem}+% avoid problems with \sout in headers with hyperref:+\pdfstringdefDisableCommands{\renewcommand{\sout}{}}+$endif$+\setlength{\parindent}{0pt}+\setlength{\parskip}{6pt plus 2pt minus 1pt}+\setlength{\emergencystretch}{3em} % prevent overfull lines+$if(numbersections)$+$else$+\setcounter{secnumdepth}{0}+$endif$+$if(verbatim-in-note)$+\VerbatimFootnotes % allows verbatim text in footnotes+$endif$+$if(lang)$+\usepackage[$lang$]{babel}+$endif$+$for(header-includes)$+$header-includes$+$endfor$++$if(title)$+\title{$title$}+$endif$+$if(author)$+\author{$for(author)$$author$$sep$ \and $endfor$}+$endif$+$if(date)$+\date{$date$}+$endif$++\begin{document}+$if(title)$+\frame{\titlepage}+$endif$++$for(include-before)$+$include-before$++$endfor$+$if(toc)$+\begin{frame}+\tableofcontents[hideallsubsections]+\end{frame}++$endif$+$body$++$if(natbib)$+$if(biblio-files)$+$if(biblio-title)$+$if(book-class)$+\renewcommand\bibname{$biblio-title$}+$else$+\renewcommand\refname{$biblio-title$}+$endif$+$endif$+\bibliography{$biblio-files$}++$endif$+$endif$+$if(biblatex)$+\printbibliography$if(biblio-title)$[title=$biblio-title$]$endif$++$endif$+$for(include-after)$+$include-after$++$endfor$+\end{document}
@@ -0,0 +1,81 @@+\startmode[*mkii]+ \enableregime[utf-8] + \setupcolors[state=start]+\stopmode+$if(mainlang)$+\mainlanguage[$mainlang$]+$endif$++% Enable hyperlinks+\setupinteraction[state=start, color=middleblue]++\setuppapersize [$if(papersize)$$papersize$$else$letter$endif$][$if(papersize)$$papersize$$else$letter$endif$]+\setuplayout [width=middle, backspace=1.5in, cutspace=1.5in,+ height=middle, topspace=0.75in, bottomspace=0.75in]++\setuppagenumbering[location={footer,center}]++\setupbodyfont[11pt]++\setupwhitespace[medium]++\setuphead[chapter] [style=\tfd]+\setuphead[section] [style=\tfc]+\setuphead[subsection] [style=\tfb]+\setuphead[subsubsection][style=\bf]++$if(number-sections)$+$else$+\setuphead[chapter, section, subsection, subsubsection][number=no]+$endif$++\definedescription+ [description]+ [headstyle=bold, style=normal, location=hanging, width=broad, margin=1cm]++\setupitemize[autointro] % prevent orphan list intro+\setupitemize[indentnext=no]++\setupthinrules[width=15em] % width of horizontal rules++\setupdelimitedtext+ [blockquote]+ [before={\blank[medium]},+ after={\blank[medium]},+ indentnext=no,+ ]++$for(header-includes)$+$header-includes$+$endfor$++\starttext+$if(title)$+\startalignment[center]+ \blank[2*big]+ {\tfd $title$}+$if(author)$+ \blank[3*medium]+ {\tfa $for(author)$$author$$sep$\crlf $endfor$}+$endif$+$if(date)$+ \blank[2*medium]+ {\tfa $date$}+$endif$+ \blank[3*medium]+\stopalignment+$endif$+$for(include-before)$+$include-before$+$endfor$+$if(toc)$+\placelist[$placelist$]+\placecontent+$endif$++$body$++$for(include-after)$+$include-after$+$endfor$+\stoptext
@@ -0,0 +1,28 @@+<?xml version="1.0" encoding="utf-8" ?>+$if(mathml)$+<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook EBNF Module V1.1CR1//EN"+ "http://www.oasis-open.org/docbook/xml/mathml/1.1CR1/dbmathml.dtd">+$else$+<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"+ "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd">+$endif$+<article>+ <articleinfo>+ <title>$title$</title>+$for(author)$+ <author>+ $author$+ </author>+$endfor$+$if(date)$+ <date>$date$</date>+$endif$+ </articleinfo>+$for(include-before)$+$include-before$+$endfor$+$body$+$for(include-after)$+$include-after$+$endfor$+</article>
@@ -0,0 +1,120 @@+<!DOCTYPE html>+<head>+<meta charset="utf-8">+$for(author-meta)$+ <meta name="author" content="$author-meta$" />+$endfor$+$if(date-meta)$+ <meta name="dcterms.date" content="$date-meta$" />+$endif$+ <title>$if(title-prefix)$$title-prefix$ - $endif$$pagetitle$</title>+ <style type="text/css">code{white-space: pre;}</style>+$if(highlighting-css)$+ <style type="text/css">+$highlighting-css$+ </style>+$endif$+$if(css)$+$for(css)$+ <link rel="stylesheet" href="$css$" $if(html5)$$else$type="text/css" $endif$/>+$endfor$+$else$+<style>+ html { background-color: black; }+ body { background-color: white; border-radius: 12px}+ /* A section is a slide. It's size is 800x600, and this will never change */+ section {+ font-family: Arial, serif;+ font-size: 20pt;+ }+ address, blockquote, dl, fieldset, form, h1, h2, h3, h4, h5, h6, hr, ol, p, pre, table, ul, dl { padding: 10px 20px 10px 20px; }+ h1, h2, h3 {+ text-align: center;+ margin: 10pt 10pt 20pt 10pt;+ }+ ul, ol {+ margin: 10px 10px 10px 50px;+ }+ section.titleslide h1 { margin-top: 200px; }+ h1.title { margin-top: 150px; }+ h1 { font-size: 180%; }+ h2 { font-size: 120%; }+ h3 { font-size: 100%; }+ q { quotes: "“" "”" "‘" "’"; }+ blockquote { font-style: italic }+ /* Figures are displayed full-page, with the caption on+ top of the image/video */+ figure {+ background-color: black;+ }+ figcaption {+ margin: 70px;+ }+ footer {+ position: absolute;+ bottom: 0;+ width: 100%;+ padding: 40px;+ text-align: right;+ background-color: #F3F4F8;+ border-top: 1px solid #CCC;+ }++ /* Transition effect */+ /* Feel free to change the transition effect for original+ animations. See here:+ https://developer.mozilla.org/en/CSS/CSS_transitions+ How to use CSS3 Transitions: */+ section {+ -moz-transition: left 400ms linear 0s;+ -webkit-transition: left 400ms linear 0s;+ -ms-transition: left 400ms linear 0s;+ transition: left 400ms linear 0s;+ }++ /* Before */+ section { left: -150%; }+ /* Now */+ section[aria-selected] { left: 0; }+ /* After */+ section[aria-selected] ~ section { left: +150%; }++ /* Incremental elements */++ /* By default, visible */+ .incremental > * { opacity: 1; }++ /* The current item */+ .incremental > *[aria-selected] { color: red; opacity: 1; }++ /* The items to-be-selected */+ .incremental > *[aria-selected] ~ * { opacity: 0.2; }+</style>+$endif$+$if(math)$+ $math$+$endif$+$for(header-includes)$+ $header-includes$+$endfor$+</head>+<body>+$if(title)$+<section>+ <h1 class="title">$title$</h1>+$for(author)$+ <h2 class="author">$author$</h2>+$endfor$+ <h3 class="date">$date$</h3>+</section>+$endif$+$for(include-before)$+$include-before$+$endfor$+$body$+$for(include-after)$+$include-after$+$endfor$+$dzslides-core$+</body>+</html>
@@ -0,0 +1,32 @@+<?xml version="1.0" encoding="UTF-8"?>+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">+<html xmlns="http://www.w3.org/1999/xhtml"$if(lang)$ xml:lang="$lang$"$endif$>+<head>+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />+ <meta http-equiv="Content-Style-Type" content="text/css" />+ <meta name="generator" content="pandoc" />+ <title>$pagetitle$</title>+$if(highlighting-css)$+ <style type="text/css">+$highlighting-css$+ </style>+$endif$+$for(css)$+ <link rel="stylesheet" type="text/css" href="$css$" />+$endfor$+</head>+<body>+$if(titlepage)$+ <h1 class="title">$title$</h1>+$for(author)$+ <h2 class="author">$author$</h2>+$endfor$+$if(date)$+ <h3 class="date">$date$</h3>+$endif$+$else$+$body$+$endif$+</body>+</html>+
@@ -0,0 +1,36 @@+<?xml version="1.0" encoding="UTF-8"?>+<!DOCTYPE html>+<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops"$if(lang)$ xml:lang="$lang$"$endif$>+<head>+ <meta charset="utf-8" />+ <meta name="generator" content="pandoc" />+ <title>$pagetitle$</title>+$if(quotes)$+ <style type="text/css">+ q { quotes: "“" "”" "‘" "’"; }+ </style>+$endif$+$if(highlighting-css)$+ <style type="text/css">+$highlighting-css$+ </style>+$endif$+$for(css)$+ <link rel="stylesheet" href="$css$" />+$endfor$+</head>+<body>+$if(titlepage)$+ <h1 class="title">$title$</h1>+$for(author)$+ <h2 class="author">$author$</h2>+$endfor$+$if(date)$+ <h3 class="date">$date$</h3>+$endif$+$else$+$body$+$endif$+</body>+</html>+
@@ -0,0 +1,58 @@+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">+<html xmlns="http://www.w3.org/1999/xhtml"$if(lang)$ lang="$lang$" xml:lang="$lang$"$endif$>+<head>+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />+ <meta http-equiv="Content-Style-Type" content="text/css" />+ <meta name="generator" content="pandoc" />+$for(author-meta)$+ <meta name="author" content="$author-meta$" />+$endfor$+$if(date-meta)$+ <meta name="date" content="$date-meta$" />+$endif$+ <title>$if(title-prefix)$$title-prefix$ - $endif$$pagetitle$</title>+ <style type="text/css">code{white-space: pre;}</style>+$if(quotes)$+ <style type="text/css">q { quotes: "“" "”" "‘" "’"; }</style>+$endif$+$if(highlighting-css)$+ <style type="text/css">+$highlighting-css$+ </style>+$endif$+$for(css)$+ <link rel="stylesheet" href="$css$" $if(html5)$$else$type="text/css" $endif$/>+$endfor$+$if(math)$+ $math$+$endif$+$for(header-includes)$+ $header-includes$+$endfor$+</head>+<body>+$for(include-before)$+$include-before$+$endfor$+$if(title)$+<div id="$idprefix$header">+<h1 class="title">$title$</h1>+$for(author)$+<h2 class="author">$author$</h2>+$endfor$+$if(date)$+<h3 class="date">$date$</h3>+$endif$+</div>+$endif$+$if(toc)$+<div id="$idprefix$TOC">+$toc$+</div>+$endif$+$body$+$for(include-after)$+$include-after$+$endfor$+</body>+</html>
@@ -0,0 +1,60 @@+<!DOCTYPE html>+<html$if(lang)$ lang="$lang$"$endif$>+<head>+ <meta charset="utf-8">+ <meta name="generator" content="pandoc">+$for(author-meta)$+ <meta name="author" content="$author-meta$">+$endfor$+$if(date-meta)$+ <meta name="dcterms.date" content="$date-meta$">+$endif$+ <title>$if(title-prefix)$$title-prefix$ - $endif$$pagetitle$</title>+ <style type="text/css">code{white-space: pre;}</style>+ <!--[if lt IE 9]>+ <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>+ <![endif]-->+$if(quotes)$+ <style type="text/css">q { quotes: "“" "”" "‘" "’"; }</style>+$endif$+$if(highlighting-css)$+ <style type="text/css">+$highlighting-css$+ </style>+$endif$+$for(css)$+ <link rel="stylesheet" href="$css$">+$endfor$+$if(math)$+ $math$+$endif$+$for(header-includes)$+ $header-includes$+$endfor$+</head>+<body>+$for(include-before)$+$include-before$+$endfor$+$if(title)$+<header>+<h1 class="title">$title$</h1>+$for(author)$+<h2 class="author">$author$</h2>+$endfor$+$if(date)$+<h3 class="date">$date$</h3>+$endif$+</header>+$endif$+$if(toc)$+<nav id="$idprefix$TOC">+$toc$+</nav>+$endif$+$body$+$for(include-after)$+$include-after$+$endfor$+</body>+</html>
@@ -0,0 +1,167 @@+\documentclass[$if(fontsize)$$fontsize$,$endif$$if(lang)$$lang$,$endif$$if(papersize)$$papersize$,$endif$]{$documentclass$}+\usepackage[T1]{fontenc}+\usepackage{lmodern}+\usepackage{amssymb,amsmath}+\usepackage{ifxetex,ifluatex}+\usepackage{fixltx2e} % provides \textsubscript+% use microtype if available+\IfFileExists{microtype.sty}{\usepackage{microtype}}{}+% use upquote if available, for straight quotes in verbatim environments+\IfFileExists{upquote.sty}{\usepackage{upquote}}{}+\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex+ \usepackage[utf8]{inputenc}+$if(euro)$+ \usepackage{eurosym}+$endif$+\else % if luatex or xelatex+ \usepackage{fontspec}+ \ifxetex+ \usepackage{xltxtra,xunicode}+ \fi+ \defaultfontfeatures{Mapping=tex-text,Scale=MatchLowercase}+ \newcommand{\euro}{€}+$if(mainfont)$+ \setmainfont{$mainfont$}+$endif$+$if(sansfont)$+ \setsansfont{$sansfont$}+$endif$+$if(monofont)$+ \setmonofont{$monofont$}+$endif$+$if(mathfont)$+ \setmathfont{$mathfont$}+$endif$+\fi+$if(geometry)$+\usepackage[$for(geometry)$$geometry$$sep$,$endfor$]{geometry}+$endif$+$if(natbib)$+\usepackage{natbib}+\bibliographystyle{plainnat}+$endif$+$if(biblatex)$+\usepackage{biblatex}+$if(biblio-files)$+\bibliography{$biblio-files$}+$endif$+$endif$+$if(listings)$+\usepackage{listings}+$endif$+$if(lhs)$+\lstnewenvironment{code}{\lstset{language=Haskell,basicstyle=\small\ttfamily}}{}+$endif$+$if(highlighting-macros)$+$highlighting-macros$+$endif$+$if(verbatim-in-note)$+\usepackage{fancyvrb}+$endif$+$if(tables)$+\usepackage{longtable}+$endif$+$if(graphics)$+\usepackage{graphicx}+% We will generate all images so they have a width \maxwidth. This means+% that they will get their normal width if they fit onto the page, but+% are scaled down if they would overflow the margins.+\makeatletter+\def\maxwidth{\ifdim\Gin@nat@width>\linewidth\linewidth+\else\Gin@nat@width\fi}+\makeatother+\let\Oldincludegraphics\includegraphics+\renewcommand{\includegraphics}[1]{\Oldincludegraphics[width=\maxwidth]{#1}}+$endif$+\ifxetex+ \usepackage[setpagesize=false, % page size defined by xetex+ unicode=false, % unicode breaks when used with xetex+ xetex]{hyperref}+\else+ \usepackage[unicode=true]{hyperref}+\fi+\hypersetup{breaklinks=true,+ bookmarks=true,+ pdfauthor={$author-meta$},+ pdftitle={$title-meta$},+ colorlinks=true,+ urlcolor=$if(urlcolor)$$urlcolor$$else$blue$endif$,+ linkcolor=$if(linkcolor)$$linkcolor$$else$magenta$endif$,+ pdfborder={0 0 0}}+$if(links-as-notes)$+% Make links footnotes instead of hotlinks:+\renewcommand{\href}[2]{#2\footnote{\url{#1}}}+$endif$+$if(strikeout)$+\usepackage[normalem]{ulem}+% avoid problems with \sout in headers with hyperref:+\pdfstringdefDisableCommands{\renewcommand{\sout}{}}+$endif$+\setlength{\parindent}{0pt}+\setlength{\parskip}{6pt plus 2pt minus 1pt}+\setlength{\emergencystretch}{3em} % prevent overfull lines+$if(numbersections)$+$else$+\setcounter{secnumdepth}{0}+$endif$+$if(verbatim-in-note)$+\VerbatimFootnotes % allows verbatim text in footnotes+$endif$+$if(lang)$+\ifxetex+ \usepackage{polyglossia}+ \setmainlanguage{$mainlang$}+\else+ \usepackage[$lang$]{babel}+\fi+$endif$+$for(header-includes)$+$header-includes$+$endfor$++$if(title)$+\title{$title$}+$endif$+\author{$for(author)$$author$$sep$ \and $endfor$}+\date{$date$}++\begin{document}+$if(title)$+\maketitle+$endif$++$for(include-before)$+$include-before$++$endfor$+$if(toc)$+{+\hypersetup{linkcolor=black}+\setcounter{tocdepth}{$toc-depth$}+\tableofcontents+}+$endif$+$body$++$if(natbib)$+$if(biblio-files)$+$if(biblio-title)$+$if(book-class)$+\renewcommand\bibname{$biblio-title$}+$else$+\renewcommand\refname{$biblio-title$}+$endif$+$endif$+\bibliography{$biblio-files$}++$endif$+$endif$+$if(biblatex)$+\printbibliography$if(biblio-title)$[title=$biblio-title$]$endif$++$endif$+$for(include-after)$+$include-after$++$endfor$+\end{document}
@@ -0,0 +1,18 @@+$if(has-tables)$+.\"t+$endif$+.TH $title$ $section$ "$date$" $description$+$for(header-includes)$+$header-includes$+$endfor$+$for(include-before)$+$include-before$+$endfor$+$body$+$for(include-after)$+$include-after$+$endfor$+$if(author)$+.SH AUTHORS+$for(author)$$author$$sep$; $endfor$.+$endif$
@@ -0,0 +1,21 @@+$if(titleblock)$+$titleblock$++$endif$+$for(header-includes)$+$header-includes$++$endfor$+$for(include-before)$+$include-before$++$endfor$+$if(toc)$+$toc$++$endif$+$body$+$for(include-after)$++$include-after$+$endfor$
@@ -0,0 +1,13 @@+$for(include-before)$+$include-before$++$endfor$+$if(toc)$+__TOC__++$endif$+$body$+$for(include-after)$++$include-after$+$endfor$
@@ -0,0 +1,27 @@+<?xml version="1.0" encoding="utf-8" ?>+<office:document-content xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" office:version="1.0">+ $automatic-styles$+$for(header-includes)$+ $header-includes$+$endfor$ +<office:body>+<office:text>+$if(title)$+<text:h text:style-name="Title">$title$</text:h>+$endif$+$for(author)$+<text:p text:style-name="Author">$author$</text:p>+$endfor$+$if(date)$+<text:p text:style-name="Date">$date$</text:p>+$endif$+$for(include-before)$+$include-before$+$endfor$+$body$+$for(include-after)$+$include-after$+$endfor$+</office:text>+</office:body>+</office:document-content>
@@ -0,0 +1,24 @@+$if(title)$+$title$++$endif$+$if(author)$+#+AUTHOR: $for(author)$$author$$sep$; $endfor$+$endif$+$if(date)$+#+DATE: $date$++$endif$+$for(header-includes)$+$header-includes$++$endfor$+$for(include-before)$+$include-before$++$endfor$+$body$+$for(include-after)$++$include-after$+$endfor$
@@ -0,0 +1,21 @@+$if(titleblock)$+$titleblock$++$endif$+$for(header-includes)$+$header-includes$++$endfor$+$for(include-before)$+$include-before$++$endfor$+$if(toc)$+$toc$++$endif$+$body$+$for(include-after)$++$include-after$+$endfor$
@@ -0,0 +1,42 @@+$if(title)$+$title$++$endif$+$for(author)$+:Author: $author$+$endfor$+$if(date)$+:Date: $date$+$endif$+$if(author)$++$else$+$if(date)$++$endif$+$endif$+$if(math)$+.. role:: math(raw)+ :format: html latex+..++$endif$+$for(include-before)$+$include-before$++$endfor$+$if(toc)$+.. contents::+ :depth: $toc-depth$+..++$endif$+$for(header-includes)$+$header-includes$++$endfor$+$body$+$for(include-after)$++$include-after$+$endfor$
@@ -0,0 +1,30 @@+{\rtf1\ansi\deff0{\fonttbl{\f0 \fswiss Helvetica;}{\f1 Courier;}}+{\colortbl;\red255\green0\blue0;\red0\green0\blue255;}+\widowctrl\hyphauto+$for(header-includes)$+$header-includes$+$endfor$++$if(title)$+{\pard \qc \f0 \sa180 \li0 \fi0 \b \fs36 $title$\par}+$endif$+$for(author)$+{\pard \qc \f0 \sa180 \li0 \fi0 $author$\par}+$endfor$+$if(date)$+{\pard \qc \f0 \sa180 \li0 \fi0 $date$\par}+$endif$+$if(spacer)$+{\pard \ql \f0 \sa180 \li0 \fi0 \par}+$endif$+$if(toc)$+$toc$+$endif$+$for(include-before)$+$include-before$+$endfor$+$body$+$for(include-after)$+$include-after$+$endfor$+}
@@ -0,0 +1,67 @@+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">+<html xmlns="http://www.w3.org/1999/xhtml">+<head>+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />+ <meta http-equiv="Content-Style-Type" content="text/css" />+ <meta name="generator" content="pandoc" />+$for(author-meta)$+ <meta name="author" content="$author-meta$" />+$endfor$+$if(date-meta)$+ <meta name="date" content="$date-meta$" />+$endif$+ <title>$if(title-prefix)$$title-prefix$ - $endif$$pagetitle$</title>+ <style type="text/css">code{white-space: pre;}</style>+ <!-- configuration parameters -->+ <meta name="defaultView" content="slideshow" />+ <meta name="controlVis" content="hidden" />+$if(highlighting-css)$+ <style type="text/css">+$highlighting-css$+ </style>+$endif$+$for(css)$+ <link rel="stylesheet" href="$css$" type="text/css" />+$endfor$+ <!-- style sheet links -->+ <link rel="stylesheet" href="$s5-url$/slides.css" type="text/css" media="projection" id="slideProj" />+ <link rel="stylesheet" href="$s5-url$/outline.css" type="text/css" media="screen" id="outlineStyle" />+ <link rel="stylesheet" href="$s5-url$/print.css" type="text/css" media="print" id="slidePrint" />+ <link rel="stylesheet" href="$s5-url$/opera.css" type="text/css" media="projection" id="operaFix" />+ <!-- S5 JS -->+ <script src="$s5-url$/slides.js" type="text/javascript"></script>+$if(math)$+ $math$+$endif$+$for(header-includes)$+ $header-includes$+$endfor$+</head>+<body>+$for(include-before)$+$include-before$+$endfor$+<div class="layout">+<div id="controls"></div>+<div id="currentSlide"></div>+<div id="header"></div>+<div id="footer">+ <h1>$date$</h1>+ <h2>$title$</h2>+</div>+</div>+<div class="presentation">+$if(title)$+<div class="titleslide slide">+ <h1>$title$</h1>+ <h2>$for(author)$$author$$sep$<br/>$endfor$</h2>+ <h3>$date$</h3>+</div>+$endif$+$body$+$for(include-after)$+$include-after$+$endfor$+</div>+</body>+</html>
@@ -0,0 +1,76 @@+<?xml version="1.0" encoding="utf-8"?>+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">+<html xmlns="http://www.w3.org/1999/xhtml"$if(lang)$ lang="$lang$" xml:lang="$lang$"$endif$>+<head>+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />+ <meta http-equiv="Content-Style-Type" content="text/css" />+ <meta name="generator" content="pandoc" />+$for(author-meta)$+ <meta name="author" content="$author-meta$" />+$endfor$+$if(date-meta)$+ <meta name="date" content="$date-meta$" />+$endif$+ <title>$if(title-prefix)$$title-prefix$ - $endif$$pagetitle$</title>+ <style type="text/css">code{white-space: pre;}</style>+$if(highlighting-css)$+ <style type="text/css">+$highlighting-css$+ </style>+$endif$+ <link rel="stylesheet" type="text/css" media="screen, projection, print"+ href="$slideous-url$/slideous.css" />+$for(css)$+ <link rel="stylesheet" type="text/css" media="screen, projection, print"+ href="$css$" />+$endfor$+$if(math)$+ $math$+$endif$+$for(header-includes)$+ $header-includes$+$endfor$+ <script src="$slideous-url$/slideous.js"+ charset="utf-8" type="text/javascript"></script>+$if(duration)$+ <meta name="duration" content="$duration$" />+$endif$+</head>+<body>+$for(include-before)$+$include-before$+$endfor$+<div id="statusbar">+<span style="float:right;">+<span style="margin-right:4em;font-weight:bold;"><span id="slideidx"></span> of {$$slidecount}</span>+<button id="homebutton" title="first slide">1</button>+<button id="prevslidebutton" title="previous slide">«</button>+<button id="previtembutton" title="previous item">‹</button>+<button id="nextitembutton" title="next item">›</button>+<button id="nextslidebutton" title="next slide">»</button>+<button id="endbutton" title="last slide">{$$slidecount}</button>+<button id="incfontbutton" title="content">A+</button>+<button id="decfontbutton" title="first slide">A-</button>+<select id="tocbox" size="1"><option></option></select>+</span>+<span id="eos">½</span>+<span title="{$$location}, {$$date}">{$$title}, {$$author}</span>+</div>+$if(title)$+<div class="slide titlepage">+ <h1 class="title">$title$</h1>+ <p class="author">+$for(author)$$author$$sep$<br/>$endfor$+ </p>+$if(date)$+ <p class="date">$date$</p>+$endif$+</div>+$endif$+$body$+$for(include-after)$+$include-after$+$endfor$+</body>+</html>
@@ -0,0 +1,60 @@+<?xml version="1.0" encoding="utf-8"?>+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">+<html xmlns="http://www.w3.org/1999/xhtml"$if(lang)$ lang="$lang$" xml:lang="$lang$"$endif$>+<head>+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />+ <meta http-equiv="Content-Style-Type" content="text/css" />+ <meta name="generator" content="pandoc" />+$for(author-meta)$+ <meta name="author" content="$author-meta$" />+$endfor$+$if(date-meta)$+ <meta name="date" content="$date-meta$" />+$endif$+ <title>$if(title-prefix)$$title-prefix$ - $endif$$pagetitle$</title>+ <style type="text/css">code{white-space: pre;}</style>+$if(highlighting-css)$+ <style type="text/css">+$highlighting-css$+ </style>+$endif$+ <link rel="stylesheet" type="text/css" media="screen, projection, print"+ href="$slidy-url$/styles/slidy.css" />+$for(css)$+ <link rel="stylesheet" type="text/css" media="screen, projection, print"+ href="$css$" />+$endfor$+$if(math)$+ $math$+$endif$+$for(header-includes)$+ $header-includes$+$endfor$+ <script src="$slidy-url$/scripts/slidy.js.gz"+ charset="utf-8" type="text/javascript"></script>+$if(duration)$+ <meta name="duration" content="$duration$" />+$endif$+</head>+<body>+$for(include-before)$+$include-before$+$endfor$+$if(title)$+<div class="slide titlepage">+ <h1 class="title">$title$</h1>+ <p class="author">+$for(author)$$author$$sep$<br/>$endfor$+ </p>+$if(date)$+ <p class="date">$date$</p>+$endif$+</div>+$endif$+$body$+$for(include-after)$+$include-after$+$endfor$+</body>+</html>
@@ -0,0 +1,64 @@+\input texinfo+@documentencoding UTF-8+$for(header-includes)$+$header-includes$+$endfor$++$if(strikeout)$+@macro textstrikeout{text}+~~\text\~~+@end macro++$endif$+$if(subscript)$+@macro textsubscript{text}+@iftex+@textsubscript{\text\}+@end iftex+@ifnottex+_@{\text\@}+@end ifnottex+@end macro++$endif$+$if(superscript)$+@macro textsuperscript{text}+@iftex+@textsuperscript{\text\}+@end iftex+@ifnottex+^@{\text\@}+@end ifnottex+@end macro++$endif$+@ifnottex+@paragraphindent 0+@end ifnottex+$if(titlepage)$+@titlepage+@title $title$+$for(author)$+@author $author$+$endfor$+$if(date)$+$date$+$endif$+@end titlepage++$endif$+$for(include-before)$+$include-before$++$endfor$+$if(toc)$+@contents++$endif$+$body$+$for(include-after)$++$include-after$+$endfor$++@bye
@@ -0,0 +1,9 @@+$for(include-before)$+$include-before$++$endfor$+$body$+$for(include-after)$++$include-after$+$endfor$
@@ -1,422 +0,0 @@-<?xml version="1.0" encoding="utf-8"?>-<style xmlns="http://purl.org/net/xbiblio/csl" class="in-text" version="1.0" demote-non-dropping-particle="sort-only">- <info>- <title>Chicago Manual of Style (Author-Date format)</title>- <id>http://www.zotero.org/styles/chicago-author-date</id>- <link href="http://www.zotero.org/styles/chicago-author-date" rel="self"/>- <author>- <name>Julian Onions</name>- <email>julian.onions@gmail.com</email>- </author>- <contributor>- <name>Sebastian Karcher</name>- </contributor>- <category citation-format="author-date"/>- <category field="generic-base"/>- <updated>2011-11-17T22:01:05+00:00</updated>- <summary>The author-date variant of the Chicago style</summary>- <link href="http://www.chicagomanualofstyle.org/tools_citationguide.html" rel="documentation"/>- <rights>This work is licensed under a Creative Commons Attribution-Share Alike 3.0 License: http://creativecommons.org/licenses/by-sa/3.0/</rights>- </info>- <macro name="secondary-contributors">- <choose>- <if type="chapter paper-conference" match="none">- <group delimiter=". ">- <choose>- <if variable="author">- <names variable="editor">- <label form="verb-short" text-case="capitalize-first" suffix=". " strip-periods="true"/>- <name and="text" delimiter=", "/>- </names>- </if>- </choose>- <choose>- <if variable="author editor" match="any">- <names variable="translator">- <label form="verb-short" text-case="capitalize-first" suffix=". " strip-periods="true"/>- <name and="text" delimiter=", "/>- </names>- </if>- </choose>- </group>- </if>- </choose>- </macro>- <macro name="container-contributors">- <choose>- <if type="chapter paper-conference" match="any">- <group prefix="," delimiter=", ">- <choose>- <if variable="author">- <names variable="editor">- <label form="verb-short" prefix=" " text-case="lowercase" suffix=". " strip-periods="true"/>- <name and="text" delimiter=", "/>- </names>- <choose>- <if variable="container-author">- <group>- <names variable="container-author">- <label form="verb-short" prefix=" " text-case="lowercase" suffix=" " strip-periods="true"/>- <name and="text" delimiter=", "/>- </names>- </group>- </if>- </choose>- </if>- </choose>- <choose>- <if variable="author editor" match="any">- <names variable="translator">- <label form="verb-short" prefix=" " text-case="lowercase" suffix=". " strip-periods="true"/>- <name and="text" delimiter=", "/>- </names>- </if>- </choose>- </group>- </if>- </choose>- </macro>- <macro name="anon">- <text term="anonymous" form="short" text-case="capitalize-first" suffix="." strip-periods="true"/>- </macro>- <macro name="editor">- <names variable="editor">- <name name-as-sort-order="first" and="text" sort-separator=", " delimiter=", " delimiter-precedes-last="always"/>- <label form="short" prefix=", " suffix="." strip-periods="true"/>- </names>- </macro>- <macro name="translator">- <names variable="translator">- <name name-as-sort-order="first" and="text" sort-separator=", " delimiter=", " delimiter-precedes-last="always"/>- <label form="verb-short" prefix=", " suffix="." strip-periods="true"/>- </names>- </macro>- <macro name="recipient">- <choose>- <if type="personal_communication">- <choose>- <if variable="genre">- <text variable="genre" text-case="capitalize-first"/>- </if>- <else>- <text term="letter" text-case="capitalize-first"/>- </else>- </choose>- </if>- </choose>- <names variable="recipient" delimiter=", ">- <label form="verb" prefix=" " text-case="lowercase" suffix=" "/>- <name and="text" delimiter=", "/>- </names>- </macro>- <macro name="contributors">- <names variable="author">- <name and="text" name-as-sort-order="first" sort-separator=", " delimiter=", " delimiter-precedes-last="always"/>- <label form="verb-short" prefix=", " suffix="." text-case="lowercase" strip-periods="true"/>- <substitute>- <text macro="editor"/>- <text macro="translator"/>- <text macro="anon"/>- </substitute>- </names>- <text macro="recipient"/>- </macro>- <macro name="contributors-short">- <names variable="author">- <name form="short" and="text" delimiter=", " initialize-with=". "/>- <substitute>- <names variable="editor"/>- <names variable="translator"/>- <text macro="anon"/>- </substitute>- </names>- </macro>- <macro name="interviewer">- <names variable="interviewer" delimiter=", ">- <label form="verb" prefix=" " text-case="capitalize-first" suffix=" "/>- <name and="text" delimiter=", "/>- </names>- </macro>- <macro name="archive">- <group delimiter=". ">- <text variable="archive_location" text-case="capitalize-first"/>- <text variable="archive"/>- <text variable="archive-place"/>- </group>- </macro>- <macro name="access">- <group delimiter=". ">- <choose>- <if type="graphic report" match="any">- <text macro="archive"/>- </if>- <else-if type="bill book graphic legal_case motion_picture report song article-magazine article-newspaper thesis chapter paper-conference" match="none">- <text macro="archive"/>- </else-if>- </choose>- <text variable="DOI" prefix="doi:"/>- <choose>- <if type="legal_case" match="none">- <text variable="URL"/>- </if>- </choose>- </group>- </macro>- <macro name="title">- <choose>- <if variable="title" match="none">- <choose>- <if type="personal_communication" match="none">- <text variable="genre" text-case="capitalize-first"/>- </if>- </choose>- </if>- <else-if type="bill book graphic legal_case motion_picture report song" match="any">- <text variable="title" font-style="italic"/>- </else-if>- <else>- <text variable="title" quotes="true"/>- </else>- </choose>- </macro>- <macro name="edition">- <choose>- <if type="bill book graphic legal_case motion_picture report song chapter paper-conference" match="any">- <choose>- <if is-numeric="edition">- <group delimiter=" ">- <number variable="edition" form="ordinal"/>- <text term="edition" form="short" suffix="." strip-periods="true"/>- </group>- </if>- <else>- <text variable="edition" suffix="."/>- </else>- </choose>- </if>- </choose>- </macro>- <macro name="locators">- <choose>- <if type="article-journal">- <text variable="volume" prefix=" "/>- <text variable="issue" prefix=" (" suffix=")"/>- </if>- <else-if type="legal_case">- <text variable="volume" prefix=", "/>- <text variable="container-title" prefix=" "/>- <text variable="page" prefix=" "/>- </else-if>- <else-if type="bill book graphic legal_case motion_picture report song" match="any">- <group prefix=". " delimiter=". ">- <group>- <text term="volume" form="short" text-case="capitalize-first" suffix=". " strip-periods="true"/>- <number variable="volume" form="numeric"/>- </group>- <group>- <number variable="number-of-volumes" form="numeric"/>- <text term="volume" form="short" prefix=" " suffix="." plural="true" strip-periods="true"/>- </group>- </group>- </else-if>- <else-if type="chapter paper-conference" match="any">- <choose>- <if variable="page" match="none">- <group prefix=". ">- <text term="volume" form="short" text-case="capitalize-first" suffix=". " strip-periods="true"/>- <number variable="volume" form="numeric"/>- </group>- </if>- </choose>- </else-if>- </choose>- </macro>- <macro name="locators-chapter">- <choose>- <if type="chapter paper-conference" match="any">- <choose>- <if variable="page">- <group prefix=", ">- <text variable="volume" suffix=":"/>- <text variable="page"/>- </group>- </if>- </choose>- </if>- </choose>- </macro>- <macro name="locators-article">- <choose>- <if type="article-newspaper">- <group prefix=", " delimiter=", ">- <group>- <text variable="edition" suffix=" "/>- <text term="edition" prefix=" "/>- </group>- <group>- <text term="section" form="short" suffix=". " strip-periods="true"/>- <text variable="section"/>- </group>- </group>- </if>- <else-if type="article-journal">- <text variable="page" prefix=": "/>- </else-if>- </choose>- </macro>- <macro name="point-locators">- <choose>- <if variable="locator">- <choose>- <if locator="page" match="none">- <choose>- <if type="bill book graphic legal_case motion_picture report song" match="any">- <choose>- <if variable="volume">- <group>- <text term="volume" form="short" text-case="lowercase" suffix=". " strip-periods="true"/>- <number variable="volume" form="numeric"/>- <label variable="locator" form="short" prefix=", " suffix=" "/>- </group>- </if>- <else>- <label variable="locator" form="short" suffix=" "/>- </else>- </choose>- </if>- </choose>- </if>- <else-if type="bill book graphic legal_case motion_picture report song" match="any">- <number variable="volume" form="numeric" suffix=":"/>- </else-if>- </choose>- <text variable="locator"/>- </if>- </choose>- </macro>- <macro name="container-prefix">- <text term="in" text-case="capitalize-first"/>- </macro>- <macro name="container-title">- <choose>- <if type="chapter paper-conference" match="any">- <text macro="container-prefix" suffix=" "/>- </if>- </choose>- <choose>- <if type="legal_case" match="none">- <text variable="container-title" font-style="italic"/>- </if>- </choose>- </macro>- <macro name="publisher">- <group delimiter=": ">- <text variable="publisher-place"/>- <text variable="publisher"/>- </group>- </macro>- <macro name="date">- <date variable="issued">- <date-part name="year"/>- </date>- </macro>- <macro name="day-month">- <date variable="issued">- <date-part name="month"/>- <date-part name="day" prefix=" "/>- </date>- </macro>- <macro name="collection-title">- <text variable="collection-title"/>- <text variable="collection-number" prefix=" "/>- </macro>- <macro name="event">- <group>- <text term="presented at" suffix=" "/>- <text variable="event"/>- </group>- </macro>- <macro name="description">- <choose>- <if type="interview">- <group delimiter=". ">- <text macro="interviewer"/>- <text variable="medium" text-case="capitalize-first"/>- </group>- </if>- <else>- <text variable="medium" text-case="capitalize-first" prefix=". "/>- </else>- </choose>- <choose>- <if variable="title" match="none"/>- <else-if type="thesis"/>- <else>- <text variable="genre" text-case="capitalize-first" prefix=". "/>- </else>- </choose>- </macro>- <macro name="issue">- <choose>- <if type="article-journal">- <text macro="day-month" prefix=" (" suffix=")"/>- </if>- <else-if type="legal_case">- <text variable="authority" prefix=". "/>- </else-if>- <else-if type="speech">- <group prefix=" " delimiter=", ">- <text macro="event"/>- <text macro="day-month"/>- <text variable="event-place"/>- </group>- </else-if>- <else-if type="article-newspaper article-magazine" match="any">- <text macro="day-month" prefix=", "/>- </else-if>- <else>- <group prefix=". " delimiter=", ">- <choose>- <if type="thesis">- <text variable="genre" text-case="capitalize-first"/>- </if>- </choose>- <text macro="publisher"/>- </group>- </else>- </choose>- </macro>- <citation et-al-min="4" et-al-use-first="1" disambiguate-add-year-suffix="true" disambiguate-add-names="true" disambiguate-add-givenname="true" givenname-disambiguation-rule="primary-name">- <layout prefix="(" suffix=")" delimiter="; ">- <group delimiter=", ">- <group delimiter=" ">- <text macro="contributors-short"/>- <text macro="date"/>- </group>- <text macro="point-locators"/>- </group>- </layout>- </citation>- <bibliography hanging-indent="true" et-al-min="11" et-al-use-first="7" subsequent-author-substitute="———" entry-spacing="0">- <sort>- <key macro="contributors"/>- <key variable="issued"/>- </sort>- <layout suffix=".">- <text macro="contributors" suffix=". "/>- <text macro="date" suffix=". "/>- <text macro="title"/>- <text macro="description"/>- <text macro="secondary-contributors" prefix=". "/>- <text macro="container-title" prefix=". "/>- <text macro="container-contributors"/>- <text macro="locators-chapter"/>- <text macro="edition" prefix=". "/>- <text macro="locators"/>- <text macro="collection-title" prefix=". "/>- <text macro="issue"/>- <text macro="locators-article"/>- <text macro="access" prefix=". "/>- </layout>- </bibliography>-</style>
@@ -1,585 +0,0 @@-<!DOCTYPE html>--<meta charset="utf-8">-<title>The Title Of Your Presentation</title>--<!-- Your Slides -->-<!-- One section is one slide -->--<section>- <!-- This is the first slide -->- <h1>My Presentation</h1>- <footer>by John Doe</footer>-</section>--<section>- <p>Some random text: But I've never been to the moon! You can see how I lived before I met you. Also Zoidberg.- I could if you hadn't turned on the light and shut off my stereo.</p>-</section>--<section>- <h3>An incremental list</h3>- <ul class="incremental">- <li>Item 1- <li>Item 2- <li>Item 3- </ul>- <details>Some notes. They are only visible using onstage shell.</details>-</section>--<section>- <q>- Who's brave enough to fly into something we all keep calling a death sphere?- </q>-</section>--<section>- <h2>Part two</h2>-</section>--<section>- <figure> <!-- Figures are used to display images and videos fullpage -->- <img src="http://placekitten.com/g/800/600">- <figcaption>An image</figcaption>- </figure>- <details>Kittens are so cute!</details>-</section>--<section>- <figure> <!-- Videos are automatically played -->- <video src="http://videos-cdn.mozilla.net/brand/Mozilla_Firefox_Manifesto_v0.2_640.webm" poster="http://www.mozilla.org/images/about/poster.jpg"></video>- <figcaption>A video</figcaption>- </figure>-</section>--<section>- <h2>End!</h2>-</section>--<!-- Your Style -->-<!-- Define the style of your presentation -->--<!-- Maybe a font from http://www.google.com/webfonts ? -->-<link href='http://fonts.googleapis.com/css?family=Oswald' rel='stylesheet'>--<style>- html { background-color: black; }- body { background-color: white; border-radius: 12px}- /* A section is a slide. It's size is 800x600, and this will never change */- section {- /* The font from Google */- font-family: 'Oswald', arial, serif;- font-size: 30px;- }- h1, h2 {- margin-top: 200px;- text-align: center;- font-size: 80px;- }- h3 {- margin: 100px 0 50px 100px;- }-- ul {- margin: 50px 200px;- }-- p {- margin: 75px;- font-size: 50px;- }-- q {- display: block;- width: 100%;- height: 100%;- background-color: black;- color: white;- font-size: 60px;- padding: 50px;- }-- /* Figures are displayed full-page, with the caption- on top of the image/video */- figure {- background-color: black;- }- figcaption {- margin: 70px;- font-size: 50px;- }-- footer {- position: absolute;- bottom: 0;- width: 100%;- padding: 40px;- text-align: right;- background-color: #F3F4F8;- border-top: 1px solid #CCC;- }-- /* Transition effect */- /* Feel free to change the transition effect for original- animations. See here:- https://developer.mozilla.org/en/CSS/CSS_transitions- How to use CSS3 Transitions: */- section {- -moz-transition: left 400ms linear 0s;- -webkit-transition: left 400ms linear 0s;- -ms-transition: left 400ms linear 0s;- transition: left 400ms linear 0s;- }-- /* Before */- section { left: -150%; }- /* Now */- section[aria-selected] { left: 0; }- /* After */- section[aria-selected] ~ section { left: +150%; }-- /* Incremental elements */-- /* By default, visible */- .incremental > * { opacity: 1; }-- /* The current item */- .incremental > *[aria-selected] { opacity: 1; }-- /* The items to-be-selected */- .incremental > *[aria-selected] ~ * { opacity: 0; }-- /* The progressbar, at the bottom of the slides, show the global- progress of the presentation. */- #progress-bar {- height: 2px;- background: #AAA;- }-</style>--<!-- {{{{ dzslides core-#-#-# __ __ __ . __ ___ __-# | \ / /__` | | | \ |__ /__`-# |__/ /_ .__/ |___ | |__/ |___ .__/ core :€-#-#-# The following block of code is not supposed to be edited.-# But if you want to change the behavior of these slides,-# feel free to hack it!-#--->--<div id="progress-bar"></div>--<!-- Default Style -->-<style>- * { margin: 0; padding: 0; -moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box; }- details { display: none; }- body {- width: 800px; height: 600px;- margin-left: -400px; margin-top: -300px;- position: absolute; top: 50%; left: 50%;- overflow: hidden;- }- section {- position: absolute;- pointer-events: none;- width: 100%; height: 100%;- }- section[aria-selected] { pointer-events: auto; }- html { overflow: hidden; }- body { display: none; }- body.loaded { display: block; }- .incremental {visibility: hidden; }- .incremental[active] {visibility: visible; }- #progress-bar{- bottom: 0;- position: absolute;- -moz-transition: width 400ms linear 0s;- -webkit-transition: width 400ms linear 0s;- -ms-transition: width 400ms linear 0s;- transition: width 400ms linear 0s;- }- figure {- width: 100%;- height: 100%;- }- figure > * {- position: absolute;- }- figure > img, figure > video {- width: 100%; height: 100%;- }-</style>--<script>- var Dz = {- remoteWindows: [],- idx: -1,- step: 0,- slides: null,- progressBar : null,- params: {- autoplay: "1"- }- };-- Dz.init = function() {- document.body.className = "loaded";- this.slides = $$("body > section");- this.progressBar = $("#progress-bar");- this.setupParams();- this.onhashchange();- this.setupTouchEvents();- this.onresize();- }- - Dz.setupParams = function() {- var p = window.location.search.substr(1).split('&');- p.forEach(function(e, i, a) {- var keyVal = e.split('=');- Dz.params[keyVal[0]] = decodeURIComponent(keyVal[1]);- });- // Specific params handling- if (!+this.params.autoplay)- $$.forEach($$("video"), function(v){ v.controls = true });- }-- Dz.onkeydown = function(aEvent) {- // Don't intercept keyboard shortcuts- if (aEvent.altKey- || aEvent.ctrlKey- || aEvent.metaKey- || aEvent.shiftKey) {- return;- }- if ( aEvent.keyCode == 37 // left arrow- || aEvent.keyCode == 38 // up arrow- || aEvent.keyCode == 33 // page up- ) {- aEvent.preventDefault();- this.back();- }- if ( aEvent.keyCode == 39 // right arrow- || aEvent.keyCode == 40 // down arrow- || aEvent.keyCode == 34 // page down- ) {- aEvent.preventDefault();- this.forward();- }- if (aEvent.keyCode == 35) { // end- aEvent.preventDefault();- this.goEnd();- }- if (aEvent.keyCode == 36) { // home- aEvent.preventDefault();- this.goStart();- }- if (aEvent.keyCode == 32) { // space- aEvent.preventDefault();- this.toggleContent();- }- if (aEvent.keyCode == 70) { // f- aEvent.preventDefault();- this.goFullscreen();- }- }-- /* Touch Events */-- Dz.setupTouchEvents = function() {- var orgX, newX;- var tracking = false;-- var db = document.body;- db.addEventListener("touchstart", start.bind(this), false);- db.addEventListener("touchmove", move.bind(this), false);-- function start(aEvent) {- aEvent.preventDefault();- tracking = true;- orgX = aEvent.changedTouches[0].pageX;- }-- function move(aEvent) {- if (!tracking) return;- newX = aEvent.changedTouches[0].pageX;- if (orgX - newX > 100) {- tracking = false;- this.forward();- } else {- if (orgX - newX < -100) {- tracking = false;- this.back();- }- }- }- }-- /* Adapt the size of the slides to the window */-- Dz.onresize = function() {- var db = document.body;- var sx = db.clientWidth / window.innerWidth;- var sy = db.clientHeight / window.innerHeight;- var transform = "scale(" + (1/Math.max(sx, sy)) + ")";-- db.style.MozTransform = transform;- db.style.WebkitTransform = transform;- db.style.OTransform = transform;- db.style.msTransform = transform;- db.style.transform = transform;- }--- Dz.getDetails = function(aIdx) {- var s = $("section:nth-of-type(" + aIdx + ")");- var d = s.$("details");- return d ? d.innerHTML : "";- }-- Dz.onmessage = function(aEvent) {- var argv = aEvent.data.split(" "), argc = argv.length;- argv.forEach(function(e, i, a) { a[i] = decodeURIComponent(e) });- var win = aEvent.source;- if (argv[0] === "REGISTER" && argc === 1) {- this.remoteWindows.push(win);- this.postMsg(win, "REGISTERED", document.title, this.slides.length);- this.postMsg(win, "CURSOR", this.idx + "." + this.step);- return;- }- if (argv[0] === "BACK" && argc === 1)- this.back();- if (argv[0] === "FORWARD" && argc === 1)- this.forward();- if (argv[0] === "START" && argc === 1)- this.goStart();- if (argv[0] === "END" && argc === 1)- this.goEnd();- if (argv[0] === "TOGGLE_CONTENT" && argc === 1)- this.toggleContent();- if (argv[0] === "SET_CURSOR" && argc === 2)- window.location.hash = "#" + argv[1];- if (argv[0] === "GET_CURSOR" && argc === 1)- this.postMsg(win, "CURSOR", this.idx + "." + this.step);- if (argv[0] === "GET_NOTES" && argc === 1)- this.postMsg(win, "NOTES", this.getDetails(this.idx));- }-- Dz.toggleContent = function() {- // If a Video is present in this new slide, play it.- // If a Video is present in the previous slide, stop it.- var s = $("section[aria-selected]");- if (s) {- var video = s.$("video");- if (video) {- if (video.ended || video.paused) {- video.play();- } else {- video.pause();- }- }- }- }-- Dz.setCursor = function(aIdx, aStep) {- // If the user change the slide number in the URL bar, jump- // to this slide.- aStep = (aStep != 0 && typeof aStep !== "undefined") ? "." + aStep : ".0";- window.location.hash = "#" + aIdx + aStep;- }-- Dz.onhashchange = function() {- var cursor = window.location.hash.split("#"),- newidx = 1,- newstep = 0;- if (cursor.length == 2) {- newidx = ~~cursor[1].split(".")[0];- newstep = ~~cursor[1].split(".")[1];- if (newstep > Dz.slides[newidx - 1].$$('.incremental > *').length) {- newstep = 0;- newidx++;- }- }- this.setProgress(newidx, newstep);- if (newidx != this.idx) {- this.setSlide(newidx);- }- if (newstep != this.step) {- this.setIncremental(newstep);- }- for (var i = 0; i < this.remoteWindows.length; i++) {- this.postMsg(this.remoteWindows[i], "CURSOR", this.idx + "." + this.step);- }- }-- Dz.back = function() {- if (this.idx == 1 && this.step == 0) {- return;- }- if (this.step == 0) {- this.setCursor(this.idx - 1,- this.slides[this.idx - 2].$$('.incremental > *').length);- } else {- this.setCursor(this.idx, this.step - 1);- }- }-- Dz.forward = function() {- if (this.idx >= this.slides.length &&- this.step >= this.slides[this.idx - 1].$$('.incremental > *').length) {- return;- }- if (this.step >= this.slides[this.idx - 1].$$('.incremental > *').length) {- this.setCursor(this.idx + 1, 0);- } else {- this.setCursor(this.idx, this.step + 1);- }- }-- Dz.goStart = function() {- this.setCursor(1, 0);- }-- Dz.goEnd = function() {- var lastIdx = this.slides.length;- var lastStep = this.slides[lastIdx - 1].$$('.incremental > *').length;- this.setCursor(lastIdx, lastStep);- }-- Dz.setSlide = function(aIdx) {- this.idx = aIdx;- var old = $("section[aria-selected]");- var next = $("section:nth-of-type("+ this.idx +")");- if (old) {- old.removeAttribute("aria-selected");- var video = old.$("video");- if (video) {- video.pause();- }- }- if (next) {- next.setAttribute("aria-selected", "true");- var video = next.$("video");- if (video && !!+this.params.autoplay) {- video.play();- }- } else {- // That should not happen- this.idx = -1;- // console.warn("Slide doesn't exist.");- }- }-- Dz.setIncremental = function(aStep) {- this.step = aStep;- var old = this.slides[this.idx - 1].$('.incremental > *[aria-selected]');- if (old) {- old.removeAttribute('aria-selected');- }- var incrementals = $$('.incremental');- if (this.step <= 0) {- $$.forEach(incrementals, function(aNode) {- aNode.removeAttribute('active');- });- return;- }- var next = this.slides[this.idx - 1].$$('.incremental > *')[this.step - 1];- if (next) {- next.setAttribute('aria-selected', true);- next.parentNode.setAttribute('active', true);- var found = false;- $$.forEach(incrementals, function(aNode) {- if (aNode != next.parentNode)- if (found)- aNode.removeAttribute('active');- else- aNode.setAttribute('active', true);- else- found = true;- });- } else {- setCursor(this.idx, 0);- }- return next;- }-- Dz.goFullscreen = function() {- var html = $('html'),- requestFullscreen = html.requestFullscreen || html.requestFullScreen || html.mozRequestFullScreen || html.webkitRequestFullScreen;- if (requestFullscreen) {- requestFullscreen.apply(html);- }- }- - Dz.setProgress = function(aIdx, aStep) {- var slide = $("section:nth-of-type("+ aIdx +")");- if (!slide)- return;- var steps = slide.$$('.incremental > *').length + 1,- slideSize = 100 / (this.slides.length - 1),- stepSize = slideSize / steps;- this.progressBar.style.width = ((aIdx - 1) * slideSize + aStep * stepSize) + '%';- }- - Dz.postMsg = function(aWin, aMsg) { // [arg0, [arg1...]]- aMsg = [aMsg];- for (var i = 2; i < arguments.length; i++)- aMsg.push(encodeURIComponent(arguments[i]));- aWin.postMessage(aMsg.join(" "), "*");- }- - function init() {- Dz.init();- window.onkeydown = Dz.onkeydown.bind(Dz);- window.onresize = Dz.onresize.bind(Dz);- window.onhashchange = Dz.onhashchange.bind(Dz);- window.onmessage = Dz.onmessage.bind(Dz);- }-- window.onload = init;-</script>---<script> // Helpers- if (!Function.prototype.bind) {- Function.prototype.bind = function (oThis) {-- // closest thing possible to the ECMAScript 5 internal IsCallable- // function - if (typeof this !== "function")- throw new TypeError(- "Function.prototype.bind - what is trying to be fBound is not callable"- );-- var aArgs = Array.prototype.slice.call(arguments, 1),- fToBind = this,- fNOP = function () {},- fBound = function () {- return fToBind.apply( this instanceof fNOP ? this : oThis || window,- aArgs.concat(Array.prototype.slice.call(arguments)));- };-- fNOP.prototype = this.prototype;- fBound.prototype = new fNOP();-- return fBound;- };- }-- var $ = (HTMLElement.prototype.$ = function(aQuery) {- return this.querySelector(aQuery);- }).bind(document);-- var $$ = (HTMLElement.prototype.$$ = function(aQuery) {- return this.querySelectorAll(aQuery);- }).bind(document);-- $$.forEach = function(nodeList, fun) {- Array.prototype.forEach.call(nodeList, fun);- }--</script>-<!-- vim: set fdm=marker: }}} -->
@@ -1,31 +0,0 @@-/* This defines styles and classes used in the book */-body { margin-left: 5%; margin-right: 5%; margin-top: 5%; margin-bottom: 5%; text-align: justify; font-size: medium; }-code { font-family: monospace; }-h1 { text-align: center; }-h2 { text-align: center; }-h3 { text-align: center; }-h4 { text-align: center; }-h5 { text-align: center; }-h6 { text-align: center; }-h1.title { }-h2.author { }-h3.date { }-/* For source-code highlighting */-table.sourceCode, tr.sourceCode, td.lineNumbers, td.sourceCode, table.sourceCode pre- { margin: 0; padding: 0; border: 0; vertical-align: baseline; border: none; }-td.lineNumbers { border-right: 1px solid #AAAAAA; text-align: right; color: #AAAAAA; padding-right: 5px; padding-left: 5px; }-td.sourceCode { padding-left: 5px; }-pre.sourceCode { }-code.sourceCode span.kw { color: #007020; font-weight: bold; }-code.sourceCode span.dt { color: #902000; }-code.sourceCode span.dv { color: #40a070; }-code.sourceCode span.bn { color: #40a070; }-code.sourceCode span.fl { color: #40a070; }-code.sourceCode span.ch { color: #4070a0; }-code.sourceCode span.st { color: #4070a0; }-code.sourceCode span.co { color: #60a0b0; font-style: italic; }-code.sourceCode span.ot { color: #007020; }-code.sourceCode span.al { color: red; font-weight: bold; }-code.sourceCode span.fu { color: #06287e; }-code.sourceCode span.re { }-code.sourceCode span.er { color: red; font-weight: bold; }
@@ -23,7 +23,7 @@ unless (null ds1 && null ds2) $ do rmContents <- UTF8.readFile "README"- let (Pandoc meta blocks) = readMarkdown defaultParserState rmContents+ let (Pandoc meta blocks) = readMarkdown def rmContents let manBlocks = removeSect [Str "Wrappers"] $ removeSect [Str "Pandoc's",Space,Str "markdown"] blocks let syntaxBlocks = extractSect [Str "Pandoc's",Space,Str "markdown"] blocks@@ -43,8 +43,7 @@ writeManPage :: FilePath -> String -> Pandoc -> IO () writeManPage page templ doc = do- let opts = defaultWriterOptions{- writerStandalone = True+ let opts = def{ writerStandalone = True , writerTemplate = templ } let manPage = writeMan opts $ bottomUp (concatMap removeLinks) $@@ -56,7 +55,7 @@ removeLinks x = [x] capitalizeHeaders :: Block -> Block-capitalizeHeaders (Header 1 xs) = Header 1 $ bottomUp capitalize xs+capitalizeHeaders (Header 1 attr xs) = Header 1 attr $ bottomUp capitalize xs capitalizeHeaders x = x capitalize :: Inline -> Inline@@ -64,22 +63,22 @@ capitalize x = x removeSect :: [Inline] -> [Block] -> [Block]-removeSect ils (Header 1 x:xs) | normalize x == normalize ils =+removeSect ils (Header 1 _ x:xs) | normalize x == normalize ils = dropWhile (not . isHeader1) xs removeSect ils (x:xs) = x : removeSect ils xs removeSect _ [] = [] extractSect :: [Inline] -> [Block] -> [Block]-extractSect ils (Header 1 z:xs) | normalize z == normalize ils =+extractSect ils (Header 1 _ z:xs) | normalize z == normalize ils = bottomUp promoteHeader $ takeWhile (not . isHeader1) xs- where promoteHeader (Header n x) = Header (n-1) x+ where promoteHeader (Header n attr x) = Header (n-1) attr x promoteHeader x = x extractSect ils (x:xs) = extractSect ils xs extractSect _ [] = [] isHeader1 :: Block -> Bool-isHeader1 (Header 1 _) = True-isHeader1 _ = False+isHeader1 (Header 1 _ _ ) = True+isHeader1 _ = False -- | Returns a list of 'dependencies' that have been modified after 'file'.
@@ -1,29 +1,29 @@-.TH PANDOC 1 "January 27, 2012" "Pandoc"+.TH PANDOC 1 "January 19, 2013" "Pandoc" .SH NAME pandoc - general markup converter .SH SYNOPSIS .PP-pandoc [\f[I]options\f[]] [\f[I]input-file\f[]]...+pandoc [\f[I]options\f[]][*input\-file*]... .SH DESCRIPTION .PP Pandoc is a Haskell library for converting from one markup format to-another, and a command-line tool that uses this library.+another, and a command\-line tool that uses this library. It can read markdown and (subsets of) Textile, reStructuredText, HTML,-LaTeX, and DocBook XML; and it can write plain text, markdown,-reStructuredText, XHTML, HTML 5, LaTeX (including beamer slide shows),-ConTeXt, RTF, DocBook XML, OpenDocument XML, ODT, Word docx, GNU-Texinfo, MediaWiki markup, EPUB, Textile, groff man pages, Emacs-Org-Mode, AsciiDoc, and Slidy, Slideous, DZSlides, or S5 HTML slide-shows.+LaTeX, MediaWiki markup, and DocBook XML; and it can write plain text,+markdown, reStructuredText, XHTML, HTML 5, LaTeX (including beamer slide+shows), ConTeXt, RTF, DocBook XML, OpenDocument XML, ODT, Word docx, GNU+Texinfo, MediaWiki markup, EPUB (v2 or v3), FictionBook2, Textile, groff+man pages, Emacs Org\-Mode, AsciiDoc, and Slidy, Slideous, DZSlides, or+S5 HTML slide shows. It can also produce PDF output on systems where LaTeX is installed. .PP Pandoc\[aq]s enhanced version of markdown includes syntax for footnotes,-tables, flexible ordered lists, definition lists, delimited code blocks,+tables, flexible ordered lists, definition lists, fenced code blocks, superscript, subscript, strikeout, title blocks, automatic tables of contents, embedded LaTeX math, citations, and markdown inside HTML block elements. (These enhancements, described below under Pandoc\[aq]s markdown, can be-disabled using the \f[C]--strict\f[] option.)+disabled using the \f[C]markdown_strict\f[] input or output format.) .PP In contrast to most existing tools for converting markdown to HTML, which use regex substitutions, Pandoc has a modular design: it consists@@ -34,18 +34,18 @@ writer. .SS Using \f[C]pandoc\f[] .PP-If no \f[I]input-file\f[] is specified, input is read from+If no \f[I]input\-file\f[] is specified, input is read from \f[I]stdin\f[].-Otherwise, the \f[I]input-files\f[] are concatenated (with a blank line+Otherwise, the \f[I]input\-files\f[] are concatenated (with a blank line between each) and used as input. Output goes to \f[I]stdout\f[] by default (though output to-\f[I]stdout\f[] is disabled for the \f[C]odt\f[], \f[C]docx\f[], and-\f[C]epub\f[] output formats).-For output to a file, use the \f[C]-o\f[] option:+\f[I]stdout\f[] is disabled for the \f[C]odt\f[], \f[C]docx\f[],+\f[C]epub\f[], and \f[C]epub3\f[] output formats).+For output to a file, use the \f[C]\-o\f[] option: .IP .nf \f[C]-pandoc\ -o\ output.html\ input.txt+pandoc\ \-o\ output.html\ input.txt \f[] .fi .PP@@ -54,7 +54,7 @@ .IP .nf \f[C]-pandoc\ -f\ html\ -t\ markdown\ http://www.fsf.org+pandoc\ \-f\ html\ \-t\ markdown\ http://www.fsf.org \f[] .fi .PP@@ -62,16 +62,16 @@ all (with blank lines between them) before parsing. .PP The format of the input and output can be specified explicitly using-command-line options.-The input format can be specified using the \f[C]-r/--read\f[] or-\f[C]-f/--from\f[] options, the output format using the-\f[C]-w/--write\f[] or \f[C]-t/--to\f[] options.+command\-line options.+The input format can be specified using the \f[C]\-r/\-\-read\f[] or+\f[C]\-f/\-\-from\f[] options, the output format using the+\f[C]\-w/\-\-write\f[] or \f[C]\-t/\-\-to\f[] options. Thus, to convert \f[C]hello.txt\f[] from markdown to LaTeX, you could type: .IP .nf \f[C]-pandoc\ -f\ markdown\ -t\ latex\ hello.txt+pandoc\ \-f\ markdown\ \-t\ latex\ hello.txt \f[] .fi .PP@@ -79,13 +79,13 @@ .IP .nf \f[C]-pandoc\ -f\ html\ -t\ markdown\ hello.html+pandoc\ \-f\ html\ \-t\ markdown\ hello.html \f[] .fi .PP-Supported output formats are listed below under the \f[C]-t/--to\f[]+Supported output formats are listed below under the \f[C]\-t/\-\-to\f[] option.-Supported input formats are listed below under the \f[C]-f/--from\f[]+Supported input formats are listed below under the \f[C]\-f/\-\-from\f[] option. Note that the \f[C]rst\f[], \f[C]textile\f[], \f[C]latex\f[], and \f[C]html\f[] readers are not complete; there are some constructs that@@ -98,7 +98,7 @@ .IP .nf \f[C]-pandoc\ -o\ hello.tex\ hello.txt+pandoc\ \-o\ hello.tex\ hello.txt \f[] .fi .PP@@ -110,13 +110,13 @@ or if the input files\[aq] extensions are unknown, the input format will be assumed to be markdown unless explicitly specified. .PP-Pandoc uses the UTF-8 character encoding for both input and output.-If your local character encoding is not UTF-8, you should pipe input and-output through \f[C]iconv\f[]:+Pandoc uses the UTF\-8 character encoding for both input and output.+If your local character encoding is not UTF\-8, you should pipe input+and output through \f[C]iconv\f[]: .IP .nf \f[C]-iconv\ -t\ utf-8\ input.txt\ |\ pandoc\ |\ iconv\ -f\ utf-8+iconv\ \-t\ utf\-8\ input.txt\ |\ pandoc\ |\ iconv\ \-f\ utf\-8 \f[] .fi .SS Creating a PDF@@ -128,87 +128,107 @@ To produce a PDF, simply specify an output file with a \f[C]\&.pdf\f[] extension. Pandoc will create a latex file and use pdflatex (or another engine, see-\f[C]--latex-engine\f[]) to convert it to PDF:+\f[C]\-\-latex\-engine\f[]) to convert it to PDF: .IP .nf \f[C]-pandoc\ test.txt\ -o\ test.pdf+pandoc\ test.txt\ \-o\ test.pdf \f[] .fi .PP Production of a PDF requires that a LaTeX engine be installed (see-\f[C]--latex-engine\f[], below), and assumes that the following LaTeX+\f[C]\-\-latex\-engine\f[], below), and assumes that the following LaTeX packages are available: \f[C]amssymb\f[], \f[C]amsmath\f[], \f[C]ifxetex\f[], \f[C]ifluatex\f[], \f[C]listings\f[] (if the-\f[C]--listings\f[] option is used), \f[C]fancyvrb\f[],-\f[C]enumerate\f[], \f[C]ctable\f[], \f[C]url\f[], \f[C]graphicx\f[],-\f[C]hyperref\f[], \f[C]ulem\f[], \f[C]babel\f[] (if the \f[C]lang\f[]-variable is set), \f[C]fontspec\f[] (if \f[C]xelatex\f[] or-\f[C]lualatex\f[] is used as the LaTeX engine), \f[C]xltxtra\f[] and-\f[C]xunicode\f[] (if \f[C]xelatex\f[] is used).+\f[C]\-\-listings\f[] option is used), \f[C]fancyvrb\f[],+\f[C]longtable\f[], \f[C]url\f[], \f[C]graphicx\f[], \f[C]hyperref\f[],+\f[C]ulem\f[], \f[C]babel\f[] (if the \f[C]lang\f[] variable is set),+\f[C]fontspec\f[] (if \f[C]xelatex\f[] or \f[C]lualatex\f[] is used as+the LaTeX engine), \f[C]xltxtra\f[] and \f[C]xunicode\f[] (if+\f[C]xelatex\f[] is used). .SS \f[C]hsmarkdown\f[] .PP-A user who wants a drop-in replacement for \f[C]Markdown.pl\f[] may+A user who wants a drop\-in replacement for \f[C]Markdown.pl\f[] may create a symbolic link to the \f[C]pandoc\f[] executable called \f[C]hsmarkdown\f[]. When invoked under the name \f[C]hsmarkdown\f[], \f[C]pandoc\f[] will-behave as if the \f[C]--strict\f[] flag had been selected, and no-command-line options will be recognized.+behave as if invoked with+\f[C]\-f\ markdown_strict\ \-\-email\-obfuscation=references\f[], and+all command\-line options will be treated as regular arguments. However, this approach does not work under Cygwin, due to problems with its simulation of symbolic links. .SH OPTIONS .SS General options .TP-.B \f[C]-f\f[] \f[I]FORMAT\f[], \f[C]-r\f[] \f[I]FORMAT\f[],-\f[C]--from=\f[]\f[I]FORMAT\f[], \f[C]--read=\f[]\f[I]FORMAT\f[]+.B \f[C]\-f\f[] \f[I]FORMAT\f[], \f[C]\-r\f[] \f[I]FORMAT\f[],+\f[C]\-\-from=\f[]\f[I]FORMAT\f[], \f[C]\-\-read=\f[]\f[I]FORMAT\f[] Specify input format. \f[I]FORMAT\f[] can be \f[C]native\f[] (native Haskell), \f[C]json\f[]-(JSON version of native AST), \f[C]markdown\f[] (markdown),-\f[C]textile\f[] (Textile), \f[C]rst\f[] (reStructuredText),-\f[C]html\f[] (HTML), \f[C]docbook\f[] (DocBook XML), or \f[C]latex\f[]-(LaTeX).+(JSON version of native AST), \f[C]markdown\f[] (pandoc\[aq]s extended+markdown), \f[C]markdown_strict\f[] (original unextended markdown),+\f[C]markdown_phpextra\f[] (PHP Markdown Extra extended markdown),+\f[C]markdown_github\f[] (github extended markdown), \f[C]textile\f[]+(Textile), \f[C]rst\f[] (reStructuredText), \f[C]html\f[] (HTML),+\f[C]docbook\f[] (DocBook XML), \f[C]mediawiki\f[] (MediaWiki markup),+or \f[C]latex\f[] (LaTeX). If \f[C]+lhs\f[] is appended to \f[C]markdown\f[], \f[C]rst\f[], \f[C]latex\f[], the input will be treated as literate Haskell source: see Literate Haskell support, below.+Markdown syntax extensions can be individually enabled or disabled by+appending \f[C]+EXTENSION\f[] or \f[C]\-EXTENSION\f[] to the format+name.+So, for example, \f[C]markdown_strict+footnotes+definition_lists\f[] is+strict markdown with footnotes and definition lists enabled, and+\f[C]markdown\-pipe_tables+hard_line_breaks\f[] is pandoc\[aq]s markdown+without pipe tables and with hard line breaks.+See Pandoc\[aq]s markdown, below, for a list of extensions and their+names. .RS .RE .TP-.B \f[C]-t\f[] \f[I]FORMAT\f[], \f[C]-w\f[] \f[I]FORMAT\f[],-\f[C]--to=\f[]\f[I]FORMAT\f[], \f[C]--write=\f[]\f[I]FORMAT\f[]+.B \f[C]\-t\f[] \f[I]FORMAT\f[], \f[C]\-w\f[] \f[I]FORMAT\f[],+\f[C]\-\-to=\f[]\f[I]FORMAT\f[], \f[C]\-\-write=\f[]\f[I]FORMAT\f[] Specify output format. \f[I]FORMAT\f[] can be \f[C]native\f[] (native Haskell), \f[C]json\f[] (JSON version of native AST), \f[C]plain\f[] (plain text),-\f[C]markdown\f[] (markdown), \f[C]rst\f[] (reStructuredText),-\f[C]html\f[] (XHTML 1), \f[C]html5\f[] (HTML 5), \f[C]latex\f[]-(LaTeX), \f[C]beamer\f[] (LaTeX beamer slide show), \f[C]context\f[]-(ConTeXt), \f[C]man\f[] (groff man), \f[C]mediawiki\f[] (MediaWiki-markup), \f[C]textile\f[] (Textile), \f[C]org\f[] (Emacs Org-Mode),-\f[C]texinfo\f[] (GNU Texinfo), \f[C]docbook\f[] (DocBook XML),-\f[C]opendocument\f[] (OpenDocument XML), \f[C]odt\f[] (OpenOffice text-document), \f[C]docx\f[] (Word docx), \f[C]epub\f[] (EPUB book),+\f[C]markdown\f[] (pandoc\[aq]s extended markdown),+\f[C]markdown_strict\f[] (original unextended markdown),+\f[C]markdown_phpextra\f[] (PHP Markdown extra extended markdown),+\f[C]markdown_github\f[] (github extended markdown), \f[C]rst\f[]+(reStructuredText), \f[C]html\f[] (XHTML 1), \f[C]html5\f[] (HTML 5),+\f[C]latex\f[] (LaTeX), \f[C]beamer\f[] (LaTeX beamer slide show),+\f[C]context\f[] (ConTeXt), \f[C]man\f[] (groff man), \f[C]mediawiki\f[]+(MediaWiki markup), \f[C]textile\f[] (Textile), \f[C]org\f[] (Emacs+Org\-Mode), \f[C]texinfo\f[] (GNU Texinfo), \f[C]docbook\f[] (DocBook+XML), \f[C]opendocument\f[] (OpenDocument XML), \f[C]odt\f[] (OpenOffice+text document), \f[C]docx\f[] (Word docx), \f[C]epub\f[] (EPUB book),+\f[C]epub3\f[] (EPUB v3), \f[C]fb2\f[] (FictionBook2 e\-book), \f[C]asciidoc\f[] (AsciiDoc), \f[C]slidy\f[] (Slidy HTML and javascript slide show), \f[C]slideous\f[] (Slideous HTML and javascript slide show), \f[C]dzslides\f[] (HTML5 + javascript slide show), \f[C]s5\f[] (S5 HTML and javascript slide show), or \f[C]rtf\f[] (rich text format).-Note that \f[C]odt\f[] and \f[C]epub\f[] output will not be directed to-\f[I]stdout\f[]; an output filename must be specified using the-\f[C]-o/--output\f[] option.+Note that \f[C]odt\f[], \f[C]epub\f[], and \f[C]epub3\f[] output will+not be directed to \f[I]stdout\f[]; an output filename must be specified+using the \f[C]\-o/\-\-output\f[] option. If \f[C]+lhs\f[] is appended to \f[C]markdown\f[], \f[C]rst\f[], \f[C]latex\f[], \f[C]beamer\f[], \f[C]html\f[], or \f[C]html5\f[], 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 \f[C]+EXTENSION\f[] or \f[C]\-EXTENSION\f[] to the format+name, as described above under \f[C]\-f\f[]. .RS .RE .TP-.B \f[C]-o\f[] \f[I]FILE\f[], \f[C]--output=\f[]\f[I]FILE\f[]+.B \f[C]\-o\f[] \f[I]FILE\f[], \f[C]\-\-output=\f[]\f[I]FILE\f[] Write output to \f[I]FILE\f[] instead of \f[I]stdout\f[].-If \f[I]FILE\f[] is \f[C]-\f[], output will go to \f[I]stdout\f[].-(Exception: if the output format is \f[C]odt\f[], \f[C]docx\f[], or-\f[C]epub\f[], output to stdout is disabled.)+If \f[I]FILE\f[] is \f[C]\-\f[], output will go to \f[I]stdout\f[].+(Exception: if the output format is \f[C]odt\f[], \f[C]docx\f[],+\f[C]epub\f[], or \f[C]epub3\f[], output to stdout is disabled.) .RS .RE .TP-.B \f[C]--data-dir=\f[]\f[I]DIRECTORY\f[]+.B \f[C]\-\-data\-dir=\f[]\f[I]DIRECTORY\f[] Specify the user data directory to search for pandoc data files. If this option is not specified, the default user data directory will be used:@@ -235,26 +255,18 @@ will override pandoc\[aq]s normal defaults. .RE .TP-.B \f[C]-v\f[], \f[C]--version\f[]+.B \f[C]\-v\f[], \f[C]\-\-version\f[] Print version. .RS .RE .TP-.B \f[C]-h\f[], \f[C]--help\f[]+.B \f[C]\-h\f[], \f[C]\-\-help\f[] Show usage message. .RS .RE .SS Reader options .TP-.B \f[C]--strict\f[]-Use strict markdown syntax, with no pandoc extensions or variants.-When the input format is HTML, this means that constructs that have no-equivalents in standard markdown (e.g.-definition lists or strikeout text) will be parsed as raw HTML.-.RS-.RE-.TP-.B \f[C]-R\f[], \f[C]--parse-raw\f[]+.B \f[C]\-R\f[], \f[C]\-\-parse\-raw\f[] Parse untranslatable HTML codes and LaTeX environments as raw HTML or LaTeX, instead of ignoring them. Affects only HTML and LaTeX input.@@ -264,88 +276,91 @@ The default is for the readers to omit untranslatable HTML codes and LaTeX environments. (The LaTeX reader does pass through untranslatable LaTeX-\f[I]commands\f[], even if \f[C]-R\f[] is not specified.)+\f[I]commands\f[], even if \f[C]\-R\f[] is not specified.) .RS .RE .TP-.B \f[C]-S\f[], \f[C]--smart\f[]+.B \f[C]\-S\f[], \f[C]\-\-smart\f[] Produce typographically correct output, converting straight quotes to-curly quotes, \f[C]---\f[] to em-dashes, \f[C]--\f[] to en-dashes, and-\f[C]\&...\f[] to ellipses.+curly quotes, \f[C]\-\-\-\f[] to em\-dashes, \f[C]\-\-\f[] to+en\-dashes, and \f[C]\&...\f[] to ellipses. Nonbreaking spaces are inserted after certain abbreviations, such as "Mr." (Note: This option is significant only when the input format is-\f[C]markdown\f[] or \f[C]textile\f[].+\f[C]markdown\f[], \f[C]markdown_strict\f[], or \f[C]textile\f[]. It is selected automatically when the input format is \f[C]textile\f[] or the output format is \f[C]latex\f[] or \f[C]context\f[], unless-\f[C]--no-tex-ligatures\f[] is used.)+\f[C]\-\-no\-tex\-ligatures\f[] is used.) .RS .RE .TP-.B \f[C]--old-dashes\f[]+.B \f[C]\-\-old\-dashes\f[] Selects the pandoc <= 1.8.2.1 behavior for parsing smart dashes:-\f[C]-\f[] before a numeral is an en-dash, and \f[C]--\f[] is an-em-dash.+\f[C]\-\f[] before a numeral is an en\-dash, and \f[C]\-\-\f[] is an+em\-dash. This option is selected automatically for \f[C]textile\f[] input. .RS .RE .TP-.B \f[C]--base-header-level=\f[]\f[I]NUMBER\f[]+.B \f[C]\-\-base\-header\-level=\f[]\f[I]NUMBER\f[] Specify the base level for headers (defaults to 1). .RS .RE .TP-.B \f[C]--indented-code-classes=\f[]\f[I]CLASSES\f[]-Specify classes to use for indented code blocks--for example,+.B \f[C]\-\-indented\-code\-classes=\f[]\f[I]CLASSES\f[]+Specify classes to use for indented code blocks\-\-for example, \f[C]perl,numberLines\f[] or \f[C]haskell\f[]. Multiple classes may be separated by spaces or commas. .RS .RE .TP-.B \f[C]--normalize\f[]+.B \f[C]\-\-normalize\f[] Normalize the document after reading: merge adjacent \f[C]Str\f[] or \f[C]Emph\f[] elements, for example, and remove repeated \f[C]Space\f[]s. .RS .RE .TP-.B \f[C]-p\f[], \f[C]--preserve-tabs\f[]+.B \f[C]\-p\f[], \f[C]\-\-preserve\-tabs\f[] Preserve tabs instead of converting them to spaces (the default).+Note that this will only affect tabs in literal code spans and code+blocks; tabs in regular text will be treated as spaces. .RS .RE .TP-.B \f[C]--tab-stop=\f[]\f[I]NUMBER\f[]+.B \f[C]\-\-tab\-stop=\f[]\f[I]NUMBER\f[] Specify the number of spaces per tab (default is 4). .RS .RE .SS General writer options .TP-.B \f[C]-s\f[], \f[C]--standalone\f[]+.B \f[C]\-s\f[], \f[C]\-\-standalone\f[] Produce output with an appropriate header and footer (e.g. a standalone HTML, LaTeX, or RTF file, not a fragment). This option is set automatically for \f[C]pdf\f[], \f[C]epub\f[],-\f[C]docx\f[], and \f[C]odt\f[] output.+\f[C]epub3\f[], \f[C]fb2\f[], \f[C]docx\f[], and \f[C]odt\f[] output. .RS .RE .TP-.B \f[C]--template=\f[]\f[I]FILE\f[]+.B \f[C]\-\-template=\f[]\f[I]FILE\f[] Use \f[I]FILE\f[] as a custom template for the generated document.-Implies \f[C]--standalone\f[].+Implies \f[C]\-\-standalone\f[]. See Templates below for a description of template syntax. If no extension is specified, an extension corresponding to the writer-will be added, so that \f[C]--template=special\f[] looks for+will be added, so that \f[C]\-\-template=special\f[] looks for \f[C]special.html\f[] for HTML output. If the template is not found, pandoc will search for it in the user data-directory (see \f[C]--data-dir\f[]).+directory (see \f[C]\-\-data\-dir\f[]). If this option is not used, a default template appropriate for the-output format will be used (see \f[C]-D/--print-default-template\f[]).+output format will be used (see+\f[C]\-D/\-\-print\-default\-template\f[]). .RS .RE .TP-.B \f[C]-V\f[] \f[I]KEY[=VAL]\f[],-\f[C]--variable=\f[]\f[I]KEY[:VAL]\f[]+.B \f[C]\-V\f[] \f[I]KEY[=VAL]\f[],+\f[C]\-\-variable=\f[]\f[I]KEY[:VAL]\f[] Set the template variable \f[I]KEY\f[] to the value \f[I]VAL\f[] when rendering the document in standalone mode.-This is generally only useful when the \f[C]--template\f[] option is+This is generally only useful when the \f[C]\-\-template\f[] option is used to specify a custom template, since pandoc automatically sets the variables used in the default templates. If no \f[I]VAL\f[] is specified, the key will be given the value@@ -353,25 +368,25 @@ .RS .RE .TP-.B \f[C]-D\f[] \f[I]FORMAT\f[],-\f[C]--print-default-template=\f[]\f[I]FORMAT\f[]+.B \f[C]\-D\f[] \f[I]FORMAT\f[],+\f[C]\-\-print\-default\-template=\f[]\f[I]FORMAT\f[] Print the default template for an output \f[I]FORMAT\f[].-(See \f[C]-t\f[] for a list of possible \f[I]FORMAT\f[]s.)+(See \f[C]\-t\f[] for a list of possible \f[I]FORMAT\f[]s.) .RS .RE .TP-.B \f[C]--no-wrap\f[]+.B \f[C]\-\-no\-wrap\f[] Disable text wrapping in output. By default, text is wrapped appropriately for the output format. .RS .RE .TP-.B \f[C]--columns\f[]=\f[I]NUMBER\f[]+.B \f[C]\-\-columns\f[]=\f[I]NUMBER\f[] Specify length of lines in characters (for text wrapping). .RS .RE .TP-.B \f[C]--toc\f[], \f[C]--table-of-contents\f[]+.B \f[C]\-\-toc\f[], \f[C]\-\-table\-of\-contents\f[] Include an automatically generated table of contents (or, in the case of \f[C]latex\f[], \f[C]context\f[], and \f[C]rst\f[], an instruction to create one) in the output document.@@ -380,13 +395,22 @@ .RS .RE .TP-.B \f[C]--no-highlight\f[]+.B \f[C]\-\-toc\-depth=\f[]\f[I]NUMBER\f[]+Specify the number of section levels to include in the table of+contents.+The default is 3 (which means that level 1, 2, and 3 headers will be+listed in the contents).+Implies \f[C]\-\-toc\f[].+.RS+.RE+.TP+.B \f[C]\-\-no\-highlight\f[] Disables syntax highlighting for code blocks and inlines, even when a language attribute is given. .RS .RE .TP-.B \f[C]--highlight-style\f[]=\f[I]STYLE\f[]+.B \f[C]\-\-highlight\-style\f[]=\f[I]STYLE\f[] Specifies the coloring style to be used in highlighted source code. Options are \f[C]pygments\f[] (the default), \f[C]kate\f[], \f[C]monochrome\f[], \f[C]espresso\f[], \f[C]zenburn\f[],@@ -394,19 +418,20 @@ .RS .RE .TP-.B \f[C]-H\f[] \f[I]FILE\f[], \f[C]--include-in-header=\f[]\f[I]FILE\f[]+.B \f[C]\-H\f[] \f[I]FILE\f[],+\f[C]\-\-include\-in\-header=\f[]\f[I]FILE\f[] Include contents of \f[I]FILE\f[], verbatim, at the end of the header. This can be used, for example, to include special CSS or javascript in HTML documents. This option can be used repeatedly to include multiple files in the header. They will be included in the order specified.-Implies \f[C]--standalone\f[].+Implies \f[C]\-\-standalone\f[]. .RS .RE .TP-.B \f[C]-B\f[] \f[I]FILE\f[],-\f[C]--include-before-body=\f[]\f[I]FILE\f[]+.B \f[C]\-B\f[] \f[I]FILE\f[],+\f[C]\-\-include\-before\-body=\f[]\f[I]FILE\f[] Include contents of \f[I]FILE\f[], verbatim, at the beginning of the document body (e.g. after the \f[C]<body>\f[] tag in HTML, or the \f[C]\\begin{document}\f[]@@ -415,27 +440,27 @@ documents. This option can be used repeatedly to include multiple files. They will be included in the order specified.-Implies \f[C]--standalone\f[].+Implies \f[C]\-\-standalone\f[]. .RS .RE .TP-.B \f[C]-A\f[] \f[I]FILE\f[],-\f[C]--include-after-body=\f[]\f[I]FILE\f[]+.B \f[C]\-A\f[] \f[I]FILE\f[],+\f[C]\-\-include\-after\-body=\f[]\f[I]FILE\f[] Include contents of \f[I]FILE\f[], verbatim, at the end of the document body (before the \f[C]</body>\f[] tag in HTML, or the \f[C]\\end{document}\f[] command in LaTeX). This option can be be used repeatedly to include multiple files. They will be included in the order specified.-Implies \f[C]--standalone\f[].+Implies \f[C]\-\-standalone\f[]. .RS .RE .SS Options affecting specific writers .TP-.B \f[C]--self-contained\f[]+.B \f[C]\-\-self\-contained\f[] Produce a standalone HTML file with no external dependencies, using \f[C]data:\f[] URIs to incorporate the contents of linked scripts, stylesheets, images, and videos.-The resulting file should be "self-contained," in the sense that it+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@@ -444,87 +469,92 @@ Scripts, images, and stylesheets at absolute URLs will be downloaded; those at relative URLs will be sought first relative to the working directory, then relative to the user data directory (see-\f[C]--data-dir\f[]), and finally relative to pandoc\[aq]s default data-directory.+\f[C]\-\-data\-dir\f[]), and finally relative to pandoc\[aq]s default+data directory. .RS .RE .TP-.B \f[C]--offline\f[]-Deprecated synonym for \f[C]--self-contained\f[].+.B \f[C]\-\-offline\f[]+Deprecated synonym for \f[C]\-\-self\-contained\f[]. .RS .RE .TP-.B \f[C]-5\f[], \f[C]--html5\f[]+.B \f[C]\-5\f[], \f[C]\-\-html5\f[] Produce HTML5 instead of HTML4. This option has no effect for writers other than \f[C]html\f[]. (\f[I]Deprecated:\f[] Use the \f[C]html5\f[] output format instead.) .RS .RE .TP-.B \f[C]--ascii\f[]+.B \f[C]\-\-html\-q\-tags\f[]+Use \f[C]<q>\f[] tags for quotes in HTML.+.RS+.RE+.TP+.B \f[C]\-\-ascii\f[] Use only ascii characters in output. Currently supported only for HTML output (which uses numerical entities-instead of UTF-8 when this option is selected).+instead of UTF\-8 when this option is selected). .RS .RE .TP-.B \f[C]--reference-links\f[]-Use reference-style links, rather than inline links, in writing markdown-or reStructuredText.+.B \f[C]\-\-reference\-links\f[]+Use reference\-style links, rather than inline links, in writing+markdown or reStructuredText. By default inline links are used. .RS .RE .TP-.B \f[C]--atx-headers\f[]+.B \f[C]\-\-atx\-headers\f[] Use ATX style headers in markdown output.-The default is to use setext-style headers for levels 1-2, and then ATX-headers.+The default is to use setext\-style headers for levels 1\-2, and then+ATX headers. .RS .RE .TP-.B \f[C]--chapters\f[]-Treat top-level headers as chapters in LaTeX, ConTeXt, and DocBook+.B \f[C]\-\-chapters\f[]+Treat top\-level headers as chapters in LaTeX, ConTeXt, and DocBook output. When the LaTeX template uses the report, book, or memoir class, this option is implied.-If \f[C]--beamer\f[] is used, top-level headers will become+If \f[C]\-\-beamer\f[] is used, top\-level headers will become \f[C]\\part{..}\f[]. .RS .RE .TP-.B \f[C]-N\f[], \f[C]--number-sections\f[]+.B \f[C]\-N\f[], \f[C]\-\-number\-sections\f[] Number section headings in LaTeX, ConTeXt, or HTML output. By default, sections are not numbered. .RS .RE .TP-.B \f[C]--no-tex-ligatures\f[]+.B \f[C]\-\-no\-tex\-ligatures\f[] Do not convert quotation marks, apostrophes, and dashes to the TeX ligatures when writing LaTeX or ConTeXt. Instead, just use literal unicode characters. This is needed for using advanced OpenType features with XeLaTeX and LuaLaTeX.-Note: normally \f[C]--smart\f[] is selected automatically for LaTeX and-ConTeXt output, but it must be specified explicitly if-\f[C]--no-tex-ligatures\f[] is selected.+Note: normally \f[C]\-\-smart\f[] is selected automatically for LaTeX+and ConTeXt output, but it must be specified explicitly if+\f[C]\-\-no\-tex\-ligatures\f[] is selected. If you use literal curly quotes, dashes, and ellipses in your source,-then you may want to use \f[C]--no-tex-ligatures\f[] without-\f[C]--smart\f[].+then you may want to use \f[C]\-\-no\-tex\-ligatures\f[] without+\f[C]\-\-smart\f[]. .RS .RE .TP-.B \f[C]--listings\f[]+.B \f[C]\-\-listings\f[] Use listings package for LaTeX code blocks .RS .RE .TP-.B \f[C]-i\f[], \f[C]--incremental\f[]+.B \f[C]\-i\f[], \f[C]\-\-incremental\f[] Make list items in slide shows display incrementally (one by one). The default is for lists to be displayed all at once. .RS .RE .TP-.B \f[C]--slide-level\f[]=\f[I]NUMBER\f[]+.B \f[C]\-\-slide\-level\f[]=\f[I]NUMBER\f[] Specifies that headers with the specified level create slides (for \f[C]beamer\f[], \f[C]s5\f[], \f[C]slidy\f[], \f[C]slideous\f[], \f[C]dzslides\f[]).@@ -536,7 +566,7 @@ .RS .RE .TP-.B \f[C]--section-divs\f[]+.B \f[C]\-\-section\-divs\f[] Wrap sections in \f[C]<div>\f[] tags (or \f[C]<section>\f[] tags in HTML5), and attach identifiers to the enclosing \f[C]<div>\f[] (or \f[C]<section>\f[]) rather than the header itself.@@ -544,40 +574,41 @@ .RS .RE .TP-.B \f[C]--email-obfuscation=\f[]\f[I]none|javascript|references\f[]+.B \f[C]\-\-email\-obfuscation=\f[]\f[I]none|javascript|references\f[] Specify a method for obfuscating \f[C]mailto:\f[] links in HTML documents. \f[I]none\f[] leaves \f[C]mailto:\f[] links as they are. \f[I]javascript\f[] obfuscates them using javascript. \f[I]references\f[] obfuscates them by printing their letters as decimal or hexadecimal character references.-If \f[C]--strict\f[] is specified, \f[I]references\f[] is used-regardless of the presence of this option. .RS .RE .TP-.B \f[C]--id-prefix\f[]=\f[I]STRING\f[]+.B \f[C]\-\-id\-prefix\f[]=\f[I]STRING\f[] Specify a prefix to be added to all automatically generated identifiers-in HTML output.+in HTML and DocBook output, and to footnote numbers in markdown output. This is useful for preventing duplicate identifiers when generating fragments to be included in other pages. .RS .RE .TP-.B \f[C]-T\f[] \f[I]STRING\f[], \f[C]--title-prefix=\f[]\f[I]STRING\f[]+.B \f[C]\-T\f[] \f[I]STRING\f[],+\f[C]\-\-title\-prefix=\f[]\f[I]STRING\f[] Specify \f[I]STRING\f[] as a prefix at the beginning of the title that appears in the HTML header (but not in the title as it appears at the beginning of the HTML body).-Implies \f[C]--standalone\f[].+Implies \f[C]\-\-standalone\f[]. .RS .RE .TP-.B \f[C]-c\f[] \f[I]URL\f[], \f[C]--css=\f[]\f[I]URL\f[]+.B \f[C]\-c\f[] \f[I]URL\f[], \f[C]\-\-css=\f[]\f[I]URL\f[] Link to a CSS style sheet.+This option can be be used repeatedly to include multiple files.+They will be included in the order specified. .RS .RE .TP-.B \f[C]--reference-odt=\f[]\f[I]FILE\f[]+.B \f[C]\-\-reference\-odt=\f[]\f[I]FILE\f[] Use the specified file as a style reference in producing an ODT. For best results, the reference ODT should be a modified version of an ODT produced using pandoc.@@ -585,12 +616,12 @@ used in the new ODT. If no reference ODT is specified on the command line, pandoc will look for a file \f[C]reference.odt\f[] in the user data directory (see-\f[C]--data-dir\f[]).+\f[C]\-\-data\-dir\f[]). If this is not found either, sensible defaults will be used. .RS .RE .TP-.B \f[C]--reference-docx=\f[]\f[I]FILE\f[]+.B \f[C]\-\-reference\-docx=\f[]\f[I]FILE\f[] Use the specified file as a style reference in producing a docx file. For best results, the reference docx should be a modified version of a docx file produced using pandoc.@@ -598,37 +629,43 @@ used in the new docx. If no reference docx is specified on the command line, pandoc will look for a file \f[C]reference.docx\f[] in the user data directory (see-\f[C]--data-dir\f[]).+\f[C]\-\-data\-dir\f[]). If this is not found either, sensible defaults will be used.+The following styles are used by pandoc: [paragraph] Normal, Title,+Authors, Date, Heading 1, Heading 2, Heading 3, Heading 4, Heading 5,+Block Quote, Definition Term, Definition, Body Text, Table Caption,+Image Caption; [character] Default Paragraph Font, Body Text Char,+Verbatim Char, Footnote Reference, Hyperlink. .RS .RE .TP-.B \f[C]--epub-stylesheet=\f[]\f[I]FILE\f[]+.B \f[C]\-\-epub\-stylesheet=\f[]\f[I]FILE\f[] Use the specified CSS file to style the EPUB. If no stylesheet is specified, pandoc will look for a file-\f[C]epub.css\f[] in the user data directory (see \f[C]--data-dir\f[]).+\f[C]epub.css\f[] in the user data directory (see+\f[C]\-\-data\-dir\f[]). If it is not found there, sensible defaults will be used. .RS .RE .TP-.B \f[C]--epub-cover-image=\f[]\f[I]FILE\f[]+.B \f[C]\-\-epub\-cover\-image=\f[]\f[I]FILE\f[] Use the specified image as the EPUB cover. It is recommended that the image be less than 1000px in width and height. .RS .RE .TP-.B \f[C]--epub-metadata=\f[]\f[I]FILE\f[]+.B \f[C]\-\-epub\-metadata=\f[]\f[I]FILE\f[] Look in the specified XML file for metadata for the EPUB. The file should contain a series of Dublin Core elements, as documented-at \f[C]http://dublincore.org/documents/dces/\f[].+at http://dublincore.org/documents/dces/. For example: .RS .IP .nf \f[C] \ <dc:rights>Creative\ Commons</dc:rights>-\ <dc:language>es-AR</dc:language>+\ <dc:language>es\-AR</dc:language> \f[] .fi .PP@@ -641,67 +678,81 @@ Any of these may be overridden by elements in the metadata file. .RE .TP-.B \f[C]--epub-embed-font=\f[]\f[I]FILE\f[]+.B \f[C]\-\-epub\-embed\-font=\f[]\f[I]FILE\f[] Embed the specified font in the EPUB. This option can be repeated to embed multiple fonts. To use embedded fonts, you will need to add declarations like the-following to your CSS (see \f[C]--epub-stylesheet\f[]):+following to your CSS (see \f[C]\-\-epub\-stylesheet\f[]): .RS .IP .nf \f[C]-\@font-face\ {-font-family:\ DejaVuSans;-font-style:\ normal;-font-weight:\ normal;-src:url("DejaVuSans-Regular.ttf");+\@font\-face\ {+font\-family:\ DejaVuSans;+font\-style:\ normal;+font\-weight:\ normal;+src:url("DejaVuSans\-Regular.ttf"); }-\@font-face\ {-font-family:\ DejaVuSans;-font-style:\ normal;-font-weight:\ bold;-src:url("DejaVuSans-Bold.ttf");+\@font\-face\ {+font\-family:\ DejaVuSans;+font\-style:\ normal;+font\-weight:\ bold;+src:url("DejaVuSans\-Bold.ttf"); }-\@font-face\ {-font-family:\ DejaVuSans;-font-style:\ italic;-font-weight:\ normal;-src:url("DejaVuSans-Oblique.ttf");+\@font\-face\ {+font\-family:\ DejaVuSans;+font\-style:\ italic;+font\-weight:\ normal;+src:url("DejaVuSans\-Oblique.ttf"); }-\@font-face\ {-font-family:\ DejaVuSans;-font-style:\ italic;-font-weight:\ bold;-src:url("DejaVuSans-BoldOblique.ttf");+\@font\-face\ {+font\-family:\ DejaVuSans;+font\-style:\ italic;+font\-weight:\ bold;+src:url("DejaVuSans\-BoldOblique.ttf"); }-body\ {\ font-family:\ "DejaVuSans";\ }+body\ {\ font\-family:\ "DejaVuSans";\ } \f[] .fi .RE .TP-.B \f[C]--latex-engine=\f[]\f[I]pdflatex|lualatex|xelatex\f[]+.B \f[C]\-\-epub\-chapter\-level=\f[]\f[I]NUMBER\f[]+Specify the header level at which to split the EPUB into separate+"chapter" files.+The default is to split into chapters at level 1 headers.+This option only affects the internal composition of the EPUB, not the+way chapters and sections are displayed to users.+Some readers may be slow if the chapter files are too large, so for+large documents with few level 1 headers, one might want to use a+chapter level of 2 or 3.+.RS+.RE+.TP+.B \f[C]\-\-latex\-engine=\f[]\f[I]pdflatex|lualatex|xelatex\f[] Use the specified LaTeX engine when producing PDF output. The default is \f[C]pdflatex\f[]. If the engine is not in your PATH, the full path of the engine may be specified here. .RS .RE-.SS Citations+.SS Citation rendering .TP-.B \f[C]--bibliography=\f[]\f[I]FILE\f[]+.B \f[C]\-\-bibliography=\f[]\f[I]FILE\f[] Specify bibliography database to be used in resolving citations. The database type will be determined from the extension of \f[I]FILE\f[], which may be \f[C]\&.mods\f[] (MODS format),-\f[C]\&.bib\f[] (BibTeX/BibLaTeX format), \f[C]\&.ris\f[] (RIS format),-\f[C]\&.enl\f[] (EndNote format), \f[C]\&.xml\f[] (EndNote XML format),-\f[C]\&.wos\f[] (ISI format), \f[C]\&.medline\f[] (MEDLINE format),-\f[C]\&.copac\f[] (Copac format), or \f[C]\&.json\f[] (citeproc JSON).+\f[C]\&.bib\f[] (BibLaTeX format, which will normally work for BibTeX+files as well), \f[C]\&.bibtex\f[] (BibTeX format), \f[C]\&.ris\f[] (RIS+format), \f[C]\&.enl\f[] (EndNote format), \f[C]\&.xml\f[] (EndNote XML+format), \f[C]\&.wos\f[] (ISI format), \f[C]\&.medline\f[] (MEDLINE+format), \f[C]\&.copac\f[] (Copac format), or \f[C]\&.json\f[] (citeproc+JSON). If you want to use multiple bibliographies, just use this option repeatedly. .RS .RE .TP-.B \f[C]--csl=\f[]\f[I]FILE\f[]+.B \f[C]\-\-csl=\f[]\f[I]FILE\f[] Specify CSL style to be used in formatting citations and the bibliography. If \f[I]FILE\f[] is not found, pandoc will look for it in@@ -722,25 +773,25 @@ .fi .PP in Windows.-If the \f[C]--csl\f[] option is not specified, pandoc will use a default-style: either \f[C]default.csl\f[] in the user data directory (see-\f[C]--data-dir\f[]), or, if that is not present, the Chicago-author-date style.+If the \f[C]\-\-csl\f[] option is not specified, pandoc will use a+default style: either \f[C]default.csl\f[] in the user data directory+(see \f[C]\-\-data\-dir\f[]), or, if that is not present, the Chicago+author\-date style. .RE .TP-.B \f[C]--citation-abbreviations=\f[]\f[I]FILE\f[]+.B \f[C]\-\-citation\-abbreviations=\f[]\f[I]FILE\f[] Specify a file containing abbreviations for journal titles and other bibliographic fields (indicated by setting \f[C]form="short"\f[] in the CSL node for the field). The format is described at-\f[C]http://citationstylist.org/2011/10/19/abbreviations-for-zotero-test-release/\f[].+http://citationstylist.org/2011/10/19/abbreviations\-for\-zotero\-test\-release/. Here is a short example: .RS .IP .nf \f[C] {\ "default":\ {-\ \ \ \ "container-title":\ {+\ \ \ \ "container\-title":\ { \ \ \ \ \ \ \ \ \ \ \ \ "Lloyd\[aq]s\ Law\ Reports":\ "Lloyd\[aq]s\ Rep", \ \ \ \ \ \ \ \ \ \ \ \ "Estates\ Gazette":\ "EG", \ \ \ \ \ \ \ \ \ \ \ \ "Scots\ Law\ Times":\ "SLT"@@ -751,18 +802,18 @@ .fi .RE .TP-.B \f[C]--natbib\f[]+.B \f[C]\-\-natbib\f[] Use natbib for citations in LaTeX output. .RS .RE .TP-.B \f[C]--biblatex\f[]+.B \f[C]\-\-biblatex\f[] Use biblatex for citations in LaTeX output. .RS .RE .SS Math rendering in HTML .TP-.B \f[C]-m\f[] [\f[I]URL\f[]], \f[C]--latexmathml\f[][=\f[I]URL\f[]]+.B \f[C]\-m\f[] [\f[I]URL\f[]], \f[C]\-\-latexmathml\f[][=\f[I]URL\f[]] Use the LaTeXMathML script to display embedded TeX math in HTML output. To insert a link to a local copy of the \f[C]LaTeXMathML.js\f[] script, provide a \f[I]URL\f[].@@ -774,7 +825,7 @@ .RS .RE .TP-.B \f[C]--mathml\f[][=\f[I]URL\f[]]+.B \f[C]\-\-mathml\f[][=\f[I]URL\f[]] Convert TeX math to MathML (in \f[C]docbook\f[] as well as \f[C]html\f[] and \f[C]html5\f[]). In standalone \f[C]html\f[] output, a small javascript (or a link to@@ -783,7 +834,7 @@ .RS .RE .TP-.B \f[C]--jsmath\f[][=\f[I]URL\f[]]+.B \f[C]\-\-jsmath\f[][=\f[I]URL\f[]] Use jsMath to display embedded TeX math in HTML output. The \f[I]URL\f[] should point to the jsMath load script (e.g. \f[C]jsMath/easy/load.js\f[]); if provided, it will be linked to in the@@ -794,7 +845,7 @@ .RS .RE .TP-.B \f[C]--mathjax\f[][=\f[I]URL\f[]]+.B \f[C]\-\-mathjax\f[][=\f[I]URL\f[]] Use MathJax to display embedded TeX math in HTML output. The \f[I]URL\f[] should point to the \f[C]MathJax.js\f[] load script. If a \f[I]URL\f[] is not provided, a link to the MathJax CDN will be@@ -802,21 +853,21 @@ .RS .RE .TP-.B \f[C]--gladtex\f[]+.B \f[C]\-\-gladtex\f[] Enclose TeX math in \f[C]<eq>\f[] tags in HTML output. These can then be processed by gladTeX to produce links to images of the typeset formulas. .RS .RE .TP-.B \f[C]--mimetex\f[][=\f[I]URL\f[]]+.B \f[C]\-\-mimetex\f[][=\f[I]URL\f[]] Render TeX math using the mimeTeX CGI script. If \f[I]URL\f[] is not specified, it is assumed that the script is at-\f[C]/cgi-bin/mimetex.cgi\f[].+\f[C]/cgi\-bin/mimetex.cgi\f[]. .RS .RE .TP-.B \f[C]--webtex\f[][=\f[I]URL\f[]]+.B \f[C]\-\-webtex\f[][=\f[I]URL\f[]] Render TeX formulas using an external script that converts TeX formulas to images. The formula will be concatenated with the URL provided.@@ -825,30 +876,30 @@ .RE .SS Options for wrapper scripts .TP-.B \f[C]--dump-args\f[]-Print information about command-line arguments to \f[I]stdout\f[], then+.B \f[C]\-\-dump\-args\f[]+Print information about command\-line arguments to \f[I]stdout\f[], then exit. This option is intended primarily for use in wrapper scripts. The first line of output contains the name of the output file specified-with the \f[C]-o\f[] option, or \f[C]-\f[] (for \f[I]stdout\f[]) if no+with the \f[C]\-o\f[] option, or \f[C]\-\f[] (for \f[I]stdout\f[]) if no output file was specified.-The remaining lines contain the command-line arguments, one per line, in-the order they appear.+The remaining lines contain the command\-line arguments, one per line,+in the order they appear. These do not include regular Pandoc options and their arguments, but do-include any options appearing after a \f[C]--\f[] separator at the end+include any options appearing after a \f[C]\-\-\f[] separator at the end of the line. .RS .RE .TP-.B \f[C]--ignore-args\f[]-Ignore command-line arguments (for use in wrapper scripts).+.B \f[C]\-\-ignore\-args\f[]+Ignore command\-line arguments (for use in wrapper scripts). Regular Pandoc options are not ignored. Thus, for example, .RS .IP .nf \f[C]-pandoc\ --ignore-args\ -o\ foo.html\ -s\ foo.txt\ --\ -e\ latin1+pandoc\ \-\-ignore\-args\ \-o\ foo.html\ \-s\ foo.txt\ \-\-\ \-e\ latin1 \f[] .fi .PP@@ -856,38 +907,36 @@ .IP .nf \f[C]-pandoc\ -o\ foo.html\ -s+pandoc\ \-o\ foo.html\ \-s \f[] .fi .RE .SH TEMPLATES .PP-When the \f[C]-s/--standalone\f[] option is used, pandoc uses a template-to add header and footer material that is needed for a self-standing-document.+When the \f[C]\-s/\-\-standalone\f[] option is used, pandoc uses a+template to add header and footer material that is needed for a+self\-standing document. To see the default template that is used, just type .IP .nf \f[C]-pandoc\ -D\ FORMAT+pandoc\ \-D\ FORMAT \f[] .fi .PP where \f[C]FORMAT\f[] is the name of the output format.-A custom template can be specified using the \f[C]--template\f[] option.+A custom template can be specified using the \f[C]\-\-template\f[]+option. You can also override the system default templates for a given output format \f[C]FORMAT\f[] by putting a file \f[C]templates/default.FORMAT\f[] in the user data directory (see-\f[C]--data-dir\f[], above).+\f[C]\-\-data\-dir\f[], above). \f[I]Exceptions:\f[] For \f[C]odt\f[] output, customize the \f[C]default.opendocument\f[] template. For \f[C]pdf\f[] output, customize the \f[C]default.latex\f[] template.-For \f[C]epub\f[] output, customize the \f[C]epub-page.html\f[],-\f[C]epub-coverimage.html\f[], and \f[C]epub-titlepage.html\f[]-templates. .PP Templates may contain \f[I]variables\f[].-Variable names are sequences of alphanumerics, \f[C]-\f[], and+Variable names are sequences of alphanumerics, \f[C]\-\f[], and \f[C]_\f[], starting with a letter. A variable name surrounded by \f[C]$\f[] signs will be replaced by its value.@@ -906,25 +955,26 @@ Some variables are set automatically by pandoc. These vary somewhat depending on the output format, but include: .TP-.B \f[C]header-includes\f[]-contents specified by \f[C]-H/--include-in-header\f[] (may have multiple-values)+.B \f[C]header\-includes\f[]+contents specified by \f[C]\-H/\-\-include\-in\-header\f[] (may have+multiple values) .RS .RE .TP .B \f[C]toc\f[]-non-null value if \f[C]--toc/--table-of-contents\f[] was specified+non\-null value if \f[C]\-\-toc/\-\-table\-of\-contents\f[] was+specified .RS .RE .TP-.B \f[C]include-before\f[]-contents specified by \f[C]-B/--include-before-body\f[] (may have+.B \f[C]include\-before\f[]+contents specified by \f[C]\-B/\-\-include\-before\-body\f[] (may have multiple values) .RS .RE .TP-.B \f[C]include-after\f[]-contents specified by \f[C]-A/--include-after-body\f[] (may have+.B \f[C]include\-after\f[]+contents specified by \f[C]\-A/\-\-include\-after\-body\f[] (may have multiple values) .RS .RE@@ -955,18 +1005,18 @@ .RS .RE .TP-.B \f[C]slidy-url\f[]+.B \f[C]slidy\-url\f[] base URL for Slidy documents (defaults to \f[C]http://www.w3.org/Talks/Tools/Slidy2\f[]) .RS .RE .TP-.B \f[C]slideous-url\f[]+.B \f[C]slideous\-url\f[] base URL for Slideous documents (defaults to \f[C]default\f[]) .RS .RE .TP-.B \f[C]s5-url\f[]+.B \f[C]s5\-url\f[] base URL for S5 documents (defaults to \f[C]ui/default\f[]) .RS .RE@@ -1015,13 +1065,13 @@ .RS .RE .TP-.B \f[C]links-as-notes\f[]+.B \f[C]links\-as\-notes\f[] causes links to be printed as footnotes in LaTeX documents .RS .RE .PP Variables may be set at the command line using the-\f[C]-V/--variable\f[] option.+\f[C]\-V/\-\-variable\f[] option. This allows users to include custom variables in their templates. .PP Templates may contain conditionals.@@ -1038,13 +1088,13 @@ .fi .PP This will include \f[C]X\f[] in the template if \f[C]variable\f[] has a-non-null value; otherwise it will include \f[C]Y\f[].+non\-null value; otherwise it will include \f[C]Y\f[]. \f[C]X\f[] and \f[C]Y\f[] are placeholders for any valid template text, and may include interpolated variables or other conditionals. The \f[C]$else$\f[] section may be omitted. .PP When variables can have multiple values (for example, \f[C]author\f[] in-a multi-author document), you can use the \f[C]$for$\f[] keyword:+a multi\-author document), you can use the \f[C]$for$\f[] keyword: .IP .nf \f[C]@@ -1067,9 +1117,113 @@ changes. We recommend tracking the changes in the default templates, and modifying your custom templates accordingly.-An easy way to do this is to fork the pandoc-templates repository-(\f[C]http://github.com/jgm/pandoc-templates\f[]) and merge in changes-after each pandoc release.+An easy way to do this is to fork the pandoc\-templates repository+(http://github.com/jgm/pandoc\-templates) and merge in changes after+each pandoc release.+.SH NON\-PANDOC EXTENSIONS+.PP+The following markdown syntax extensions are not enabled by default in+pandoc, but may be enabled by adding \f[C]+EXTENSION\f[] to the format+name, where \f[C]EXTENSION\f[] is the name of the extension.+Thus, for example, \f[C]markdown+hard_line_breaks\f[] is markdown with+hard line breaks.+.PP+\f[B]Extension: \f[C]hard_line_breaks\f[]\f[]+.PD 0+.P+.PD+Causes all newlines within a paragraph to be interpreted as hard line+breaks instead of spaces.+.PP+\f[B]Extension: \f[C]tex_math_single_backslash\f[]\f[]+.PD 0+.P+.PD+Causes anything between \f[C]\\(\f[] and \f[C]\\)\f[] to be interpreted+as inline TeX math, and anything between \f[C]\\[\f[] and \f[C]\\]\f[]+to be interpreted as display TeX math.+Note: a drawback of this extension is that it precludes escaping+\f[C](\f[] and \f[C][\f[].+.PP+\f[B]Extension: \f[C]tex_math_double_backslash\f[]\f[]+.PD 0+.P+.PD+Causes anything between \f[C]\\\\(\f[] and \f[C]\\\\)\f[] to be+interpreted as inline TeX math, and anything between \f[C]\\\\[\f[] and+\f[C]\\\\]\f[] to be interpreted as display TeX math.+.PP+\f[B]Extension: \f[C]markdown_attribute\f[]\f[]+.PD 0+.P+.PD+By default, pandoc interprets material inside block\-level tags as+markdown.+This extension changes the behavior so that markdown is only parsed+inside block\-level tags if the tags have the attribute+\f[C]markdown=1\f[].+.PP+\f[B]Extension: \f[C]mmd_title_block\f[]\f[]+.PD 0+.P+.PD+Enables a MultiMarkdown style title block at the top of the document,+for example:+.IP+.nf+\f[C]+Title:\ \ \ My\ title+Author:\ \ John\ Doe+Date:\ \ \ \ September\ 1,\ 2008+Comment:\ This\ is\ a\ sample\ mmd\ title\ block,\ with+\ \ \ \ \ \ \ \ \ a\ field\ spanning\ multiple\ lines.+\f[]+.fi+.PP+See the MultiMarkdown documentation for details.+Note that only title, author, and date are recognized; other fields are+simply ignored by pandoc.+If \f[C]pandoc_title_block\f[] is enabled, it will take precedence over+\f[C]mmd_title_block\f[].+.PP+\f[B]Extension: \f[C]abbrevations\f[]\f[]+.PD 0+.P+.PD+Parses PHP Markdown Extra abbreviation keys, like+.IP+.nf+\f[C]+*[HTML]:\ Hyper\ Text\ Markup\ Language+\f[]+.fi+.PP+Note that the pandoc document model does not support abbreviations, so+if this extension is enabled, abbreviation keys are simply skipped (as+opposed to being parsed as paragraphs).+.PP+\f[B]Extension: \f[C]autolink_bare_uris\f[]\f[]+.PD 0+.P+.PD+Makes all absolute URIs into links, even when not surrounded by pointy+braces \f[C]<...>\f[].+.PP+\f[B]Extension: \f[C]link_attributes\f[]\f[]+.PD 0+.P+.PD+Parses multimarkdown style key\-value attributes on link and image+references.+Note that pandoc\[aq]s internal document model provides nowhere to put+these, so they are presently just ignored.+.PP+\f[B]Extension: \f[C]mmd_header_identifiers\f[]\f[]+.PD 0+.P+.PD+Parses multimarkdown style header identifiers (in square brackets, after+the header but before any trailing \f[C]#\f[]s in an ATX header). .SH PRODUCING SLIDE SHOWS WITH PANDOC .PP You can use Pandoc to produce an HTML + javascript slide presentation@@ -1090,29 +1244,29 @@ ##\ Getting\ up --\ Turn\ off\ alarm--\ Get\ out\ of\ bed+\-\ Turn\ off\ alarm+\-\ Get\ out\ of\ bed ##\ Breakfast --\ Eat\ eggs--\ Drink\ coffee+\-\ Eat\ eggs+\-\ Drink\ coffee #\ In\ the\ evening ##\ Dinner --\ Eat\ spaghetti--\ Drink\ wine+\-\ Eat\ spaghetti+\-\ Drink\ wine -------------------+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-  ##\ Going\ to\ sleep --\ Get\ in\ bed--\ Count\ sheep+\-\ Get\ in\ bed+\-\ Count\ sheep \f[] .fi .PP@@ -1120,7 +1274,7 @@ .IP .nf \f[C]-pandoc\ -t\ s5\ -s\ habits.txt\ -o\ habits.html+pandoc\ \-t\ s5\ \-s\ habits.txt\ \-o\ habits.html \f[] .fi .PP@@ -1128,7 +1282,7 @@ .IP .nf \f[C]-pandoc\ -t\ slidy\ -s\ habits.txt\ -o\ habits.html+pandoc\ \-t\ slidy\ \-s\ habits.txt\ \-o\ habits.html \f[] .fi .PP@@ -1136,7 +1290,7 @@ .IP .nf \f[C]-pandoc\ -t\ slideous\ -s\ habits.txt\ -o\ habits.html+pandoc\ \-t\ slideous\ \-s\ habits.txt\ \-o\ habits.html \f[] .fi .PP@@ -1144,7 +1298,7 @@ .IP .nf \f[C]-pandoc\ -t\ dzslides\ -s\ habits.txt\ -o\ habits.html+pandoc\ \-t\ dzslides\ \-s\ habits.txt\ \-o\ habits.html \f[] .fi .PP@@ -1152,16 +1306,16 @@ .IP .nf \f[C]-pandoc\ -t\ beamer\ habits.txt\ -o\ habits.pdf+pandoc\ \-t\ beamer\ habits.txt\ \-o\ habits.pdf \f[] .fi .PP for beamer. .PP-With all HTML slide formats, the \f[C]--self-contained\f[] option can be-used to produce a single file that contains all of the data necessary to-display the slide show, including linked scripts, stylesheets, images,-and videos.+With all HTML slide formats, the \f[C]\-\-self\-contained\f[] option can+be used to produce a single file that contains all of the data necessary+to display the slide show, including linked scripts, stylesheets,+images, and videos. .SS Structuring the slide show .PP By default, the \f[I]slide level\f[] is the highest header level in the@@ -1169,7 +1323,8 @@ header, somewhere in the document. In the example above, level 1 headers are always followed by level 2 headers, which are followed by content, so 2 is the slide level.-This default can be overridden using the \f[C]--slide-level\f[] option.+This default can be overridden using the \f[C]\-\-slide\-level\f[]+option. .PP The document is carved up into slides according to the following rules: .IP \[bu] 2@@ -1192,33 +1347,31 @@ These rules are designed to support many different styles of slide show. If you don\[aq]t care about structuring your slides into sections and subsections, you can just use level 1 headers for all each slide.-(In that case, level 1 will be the slide level.)- But you can also structure the slide show into sections, as in the-example above.+(In that case, level 1 will be the slide level.) But you can also+structure the slide show into sections, as in the example above. .PP For Slidy, Slideous and S5, the file produced by pandoc with the-\f[C]-s/--standalone\f[] option embeds a link to javascripts and CSS+\f[C]\-s/\-\-standalone\f[] option embeds a link to javascripts and CSS files, which are assumed to be available at the relative path \f[C]s5/default\f[] (for S5) or \f[C]slideous\f[] (for Slideous), or at the Slidy website at \f[C]w3.org\f[] (for Slidy).-(These paths can be changed by setting the \f[C]slidy-url\f[],-\f[C]slideous-url\f[] or \f[C]s5-url\f[] variables; see-\f[C]--variable\f[], above.)- For DZSlides, the (relatively short) javascript and css are included in-the file by default.+(These paths can be changed by setting the \f[C]slidy\-url\f[],+\f[C]slideous\-url\f[] or \f[C]s5\-url\f[] variables; see+\f[C]\-\-variable\f[], above.) For DZSlides, the (relatively short)+javascript and css are included in the file by default. .SS Incremental lists .PP By default, these writers produces lists that display "all at once." If you want your lists to display incrementally (one item at a time), use-the \f[C]-i\f[] option.+the \f[C]\-i\f[] option. If you want a particular list to depart from the default (that is, to-display incrementally without the \f[C]-i\f[] option and all at once-with the \f[C]-i\f[] option), put it in a block quote:+display incrementally without the \f[C]\-i\f[] option and all at once+with the \f[C]\-i\f[] option), put it in a block quote: .IP .nf \f[C]->\ -\ Eat\ spaghetti->\ -\ Drink\ wine+>\ \-\ Eat\ spaghetti+>\ \-\ Drink\ wine \f[] .fi .PP@@ -1229,10 +1382,10 @@ You can change the style of HTML slides by putting customized CSS files in \f[C]$DATADIR/s5/default\f[] (for S5), \f[C]$DATADIR/slidy\f[] (for Slidy), or \f[C]$DATADIR/slideous\f[] (for Slideous), where-\f[C]$DATADIR\f[] is the user data directory (see \f[C]--data-dir\f[],-above).+\f[C]$DATADIR\f[] is the user data directory (see+\f[C]\-\-data\-dir\f[], above). The originals may be found in pandoc\[aq]s system data directory-(generally \f[C]$CABALDIR/pandoc-VERSION/s5/default\f[]).+(generally \f[C]$CABALDIR/pandoc\-VERSION/s5/default\f[]). Pandoc will look there for any files it does not find in the user data directory. .PP@@ -1240,19 +1393,20 @@ modified there. .PP To style beamer slides, you can specify a beamer "theme" or "colortheme"-using the \f[C]-V\f[] option:+using the \f[C]\-V\f[] option: .IP .nf \f[C]-pandoc\ -t\ beamer\ habits.txt\ -V\ theme:Warsaw\ -o\ habits.pdf+pandoc\ \-t\ beamer\ habits.txt\ \-V\ theme:Warsaw\ \-o\ habits.pdf \f[] .fi .SH LITERATE HASKELL SUPPORT .PP-If you append \f[C]+lhs\f[] to an appropriate input or output format-(\f[C]markdown\f[], \f[C]rst\f[], or \f[C]latex\f[] for input or output;-\f[C]beamer\f[], \f[C]html\f[] or \f[C]html5\f[] for output only),-pandoc will treat the document as literate Haskell source.+If you append \f[C]+lhs\f[] (or \f[C]+literate_haskell\f[]) to an+appropriate input or output format (\f[C]markdown\f[],+\f[C]mardkown_strict\f[], \f[C]rst\f[], or \f[C]latex\f[] for input or+output; \f[C]beamer\f[], \f[C]html\f[] or \f[C]html5\f[] for output+only), pandoc will treat the document as literate Haskell source. This means that .IP \[bu] 2 In markdown input, "bird track" sections will be parsed as Haskell code@@ -1264,8 +1418,8 @@ \f[C]literate\f[] will be rendered using bird tracks, and block quotations will be indented one space, so they will not be treated as Haskell code.-In addition, headers will be rendered setext-style (with underlines)-rather than atx-style (with \[aq]#\[aq] characters).+In addition, headers will be rendered setext\-style (with underlines)+rather than atx\-style (with \[aq]#\[aq] characters). (This is because ghc treats \[aq]#\[aq] characters in column 1 as introducing line numbers.) .IP \[bu] 2@@ -1288,7 +1442,7 @@ .IP .nf \f[C]-pandoc\ -f\ markdown+lhs\ -t\ html+pandoc\ \-f\ markdown+lhs\ \-t\ html \f[] .fi .PP@@ -1297,7 +1451,7 @@ .IP .nf \f[C]-pandoc\ -f\ markdown+lhs\ -t\ html+lhs+pandoc\ \-f\ markdown+lhs\ \-t\ html+lhs \f[] .fi .PP@@ -1305,17 +1459,18 @@ and pasted as literate Haskell source. .SH AUTHORS .PP-© 2006-2011 John MacFarlane (jgm at berkeley dot edu).+© 2006\-2011 John MacFarlane (jgm at berkeley dot edu). Released under the GPL, version 2 or greater. This software carries no warranty of any kind.-(See COPYRIGHT for full copyright and warranty notices.)- Other contributors include Recai Oktaş, Paulo Tanimoto, Peter Wang,-Andrea Rossato, Eric Kow, infinity0x, Luke Plant, shreevatsa.public,-Puneeth Chaganti, Paul Rivier, rodja.trappe, Bradley Kuhn, thsutton,-Nathan Gass, Jonathan Daugherty, Jérémy Bobbio, Justin Bogner, qerub,+(See COPYRIGHT for full copyright and warranty notices.) Other+contributors include Recai Oktaş, Paulo Tanimoto, Peter Wang, Andrea+Rossato, Eric Kow, infinity0x, Luke Plant, shreevatsa.public, Puneeth+Chaganti, Paul Rivier, rodja.trappe, Bradley Kuhn, thsutton, Nathan+Gass, Jonathan Daugherty, Jérémy Bobbio, Justin Bogner, qerub, Christopher Sawicki, Kelsey Hightower, Masayoshi Takahashi, Antoine Latter, Ralf Stephan, Eric Seidel, B.-Scott Michel, Gavin Beatty.+Scott Michel, Gavin Beatty, Sergey Astanin, Arlo O\[aq]Keeffe, Denis+Laxalde, Brent Yorgey. .SH PANDOC'S MARKDOWN For a complete description of pandoc's extensions to standard markdown, see \f[C]pandoc_markdown\f[] (5).
@@ -1,5 +1,5 @@ .\"t-.TH PANDOC_MARKDOWN 5 "January 27, 2012" "Pandoc"+.TH PANDOC_MARKDOWN 5 "January 19, 2013" "Pandoc" .SH NAME pandoc_markdown - markdown syntax for pandoc(1) .SH DESCRIPTION@@ -8,18 +8,23 @@ Gruber\[aq]s markdown syntax. This document explains the syntax, noting differences from standard markdown.-Except where noted, these differences can be suppressed by specifying-the \f[C]--strict\f[] command-line option.+Except where noted, these differences can be suppressed by using the+\f[C]markdown_strict\f[] format instead of \f[C]markdown\f[].+An extensions can be enabled by adding \f[C]+EXTENSION\f[] to the format+name and disabled by adding \f[C]\-EXTENSION\f[].+For example, \f[C]markdown_strict+footnotes\f[] is strict markdown with+footnotes enabled, while \f[C]markdown\-footnotes\-pipe_tables\f[] is+pandoc\[aq]s markdown without footnotes or pipe tables. .SH PHILOSOPHY .PP Markdown is designed to be easy to write, and, even more importantly, easy to read: .RS .PP-A Markdown-formatted document should be publishable as-is, as plain+A Markdown\-formatted document should be publishable as\-is, as plain text, without looking like it\[aq]s been marked up with tags or formatting instructions.--- John Gruber+\-\- John Gruber .RE .PP This principle has guided pandoc\[aq]s decisions in finding syntax for@@ -30,7 +35,7 @@ Whereas markdown was originally designed with HTML generation in mind, pandoc is designed for multiple output formats. Thus, while pandoc allows the embedding of raw HTML, it discourages it,-and provides other, non-HTMLish ways of representing important document+and provides other, non\-HTMLish ways of representing important document elements like definition lists, tables, mathematics, and footnotes. .SH PARAGRAPHS .PP@@ -39,51 +44,57 @@ Newlines are treated as spaces, so you can reflow your paragraphs as you like. If you need a hard line break, put two or more spaces at the end of a-line, or type a backslash followed by a newline.+line.+.PP+\f[B]Extension: \f[C]escaped_line_breaks\f[]\f[]+.PP+A backslash followed by a newline is also a hard line break. .SH HEADERS .PP There are two kinds of headers, Setext and atx.-.SS Setext-style headers+.SS Setext\-style headers .PP-A setext-style header is a line of text "underlined" with a row of-\f[C]=\f[] signs (for a level one header) of \f[C]-\f[] signs (for a+A setext\-style header is a line of text "underlined" with a row of+\f[C]=\f[] signs (for a level one header) of \f[C]\-\f[] signs (for a level two header): .IP .nf \f[C]-A\ level-one\ header+A\ level\-one\ header ================== -A\ level-two\ header-------------------+A\ level\-two\ header+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- \f[] .fi .PP The header text can contain inline formatting, such as emphasis (see Inline formatting, below).-.SS Atx-style headers+.SS Atx\-style headers .PP-An Atx-style header consists of one to six \f[C]#\f[] signs and a line+An Atx\-style header consists of one to six \f[C]#\f[] signs and a line of text, optionally followed by any number of \f[C]#\f[] signs. The number of \f[C]#\f[] signs at the beginning of the line is the header level: .IP .nf \f[C]-##\ A\ level-two\ header+##\ A\ level\-two\ header -###\ A\ level-three\ header\ ###+###\ A\ level\-three\ header\ ### \f[] .fi .PP-As with setext-style headers, the header text can contain formatting:+As with setext\-style headers, the header text can contain formatting: .IP .nf \f[C]-#\ A\ level-one\ header\ with\ a\ [link](/url)\ and\ *emphasis*+#\ A\ level\-one\ header\ with\ a\ [link](/url)\ and\ *emphasis* \f[] .fi .PP+\f[B]Extension: \f[C]blank_before_header\f[]\f[]+.PP Standard markdown syntax does not require a blank line before a header. Pandoc does require this (except, of course, at the beginning of the document).@@ -100,11 +111,40 @@ .fi .SS Header identifiers in HTML, LaTeX, and ConTeXt .PP-\f[I]Pandoc extension\f[].+\f[B]Extension: \f[C]header_attributes\f[]\f[] .PP-Each header element in pandoc\[aq]s HTML and ConTeXt output is given a-unique identifier.-This identifier is based on the text of the header.+Headers can be assigned attributes using this syntax at the end of the+line containing the header text:+.IP+.nf+\f[C]+{#identifier\ .class\ .class\ key=value\ key=value}+\f[]+.fi+.PP+Although this syntax allows assignment of classes and key/value+attributes, only identifiers currently have any affect in the writers+(and only in some writers: HTML, LaTeX, ConTeXt, Textile, AsciiDoc).+Thus, for example, the following headers will all be assigned the+identifier \f[C]foo\f[]:+.IP+.nf+\f[C]+#\ My\ header\ {#foo}++##\ My\ header\ ##\ \ \ \ {#foo}++My\ other\ header\ \ \ {#foo}+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\f[]+.fi+.PP+(This syntax is compatible with PHP Markdown Extra.)+.PP+\f[B]Extension: \f[C]auto_identifiers\f[]\f[]+.PP+A header without an explicitly specified identifier will be+automatically assigned a unique identifier based on the header text. To derive the identifier from the header text, .IP \[bu] 2 Remove all formatting, links, etc.@@ -134,17 +174,17 @@ T{ Header identifiers in HTML T}@T{-\f[C]header-identifiers-in-html\f[]+\f[C]header\-identifiers\-in\-html\f[] T} T{-\f[I]Dogs\f[]?--in \f[I]my\f[] house?+\f[I]Dogs\f[]?\-\-in \f[I]my\f[] house? T}@T{-\f[C]dogs--in-my-house\f[]+\f[C]dogs\-\-in\-my\-house\f[] T} T{ HTML, S5, or RTF? T}@T{-\f[C]html-s5-or-rtf\f[]+\f[C]html\-s5\-or\-rtf\f[] T} T{ 3.@@ -163,11 +203,12 @@ from the header text. The exception is when several headers have the same text; in this case, the first will get an identifier as described above; the second will get-the same identifier with \f[C]-1\f[] appended; the third with-\f[C]-2\f[]; and so on.+the same identifier with \f[C]\-1\f[] appended; the third with+\f[C]\-2\f[]; and so on. .PP These identifiers are used to provide link targets in the table of-contents generated by the \f[C]--toc|--table-of-contents\f[] option.+contents generated by the \f[C]\-\-toc|\-\-table\-of\-contents\f[]+option. They also make it easy to provide links from one section of a document to another. A link to this section, for example, might look like this:@@ -175,20 +216,64 @@ .nf \f[C] See\ the\ section\ on-[header\ identifiers](#header-identifiers-in-html).+[header\ identifiers](#header\-identifiers\-in\-html). \f[] .fi .PP Note, however, that this method of providing links to sections works only in HTML, LaTeX, and ConTeXt formats. .PP-If the \f[C]--section-divs\f[] option is specified, then each section+If the \f[C]\-\-section\-divs\f[] option is specified, then each section will be wrapped in a \f[C]div\f[] (or a \f[C]section\f[], if-\f[C]--html5\f[] was specified), and the identifier will be attached to-the enclosing \f[C]<div>\f[] (or \f[C]<section>\f[]) tag rather than the-header itself.+\f[C]\-\-html5\f[] was specified), and the identifier will be attached+to the enclosing \f[C]<div>\f[] (or \f[C]<section>\f[]) tag rather than+the header itself. This allows entire sections to be manipulated using javascript or treated differently in CSS.+.PP+\f[B]Extension: \f[C]implicit_header_references\f[]\f[]+.PP+Pandoc behaves as if reference links have been defined for each header.+So, instead of+.IP+.nf+\f[C]+[header\ identifiers](#header\-identifiers\-in\-html)+\f[]+.fi+.PP+you can simply write+.IP+.nf+\f[C]+[header\ identifiers]+\f[]+.fi+.PP+or+.IP+.nf+\f[C]+[header\ identifiers][]+\f[]+.fi+.PP+or+.IP+.nf+\f[C]+[the\ section\ on\ header\ identifiers][header\ identifiers]+\f[]+.fi+.PP+If there are multiple headers with identical text, the corresponding+reference will link to the first one only, and you will need to use+explicit links to link to the others, as described above.+.PP+Unlike regular reference links, these references are case\-sensitive.+.PP+Note: if you have defined an explicit identifier for a header, then+implicit references to it will not work. .SH BLOCK QUOTATIONS .PP Markdown uses email conventions for quoting blocks of text.@@ -233,6 +318,8 @@ \f[] .fi .PP+\f[B]Extension: \f[C]blank_line_before_blockquote\f[]\f[]+.PP Standard markdown syntax does not require a blank line before a block quote. Pandoc does require this (except, of course, at the beginning of the@@ -240,8 +327,8 @@ The reason for the requirement is that it is all too easy for a \f[C]>\f[] to end up at the beginning of a line by accident (perhaps through line wrapping).-So, unless \f[C]--strict\f[] is used, the following does not produce a-nested block quote in pandoc:+So, unless the \f[C]markdown_strict\f[] format is used, the following+does not produce a nested block quote in pandoc: .IP .nf \f[C]@@ -269,12 +356,12 @@ of the verbatim text, and is removed in the output. .PP Note: blank lines in the verbatim text need not begin with four spaces.-.SS Delimited code blocks+.SS Fenced code blocks .PP-\f[I]Pandoc extension\f[].+\f[B]Extension: \f[C]fenced_code_blocks\f[]\f[] .PP In addition to standard indented code blocks, Pandoc supports-\f[I]delimited\f[] code blocks.+\f[I]fenced\f[] code blocks. These begin with a row of three or more tildes (\f[C]~\f[]) or backticks (\f[C]`\f[]) and end with a row of tildes or backticks that must be at least as long as the starting row.@@ -291,7 +378,7 @@ \f[] .fi .PP-Like regular code blocks, delimited code blocks must be separated from+Like regular code blocks, fenced code blocks must be separated from surrounding text by blank lines. .PP If the code itself contains a row of tildes or backticks, just use a@@ -328,8 +415,8 @@ and LaTeX. If highlighting is supported for your output format and language, then the code block above will appear highlighted, with numbered lines.-(To see which languages are supported, do \f[C]pandoc\ --version\f[].)- Otherwise, the code block above will appear as follows:+(To see which languages are supported, do \f[C]pandoc\ \-\-version\f[].)+Otherwise, the code block above will appear as follows: .IP .nf \f[C]@@ -362,14 +449,50 @@ \f[] .fi .PP-To prevent all highlighting, use the \f[C]--no-highlight\f[] flag.-To set the highlighting style, use \f[C]--highlight-style\f[].+To prevent all highlighting, use the \f[C]\-\-no\-highlight\f[] flag.+To set the highlighting style, use \f[C]\-\-highlight\-style\f[].+.SH LINE BLOCKS+.PP+\f[B]Extension: \f[C]line_blocks\f[]\f[]+.PP+A line block is a sequence of lines beginning with a vertical bar+(\f[C]|\f[]) followed by a space.+The division into lines will be preserved in the output, as will any+leading spaces; otherwise, the lines will be formatted as markdown.+This is useful for verse and addresses:+.IP+.nf+\f[C]+|\ The\ limerick\ packs\ laughs\ anatomical+|\ In\ space\ that\ is\ quite\ economical.+|\ \ \ \ But\ the\ good\ ones\ I\[aq]ve\ seen+|\ \ \ \ So\ seldom\ are\ clean+|\ And\ the\ clean\ ones\ so\ seldom\ are\ comical++|\ 200\ Main\ St.+|\ Berkeley,\ CA\ 94718+\f[]+.fi+.PP+The lines can be hard\-wrapped if needed, but the continuation line must+begin with a space.+.IP+.nf+\f[C]+|\ The\ Right\ Honorable\ Most\ Venerable\ and\ Righteous\ Samuel\ L.+\ \ Constable,\ Jr.+|\ 200\ Main\ St.+|\ Berkeley,\ CA\ 94718+\f[]+.fi+.PP+This syntax is borrowed from reStructuredText. .SH LISTS .SS Bullet lists .PP A bullet list is a list of bulleted list items. A bulleted list item begins with a bullet (\f[C]*\f[], \f[C]+\f[], or-\f[C]-\f[]).+\f[C]\-\f[]). Here is a simple example: .IP .nf@@ -418,9 +541,9 @@ *\ and\ my\ second. \f[] .fi-.SS The four-space rule+.SS The four\-space rule .PP-A list item may contain multiple paragraphs and other block-level+A list item may contain multiple paragraphs and other block\-level content. However, subsequent paragraphs must be preceded by a blank line and indented four spaces or a tab.@@ -448,8 +571,8 @@ \f[C] *\ fruits \ \ \ \ +\ apples-\ \ \ \ \ \ \ \ -\ macintosh-\ \ \ \ \ \ \ \ -\ red\ delicious+\ \ \ \ \ \ \ \ \-\ macintosh+\ \ \ \ \ \ \ \ \-\ red\ delicious \ \ \ \ +\ pears \ \ \ \ +\ peaches *\ vegetables@@ -476,16 +599,16 @@ \f[] .fi .PP-\f[B]Note:\f[] Although the four-space rule for continuation paragraphs+\f[B]Note:\f[] Although the four\-space rule for continuation paragraphs comes from the official markdown syntax guide, the reference implementation, \f[C]Markdown.pl\f[], does not follow it. So pandoc will give different results than \f[C]Markdown.pl\f[] when authors have indented continuation paragraphs fewer than four spaces. .PP-The markdown syntax guide is not explicit whether the four-space rule-applies to \f[I]all\f[] block-level content in a list item; it only+The markdown syntax guide is not explicit whether the four\-space rule+applies to \f[I]all\f[] block\-level content in a list item; it only mentions paragraphs and code blocks.-But it implies that the rule applies to all block-level content+But it implies that the rule applies to all block\-level content (including nested lists), and pandoc interprets it that way. .SS Ordered lists .PP@@ -515,17 +638,19 @@ \f[] .fi .PP-\f[I]Pandoc extension\f[].+\f[B]Extension: \f[C]fancy_lists\f[]\f[] .PP Unlike standard markdown, Pandoc allows ordered list items to be marked with uppercase and lowercase letters and roman numerals, in addition to arabic numerals. List markers may be enclosed in parentheses or followed by a single-right-parentheses or period.+right\-parentheses or period. They must be separated from the text that follows by at least one space, and, if the list marker is a capital letter with a period, by at least two spaces.[1] .PP+\f[B]Extension: \f[C]startnum\f[]\f[]+.PP Pandoc also pays attention to the type of list marker used, and to the starting number, and both of these are preserved where possible in the output format.@@ -568,7 +693,7 @@ .fi .SS Definition lists .PP-\f[I]Pandoc extension\f[].+\f[B]Extension: \f[C]definition_lists\f[]\f[] .PP Pandoc supports definition lists, using a syntax inspired by PHP Markdown Extra and reStructuredText:[2]@@ -596,8 +721,8 @@ The body of the definition (including the first line, aside from the colon or tilde) should be indented four spaces. A term may have multiple definitions, and each definition may consist of-one or more block elements (paragraph, code block, list, etc.)-, each indented four spaces or one tab stop.+one or more block elements (paragraph, code block, list, etc.), each+indented four spaces or one tab stop. .PP If you leave space after the definition (as in the example above), the blocks of the definitions will be considered paragraphs.@@ -617,7 +742,7 @@ .fi .SS Numbered example lists .PP-\f[I]Pandoc extension\f[].+\f[B]Extension: \f[C]example_lists\f[]\f[] .PP The special list marker \f[C]\@\f[] can be used for sequentially numbered examples.@@ -661,9 +786,9 @@ \f[C] +\ \ \ First +\ \ \ Second:-\ -\ \ \ Fee-\ -\ \ \ Fie-\ -\ \ \ Foe+\ \-\ \ \ Fee+\ \-\ \ \ Fie+\ \-\ \ \ Foe +\ \ \ Third \f[]@@ -678,8 +803,8 @@ Since "Second" is followed by a list, and not a blank line, it isn\[aq]t treated as a paragraph. The fact that the list is followed by a blank line is irrelevant.-(Note: Pandoc works this way even when the \f[C]--strict\f[] option is-specified.+(Note: Pandoc works this way even when the \f[C]markdown_strict\f[]+format is specified. This behavior is consistent with the official markdown syntax description, even though it is different from that of \f[C]Markdown.pl\f[].)@@ -689,8 +814,8 @@ .IP .nf \f[C]--\ \ \ item\ one--\ \ \ item\ two+\-\ \ \ item\ one+\-\ \ \ item\ two \ \ \ \ {\ my\ code\ block\ } \f[]@@ -700,16 +825,16 @@ \f[C]{\ my\ code\ block\ }\f[] as the second paragraph of item two, and not as a code block. .PP-To "cut off" the list after item two, you can insert some non-indented+To "cut off" the list after item two, you can insert some non\-indented content, like an HTML comment, which won\[aq]t produce visible output in any format: .IP .nf \f[C]--\ \ \ item\ one--\ \ \ item\ two+\-\ \ \ item\ one+\-\ \ \ item\ two -<!--\ end\ of\ list\ -->+<!\-\-\ end\ of\ list\ \-\-> \ \ \ \ {\ my\ code\ block\ } \f[]@@ -724,7 +849,7 @@ 2.\ \ two 3.\ \ three -<!--\ -->+<!\-\-\ \-\-> 1.\ \ uno 2.\ \ dos@@ -733,7 +858,7 @@ .fi .SH HORIZONTAL RULES .PP-A line containing a row of three or more \f[C]*\f[], \f[C]-\f[], or+A line containing a row of three or more \f[C]*\f[], \f[C]\-\f[], or \f[C]_\f[] characters (optionally separated by spaces) produces a horizontal rule: .IP@@ -741,23 +866,27 @@ \f[C] *\ \ *\ \ *\ \ * ----------------+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- \f[] .fi .SH TABLES .PP-\f[I]Pandoc extension\f[].+\f[B]Extension: \f[C]simple_tables\f[], \f[C]multiline_tables\f[],+\f[C]grid_tables\f[], \f[C]pipe_tables\f[], \f[C]table_captions\f[]\f[] .PP-Three kinds of tables may be used.-All three kinds presuppose the use of a fixed-width font, such as+Four kinds of tables may be used.+The first three kinds presuppose the use of a fixed\-width font, such as Courier.+The fourth kind can be used with proportionally spaced fonts, as it does+not require lining up columns.+.SS Simple tables .PP-\f[B]Simple tables\f[] look like this:+Simple tables look like this: .IP .nf \f[C] \ \ Right\ \ \ \ \ Left\ \ \ \ \ Center\ \ \ \ \ Default--------\ \ \ \ \ ------\ ----------\ \ \ -------+\-\-\-\-\-\-\-\ \ \ \ \ \-\-\-\-\-\-\ \-\-\-\-\-\-\-\-\-\-\ \ \ \-\-\-\-\-\-\- \ \ \ \ \ 12\ \ \ \ \ 12\ \ \ \ \ \ \ \ 12\ \ \ \ \ \ \ \ \ \ \ \ 12 \ \ \ \ 123\ \ \ \ \ 123\ \ \ \ \ \ \ 123\ \ \ \ \ \ \ \ \ \ 123 \ \ \ \ \ \ 1\ \ \ \ \ 1\ \ \ \ \ \ \ \ \ \ 1\ \ \ \ \ \ \ \ \ \ \ \ \ 1@@ -771,10 +900,10 @@ relative to the dashed line below it:[3] .IP \[bu] 2 If the dashed line is flush with the header text on the right side but-extends beyond it on the left, the column is right-aligned.+extends beyond it on the left, the column is right\-aligned. .IP \[bu] 2 If the dashed line is flush with the header text on the left side but-extends beyond it on the right, the column is left-aligned.+extends beyond it on the right, the column is left\-aligned. .IP \[bu] 2 If the dashed line extends beyond the header text on both sides, the column is centered.@@ -796,11 +925,11 @@ .IP .nf \f[C]--------\ \ \ \ \ ------\ ----------\ \ \ -------+\-\-\-\-\-\-\-\ \ \ \ \ \-\-\-\-\-\-\ \-\-\-\-\-\-\-\-\-\-\ \ \ \-\-\-\-\-\-\- \ \ \ \ \ 12\ \ \ \ \ 12\ \ \ \ \ \ \ \ 12\ \ \ \ \ \ \ \ \ \ \ \ \ 12 \ \ \ \ 123\ \ \ \ \ 123\ \ \ \ \ \ \ 123\ \ \ \ \ \ \ \ \ \ \ 123 \ \ \ \ \ \ 1\ \ \ \ \ 1\ \ \ \ \ \ \ \ \ \ 1\ \ \ \ \ \ \ \ \ \ \ \ \ \ 1--------\ \ \ \ \ ------\ ----------\ \ \ -------+\-\-\-\-\-\-\-\ \ \ \ \ \-\-\-\-\-\-\ \-\-\-\-\-\-\-\-\-\-\ \ \ \-\-\-\-\-\-\- \f[] .fi .PP@@ -808,25 +937,26 @@ of the first line of the table body. So, in the tables above, the columns would be right, left, center, and right aligned, respectively.+.SS Multiline tables .PP-\f[B]Multiline tables\f[] allow headers and table rows to span multiple-lines of text (but cells that span multiple columns or rows of the table-are not supported).+Multiline tables allow headers and table rows to span multiple lines of+text (but cells that span multiple columns or rows of the table are not+supported). Here is an example: .IP .nf \f[C]--------------------------------------------------------------+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- \ Centered\ \ \ Default\ \ \ \ \ \ \ \ \ \ \ Right\ Left \ \ Header\ \ \ \ Aligned\ \ \ \ \ \ \ \ \ Aligned\ Aligned------------\ -------\ ---------------\ -------------------------+\-\-\-\-\-\-\-\-\-\-\-\ \-\-\-\-\-\-\-\ \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\ \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- \ \ \ First\ \ \ \ row\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 12.0\ Example\ of\ a\ row\ that \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ spans\ multiple\ lines. \ \ Second\ \ \ \ row\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 5.0\ Here\[aq]s\ another\ one.\ Note \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ the\ blank\ line\ between \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ rows.--------------------------------------------------------------+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- Table:\ Here\[aq]s\ the\ caption.\ It,\ too,\ may\ span multiple\ lines.@@ -852,14 +982,14 @@ .IP .nf \f[C]------------\ -------\ ---------------\ -------------------------+\-\-\-\-\-\-\-\-\-\-\-\ \-\-\-\-\-\-\-\ \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\ \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- \ \ \ First\ \ \ \ row\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 12.0\ Example\ of\ a\ row\ that \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ spans\ multiple\ lines. \ \ Second\ \ \ \ row\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 5.0\ Here\[aq]s\ another\ one.\ Note \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ the\ blank\ line\ between \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ rows.--------------------------------------------------------------+\-\-\-\-\-\-\-\-\-\-\-\ \-\-\-\-\-\-\-\ \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\ \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- :\ Here\[aq]s\ a\ multiline\ table\ without\ headers. \f[]@@ -868,36 +998,92 @@ It is possible for a multiline table to have just one row, but the row should be followed by a blank line (and then the row of dashes that ends the table), or the table may be interpreted as a simple table.+.SS Grid tables .PP-\f[B]Grid tables\f[] look like this:+Grid tables look like this: .IP .nf \f[C] :\ Sample\ grid\ table. -+---------------+---------------+--------------------+++\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+ |\ Fruit\ \ \ \ \ \ \ \ \ |\ Price\ \ \ \ \ \ \ \ \ |\ Advantages\ \ \ \ \ \ \ \ \ | +===============+===============+====================+-|\ Bananas\ \ \ \ \ \ \ |\ $1.34\ \ \ \ \ \ \ \ \ |\ -\ built-in\ wrapper\ |-|\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ |\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ |\ -\ bright\ color\ \ \ \ \ |-+---------------+---------------+--------------------+-|\ Oranges\ \ \ \ \ \ \ |\ $2.10\ \ \ \ \ \ \ \ \ |\ -\ cures\ scurvy\ \ \ \ \ |-|\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ |\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ |\ -\ tasty\ \ \ \ \ \ \ \ \ \ \ \ |-+---------------+---------------+--------------------++|\ Bananas\ \ \ \ \ \ \ |\ $1.34\ \ \ \ \ \ \ \ \ |\ \-\ built\-in\ wrapper\ |+|\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ |\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ |\ \-\ bright\ color\ \ \ \ \ |++\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-++|\ Oranges\ \ \ \ \ \ \ |\ $2.10\ \ \ \ \ \ \ \ \ |\ \-\ cures\ scurvy\ \ \ \ \ |+|\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ |\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ |\ \-\ tasty\ \ \ \ \ \ \ \ \ \ \ \ |++\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+ \f[] .fi .PP The row of \f[C]=\f[]s separates the header from the table body, and can be omitted for a headerless table. The cells of grid tables may contain arbitrary block elements (multiple-paragraphs, code blocks, lists, etc.)-\&.+paragraphs, code blocks, lists, etc.). Alignments are not supported, nor are cells that span multiple columns or rows. Grid tables can be created easily using Emacs table mode.+.SS Pipe tables+.PP+Pipe tables look like this:+.IP+.nf+\f[C]+|\ Right\ |\ Left\ |\ Default\ |\ Center\ |+|\-\-\-\-\-\-:|:\-\-\-\-\-|\-\-\-\-\-\-\-\-\-|:\-\-\-\-\-\-:|+|\ \ \ 12\ \ |\ \ 12\ \ |\ \ \ \ 12\ \ \ |\ \ \ \ 12\ \ |+|\ \ 123\ \ |\ \ 123\ |\ \ \ 123\ \ \ |\ \ \ 123\ \ |+|\ \ \ \ 1\ \ |\ \ \ \ 1\ |\ \ \ \ \ 1\ \ \ |\ \ \ \ \ 1\ \ |++\ \ :\ Demonstration\ of\ simple\ table\ syntax.+\f[]+.fi+.PP+The syntax is the same as in PHP markdown extra.+The beginning and ending pipe characters are optional, but pipes are+required between all columns.+The colons indicate column alignment as shown.+The header can be omitted, but the horizontal line must still be+included, as it defines column alignments.+.PP+Since the pipes indicate column boundaries, columns need not be+vertically aligned, as they are in the above example.+So, this is a perfectly legal (though ugly) pipe table:+.IP+.nf+\f[C]+fruit|\ price+\-\-\-\-\-|\-\-\-\-\-:+apple|2.05+pear|1.37+orange|3.09+\f[]+.fi+.PP+The cells of pipe tables cannot contain block elements like paragraphs+and lists, and cannot span multiple lines.+.PP+Note: Pandoc also recognizes pipe tables of the following form, as can+produced by Emacs\[aq] orgtbl\-mode:+.IP+.nf+\f[C]+|\ One\ |\ Two\ \ \ |+|\-\-\-\-\-+\-\-\-\-\-\-\-|+|\ my\ \ |\ table\ |+|\ is\ \ |\ nice\ \ |+\f[]+.fi+.PP+The difference is that \f[C]+\f[] is used instead of \f[C]|\f[].+Other orgtbl features are not supported.+In particular, to get non\-default column alignment, you\[aq]ll need to+add colons as above. .SH TITLE BLOCK .PP-\f[I]Pandoc extension\f[].+\f[B]Extension: \f[C]pandoc_title_block\f[]\f[] .PP If the file begins with a title block .IP@@ -911,9 +1097,8 @@ .PP it will be parsed as bibliographic information, not regular text. (It will be used, for example, in the title of standalone LaTeX or HTML-output.)- The block may contain just a title, a title and an author, or all three-elements.+output.) The block may contain just a title, a title and an author, or+all three elements. If you want to include an author but no title, or a title and a date but no author, you need a blank line: .IP@@ -957,28 +1142,27 @@ The date must fit on one line. .PP All three metadata fields may contain standard inline formatting-(italics, links, footnotes, etc.)-\&.+(italics, links, footnotes, etc.). .PP Title blocks will always be parsed, but they will affect the output only-when the \f[C]--standalone\f[] (\f[C]-s\f[]) option is chosen.-In HTML output, titles will appear twice: once in the document head --+when the \f[C]\-\-standalone\f[] (\f[C]\-s\f[]) option is chosen.+In HTML output, titles will appear twice: once in the document head \-\- this is the title that will appear at the top of the window in a browser--- and once at the beginning of the document body.+\-\- and once at the beginning of the document body. The title in the document head can have an optional prefix attached-(\f[C]--title-prefix\f[] or \f[C]-T\f[] option).+(\f[C]\-\-title\-prefix\f[] or \f[C]\-T\f[] option). The title in the body appears as an H1 element with class "title", so it can be suppressed or reformatted with CSS.-If a title prefix is specified with \f[C]-T\f[] and no title block+If a title prefix is specified with \f[C]\-T\f[] and no title block appears in the document, the title prefix will be used by itself as the HTML title. .PP The man page writer extracts a title, man page section number, and other header and footer information from the title line. The title is assumed to be the first word on the title line, which may-optionally end with a (single-digit) section number in parentheses.+optionally end with a (single\-digit) section number in parentheses. (There should be no space between the title and the parentheses.)- Anything after this is assumed to be additional footer and header text.+Anything after this is assumed to be additional footer and header text. A single pipe character (\f[C]|\f[]) should be used to separate the footer text from the header text. Thus,@@ -1008,6 +1192,8 @@ will also have "Version 4.0" in the header. .SH BACKSLASH ESCAPES .PP+\f[B]Extension: \f[C]all_symbols_escapable\f[]\f[]+.PP Except inside a code block or inline code, any punctuation or space character preceded by a backslash will be treated literally, even if it would normally indicate formatting.@@ -1036,22 +1222,22 @@ .fi .PP This rule is easier to remember than standard markdown\[aq]s rule, which-allows only the following characters to be backslash-escaped:+allows only the following characters to be backslash\-escaped: .IP .nf \f[C]-\\`*_{}[]()>#+-.!+\\`*_{}[]()>#+\-.! \f[] .fi .PP-(However, if the \f[C]--strict\f[] option is supplied, the standard+(However, if the \f[C]markdown_strict\f[] format is used, the standard markdown rule will be used.) .PP-A backslash-escaped space is parsed as a nonbreaking space.+A backslash\-escaped space is parsed as a nonbreaking space. It will appear in TeX output as \f[C]~\f[] and in HTML and XML as \f[C]\\ \f[] or \f[C]\\ \f[]. .PP-A backslash-escaped newline (i.e.+A backslash\-escaped newline (i.e. a backslash occurring at the end of a line) is parsed as a hard line break. It will appear in TeX output as \f[C]\\\\\f[] and in HTML as@@ -1062,11 +1248,11 @@ Backslash escapes do not work in verbatim contexts. .SH SMART PUNCTUATION .PP-\f[I]Pandoc extension\f[].+\f[B]Extension\f[] .PP-If the \f[C]--smart\f[] option is specified, pandoc will produce+If the \f[C]\-\-smart\f[] option is specified, pandoc will produce typographically correct output, converting straight quotes to curly-quotes, \f[C]---\f[] to em-dashes, \f[C]--\f[] to en-dashes, and+quotes, \f[C]\-\-\-\f[] to em\-dashes, \f[C]\-\-\f[] to en\-dashes, and \f[C]\&...\f[] to ellipses. Nonbreaking spaces are inserted after certain abbreviations, such as "Mr."@@ -1096,7 +1282,7 @@ .fi .PP A \f[C]*\f[] or \f[C]_\f[] character surrounded by spaces, or-backslash-escaped, will not trigger emphasis:+backslash\-escaped, will not trigger emphasis: .IP .nf \f[C]@@ -1104,6 +1290,8 @@ \f[] .fi .PP+\f[B]Extension: \f[C]intraword_underscores\f[]\f[]+.PP Because \f[C]_\f[] is sometimes used inside words and identifiers, pandoc does not interpret a \f[C]_\f[] surrounded by alphanumeric characters as an emphasis marker.@@ -1116,7 +1304,7 @@ .fi .SS Strikeout .PP-\f[I]Pandoc extension\f[].+\f[B]Extension: \f[C]strikeout\f[]\f[] .PP To strikeout a section of text with a horizontal line, begin and end it with \f[C]~~\f[].@@ -1129,7 +1317,7 @@ .fi .SS Superscripts and subscripts .PP-\f[I]Pandoc extension\f[].+\f[B]Extension: \f[C]superscript\f[], \f[C]subscript\f[]\f[] .PP Superscripts may be written by surrounding the superscripted text by \f[C]^\f[] characters; subscripts may be written by surrounding the@@ -1145,9 +1333,9 @@ If the superscripted or subscripted text contains spaces, these spaces must be escaped with backslashes. (This is to prevent accidental superscripting and subscripting through-the ordinary use of \f[C]~\f[] and \f[C]^\f[].)- Thus, if you want the letter P with \[aq]a cat\[aq] in subscripts, use-\f[C]P~a\\\ cat~\f[], not \f[C]P~a\ cat~\f[].+the ordinary use of \f[C]~\f[] and \f[C]^\f[].) Thus, if you want the+letter P with \[aq]a cat\[aq] in subscripts, use \f[C]P~a\\\ cat~\f[],+not \f[C]P~a\ cat~\f[]. .SS Verbatim .PP To make a short span of text verbatim, put it inside backticks:@@ -1173,7 +1361,7 @@ consecutive backticks (optionally followed by a space) and ends with a string of the same number of backticks (optionally preceded by a space). .PP-Note that backslash-escapes (and other markdown constructs) do not work+Note that backslash\-escapes (and other markdown constructs) do not work in verbatim contexts: .IP .nf@@ -1182,7 +1370,9 @@ \f[] .fi .PP-Attributes can be attached to verbatim text, just as with delimited code+\f[B]Extension: \f[C]inline_code_attributes\f[]\f[]+.PP+Attributes can be attached to verbatim text, just as with fenced code blocks: .IP .nf@@ -1192,7 +1382,7 @@ .fi .SH MATH .PP-\f[I]Pandoc extension\f[].+\f[B]Extension: \f[C]tex_math_dollars\f[]\f[] .PP Anything between two \f[C]$\f[] characters will be treated as TeX math. The opening \f[C]$\f[] must have a character immediately to its right,@@ -1200,13 +1390,13 @@ left. Thus, \f[C]$20,000\ and\ $30,000\f[] won\[aq]t parse as math. If for some reason you need to enclose text in literal \f[C]$\f[]-characters, backslash-escape them and they won\[aq]t be treated as math+characters, backslash\-escape them and they won\[aq]t be treated as math delimiters. .PP TeX math will be printed in all output formats. How it is rendered depends on the output format: .TP-.B Markdown, LaTeX, Org-Mode, ConTeXt+.B Markdown, LaTeX, Org\-Mode, ConTeXt It will appear verbatim between \f[C]$\f[] characters. .RS .RE@@ -1249,8 +1439,8 @@ .RE .TP .B Docbook-If the \f[C]--mathml\f[] flag is used, it will be rendered using mathml-in an \f[C]inlineequation\f[] or \f[C]informalequation\f[] tag.+If the \f[C]\-\-mathml\f[] flag is used, it will be rendered using+mathml in an \f[C]inlineequation\f[] or \f[C]informalequation\f[] tag. Otherwise it will be rendered, if possible, using unicode characters. .RS .RE@@ -1260,38 +1450,46 @@ .RS .RE .TP-.B HTML, Slidy, Slideous, DZSlides, S5, EPUB-The way math is rendered in HTML will depend on the command-line options-selected:+.B FictionBook2+If the \f[C]\-\-webtex\f[] option is used, formulas are rendered as+images using Google Charts or other compatible web service, downloaded+and embedded in the e\-book.+Otherwise, they will appear verbatim. .RS+.RE+.TP+.B HTML, Slidy, DZSlides, S5, EPUB+The way math is rendered in HTML will depend on the command\-line+options selected:+.RS .IP "1." 3 The default is to render TeX math as far as possible using unicode characters, as with RTF, DocBook, and OpenDocument output. Formulas are put inside a \f[C]span\f[] with \f[C]class="math"\f[], so that they may be styled differently from the surrounding text if needed. .IP "2." 3-If the \f[C]--latexmathml\f[] option is used, TeX math will be displayed-between $ or $$ characters and put in \f[C]<span>\f[] tags with class-\f[C]LaTeX\f[].+If the \f[C]\-\-latexmathml\f[] option is used, TeX math will be+displayed between \f[C]$\f[] or \f[C]$$\f[] characters and put in+\f[C]<span>\f[] tags with class \f[C]LaTeX\f[]. The LaTeXMathML script will be used to render it as formulas. (This trick does not work in all browsers, but it works in Firefox. In browsers that do not support LaTeXMathML, TeX math will appear-verbatim between $ characters.)+verbatim between \f[C]$\f[] characters.) .IP "3." 3-If the \f[C]--jsmath\f[] option is used, TeX math will be put inside+If the \f[C]\-\-jsmath\f[] option is used, TeX math will be put inside \f[C]<span>\f[] tags (for inline math) or \f[C]<div>\f[] tags (for display math) with class \f[C]math\f[]. The jsMath script will be used to render it. .IP "4." 3-If the \f[C]--mimetex\f[] option is used, the mimeTeX CGI script will be-called to generate images for each TeX formula.+If the \f[C]\-\-mimetex\f[] option is used, the mimeTeX CGI script will+be called to generate images for each TeX formula. This should work in all browsers.-The \f[C]--mimetex\f[] option takes an optional URL as argument.+The \f[C]\-\-mimetex\f[] option takes an optional URL as argument. If no URL is specified, it will be assumed that the mimeTeX CGI script-is at \f[C]/cgi-bin/mimetex.cgi\f[].+is at \f[C]/cgi\-bin/mimetex.cgi\f[]. .IP "5." 3-If the \f[C]--gladtex\f[] option is used, TeX formulas will be enclosed-in \f[C]<eq>\f[] tags in the HTML output.+If the \f[C]\-\-gladtex\f[] option is used, TeX formulas will be+enclosed in \f[C]<eq>\f[] tags in the HTML output. The resulting \f[C]htex\f[] file may then be processed by gladTeX, which will produce image files for each formula and an \f[C]html\f[] file with links to these images.@@ -1300,31 +1498,41 @@ .IP .nf \f[C]-pandoc\ -s\ --gladtex\ myfile.txt\ -o\ myfile.htex-gladtex\ -d\ myfile-images\ myfile.htex-#\ produces\ myfile.html\ and\ images\ in\ myfile-images+pandoc\ \-s\ \-\-gladtex\ myfile.txt\ \-o\ myfile.htex+gladtex\ \-d\ myfile\-images\ myfile.htex+#\ produces\ myfile.html\ and\ images\ in\ myfile\-images \f[] .fi .RE .IP "6." 3-If the \f[C]--webtex\f[] option is used, TeX formulas will be converted-to \f[C]<img>\f[] tags that link to an external script that converts-formulas to images.-The formula will be URL-encoded and concatenated with the URL provided.+If the \f[C]\-\-webtex\f[] option is used, TeX formulas will be+converted to \f[C]<img>\f[] tags that link to an external script that+converts formulas to images.+The formula will be URL\-encoded and concatenated with the URL provided. If no URL is specified, the Google Chart API will be used (\f[C]http://chart.apis.google.com/chart?cht=tx&chl=\f[]).+.IP "7." 3+If the \f[C]\-\-mathjax\f[] option is used, TeX math will be displayed+between \f[C]\\(...\\)\f[] (for inline math) or \f[C]\\[...\\]\f[] (for+display math) and put in \f[C]<span>\f[] tags with class \f[C]math\f[].+The MathJax script will be used to render it as formulas. .RE .SH RAW HTML .PP+\f[B]Extension: \f[C]raw_html\f[]\f[]+.PP Markdown allows you to insert raw HTML (or DocBook) anywhere in a document (except verbatim contexts, where \f[C]<\f[], \f[C]>\f[], and \f[C]&\f[] are interpreted literally).+(Techncially this is not an extension, since standard markdown allows+it, but it has been made an extension so that it can be disabled if+desired.) .PP The raw HTML is passed through unchanged in HTML, S5, Slidy, Slideous, DZSlides, EPUB, Markdown, and Textile output, and suppressed in other formats. .PP-\f[I]Pandoc extension\f[].+\f[B]Extension: \f[C]markdown_in_html_blocks\f[]\f[] .PP Standard markdown allows you to include HTML "blocks": blocks of HTML between balanced tags that are separated from the surrounding text with@@ -1332,8 +1540,9 @@ Within these blocks, everything is interpreted as HTML, not markdown; so (for example), \f[C]*\f[] does not signify emphasis. .PP-Pandoc behaves this way when \f[C]--strict\f[] is specified; but by-default, pandoc interprets material between HTML block tags as markdown.+Pandoc behaves this way when the \f[C]markdown_strict\f[] format is+used; but by default, pandoc interprets material between HTML block tags+as markdown. Thus, for example, Pandoc will turn .IP .nf@@ -1372,7 +1581,7 @@ markdown. .SH RAW TEX .PP-\f[I]Pandoc extension\f[].+\f[B]Extension: \f[C]raw_tex\f[]\f[] .PP In addition to raw HTML, pandoc allows raw LaTeX, TeX, and ConTeXt to be included in a document.@@ -1392,9 +1601,9 @@ \f[C] \\begin{tabular}{|l|l|}\\hline Age\ &\ Frequency\ \\\\\ \\hline-18--25\ \ &\ 15\ \\\\-26--35\ \ &\ 33\ \\\\\ -36--45\ \ &\ 22\ \\\\\ \\hline+18\-\-25\ \ &\ 15\ \\\\+26\-\-35\ \ &\ 33\ \\\\+36\-\-45\ \ &\ 22\ \\\\\ \\hline \\end{tabular} \f[] .fi@@ -1404,8 +1613,10 @@ .PP Inline LaTeX is ignored in output formats other than Markdown, LaTeX, and ConTeXt.-.SS Macros+.SH LATEX MACROS .PP+\f[B]Extension: \f[C]latex_macros\f[]\f[]+.PP For output formats other than LaTeX, pandoc will parse LaTeX \f[C]\\newcommand\f[] and \f[C]\\renewcommand\f[] definitions and apply the resulting macros to all LaTeX math.@@ -1461,12 +1672,10 @@ .PP The link consists of link text in square brackets, followed by a label in square brackets.-(There can be space between the two.)- The link definition must begin at the left margin or indented no more-than three spaces.-It consists of the bracketed label, followed by a colon and a space,-followed by the URL, and optionally (after a space) a link title either-in quotes or in parentheses.+(There can be space between the two.) The link definition consists of+the bracketed label, followed by a colon and a space, followed by the+URL, and optionally (after a space) a link title either in quotes or in+parentheses. .PP Here are some examples: .IP@@ -1517,6 +1726,21 @@ [my\ website]:\ http://foo.bar.baz \f[] .fi+.PP+Note: In \f[C]Markdown.pl\f[] and most other markdown implementations,+reference link definitions cannot occur in nested constructions such as+list items or block quotes.+Pandoc lifts this arbitrary seeming restriction.+So the following is fine in pandoc, though not in most other+implementations:+.IP+.nf+\f[C]+>\ My\ block\ [quote].+>+>\ [quote]:\ /foo+\f[]+.fi .SS Internal links .PP To link to another section of the same document, use the automatically@@ -1558,14 +1782,13 @@ .fi .SS Pictures with captions .PP-\f[I]Pandoc extension\f[].+\f[B]Extension: \f[C]implicit_figures\f[]\f[] .PP An image occurring by itself in a paragraph will be rendered as a figure with a caption.[4] (In LaTeX, a figure environment will be used; in HTML, the image will be placed in a \f[C]div\f[] with class \f[C]figure\f[], together with a caption in a \f[C]p\f[] with class-\f[C]caption\f[].)- The image\[aq]s alt text will be used as the caption.+\f[C]caption\f[].) The image\[aq]s alt text will be used as the caption. .IP .nf \f[C]@@ -1579,12 +1802,12 @@ .IP .nf \f[C]-![This\ image\ won\[aq]t\ be\ a\ figure](/url/of/image.png)\\\ +![This\ image\ won\[aq]t\ be\ a\ figure](/url/of/image.png)\\ \f[] .fi .SH FOOTNOTES .PP-\f[I]Pandoc extension\f[].+\f[B]Extension: \f[C]footnotes\f[]\f[] .PP Pandoc\[aq]s markdown allows footnotes, using the following syntax: .IP@@ -1596,14 +1819,14 @@ [^longnote]:\ Here\[aq]s\ one\ with\ multiple\ blocks. -\ \ \ \ Subsequent\ paragraphs\ are\ indented\ to\ show\ that\ they\ +\ \ \ \ Subsequent\ paragraphs\ are\ indented\ to\ show\ that\ they belong\ to\ the\ previous\ footnote. \ \ \ \ \ \ \ \ {\ some.code\ } \ \ \ \ The\ whole\ paragraph\ can\ be\ indented,\ or\ just\ the\ first-\ \ \ \ line.\ \ In\ this\ way,\ multi-paragraph\ footnotes\ work\ like-\ \ \ \ multi-paragraph\ list\ items.+\ \ \ \ line.\ \ In\ this\ way,\ multi\-paragraph\ footnotes\ work\ like+\ \ \ \ multi\-paragraph\ list\ items. This\ paragraph\ won\[aq]t\ be\ part\ of\ the\ note,\ because\ it isn\[aq]t\ indented.@@ -1617,9 +1840,10 @@ .PP The footnotes themselves need not be placed at the end of the document. They may appear anywhere except inside other block elements (lists,-block quotes, tables, etc.)-\&.+block quotes, tables, etc.). .PP+\f[B]Extension: \f[C]inline_notes\f[]\f[]+.PP Inline footnotes are also allowed (though, unlike regular notes, they cannot contain multiple paragraphs). The syntax is as follows:@@ -1635,10 +1859,10 @@ Inline and regular footnotes may be mixed freely. .SH CITATIONS .PP-\f[I]Pandoc extension\f[].+\f[B]Extension: \f[C]citations\f[]\f[] .PP Pandoc can automatically generate citations and a bibliography in a-number of styles (using Andrea Rossato\[aq]s \f[C]hs-citeproc\f[]).+number of styles (using Andrea Rossato\[aq]s \f[C]hs\-citeproc\f[]). In order to use this feature, you will need a bibliographic database in one of the following formats: .PP@@ -1657,11 +1881,16 @@ \&.mods T} T{-BibTeX/BibLaTeX+BibLaTeX T}@T{ \&.bib T} T{+BibTeX+T}@T{+\&.bibtex+T}+T{ RIS T}@T{ \&.ris@@ -1698,19 +1927,22 @@ T} .TE .PP+Note that \f[C]\&.bib\f[] can generally be used with both BibTeX and+BibLaTeX files, but you can use \f[C]\&.bibtex\f[] to force BibTeX.+.PP You will need to specify the bibliography file using the-\f[C]--bibliography\f[] command-line option (which may be repeated if+\f[C]\-\-bibliography\f[] command\-line option (which may be repeated if you have several bibliographies). .PP-By default, pandoc will use a Chicago author-date format for citations+By default, pandoc will use a Chicago author\-date format for citations and references.-To use another style, you will need to use the \f[C]--csl\f[] option to-specify a CSL 1.0 style file.+To use another style, you will need to use the \f[C]\-\-csl\f[] option+to specify a CSL 1.0 style file. A primer on creating and modifying CSL styles can be found at-\f[C]http://citationstyles.org/downloads/primer.html\f[].+http://citationstyles.org/downloads/primer.html. A repository of CSL styles can be found at-\f[C]https://github.com/citation-style-language/styles\f[].-See also \f[C]http://zotero.org/styles\f[] for easy browsing.+https://github.com/citation\-style\-language/styles.+See also http://zotero.org/styles for easy browsing. .PP Citations go inside square brackets and are separated by semicolons. Each citation must have a key, composed of \[aq]\@\[aq] + the citation@@ -1720,25 +1952,25 @@ .IP .nf \f[C]-Blah\ blah\ [see\ \@doe99,\ pp.\ 33-35;\ also\ \@smith04,\ ch.\ 1].+Blah\ blah\ [see\ \@doe99,\ pp.\ 33\-35;\ also\ \@smith04,\ ch.\ 1]. -Blah\ blah\ [\@doe99,\ pp.\ 33-35,\ 38-39\ and\ *passim*].+Blah\ blah\ [\@doe99,\ pp.\ 33\-35,\ 38\-39\ and\ *passim*]. Blah\ blah\ [\@smith04;\ \@doe99]. \f[] .fi .PP-A minus sign (\f[C]-\f[]) before the \f[C]\@\f[] will suppress mention+A minus sign (\f[C]\-\f[]) before the \f[C]\@\f[] will suppress mention of the author in the citation. This can be useful when the author is already mentioned in the text: .IP .nf \f[C]-Smith\ says\ blah\ [-\@smith04].+Smith\ says\ blah\ [\-\@smith04]. \f[] .fi .PP-You can also write an in-text citation, as follows:+You can also write an in\-text citation, as follows: .IP .nf \f[C]
@@ -1,5 +1,5 @@ Name: pandoc-Version: 1.9.4.5+Version: 1.10 Cabal-Version: >= 1.10 Build-Type: Custom License: GPL@@ -16,11 +16,12 @@ Description: Pandoc is a Haskell library for converting from one markup format to another, and a command-line tool that uses this library. It can read markdown and (subsets of) HTML,- reStructuredText, LaTeX, DocBook, and Textile, and it can write- markdown, reStructuredText, HTML, LaTeX, ConTeXt, Docbook,- OpenDocument, ODT, Word docx, RTF, MediaWiki, Textile,- groff man pages, plain text, Emacs Org-Mode, AsciiDoc, EPUB,- and S5, Slidy and Slideous HTML slide shows.+ reStructuredText, LaTeX, DocBook, MediaWiki markup,+ and Textile, and it can write markdown, reStructuredText,+ HTML, LaTeX, ConTeXt, Docbook, OpenDocument, ODT,+ Word docx, RTF, MediaWiki, Textile, groff man pages,+ plain text, Emacs Org-Mode, AsciiDoc, EPUB (v2 and v3),+ FictionBook2, and S5, Slidy and Slideous HTML slide shows. . Pandoc extends standard markdown syntax with footnotes, embedded LaTeX, definition lists, tables, and other@@ -37,55 +38,58 @@ only adding a reader or writer. Data-Files: -- templates- templates/default.html, templates/default.html5,- templates/default.docbook, templates/default.beamer,- templates/default.opendocument, templates/default.latex,- templates/default.context, templates/default.texinfo,- templates/default.man, templates/default.markdown,- templates/default.rst, templates/default.plain,- templates/default.mediawiki, templates/default.rtf,- templates/default.s5, templates/default.slidy,- templates/default.slideous,- templates/default.dzslides, templates/default.asciidoc,- templates/default.textile, templates/default.org,- templates/epub-titlepage.html, templates/epub-page.html,- templates/epub-coverimage.html,+ data/templates/default.html, data/templates/default.html5,+ data/templates/default.docbook, data/templates/default.beamer,+ data/templates/default.opendocument,+ data/templates/default.latex,+ data/templates/default.context,+ data/templates/default.texinfo,+ data/templates/default.man,+ data/templates/default.markdown,+ data/templates/default.rst, data/templates/default.plain,+ data/templates/default.mediawiki, data/templates/default.rtf,+ data/templates/default.s5, data/templates/default.slidy,+ data/templates/default.slideous,+ data/templates/default.dzslides,+ data/templates/default.asciidoc,+ data/templates/default.textile, data/templates/default.org,+ data/templates/default.epub, data/templates/default.epub3, -- data for ODT writer- reference.odt,+ data/reference.odt, -- data for docx writer- reference.docx,+ data/reference.docx, -- stylesheet for EPUB writer- epub.css,+ data/epub.css, -- data for LaTeXMathML writer data/LaTeXMathML.js, data/MathMLinHTML.js, -- data for S5 writer- s5/default/slides.js,- s5/default/s5-core.css,- s5/default/framing.css,- s5/default/pretty.css,- s5/default/opera.css,- s5/default/outline.css,- s5/default/print.css,- s5/default/slides.css,- s5/default/iepngfix.htc,- s5/default/blank.gif,- s5/default/bodybg.gif,+ data/s5/default/slides.js,+ data/s5/default/s5-core.css,+ data/s5/default/framing.css,+ data/s5/default/pretty.css,+ data/s5/default/opera.css,+ data/s5/default/outline.css,+ data/s5/default/print.css,+ data/s5/default/slides.css,+ data/s5/default/iepngfix.htc,+ data/s5/default/blank.gif,+ data/s5/default/bodybg.gif, -- data for slidy writer- slidy/styles/slidy.css,- slidy/scripts/slidy.js.gz,- slidy/graphics/fold.gif,- slidy/graphics/unfold.gif,- slidy/graphics/nofold-dim.gif,- slidy/graphics/unfold-dim.gif,- slidy/graphics/fold-dim.gif,+ data/slidy/styles/slidy.css,+ data/slidy/scripts/slidy.js.gz,+ data/slidy/graphics/fold.gif,+ data/slidy/graphics/unfold.gif,+ data/slidy/graphics/nofold-dim.gif,+ data/slidy/graphics/unfold-dim.gif,+ data/slidy/graphics/fold-dim.gif, -- data for slideous writer- slideous/slideous.css,- slideous/slideous.js,+ data/slideous/slideous.css,+ data/slideous/slideous.js, -- data for dzslides writer- dzslides/template.html,+ data/dzslides/template.html, -- data for citeproc- default.csl,+ data/default.csl, -- documentation README, INSTALL, COPYRIGHT, BUGS, changelog Extra-Source-Files:@@ -95,8 +99,6 @@ -- generated man pages (produced post-build) man/man1/pandoc.1, man/man5/pandoc_markdown.5,- -- benchmarks- Benchmark.hs, -- tests tests/bodybg.gif, tests/docbook-reader.docbook@@ -121,6 +123,8 @@ tests/markdown-citations.mhra.txt, tests/markdown-citations.ieee.txt, tests/textile-reader.textile,+ tests/mediawiki-reader.wiki,+ tests/mediawiki-reader.native, tests/rst-reader.native, tests/rst-reader.rst, tests/s5.basic.html,@@ -165,6 +169,7 @@ tests/writer.rtf, tests/writer.texinfo, tests/lhs-test.native,+ tests/lhs-test-markdown.native, tests/lhs-test.markdown, tests/lhs-test.markdown+lhs, tests/lhs-test.rst,@@ -173,7 +178,9 @@ tests/lhs-test.latex+lhs, tests/lhs-test.html, tests/lhs-test.html+lhs,- tests/lhs-test.fragment.html+lhs+ tests/lhs-test.fragment.html+lhs,+ tests/pipe-tables.txt,+ tests/pipe-tables.native Extra-Tmp-Files: man/man1/pandoc.1, man/man5/pandoc_markdown.5 @@ -181,30 +188,26 @@ type: git location: git://github.com/jgm/pandoc.git -Flag executable- Description: Build the pandoc executable.- Default: True-Flag library- Description: Build the pandoc library.- Default: True Flag blaze_html_0_5 Description: Use blaze-html 0.5 and blaze-markup 0.5+ Default: True+Flag embed_data_files+ Description: Embed data files in binary for relocatable executable. Default: False Library- -- Note: the following is duplicated in all stanzas.- -- It needs to be duplicated because of the library & executable flags.- -- BEGIN DUPLICATED SECTION- Build-Depends: containers >= 0.1 && < 0.6,+ Build-Depends: base >= 4.2 && <5,+ syb >= 0.1 && < 0.4,+ containers >= 0.1 && < 0.6, parsec >= 3.1 && < 3.2, mtl >= 1.1 && < 2.2, network >= 2 && < 2.5, filepath >= 1.1 && < 1.4, process >= 1 && < 1.2, directory >= 1 && < 1.3,- bytestring >= 0.9 && < 1.0,+ bytestring >= 0.9 && < 0.11,+ text >= 0.11 && < 0.12, zip-archive >= 0.1.1.7 && < 0.2,- utf8-string >= 0.3 && < 0.4, old-locale >= 1 && < 1.1, time >= 1.2 && < 1.5, HTTP >= 4000.0.5 && < 4000.3,@@ -212,13 +215,14 @@ xml >= 1.3.12 && < 1.4, random >= 1 && < 1.1, extensible-exceptions >= 0.1 && < 0.2,- citeproc-hs >= 0.3.4 && < 0.4,- pandoc-types >= 1.9.0.2 && < 1.10,+ citeproc-hs >= 0.3.6 && < 0.4,+ pandoc-types >= 1.10 && < 1.11, json >= 0.4 && < 0.8, tagsoup >= 0.12.5 && < 0.13, base64-bytestring >= 0.1 && < 1.1, zlib >= 0.5 && < 0.6, highlighting-kate >= 0.5.1 && < 0.6,+ data-default >= 0.4 && < 0.6, temporary >= 1.1 && < 1.2 if flag(blaze_html_0_5) build-depends:@@ -227,17 +231,17 @@ else build-depends: blaze-html >= 0.4.3.0 && < 0.5- if impl(ghc >= 6.10)- Build-depends: base >= 4 && < 5, syb >= 0.1 && < 0.4- else- Build-depends: base >= 3 && < 4+ if flag(embed_data_files)+ build-depends: file-embed >= 0.0.4.7 && < 0.1,+ template-haskell >= 2.4 && < 2.9+ cpp-options: -DEMBED_DATA_FILES if impl(ghc >= 7.0.1)- Ghc-Options: -O2 -rtsopts -Wall -fno-warn-unused-do-bind -dno-debug-output+ Ghc-Options: -rtsopts -Wall -fno-warn-unused-do-bind else if impl(ghc >= 6.12)- Ghc-Options: -O2 -Wall -fno-warn-unused-do-bind -dno-debug-output+ Ghc-Options: -Wall -fno-warn-unused-do-bind else- Ghc-Options: -O2 -Wall+ Ghc-Options: -Wall if impl(ghc >= 7.0.1) Ghc-Prof-Options: -auto-all -caf-all -rtsopts else@@ -249,9 +253,9 @@ RelaxedPolyRec, DeriveDataTypeable, TypeSynonymInstances, FlexibleInstances Hs-Source-Dirs: src- -- END DUPLICATED SECTION Exposed-Modules: Text.Pandoc,+ Text.Pandoc.Options, Text.Pandoc.Pretty, Text.Pandoc.Shared, Text.Pandoc.Parsing,@@ -259,6 +263,7 @@ Text.Pandoc.Readers.HTML, Text.Pandoc.Readers.LaTeX, Text.Pandoc.Readers.Markdown,+ Text.Pandoc.Readers.MediaWiki, Text.Pandoc.Readers.RST, Text.Pandoc.Readers.DocBook, Text.Pandoc.Readers.TeXMath,@@ -282,95 +287,60 @@ Text.Pandoc.Writers.ODT, Text.Pandoc.Writers.Docx, Text.Pandoc.Writers.EPUB,+ Text.Pandoc.Writers.FB2, Text.Pandoc.PDF,+ Text.Pandoc.UTF8, Text.Pandoc.Templates,+ Text.Pandoc.XML, Text.Pandoc.Biblio,- Text.Pandoc.UTF8, Text.Pandoc.SelfContained- Other-Modules: Text.Pandoc.XML,- Text.Pandoc.MIME,+ Other-Modules: Text.Pandoc.MIME, Text.Pandoc.UUID, Text.Pandoc.ImageSize, Text.Pandoc.Slides, Paths_pandoc - if flag(library)- Buildable: True- else- Buildable: False+ Buildable: True Executable pandoc- -- Note: the following is duplicated in all stanzas.- -- It needs to be duplicated because of the library & executable flags.- -- BEGIN DUPLICATED SECTION- Build-Depends: containers >= 0.1 && < 0.6,- parsec >= 3.1 && < 3.2,- mtl >= 1.1 && < 2.2,- network >= 2 && < 2.5,- filepath >= 1.1 && < 1.4,- process >= 1 && < 1.2,+ Build-Depends: pandoc,+ base >= 4.2 && <5, directory >= 1 && < 1.3,- bytestring >= 0.9 && < 1.0,- zip-archive >= 0.1.1.7 && < 0.2,- utf8-string >= 0.3 && < 0.4,- old-locale >= 1 && < 1.1,- time >= 1.2 && < 1.5,- HTTP >= 4000.0.5 && < 4000.3,- texmath >= 0.6.0.2 && < 0.7,- xml >= 1.3.12 && < 1.4,- random >= 1 && < 1.1,+ filepath >= 1.1 && < 1.4,+ network >= 2 && < 2.5,+ text >= 0.11 && < 0.12,+ bytestring >= 0.9 && < 0.11, extensible-exceptions >= 0.1 && < 0.2,- citeproc-hs >= 0.3.4 && < 0.4,- pandoc-types >= 1.9.0.2 && < 1.10,- json >= 0.4 && < 0.8,- tagsoup >= 0.12.5 && < 0.13,- base64-bytestring >= 0.1 && < 1.1,- zlib >= 0.5 && < 0.6, highlighting-kate >= 0.5.1 && < 0.6,- temporary >= 1.1 && < 1.2- if flag(blaze_html_0_5)- build-depends:- blaze-html >= 0.5 && < 0.6,- blaze-markup >= 0.5.1 && < 0.6- else- build-depends:- blaze-html >= 0.4.3.0 && < 0.5- if impl(ghc >= 6.10)- Build-depends: base >= 4 && < 5, syb >= 0.1 && < 0.4- else- Build-depends: base >= 3 && < 4+ HTTP >= 4000.0.5 && < 4000.3,+ citeproc-hs >= 0.3.6 && < 0.4 if impl(ghc >= 7.0.1)- Ghc-Options: -O2 -rtsopts -threaded -Wall -fno-warn-unused-do-bind -dno-debug-output+ Ghc-Options: -rtsopts -Wall -fno-warn-unused-do-bind else if impl(ghc >= 6.12)- Ghc-Options: -O2 -Wall -threaded -fno-warn-unused-do-bind -dno-debug-output+ Ghc-Options: -Wall -fno-warn-unused-do-bind else- Ghc-Options: -O2 -Wall -threaded+ Ghc-Options: -Wall if impl(ghc >= 7.0.1) Ghc-Prof-Options: -auto-all -caf-all -rtsopts else Ghc-Prof-Options: -auto-all -caf-all Default-Language: Haskell98 Default-Extensions: CPP- Other-Extensions: PatternGuards, OverloadedStrings,- ScopedTypeVariables, GeneralizedNewtypeDeriving,- RelaxedPolyRec, DeriveDataTypeable, TypeSynonymInstances,- FlexibleInstances- Hs-Source-Dirs: src- -- END DUPLICATED SECTION-- Main-Is: pandoc.hs- if flag(executable)- Buildable: True- else- Buildable: False+ Other-Extensions: PatternGuards, OverloadedStrings,+ ScopedTypeVariables, GeneralizedNewtypeDeriving,+ RelaxedPolyRec, DeriveDataTypeable, TypeSynonymInstances,+ FlexibleInstances+ Hs-Source-Dirs: .+ Main-Is: pandoc.hs+ Buildable: True -- NOTE: A trick in Setup.hs makes sure this won't be installed: Executable make-pandoc-man-pages- Main-Is: make-pandoc-man-pages.hs+ Main-Is: make-pandoc-man-pages.hs Hs-Source-Dirs: man- Build-Depends: base >= 4.2 && < 5,- pandoc,+ Build-Depends: pandoc,+ base >= 4.2 && < 5, directory >= 1 && < 1.3, filepath >= 1.1 && < 1.4, old-time >= 1.1 && < 1.2,@@ -382,54 +352,64 @@ Type: exitcode-stdio-1.0 Main-Is: test-pandoc.hs Hs-Source-Dirs: tests- if impl(ghc >= 6.10)- Build-depends: base >= 4 && < 5, syb >= 0.1 && < 0.4- else- Build-depends: base >= 3 && < 4+ Build-Depends: base >= 4.2 && < 5,+ syb >= 0.1 && < 0.4,+ pandoc,+ pandoc-types >= 1.10 && < 1.11,+ bytestring >= 0.9 && < 0.11,+ text >= 0.11 && < 0.12,+ directory >= 1 && < 1.3,+ filepath >= 1.1 && < 1.4,+ process >= 1 && < 1.2,+ Diff >= 0.2 && < 0.3,+ test-framework >= 0.3 && < 0.7,+ test-framework-hunit >= 0.2 && < 0.3,+ test-framework-quickcheck2 >= 0.2.9 && < 0.3,+ QuickCheck >= 2.4 && < 2.6,+ HUnit >= 1.2 && < 1.3,+ template-haskell >= 2.4 && < 2.9,+ containers >= 0.1 && < 0.6,+ ansi-terminal == 0.5.*+ Other-Modules: Tests.Old+ Tests.Helpers+ Tests.Arbitrary+ Tests.Shared+ Tests.Readers.LaTeX+ Tests.Readers.Markdown+ Tests.Readers.RST+ Tests.Writers.Native+ Tests.Writers.ConTeXt+ Tests.Writers.HTML+ Tests.Writers.Markdown+ Tests.Writers.LaTeX if impl(ghc >= 7.0.1)- Ghc-Options: -O2 -rtsopts -threaded -Wall -fno-warn-unused-do-bind -dno-debug-output+ Ghc-Options: -rtsopts -Wall -fno-warn-unused-do-bind else if impl(ghc >= 6.12)- Ghc-Options: -O2 -Wall -threaded -fno-warn-unused-do-bind -dno-debug-output+ Ghc-Options: -Wall -fno-warn-unused-do-bind else- Ghc-Options: -O2 -Wall -threaded- if impl(ghc >= 7.0.1)- Ghc-Prof-Options: -auto-all -caf-all -rtsopts+ Ghc-Options: -Wall+ if impl(ghc >= 7)+ cpp-options: -D_LIT=lit else- Ghc-Prof-Options: -auto-all -caf-all+ cpp-options: -D_LIT=$lit Default-Language: Haskell98- Default-Extensions: CPP- Other-Extensions: PatternGuards, OverloadedStrings,- ScopedTypeVariables, GeneralizedNewtypeDeriving,- RelaxedPolyRec, DeriveDataTypeable, TypeSynonymInstances,- FlexibleInstances- if impl(ghc >= 7)- cpp-options: -D_LIT=lit+ Default-Extensions: CPP, TemplateHaskell, QuasiQuotes++benchmark benchmark-pandoc+ Type: exitcode-stdio-1.0+ Main-Is: benchmark-pandoc.hs+ Hs-Source-Dirs: benchmark+ Build-Depends: pandoc,+ base >= 4.2 && < 5,+ syb >= 0.1 && < 0.4,+ criterion >= 0.5 && < 0.7,+ json >= 0.4 && < 0.8+ if impl(ghc >= 7.0.1)+ Ghc-Options: -rtsopts -Wall -fno-warn-unused-do-bind else- cpp-options: -D_LIT=$lit- Other-Extensions: TemplateHaskell, QuasiQuotes- Build-Depends: pandoc, Diff, test-framework >= 0.3 && < 0.7,- pandoc-types >= 1.9.0.2 && < 1.10,- test-framework-hunit >= 0.2 && < 0.3,- test-framework-quickcheck2 >= 0.2.9 && < 0.3,- process >= 1 && < 1.2,- filepath >= 1.1 && < 1.4,- directory >= 1 && < 1.3,- bytestring >= 0.9 && < 1.0,- utf8-string >= 0.3 && < 0.4,- QuickCheck >= 2.4 && < 2.6,- HUnit >= 1.2 && < 1.3,- template-haskell >= 2.4 && < 2.9,- ansi-terminal == 0.5.*- Other-Modules: Tests.Old- Tests.Helpers- Tests.Arbitrary- Tests.Shared- Tests.Readers.LaTeX- Tests.Readers.Markdown- Tests.Readers.RST- Tests.Writers.Native- Tests.Writers.ConTeXt- Tests.Writers.HTML- Tests.Writers.Markdown- Tests.Writers.LaTeX+ if impl(ghc >= 6.12)+ Ghc-Options: -Wall -fno-warn-unused-do-bind+ else+ Ghc-Options: -Wall+ Default-Language: Haskell98
@@ -0,0 +1,1093 @@+{-# LANGUAGE CPP #-}+{-+Copyright (C) 2006-2013 John MacFarlane <jgm@berkeley.edu>++This program is free software; you can redistribute it and/or modify+it under the terms of the GNU General Public License as published by+the Free Software Foundation; either version 2 of the License, or+(at your option) any later version.++This program is distributed in the hope that it will be useful,+but WITHOUT ANY WARRANTY; without even the implied warranty of+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+GNU General Public License for more details.++You should have received a copy of the GNU General Public License+along with this program; if not, write to the Free Software+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA+-}++{- |+ Module : Main+ Copyright : Copyright (C) 2006-2013 John MacFarlane+ License : GNU GPL, version 2 or above++ Maintainer : John MacFarlane <jgm@berkeley@edu>+ Stability : alpha+ Portability : portable++Parses command-line options and calls the appropriate readers and+writers.+-}+module Main where+import Text.Pandoc+import Text.Pandoc.PDF (tex2pdf)+import Text.Pandoc.Readers.LaTeX (handleIncludes)+import Text.Pandoc.Shared ( tabFilter, readDataFileUTF8, safeRead,+ headerShift, normalize, err, warn )+import Text.Pandoc.XML ( toEntities, fromEntities )+import Text.Pandoc.SelfContained ( makeSelfContained )+import Text.Pandoc.Highlighting ( languages, Style, tango, pygments,+ espresso, zenburn, kate, haddock, monochrome )+import System.Environment ( getArgs, getProgName )+import System.Exit ( exitWith, ExitCode (..) )+import System.FilePath+import System.Console.GetOpt+import Data.Char ( toLower )+import Data.List ( intercalate, isPrefixOf )+import System.Directory ( getAppUserDataDirectory, doesFileExist, findExecutable )+import System.IO ( stdout )+import System.IO.Error ( isDoesNotExistError )+import qualified Control.Exception as E+import Control.Exception.Extensible ( throwIO )+import qualified Text.Pandoc.UTF8 as UTF8+import qualified Text.CSL as CSL+import Control.Monad (when, unless, liftM)+import Network.HTTP (simpleHTTP, mkRequest, getResponseBody, RequestMethod(..))+import Network.URI (parseURI, isURI, URI(..))+import qualified Data.ByteString.Lazy as B+import Text.CSL.Reference (Reference(..))++copyrightMessage :: String+copyrightMessage = "\nCopyright (C) 2006-2013 John MacFarlane\n" +++ "Web: http://johnmacfarlane.net/pandoc\n" +++ "This is free software; see the source for copying conditions. There is no\n" +++ "warranty, not even for merchantability or fitness for a particular purpose."++compileInfo :: String+compileInfo =+ "\nCompiled with citeproc-hs " ++ VERSION_citeproc_hs ++ ", texmath " +++ VERSION_texmath ++ ", highlighting-kate " ++ VERSION_highlighting_kate +++ ".\nSyntax highlighting is supported for the following languages:\n " +++ wrapWords 4 78 languages++-- | Converts a list of strings into a single string with the items printed as+-- comma separated words in lines with a maximum line length.+wrapWords :: Int -> Int -> [String] -> String+wrapWords indent c = wrap' (c - indent) (c - indent)+ where wrap' _ _ [] = ""+ wrap' cols remaining (x:xs) = if remaining == cols+ then x ++ wrap' cols (remaining - length x) xs+ else if (length x + 1) > remaining+ then ",\n" ++ replicate indent ' ' ++ x ++ wrap' cols (cols - length x) xs+ else ", " ++ x ++ wrap' cols (remaining - (length x + 2)) xs++isTextFormat :: String -> Bool+isTextFormat s = takeWhile (`notElem` "+-") s `notElem` ["odt","docx","epub","epub3"]++-- | Data structure for command line options.+data Opt = Opt+ { optTabStop :: Int -- ^ Number of spaces per tab+ , optPreserveTabs :: Bool -- ^ Preserve tabs instead of converting to spaces+ , optStandalone :: Bool -- ^ Include header, footer+ , optReader :: String -- ^ Reader format+ , optWriter :: String -- ^ Writer format+ , optParseRaw :: Bool -- ^ Parse unconvertable HTML and TeX+ , optTableOfContents :: Bool -- ^ Include table of contents+ , optTransforms :: [Pandoc -> Pandoc] -- ^ Doc transforms to apply+ , optTemplate :: Maybe FilePath -- ^ Custom template+ , optVariables :: [(String,String)] -- ^ Template variables to set+ , optOutputFile :: String -- ^ Name of output file+ , optNumberSections :: Bool -- ^ Number sections in LaTeX+ , optSectionDivs :: Bool -- ^ Put sections in div tags in HTML+ , optIncremental :: Bool -- ^ Use incremental lists in Slidy/Slideous/S5+ , optSelfContained :: Bool -- ^ Make HTML accessible offline+ , optSmart :: Bool -- ^ Use smart typography+ , optOldDashes :: Bool -- ^ Parse dashes like pandoc <=1.8.2.1+ , optHtml5 :: Bool -- ^ Produce HTML5 in HTML+ , optHtmlQTags :: Bool -- ^ Use <q> tags in HTML+ , optHighlight :: Bool -- ^ Highlight source code+ , optHighlightStyle :: Style -- ^ Style to use for highlighted code+ , optChapters :: Bool -- ^ Use chapter for top-level sects+ , optHTMLMathMethod :: HTMLMathMethod -- ^ Method to print HTML math+ , optReferenceODT :: Maybe FilePath -- ^ Path of reference.odt+ , optReferenceDocx :: Maybe FilePath -- ^ Path of reference.docx+ , optEpubStylesheet :: Maybe String -- ^ EPUB stylesheet+ , optEpubMetadata :: String -- ^ EPUB metadata+ , optEpubFonts :: [FilePath] -- ^ EPUB fonts to embed+ , optEpubChapterLevel :: Int -- ^ Header level at which to split chapters+ , optTOCDepth :: Int -- ^ Number of levels to include in TOC+ , optDumpArgs :: Bool -- ^ Output command-line arguments+ , optIgnoreArgs :: Bool -- ^ Ignore command-line arguments+ , optReferenceLinks :: Bool -- ^ Use reference links in writing markdown, rst+ , optWrapText :: Bool -- ^ Wrap text+ , optColumns :: Int -- ^ Line length in characters+ , optPlugins :: [Pandoc -> IO Pandoc] -- ^ Plugins to apply+ , optEmailObfuscation :: ObfuscationMethod+ , optIdentifierPrefix :: String+ , optIndentedCodeClasses :: [String] -- ^ Default classes for indented code blocks+ , optDataDir :: Maybe FilePath+ , optCiteMethod :: CiteMethod -- ^ Method to output cites+ , optBibliography :: [String]+ , optCslFile :: Maybe FilePath+ , optAbbrevsFile :: Maybe FilePath+ , optListings :: Bool -- ^ Use listings package for code blocks+ , optLaTeXEngine :: String -- ^ Program to use for latex -> pdf+ , optSlideLevel :: Maybe Int -- ^ Header level that creates slides+ , optSetextHeaders :: Bool -- ^ Use atx headers for markdown level 1-2+ , optAscii :: Bool -- ^ Use ascii characters only in html+ , optTeXLigatures :: Bool -- ^ Use TeX ligatures for quotes/dashes+ }++-- | Defaults for command-line options.+defaultOpts :: Opt+defaultOpts = Opt+ { optTabStop = 4+ , optPreserveTabs = False+ , optStandalone = False+ , optReader = "" -- null for default reader+ , optWriter = "" -- null for default writer+ , optParseRaw = False+ , optTableOfContents = False+ , optTransforms = []+ , optTemplate = Nothing+ , optVariables = []+ , optOutputFile = "-" -- "-" means stdout+ , optNumberSections = False+ , optSectionDivs = False+ , optIncremental = False+ , optSelfContained = False+ , optSmart = False+ , optOldDashes = False+ , optHtml5 = False+ , optHtmlQTags = False+ , optHighlight = True+ , optHighlightStyle = pygments+ , optChapters = False+ , optHTMLMathMethod = PlainMath+ , optReferenceODT = Nothing+ , optReferenceDocx = Nothing+ , optEpubStylesheet = Nothing+ , optEpubMetadata = ""+ , optEpubFonts = []+ , optEpubChapterLevel = 1+ , optTOCDepth = 3+ , optDumpArgs = False+ , optIgnoreArgs = False+ , optReferenceLinks = False+ , optWrapText = True+ , optColumns = 72+ , optPlugins = []+ , optEmailObfuscation = JavascriptObfuscation+ , optIdentifierPrefix = ""+ , optIndentedCodeClasses = []+ , optDataDir = Nothing+ , optCiteMethod = Citeproc+ , optBibliography = []+ , optCslFile = Nothing+ , optAbbrevsFile = Nothing+ , optListings = False+ , optLaTeXEngine = "pdflatex"+ , optSlideLevel = Nothing+ , optSetextHeaders = True+ , optAscii = False+ , optTeXLigatures = True+ }++-- | A list of functions, each transforming the options data structure+-- in response to a command-line option.+options :: [OptDescr (Opt -> IO Opt)]+options =+ [ Option "fr" ["from","read"]+ (ReqArg+ (\arg opt -> return opt { optReader = map toLower arg })+ "FORMAT")+ ""++ , Option "tw" ["to","write"]+ (ReqArg+ (\arg opt -> return opt { optWriter = map toLower arg })+ "FORMAT")+ ""++ , Option "o" ["output"]+ (ReqArg+ (\arg opt -> return opt { optOutputFile = arg })+ "FILENAME")+ "" -- "Name of output file"++ , Option "" ["data-dir"]+ (ReqArg+ (\arg opt -> return opt { optDataDir = Just arg })+ "DIRECTORY") -- "Directory containing pandoc data files."+ ""++ , Option "" ["strict"]+ (NoArg+ (\opt -> do+ err 59 $ "The --strict option has been removed.\n" +++ "Use `markdown_strict' input or output format instead."+ return opt ))+ "" -- "Disable markdown syntax extensions"++ , Option "R" ["parse-raw"]+ (NoArg+ (\opt -> return opt { optParseRaw = True }))+ "" -- "Parse untranslatable HTML codes and LaTeX environments as raw"++ , Option "S" ["smart"]+ (NoArg+ (\opt -> return opt { optSmart = True }))+ "" -- "Use smart quotes, dashes, and ellipses"++ , Option "" ["old-dashes"]+ (NoArg+ (\opt -> return opt { optSmart = True+ , optOldDashes = True }))+ "" -- "Use smart quotes, dashes, and ellipses"++ , Option "" ["base-header-level"]+ (ReqArg+ (\arg opt ->+ case safeRead arg of+ Just t | t > 0 -> do+ let oldTransforms = optTransforms opt+ let shift = t - 1+ return opt{ optTransforms =+ headerShift shift : oldTransforms }+ _ -> err 19+ "base-header-level must be a number > 0")+ "NUMBER")+ "" -- "Headers base level"++ , Option "" ["indented-code-classes"]+ (ReqArg+ (\arg opt -> return opt { optIndentedCodeClasses = words $+ map (\c -> if c == ',' then ' ' else c) arg })+ "STRING")+ "" -- "Classes (whitespace- or comma-separated) to use for indented code-blocks"++ , Option "" ["normalize"]+ (NoArg+ (\opt -> return opt { optTransforms =+ normalize : optTransforms opt } ))+ "" -- "Normalize the Pandoc AST"++ , Option "p" ["preserve-tabs"]+ (NoArg+ (\opt -> return opt { optPreserveTabs = True }))+ "" -- "Preserve tabs instead of converting to spaces"++ , Option "" ["tab-stop"]+ (ReqArg+ (\arg opt ->+ case safeRead arg of+ Just t | t > 0 -> return opt { optTabStop = t }+ _ -> err 31+ "tab-stop must be a number greater than 0")+ "NUMBER")+ "" -- "Tab stop (default 4)"++ , Option "s" ["standalone"]+ (NoArg+ (\opt -> return opt { optStandalone = True }))+ "" -- "Include needed header and footer on output"++ , Option "" ["template"]+ (ReqArg+ (\arg opt -> do+ return opt{ optTemplate = Just arg,+ optStandalone = True })+ "FILENAME")+ "" -- "Use custom template"++ , Option "V" ["variable"]+ (ReqArg+ (\arg opt -> do+ let (key,val) = case break (`elem` ":=") arg of+ (k,_:v) -> (k,v)+ (k,_) -> (k,"true")+ return opt{ optVariables = (key,val) : optVariables opt })+ "KEY[:VALUE]")+ "" -- "Use custom template"++ , Option "D" ["print-default-template"]+ (ReqArg+ (\arg _ -> do+ templ <- getDefaultTemplate Nothing arg+ case templ of+ Right t -> UTF8.hPutStr stdout t+ Left e -> error $ show e+ exitWith ExitSuccess)+ "FORMAT")+ "" -- "Print default template for FORMAT"++ , Option "" ["no-wrap"]+ (NoArg+ (\opt -> return opt { optWrapText = False }))+ "" -- "Do not wrap text in output"++ , Option "" ["columns"]+ (ReqArg+ (\arg opt ->+ case safeRead arg of+ Just t | t > 0 -> return opt { optColumns = t }+ _ -> err 33 $+ "columns must be a number greater than 0")+ "NUMBER")+ "" -- "Length of line in characters"++ , Option "" ["toc", "table-of-contents"]+ (NoArg+ (\opt -> return opt { optTableOfContents = True }))+ "" -- "Include table of contents"++ , Option "" ["toc-depth"]+ (ReqArg+ (\arg opt -> do+ case safeRead arg of+ Just t | t >= 1 && t <= 6 ->+ return opt { optTOCDepth = t,+ optTableOfContents = True }+ _ -> err 57 $+ "TOC level must be a number between 1 and 6")+ "NUMBER")+ "" -- "Number of levels to include in TOC"++ , Option "" ["no-highlight"]+ (NoArg+ (\opt -> return opt { optHighlight = False }))+ "" -- "Don't highlight source code"++ , Option "" ["highlight-style"]+ (ReqArg+ (\arg opt -> do+ newStyle <- case map toLower arg of+ "pygments" -> return pygments+ "tango" -> return tango+ "espresso" -> return espresso+ "zenburn" -> return zenburn+ "kate" -> return kate+ "monochrome" -> return monochrome+ "haddock" -> return haddock+ _ -> err 39 $+ "Unknown style :" ++ arg+ return opt{ optHighlightStyle = newStyle })+ "STYLE")+ "" -- "Style for highlighted code"++ , Option "H" ["include-in-header"]+ (ReqArg+ (\arg opt -> do+ text <- UTF8.readFile arg+ -- add new ones to end, so they're included in order specified+ let newvars = optVariables opt ++ [("header-includes",text)]+ return opt { optVariables = newvars,+ optStandalone = True })+ "FILENAME")+ "" -- "File to include at end of header (implies -s)"++ , Option "B" ["include-before-body"]+ (ReqArg+ (\arg opt -> do+ text <- UTF8.readFile arg+ -- add new ones to end, so they're included in order specified+ let newvars = optVariables opt ++ [("include-before",text)]+ return opt { optVariables = newvars,+ optStandalone = True })+ "FILENAME")+ "" -- "File to include before document body"++ , Option "A" ["include-after-body"]+ (ReqArg+ (\arg opt -> do+ text <- UTF8.readFile arg+ -- add new ones to end, so they're included in order specified+ let newvars = optVariables opt ++ [("include-after",text)]+ return opt { optVariables = newvars,+ optStandalone = True })+ "FILENAME")+ "" -- "File to include after document body"++ , Option "" ["self-contained"]+ (NoArg+ (\opt -> return opt { optSelfContained = True,+ optVariables = ("slidy-url","slidy") :+ optVariables opt,+ optStandalone = True }))+ "" -- "Make slide shows include all the needed js and css"++ , Option "" ["offline"]+ (NoArg+ (\opt -> do warn $ "--offline is deprecated. Use --self-contained instead."+ return opt { optSelfContained = True,+ optStandalone = True }))+ "" -- "Make slide shows include all the needed js and css"+ -- deprecated synonym for --self-contained++ , Option "5" ["html5"]+ (NoArg+ (\opt -> do+ warn $ "--html5 is deprecated. "+ ++ "Use the html5 output format instead."+ return opt { optHtml5 = True }))+ "" -- "Produce HTML5 in HTML output"++ , Option "" ["html-q-tags"]+ (NoArg+ (\opt -> do+ return opt { optHtmlQTags = True }))+ "" -- "Use <q> tags for quotes in HTML"++ , Option "" ["ascii"]+ (NoArg+ (\opt -> return opt { optAscii = True }))+ "" -- "Use ascii characters only in HTML output"++ , Option "" ["reference-links"]+ (NoArg+ (\opt -> return opt { optReferenceLinks = True } ))+ "" -- "Use reference links in parsing HTML"++ , Option "" ["atx-headers"]+ (NoArg+ (\opt -> return opt { optSetextHeaders = False } ))+ "" -- "Use atx-style headers for markdown"++ , Option "" ["chapters"]+ (NoArg+ (\opt -> return opt { optChapters = True }))+ "" -- "Use chapter for top-level sections in LaTeX, DocBook"++ , Option "N" ["number-sections"]+ (NoArg+ (\opt -> return opt { optNumberSections = True }))+ "" -- "Number sections in LaTeX"++ , Option "" ["no-tex-ligatures"]+ (NoArg+ (\opt -> return opt { optTeXLigatures = False }))+ "" -- "Don't use tex ligatures for quotes, dashes"++ , Option "" ["listings"]+ (NoArg+ (\opt -> return opt { optListings = True }))+ "" -- "Use listings package for LaTeX code blocks"++ , Option "i" ["incremental"]+ (NoArg+ (\opt -> return opt { optIncremental = True }))+ "" -- "Make list items display incrementally in Slidy/Slideous/S5"++ , Option "" ["slide-level"]+ (ReqArg+ (\arg opt -> do+ case safeRead arg of+ Just t | t >= 1 && t <= 6 ->+ return opt { optSlideLevel = Just t }+ _ -> err 39 $+ "slide level must be a number between 1 and 6")+ "NUMBER")+ "" -- "Force header level for slides"++ , Option "" ["section-divs"]+ (NoArg+ (\opt -> return opt { optSectionDivs = True }))+ "" -- "Put sections in div tags in HTML"++ , Option "" ["email-obfuscation"]+ (ReqArg+ (\arg opt -> do+ method <- case arg of+ "references" -> return ReferenceObfuscation+ "javascript" -> return JavascriptObfuscation+ "none" -> return NoObfuscation+ _ -> err 6+ ("Unknown obfuscation method: " ++ arg)+ return opt { optEmailObfuscation = method })+ "none|javascript|references")+ "" -- "Method for obfuscating email in HTML"++ , Option "" ["id-prefix"]+ (ReqArg+ (\arg opt -> return opt { optIdentifierPrefix = arg })+ "STRING")+ "" -- "Prefix to add to automatically generated HTML identifiers"++ , Option "T" ["title-prefix"]+ (ReqArg+ (\arg opt -> do+ let newvars = ("title-prefix", arg) : optVariables opt+ return opt { optVariables = newvars,+ optStandalone = True })+ "STRING")+ "" -- "String to prefix to HTML window title"++ , Option "c" ["css"]+ (ReqArg+ (\arg opt -> do+ -- add new link to end, so it is included in proper order+ let newvars = optVariables opt ++ [("css",arg)]+ return opt { optVariables = newvars,+ optStandalone = True })+ "URL")+ "" -- "Link to CSS style sheet"++ , Option "" ["reference-odt"]+ (ReqArg+ (\arg opt -> do+ return opt { optReferenceODT = Just arg })+ "FILENAME")+ "" -- "Path of custom reference.odt"++ , Option "" ["reference-docx"]+ (ReqArg+ (\arg opt -> do+ return opt { optReferenceDocx = Just arg })+ "FILENAME")+ "" -- "Path of custom reference.docx"++ , Option "" ["epub-stylesheet"]+ (ReqArg+ (\arg opt -> do+ text <- UTF8.readFile arg+ return opt { optEpubStylesheet = Just text })+ "FILENAME")+ "" -- "Path of epub.css"++ , Option "" ["epub-cover-image"]+ (ReqArg+ (\arg opt ->+ return opt { optVariables =+ ("epub-cover-image", arg) : optVariables opt })+ "FILENAME")+ "" -- "Path of epub cover image"++ , Option "" ["epub-metadata"]+ (ReqArg+ (\arg opt -> do+ text <- UTF8.readFile arg+ return opt { optEpubMetadata = text })+ "FILENAME")+ "" -- "Path of epub metadata file"++ , Option "" ["epub-embed-font"]+ (ReqArg+ (\arg opt -> do+ return opt{ optEpubFonts = arg : optEpubFonts opt })+ "FILE")+ "" -- "Directory of fonts to embed"++ , Option "" ["epub-chapter-level"]+ (ReqArg+ (\arg opt -> do+ case safeRead arg of+ Just t | t >= 1 && t <= 6 ->+ return opt { optEpubChapterLevel = t }+ _ -> err 59 $+ "chapter level must be a number between 1 and 6")+ "NUMBER")+ "" -- "Header level at which to split chapters in EPUB"++ , Option "" ["latex-engine"]+ (ReqArg+ (\arg opt -> do+ let b = takeBaseName arg+ if (b == "pdflatex" || b == "lualatex" || b == "xelatex")+ then return opt { optLaTeXEngine = arg }+ else err 45 "latex-engine must be pdflatex, lualatex, or xelatex.")+ "PROGRAM")+ "" -- "Name of latex program to use in generating PDF"++ , Option "" ["bibliography"]+ (ReqArg+ (\arg opt -> return opt { optBibliography = (optBibliography opt) ++ [arg] })+ "FILENAME")+ ""++ , Option "" ["csl"]+ (ReqArg+ (\arg opt -> return opt { optCslFile = Just arg })+ "FILENAME")+ ""++ , Option "" ["citation-abbreviations"]+ (ReqArg+ (\arg opt -> return opt { optAbbrevsFile = Just arg })+ "FILENAME")+ ""++ , Option "" ["natbib"]+ (NoArg+ (\opt -> return opt { optCiteMethod = Natbib }))+ "" -- "Use natbib cite commands in LaTeX output"++ , Option "" ["biblatex"]+ (NoArg+ (\opt -> return opt { optCiteMethod = Biblatex }))+ "" -- "Use biblatex cite commands in LaTeX output"++ , Option "m" ["latexmathml", "asciimathml"]+ (OptArg+ (\arg opt ->+ return opt { optHTMLMathMethod = LaTeXMathML arg })+ "URL")+ "" -- "Use LaTeXMathML script in html output"++ , Option "" ["mathml"]+ (OptArg+ (\arg opt ->+ return opt { optHTMLMathMethod = MathML arg })+ "URL")+ "" -- "Use mathml for HTML math"++ , Option "" ["mimetex"]+ (OptArg+ (\arg opt -> do+ let url' = case arg of+ Just u -> u ++ "?"+ Nothing -> "/cgi-bin/mimetex.cgi?"+ return opt { optHTMLMathMethod = WebTeX url' })+ "URL")+ "" -- "Use mimetex for HTML math"++ , Option "" ["webtex"]+ (OptArg+ (\arg opt -> do+ let url' = case arg of+ Just u -> u+ Nothing -> "http://chart.apis.google.com/chart?cht=tx&chl="+ return opt { optHTMLMathMethod = WebTeX url' })+ "URL")+ "" -- "Use web service for HTML math"++ , Option "" ["jsmath"]+ (OptArg+ (\arg opt -> return opt { optHTMLMathMethod = JsMath arg})+ "URL")+ "" -- "Use jsMath for HTML math"++ , Option "" ["mathjax"]+ (OptArg+ (\arg opt -> do+ let url' = case arg of+ Just u -> u+ Nothing -> "http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"+ return opt { optHTMLMathMethod = MathJax url'})+ "URL")+ "" -- "Use MathJax for HTML math"++ , Option "" ["gladtex"]+ (NoArg+ (\opt -> return opt { optHTMLMathMethod = GladTeX }))+ "" -- "Use gladtex for HTML math"++ , Option "" ["dump-args"]+ (NoArg+ (\opt -> return opt { optDumpArgs = True }))+ "" -- "Print output filename and arguments to stdout."++ , Option "" ["ignore-args"]+ (NoArg+ (\opt -> return opt { optIgnoreArgs = True }))+ "" -- "Ignore command-line arguments."++ , Option "v" ["version"]+ (NoArg+ (\_ -> do+ prg <- getProgName+ UTF8.hPutStrLn stdout (prg ++ " " ++ pandocVersion ++ compileInfo +++ copyrightMessage)+ exitWith ExitSuccess ))+ "" -- "Print version"++ , Option "h" ["help"]+ (NoArg+ (\_ -> do+ prg <- getProgName+ UTF8.hPutStr stdout (usageMessage prg options)+ exitWith ExitSuccess ))+ "" -- "Show help"++ ]++-- Returns usage message+usageMessage :: String -> [OptDescr (Opt -> IO Opt)] -> String+usageMessage programName = usageInfo+ (programName ++ " [OPTIONS] [FILES]" ++ "\nInput formats: " +++ (wrapWords 16 78 $ readers'names) ++ "\nOutput formats: " +++ (wrapWords 16 78 $ writers'names) ++ "\nOptions:")+ where+ writers'names = map fst writers+ readers'names = map fst readers++-- Determine default reader based on source file extensions+defaultReaderName :: String -> [FilePath] -> String+defaultReaderName fallback [] = fallback+defaultReaderName fallback (x:xs) =+ case takeExtension (map toLower x) of+ ".xhtml" -> "html"+ ".html" -> "html"+ ".htm" -> "html"+ ".tex" -> "latex"+ ".latex" -> "latex"+ ".ltx" -> "latex"+ ".rst" -> "rst"+ ".lhs" -> "markdown+lhs"+ ".db" -> "docbook"+ ".wiki" -> "mediawiki"+ ".textile" -> "textile"+ ".native" -> "native"+ ".json" -> "json"+ _ -> defaultReaderName fallback xs++-- Returns True if extension of first source is .lhs+lhsExtension :: [FilePath] -> Bool+lhsExtension (x:_) = takeExtension x == ".lhs"+lhsExtension _ = False++-- Determine default writer based on output file extension+defaultWriterName :: FilePath -> String+defaultWriterName "-" = "html" -- no output file+defaultWriterName x =+ case takeExtension (map toLower x) of+ "" -> "markdown" -- empty extension+ ".tex" -> "latex"+ ".latex" -> "latex"+ ".ltx" -> "latex"+ ".context" -> "context"+ ".ctx" -> "context"+ ".rtf" -> "rtf"+ ".rst" -> "rst"+ ".s5" -> "s5"+ ".native" -> "native"+ ".json" -> "json"+ ".txt" -> "markdown"+ ".text" -> "markdown"+ ".md" -> "markdown"+ ".markdown" -> "markdown"+ ".textile" -> "textile"+ ".lhs" -> "markdown+lhs"+ ".texi" -> "texinfo"+ ".texinfo" -> "texinfo"+ ".db" -> "docbook"+ ".odt" -> "odt"+ ".docx" -> "docx"+ ".epub" -> "epub"+ ".org" -> "org"+ ".asciidoc" -> "asciidoc"+ ".pdf" -> "latex"+ ".fb2" -> "fb2"+ ['.',y] | y `elem` ['1'..'9'] -> "man"+ _ -> "html"++main :: IO ()+main = do++ rawArgs <- liftM (map UTF8.decodeArg) getArgs+ prg <- getProgName+ let compatMode = (prg == "hsmarkdown")++ let (actions, args, errors) = if compatMode+ then ([], rawArgs, [])+ else getOpt Permute options rawArgs++ unless (null errors) $+ err 2 $ concat $ errors +++ ["Try " ++ prg ++ " --help for more information."]++ let defaultOpts' = if compatMode+ then defaultOpts { optReader = "markdown_strict"+ , optWriter = "html"+ , optEmailObfuscation =+ ReferenceObfuscation }+ else defaultOpts++ -- thread option data structure through all supplied option actions+ opts <- foldl (>>=) (return defaultOpts') actions++ let Opt { optTabStop = tabStop+ , optPreserveTabs = preserveTabs+ , optStandalone = standalone+ , optReader = readerName+ , optWriter = writerName+ , optParseRaw = parseRaw+ , optVariables = variables+ , optTableOfContents = toc+ , optTransforms = transforms+ , optTemplate = templatePath+ , optOutputFile = outputFile+ , optNumberSections = numberSections+ , optSectionDivs = sectionDivs+ , optIncremental = incremental+ , optSelfContained = selfContained+ , optSmart = smart+ , optOldDashes = oldDashes+ , optHtml5 = html5+ , optHtmlQTags = htmlQTags+ , optHighlight = highlight+ , optHighlightStyle = highlightStyle+ , optChapters = chapters+ , optHTMLMathMethod = mathMethod+ , optReferenceODT = referenceODT+ , optReferenceDocx = referenceDocx+ , optEpubStylesheet = epubStylesheet+ , optEpubMetadata = epubMetadata+ , optEpubFonts = epubFonts+ , optEpubChapterLevel = epubChapterLevel+ , optTOCDepth = epubTOCDepth+ , optDumpArgs = dumpArgs+ , optIgnoreArgs = ignoreArgs+ , optReferenceLinks = referenceLinks+ , optWrapText = wrap+ , optColumns = columns+ , optEmailObfuscation = obfuscationMethod+ , optIdentifierPrefix = idPrefix+ , optIndentedCodeClasses = codeBlockClasses+ , optDataDir = mbDataDir+ , optBibliography = reffiles+ , optCslFile = mbCsl+ , optAbbrevsFile = cslabbrevs+ , optCiteMethod = citeMethod+ , optListings = listings+ , optLaTeXEngine = latexEngine+ , optSlideLevel = slideLevel+ , optSetextHeaders = setextHeaders+ , optAscii = ascii+ , optTeXLigatures = texLigatures+ } = opts++ when dumpArgs $+ do UTF8.hPutStrLn stdout outputFile+ mapM_ (\arg -> UTF8.hPutStrLn stdout arg) args+ exitWith ExitSuccess++ let sources = if ignoreArgs then [] else args++ datadir <- case mbDataDir of+ Nothing -> E.catch+ (liftM Just $ getAppUserDataDirectory "pandoc")+ (\e -> let _ = (e :: E.SomeException)+ in return Nothing)+ Just _ -> return mbDataDir++ -- assign reader and writer based on options and filenames+ let readerName' = if null readerName+ then let fallback = if any isURI sources+ then "html"+ else "markdown"+ in defaultReaderName fallback sources+ else readerName++ let writerName' = if null writerName+ then defaultWriterName outputFile+ else writerName++ let pdfOutput = map toLower (takeExtension outputFile) == ".pdf"++ let laTeXOutput = "latex" `isPrefixOf` writerName' ||+ "beamer" `isPrefixOf` writerName'++ when pdfOutput $ do+ -- make sure writer is latex or beamer+ unless laTeXOutput $+ err 47 $ "cannot produce pdf output with " ++ writerName' ++ " writer"+ -- check for latex program+ mbLatex <- findExecutable latexEngine+ case mbLatex of+ Nothing -> err 41 $+ latexEngine ++ " not found. " +++ latexEngine ++ " is needed for pdf output."+ Just _ -> return ()++ reader <- case getReader readerName' of+ Right r -> return r+ Left e -> err 7 e++ let standalone' = standalone || not (isTextFormat writerName') || pdfOutput++ templ <- case templatePath of+ _ | not standalone' -> return ""+ Nothing -> do+ deftemp <- getDefaultTemplate datadir writerName'+ case deftemp of+ Left e -> throwIO e+ Right t -> return t+ Just tp -> do+ -- strip off extensions+ let format = takeWhile (`notElem` "+-") writerName'+ let tp' = case takeExtension tp of+ "" -> tp <.> format+ _ -> tp+ E.catch (UTF8.readFile tp')+ (\e -> if isDoesNotExistError e+ then E.catch+ (readDataFileUTF8 datadir+ ("templates" </> tp'))+ (\e' -> let _ = (e' :: E.SomeException)+ in throwIO e')+ else throwIO e)++ variables' <- case mathMethod of+ LaTeXMathML Nothing -> do+ s <- readDataFileUTF8 datadir+ ("LaTeXMathML.js")+ return $ ("mathml-script", s) : variables+ MathML Nothing -> do+ s <- readDataFileUTF8 datadir+ ("MathMLinHTML.js")+ return $ ("mathml-script", s) : variables+ _ -> return variables++ variables'' <- if "dzslides" `isPrefixOf` writerName'+ then do+ dztempl <- readDataFileUTF8 datadir+ ("dzslides" </> "template.html")+ let dzcore = unlines $ dropWhile (not . isPrefixOf "<!-- {{{{ dzslides core")+ $ lines dztempl+ return $ ("dzslides-core", dzcore) : variables'+ else return variables'++ -- unescape reference ids, which may contain XML entities, so+ -- that we can do lookups with regular string equality+ let unescapeRefId ref = ref{ refId = fromEntities (refId ref) }++ refs <- mapM (\f -> E.catch (CSL.readBiblioFile f)+ (\e -> let _ = (e :: E.SomeException)+ in err 23 $ "Error reading bibliography `" ++ f +++ "'" ++ "\n" ++ show e))+ reffiles >>=+ return . map unescapeRefId . concat++ mbsty <- if citeMethod == Citeproc && not (null refs)+ then do+ csl <- CSL.parseCSL =<<+ case mbCsl of+ Nothing -> readDataFileUTF8 datadir+ "default.csl"+ Just cslfile -> do+ exists <- doesFileExist cslfile+ if exists+ then UTF8.readFile cslfile+ else do+ csldir <- getAppUserDataDirectory "csl"+ readDataFileUTF8 (Just csldir)+ (replaceExtension cslfile "csl")+ abbrevs <- maybe (return []) CSL.readJsonAbbrevFile cslabbrevs+ return $ Just csl { CSL.styleAbbrevs = abbrevs }+ else return Nothing++ let sourceDir = case sources of+ [] -> "."+ (x:_) -> case parseURI x of+ Just u+ | uriScheme u `elem` ["http:","https:"] ->+ show u{ uriPath = "", uriQuery = "", uriFragment = "" }+ _ -> takeDirectory x++ let readerOpts = def{ readerSmart = smart || (texLigatures &&+ (laTeXOutput || "context" `isPrefixOf` writerName'))+ , readerStandalone = standalone'+ , readerParseRaw = parseRaw+ , readerColumns = columns+ , readerTabStop = tabStop+ , readerOldDashes = oldDashes+ , readerReferences = refs+ , readerCitationStyle = mbsty+ , readerIndentedCodeClasses = codeBlockClasses+ , readerApplyMacros = not laTeXOutput+ }++ let writerOptions = def { writerStandalone = standalone',+ writerTemplate = templ,+ writerVariables = variables'',+ writerTabStop = tabStop,+ writerTableOfContents = toc,+ writerHTMLMathMethod = mathMethod,+ writerIncremental = incremental,+ writerCiteMethod = citeMethod,+ writerBiblioFiles = reffiles,+ writerIgnoreNotes = False,+ writerNumberSections = numberSections,+ writerSectionDivs = sectionDivs,+ writerReferenceLinks = referenceLinks,+ writerWrapText = wrap,+ writerColumns = columns,+ writerEmailObfuscation = obfuscationMethod,+ writerIdentifierPrefix = idPrefix,+ writerSourceDirectory = sourceDir,+ writerUserDataDir = datadir,+ writerHtml5 = html5,+ writerHtmlQTags = htmlQTags,+ writerChapters = chapters,+ writerListings = listings,+ writerBeamer = False,+ writerSlideLevel = slideLevel,+ writerHighlight = highlight,+ writerHighlightStyle = highlightStyle,+ writerSetextHeaders = setextHeaders,+ writerTeXLigatures = texLigatures,+ writerEpubMetadata = epubMetadata,+ writerEpubStylesheet = epubStylesheet,+ writerEpubFonts = epubFonts,+ writerEpubChapterLevel = epubChapterLevel,+ writerTOCDepth = epubTOCDepth,+ writerReferenceODT = referenceODT,+ writerReferenceDocx = referenceDocx+ }++ when (not (isTextFormat writerName') && outputFile == "-") $+ err 5 $ "Cannot write " ++ writerName' ++ " output to stdout.\n" +++ "Specify an output file using the -o option."++ let readSources [] = mapM readSource ["-"]+ readSources srcs = mapM readSource srcs+ readSource "-" = UTF8.getContents+ readSource src = case parseURI src of+ Just u | uriScheme u `elem` ["http:","https:"] ->+ readURI u+ _ -> UTF8.readFile src+ readURI uri = simpleHTTP (mkRequest GET uri) >>= getResponseBody >>=+ return . UTF8.toStringLazy -- treat all as UTF8++ let convertTabs = tabFilter (if preserveTabs then 0 else tabStop)++ let handleIncludes' = if readerName' == "latex" || readerName' == "latex+lhs"+ then handleIncludes+ else return++ doc <- readSources sources >>=+ handleIncludes' . convertTabs . intercalate "\n" >>=+ reader readerOpts++ let doc0 = foldr ($) doc transforms++ let writeBinary :: B.ByteString -> IO ()+ writeBinary = B.writeFile (UTF8.encodePath outputFile)++ let writerFn :: FilePath -> String -> IO ()+ writerFn "-" = UTF8.putStr+ writerFn f = UTF8.writeFile f++ case getWriter writerName' of+ Left e -> err 9 e+ Right (IOStringWriter f) -> f writerOptions doc0 >>= writerFn outputFile+ Right (IOByteStringWriter f) -> f writerOptions doc0 >>= writeBinary+ Right (PureStringWriter f)+ | pdfOutput -> do+ res <- tex2pdf latexEngine $ f writerOptions doc0+ case res of+ Right pdf -> writeBinary pdf+ Left err' -> err 43 $ UTF8.toStringLazy err'+ | otherwise -> selfcontain (f writerOptions doc0 +++ ['\n' | not standalone'])+ >>= writerFn outputFile . handleEntities+ where htmlFormat = writerName' `elem`+ ["html","html+lhs","html5","html5+lhs",+ "s5","slidy","slideous","dzslides"]+ selfcontain = if selfContained && htmlFormat+ then makeSelfContained datadir+ else return+ handleEntities = if htmlFormat && ascii+ then toEntities+ else id
binary file changed (8299 → absent bytes)
binary file changed (7058 → absent bytes)
binary file changed (49 → absent bytes)
binary file changed (10119 → absent bytes)
@@ -1,23 +0,0 @@-/* The following styles size, place, and layer the slide components.- Edit these if you want to change the overall slide layout.- The commented lines can be uncommented (and modified, if necessary) - to help you with the rearrangement process. */--/* target = 1024x768 */--div#header, div#footer, .slide {width: 100%; top: 0; left: 0;}-div#header {top: 0; height: 3em; z-index: 1;}-div#footer {top: auto; bottom: 0; height: 2.5em; z-index: 5;}-.slide {top: 0; width: 92%; padding: 3.5em 4% 4%; z-index: 2; list-style: none;}-div#controls {left: 50%; bottom: 0; width: 50%; z-index: 100;}-div#controls form {position: absolute; bottom: 0; right: 0; width: 100%;- margin: 0;}-#currentSlide {position: absolute; width: 10%; left: 45%; bottom: 1em; z-index: 10;}-html>body #currentSlide {position: fixed;}--/*-div#header {background: #FCC;}-div#footer {background: #CCF;}-div#controls {background: #BBD;}-div#currentSlide {background: #FFC;}-*/
@@ -1,42 +0,0 @@-<public:component> -<public:attach event="onpropertychange" onevent="doFix()" /> - -<script> - -// IE5.5+ PNG Alpha Fix v1.0 by Angus Turnbull http://www.twinhelix.com -// Free usage permitted as long as this notice remains intact. - -// This must be a path to a blank image. That's all the configuration you need here. -var blankImg = 'ui/default/blank.gif'; - -var f = 'DXImageTransform.Microsoft.AlphaImageLoader'; - -function filt(s, m) { - if (filters[f]) { - filters[f].enabled = s ? true : false; - if (s) with (filters[f]) { src = s; sizingMethod = m } - } else if (s) style.filter = 'progid:'+f+'(src="'+s+'",sizingMethod="'+m+'")'; -} - -function doFix() { - if ((parseFloat(navigator.userAgent.match(/MSIE (\S+)/)[1]) < 5.5) || - (event && !/(background|src)/.test(event.propertyName))) return; - - if (tagName == 'IMG') { - if ((/\.png$/i).test(src)) { - filt(src, 'image'); // was 'scale' - src = blankImg; - } else if (src.indexOf(blankImg) < 0) filt(); - } else if (style.backgroundImage) { - if (style.backgroundImage.match(/^url[("']+(.*\.png)[)"']+$/i)) { - var s = RegExp.$1; - style.backgroundImage = ''; - filt(s, 'crop'); - } else filt(); - } -} - -doFix(); - -</script> -</public:component>
@@ -1,7 +0,0 @@-/* DO NOT CHANGE THESE unless you really want to break Opera Show */-.slide {- visibility: visible !important;- position: static !important;- page-break-before: always;-}-#slide0 {page-break-before: avoid;}
@@ -1,15 +0,0 @@-/* don't change this unless you want the layout stuff to show up in the outline view! */--.layout div, #footer *, #controlForm * {display: none;}-#footer, #controls, #controlForm, #navLinks, #toggle {- display: block; visibility: visible; margin: 0; padding: 0;}-#toggle {float: right; padding: 0.5em;}-html>body #toggle {position: fixed; top: 0; right: 0;}--/* making the outline look pretty-ish */--#slide0 h1, #slide0 h2, #slide0 h3, #slide0 h4 {border: none; margin: 0;}-#slide0 h1 {padding-top: 1.5em;}-.slide h1 {margin: 1.5em 0 0; padding-top: 0.25em;- border-top: 1px solid #888; border-bottom: 1px solid #AAA;}-#toggle {border: 1px solid; border-width: 0 0 1px 1px; background: #FFF;}
@@ -1,86 +0,0 @@-/* Following are the presentation styles -- edit away! */--body {background: #FFF url(bodybg.gif) -16px 0 no-repeat; color: #000; font-size: 2em;}-:link, :visited {text-decoration: none; color: #00C;}-#controls :active {color: #88A !important;}-#controls :focus {outline: 1px dotted #227;}-h1, h2, h3, h4 {font-size: 100%; margin: 0; padding: 0; font-weight: inherit;}-ul, pre {margin: 0; line-height: 1em;}-html, body {margin: 0; padding: 0;}--blockquote, q {font-style: italic;}-blockquote {padding: 0 2em 0.5em; margin: 0 1.5em 0.5em; text-align: center; font-size: 1em;}-blockquote p {margin: 0;}-blockquote i {font-style: normal;}-blockquote b {display: block; margin-top: 0.5em; font-weight: normal; font-size: smaller; font-style: normal;}-blockquote b i {font-style: italic;}--kbd {font-weight: bold; font-size: 1em;}-sup {font-size: smaller; line-height: 1px;}--.slide code {padding: 2px 0.25em; font-weight: bold; color: #533;}-.slide code.bad, code del {color: red;}-.slide code.old {color: silver;}-.slide pre {padding: 0; margin: 0.25em 0 0.5em 0.5em; color: #533; font-size: 90%;}-.slide pre code {display: block;}-.slide ul {margin-left: 5%; margin-right: 7%; list-style: disc;}-.slide li {margin-top: 0.75em; margin-right: 0;}-.slide ul ul {line-height: 1;}-.slide ul ul li {margin: .2em; font-size: 85%; list-style: square;}-.slide img.leader {display: block; margin: 0 auto;}--div#header, div#footer {background: #005; color: #AAB;- font-family: Verdana, Helvetica, sans-serif;}-div#header {background: #005 url(bodybg.gif) -16px 0 no-repeat;- line-height: 1px;}-div#footer {font-size: 0.5em; font-weight: bold; padding: 1em 0;}-#footer h1, #footer h2 {display: block; padding: 0 1em;}-#footer h2 {font-style: italic;}--div.long {font-size: 0.75em;}-.slide h1 {position: absolute; top: 0.7em; left: 87px; z-index: 1;- margin: 0; padding: 0.3em 0 0 50px; white-space: nowrap;- font: bold 150%/1em Helvetica, sans-serif; text-transform: capitalize;- color: #DDE; background: #005;}-.slide h3 {font-size: 130%;}-h1 abbr {font-variant: small-caps;}--div#controls {position: absolute; left: 50%; bottom: 0;- width: 50%;- text-align: right; font: bold 0.9em Verdana, Helvetica, sans-serif;}-html>body div#controls {position: fixed; padding: 0 0 1em 0;- top: auto;}-div#controls form {position: absolute; bottom: 0; right: 0; width: 100%;- margin: 0; padding: 0;}-#controls #navLinks a {padding: 0; margin: 0 0.5em; - background: #005; border: none; color: #779; - cursor: pointer;}-#controls #navList {height: 1em;}-#controls #navList #jumplist {position: absolute; bottom: 0; right: 0; background: #DDD; color: #227;}--#currentSlide {text-align: center; font-size: 0.5em; color: #449;}--#slide0 {padding-top: 3.5em; font-size: 90%;}-#slide0 h1 {position: static; margin: 1em 0 0; padding: 0;- font: bold 2em Helvetica, sans-serif; white-space: normal;- color: #000; background: transparent;}-#slide0 h2 {font: bold italic 1em Helvetica, sans-serif; margin: 0.25em;}-#slide0 h3 {margin-top: 1.5em; font-size: 1.5em;}-#slide0 h4 {margin-top: 0; font-size: 1em;}--ul.urls {list-style: none; display: inline; margin: 0;}-.urls li {display: inline; margin: 0;}-.note {display: none;}-.external {border-bottom: 1px dotted gray;}-html>body .external {border-bottom: none;}-.external:after {content: " \274F"; font-size: smaller; color: #77B;}--.incremental, .incremental *, .incremental *:after {color: #DDE; visibility: visible;}-img.incremental {visibility: hidden;}-.slide .current {color: #B02;}---/* diagnostics--li:after {content: " [" attr(class) "]"; color: #F88;}-*/
@@ -1,24 +0,0 @@-/* The following rule is necessary to have all slides appear in print! DO NOT REMOVE IT! */-.slide, ul {page-break-inside: avoid; visibility: visible !important;}-h1 {page-break-after: avoid;}--body {font-size: 12pt; background: white;}-* {color: black;}--#slide0 h1 {font-size: 200%; border: none; margin: 0.5em 0 0.25em;}-#slide0 h3 {margin: 0; padding: 0;}-#slide0 h4 {margin: 0 0 0.5em; padding: 0;}-#slide0 {margin-bottom: 3em;}--h1 {border-top: 2pt solid gray; border-bottom: 1px dotted silver;}-.extra {background: transparent !important;}-div.extra, pre.extra, .example {font-size: 10pt; color: #333;}-ul.extra a {font-weight: bold;}-p.example {display: none;}--#header {display: none;}-#footer h1 {margin: 0; border-bottom: 1px solid; color: gray; font-style: italic;}-#footer h2, #controls {display: none;}--/* The following rule keeps the layout stuff out of print. Remove at your own risk! */-.layout, .layout * {display: none !important;}
@@ -1,9 +0,0 @@-/* Do not edit or override these styles! The system will likely break if you do. */--div#header, div#footer, div#controls, .slide {position: absolute;}-html>body div#header, html>body div#footer, - html>body div#controls, html>body .slide {position: fixed;}-.handout {display: none;}-.layout {display: block;}-.slide, .hideme, .incremental {visibility: hidden;}-#slide0 {visibility: visible;}
@@ -1,3 +0,0 @@-@import url(s5-core.css); /* required to make the slide show run at all */-@import url(framing.css); /* sets basic placement and size of slide components */-@import url(pretty.css); /* stuff that makes the slides look better than blah */
@@ -1,553 +0,0 @@-// S5 v1.1 slides.js -- released into the Public Domain-//-// Please see http://www.meyerweb.com/eric/tools/s5/credits.html for information -// about all the wonderful and talented contributors to this code!--var undef;-var slideCSS = '';-var snum = 0;-var smax = 1;-var incpos = 0;-var number = undef;-var s5mode = true;-var defaultView = 'slideshow';-var controlVis = 'visible';--var isIE = navigator.appName == 'Microsoft Internet Explorer' && navigator.userAgent.indexOf('Opera') < 1 ? 1 : 0;-var isOp = navigator.userAgent.indexOf('Opera') > -1 ? 1 : 0;-var isGe = navigator.userAgent.indexOf('Gecko') > -1 && navigator.userAgent.indexOf('Safari') < 1 ? 1 : 0;--function hasClass(object, className) {- if (!object.className) return false;- return (object.className.search('(^|\\s)' + className + '(\\s|$)') != -1);-}--function hasValue(object, value) {- if (!object) return false;- return (object.search('(^|\\s)' + value + '(\\s|$)') != -1);-}--function removeClass(object,className) {- if (!object) return;- object.className = object.className.replace(new RegExp('(^|\\s)'+className+'(\\s|$)'), RegExp.$1+RegExp.$2);-}--function addClass(object,className) {- if (!object || hasClass(object, className)) return;- if (object.className) {- object.className += ' '+className;- } else {- object.className = className;- }-}--function GetElementsWithClassName(elementName,className) {- var allElements = document.getElementsByTagName(elementName);- var elemColl = new Array();- for (var i = 0; i< allElements.length; i++) {- if (hasClass(allElements[i], className)) {- elemColl[elemColl.length] = allElements[i];- }- }- return elemColl;-}--function isParentOrSelf(element, id) {- if (element == null || element.nodeName=='BODY') return false;- else if (element.id == id) return true;- else return isParentOrSelf(element.parentNode, id);-}--function nodeValue(node) {- var result = "";- if (node.nodeType == 1) {- var children = node.childNodes;- for (var i = 0; i < children.length; ++i) {- result += nodeValue(children[i]);- } - }- else if (node.nodeType == 3) {- result = node.nodeValue;- }- return(result);-}--function slideLabel() {- var slideColl = GetElementsWithClassName('*','slide');- var list = document.getElementById('jumplist');- smax = slideColl.length;- for (var n = 0; n < smax; n++) {- var obj = slideColl[n];-- var did = 'slide' + n.toString();- obj.setAttribute('id',did);- if (isOp) continue;-- var otext = '';- var menu = obj.firstChild;- if (!menu) continue; // to cope with empty slides- while (menu && menu.nodeType == 3) {- menu = menu.nextSibling;- }- if (!menu) continue; // to cope with slides with only text nodes-- var menunodes = menu.childNodes;- for (var o = 0; o < menunodes.length; o++) {- otext += nodeValue(menunodes[o]);- }- list.options[list.length] = new Option(n + ' : ' + otext, n);- }-}--function currentSlide() {- var cs;- if (document.getElementById) {- cs = document.getElementById('currentSlide');- } else {- cs = document.currentSlide;- }- cs.innerHTML = '<span id="csHere">' + snum + '<\/span> ' + - '<span id="csSep">\/<\/span> ' + - '<span id="csTotal">' + (smax-1) + '<\/span>';- if (snum == 0) {- cs.style.visibility = 'hidden';- } else {- cs.style.visibility = 'visible';- }-}--function go(step) {- if (document.getElementById('slideProj').disabled || step == 0) return;- var jl = document.getElementById('jumplist');- var cid = 'slide' + snum;- var ce = document.getElementById(cid);- if (incrementals[snum].length > 0) {- for (var i = 0; i < incrementals[snum].length; i++) {- removeClass(incrementals[snum][i], 'current');- removeClass(incrementals[snum][i], 'incremental');- }- }- if (step != 'j') {- snum += step;- lmax = smax - 1;- if (snum > lmax) snum = lmax;- if (snum < 0) snum = 0;- } else- snum = parseInt(jl.value);- var nid = 'slide' + snum;- var ne = document.getElementById(nid);- if (!ne) {- ne = document.getElementById('slide0');- snum = 0;- }- if (step < 0) {incpos = incrementals[snum].length} else {incpos = 0;}- if (incrementals[snum].length > 0 && incpos == 0) {- for (var i = 0; i < incrementals[snum].length; i++) {- if (hasClass(incrementals[snum][i], 'current'))- incpos = i + 1;- else- addClass(incrementals[snum][i], 'incremental');- }- }- if (incrementals[snum].length > 0 && incpos > 0)- addClass(incrementals[snum][incpos - 1], 'current');- ce.style.visibility = 'hidden';- ne.style.visibility = 'visible';- jl.selectedIndex = snum;- currentSlide();- number = 0;-}--function goTo(target) {- if (target >= smax || target == snum) return;- go(target - snum);-}--function subgo(step) {- if (step > 0) {- removeClass(incrementals[snum][incpos - 1],'current');- removeClass(incrementals[snum][incpos], 'incremental');- addClass(incrementals[snum][incpos],'current');- incpos++;- } else {- incpos--;- removeClass(incrementals[snum][incpos],'current');- addClass(incrementals[snum][incpos], 'incremental');- addClass(incrementals[snum][incpos - 1],'current');- }-}--function toggle() {- var slideColl = GetElementsWithClassName('*','slide');- var slides = document.getElementById('slideProj');- var outline = document.getElementById('outlineStyle');- if (!slides.disabled) {- slides.disabled = true;- outline.disabled = false;- s5mode = false;- fontSize('1em');- for (var n = 0; n < smax; n++) {- var slide = slideColl[n];- slide.style.visibility = 'visible';- }- } else {- slides.disabled = false;- outline.disabled = true;- s5mode = true;- fontScale();- for (var n = 0; n < smax; n++) {- var slide = slideColl[n];- slide.style.visibility = 'hidden';- }- slideColl[snum].style.visibility = 'visible';- }-}--function showHide(action) {- var obj = GetElementsWithClassName('*','hideme')[0];- switch (action) {- case 's': obj.style.visibility = 'visible'; break;- case 'h': obj.style.visibility = 'hidden'; break;- case 'k':- if (obj.style.visibility != 'visible') {- obj.style.visibility = 'visible';- } else {- obj.style.visibility = 'hidden';- }- break;- }-}--// 'keys' code adapted from MozPoint (http://mozpoint.mozdev.org/)-function keys(key) {- if (!key) {- key = event;- key.which = key.keyCode;- }- if (key.which == 84) {- toggle();- return;- }- if (s5mode) {- switch (key.which) {- case 10: // return- case 13: // enter- if (window.event && isParentOrSelf(window.event.srcElement, 'controls')) return;- if (key.target && isParentOrSelf(key.target, 'controls')) return;- if(number != undef) {- goTo(number);- break;- }- case 32: // spacebar- case 34: // page down- case 39: // rightkey- case 40: // downkey- if(number != undef) {- go(number);- } else if (!incrementals[snum] || incpos >= incrementals[snum].length) {- go(1);- } else {- subgo(1);- }- break;- case 33: // page up- case 37: // leftkey- case 38: // upkey- if(number != undef) {- go(-1 * number);- } else if (!incrementals[snum] || incpos <= 0) {- go(-1);- } else {- subgo(-1);- }- break;- case 36: // home- goTo(0);- break;- case 35: // end- goTo(smax-1);- break;- case 67: // c- showHide('k');- break;- }- if (key.which < 48 || key.which > 57) {- number = undef;- } else {- if (window.event && isParentOrSelf(window.event.srcElement, 'controls')) return;- if (key.target && isParentOrSelf(key.target, 'controls')) return;- number = (((number != undef) ? number : 0) * 10) + (key.which - 48);- }- }- return false;-}--function clicker(e) {- number = undef;- var target;- if (window.event) {- target = window.event.srcElement;- e = window.event;- } else target = e.target;- if (target.getAttribute('href') != null || hasValue(target.rel, 'external') || isParentOrSelf(target, 'controls') || isParentOrSelf(target,'embed') || isParentOrSelf(target,'object')) return true;- if (!e.which || e.which == 1) {- if (!incrementals[snum] || incpos >= incrementals[snum].length) {- go(1);- } else {- subgo(1);- }- }-}--function findSlide(hash) {- var target = null;- var slides = GetElementsWithClassName('*','slide');- for (var i = 0; i < slides.length; i++) {- var targetSlide = slides[i];- if ( (targetSlide.name && targetSlide.name == hash)- || (targetSlide.id && targetSlide.id == hash) ) {- target = targetSlide;- break;- }- }- while(target != null && target.nodeName != 'BODY') {- if (hasClass(target, 'slide')) {- return parseInt(target.id.slice(5));- }- target = target.parentNode;- }- return null;-}--function slideJump() {- if (window.location.hash == null) return;- var sregex = /^#slide(\d+)$/;- var matches = sregex.exec(window.location.hash);- var dest = null;- if (matches != null) {- dest = parseInt(matches[1]);- } else {- dest = findSlide(window.location.hash.slice(1));- }- if (dest != null)- go(dest - snum);-}--function fixLinks() {- var thisUri = window.location.href;- thisUri = thisUri.slice(0, thisUri.length - window.location.hash.length);- var aelements = document.getElementsByTagName('A');- for (var i = 0; i < aelements.length; i++) {- var a = aelements[i].href;- var slideID = a.match('\#slide[0-9]{1,2}');- if ((slideID) && (slideID[0].slice(0,1) == '#')) {- var dest = findSlide(slideID[0].slice(1));- if (dest != null) {- if (aelements[i].addEventListener) {- aelements[i].addEventListener("click", new Function("e",- "if (document.getElementById('slideProj').disabled) return;" +- "go("+dest+" - snum); " +- "if (e.preventDefault) e.preventDefault();"), true);- } else if (aelements[i].attachEvent) {- aelements[i].attachEvent("onclick", new Function("",- "if (document.getElementById('slideProj').disabled) return;" +- "go("+dest+" - snum); " +- "event.returnValue = false;"));- }- }- }- }-}--function externalLinks() {- if (!document.getElementsByTagName) return;- var anchors = document.getElementsByTagName('a');- for (var i=0; i<anchors.length; i++) {- var anchor = anchors[i];- if (anchor.getAttribute('href') && hasValue(anchor.rel, 'external')) {- anchor.target = '_blank';- addClass(anchor,'external');- }- }-}--function createControls() {- var controlsDiv = document.getElementById("controls");- if (!controlsDiv) return;- var hider = ' onmouseover="showHide(\'s\');" onmouseout="showHide(\'h\');"';- var hideDiv, hideList = '';- if (controlVis == 'hidden') {- hideDiv = hider;- } else {- hideList = hider;- }- controlsDiv.innerHTML = '<form action="#" id="controlForm"' + hideDiv + '>' +- '<div id="navLinks">' +- '<a accesskey="t" id="toggle" href="javascript:toggle();">Ø<\/a>' +- '<a accesskey="z" id="prev" href="javascript:go(-1);">«<\/a>' +- '<a accesskey="x" id="next" href="javascript:go(1);">»<\/a>' +- '<div id="navList"' + hideList + '><select id="jumplist" onchange="go(\'j\');"><\/select><\/div>' +- '<\/div><\/form>';- if (controlVis == 'hidden') {- var hidden = document.getElementById('navLinks');- } else {- var hidden = document.getElementById('jumplist');- }- addClass(hidden,'hideme');-}--function fontScale() { // causes layout problems in FireFox that get fixed if browser's Reload is used; same may be true of other Gecko-based browsers- if (!s5mode) return false;- var vScale = 22; // both yield 32 (after rounding) at 1024x768- var hScale = 32; // perhaps should auto-calculate based on theme's declared value?- if (window.innerHeight) {- var vSize = window.innerHeight;- var hSize = window.innerWidth;- } else if (document.documentElement.clientHeight) {- var vSize = document.documentElement.clientHeight;- var hSize = document.documentElement.clientWidth;- } else if (document.body.clientHeight) {- var vSize = document.body.clientHeight;- var hSize = document.body.clientWidth;- } else {- var vSize = 700; // assuming 1024x768, minus chrome and such- var hSize = 1024; // these do not account for kiosk mode or Opera Show- }- var newSize = Math.min(Math.round(vSize/vScale),Math.round(hSize/hScale));- fontSize(newSize + 'px');- if (isGe) { // hack to counter incremental reflow bugs- var obj = document.getElementsByTagName('body')[0];- obj.style.display = 'none';- obj.style.display = 'block';- }-}--function fontSize(value) {- if (!(s5ss = document.getElementById('s5ss'))) {- if (!isIE) {- document.getElementsByTagName('head')[0].appendChild(s5ss = document.createElement('style'));- s5ss.setAttribute('media','screen, projection');- s5ss.setAttribute('id','s5ss');- } else {- document.createStyleSheet();- document.s5ss = document.styleSheets[document.styleSheets.length - 1];- }- }- if (!isIE) {- while (s5ss.lastChild) s5ss.removeChild(s5ss.lastChild);- s5ss.appendChild(document.createTextNode('body {font-size: ' + value + ' !important;}'));- } else {- document.s5ss.addRule('body','font-size: ' + value + ' !important;');- }-}--function notOperaFix() {- slideCSS = document.getElementById('slideProj').href;- var slides = document.getElementById('slideProj');- var outline = document.getElementById('outlineStyle');- slides.setAttribute('media','screen');- outline.disabled = true;- if (isGe) {- slides.setAttribute('href','null'); // Gecko fix- slides.setAttribute('href',slideCSS); // Gecko fix- }- if (isIE && document.styleSheets && document.styleSheets[0]) {- document.styleSheets[0].addRule('img', 'behavior: url(ui/default/iepngfix.htc)');- document.styleSheets[0].addRule('div', 'behavior: url(ui/default/iepngfix.htc)');- document.styleSheets[0].addRule('.slide', 'behavior: url(ui/default/iepngfix.htc)');- }-}--function getIncrementals(obj) {- var incrementals = new Array();- if (!obj) - return incrementals;- var children = obj.childNodes;- for (var i = 0; i < children.length; i++) {- var child = children[i];- if (hasClass(child, 'incremental')) {- if (child.nodeName == 'OL' || child.nodeName == 'UL') {- removeClass(child, 'incremental');- for (var j = 0; j < child.childNodes.length; j++) {- if (child.childNodes[j].nodeType == 1) {- addClass(child.childNodes[j], 'incremental');- }- }- } else {- incrementals[incrementals.length] = child;- removeClass(child,'incremental');- }- }- if (hasClass(child, 'show-first')) {- if (child.nodeName == 'OL' || child.nodeName == 'UL') {- removeClass(child, 'show-first');- if (child.childNodes[isGe].nodeType == 1) {- removeClass(child.childNodes[isGe], 'incremental');- }- } else {- incrementals[incrementals.length] = child;- }- }- incrementals = incrementals.concat(getIncrementals(child));- }- return incrementals;-}--function createIncrementals() {- var incrementals = new Array();- for (var i = 0; i < smax; i++) {- incrementals[i] = getIncrementals(document.getElementById('slide'+i));- }- return incrementals;-}--function defaultCheck() {- var allMetas = document.getElementsByTagName('meta');- for (var i = 0; i< allMetas.length; i++) {- if (allMetas[i].name == 'defaultView') {- defaultView = allMetas[i].content;- }- if (allMetas[i].name == 'controlVis') {- controlVis = allMetas[i].content;- }- }-}--// Key trap fix, new function body for trap()-function trap(e) {- if (!e) {- e = event;- e.which = e.keyCode;- }- try {- modifierKey = e.ctrlKey || e.altKey || e.metaKey;- }- catch(e) {- modifierKey = false;- }- return modifierKey || e.which == 0;-}--function startup() {- defaultCheck();- if (!isOp) - createControls();- slideLabel();- fixLinks();- externalLinks();- fontScale();- if (!isOp) {- notOperaFix();- incrementals = createIncrementals();- slideJump();- if (defaultView == 'outline') {- toggle();- }- document.onkeyup = keys;- document.onkeypress = trap;- document.onclick = clicker;- }-}--window.onload = startup;-window.onresize = function(){setTimeout('fontScale()', 50);}
@@ -1,95 +0,0 @@-/* This work is licensed under Creative Commons GNU LGPL License.-- License: http://creativecommons.org/licenses/LGPL/2.1/- Version: 1.0-- Author: Stefan Goessner/2005- Web: http://goessner.net/ -*/-@media screen, projection {-body {- background-color: #e3eee7;- padding: 0;- margin: 0;- color: #132; - border-color: #678; - font-size: 125%;-}-#statusbar {- display: none;- position: absolute; z-index: 10;- top: auto; bottom: 0; left: 0; right: 0;- height: 2em;- background-color: #f0fff8;- color: #132;- font-size: 75%;- padding: 0.5em 0.5em 0 2px;- border-top: solid 1px #000;-}-#statusbar button, #tocbox {- cursor: pointer; - color: #031;- background-color: #e0eee7;- margin: 1px;- padding: 0 0.5em;- border: inset 1px black;-}-#statusbar button:hover, #tocbox:hover {- color: #031;- background-color: #c0ccc6;- border: outset 1px black;-}-#tocbox {- width: 15em;-}-#eos {- visibility: hidden;- color: #021;- background-color: #fffafa;- border: inset 1px black;- font-size: 120%;-}-div.slide {- display: block;- margin: 0 0 2em 0;- padding: 0 150px;-}--div.slide h1 {- background: #a0aaa4;- color: #f0fff8;- padding: 0 0.5em 0 0.5em;- margin: 0 -150px;- font-size: 120%;- border-bottom: solid 1px black;-}--div.slide h1:before { content: "# "; }-div.handout { display: block; }- -body>#statusbar { /* ie6 hack for fixing the statusbar - in quirks mode */- position: fixed; /* thanks to Anne van Kesteren and Arthur Steiner */-} /* see http://limpid.nl/lab/css/fixed/footer */-* html body {- overflow: hidden;-}-* html div.slide {- height: 100%;- padding-bottom: 2em;- overflow: auto;-} /* end ie6-hack */--} /* @media screen, projection */--@media print {-body {- color: black;- font-family: sans-serif;- font-size: 11pt;-}--#statusbar { display: none; }-div.slide { page-break-after: always; }-div.handout { display: block; }--} /* @media print */
@@ -1,321 +0,0 @@-/* This work is licensed under Creative Commons GNU LGPL License.-- License: http://creativecommons.org/licenses/LGPL/2.1/-- Author: Stefan Goessner/2005-2006- Web: http://goessner.net/ -*/-var Slideous = {- version: 1.0,- // == user customisable ===- clickables: { a: true, button: true, img: true, input: true, object: true, textarea: true, select: true, option: true },- incrementables: { blockquote: { filter: "self, parent" }, - dd: { filter: "self, parent" },- dt: { filter: "self, parent" },- h2: { filter: "self, parent" },- h3: { filter: "self, parent" },- h4: { filter: "self, parent" },- h5: { filter: "self, parent" },- h6: { filter: "self, parent" },- li: { filter: "self, parent" },- p: { filter: "self" }, - pre: { filter: "self" }, - img: { filter: "self, parent" }, - object: { filter: "self, parent" },- table: { filter: "self, parent" },- td: { filter: "self, parent" },- th: { filter: "self, parent" },- tr: { filter: "parent, grandparent" }- },- autoincrementables: { ol: true, ul: true, dl: true },- autoincrement: false,- statusbar: true,- navbuttons: { incfontbutton: function(){Slideous.changefontsize(+Slideous.fontdelta);},- decfontbutton: function(){Slideous.changefontsize(-Slideous.fontdelta);},- contentbutton: function(){Slideous.gotoslide(Slideous.tocidx(), true, true);},- homebutton: function(){Slideous.gotoslide(1, true, true);},- prevslidebutton: function(){Slideous.previous(false);},- previtembutton: function(){Slideous.previous(true);},- nextitembutton: function(){Slideous.next(true);},- nextslidebutton: function(){Slideous.next(false);},- endbutton: function(){Slideous.gotoslide(Slideous.count,true,true);} },- fontsize: 125, // in percent, corresponding to body.font-size in css file- fontdelta: 5, // increase/decrease fontsize by this value- mousesensitive: true,- tocidx: 0,- tocitems: { toc: "<li><a href=\"#s{\$slideidx}\">{\$slidetitle}</a></li>",- tocbox: "<option value=\"#s{\$slideidx}\" title=\"{\$slidetitle}\">{\$slidetitle}</option>" },- keydown: function(evt) {- evt = evt || window.event;- var key = evt.keyCode || evt.which;- if (key && !evt.ctrlKey && !evt.altKey) {- switch (key) {- case 33: // page up ... previous slide- Slideous.previous(false); evt.cancel = !Slideous.showall; break;- case 37: // left arrow ... previous item- Slideous.previous(true); evt.cancel = !Slideous.showall; break;- case 32: // space bar- case 39: // right arrow- Slideous.next(true); evt.cancel = !Slideous.showall; break;- case 13: // carriage return ... next slide- case 34: // page down- Slideous.next(false); evt.cancel = !Slideous.showall; break;- case 35: // end ... last slide (not recognised by opera)- Slideous.gotoslide(Slideous.count, true, true); evt.cancel = !Slideous.showall; break;- case 36: // home ... first slide (not recognised by opera)- Slideous.gotoslide(1, true, true); evt.cancel = !Slideous.showall; break;- case 65: // A ... show All- case 80: // P ... Print mode- Slideous.toggleshowall(!Slideous.showall); evt.cancel = true; break;- case 67: // C ... goto contents- Slideous.gotoslide(Slideous.tocidx, true, true); evt.cancel = true; break;- case 77: // M ... toggle mouse sensitivity- Slideous.mousenavigation(Slideous.mousesensitive = !Slideous.mousesensitive); evt.cancel = true; break;- case 83: // S ... toggle statusbar- Slideous.togglestatusbar(); evt.cancel = true; break;- case 61: // + ... increase fontsize- case 107:- Slideous.changefontsize(+Slideous.fontdelta); evt.cancel = true; break;- case 109: // - ... decrease fontsize- Slideous.changefontsize(-Slideous.fontdelta); evt.cancel = true; break;- default: break;- }- if (evt.cancel) evt.returnValue = false;- }- return !evt.cancel;- },-- // == program logic ===- count: 0, // # of slides ..- curidx: 0, // current slide index ..- mousedownpos: null, // last mouse down position ..- contentselected: false, // indicates content selection ..- showall: true,- init: function() {- Slideous.curidx = 1;- Slideous.importproperties();- Slideous.registerslides();- document.body.innerHTML = Slideous.injectproperties(document.body.innerHTML);- Slideous.buildtocs();- Slideous.registeranchors();- Slideous.toggleshowall(false);- Slideous.updatestatus();- document.body.style.fontSize = Slideous.fontsize+"%";- document.getElementById("s1").style.display = "block";- document.onkeydown = Slideous.keydown;- Slideous.mousenavigation(Slideous.mousesensitive);- Slideous.registerbuttons();- if (window.location.hash)- Slideous.gotoslide(window.location.hash.substr(2), true, true);- },- registerslides: function() {- var div = document.getElementsByTagName("div");- Slideous.count = 0;- for (var i in div)- if (Slideous.hasclass(div[i], "slide"))- div[i].setAttribute("id", "s"+(++Slideous.count));- },- registeranchors: function() {- var a = document.getElementsByTagName("a"),- loc = (window.location.hostname+window.location.pathname).replace(/\\/g, "/");- for (var i in a) {- if (a[i].href && a[i].href.indexOf(loc) >= 0 && a[i].href.lastIndexOf("#") >= 0) {- a[i].href = "javascript:Slideous.gotoslide(" + a[i].href.substr(a[i].href.lastIndexOf("#")+2)+",true,true)";- }- }- },- registerbuttons: function() {- var button;- for (var b in Slideous.navbuttons)- if (button = document.getElementById(b))- button.onclick = Slideous.navbuttons[b];- },- importproperties: function() { // from html meta section ..- var meta = document.getElementsByTagName("meta"), elem;- for (var i in meta)- if (meta[i].attributes && meta[i].attributes["name"] && meta[i].attributes["name"].value in Slideous)- switch (typeof(Slideous[meta[i].attributes["name"].value])) {- case "number": Slideous[meta[i].attributes["name"].value] = parseInt(meta[i].attributes["content"].value); break;- case "boolean": Slideous[meta[i].attributes["name"].value] = meta[i].attributes["content"].value == "true" ? true : false; break;- default: Slideous[meta[i].attributes["name"].value] = meta[i].attributes["content"].value; break;- }- },- injectproperties: function(str) {- var meta = document.getElementsByTagName("meta"), elem;- for (var i in meta) {- if (meta[i].attributes && meta[i].attributes["name"])- str = str.replace(new RegExp("{\\$"+meta[i].attributes["name"].value+"}","g"), meta[i].attributes["content"].value);- }- return str = str.replace(/{\$generator}/g, "Slideous")- .replace(/{\$version}/g, Slideous.version)- .replace(/{\$title}/g, document.title)- .replace(/{\$slidecount}/g, Slideous.count);- },- buildtocs: function() {- var toc = document.getElementById("toc"), list = "",- tocbox = document.getElementById("tocbox");- if (toc) {- for (var i=0; i<Slideous.count; i++)- list += Slideous.tocitems.toc.replace(/{\$slideidx}/g, i+1).replace(/{\$slidetitle}/, document.getElementById("s"+(i+1)).getElementsByTagName("h1")[0].innerHTML);- toc.innerHTML = list;- while (toc && !Slideous.hasclass(toc, "slide")) toc = toc.parentNode;- if (toc) Slideous.tocidx = toc.getAttribute("id").substr(1);- }- if (tocbox) {- tocbox.innerHTML = "";- for (var i=0; i<Slideous.count; i++)- tocbox.options[tocbox.length] = new Option((i+1)+". "+document.getElementById("s"+(i+1)).getElementsByTagName("h1")[0].innerHTML, "#s"+(i+1));- tocbox.onchange = function() { Slideous.gotoslide(this.selectedIndex+1, true, true); };- }- },- next: function(deep) {- if (!Slideous.showall) {- var slide = document.getElementById("s"+Slideous.curidx),- item = Slideous.firstitem(slide, Slideous.isitemhidden);- if (deep) { // next item- if (item)- Slideous.displayitem(item, true);- else- Slideous.gotoslide(Slideous.curidx+1, false, false);- }- else if (item) // complete slide ..- while (item = Slideous.firstitem(slide, Slideous.isitemhidden))- Slideous.displayitem(item, true);- else // next slide- Slideous.gotoslide(Slideous.curidx+1, true, false);- Slideous.updatestatus();- }- },- previous: function(deep) {- if (!Slideous.showall) {- var slide = document.getElementById("s"+Slideous.curidx);- if (deep) {- var item = Slideous.lastitem(slide, Slideous.isitemvisible);- if (item)- Slideous.displayitem(item, false);- else- Slideous.gotoslide(Slideous.curidx-1, true, false);- }- else- Slideous.gotoslide(Slideous.curidx-1, true, false);- Slideous.updatestatus();- }- },- gotoslide: function(i, showitems, updatestatus) {- if (!Slideous.showall && i > 0 && i <= Slideous.count && i != Slideous.curidx) {- document.getElementById("s"+Slideous.curidx).style.display = "none";- var slide = document.getElementById("s"+(Slideous.curidx=i)), item;- while (item = Slideous.firstitem(slide, showitems ? Slideous.isitemhidden : Slideous.isitemvisible))- Slideous.displayitem(item, showitems);- slide.style.display = "block";- if (updatestatus)- Slideous.updatestatus();- }- },- firstitem: function(root, filter) {- var found = filter(root);- for (var node=root.firstChild; node!=null && !found; node = node.nextSibling)- found = Slideous.firstitem(node, filter);- return found;- },- lastitem: function(root, filter) {- var found = null;- for (var node=root.lastChild; node!=null && !found; node = node.previousSibling)- found = Slideous.lastitem(node, filter);- return found || filter(root);- },- isitem: function(node, visible) {- var nodename;- return node && node.nodeType == 1 // elements only ..- && (nodename=node.nodeName.toLowerCase()) in Slideous.incrementables- && ( Slideous.incrementables[nodename].filter.match("\\bself\\b") && (Slideous.hasclass(node, "incremental") || (Slideous.autoincrement && nodename in Slideous.autoincrementables))- || Slideous.incrementables[nodename].filter.match("\\bparent\\b") && (Slideous.hasclass(node.parentNode, "incremental") || (Slideous.autoincrement && node.parentNode.nodeName.toLowerCase() in Slideous.autoincrementables))- || Slideous.incrementables[nodename].filter.match("\\bgrandparent\\b") && (Slideous.hasclass(node.parentNode.parentNode, "incremental") || (Slideous.autoincrement && node.parentNode.parentNode.nodeName.toLowerCase() in Slideous.autoincrementables))- )- && (visible ? (node.style.visibility != "hidden")- : (node.style.visibility == "hidden"))- ? node : null;- },- isitemvisible: function(node) { return Slideous.isitem(node, true); },- isitemhidden: function(node) { return Slideous.isitem(node, false); },- displayitem: function(item, show) {- if (item) item.style.visibility = (show ? "visible" : "hidden");- },- updatestatus: function() {- if (Slideous.statusbar) {- var eos = document.getElementById("eos"), - idx = document.getElementById("slideidx"),- tocbox = document.getElementById("tocbox");- if (eos) - eos.style.visibility = Slideous.firstitem(document.getElementById("s"+Slideous.curidx), Slideous.isitemhidden) != null- ? "visible" : "hidden";- if (idx) - idx.innerHTML = Slideous.curidx;- if (tocbox)- tocbox.selectedIndex = Slideous.curidx-1;- }- },- changefontsize: function(delta) {- document.body.style.fontSize = (Slideous.fontsize+=delta)+"%";- },- togglestatusbar: function() {- document.getElementById("statusbar").style.display = (Slideous.statusbar = !Slideous.statusbar) ? "block" : "none";- },- toggleshowall: function(showall) {- var slide, item;- for (var i=0; i<Slideous.count; i++) {- slide = document.getElementById("s"+(i+1));- slide.style.display = showall ? "block" : "none";- while (item = Slideous.firstitem(slide, showall ? Slideous.isitemhidden : Slideous.isitemvisible)) - Slideous.displayitem(item, showall);- var divs = slide.getElementsByTagName("div");- for (var j in divs)- if (Slideous.hasclass(divs[j], "handout"))- divs[j].style.display = showall ? "block" : "none";- }- if (!showall)- document.getElementById("s"+Slideous.curidx).style.display = "block";- if (Slideous.statusbar) - document.getElementById("statusbar").style.display = showall ? "none" : "block";- Slideous.showall = showall;- },- hasclass: function(elem, classname) {- var classattr = null;- return (classattr=(elem.attributes && elem.attributes["class"])) - && classattr.nodeValue.match("\\b"+classname+"\\b");- },- selectedcontent: function() {- return window.getSelection ? window.getSelection().toString() - : document.getSelection ? document.getSelection() - : document.selection ? document.selection.createRange().text- : "";- },- mousenavigation: function(on) {- if (on) {- document.onmousedown = Slideous.mousedown;- document.onmouseup = Slideous.mouseup;- }- else- document.onmousedown = document.onmouseup = null;- },- mousepos: function(e) {- return e.pageX ? {x: e.pageX, y: e.pageY} - : {x: e.x+document.body.scrollLeft, y: e.y+document.body.scrollTop};- },- mousedown: function(evt) {- evt = evt||window.event;- Slideous.mousedownpos = Slideous.mousepos(evt);- Slideous.contentselected = !!Slideous.selectedcontent() || ((evt.target || evt.srcElement).nodeName.toLowerCase() in Slideous.clickables);- return true;- },- mouseup: function(evt) {- evt = evt||window.event;- var pos = Slideous.mousepos(evt);- if (pos.x == Slideous.mousedownpos.x && pos.y == Slideous.mousedownpos.y && !Slideous.contentselected) {- Slideous.next(true);- return evt.returnValue = !(evt.cancel = true);- }- return false;- }-};-window.onload = Slideous.init;
binary file changed (56 → absent bytes)
binary file changed (56 → absent bytes)
binary file changed (48 → absent bytes)
binary file changed (59 → absent bytes)
binary file changed (59 → absent bytes)
binary file changed (12801 → absent bytes)
@@ -1,405 +0,0 @@-/* slidy.css-- Copyright (c) 2005-2010 W3C (MIT, ERCIM, Keio), All Rights Reserved.- W3C liability, trademark, document use and software licensing- rules apply, see:-- http://www.w3.org/Consortium/Legal/copyright-documents- http://www.w3.org/Consortium/Legal/copyright-software-*/-body-{- margin: 0 0 0 0;- padding: 0 0 0 0;- width: 100%;- height: 100%;- color: black;- background-color: white;- font-family: "Gill Sans MT", "Gill Sans", GillSans, sans-serif;- font-size: 14pt;-}--div.toolbar {- position: fixed; z-index: 200;- top: auto; bottom: 0; left: 0; right: 0;- height: 1.2em; text-align: right;- padding-left: 1em;- padding-right: 1em; - font-size: 60%;- color: red;- background-color: rgb(240,240,240);- border-top: solid 1px rgb(180,180,180);-}--div.toolbar span.copyright {- color: black;- margin-left: 0.5em;-}--div.initial_prompt {- position: absolute;- z-index: 1000;- bottom: 1.2em;- width: 100%;- background-color: rgb(200,200,200);- opacity: 0.35;- background-color: rgb(200,200,200, 0.35);- cursor: pointer;-}--div.initial_prompt p.help {- text-align: center;-}--div.initial_prompt p.close {- text-align: right;- font-style: italic;-}--div.slidy_toc {- position: absolute;- z-index: 300;- width: 60%;- max-width: 30em;- height: 30em;- overflow: auto;- top: auto;- right: auto;- left: 4em;- bottom: 4em;- padding: 1em;- background: rgb(240,240,240);- border-style: solid;- border-width: 2px;- font-size: 60%;-}--div.slidy_toc .toc_heading {- text-align: center;- width: 100%;- margin: 0;- margin-bottom: 1em;- border-bottom-style: solid;- border-bottom-color: rgb(180,180,180);- border-bottom-width: 1px;-}--div.slide {- z-index: 20;- margin: 0 0 0 0;- padding-top: 0;- padding-bottom: 0;- padding-left: 20px;- padding-right: 20px;- border-width: 0;- clear: both;- top: 0;- bottom: 0;- left: 0;- right: 0;- line-height: 120%;- background-color: transparent;-}--div.background {- display: none;-}--div.handout {- margin-left: 20px;- margin-right: 20px;-}--div.slide.titlepage {- text-align: center;-}--div.slide.titlepage h1 {- padding-top: 10%;- margin-right: 0;-}--div.slide h1 {- padding-left: 0;- padding-right: 20pt;- padding-top: 4pt;- padding-bottom: 4pt;- margin-top: 0;- margin-left: 0;- margin-right: 60pt;- margin-bottom: 0.5em;- display: block; - font-size: 160%;- line-height: 1.2em;- background: transparent;-}--div.toc {- position: absolute;- top: auto;- bottom: 4em;- left: 4em;- right: auto;- width: 60%;- max-width: 30em;- height: 30em;- border: solid thin black;- padding: 1em;- background: rgb(240,240,240);- color: black;- z-index: 300;- overflow: auto;- display: block;- visibility: visible;-}--div.toc-heading {- width: 100%;- border-bottom: solid 1px rgb(180,180,180);- margin-bottom: 1em;- text-align: center;-}--img {- image-rendering: optimize-quality;-}--pre {- font-size: 80%;- font-weight: bold;- line-height: 120%;- padding-top: 0.2em;- padding-bottom: 0.2em;- padding-left: 1em;- padding-right: 1em;- border-style: solid;- border-left-width: 1em;- border-top-width: thin;- border-right-width: thin;- border-bottom-width: thin;- border-color: #95ABD0;- color: #00428C;- background-color: #E4E5E7;-}--li pre { margin-left: 0; }--blockquote { font-style: italic }--img { background-color: transparent }--p.copyright { font-size: smaller }--.center { text-align: center }-.footnote { font-size: smaller; margin-left: 2em; }--a img { border-width: 0; border-style: none }--a:visited { color: navy }-a:link { color: navy }-a:hover { color: red; text-decoration: underline }-a:active { color: red; text-decoration: underline }--a {text-decoration: none}-.navbar a:link {color: white}-.navbar a:visited {color: yellow}-.navbar a:active {color: red}-.navbar a:hover {color: red}--ul { list-style-type: square; }-ul ul { list-style-type: disc; }-ul ul ul { list-style-type: circle; }-ul ul ul ul { list-style-type: disc; }-li { margin-left: 0.5em; margin-top: 0.5em; }-li li { font-size: 85%; font-style: italic }-li li li { font-size: 85%; font-style: normal }--div dt-{- margin-left: 0;- margin-top: 1em;- margin-bottom: 0.5em;- font-weight: bold;-}-div dd-{- margin-left: 2em;- margin-bottom: 0.5em;-}---p,pre,ul,ol,blockquote,h2,h3,h4,h5,h6,dl,table {- margin-left: 1em;- margin-right: 1em;-}--p.subhead { font-weight: bold; margin-top: 2em; }--.smaller { font-size: smaller }-.bigger { font-size: 130% }--td,th { padding: 0.2em }--ul {- margin: 0.5em 1.5em 0.5em 1.5em;- padding: 0;-}--ol {- margin: 0.5em 1.5em 0.5em 1.5em;- padding: 0;-}--ul { list-style-type: square; }-ul ul { list-style-type: disc; }-ul ul ul { list-style-type: circle; }-ul ul ul ul { list-style-type: disc; }--ul li { - list-style: square;- margin: 0.1em 0em 0.6em 0;- padding: 0 0 0 0;- line-height: 140%;-}--ol li { - margin: 0.1em 0em 0.6em 1.5em;- padding: 0 0 0 0px;- line-height: 140%;- list-style-type: decimal;-}--li ul li { - font-size: 85%; - font-style: italic;- list-style-type: disc;- background: transparent;- padding: 0 0 0 0;-}-li li ul li { - font-size: 85%; - font-style: normal;- list-style-type: circle;- background: transparent;- padding: 0 0 0 0;-}-li li li ul li {- list-style-type: disc;- background: transparent;- padding: 0 0 0 0;-}--li ol li {- list-style-type: decimal;-}---li li ol li {- list-style-type: decimal;-}--/*- setting class="outline on ol or ul makes it behave as an- ouline list where blocklevel content in li elements is- hidden by default and can be expanded or collapsed with- mouse click. Set class="expand" on li to override default-*/--ol.outline li:hover { cursor: pointer }-ol.outline li.nofold:hover { cursor: default }--ul.outline li:hover { cursor: pointer }-ul.outline li.nofold:hover { cursor: default }--ol.outline { list-style:decimal; }-ol.outline ol { list-style-type:lower-alpha }--ol.outline li.nofold {- padding: 0 0 0 20px;- background: transparent url(../graphics/nofold-dim.gif) no-repeat 0px 0.5em;-}-ol.outline li.unfolded {- padding: 0 0 0 20px;- background: transparent url(../graphics/fold-dim.gif) no-repeat 0px 0.5em;-}-ol.outline li.folded {- padding: 0 0 0 20px;- background: transparent url(../graphics/unfold-dim.gif) no-repeat 0px 0.5em;-}-ol.outline li.unfolded:hover {- padding: 0 0 0 20px;- background: transparent url(../graphics/fold.gif) no-repeat 0px 0.5em;-}-ol.outline li.folded:hover {- padding: 0 0 0 20px;- background: transparent url(../graphics/unfold.gif) no-repeat 0px 0.5em;-}--ul.outline li.nofold {- padding: 0 0 0 20px;- background: transparent url(../graphics/nofold-dim.gif) no-repeat 0px 0.5em;-}-ul.outline li.unfolded {- padding: 0 0 0 20px;- background: transparent url(../graphics/fold-dim.gif) no-repeat 0px 0.5em;-}-ul.outline li.folded {- padding: 0 0 0 20px;- background: transparent url(../graphics/unfold-dim.gif) no-repeat 0px 0.5em;-}-ul.outline li.unfolded:hover {- padding: 0 0 0 20px;- background: transparent url(../graphics/fold.gif) no-repeat 0px 0.5em;-}-ul.outline li.folded:hover {- padding: 0 0 0 20px;- background: transparent url(../graphics/unfold.gif) no-repeat 0px 0.5em;-}--/* for slides with class "title" in table of contents */-a.titleslide { font-weight: bold; font-style: italic }--/*- hide images for work around for save as bug- where browsers fail to save images used by CSS-*/-img.hidden { display: none; visibility: hidden }-div.initial_prompt { display: none; visibility: hidden }-- div.slide {- visibility: visible;- position: inherit;- }- div.handout {- border-top-style: solid;- border-top-width: thin;- border-top-color: black;- }--@media screen {- .hidden { display: none; visibility: visible }-- div.slide.hidden { display: block; visibility: visible }- div.handout.hidden { display: block; visibility: visible }- div.background { display: none; visibility: hidden }- body.single_slide div.initial_prompt { display: block; visibility: visible }- body.single_slide div.background { display: block; visibility: visible }- body.single_slide div.background.hidden { display: none; visibility: hidden }- body.single_slide .invisible { visibility: hidden }- body.single_slide .hidden { display: none; visibility: hidden }- body.single_slide div.slide { position: absolute }- body.single_slide div.handout { display: none; visibility: hidden }-}--@media print {- .hidden { display: block; visibility: visible }-- div.slide pre { font-size: 60%; padding-left: 0.5em; }- div.toolbar { display: none; visibility: hidden; }- div.slidy_toc { display: none; visibility: hidden; }- div.background { display: none; visibility: hidden; }- div.slide { page-break-before: always }- /* :first-child isn't reliable for print media */- div.slide.first-slide { page-break-before: avoid }-}-
@@ -20,10 +20,10 @@ {- | Module : Text.Pandoc Copyright : Copyright (C) 2006-2010 John MacFarlane- License : GNU GPL, version 2 or above + License : GNU GPL, version 2 or above Maintainer : John MacFarlane <jgm@berkeley.edu>- Stability : alpha + Stability : alpha Portability : portable This helper module exports the main writers, readers, and data@@ -43,9 +43,8 @@ > > markdownToRST :: String -> String > markdownToRST =-> (writeRST defaultWriterOptions {writerReferenceLinks = True}) .-> readMarkdown defaultParserState-> +> (writeRST def {writerReferenceLinks = True}) . readMarkdown def+> > main = getContents >>= putStrLn . markdownToRST Note: all of the readers assume that the input text has @'\n'@@@ -55,31 +54,27 @@ -} module Text.Pandoc- ( + ( -- * Definitions module Text.Pandoc.Definition -- * Generics , module Text.Pandoc.Generic+ -- * Options+ , module Text.Pandoc.Options -- * Lists of readers and writers , readers , writers -- * Readers: converting /to/ Pandoc format , readMarkdown+ , readMediaWiki , readRST , readLaTeX , readHtml , readTextile , readDocBook , readNative- -- * Parser state used in readers- , ParserState (..)- , defaultParserState- , ParserContext (..)- , QuoteContext (..)- , KeyTable- , NoteTable- , HeaderType (..) -- * Writers: converting /from/ Pandoc format+ , Writer (..) , writeNative , writeMarkdown , writePlain@@ -98,20 +93,16 @@ , writeODT , writeDocx , writeEPUB+ , writeFB2 , writeOrg , writeAsciiDoc- -- * Writer options used in writers - , WriterOptions (..)- , HTMLSlideVariant (..)- , HTMLMathMethod (..)- , CiteMethod (..)- , defaultWriterOptions -- * Rendering templates and default templates , module Text.Pandoc.Templates -- * Version , pandocVersion -- * Miscellaneous- , rtfEmbedImage+ , getReader+ , getWriter , jsonFilter , ToJsonFilter(..) ) where@@ -119,6 +110,7 @@ import Text.Pandoc.Definition import Text.Pandoc.Generic import Text.Pandoc.Readers.Markdown+import Text.Pandoc.Readers.MediaWiki import Text.Pandoc.Readers.RST import Text.Pandoc.Readers.DocBook import Text.Pandoc.Readers.LaTeX@@ -127,7 +119,7 @@ import Text.Pandoc.Readers.Native import Text.Pandoc.Writers.Native import Text.Pandoc.Writers.Markdown-import Text.Pandoc.Writers.RST +import Text.Pandoc.Writers.RST import Text.Pandoc.Writers.LaTeX import Text.Pandoc.Writers.ConTeXt import Text.Pandoc.Writers.Texinfo@@ -135,85 +127,162 @@ import Text.Pandoc.Writers.ODT import Text.Pandoc.Writers.Docx import Text.Pandoc.Writers.EPUB+import Text.Pandoc.Writers.FB2 import Text.Pandoc.Writers.Docbook import Text.Pandoc.Writers.OpenDocument import Text.Pandoc.Writers.Man-import Text.Pandoc.Writers.RTF +import Text.Pandoc.Writers.RTF import Text.Pandoc.Writers.MediaWiki import Text.Pandoc.Writers.Textile import Text.Pandoc.Writers.Org import Text.Pandoc.Writers.AsciiDoc import Text.Pandoc.Templates-import Text.Pandoc.Parsing-import Text.Pandoc.Shared+import Text.Pandoc.Options+import Text.Pandoc.Shared (safeRead, warn)+import Data.ByteString.Lazy (ByteString)+import Data.List (intercalate) import Data.Version (showVersion) import Text.JSON.Generic+import Data.Set (Set)+import qualified Data.Set as Set+import Text.Parsec+import Text.Parsec.Error import Paths_pandoc (version) -- | Version number of pandoc library. pandocVersion :: String pandocVersion = showVersion version +parseFormatSpec :: String+ -> Either ParseError (String, Set Extension -> Set Extension)+parseFormatSpec = parse formatSpec ""+ where formatSpec = do+ name <- formatName+ extMods <- many extMod+ return (name, foldl (.) id extMods)+ formatName = many1 $ noneOf "-+"+ extMod = do+ polarity <- oneOf "-+"+ name <- many $ noneOf "-+"+ ext <- case safeRead ("Ext_" ++ name) of+ Just n -> return n+ Nothing+ | name == "lhs" -> return Ext_literate_haskell+ | otherwise -> fail $ "Unknown extension: " ++ name+ return $ case polarity of+ '-' -> Set.delete ext+ _ -> Set.insert ext++-- auxiliary function for readers:+markdown :: ReaderOptions -> String -> IO Pandoc+markdown o s = do+ let (doc, warnings) = readMarkdownWithWarnings o s+ mapM_ warn warnings+ return doc+ -- | Association list of formats and readers.-readers :: [(String, ParserState -> String -> Pandoc)]-readers = [("native" , \_ -> readNative)- ,("json" , \_ -> decodeJSON)- ,("markdown" , readMarkdown)- ,("markdown+lhs" , \st ->- readMarkdown st{ stateLiterateHaskell = True})- ,("rst" , readRST)- ,("rst+lhs" , \st ->- readRST st{ stateLiterateHaskell = True})- ,("docbook" , readDocBook)- ,("textile" , readTextile) -- TODO : textile+lhs - ,("html" , readHtml)- ,("latex" , readLaTeX)- ,("latex+lhs" , \st ->- readLaTeX st{ stateLiterateHaskell = True})+readers :: [(String, ReaderOptions -> String -> IO Pandoc)]+readers = [("native" , \_ s -> return $ readNative s)+ ,("json" , \_ s -> return $ decodeJSON s)+ ,("markdown" , markdown)+ ,("markdown_strict" , markdown)+ ,("markdown_phpextra" , markdown)+ ,("markdown_mmd", markdown)+ ,("rst" , \o s -> return $ readRST o s)+ ,("mediawiki" , \o s -> return $ readMediaWiki o s)+ ,("docbook" , \o s -> return $ readDocBook o s)+ ,("textile" , \o s -> return $ readTextile o s) -- TODO : textile+lhs+ ,("html" , \o s -> return $ readHtml o s)+ ,("latex" , \o s -> return $ readLaTeX o s) ] --- | Association list of formats and writers (omitting the--- binary writers, odt, docx, and epub).-writers :: [ ( String, WriterOptions -> Pandoc -> String ) ]-writers = [("native" , writeNative)- ,("json" , \_ -> encodeJSON)- ,("html" , writeHtmlString)- ,("html5" , \o ->- writeHtmlString o{ writerHtml5 = True })- ,("html+lhs" , \o ->- writeHtmlString o{ writerLiterateHaskell = True })- ,("html5+lhs" , \o ->- writeHtmlString o{ writerLiterateHaskell = True,- writerHtml5 = True })- ,("s5" , writeHtmlString)- ,("slidy" , writeHtmlString)- ,("slideous" , writeHtmlString)- ,("dzslides" , writeHtmlString)- ,("docbook" , writeDocbook)- ,("opendocument" , writeOpenDocument)- ,("latex" , writeLaTeX)- ,("latex+lhs" , \o ->- writeLaTeX o{ writerLiterateHaskell = True })- ,("beamer" , \o ->- writeLaTeX o{ writerBeamer = True })- ,("beamer+lhs" , \o ->- writeLaTeX o{ writerBeamer = True, writerLiterateHaskell = True })- ,("context" , writeConTeXt)- ,("texinfo" , writeTexinfo)- ,("man" , writeMan)- ,("markdown" , writeMarkdown)- ,("markdown+lhs" , \o ->- writeMarkdown o{ writerLiterateHaskell = True })- ,("plain" , writePlain)- ,("rst" , writeRST)- ,("rst+lhs" , \o ->- writeRST o{ writerLiterateHaskell = True })- ,("mediawiki" , writeMediaWiki)- ,("textile" , writeTextile)- ,("rtf" , writeRTF)- ,("org" , writeOrg)- ,("asciidoc" , writeAsciiDoc)- ]+data Writer = PureStringWriter (WriterOptions -> Pandoc -> String)+ | IOStringWriter (WriterOptions -> Pandoc -> IO String)+ | IOByteStringWriter (WriterOptions -> Pandoc -> IO ByteString)++-- | Association list of formats and writers.+writers :: [ ( String, Writer ) ]+writers = [+ ("native" , PureStringWriter writeNative)+ ,("json" , PureStringWriter $ \_ -> encodeJSON)+ ,("docx" , IOByteStringWriter writeDocx)+ ,("odt" , IOByteStringWriter writeODT)+ ,("epub" , IOByteStringWriter $ \o ->+ writeEPUB o{ writerEpubVersion = Just EPUB2 })+ ,("epub3" , IOByteStringWriter $ \o ->+ writeEPUB o{ writerEpubVersion = Just EPUB3 })+ ,("fb2" , IOStringWriter writeFB2)+ ,("html" , PureStringWriter writeHtmlString)+ ,("html5" , PureStringWriter $ \o ->+ writeHtmlString o{ writerHtml5 = True })+ ,("s5" , PureStringWriter $ \o ->+ writeHtmlString o{ writerSlideVariant = S5Slides+ , writerTableOfContents = False })+ ,("slidy" , PureStringWriter $ \o ->+ writeHtmlString o{ writerSlideVariant = SlidySlides })+ ,("slideous" , PureStringWriter $ \o ->+ writeHtmlString o{ writerSlideVariant = SlideousSlides })+ ,("dzslides" , PureStringWriter $ \o ->+ writeHtmlString o{ writerSlideVariant = DZSlides+ , writerHtml5 = True })+ ,("docbook" , PureStringWriter writeDocbook)+ ,("opendocument" , PureStringWriter writeOpenDocument)+ ,("latex" , PureStringWriter writeLaTeX)+ ,("beamer" , PureStringWriter $ \o ->+ writeLaTeX o{ writerBeamer = True })+ ,("context" , PureStringWriter writeConTeXt)+ ,("texinfo" , PureStringWriter writeTexinfo)+ ,("man" , PureStringWriter writeMan)+ ,("markdown" , PureStringWriter writeMarkdown)+ ,("markdown_strict" , PureStringWriter writeMarkdown)+ ,("markdown_phpextra" , PureStringWriter writeMarkdown)+ ,("markdown_github" , PureStringWriter writeMarkdown)+ ,("markdown_mmd" , PureStringWriter writeMarkdown)+ ,("plain" , PureStringWriter writePlain)+ ,("rst" , PureStringWriter writeRST)+ ,("mediawiki" , PureStringWriter writeMediaWiki)+ ,("textile" , PureStringWriter writeTextile)+ ,("rtf" , IOStringWriter writeRTFWithEmbeddedImages)+ ,("org" , PureStringWriter writeOrg)+ ,("asciidoc" , PureStringWriter writeAsciiDoc)+ ]++getDefaultExtensions :: String -> Set Extension+getDefaultExtensions "markdown_strict" = strictExtensions+getDefaultExtensions "markdown_phpextra" = phpMarkdownExtraExtensions+getDefaultExtensions "markdown_mmd" = multimarkdownExtensions+getDefaultExtensions "markdown_github" = githubMarkdownExtensions+getDefaultExtensions _ = pandocExtensions++-- | Retrieve reader based on formatSpec (format+extensions).+getReader :: String -> Either String (ReaderOptions -> String -> IO Pandoc)+getReader s =+ case parseFormatSpec s of+ Left e -> Left $ intercalate "\n" $ [m | Message m <- errorMessages e]+ Right (readerName, setExts) ->+ case lookup readerName readers of+ Nothing -> Left $ "Unknown reader: " ++ readerName+ Just r -> Right $ \o ->+ r o{ readerExtensions = setExts $+ getDefaultExtensions readerName }++-- | Retrieve writer based on formatSpec (format+extensions).+getWriter :: String -> Either String Writer+getWriter s =+ case parseFormatSpec s of+ Left e -> Left $ intercalate "\n" $ [m | Message m <- errorMessages e]+ Right (writerName, setExts) ->+ case lookup writerName writers of+ Nothing -> Left $ "Unknown writer: " ++ writerName+ Just (PureStringWriter r) -> Right $ PureStringWriter $+ \o -> r o{ writerExtensions = setExts $+ getDefaultExtensions writerName }+ Just (IOStringWriter r) -> Right $ IOStringWriter $+ \o -> r o{ writerExtensions = setExts $+ getDefaultExtensions writerName }+ Just (IOByteStringWriter r) -> Right $ IOByteStringWriter $+ \o -> r o{ writerExtensions = setExts $+ getDefaultExtensions writerName } {-# DEPRECATED jsonFilter "Use toJsonFilter instead" #-} -- | Converts a transformation on the Pandoc AST into a function
@@ -30,7 +30,6 @@ module Text.Pandoc.Biblio ( processBiblio ) where import Data.List-import Data.Unique import Data.Char ( isDigit, isPunctuation ) import qualified Data.Map as M import Text.CSL hiding ( Cite(..), Citation(..) )@@ -38,30 +37,24 @@ import Text.Pandoc.Definition import Text.Pandoc.Generic import Text.Pandoc.Shared (stringify)-import Text.ParserCombinators.Parsec+import Text.Parsec hiding (State) import Control.Monad+import Control.Monad.State -- | Process a 'Pandoc' document by adding citations formatted -- according to a CSL style, using 'citeproc' from citeproc-hs.-processBiblio :: FilePath -> Maybe FilePath -> [Reference] -> Pandoc- -> IO Pandoc-processBiblio cslfile abrfile r p- = if null r then return p- else do- csl <- readCSLFile cslfile- abbrevs <- case abrfile of- Just f -> readJsonAbbrevFile f- Nothing -> return []- p' <- bottomUpM setHash p- let grps = queryWith getCitation p'- style = csl { styleAbbrevs = abbrevs }- result = citeproc procOpts style r (setNearNote style $- map (map toCslCite) grps)- cits_map = M.fromList $ zip grps (citations result)- biblioList = map (renderPandoc' style) (bibliography result)- Pandoc m b = bottomUp (processCite style cits_map) p'- b' = bottomUp mvPunct $ deNote b- return $ Pandoc m $ b' ++ biblioList+processBiblio :: Maybe Style -> [Reference] -> Pandoc -> Pandoc+processBiblio Nothing _ p = p+processBiblio _ [] p = p+processBiblio (Just style) r p =+ let p' = evalState (bottomUpM setHash p) 1+ grps = queryWith getCitation p'+ result = citeproc procOpts style r (setNearNote style $+ map (map toCslCite) grps)+ cits_map = M.fromList $ zip grps (citations result)+ biblioList = map (renderPandoc' style) (bibliography result)+ Pandoc m b = bottomUp mvPunct . deNote . bottomUp (processCite style cits_map) $ p'+ in Pandoc m $ b ++ biblioList -- | Substitute 'Cite' elements with formatted citations. processCite :: Style -> M.Map [Citation] [FormattedOutput] -> Inline -> Inline@@ -92,18 +85,10 @@ mvPunct xs = xs sanitize :: [Inline] -> [Inline]-sanitize xs | endWithPunct xs = toCapital' xs- | otherwise = toCapital' (xs ++ [Str "."])---- NOTE: toCapital' works around a bug in toCapital from citeproc-hs 0.3.4.--- When citeproc-hs is fixed, we can return to using toCapital in sanitize.-toCapital' :: [Inline] -> [Inline]-toCapital' [] = []-toCapital' xs = case toCapital xs of- [] -> xs- ys -> ys+sanitize xs | endWithPunct xs = toCapital xs+ | otherwise = toCapital (xs ++ [Str "."]) -deNote :: [Block] -> [Block]+deNote :: Pandoc -> Pandoc deNote = topDown go where go (Note [Para xs]) = Note $ bottomUp go' [Para $ sanitize xs] go (Note xs) = Note $ bottomUp go' xs@@ -124,9 +109,11 @@ getCitation i | Cite t _ <- i = [t] | otherwise = [] -setHash :: Citation -> IO Citation-setHash (Citation i p s cm nn _)- = hashUnique `fmap` newUnique >>= return . Citation i p s cm nn+setHash :: Citation -> State Int Citation+setHash c = do+ ident <- get+ put $ ident + 1+ return c{ citationHash = ident } toCslCite :: Citation -> CSL.Cite toCslCite c@@ -165,7 +152,7 @@ breakup (x : xs) = x : breakup xs splitup = groupBy (\x y -> x /= '\160' && y /= '\160') -pLocatorWords :: GenParser Inline st (String, [Inline])+pLocatorWords :: Parsec [Inline] st (String, [Inline]) pLocatorWords = do l <- pLocator s <- getInput -- rest is suffix@@ -173,16 +160,16 @@ then return (init l, Str "," : s) else return (l, s) -pMatch :: (Inline -> Bool) -> GenParser Inline st Inline+pMatch :: (Inline -> Bool) -> Parsec [Inline] st Inline pMatch condition = try $ do t <- anyToken guard $ condition t return t -pSpace :: GenParser Inline st Inline+pSpace :: Parsec [Inline] st Inline pSpace = pMatch (\t -> t == Space || t == Str "\160") -pLocator :: GenParser Inline st String+pLocator :: Parsec [Inline] st String pLocator = try $ do optional $ pMatch (== Str ",") optional pSpace@@ -190,7 +177,7 @@ gs <- many1 pWordWithDigits return $ stringify f ++ (' ' : unwords gs) -pWordWithDigits :: GenParser Inline st String+pWordWithDigits :: Parsec [Inline] st String pWordWithDigits = try $ do pSpace r <- many1 (notFollowedBy pSpace >> anyToken)
@@ -47,6 +47,7 @@ , Style ) where import Text.Pandoc.Definition+import Text.Pandoc.Shared (safeRead) import Text.Highlighting.Kate import Data.List (find) import Data.Maybe (fromMaybe)@@ -60,9 +61,9 @@ -> String -- ^ Raw contents of the CodeBlock -> Maybe a -- ^ Maybe the formatted result highlight formatter (_, classes, keyvals) rawCode =- let firstNum = case reads (fromMaybe "1" $ lookup "startFrom" keyvals) of- ((n,_):_) -> n- [] -> 1+ let firstNum = case safeRead (fromMaybe "1" $ lookup "startFrom" keyvals) of+ Just n -> n+ Nothing -> 1 fmtOpts = defaultFormatOpts{ startNumber = firstNum, numberLines = any (`elem`
@@ -29,9 +29,9 @@ Functions for determining the size of a PNG, JPEG, or GIF image. -} module Text.Pandoc.ImageSize ( ImageType(..), imageType, imageSize,- sizeInPixels, sizeInPoints, readImageSize ) where-import Data.ByteString.Lazy (ByteString, unpack)-import qualified Data.ByteString.Lazy.Char8 as B+ sizeInPixels, sizeInPoints ) where+import Data.ByteString (ByteString, unpack)+import qualified Data.ByteString.Char8 as B import Control.Monad import Data.Bits @@ -47,9 +47,6 @@ , dpiY :: Integer } deriving (Read, Show, Eq) --readImageSize :: FilePath -> IO (Maybe ImageSize)-readImageSize fp = imageSize `fmap` B.readFile fp imageType :: ByteString -> Maybe ImageType imageType img = case B.take 4 img of
@@ -19,7 +19,7 @@ {- | Module : Text.Pandoc.MIME Copyright : Copyright (C) 2011 John MacFarlane- License : GNU GPL, version 2 or above + License : GNU GPL, version 2 or above Maintainer : John MacFarlane <jgm@berkeley.edu> Stability : alpha@@ -141,6 +141,7 @@ ,("embl","chemical/x-embl-dl-nucleotide") ,("eml","message/rfc822") ,("ent","chemical/x-ncbi-asn1-ascii")+ ,("eot","application/vnd.ms-fontobject") ,("eps","application/postscript") ,("etx","text/x-setext") ,("exe","application/x-msdos-program")@@ -155,6 +156,7 @@ ,("fm","application/x-maker") ,("frame","application/x-maker") ,("frm","application/x-maker")+ ,("fs","text/plain") ,("gal","chemical/x-gaussian-log") ,("gam","chemical/x-gamess-input") ,("gamin","chemical/x-gamess-input")@@ -442,6 +444,7 @@ ,("vms","chemical/x-vamas-iso14976") ,("vrm","x-world/x-vrml") ,("vrml","model/vrml")+ ,("vs","text/plain") ,("vsd","application/vnd.visio") ,("wad","application/x-doom") ,("wav","audio/x-wav")@@ -460,6 +463,7 @@ ,("wmv","video/x-ms-wmv") ,("wmx","video/x-ms-wmx") ,("wmz","application/x-ms-wmz")+ ,("woff","application/x-font-woff") ,("wp5","application/wordperfect5.1") ,("wpd","application/wordperfect") ,("wrl","model/vrml")
@@ -0,0 +1,347 @@+{-+Copyright (C) 2012 John MacFarlane <jgm@berkeley.edu>++This program is free software; you can redistribute it and/or modify+it under the terms of the GNU General Public License as published by+the Free Software Foundation; either version 2 of the License, or+(at your option) any later version.++This program is distributed in the hope that it will be useful,+but WITHOUT ANY WARRANTY; without even the implied warranty of+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+GNU General Public License for more details.++You should have received a copy of the GNU General Public License+along with this program; if not, write to the Free Software+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA+-}++{- |+ Module : Text.Pandoc.Options+ Copyright : Copyright (C) 2012 John MacFarlane+ License : GNU GPL, version 2 or above++ Maintainer : John MacFarlane <jgm@berkeley.edu>+ Stability : alpha+ Portability : portable++Data structures and functions for representing parser and writer+options.+-}+module Text.Pandoc.Options ( Extension(..)+ , pandocExtensions+ , strictExtensions+ , phpMarkdownExtraExtensions+ , githubMarkdownExtensions+ , multimarkdownExtensions+ , ReaderOptions(..)+ , HTMLMathMethod (..)+ , CiteMethod (..)+ , ObfuscationMethod (..)+ , HTMLSlideVariant (..)+ , EPUBVersion (..)+ , WriterOptions (..)+ , def+ , isEnabled+ ) where+import Data.Set (Set)+import qualified Data.Set as Set+import Data.Default+import Text.Pandoc.Highlighting (Style, pygments)+import qualified Text.CSL as CSL++-- | Individually selectable syntax extensions.+data Extension =+ Ext_footnotes -- ^ Pandoc/PHP/MMD style footnotes+ | Ext_inline_notes -- ^ Pandoc-style inline notes+ | Ext_pandoc_title_block -- ^ Pandoc title block+ | Ext_mmd_title_block -- ^ Multimarkdown metadata block+ | Ext_table_captions -- ^ Pandoc-style table captions+ | Ext_implicit_figures -- ^ A paragraph with just an image is a figure+ | Ext_simple_tables -- ^ Pandoc-style simple tables+ | Ext_multiline_tables -- ^ Pandoc-style multiline tables+ | Ext_grid_tables -- ^ Grid tables (pandoc, reST)+ | Ext_pipe_tables -- ^ Pipe tables (as in PHP markdown extra)+ | Ext_citations -- ^ Pandoc/citeproc citations+ | Ext_raw_tex -- ^ Allow raw TeX (other than math)+ | Ext_raw_html -- ^ Allow raw HTML+ | Ext_tex_math_dollars -- ^ TeX math between $..$ or $$..$$+ | Ext_tex_math_single_backslash -- ^ TeX math btw \(..\) \[..\]+ | Ext_tex_math_double_backslash -- ^ TeX math btw \\(..\\) \\[..\\]+ | Ext_latex_macros -- ^ Parse LaTeX macro definitions (for math only)+ | Ext_fenced_code_blocks -- ^ Parse fenced code blocks+ | Ext_fenced_code_attributes -- ^ Allow attributes on fenced code blocks+ | Ext_backtick_code_blocks -- ^ Github style ``` code blocks+ | Ext_inline_code_attributes -- ^ Allow attributes on inline code+ | Ext_markdown_in_html_blocks -- ^ Interpret as markdown inside HTML blocks+ | Ext_markdown_attribute -- ^ Interpret text inside HTML as markdown+ -- iff container has attribute 'markdown'+ | Ext_escaped_line_breaks -- ^ Treat a backslash at EOL as linebreak+ | Ext_link_attributes -- ^ MMD style reference link attributes+ | Ext_autolink_bare_uris -- ^ Make all absolute URIs into links+ | Ext_fancy_lists -- ^ Enable fancy list numbers and delimiters+ | Ext_startnum -- ^ Make start number of ordered list significant+ | Ext_definition_lists -- ^ Definition lists as in pandoc, mmd, php+ | Ext_example_lists -- ^ Markdown-style numbered examples+ | Ext_all_symbols_escapable -- ^ Make all non-alphanumerics escapable+ | Ext_intraword_underscores -- ^ Treat underscore inside word as literal+ | Ext_blank_before_blockquote -- ^ Require blank line before a blockquote+ | Ext_blank_before_header -- ^ Require blank line before a header+ | Ext_strikeout -- ^ Strikeout using ~~this~~ syntax+ | Ext_superscript -- ^ Superscript using ^this^ syntax+ | Ext_subscript -- ^ Subscript using ~this~ syntax+ | Ext_hard_line_breaks -- ^ All newlines become hard line breaks+ | Ext_literate_haskell -- ^ Enable literate Haskell conventions+ | Ext_abbreviations -- ^ PHP markdown extra abbreviation definitions+ | Ext_auto_identifiers -- ^ Automatic identifiers for headers+ | Ext_header_attributes -- ^ Explicit header attributes {#id .class k=v}+ | Ext_mmd_header_identifiers -- ^ Multimarkdown style header identifiers [myid]+ | Ext_implicit_header_references -- ^ Implicit reference links for headers+ | Ext_line_blocks -- ^ RST style line blocks+ deriving (Show, Read, Enum, Eq, Ord, Bounded)++pandocExtensions :: Set Extension+pandocExtensions = Set.fromList+ [ Ext_footnotes+ , Ext_inline_notes+ , Ext_pandoc_title_block+ , Ext_table_captions+ , Ext_implicit_figures+ , Ext_simple_tables+ , Ext_multiline_tables+ , Ext_grid_tables+ , Ext_pipe_tables+ , Ext_citations+ , Ext_raw_tex+ , Ext_raw_html+ , Ext_tex_math_dollars+ , Ext_latex_macros+ , Ext_fenced_code_blocks+ , Ext_fenced_code_attributes+ , Ext_backtick_code_blocks+ , Ext_inline_code_attributes+ , Ext_markdown_in_html_blocks+ , Ext_escaped_line_breaks+ , Ext_fancy_lists+ , Ext_startnum+ , Ext_definition_lists+ , Ext_example_lists+ , Ext_all_symbols_escapable+ , Ext_intraword_underscores+ , Ext_blank_before_blockquote+ , Ext_blank_before_header+ , Ext_strikeout+ , Ext_superscript+ , Ext_subscript+ , Ext_auto_identifiers+ , Ext_header_attributes+ , Ext_implicit_header_references+ , Ext_line_blocks+ ]++phpMarkdownExtraExtensions :: Set Extension+phpMarkdownExtraExtensions = Set.fromList+ [ Ext_footnotes+ , Ext_pipe_tables+ , Ext_raw_html+ , Ext_markdown_attribute+ , Ext_fenced_code_blocks+ , Ext_definition_lists+ , Ext_intraword_underscores+ , Ext_header_attributes+ , Ext_abbreviations+ ]++githubMarkdownExtensions :: Set Extension+githubMarkdownExtensions = Set.fromList+ [ Ext_pipe_tables+ , Ext_raw_html+ , Ext_tex_math_single_backslash+ , Ext_fenced_code_blocks+ , Ext_fenced_code_attributes+ , Ext_backtick_code_blocks+ , Ext_autolink_bare_uris+ , Ext_intraword_underscores+ , Ext_strikeout+ , Ext_hard_line_breaks+ ]++multimarkdownExtensions :: Set Extension+multimarkdownExtensions = Set.fromList+ [ Ext_pipe_tables+ , Ext_raw_html+ , Ext_markdown_attribute+ , Ext_link_attributes+ , Ext_raw_tex+ , Ext_tex_math_double_backslash+ , Ext_intraword_underscores+ , Ext_mmd_title_block+ , Ext_footnotes+ , Ext_definition_lists+ , Ext_all_symbols_escapable+ , Ext_implicit_header_references+ , Ext_auto_identifiers+ , Ext_mmd_header_identifiers+ ]++strictExtensions :: Set Extension+strictExtensions = Set.fromList+ [ Ext_raw_html ]++data ReaderOptions = ReaderOptions{+ readerExtensions :: Set Extension -- ^ Syntax extensions+ , readerSmart :: Bool -- ^ Smart punctuation+ , readerStrict :: Bool -- ^ FOR TRANSITION ONLY+ , readerStandalone :: Bool -- ^ Standalone document with header+ , readerParseRaw :: Bool -- ^ Parse raw HTML, LaTeX+ , readerColumns :: Int -- ^ Number of columns in terminal+ , readerTabStop :: Int -- ^ Tab stop+ , readerOldDashes :: Bool -- ^ Use pandoc <= 1.8.2.1 behavior+ -- in parsing dashes; -- is em-dash;+ -- - before numerial is en-dash+ , readerReferences :: [CSL.Reference] -- ^ Bibliographic references+ , readerCitationStyle :: Maybe CSL.Style -- ^ Citation style+ , readerApplyMacros :: Bool -- ^ Apply macros to TeX math+ , readerIndentedCodeClasses :: [String] -- ^ Default classes for+ -- indented code blocks+} deriving (Show, Read)++instance Default ReaderOptions+ where def = ReaderOptions{+ readerExtensions = pandocExtensions+ , readerSmart = False+ , readerStrict = False+ , readerStandalone = False+ , readerParseRaw = False+ , readerColumns = 80+ , readerTabStop = 4+ , readerOldDashes = False+ , readerReferences = []+ , readerCitationStyle = Nothing+ , readerApplyMacros = True+ , readerIndentedCodeClasses = []+ }++--+-- Writer options+--++data EPUBVersion = EPUB2 | EPUB3 deriving (Eq, Show, Read)++data HTMLMathMethod = PlainMath+ | LaTeXMathML (Maybe String) -- url of LaTeXMathML.js+ | JsMath (Maybe String) -- url of jsMath load script+ | GladTeX+ | WebTeX String -- url of TeX->image script.+ | MathML (Maybe String) -- url of MathMLinHTML.js+ | MathJax String -- url of MathJax.js+ deriving (Show, Read, Eq)++data CiteMethod = Citeproc -- use citeproc to render them+ | Natbib -- output natbib cite commands+ | Biblatex -- output biblatex cite commands+ deriving (Show, Read, Eq)++-- | Methods for obfuscating email addresses in HTML.+data ObfuscationMethod = NoObfuscation+ | ReferenceObfuscation+ | JavascriptObfuscation+ deriving (Show, Read, Eq)++-- | Varieties of HTML slide shows.+data HTMLSlideVariant = S5Slides+ | SlidySlides+ | SlideousSlides+ | DZSlides+ | NoSlides+ deriving (Show, Read, Eq)++-- | Options for writers+data WriterOptions = WriterOptions+ { writerStandalone :: Bool -- ^ Include header and footer+ , writerTemplate :: String -- ^ Template to use in standalone mode+ , writerVariables :: [(String, String)] -- ^ Variables to set in template+ , writerTabStop :: Int -- ^ Tabstop for conversion btw spaces and tabs+ , writerTableOfContents :: Bool -- ^ Include table of contents+ , writerSlideVariant :: HTMLSlideVariant -- ^ Are we writing S5, Slidy or Slideous?+ , writerIncremental :: Bool -- ^ True if lists should be incremental+ , writerHTMLMathMethod :: HTMLMathMethod -- ^ How to print math in HTML+ , writerIgnoreNotes :: Bool -- ^ Ignore footnotes (used in making toc)+ , writerNumberSections :: Bool -- ^ Number sections in LaTeX+ , writerSectionDivs :: Bool -- ^ Put sections in div tags in HTML+ , writerExtensions :: Set Extension -- ^ Markdown extensions that can be used+ , writerReferenceLinks :: Bool -- ^ Use reference links in writing markdown, rst+ , writerWrapText :: Bool -- ^ Wrap text to line length+ , writerColumns :: Int -- ^ Characters in a line (for text wrapping)+ , writerEmailObfuscation :: ObfuscationMethod -- ^ How to obfuscate emails+ , writerIdentifierPrefix :: String -- ^ Prefix for section & note ids in HTML+ -- and for footnote marks in markdown+ , writerSourceDirectory :: FilePath -- ^ Directory path of 1st source file+ , writerUserDataDir :: Maybe FilePath -- ^ Path of user data directory+ , writerCiteMethod :: CiteMethod -- ^ How to print cites+ , writerBiblioFiles :: [FilePath] -- ^ Biblio files to use for citations+ , writerHtml5 :: Bool -- ^ Produce HTML5+ , writerHtmlQTags :: Bool -- ^ Use @<q>@ tags for quotes in HTML+ , writerBeamer :: Bool -- ^ Produce beamer LaTeX slide show+ , writerSlideLevel :: Maybe Int -- ^ Force header level of slides+ , writerChapters :: Bool -- ^ Use "chapter" for top-level sects+ , writerListings :: Bool -- ^ Use listings package for code+ , writerHighlight :: Bool -- ^ Highlight source code+ , writerHighlightStyle :: Style -- ^ Style to use for highlighting+ , writerSetextHeaders :: Bool -- ^ Use setext headers for levels 1-2 in markdown+ , writerTeXLigatures :: Bool -- ^ Use tex ligatures quotes, dashes in latex+ , writerEpubVersion :: Maybe EPUBVersion -- ^ Nothing or EPUB version+ , writerEpubMetadata :: String -- ^ Metadata to include in EPUB+ , writerEpubStylesheet :: Maybe String -- ^ EPUB stylesheet specified at command line+ , writerEpubFonts :: [FilePath] -- ^ Paths to fonts to embed+ , writerEpubChapterLevel :: Int -- ^ Header level for chapters (separate files)+ , writerTOCDepth :: Int -- ^ Number of levels to include in TOC+ , writerReferenceODT :: Maybe FilePath -- ^ Path to reference ODT if specified+ , writerReferenceDocx :: Maybe FilePath -- ^ Ptah to reference DOCX if specified+ } deriving Show++instance Default WriterOptions where+ def = WriterOptions { writerStandalone = False+ , writerTemplate = ""+ , writerVariables = []+ , writerTabStop = 4+ , writerTableOfContents = False+ , writerSlideVariant = NoSlides+ , writerIncremental = False+ , writerHTMLMathMethod = PlainMath+ , writerIgnoreNotes = False+ , writerNumberSections = False+ , writerSectionDivs = False+ , writerExtensions = pandocExtensions+ , writerReferenceLinks = False+ , writerWrapText = True+ , writerColumns = 72+ , writerEmailObfuscation = JavascriptObfuscation+ , writerIdentifierPrefix = ""+ , writerSourceDirectory = "."+ , writerUserDataDir = Nothing+ , writerCiteMethod = Citeproc+ , writerBiblioFiles = []+ , writerHtml5 = False+ , writerHtmlQTags = False+ , writerBeamer = False+ , writerSlideLevel = Nothing+ , writerChapters = False+ , writerListings = False+ , writerHighlight = False+ , writerHighlightStyle = pygments+ , writerSetextHeaders = True+ , writerTeXLigatures = True+ , writerEpubVersion = Nothing+ , writerEpubMetadata = ""+ , writerEpubStylesheet = Nothing+ , writerEpubFonts = []+ , writerEpubChapterLevel = 1+ , writerTOCDepth = 3+ , writerReferenceODT = Nothing+ , writerReferenceDocx = Nothing+ }++-- | Returns True if the given extension is enabled.+isEnabled :: Extension -> WriterOptions -> Bool+isEnabled ext opts = ext `Set.member` (writerExtensions opts)
@@ -1,3 +1,4 @@+{-# LANGUAGE GeneralizedNewtypeDeriving #-} {- Copyright (C) 2006-2010 John MacFarlane <jgm@berkeley.edu> @@ -19,7 +20,7 @@ {- | Module : Text.Pandoc.Parsing Copyright : Copyright (C) 2006-2010 John MacFarlane- License : GNU GPL, version 2 or above + License : GNU GPL, version 2 or above Maintainer : John MacFarlane <jgm@berkeley.edu> Stability : alpha@@ -32,6 +33,7 @@ many1Till, notFollowedBy', oneOfStrings,+ oneOfStringsCI, spaceChar, nonspaceChar, skipSpaces,@@ -47,110 +49,221 @@ uri, withHorizDisplacement, withRaw,- nullBlock,- failIfStrict,- failUnlessLHS, escaped, characterReference, updateLastStrPos, anyOrderedListMarker, orderedListMarker, charRef,+ lineBlockLines, tableWith,+ widthsFromIndices, gridTableWith, readWith, testStringWith,+ getOption,+ guardEnabled,+ guardDisabled, ParserState (..), defaultParserState, HeaderType (..), ParserContext (..), QuoteContext (..), NoteTable,+ NoteTable', KeyTable,- Key,+ SubstTable,+ Key (..), toKey,- fromKey,- lookupKeySrc, smartPunctuation,+ withQuoteContext,+ singleQuoteStart,+ singleQuoteEnd,+ doubleQuoteStart,+ doubleQuoteEnd,+ ellipses,+ apostrophe,+ dash,+ nested, macro,- applyMacros' )+ applyMacros',+ Parser,+ F(..),+ runF,+ askF,+ asksF,+ -- * Re-exports from Text.Pandoc.Parsec+ runParser,+ parse,+ anyToken,+ getInput,+ setInput,+ unexpected,+ char,+ letter,+ digit,+ alphaNum,+ skipMany,+ skipMany1,+ spaces,+ space,+ anyChar,+ satisfy,+ newline,+ string,+ count,+ eof,+ noneOf,+ oneOf,+ lookAhead,+ notFollowedBy,+ many,+ many1,+ manyTill,+ (<|>),+ (<?>),+ choice,+ try,+ sepBy,+ sepBy1,+ sepEndBy,+ sepEndBy1,+ endBy,+ endBy1,+ option,+ optional,+ optionMaybe,+ getState,+ setState,+ updateState,+ SourcePos,+ getPosition,+ setPosition,+ sourceColumn,+ sourceLine,+ newPos,+ token+ ) where import Text.Pandoc.Definition-import Text.Pandoc.Generic+import Text.Pandoc.Options+import Text.Pandoc.Builder (Blocks, Inlines) import qualified Text.Pandoc.UTF8 as UTF8 (putStrLn)-import Text.ParserCombinators.Parsec-import Data.Char ( toLower, toUpper, ord, isAscii, isAlphaNum, isDigit, isPunctuation )+import Text.Parsec+import Text.Parsec.Pos (newPos)+import Data.Char ( toLower, toUpper, ord, isAscii, isAlphaNum, isDigit, isHexDigit,+ isSpace ) import Data.List ( intercalate, transpose )-import Network.URI ( parseURI, URI (..), isAllowedInURI )-import Control.Monad ( join, liftM, guard ) import Text.Pandoc.Shared import qualified Data.Map as M import Text.TeXMath.Macros (applyMacros, Macro, parseMacroDefinitions) import Text.HTML.TagSoup.Entity ( lookupEntity )+import Data.Default+import qualified Data.Set as Set+import Control.Monad.Reader+import Control.Applicative ((*>), (<*), (<$), liftA2)+import Data.Monoid +type Parser t s = Parsec t s++newtype F a = F { unF :: Reader ParserState a } deriving (Monad, Functor)++runF :: F a -> ParserState -> a+runF = runReader . unF++askF :: F ParserState+askF = F ask++asksF :: (ParserState -> a) -> F a+asksF f = F $ asks f++instance Monoid a => Monoid (F a) where+ mempty = return mempty+ mappend = liftM2 mappend+ mconcat = liftM mconcat . sequence+ -- | Like >>, but returns the operation on the left. -- (Suggested by Tillmann Rendel on Haskell-cafe list.) (>>~) :: (Monad m) => m a -> m b -> m a a >>~ b = a >>= \x -> b >> return x -- | Parse any line of text-anyLine :: GenParser Char st [Char]+anyLine :: Parser [Char] st [Char] anyLine = manyTill anyChar newline -- | Like @manyTill@, but reads at least one item.-many1Till :: GenParser tok st a- -> GenParser tok st end- -> GenParser tok st [a]+many1Till :: Parser [tok] st a+ -> Parser [tok] st end+ -> Parser [tok] st [a] many1Till p end = do first <- p rest <- manyTill p end return (first:rest) --- | A more general form of @notFollowedBy@. This one allows any +-- | A more general form of @notFollowedBy@. This one allows any -- type of parser to be specified, and succeeds only if that parser fails. -- It does not consume any input.-notFollowedBy' :: Show b => GenParser a st b -> GenParser a st ()+notFollowedBy' :: Show b => Parser [a] st b -> Parser [a] st () notFollowedBy' p = try $ join $ do a <- try p return (unexpected (show a)) <|> return (return ()) -- (This version due to Andrew Pimlott on the Haskell mailing list.) --- | Parses one of a list of strings (tried in order). -oneOfStrings :: [String] -> GenParser Char st String-oneOfStrings listOfStrings = choice $ map (try . string) listOfStrings+oneOfStrings' :: (Char -> Char -> Bool) -> [String] -> Parser [Char] st String+oneOfStrings' _ [] = fail "no strings"+oneOfStrings' matches strs = try $ do+ c <- anyChar+ let strs' = [xs | (x:xs) <- strs, x `matches` c]+ case strs' of+ [] -> fail "not found"+ _ -> (c:) `fmap` oneOfStrings' matches strs'+ <|> if "" `elem` strs'+ then return [c]+ else fail "not found" +-- | Parses one of a list of strings. If the list contains+-- two strings one of which is a prefix of the other, the longer+-- string will be matched if possible.+oneOfStrings :: [String] -> Parser [Char] st String+oneOfStrings = oneOfStrings' (==)++-- | Parses one of a list of strings (tried in order), case insensitive.+oneOfStringsCI :: [String] -> Parser [Char] st String+oneOfStringsCI = oneOfStrings' ciMatch+ where ciMatch x y = toLower x == toLower y+ -- | Parses a space or tab.-spaceChar :: CharParser st Char+spaceChar :: Parser [Char] st Char spaceChar = satisfy $ \c -> c == ' ' || c == '\t' -- | Parses a nonspace, nonnewline character.-nonspaceChar :: CharParser st Char+nonspaceChar :: Parser [Char] st Char nonspaceChar = satisfy $ \x -> x /= '\t' && x /= '\n' && x /= ' ' && x /= '\r' -- | Skips zero or more spaces or tabs.-skipSpaces :: GenParser Char st ()+skipSpaces :: Parser [Char] st () skipSpaces = skipMany spaceChar -- | Skips zero or more spaces or tabs, then reads a newline.-blankline :: GenParser Char st Char+blankline :: Parser [Char] st Char blankline = try $ skipSpaces >> newline -- | Parses one or more blank lines and returns a string of newlines.-blanklines :: GenParser Char st [Char]+blanklines :: Parser [Char] st [Char] blanklines = many1 blankline -- | Parses material enclosed between start and end parsers.-enclosed :: GenParser Char st t -- ^ start parser- -> GenParser Char st end -- ^ end parser- -> GenParser Char st a -- ^ content parser (to be used repeatedly)- -> GenParser Char st [a]-enclosed start end parser = try $ +enclosed :: Parser [Char] st t -- ^ start parser+ -> Parser [Char] st end -- ^ end parser+ -> Parser [Char] st a -- ^ content parser (to be used repeatedly)+ -> Parser [Char] st [a]+enclosed start end parser = try $ start >> notFollowedBy space >> many1Till parser end -- | Parse string, case insensitive.-stringAnyCase :: [Char] -> CharParser st String+stringAnyCase :: [Char] -> Parser [Char] st String stringAnyCase [] = string "" stringAnyCase (x:xs) = do firstChar <- char (toUpper x) <|> char (toLower x)@@ -158,7 +271,7 @@ return (firstChar:rest) -- | Parse contents of 'str' using 'parser' and return result.-parseFromString :: GenParser tok st a -> [tok] -> GenParser tok st a+parseFromString :: Parser [tok] st a -> [tok] -> Parser [tok] st a parseFromString parser str = do oldPos <- getPosition oldInput <- getInput@@ -169,8 +282,8 @@ return result -- | Parse raw line block up to and including blank lines.-lineClump :: GenParser Char st String-lineClump = blanklines +lineClump :: Parser [Char] st String+lineClump = blanklines <|> (many1 (notFollowedBy blankline >> anyLine) >>= return . unlines) -- | Parse a string of characters between an open character@@ -178,8 +291,8 @@ -- pairs of open and close, which must be different. For example, -- @charsInBalanced '(' ')' anyChar@ will parse "(hello (there))" -- and return "hello (there)".-charsInBalanced :: Char -> Char -> GenParser Char st Char- -> GenParser Char st String+charsInBalanced :: Char -> Char -> Parser [Char] st Char+ -> Parser [Char] st String charsInBalanced open close parser = try $ do char open let isDelim c = c == open || c == close@@ -204,13 +317,13 @@ -- | Parses a roman numeral (uppercase or lowercase), returns number. romanNumeral :: Bool -- ^ Uppercase if true- -> GenParser Char st Int+ -> Parser [Char] st Int romanNumeral upperCase = do- let romanDigits = if upperCase - then uppercaseRomanDigits + let romanDigits = if upperCase+ then uppercaseRomanDigits else lowercaseRomanDigits lookAhead $ oneOf romanDigits- let [one, five, ten, fifty, hundred, fivehundred, thousand] = + let [one, five, ten, fifty, hundred, fivehundred, thousand] = map char romanDigits thousands <- many thousand >>= (return . (1000 *) . length) ninehundreds <- option 0 $ try $ hundred >> thousand >> return 900@@ -234,68 +347,90 @@ -- Parsers for email addresses and URIs -emailChar :: GenParser Char st Char-emailChar = alphaNum <|>- satisfy (\c -> c == '-' || c == '+' || c == '_' || c == '.')+-- | Parses an email address; returns original and corresponding+-- escaped mailto: URI.+emailAddress :: Parser [Char] st (String, String)+emailAddress = try $ liftA2 toResult mailbox (char '@' *> domain)+ where toResult mbox dom = let full = mbox ++ '@':dom+ in (full, escapeURI $ "mailto:" ++ full)+ mailbox = intercalate "." `fmap` (emailWord `sepby1` dot)+ domain = intercalate "." `fmap` (subdomain `sepby1` dot)+ dot = char '.'+ subdomain = many1 $ alphaNum <|> innerPunct+ innerPunct = try (satisfy (\c -> isEmailPunct c || c == '@') <*+ notFollowedBy space)+ emailWord = many1 $ satisfy isEmailChar+ isEmailChar c = isAlphaNum c || isEmailPunct c+ isEmailPunct c = c `elem` "!\"#$%&'*+-/=?^_{|}~"+ -- note: sepBy1 from parsec consumes input when sep+ -- succeeds and p fails, so we use this variant here.+ sepby1 p sep = liftA2 (:) p (many (try $ sep >> p)) -domainChar :: GenParser Char st Char-domainChar = alphaNum <|> char '-' -domain :: GenParser Char st [Char]-domain = do- first <- many1 domainChar- dom <- many1 $ try (char '.' >> many1 domainChar )- return $ intercalate "." (first:dom)+-- Schemes from http://www.iana.org/assignments/uri-schemes.html plus+-- the unofficial schemes coap, doi, javascript.+schemes :: [String]+schemes = ["coap","doi","javascript","aaa","aaas","about","acap","cap","cid",+ "crid","data","dav","dict","dns","file","ftp","geo","go","gopher",+ "h323","http","https","iax","icap","im","imap","info","ipp","iris",+ "iris.beep","iris.xpc","iris.xpcs","iris.lwz","ldap","mailto","mid",+ "msrp","msrps","mtqp","mupdate","news","nfs","ni","nih","nntp",+ "opaquelocktoken","pop","pres","rtsp","service","session","shttp","sieve",+ "sip","sips","sms","snmp","soap.beep","soap.beeps","tag","tel","telnet",+ "tftp","thismessage","tn3270","tip","tv","urn","vemmi","ws","wss","xcon",+ "xcon-userid","xmlrpc.beep","xmlrpc.beeps","xmpp","z39.50r","z39.50s",+ "adiumxtra","afp","afs","aim","apt","attachment","aw","beshare","bitcoin",+ "bolo","callto","chrome","chrome-extension","com-eventbrite-attendee",+ "content", "cvs","dlna-playsingle","dlna-playcontainer","dtn","dvb",+ "ed2k","facetime","feed","finger","fish","gg","git","gizmoproject",+ "gtalk","hcp","icon","ipn","irc","irc6","ircs","itms","jar","jms",+ "keyparc","lastfm","ldaps","magnet","maps","market","message","mms",+ "ms-help","msnim","mumble","mvn","notes","oid","palm","paparazzi",+ "platform","proxy","psyc","query","res","resource","rmi","rsync",+ "rtmp","secondlife","sftp","sgn","skype","smb","soldat","spotify",+ "ssh","steam","svn","teamspeak","things","udp","unreal","ut2004",+ "ventrilo","view-source","webcal","wtai","wyciwyg","xfire","xri",+ "ymsgr"] --- | Parses an email address; returns original and corresponding--- escaped mailto: URI.-emailAddress :: GenParser Char st (String, String)-emailAddress = try $ do- firstLetter <- alphaNum- restAddr <- many emailChar- let addr = firstLetter:restAddr- char '@'- dom <- domain- let full = addr ++ '@':dom- return (full, escapeURI $ "mailto:" ++ full)+uriScheme :: Parser [Char] st String+uriScheme = oneOfStringsCI schemes -- | Parses a URI. Returns pair of original and URI-escaped version.-uri :: GenParser Char st (String, String)+uri :: Parser [Char] st (String, String) uri = try $ do- let protocols = [ "http:", "https:", "ftp:", "file:", "mailto:",- "news:", "telnet:" ]- lookAhead $ oneOfStrings protocols- -- Scan non-ascii characters and ascii characters allowed in a URI.- -- We allow punctuation except when followed by a space, since- -- we don't want the trailing '.' in 'http://google.com.'- let innerPunct = try $ satisfy isPunctuation >>~- notFollowedBy (newline <|> spaceChar)- let uriChar = innerPunct <|>- satisfy (\c -> not (isPunctuation c) &&- (not (isAscii c) || isAllowedInURI c))- -- We want to allow+ scheme <- uriScheme+ char ':'+ -- /^[\/\w\u0080-\uffff]+|%[A-Fa-f0-9]+|&#?\w+;|(?:[,]+|[\S])[%&~\w\u0080-\uffff]/+ -- We allow punctuation except at the end, since+ -- we don't want the trailing '.' in 'http://google.com.' We want to allow -- http://en.wikipedia.org/wiki/State_of_emergency_(disambiguation) -- as a URL, while NOT picking up the closing paren in- -- (http://wikipedia.org)- -- So we include balanced parens in the URL.- let inParens = try $ do char '('- res <- many uriChar- char ')'- return $ '(' : res ++ ")"- str <- liftM concat $ many1 $ inParens <|> count 1 (innerPunct <|> uriChar)- -- now see if they amount to an absolute URI- case parseURI (escapeURI str) of- Just uri' -> if uriScheme uri' `elem` protocols- then return (str, show uri')- else fail "not a URI"- Nothing -> fail "not a URI"+ -- (http://wikipedia.org). So we include balanced parens in the URL.+ let isWordChar c = isAlphaNum c || c == '_' || c == '/' || not (isAscii c)+ let wordChar = satisfy isWordChar+ let percentEscaped = try $ char '%' >> skipMany1 (satisfy isHexDigit)+ let entity = () <$ characterReference+ let punct = skipMany1 (char ',')+ <|> () <$ (satisfy (not . isSpace))+ let uriChunk = skipMany1 wordChar+ <|> percentEscaped+ <|> entity+ <|> (try $ punct >> notFollowedBy (satisfy $ not . isWordChar))+ str <- snd `fmap` withRaw (skipMany1 ( () <$+ (enclosed (char '(') (char ')') uriChunk+ <|> enclosed (char '{') (char '}') uriChunk+ <|> enclosed (char '[') (char ']') uriChunk)+ <|> uriChunk))+ str' <- option str $ char '/' >> return (str ++ "/")+ let uri' = scheme ++ ":" ++ str'+ return (uri', escapeURI uri') -- | Applies a parser, returns tuple of its results and its horizontal -- displacement (the difference between the source column at the end -- and the source column at the beginning). Vertical displacement -- (source row) is ignored.-withHorizDisplacement :: GenParser Char st a -- ^ Parser to apply- -> GenParser Char st (a, Int) -- ^ (result, displacement)+withHorizDisplacement :: Parser [Char] st a -- ^ Parser to apply+ -> Parser [Char] st (a, Int) -- ^ (result, displacement) withHorizDisplacement parser = do pos1 <- getPosition result <- parser@@ -304,7 +439,7 @@ -- | Applies a parser and returns the raw string that was parsed, -- along with the value produced by the parser.-withRaw :: GenParser Char st a -> GenParser Char st (a, [Char])+withRaw :: Parser [Char] st a -> Parser [Char] st (a, [Char]) withRaw parser = do pos1 <- getPosition inp <- getInput@@ -314,33 +449,18 @@ let (l2,c2) = (sourceLine pos2, sourceColumn pos2) let inplines = take ((l2 - l1) + 1) $ lines inp let raw = case inplines of- [] -> error "raw: inplines is null" -- shouldn't happen+ [] -> "" [l] -> take (c2 - c1) l ls -> unlines (init ls) ++ take (c2 - 1) (last ls) return (result, raw) --- | Parses a character and returns 'Null' (so that the parser can move on--- if it gets stuck).-nullBlock :: GenParser Char st Block-nullBlock = anyChar >> return Null---- | Fail if reader is in strict markdown syntax mode.-failIfStrict :: GenParser a ParserState ()-failIfStrict = do- state <- getState- if stateStrict state then fail "strict mode" else return ()---- | Fail unless we're in literate haskell mode.-failUnlessLHS :: GenParser tok ParserState ()-failUnlessLHS = getState >>= guard . stateLiterateHaskell- -- | Parses backslash, then applies character parser.-escaped :: GenParser Char st Char -- ^ Parser for character to escape- -> GenParser Char st Char+escaped :: Parser [Char] st Char -- ^ Parser for character to escape+ -> Parser [Char] st Char escaped parser = try $ char '\\' >> parser -- | Parse character entity.-characterReference :: GenParser Char st Char+characterReference :: Parser [Char] st Char characterReference = try $ do char '&' ent <- many1Till nonspaceChar (char ';')@@ -349,19 +469,19 @@ Nothing -> fail "entity not found" -- | Parses an uppercase roman numeral and returns (UpperRoman, number).-upperRoman :: GenParser Char st (ListNumberStyle, Int)+upperRoman :: Parser [Char] st (ListNumberStyle, Int) upperRoman = do num <- romanNumeral True return (UpperRoman, num) -- | Parses a lowercase roman numeral and returns (LowerRoman, number).-lowerRoman :: GenParser Char st (ListNumberStyle, Int)+lowerRoman :: Parser [Char] st (ListNumberStyle, Int) lowerRoman = do num <- romanNumeral False return (LowerRoman, num) -- | Parses a decimal numeral and returns (Decimal, number).-decimal :: GenParser Char st (ListNumberStyle, Int)+decimal :: Parser [Char] st (ListNumberStyle, Int) decimal = do num <- many1 digit return (Decimal, read num)@@ -370,7 +490,7 @@ -- returns (DefaultStyle, [next example number]). The next -- example number is incremented in parser state, and the label -- (if present) is added to the label table.-exampleNum :: GenParser Char ParserState (ListNumberStyle, Int)+exampleNum :: Parser [Char] ParserState (ListNumberStyle, Int) exampleNum = do char '@' lab <- many (alphaNum <|> satisfy (\c -> c == '_' || c == '-'))@@ -384,38 +504,38 @@ return (Example, num) -- | Parses a '#' returns (DefaultStyle, 1).-defaultNum :: GenParser Char st (ListNumberStyle, Int)+defaultNum :: Parser [Char] st (ListNumberStyle, Int) defaultNum = do char '#' return (DefaultStyle, 1) -- | Parses a lowercase letter and returns (LowerAlpha, number).-lowerAlpha :: GenParser Char st (ListNumberStyle, Int)+lowerAlpha :: Parser [Char] st (ListNumberStyle, Int) lowerAlpha = do ch <- oneOf ['a'..'z'] return (LowerAlpha, ord ch - ord 'a' + 1) -- | Parses an uppercase letter and returns (UpperAlpha, number).-upperAlpha :: GenParser Char st (ListNumberStyle, Int)+upperAlpha :: Parser [Char] st (ListNumberStyle, Int) upperAlpha = do ch <- oneOf ['A'..'Z'] return (UpperAlpha, ord ch - ord 'A' + 1) -- | Parses a roman numeral i or I-romanOne :: GenParser Char st (ListNumberStyle, Int)+romanOne :: Parser [Char] st (ListNumberStyle, Int) romanOne = (char 'i' >> return (LowerRoman, 1)) <|> (char 'I' >> return (UpperRoman, 1)) -- | Parses an ordered list marker and returns list attributes.-anyOrderedListMarker :: GenParser Char ParserState ListAttributes -anyOrderedListMarker = choice $ +anyOrderedListMarker :: Parser [Char] ParserState ListAttributes+anyOrderedListMarker = choice $ [delimParser numParser | delimParser <- [inPeriod, inOneParen, inTwoParens], numParser <- [decimal, exampleNum, defaultNum, romanOne, lowerAlpha, lowerRoman, upperAlpha, upperRoman]] -- | Parses a list number (num) followed by a period, returns list attributes.-inPeriod :: GenParser Char st (ListNumberStyle, Int)- -> GenParser Char st ListAttributes +inPeriod :: Parser [Char] st (ListNumberStyle, Int)+ -> Parser [Char] st ListAttributes inPeriod num = try $ do (style, start) <- num char '.'@@ -423,18 +543,18 @@ then DefaultDelim else Period return (start, style, delim)- + -- | Parses a list number (num) followed by a paren, returns list attributes.-inOneParen :: GenParser Char st (ListNumberStyle, Int)- -> GenParser Char st ListAttributes +inOneParen :: Parser [Char] st (ListNumberStyle, Int)+ -> Parser [Char] st ListAttributes inOneParen num = try $ do (style, start) <- num char ')' return (start, style, OneParen) -- | Parses a list number (num) enclosed in parens, returns list attributes.-inTwoParens :: GenParser Char st (ListNumberStyle, Int)- -> GenParser Char st ListAttributes +inTwoParens :: Parser [Char] st (ListNumberStyle, Int)+ -> Parser [Char] st ListAttributes inTwoParens num = try $ do char '(' (style, start) <- num@@ -443,9 +563,9 @@ -- | Parses an ordered list marker with a given style and delimiter, -- returns number.-orderedListMarker :: ListNumberStyle - -> ListNumberDelim - -> GenParser Char ParserState Int+orderedListMarker :: ListNumberStyle+ -> ListNumberDelim+ -> Parser [Char] ParserState Int orderedListMarker style delim = do let num = defaultNum <|> -- # can continue any kind of list case style of@@ -465,38 +585,51 @@ return start -- | Parses a character reference and returns a Str element.-charRef :: GenParser Char st Inline+charRef :: Parser [Char] st Inline charRef = do c <- characterReference return $ Str [c] +lineBlockLine :: Parser [Char] st String+lineBlockLine = try $ do+ char '|'+ char ' '+ white <- many (spaceChar >> return '\160')+ notFollowedBy newline+ line <- anyLine+ continuations <- many (try $ char ' ' >> anyLine)+ return $ white ++ unwords (line : continuations)++-- | Parses an RST-style line block and returns a list of strings.+lineBlockLines :: Parser [Char] st [String]+lineBlockLines = try $ do+ lines' <- many1 lineBlockLine+ skipMany1 $ blankline <|> try (char '|' >> blankline)+ return lines'+ -- | Parse a table using 'headerParser', 'rowParser', -- 'lineParser', and 'footerParser'.-tableWith :: GenParser Char ParserState ([[Block]], [Alignment], [Int])- -> ([Int] -> GenParser Char ParserState [[Block]])- -> GenParser Char ParserState sep- -> GenParser Char ParserState end- -> GenParser Char ParserState [Inline]- -> GenParser Char ParserState Block-tableWith headerParser rowParser lineParser footerParser captionParser = try $ do- caption' <- option [] captionParser+tableWith :: Parser [Char] ParserState ([[Block]], [Alignment], [Int])+ -> ([Int] -> Parser [Char] ParserState [[Block]])+ -> Parser [Char] ParserState sep+ -> Parser [Char] ParserState end+ -> Parser [Char] ParserState Block+tableWith headerParser rowParser lineParser footerParser = try $ do (heads, aligns, indices) <- headerParser- lines' <- rowParser indices `sepEndBy` lineParser+ lines' <- rowParser indices `sepEndBy1` lineParser footerParser- caption <- if null caption'- then option [] captionParser- else return caption'- state <- getState- let numColumns = stateColumns state- let widths = widthsFromIndices numColumns indices- return $ Table caption aligns widths heads lines'+ numColumns <- getOption readerColumns+ let widths = if (indices == [])+ then replicate (length aligns) 0.0+ else widthsFromIndices numColumns indices+ return $ Table [] aligns widths heads lines' -- Calculate relative widths of table columns, based on indices widthsFromIndices :: Int -- Number of columns on terminal -> [Int] -- Indices -> [Double] -- Fractional relative sizes of columns-widthsFromIndices _ [] = [] -widthsFromIndices numColumns' indices = +widthsFromIndices _ [] = []+widthsFromIndices numColumns' indices = let numColumns = max numColumns' (if null indices then 0 else last indices) lengths' = zipWith (-) indices (0:indices) lengths = reverse $@@ -516,28 +649,30 @@ fracs = map (\l -> (fromIntegral l) / quotient) lengths in tail fracs +---+ -- Parse a grid table: starts with row of '-' on top, then header -- (which may be grid), then the rows, -- which may be grid, separated by blank lines, and -- ending with a footer (dashed line followed by blank line).-gridTableWith :: GenParser Char ParserState Block -- ^ Block parser- -> GenParser Char ParserState [Inline] -- ^ Caption parser+gridTableWith :: Parser [Char] ParserState [Block] -- ^ Block list parser -> Bool -- ^ Headerless table- -> GenParser Char ParserState Block-gridTableWith block tableCaption headless =- tableWith (gridTableHeader headless block) (gridTableRow block) (gridTableSep '-') gridTableFooter tableCaption+ -> Parser [Char] ParserState Block+gridTableWith blocks headless =+ tableWith (gridTableHeader headless blocks) (gridTableRow blocks)+ (gridTableSep '-') gridTableFooter gridTableSplitLine :: [Int] -> String -> [String] gridTableSplitLine indices line = map removeFinalBar $ tail $- splitStringByIndices (init indices) $ removeTrailingSpace line+ splitStringByIndices (init indices) $ trimr line -gridPart :: Char -> GenParser Char st (Int, Int)+gridPart :: Char -> Parser [Char] st (Int, Int) gridPart ch = do dashes <- many1 (char ch) char '+' return (length dashes, length dashes + 1) -gridDashedLines :: Char -> GenParser Char st [(Int,Int)]+gridDashedLines :: Char -> Parser [Char] st [(Int,Int)] gridDashedLines ch = try $ char '+' >> many1 (gridPart ch) >>~ blankline removeFinalBar :: String -> String@@ -545,18 +680,18 @@ reverse . dropWhile (`elem` " \t") . dropWhile (=='|') . reverse -- | Separator between rows of grid table.-gridTableSep :: Char -> GenParser Char ParserState Char+gridTableSep :: Char -> Parser [Char] ParserState Char gridTableSep ch = try $ gridDashedLines ch >> return '\n' -- | Parse header for a grid table. gridTableHeader :: Bool -- ^ Headerless table- -> GenParser Char ParserState Block- -> GenParser Char ParserState ([[Block]], [Alignment], [Int])-gridTableHeader headless block = try $ do+ -> Parser [Char] ParserState [Block]+ -> Parser [Char] ParserState ([[Block]], [Alignment], [Int])+gridTableHeader headless blocks = try $ do optional blanklines dashes <- gridDashedLines '-' rawContent <- if headless- then return $ repeat "" + then return $ repeat "" else many1 (notFollowedBy (gridTableSep '=') >> char '|' >> many1Till anyChar newline)@@ -571,25 +706,24 @@ then replicate (length dashes) "" else map (intercalate " ") $ transpose $ map (gridTableSplitLine indices) rawContent- heads <- mapM (parseFromString $ many block) $- map removeLeadingTrailingSpace rawHeads+ heads <- mapM (parseFromString blocks) $ map trim rawHeads return (heads, aligns, indices) -gridTableRawLine :: [Int] -> GenParser Char ParserState [String]+gridTableRawLine :: [Int] -> Parser [Char] ParserState [String] gridTableRawLine indices = do char '|' line <- many1Till anyChar newline return (gridTableSplitLine indices line) -- | Parse row of grid table.-gridTableRow :: GenParser Char ParserState Block+gridTableRow :: Parser [Char] ParserState [Block] -> [Int]- -> GenParser Char ParserState [[Block]]-gridTableRow block indices = do+ -> Parser [Char] ParserState [[Block]]+gridTableRow blocks indices = do colLines <- many1 (gridTableRawLine indices) let cols = map ((++ "\n") . unlines . removeOneLeadingSpace) $ transpose colLines- mapM (liftM compactifyCell . parseFromString (many block)) cols+ mapM (liftM compactifyCell . parseFromString blocks) cols removeOneLeadingSpace :: [String] -> [String] removeOneLeadingSpace xs =@@ -603,23 +737,23 @@ compactifyCell bs = head $ compactify [bs] -- | Parse footer for a grid table.-gridTableFooter :: GenParser Char ParserState [Char]+gridTableFooter :: Parser [Char] ParserState [Char] gridTableFooter = blanklines --- -- | Parse a string with a given parser and state.-readWith :: GenParser t ParserState a -- ^ parser+readWith :: Parser [t] ParserState a -- ^ parser -> ParserState -- ^ initial state -> [t] -- ^ input -> a-readWith parser state input = +readWith parser state input = case runParser parser state "source" input of Left err' -> error $ "\nError:\n" ++ show err' Right result -> result -- | Parse a string with @parser@ (for testing).-testStringWith :: (Show a) => GenParser Char ParserState a+testStringWith :: (Show a) => Parser [Char] ParserState a -> String -> IO () testStringWith parser str = UTF8.putStrLn $ show $@@ -627,72 +761,75 @@ -- | Parsing options. data ParserState = ParserState- { stateParseRaw :: Bool, -- ^ Parse raw HTML and LaTeX?+ { stateOptions :: ReaderOptions, -- ^ User options stateParserContext :: ParserContext, -- ^ Inside list? stateQuoteContext :: QuoteContext, -- ^ Inside quoted environment?+ stateAllowLinks :: Bool, -- ^ Allow parsing of links stateMaxNestingLevel :: Int, -- ^ Max # of nested Strong/Emph stateLastStrPos :: Maybe SourcePos, -- ^ Position after last str parsed- stateKeys :: KeyTable, -- ^ List of reference keys- stateCitations :: [String], -- ^ List of available citations- stateNotes :: NoteTable, -- ^ List of notes- stateTabStop :: Int, -- ^ Tab stop- stateStandalone :: Bool, -- ^ Parse bibliographic info?+ stateKeys :: KeyTable, -- ^ List of reference keys (with fallbacks)+ stateSubstitutions :: SubstTable, -- ^ List of substitution references+ stateNotes :: NoteTable, -- ^ List of notes (raw bodies)+ stateNotes' :: NoteTable', -- ^ List of notes (parsed bodies) stateTitle :: [Inline], -- ^ Title of document stateAuthors :: [[Inline]], -- ^ Authors of document stateDate :: [Inline], -- ^ Date of document- stateStrict :: Bool, -- ^ Use strict markdown syntax?- stateSmart :: Bool, -- ^ Use smart typography?- stateOldDashes :: Bool, -- ^ Use pandoc <= 1.8.2.1 behavior- -- in parsing dashes; -- is em-dash;- -- before numeral is en-dash- stateLiterateHaskell :: Bool, -- ^ Treat input as literate haskell- stateColumns :: Int, -- ^ Number of columns in terminal stateHeaderTable :: [HeaderType], -- ^ Ordered list of header types used- stateIndentedCodeClasses :: [String], -- ^ Classes to use for indented code blocks+ stateHeaders :: [[Inline]], -- ^ List of headers (used for implicit ref links)+ stateIdentifiers :: [String], -- ^ List of header identifiers used stateNextExample :: Int, -- ^ Number of next example- stateExamples :: M.Map String Int, -- ^ Map from example labels to numbers + stateExamples :: M.Map String Int, -- ^ Map from example labels to numbers stateHasChapters :: Bool, -- ^ True if \chapter encountered- stateApplyMacros :: Bool, -- ^ Apply LaTeX macros? stateMacros :: [Macro], -- ^ List of macros defined so far- stateRstDefaultRole :: String -- ^ Current rST default interpreted text role+ stateRstDefaultRole :: String, -- ^ Current rST default interpreted text role+ stateWarnings :: [String] -- ^ Warnings generated by the parser }- deriving Show +instance Default ParserState where+ def = defaultParserState+ defaultParserState :: ParserState-defaultParserState = - ParserState { stateParseRaw = False,+defaultParserState =+ ParserState { stateOptions = def, stateParserContext = NullState, stateQuoteContext = NoQuote,+ stateAllowLinks = True, stateMaxNestingLevel = 6, stateLastStrPos = Nothing, stateKeys = M.empty,- stateCitations = [],+ stateSubstitutions = M.empty, stateNotes = [],- stateTabStop = 4,- stateStandalone = False,+ stateNotes' = [], stateTitle = [], stateAuthors = [], stateDate = [],- stateStrict = False,- stateSmart = False,- stateOldDashes = False,- stateLiterateHaskell = False,- stateColumns = 80, stateHeaderTable = [],- stateIndentedCodeClasses = [],+ stateHeaders = [],+ stateIdentifiers = [], stateNextExample = 1, stateExamples = M.empty, stateHasChapters = False,- stateApplyMacros = True, stateMacros = [],- stateRstDefaultRole = "title-reference"}+ stateRstDefaultRole = "title-reference",+ stateWarnings = []} -data HeaderType +getOption :: (ReaderOptions -> a) -> Parser s ParserState a+getOption f = (f . stateOptions) `fmap` getState++-- | Succeed only if the extension is enabled.+guardEnabled :: Extension -> Parser s ParserState ()+guardEnabled ext = getOption readerExtensions >>= guard . Set.member ext++-- | Succeed only if the extension is disabled.+guardDisabled :: Extension -> Parser s ParserState ()+guardDisabled ext = getOption readerExtensions >>= guard . not . Set.member ext++data HeaderType = SingleHeader Char -- ^ Single line of characters underneath | DoubleHeader Char -- ^ Lines of characters above and below deriving (Eq, Show) -data ParserContext +data ParserContext = ListItemState -- ^ Used when running parser on list item contents | NullState -- ^ Default state deriving (Eq, Show)@@ -705,51 +842,37 @@ type NoteTable = [(String, String)] -newtype Key = Key [Inline] deriving (Show, Read, Eq, Ord)+type NoteTable' = [(String, F Blocks)] -- used in markdown reader -toKey :: [Inline] -> Key-toKey = Key . bottomUp lowercase- where lowercase :: Inline -> Inline- lowercase (Str xs) = Str (map toLower xs)- lowercase (Math t xs) = Math t (map toLower xs)- lowercase (Code attr xs) = Code attr (map toLower xs)- lowercase (RawInline f xs) = RawInline f (map toLower xs)- lowercase LineBreak = Space- lowercase x = x+newtype Key = Key String deriving (Show, Read, Eq, Ord) -fromKey :: Key -> [Inline]-fromKey (Key xs) = xs+toKey :: String -> Key+toKey = Key . map toLower . unwords . words type KeyTable = M.Map Key Target --- | Look up key in key table and return target object.-lookupKeySrc :: KeyTable -- ^ Key table- -> Key -- ^ Key- -> Maybe Target-lookupKeySrc table key = case M.lookup key table of- Nothing -> Nothing- Just src -> Just src+type SubstTable = M.Map Key Inlines -- | Fail unless we're in "smart typography" mode.-failUnlessSmart :: GenParser tok ParserState ()-failUnlessSmart = getState >>= guard . stateSmart+failUnlessSmart :: Parser [tok] ParserState ()+failUnlessSmart = getOption readerSmart >>= guard -smartPunctuation :: GenParser Char ParserState Inline- -> GenParser Char ParserState Inline+smartPunctuation :: Parser [Char] ParserState Inline+ -> Parser [Char] ParserState Inline smartPunctuation inlineParser = do failUnlessSmart choice [ quoted inlineParser, apostrophe, dash, ellipses ] -apostrophe :: GenParser Char ParserState Inline+apostrophe :: Parser [Char] ParserState Inline apostrophe = (char '\'' <|> char '\8217') >> return (Str "\x2019") -quoted :: GenParser Char ParserState Inline- -> GenParser Char ParserState Inline+quoted :: Parser [Char] ParserState Inline+ -> Parser [Char] ParserState Inline quoted inlineParser = doubleQuoted inlineParser <|> singleQuoted inlineParser withQuoteContext :: QuoteContext- -> (GenParser Char ParserState Inline)- -> GenParser Char ParserState Inline+ -> Parser [tok] ParserState a+ -> Parser [tok] ParserState a withQuoteContext context parser = do oldState <- getState let oldQuoteContext = stateQuoteContext oldState@@ -759,128 +882,137 @@ setState newState { stateQuoteContext = oldQuoteContext } return result -singleQuoted :: GenParser Char ParserState Inline- -> GenParser Char ParserState Inline+singleQuoted :: Parser [Char] ParserState Inline+ -> Parser [Char] ParserState Inline singleQuoted inlineParser = try $ do singleQuoteStart withQuoteContext InSingleQuote $ many1Till inlineParser singleQuoteEnd >>= return . Quoted SingleQuote . normalizeSpaces -doubleQuoted :: GenParser Char ParserState Inline- -> GenParser Char ParserState Inline+doubleQuoted :: Parser [Char] ParserState Inline+ -> Parser [Char] ParserState Inline doubleQuoted inlineParser = try $ do doubleQuoteStart withQuoteContext InDoubleQuote $ do contents <- manyTill inlineParser doubleQuoteEnd return . Quoted DoubleQuote . normalizeSpaces $ contents -failIfInQuoteContext :: QuoteContext -> GenParser tok ParserState ()+failIfInQuoteContext :: QuoteContext -> Parser [tok] ParserState () failIfInQuoteContext context = do st <- getState if stateQuoteContext st == context then fail "already inside quotes" else return () -charOrRef :: [Char] -> GenParser Char st Char+charOrRef :: [Char] -> Parser [Char] st Char charOrRef cs = oneOf cs <|> try (do c <- characterReference guard (c `elem` cs) return c) -updateLastStrPos :: GenParser Char ParserState ()-updateLastStrPos = getPosition >>= \p -> +updateLastStrPos :: Parser [Char] ParserState ()+updateLastStrPos = getPosition >>= \p -> updateState $ \s -> s{ stateLastStrPos = Just p } -singleQuoteStart :: GenParser Char ParserState ()+singleQuoteStart :: Parser [Char] ParserState () singleQuoteStart = do failIfInQuoteContext InSingleQuote pos <- getPosition st <- getState -- single quote start can't be right after str guard $ stateLastStrPos st /= Just pos- try $ do charOrRef "'\8216\145"- notFollowedBy (oneOf ")!],;:-? \t\n")- notFollowedBy (char '.') <|> lookAhead (string "..." >> return ())- notFollowedBy (try (oneOfStrings ["s","t","m","ve","ll","re"] >>- satisfy (not . isAlphaNum))) - -- possess/contraction- return ()+ () <$ charOrRef "'\8216\145" -singleQuoteEnd :: GenParser Char st ()+singleQuoteEnd :: Parser [Char] st () singleQuoteEnd = try $ do charOrRef "'\8217\146" notFollowedBy alphaNum -doubleQuoteStart :: GenParser Char ParserState ()+doubleQuoteStart :: Parser [Char] ParserState () doubleQuoteStart = do failIfInQuoteContext InDoubleQuote try $ do charOrRef "\"\8220\147" notFollowedBy (satisfy (\c -> c == ' ' || c == '\t' || c == '\n')) -doubleQuoteEnd :: GenParser Char st ()+doubleQuoteEnd :: Parser [Char] st () doubleQuoteEnd = do charOrRef "\"\8221\148" return () -ellipses :: GenParser Char st Inline+ellipses :: Parser [Char] st Inline ellipses = do try (charOrRef "\8230\133") <|> try (string "..." >> return '…') return (Str "\8230") -dash :: GenParser Char ParserState Inline+dash :: Parser [Char] ParserState Inline dash = do- oldDashes <- stateOldDashes `fmap` getState+ oldDashes <- getOption readerOldDashes if oldDashes then emDashOld <|> enDashOld else Str `fmap` (hyphenDash <|> emDash <|> enDash) -- Two hyphens = en-dash, three = em-dash-hyphenDash :: GenParser Char st String+hyphenDash :: Parser [Char] st String hyphenDash = do try $ string "--" option "\8211" (char '-' >> return "\8212") -emDash :: GenParser Char st String+emDash :: Parser [Char] st String emDash = do try (charOrRef "\8212\151") return "\8212" -enDash :: GenParser Char st String+enDash :: Parser [Char] st String enDash = do try (charOrRef "\8212\151") return "\8211" -enDashOld :: GenParser Char st Inline+enDashOld :: Parser [Char] st Inline enDashOld = do try (charOrRef "\8211\150") <|> try (char '-' >> lookAhead (satisfy isDigit) >> return '–') return (Str "\8211") -emDashOld :: GenParser Char st Inline+emDashOld :: Parser [Char] st Inline emDashOld = do try (charOrRef "\8212\151") <|> (try $ string "--" >> optional (char '-') >> return '-') return (Str "\8212") +-- This is used to prevent exponential blowups for things like:+-- a**a*a**a*a**a*a**a*a**a*a**a*a**+nested :: Parser s ParserState a+ -> Parser s ParserState a+nested p = do+ nestlevel <- stateMaxNestingLevel `fmap` getState+ guard $ nestlevel > 0+ updateState $ \st -> st{ stateMaxNestingLevel = stateMaxNestingLevel st - 1 }+ res <- p+ updateState $ \st -> st{ stateMaxNestingLevel = nestlevel }+ return res+ -- -- Macros -- -- | Parse a \newcommand or \renewcommand macro definition.-macro :: GenParser Char ParserState Block+macro :: Parser [Char] ParserState Block macro = do- getState >>= guard . stateApplyMacros+ apply <- getOption readerApplyMacros inp <- getInput case parseMacroDefinitions inp of- ([], _) -> pzero- (ms, rest) -> do count (length inp - length rest) anyChar- updateState $ \st ->- st { stateMacros = ms ++ stateMacros st }- return Null+ ([], _) -> mzero+ (ms, rest) -> do def' <- count (length inp - length rest) anyChar+ if apply+ then do+ updateState $ \st ->+ st { stateMacros = ms ++ stateMacros st }+ return Null+ else return $ RawBlock "latex" def' -- | Apply current macros to string.-applyMacros' :: String -> GenParser Char ParserState String+applyMacros' :: String -> Parser [Char] ParserState String applyMacros' target = do- apply <- liftM stateApplyMacros getState+ apply <- getOption readerApplyMacros if apply then do macros <- liftM stateMacros getState return $ applyMacros macros target
@@ -20,7 +20,7 @@ {- | Module : Text.Pandoc.Pretty Copyright : Copyright (C) 2010 John MacFarlane- License : GNU GPL, version 2 or above + License : GNU GPL, version 2 or above Maintainer : John MacFarlane <jgm@berkeley.edu> Stability : alpha@@ -202,18 +202,17 @@ outp :: (IsString a, Monoid a) => Int -> String -> DocState a-outp off s | off <= 0 = do+outp off s | off < 0 = do -- offset < 0 means newline characters st' <- get let rawpref = prefix st' when (column st' == 0 && usePrefix st' && not (null rawpref)) $ do let pref = reverse $ dropWhile isSpace $ reverse rawpref modify $ \st -> st{ output = fromString pref : output st , column = column st + realLength pref }- when (off < 0) $ do- modify $ \st -> st { output = fromString s : output st- , column = 0- , newlines = newlines st + 1 }-outp off s = do+ modify $ \st -> st { output = fromString s : output st+ , column = 0+ , newlines = newlines st + 1 }+outp off s = do -- offset >= 0 (0 might be combining char) st' <- get let pref = prefix st' when (column st' == 0 && usePrefix st' && not (null pref)) $ do@@ -510,7 +509,9 @@ | c >= '\xFE10' && c <= '\xFE19' -> 2 | c >= '\xFE20' && c <= '\xFE26' -> 1 | c >= '\xFE30' && c <= '\xFE6B' -> 2- | c >= '\xFE70' && c <= '\x16A38' -> 1+ | c >= '\xFE70' && c <= '\xFEFF' -> 1+ | c >= '\xFF01' && c <= '\xFF60' -> 2+ | c >= '\xFF61' && c <= '\x16A38' -> 1 | c >= '\x1B000' && c <= '\x1B001' -> 2 | c >= '\x1D000' && c <= '\x1F1FF' -> 1 | c >= '\x1F200' && c <= '\x1F251' -> 2
@@ -1,6 +1,6 @@ module Text.Pandoc.Readers.DocBook ( readDocBook ) where import Data.Char (toUpper, isDigit)-import Text.Pandoc.Parsing (ParserState(..))+import Text.Pandoc.Options import Text.Pandoc.Definition import Text.Pandoc.Builder import Text.XML.Light@@ -133,7 +133,7 @@ [ ] exceptionname - The name of an exception [ ] fax - A fax number [ ] fieldsynopsis - The name of a field in a class definition-[ ] figure - A formal figure, generally an illustration, with a title+[x] figure - A formal figure, generally an illustration, with a title [x] filename - The name of a file [ ] firstname - The first name of a person [ ] firstterm - The first occurrence of a term@@ -455,13 +455,13 @@ [x] tocfront - An entry in a table of contents for a front matter component [x] toclevel1 - A top-level entry within a table of contents entry for a chapter-like component-[x] toclevel2 - A second-level entry within a table of contents entry for a +[x] toclevel2 - A second-level entry within a table of contents entry for a chapter-like component-[x] toclevel3 - A third-level entry within a table of contents entry for a +[x] toclevel3 - A third-level entry within a table of contents entry for a chapter-like component-[x] toclevel4 - A fourth-level entry within a table of contents entry for a +[x] toclevel4 - A fourth-level entry within a table of contents entry for a chapter-like component-[x] toclevel5 - A fifth-level entry within a table of contents entry for a +[x] toclevel5 - A fifth-level entry within a table of contents entry for a chapter-like component [x] tocpart - An entry in a table of contents for a part of a book [ ] token - A unit of information@@ -501,9 +501,10 @@ , dbDocAuthors :: [Inlines] , dbDocDate :: Inlines , dbBook :: Bool+ , dbFigureTitle :: Inlines } deriving Show -readDocBook :: ParserState -> String -> Pandoc+readDocBook :: ReaderOptions -> String -> Pandoc readDocBook _ inp = setTitle (dbDocTitle st') $ setAuthors (dbDocAuthors st') $ setDate (dbDocDate st')@@ -515,8 +516,19 @@ , dbDocAuthors = [] , dbDocDate = mempty , dbBook = False+ , dbFigureTitle = mempty } +getFigure :: Element -> DB Blocks+getFigure e = do+ tit <- case filterChild (named "title") e of+ Just t -> getInlines t+ Nothing -> return mempty+ modify $ \st -> st{ dbFigureTitle = tit }+ res <- getBlocks e+ modify $ \st -> st{ dbFigureTitle = mempty }+ return res+ -- normalize input, consolidating adjacent Text and CRef elements normalizeTree :: [Content] -> [Content] normalizeTree = everywhere (mkT go)@@ -574,7 +586,7 @@ (Para xs : rest) -> para (toadd <> fromList xs) <> fromList rest _ -> bs --- function that is used by both mediaobject (in parseBlock) +-- function that is used by both mediaobject (in parseBlock) -- and inlinemediaobject (in parseInline) getImage :: Element -> DB Inlines getImage e = do@@ -585,10 +597,13 @@ Just i -> return $ attrValue "fileref" i caption <- case filterChild (\x -> named "caption" x || named "textobject" x) e of- Nothing -> return mempty+ Nothing -> gets dbFigureTitle Just z -> mconcat <$> (mapM parseInline $ elContent z) return $ image imageUrl "" caption +getBlocks :: Element -> DB Blocks+getBlocks e = mconcat <$> (mapM parseBlock $ elContent e)+ parseBlock :: Content -> DB Blocks parseBlock (Text (CData CDataRaw _ _)) = return mempty -- DOCTYPE parseBlock (Text (CData _ s _)) = if all isSpace s@@ -613,7 +628,7 @@ "attribution" -> return mempty "titleabbrev" -> return mempty "authorinitials" -> return mempty- "title" -> return mempty -- handled by getTitle or sect+ "title" -> return mempty -- handled by getTitle or sect or figure "bibliography" -> sect 0 "bibliodiv" -> sect 1 "biblioentry" -> parseMixed para (elContent e)@@ -674,7 +689,8 @@ orderedListWith (start,listStyle,DefaultDelim) <$> listitems "variablelist" -> definitionList <$> deflistitems- "mediaobject" -> para <$> (getImage e)+ "figure" -> getFigure e+ "mediaobject" -> para <$> getImage e "caption" -> return mempty "info" -> getTitle >> getAuthors >> getDate >> return mempty "articleinfo" -> getTitle >> getAuthors >> getDate >> return mempty@@ -702,8 +718,7 @@ "programlisting" -> codeBlockWithLang "?xml" -> return mempty _ -> getBlocks e- where getBlocks e' = mconcat <$> (mapM parseBlock $ elContent e')- parseMixed container conts = do+ where parseMixed container conts = do let (ils,rest) = break isBlockElement conts ils' <- (trimInlines . mconcat) <$> mapM parseInline ils let p = if ils' == mempty then mempty else container ils'@@ -862,15 +877,15 @@ "varargs" -> return $ code "(...)" "xref" -> return $ str "?" -- so at least you know something is there "email" -> return $ link ("mailto:" ++ strContent e) ""- $ code $ strContent e- "uri" -> return $ link (strContent e) "" $ code $ strContent e+ $ str $ strContent e+ "uri" -> return $ link (strContent e) "" $ str $ strContent e "ulink" -> link (attrValue "url" e) "" <$> innerInlines "link" -> do ils <- innerInlines let href = case findAttr (QName "href" (Just "http://www.w3.org/1999/xlink") Nothing) e of Just h -> h _ -> ('#' : attrValue "linkend" e)- let ils' = if ils == mempty then code href else ils+ let ils' = if ils == mempty then str href else ils return $ link href "" ils' "foreignphrase" -> emph <$> innerInlines "emphasis" -> case attrValue "role" e of
@@ -19,10 +19,10 @@ {- | Module : Text.Pandoc.Readers.HTML Copyright : Copyright (C) 2006-2010 John MacFarlane- License : GNU GPL, version 2 or above + License : GNU GPL, version 2 or above Maintainer : John MacFarlane <jgm@berkeley.edu>- Stability : alpha + Stability : alpha Portability : portable Conversion of HTML to 'Pandoc' document.@@ -36,18 +36,17 @@ , isCommentTag ) where -import Text.ParserCombinators.Parsec-import Text.ParserCombinators.Parsec.Pos import Text.HTML.TagSoup import Text.HTML.TagSoup.Match import Text.Pandoc.Definition import Text.Pandoc.Builder (text, toList) import Text.Pandoc.Shared+import Text.Pandoc.Options import Text.Pandoc.Parsing import Data.Maybe ( fromMaybe, isJust ) import Data.List ( intercalate )-import Data.Char ( isDigit, toLower )-import Control.Monad ( liftM, guard, when )+import Data.Char ( isDigit )+import Control.Monad ( liftM, guard, when, mzero ) isSpace :: Char -> Bool isSpace ' ' = True@@ -56,11 +55,11 @@ isSpace _ = False -- | Convert HTML-formatted string to 'Pandoc' document.-readHtml :: ParserState -- ^ Parser state+readHtml :: ReaderOptions -- ^ Reader options -> String -- ^ String to parse (assumes @'\n'@ line endings) -> Pandoc-readHtml st inp = Pandoc meta blocks- where blocks = readWith parseBody st rest+readHtml opts inp = Pandoc meta blocks+ where blocks = readWith parseBody def{ stateOptions = opts } rest tags = canonicalizeTags $ parseTagsOptions parseOptions{ optTagPosition = True } inp hasHeader = any (~== TagOpen "head" []) tags@@ -68,7 +67,7 @@ then parseHeader tags else (Meta [] [] [], tags) -type TagParser = GenParser (Tag String) ParserState+type TagParser = Parser [Tag String] ParserState -- TODO - fix this - not every header has a title tag parseHeader :: [Tag String] -> (Meta, [Tag String])@@ -96,18 +95,6 @@ , pRawHtmlBlock ] --- repeated in SelfContained -- consolidate eventually-renderTags' :: [Tag String] -> String-renderTags' = renderTagsOptions- renderOptions{ optMinimize = \x ->- let y = map toLower x- in y == "hr" || y == "br" ||- y == "img" || y == "meta" ||- y == "link"- , optRawTag = \x ->- let y = map toLower x- in y == "script" || y == "style" }- pList :: TagParser [Block] pList = pBulletList <|> pOrderedList <|> pDefinitionList @@ -126,25 +113,22 @@ pOrderedList :: TagParser [Block] pOrderedList = try $ do TagOpen _ attribs <- pSatisfy (~== TagOpen "ol" [])- st <- getState- let (start, style) = if stateStrict st- then (1, DefaultStyle) - else (sta', sty')- where sta = fromMaybe "1" $- lookup "start" attribs- sta' = if all isDigit sta- then read sta- else 1- sty = fromMaybe (fromMaybe "" $- lookup "style" attribs) $- lookup "class" attribs- sty' = case sty of- "lower-roman" -> LowerRoman- "upper-roman" -> UpperRoman- "lower-alpha" -> LowerAlpha- "upper-alpha" -> UpperAlpha- "decimal" -> Decimal- _ -> DefaultStyle+ let (start, style) = (sta', sty')+ where sta = fromMaybe "1" $+ lookup "start" attribs+ sta' = if all isDigit sta+ then read sta+ else 1+ sty = fromMaybe (fromMaybe "" $+ lookup "style" attribs) $+ lookup "class" attribs+ sty' = case sty of+ "lower-roman" -> LowerRoman+ "upper-roman" -> UpperRoman+ "lower-alpha" -> LowerAlpha+ "upper-alpha" -> UpperAlpha+ "decimal" -> Decimal+ _ -> DefaultStyle let nonItem = pSatisfy (\t -> not (tagOpen (`elem` ["li","ol","ul","dl"]) (const True) t) && not (t ~== TagClose "ol"))@@ -176,7 +160,7 @@ else bs where isParaish (Para _) = True isParaish (CodeBlock _ _) = True- isParaish (Header _ _) = True+ isParaish (Header _ _ _) = True isParaish (BlockQuote _) = True isParaish (BulletList _) = not inList isParaish (OrderedList _ _) = not inList@@ -196,8 +180,8 @@ pRawHtmlBlock :: TagParser [Block] pRawHtmlBlock = do raw <- pHtmlBlock "script" <|> pHtmlBlock "style" <|> pRawTag- state <- getState- if stateParseRaw state && not (null raw)+ parseRaw <- getOption readerParseRaw+ if parseRaw && not (null raw) then return [RawBlock "html" raw] else return [] @@ -217,7 +201,9 @@ contents <- liftM concat $ manyTill inline (pCloses tagtype <|> eof) return $ if bodyTitle then [] -- skip a representation of the title in the body- else [Header level $ normalizeSpaces contents]+ else [Header level (fromAttrib "id" $+ TagOpen tagtype attr, [], []) $+ normalizeSpaces contents] pHrule :: TagParser [Block] pHrule = do@@ -235,7 +221,7 @@ rows <- pOptInTag "tbody" $ many1 $ try $ skipMany pBlank >> pInTags "tr" (pCell "td") skipMany pBlank- TagClose _ <- pSatisfy (~== TagClose "table") + TagClose _ <- pSatisfy (~== TagClose "table") let cols = maximum $ map length rows let aligns = replicate cols AlignLeft let widths = replicate cols 0@@ -281,15 +267,13 @@ let attribsId = fromMaybe "" $ lookup "id" attr let attribsClasses = words $ fromMaybe "" $ lookup "class" attr let attribsKV = filter (\(k,_) -> k /= "class" && k /= "id") attr- st <- getState- let attribs = if stateStrict st- then ("",[],[])- else (attribsId, attribsClasses, attribsKV)+ let attribs = (attribsId, attribsClasses, attribsKV) return [CodeBlock attribs result] inline :: TagParser [Inline] inline = choice [ pTagText+ , pQ , pEmph , pStrong , pSuperscript@@ -310,7 +294,7 @@ pSat :: (Tag String -> Bool) -> TagParser (Tag String) pSat f = do pos <- getPosition- token show (const pos) (\x -> if f x then Just x else Nothing) + token show (const pos) (\x -> if f x then Just x else Nothing) pSatisfy :: (Tag String -> Bool) -> TagParser (Tag String) pSatisfy f = try $ optional pLocation >> pSat f@@ -325,6 +309,17 @@ optional $ pSatisfy (tagClose f) return open +pQ :: TagParser [Inline]+pQ = do+ quoteContext <- stateQuoteContext `fmap` getState+ let quoteType = case quoteContext of+ InDoubleQuote -> SingleQuote+ _ -> DoubleQuote+ let innerQuoteContext = if quoteType == SingleQuote+ then InSingleQuote+ else InDoubleQuote+ withQuoteContext innerQuoteContext $ pInlinesInTags "q" (Quoted quoteType)+ pEmph :: TagParser [Inline] pEmph = pInlinesInTags "em" Emph <|> pInlinesInTags "i" Emph @@ -332,14 +327,13 @@ pStrong = pInlinesInTags "strong" Strong <|> pInlinesInTags "b" Strong pSuperscript :: TagParser [Inline]-pSuperscript = failIfStrict >> pInlinesInTags "sup" Superscript+pSuperscript = pInlinesInTags "sup" Superscript pSubscript :: TagParser [Inline]-pSubscript = failIfStrict >> pInlinesInTags "sub" Subscript+pSubscript = pInlinesInTags "sub" Subscript pStrikeout :: TagParser [Inline] pStrikeout = do- failIfStrict pInlinesInTags "s" Strikeout <|> pInlinesInTags "strike" Strikeout <|> pInlinesInTags "del" Strikeout <|>@@ -381,8 +375,8 @@ pRawHtmlInline :: TagParser [Inline] pRawHtmlInline = do result <- pSatisfy (tagComment (const True)) <|> pSatisfy isInlineTag- state <- getState- if stateParseRaw state+ parseRaw <- getOption readerParseRaw+ if parseRaw then return [RawInline "html" $ renderTags' [result]] else return [] @@ -417,7 +411,7 @@ (TagClose "ul") | tagtype == "li" -> return () (TagClose "ol") | tagtype == "li" -> return () (TagClose "dl") | tagtype == "li" -> return ()- _ -> pzero+ _ -> mzero pTagText :: TagParser [Inline] pTagText = try $ do@@ -432,11 +426,11 @@ (TagText str) <- pSatisfy isTagText guard $ all isSpace str -pTagContents :: GenParser Char ParserState Inline+pTagContents :: Parser [Char] ParserState Inline pTagContents = pStr <|> pSpace <|> smartPunctuation pTagContents <|> pSymbol <|> pBad -pStr :: GenParser Char ParserState Inline+pStr :: Parser [Char] ParserState Inline pStr = do result <- many1 $ satisfy $ \c -> not (isSpace c) && not (isSpecial c) && not (isBad c)@@ -455,13 +449,13 @@ isSpecial '\8221' = True isSpecial _ = False -pSymbol :: GenParser Char ParserState Inline+pSymbol :: Parser [Char] ParserState Inline pSymbol = satisfy isSpecial >>= return . Str . (:[]) isBad :: Char -> Bool isBad c = c >= '\128' && c <= '\159' -- not allowed in HTML -pBad :: GenParser Char ParserState Inline+pBad :: Parser [Char] ParserState Inline pBad = do c <- satisfy isBad let c' = case c of@@ -495,7 +489,7 @@ _ -> '?' return $ Str [c'] -pSpace :: GenParser Char ParserState Inline+pSpace :: Parser [Char] ParserState Inline pSpace = many1 (satisfy isSpace) >> return Space --@@ -516,12 +510,15 @@ -} blockHtmlTags :: [String]-blockHtmlTags = ["address", "blockquote", "body", "center", "dir", "div",- "dl", "fieldset", "form", "h1", "h2", "h3", "h4",- "h5", "h6", "head", "hr", "html", "isindex", "menu",- "noframes", "noscript", "ol", "p", "pre", "table", "ul", "dd",+blockHtmlTags = ["address", "article", "aside", "blockquote", "body", "button", "canvas",+ "caption", "center", "col", "colgroup", "dd", "dir", "div",+ "dl", "dt", "embed", "fieldset", "figcaption", "figure", "footer",+ "form", "h1", "h2", "h3", "h4",+ "h5", "h6", "head", "header", "hgroup", "hr", "html", "isindex", "map", "menu",+ "noframes", "noscript", "object", "ol", "output", "p", "pre", "progress",+ "section", "table", "tbody", "textarea", "thead", "tfoot", "ul", "dd", "dt", "frameset", "li", "tbody", "td", "tfoot",- "th", "thead", "tr", "script", "style"]+ "th", "thead", "tr", "script", "style", "video"] -- We want to allow raw docbook in markdown documents, so we -- include docbook block tags here too.@@ -593,22 +590,21 @@ --- parsers for use in markdown, textile readers -- | Matches a stretch of HTML in balanced tags.-htmlInBalanced :: (Tag String -> Bool) -> GenParser Char ParserState String+htmlInBalanced :: (Tag String -> Bool) -> Parser [Char] ParserState String htmlInBalanced f = try $ do (TagOpen t _, tag) <- htmlTag f guard $ '/' `notElem` tag -- not a self-closing tag- let nonTagChunk = many1 $ satisfy (/= '<') let stopper = htmlTag (~== TagClose t) let anytag = liftM snd $ htmlTag (const True) contents <- many $ notFollowedBy' stopper >>- (nonTagChunk <|> htmlInBalanced (const True) <|> anytag)+ (htmlInBalanced f <|> anytag <|> count 1 anyChar) endtag <- liftM snd stopper return $ tag ++ concat contents ++ endtag -- | Matches a tag meeting a certain condition.-htmlTag :: (Tag String -> Bool) -> GenParser Char ParserState (Tag String, String)+htmlTag :: (Tag String -> Bool) -> Parser [Char] st (Tag String, String) htmlTag f = try $ do- lookAhead (char '<')+ lookAhead $ char '<' >> (oneOf "/!?" <|> letter) (next : _) <- getInput >>= return . canonicalizeTags . parseTags guard $ f next -- advance the parser@@ -617,7 +613,7 @@ count (length s + 4) anyChar skipMany (satisfy (/='>')) char '>'- return (next, "<!--" ++ s ++ "-->") + return (next, "<!--" ++ s ++ "-->") _ -> do rendered <- manyTill anyChar (char '>') return (next, rendered ++ ">")
@@ -1,3 +1,4 @@+{-# LANGUAGE ScopedTypeVariables #-} {- Copyright (C) 2006-2012 John MacFarlane <jgm@berkeley.edu> @@ -27,17 +28,17 @@ Conversion of LaTeX to 'Pandoc' document. -}-{-# LANGUAGE ScopedTypeVariables #-} module Text.Pandoc.Readers.LaTeX ( readLaTeX, rawLaTeXInline, rawLaTeXBlock, handleIncludes ) where -import Text.ParserCombinators.Parsec hiding ((<|>), space, many, optional) import Text.Pandoc.Definition import Text.Pandoc.Shared-import Text.Pandoc.Parsing+import Text.Pandoc.Options+import Text.Pandoc.Biblio (processBiblio)+import Text.Pandoc.Parsing hiding ((<|>), many, optional, space) import qualified Text.Pandoc.UTF8 as UTF8 import Data.Char ( chr, ord ) import Control.Monad@@ -45,16 +46,17 @@ import Data.Char (isLetter, isPunctuation, isSpace) import Control.Applicative import Data.Monoid-import System.FilePath (replaceExtension)+import System.Environment (getEnv)+import System.FilePath (replaceExtension, (</>)) import Data.List (intercalate) import qualified Data.Map as M-import qualified Control.Exception as E (catch, IOException)+import qualified Control.Exception as E -- | Parse LaTeX from string and return 'Pandoc' document.-readLaTeX :: ParserState -- ^ Parser state, including options for parser+readLaTeX :: ReaderOptions -- ^ Reader options -> String -- ^ String to parse (assumes @'\n'@ line endings) -> Pandoc-readLaTeX = readWith parseLaTeX+readLaTeX opts = readWith parseLaTeX def{ stateOptions = opts } parseLaTeX :: LP Pandoc parseLaTeX = do@@ -64,9 +66,12 @@ let title' = stateTitle st let authors' = stateAuthors st let date' = stateDate st- return $ Pandoc (Meta title' authors' date') $ toList bs+ refs <- getOption readerReferences+ mbsty <- getOption readerCitationStyle+ return $ processBiblio mbsty refs+ $ Pandoc (Meta title' authors' date') $ toList bs -type LP = GenParser Char ParserState+type LP = Parser [Char] ParserState anyControlSeq :: LP String anyControlSeq = do@@ -147,9 +152,6 @@ bracketed :: Monoid a => LP a -> LP a bracketed parser = try $ char '[' *> (mconcat <$> manyTill parser (char ']')) -trim :: String -> String-trim = removeLeadingTrailingSpace- mathDisplay :: LP String -> LP Inlines mathDisplay p = displayMath <$> (try p >>= applyMacros' . trim) @@ -167,10 +169,8 @@ (try $ string "``" *> manyTill inline (try $ string "''")) single_quote :: LP Inlines-single_quote = char '`' *>- ( try ((singleQuoted . mconcat) <$>- manyTill inline (try $ char '\'' >> notFollowedBy letter))- <|> lit "`")+single_quote = (singleQuoted . mconcat) <$>+ (try $ char '`' *> manyTill inline (try $ char '\'' >> notFollowedBy letter)) inline :: LP Inlines inline = (mempty <$ comment)@@ -182,17 +182,19 @@ ((char '-') *> option (str "–") (str "—" <$ char '-'))) <|> double_quote <|> single_quote+ <|> (str "“" <$ try (string "``")) -- nb. {``} won't be caught by double_quote+ <|> (str "”" <$ try (string "''"))+ <|> (str "‘" <$ char '`') -- nb. {`} won't be caught by single_quote <|> (str "’" <$ char '\'') <|> (str "\160" <$ char '~') <|> (mathDisplay $ string "$$" *> mathChars <* string "$$") <|> (mathInline $ char '$' *> mathChars <* char '$') <|> (superscript <$> (char '^' *> tok)) <|> (subscript <$> (char '_' *> tok))- <|> (failUnlessLHS *> char '|' *> doLHSverb)- <|> (str <$> count 1 tildeEscape)- <|> (str <$> string "]")- <|> (str <$> string "#") -- TODO print warning?- <|> (str <$> string "&") -- TODO print warning?+ <|> (guardEnabled Ext_literate_haskell *> char '|' *> doLHSverb)+ <|> (str . (:[]) <$> tildeEscape)+ <|> (str . (:[]) <$> oneOf "[]")+ <|> (str . (:[]) <$> oneOf "#&") -- TODO print warning? -- <|> (str <$> count 1 (satisfy (\c -> c /= '\\' && c /='\n' && c /='}' && c /='{'))) -- eat random leftover characters inlines :: LP Inlines@@ -202,10 +204,10 @@ block = (mempty <$ comment) <|> (mempty <$ ((spaceChar <|> newline) *> spaces)) <|> environment- <|> mempty <$ macro -- TODO improve macros, make them work everywhere+ <|> mempty <$ macro <|> blockCommand- <|> grouped block <|> paragraph+ <|> grouped block <|> (mempty <$ char '&') -- loose & in table environment @@ -215,6 +217,7 @@ blockCommand :: LP Blocks blockCommand = try $ do name <- anyControlSeq+ guard $ name /= "begin" && name /= "end" star <- option "" (string "*" <* optional sp) let name' = name ++ star case M.lookup name' blockCommands of@@ -232,14 +235,14 @@ where optargs = skipopts *> skipMany (try $ optional sp *> braced) contseq = '\\':name doraw = (rawInline "latex" . (contseq ++) . snd) <$>- (getState >>= guard . stateParseRaw >> (withRaw optargs))+ (getOption readerParseRaw >>= guard >> (withRaw optargs)) ignoreBlocks :: String -> (String, LP Blocks) ignoreBlocks name = (name, doraw <|> (mempty <$ optargs)) where optargs = skipopts *> skipMany (try $ optional sp *> braced) contseq = '\\':name doraw = (rawBlock "latex" . (contseq ++) . snd) <$>- (getState >>= guard . stateParseRaw >> (withRaw optargs))+ (getOption readerParseRaw >>= guard >> (withRaw optargs)) blockCommands :: M.Map String (LP Blocks) blockCommands = M.fromList $@@ -266,8 +269,6 @@ , ("closing", skipopts *> closing) -- , ("rule", skipopts *> tok *> tok *> pure horizontalRule)- , ("begin", mzero) -- these are here so they won't be interpreted as inline- , ("end", mzero) , ("item", skipopts *> loose_item) , ("documentclass", skipopts *> braced *> preamble) , ("centerline", (para . trimInlines) <$> (skipopts *> tok))@@ -285,7 +286,6 @@ -- that are to be processed by the compiler but not printed. , "ignore" , "hyperdef"- , "noindent" , "markboth", "markright", "markleft" , "hspace", "vspace" ]@@ -322,15 +322,20 @@ inlineCommand :: LP Inlines inlineCommand = try $ do name <- anyControlSeq+ guard $ name /= "begin" && name /= "end" guard $ not $ isBlockCommand name- parseRaw <- stateParseRaw `fmap` getState+ parseRaw <- getOption readerParseRaw star <- option "" (string "*") let name' = name ++ star- let rawargs = withRaw (skipopts *> option "" dimenarg- *> many braced) >>= applyMacros' . snd- let raw = if parseRaw- then (rawInline "latex" . (('\\':name') ++)) <$> rawargs- else mempty <$> rawargs+ let raw = do+ rawargs <- withRaw (skipopts *> option "" dimenarg *> many braced)+ let rawcommand = '\\' : name ++ star ++ snd rawargs+ transformed <- applyMacros' rawcommand+ if transformed /= rawcommand+ then parseFromString inlines transformed+ else if parseRaw+ then return $ rawInline "latex" rawcommand+ else return mempty case M.lookup name' inlineCommands of Just p -> p <|> raw Nothing -> case M.lookup name inlineCommands of@@ -338,7 +343,7 @@ Nothing -> raw unlessParseRaw :: LP ()-unlessParseRaw = getState >>= guard . not . stateParseRaw+unlessParseRaw = getOption readerParseRaw >>= guard . not isBlockCommand :: String -> Bool isBlockCommand s = maybe False (const True) $ M.lookup s blockCommands@@ -353,6 +358,7 @@ , ("textsubscript", subscript <$> tok) , ("textbackslash", lit "\\") , ("backslash", lit "\\")+ , ("slash", lit "/") , ("textbf", strong <$> tok) , ("ldots", lit "…") , ("dots", lit "…")@@ -420,23 +426,24 @@ , ("lstinline", doverb) , ("texttt", (code . stringify . toList) <$> tok) , ("url", (unescapeURL <$> braced) >>= \url ->- pure (link url "" (codeWith ("",["url"],[]) url)))+ pure (link url "" (str url))) , ("href", (unescapeURL <$> braced <* optional sp) >>= \url -> tok >>= \lab -> pure (link url "" lab)) , ("includegraphics", skipopts *> (unescapeURL <$> braced) >>= (\src -> pure (image src "" (str "image"))))- , ("cite", citation "cite" NormalCitation False)+ , ("enquote", enquote)+ , ("cite", citation "cite" AuthorInText False) , ("citep", citation "citep" NormalCitation False) , ("citep*", citation "citep*" NormalCitation False) , ("citeal", citation "citeal" NormalCitation False) , ("citealp", citation "citealp" NormalCitation False) , ("citealp*", citation "citealp*" NormalCitation False) , ("autocite", citation "autocite" NormalCitation False)- , ("footcite", citation "footcite" NormalCitation False)+ , ("footcite", inNote <$> citation "footcite" NormalCitation False) , ("parencite", citation "parencite" NormalCitation False) , ("supercite", citation "supercite" NormalCitation False)- , ("footcitetext", citation "footcitetext" NormalCitation False)+ , ("footcitetext", inNote <$> citation "footcitetext" NormalCitation False) , ("citeyearpar", citation "citeyearpar" SuppressAuthor False) , ("citeyear", citation "citeyear" SuppressAuthor False) , ("autocite*", citation "autocite*" SuppressAuthor False)@@ -450,15 +457,15 @@ , ("textcites", citation "textcites" AuthorInText True) , ("cites", citation "cites" NormalCitation True) , ("autocites", citation "autocites" NormalCitation True)- , ("footcites", citation "footcites" NormalCitation True)+ , ("footcites", inNote <$> citation "footcites" NormalCitation True) , ("parencites", citation "parencites" NormalCitation True) , ("supercites", citation "supercites" NormalCitation True)- , ("footcitetexts", citation "footcitetexts" NormalCitation True)+ , ("footcitetexts", inNote <$> citation "footcitetexts" NormalCitation True) , ("Autocite", citation "Autocite" NormalCitation False) , ("Footcite", citation "Footcite" NormalCitation False) , ("Parencite", citation "Parencite" NormalCitation False) , ("Supercite", citation "Supercite" NormalCitation False)- , ("Footcitetext", citation "Footcitetext" NormalCitation False)+ , ("Footcitetext", inNote <$> citation "Footcitetext" NormalCitation False) , ("Citeyearpar", citation "Citeyearpar" SuppressAuthor False) , ("Citeyear", citation "Citeyear" SuppressAuthor False) , ("Autocite*", citation "Autocite*" SuppressAuthor False)@@ -471,7 +478,7 @@ , ("Footcites", citation "Footcites" NormalCitation True) , ("Parencites", citation "Parencites" NormalCitation True) , ("Supercites", citation "Supercites" NormalCitation True)- , ("Footcitetexts", citation "Footcitetexts" NormalCitation True)+ , ("Footcitetexts", inNote <$> citation "Footcitetexts" NormalCitation True) , ("citetext", complexNatbibCitation NormalCitation) , ("citeauthor", (try (tok *> optional sp *> controlSeq "citetext") *> complexNatbibCitation AuthorInText)@@ -479,8 +486,12 @@ ] ++ map ignoreInlines -- these commands will be ignored unless --parse-raw is specified, -- in which case they will appear as raw latex blocks:- [ "index", "nocite" ]+ [ "noindent", "index", "nocite" ] +inNote :: Inlines -> Inlines+inNote ils =+ note $ para $ ils <> str "."+ unescapeURL :: String -> String unescapeURL ('\\':x:xs) | isEscapable x = x:unescapeURL xs where isEscapable '%' = True@@ -489,6 +500,14 @@ unescapeURL (x:xs) = x:unescapeURL xs unescapeURL [] = "" +enquote :: LP Inlines+enquote = do+ skipopts+ context <- stateQuoteContext <$> getState+ if context == InDoubleQuote+ then singleQuoted <$> withQuoteContext InSingleQuote tok+ else doubleQuoted <$> withQuoteContext InDoubleQuote tok+ doverb :: LP Inlines doverb = do marker <- anyChar@@ -645,11 +664,7 @@ inlineText = str <$> many1 inlineChar inlineChar :: LP Char-inlineChar = satisfy $ \c ->- not (c == '\\' || c == '$' || c == '%' || c == '^' || c == '_' ||- c == '&' || c == '~' || c == '#' || c == '{' || c == '}' ||- c == '^' || c == '\'' || c == '`' || c == '-' || c == ']' ||- c == ' ' || c == '\t' || c == '\n' )+inlineChar = noneOf "\\$%^_&~#{}^'`-[] \t\n" environment :: LP Blocks environment = do@@ -662,7 +677,7 @@ rawEnv :: String -> LP Blocks rawEnv name = do let addBegin x = "\\begin{" ++ name ++ "}" ++ x- parseRaw <- stateParseRaw `fmap` getState+ parseRaw <- getOption readerParseRaw if parseRaw then (rawBlock "latex" . addBegin) <$> (withRaw (env name blocks) >>= applyMacros' . snd)@@ -670,29 +685,52 @@ -- | Replace "include" commands with file contents. handleIncludes :: String -> IO String-handleIncludes [] = return []-handleIncludes ('\\':xs) =+handleIncludes = handleIncludes' []++-- parents parameter prevents infinite include loops+handleIncludes' :: [FilePath] -> String -> IO String+handleIncludes' _ [] = return []+handleIncludes' parents ('%':xs) = handleIncludes' parents+ $ drop 1 $ dropWhile (/='\n') xs+handleIncludes' parents ('\\':xs) = case runParser include defaultParserState "input" ('\\':xs) of- Right (fs, rest) -> do let getfile f = E.catch (UTF8.readFile f)- (\(_::E.IOException) -> return "")- yss <- mapM getfile fs- (intercalate "\n" yss ++) `fmap`- handleIncludes rest+ Right (fs, rest) -> do yss <- mapM (\f -> if f `elem` parents+ then "" <$ warn ("Include file loop in '"+ ++ f ++ "'.")+ else readTeXFile f >>=+ handleIncludes' (f:parents)) fs+ rest' <- handleIncludes' parents rest+ return $ intercalate "\n" yss ++ rest' _ -> case runParser (verbCmd <|> verbatimEnv) defaultParserState- "input" ('\\':xs) of- Right (r, rest) -> (r ++) `fmap` handleIncludes rest- _ -> ('\\':) `fmap` handleIncludes xs-handleIncludes (x:xs) = (x:) `fmap` handleIncludes xs+ "input" ('\\':xs) of+ Right (r, rest) -> (r ++) `fmap` handleIncludes' parents rest+ _ -> ('\\':) `fmap` handleIncludes' parents xs+handleIncludes' parents (x:xs) = (x:) `fmap` handleIncludes' parents xs +readTeXFile :: FilePath -> IO String+readTeXFile f = do+ texinputs <- E.catch (getEnv "TEXINPUTS") $ \(_ :: E.SomeException) ->+ return "."+ let ds = splitBy (==':') texinputs+ readFileFromDirs ds f++readFileFromDirs :: [FilePath] -> FilePath -> IO String+readFileFromDirs [] _ = return ""+readFileFromDirs (d:ds) f =+ E.catch (UTF8.readFile $ d </> f) $ \(_ :: E.SomeException) ->+ readFileFromDirs ds f+ include :: LP ([FilePath], String) include = do- name <- controlSeq "include" <|> controlSeq "usepackage"+ name <- controlSeq "include"+ <|> controlSeq "input"+ <|> controlSeq "usepackage" skipopts fs <- (splitBy (==',')) <$> braced rest <- getInput- let fs' = if name == "include"- then map (flip replaceExtension ".tex") fs- else map (flip replaceExtension ".sty") fs+ let fs' = if name == "usepackage"+ then map (flip replaceExtension ".sty") fs+ else map (flip replaceExtension ".tex") fs return (fs', rest) verbCmd :: LP (String, String)@@ -715,15 +753,13 @@ rest <- getInput return (r,rest) -rawLaTeXBlock :: GenParser Char ParserState String-rawLaTeXBlock = snd <$> withRaw (environment <|> blockCommand)+rawLaTeXBlock :: Parser [Char] ParserState String+rawLaTeXBlock = snd <$> try (withRaw (environment <|> blockCommand)) -rawLaTeXInline :: GenParser Char ParserState Inline+rawLaTeXInline :: Parser [Char] ParserState Inline rawLaTeXInline = do- (res, raw) <- withRaw inlineCommand- if res == mempty- then return (Str "")- else RawInline "latex" <$> (applyMacros' raw)+ raw <- (snd <$> withRaw inlineCommand) <|> (snd <$> withRaw blockCommand)+ RawInline "latex" <$> applyMacros' raw environments :: M.Map String (LP Blocks) environments = M.fromList@@ -737,7 +773,7 @@ , ("itemize", bulletList <$> listenv "itemize" (many item)) , ("description", definitionList <$> listenv "description" (many descItem)) , ("enumerate", ordered_list)- , ("code", failUnlessLHS *>+ , ("code", guardEnabled Ext_literate_haskell *> (codeBlockWith ("",["sourceCode","literate","haskell"],[]) <$> verbEnv "code")) , ("verbatim", codeBlock <$> (verbEnv "verbatim"))@@ -745,6 +781,9 @@ , ("lstlisting", codeBlock <$> (verbEnv "lstlisting")) , ("minted", liftA2 (\l c -> codeBlockWith ("",[l],[]) c) (grouped (many1 $ satisfy (/= '}'))) (verbEnv "minted"))+ , ("obeylines", parseFromString+ (para . trimInlines . mconcat <$> many inline) =<<+ intercalate "\\\\\n" . lines <$> verbEnv "obeylines") , ("displaymath", mathEnv Nothing "displaymath") , ("equation", mathEnv Nothing "equation") , ("equation*", mathEnv Nothing "equation*")@@ -801,7 +840,9 @@ return (ils, [bs]) env :: String -> LP a -> LP a-env name p = p <* (controlSeq "end" *> braced >>= guard . (== name))+env name p = p <*+ (try (controlSeq "end" *> braced >>= guard . (== name))+ <?> ("\\end{" ++ name ++ "}")) listenv :: String -> LP a -> LP a listenv name p = try $ do
@@ -20,1364 +20,1724 @@ {- | Module : Text.Pandoc.Readers.Markdown Copyright : Copyright (C) 2006-2010 John MacFarlane- License : GNU GPL, version 2 or above -- Maintainer : John MacFarlane <jgm@berkeley.edu>- Stability : alpha- Portability : portable--Conversion of markdown-formatted plain text to 'Pandoc' document.--}-module Text.Pandoc.Readers.Markdown ( readMarkdown ) where--import Data.List ( transpose, sortBy, findIndex, intercalate )-import qualified Data.Map as M-import Data.Ord ( comparing )-import Data.Char ( isAlphaNum )-import Data.Maybe-import Text.Pandoc.Definition-import Text.Pandoc.Generic-import Text.Pandoc.Shared-import Text.Pandoc.Parsing-import Text.Pandoc.Readers.LaTeX ( rawLaTeXInline, rawLaTeXBlock )-import Text.Pandoc.Readers.HTML ( htmlTag, htmlInBalanced, isInlineTag, isBlockTag,- isTextTag, isCommentTag )-import Text.Pandoc.XML ( fromEntities )-import Text.ParserCombinators.Parsec-import Control.Monad (when, liftM, guard, mzero)-import Text.HTML.TagSoup-import Text.HTML.TagSoup.Match (tagOpen)---- | Read markdown from an input string and return a Pandoc document.-readMarkdown :: ParserState -- ^ Parser state, including options for parser- -> String -- ^ String to parse (assuming @'\n'@ line endings)- -> Pandoc-readMarkdown state s = (readWith parseMarkdown) state (s ++ "\n\n")------- Constants and data structure definitions-----isBulletListMarker :: Char -> Bool-isBulletListMarker '*' = True-isBulletListMarker '+' = True-isBulletListMarker '-' = True-isBulletListMarker _ = False--isHruleChar :: Char -> Bool-isHruleChar '*' = True-isHruleChar '-' = True-isHruleChar '_' = True-isHruleChar _ = False--setextHChars :: [Char]-setextHChars = "=-"--isBlank :: Char -> Bool-isBlank ' ' = True-isBlank '\t' = True-isBlank '\n' = True-isBlank _ = False------- auxiliary functions-----indentSpaces :: GenParser Char ParserState [Char]-indentSpaces = try $ do- state <- getState- let tabStop = stateTabStop state- count tabStop (char ' ') <|>- string "\t" <?> "indentation"--nonindentSpaces :: GenParser Char ParserState [Char]-nonindentSpaces = do- state <- getState- let tabStop = stateTabStop state- sps <- many (char ' ')- if length sps < tabStop - then return sps- else unexpected "indented line"--skipNonindentSpaces :: GenParser Char ParserState ()-skipNonindentSpaces = do- state <- getState- atMostSpaces (stateTabStop state - 1)--atMostSpaces :: Int -> GenParser Char ParserState ()-atMostSpaces 0 = notFollowedBy (char ' ')-atMostSpaces n = (char ' ' >> atMostSpaces (n-1)) <|> return ()--litChar :: GenParser Char ParserState Char-litChar = escapedChar'- <|> noneOf "\n"- <|> (newline >> notFollowedBy blankline >> return ' ')---- | Fail unless we're at beginning of a line.-failUnlessBeginningOfLine :: GenParser tok st () -failUnlessBeginningOfLine = do- pos <- getPosition- if sourceColumn pos == 1 then return () else fail "not beginning of line"---- | Parse a sequence of inline elements between square brackets,--- including inlines between balanced pairs of square brackets.-inlinesInBalancedBrackets :: GenParser Char ParserState Inline- -> GenParser Char ParserState [Inline]-inlinesInBalancedBrackets parser = try $ do- char '['- result <- manyTill ( (do lookAhead $ try $ do (Str res) <- parser- guard (res == "[")- bal <- inlinesInBalancedBrackets parser- return $ [Str "["] ++ bal ++ [Str "]"])- <|> (count 1 parser))- (char ']')- return $ concat result------- document structure-----titleLine :: GenParser Char ParserState [Inline]-titleLine = try $ do- char '%'- skipSpaces- res <- many $ (notFollowedBy newline >> inline)- <|> try (endline >> whitespace)- newline- return $ normalizeSpaces res--authorsLine :: GenParser Char ParserState [[Inline]]-authorsLine = try $ do - char '%'- skipSpaces- authors <- sepEndBy (many (notFollowedBy (satisfy $ \c ->- c == ';' || c == '\n') >> inline))- (char ';' <|>- try (newline >> notFollowedBy blankline >> spaceChar))- newline- return $ filter (not . null) $ map normalizeSpaces authors--dateLine :: GenParser Char ParserState [Inline]-dateLine = try $ do- char '%'- skipSpaces- date <- manyTill inline newline- return $ normalizeSpaces date--titleBlock :: GenParser Char ParserState ([Inline], [[Inline]], [Inline])-titleBlock = try $ do- failIfStrict- title <- option [] titleLine- author <- option [] authorsLine- date <- option [] dateLine- optional blanklines- return (title, author, date)--parseMarkdown :: GenParser Char ParserState Pandoc -parseMarkdown = do- -- markdown allows raw HTML- updateState (\state -> state { stateParseRaw = True })- startPos <- getPosition- -- go through once just to get list of reference keys and notes- -- docMinusKeys is the raw document with blanks where the keys/notes were...- st <- getState- let firstPassParser = referenceKey- <|> (if stateStrict st then pzero else noteBlock)- <|> liftM snd (withRaw codeBlockDelimited)- <|> lineClump- docMinusKeys <- liftM concat $ manyTill firstPassParser eof- setInput docMinusKeys- setPosition startPos- st' <- getState- let reversedNotes = stateNotes st'- updateState $ \s -> s { stateNotes = reverse reversedNotes }- -- now parse it for real...- (title, author, date) <- option ([],[],[]) titleBlock- blocks <- parseBlocks- let doc = Pandoc (Meta title author date) $ filter (/= Null) blocks- -- if there are labeled examples, change references into numbers- examples <- liftM stateExamples getState- let handleExampleRef :: Inline -> Inline- handleExampleRef z@(Str ('@':xs)) =- case M.lookup xs examples of- Just n -> Str (show n)- Nothing -> z- handleExampleRef z = z- if M.null examples- then return doc- else return $ bottomUp handleExampleRef doc---- --- initial pass for references and notes-----referenceKey :: GenParser Char ParserState [Char]-referenceKey = try $ do- startPos <- getPosition- skipNonindentSpaces- lab <- reference- char ':'- skipSpaces >> optional newline >> skipSpaces >> notFollowedBy (char '[')- let sourceURL = liftM unwords $ many $ try $ do- notFollowedBy' referenceTitle- skipMany spaceChar- optional $ newline >> notFollowedBy blankline- skipMany spaceChar- notFollowedBy' reference- many1 $ escapedChar' <|> satisfy (not . isBlank)- let betweenAngles = try $ char '<' >>- manyTill (escapedChar' <|> litChar) (char '>')- src <- try betweenAngles <|> sourceURL- tit <- option "" referenceTitle- blanklines- endPos <- getPosition- let target = (escapeURI $ removeTrailingSpace src, tit)- st <- getState- let oldkeys = stateKeys st- updateState $ \s -> s { stateKeys = M.insert (toKey lab) target oldkeys }- -- return blanks so line count isn't affected- return $ replicate (sourceLine endPos - sourceLine startPos) '\n'--referenceTitle :: GenParser Char ParserState String-referenceTitle = try $ do- skipSpaces >> optional newline >> skipSpaces- tit <- (charsInBalanced '(' ')' litChar >>= return . unwords . words)- <|> do delim <- char '\'' <|> char '"'- manyTill litChar (try (char delim >> skipSpaces >>- notFollowedBy (noneOf ")\n")))- return $ fromEntities tit--noteMarker :: GenParser Char ParserState [Char]-noteMarker = string "[^" >> many1Till (satisfy $ not . isBlank) (char ']')--rawLine :: GenParser Char ParserState [Char]-rawLine = try $ do- notFollowedBy blankline- notFollowedBy' $ try $ skipNonindentSpaces >> noteMarker- optional indentSpaces- anyLine--rawLines :: GenParser Char ParserState [Char]-rawLines = do- first <- anyLine- rest <- many rawLine- return $ unlines (first:rest)--noteBlock :: GenParser Char ParserState [Char]-noteBlock = try $ do- startPos <- getPosition- skipNonindentSpaces- ref <- noteMarker- char ':'- optional blankline- optional indentSpaces- raw <- sepBy rawLines- (try (blankline >> indentSpaces >>- notFollowedBy blankline))- optional blanklines- endPos <- getPosition- let newnote = (ref, (intercalate "\n" raw) ++ "\n\n")- st <- getState- let oldnotes = stateNotes st- updateState $ \s -> s { stateNotes = newnote : oldnotes }- -- return blanks so line count isn't affected- return $ replicate (sourceLine endPos - sourceLine startPos) '\n'------- parsing blocks-----parseBlocks :: GenParser Char ParserState [Block]-parseBlocks = manyTill block eof--block :: GenParser Char ParserState Block-block = do- st <- getState- choice (if stateStrict st- then [ header- , codeBlockIndented- , blockQuote- , hrule- , bulletList- , orderedList- , htmlBlock- , para- , plain- , nullBlock ]- else [ codeBlockDelimited- , macro- , header - , table- , codeBlockIndented- , lhsCodeBlock- , blockQuote- , hrule- , bulletList- , orderedList- , definitionList- , rawTeXBlock- , para- , rawHtmlBlocks- , plain- , nullBlock ]) <?> "block"------- header blocks-----header :: GenParser Char ParserState Block-header = setextHeader <|> atxHeader <?> "header"--atxHeader :: GenParser Char ParserState Block-atxHeader = try $ do- level <- many1 (char '#') >>= return . length- notFollowedBy (char '.' <|> char ')') -- this would be a list- skipSpaces- text <- manyTill inline atxClosing >>= return . normalizeSpaces- return $ Header level text--atxClosing :: GenParser Char st [Char]-atxClosing = try $ skipMany (char '#') >> blanklines--setextHeader :: GenParser Char ParserState Block-setextHeader = try $ do- -- This lookahead prevents us from wasting time parsing Inlines- -- unless necessary -- it gives a significant performance boost.- lookAhead $ anyLine >> many1 (oneOf setextHChars) >> blankline- text <- many1Till inline newline- underlineChar <- oneOf setextHChars- many (char underlineChar)- blanklines- let level = (fromMaybe 0 $ findIndex (== underlineChar) setextHChars) + 1- return $ Header level (normalizeSpaces text)------- hrule block-----hrule :: GenParser Char st Block-hrule = try $ do- skipSpaces- start <- satisfy isHruleChar- count 2 (skipSpaces >> char start)- skipMany (spaceChar <|> char start)- newline- optional blanklines- return HorizontalRule------- code blocks-----indentedLine :: GenParser Char ParserState [Char]-indentedLine = indentSpaces >> manyTill anyChar newline >>= return . (++ "\n")--blockDelimiter :: (Char -> Bool)- -> Maybe Int- -> GenParser Char st (Int, (String, [String], [(String, String)]), Char)-blockDelimiter f len = try $ do- c <- lookAhead (satisfy f)- size <- case len of- Just l -> count l (char c) >> many (char c) >> return l- Nothing -> count 3 (char c) >> many (char c) >>=- return . (+ 3) . length- many spaceChar- attr <- option ([],[],[])- $ attributes -- ~~~ {.ruby}- <|> (many1 alphaNum >>= \x -> return ([],[x],[])) -- github variant ```ruby- blankline- return (size, attr, c)--attributes :: GenParser Char st ([Char], [[Char]], [([Char], [Char])])-attributes = try $ do- char '{'- spnl- attrs <- many (attribute >>~ spnl)- char '}'- let (ids, classes, keyvals) = unzip3 attrs- let firstNonNull [] = ""- firstNonNull (x:xs) | not (null x) = x- | otherwise = firstNonNull xs- return (firstNonNull $ reverse ids, concat classes, concat keyvals)--attribute :: GenParser Char st ([Char], [[Char]], [([Char], [Char])])-attribute = identifierAttr <|> classAttr <|> keyValAttr--identifier :: GenParser Char st [Char]-identifier = do- first <- letter- rest <- many $ alphaNum <|> oneOf "-_:."- return (first:rest)--identifierAttr :: GenParser Char st ([Char], [a], [a1])-identifierAttr = try $ do- char '#'- result <- identifier- return (result,[],[])--classAttr :: GenParser Char st ([Char], [[Char]], [a])-classAttr = try $ do- char '.'- result <- identifier- return ("",[result],[])--keyValAttr :: GenParser Char st ([Char], [a], [([Char], [Char])])-keyValAttr = try $ do- key <- identifier- char '='- val <- enclosed (char '"') (char '"') anyChar- <|> enclosed (char '\'') (char '\'') anyChar- <|> many nonspaceChar- return ("",[],[(key,val)])--codeBlockDelimited :: GenParser Char st Block-codeBlockDelimited = try $ do- (size, attr, c) <- blockDelimiter (\c -> c == '~' || c == '`') Nothing- contents <- manyTill anyLine (blockDelimiter (== c) (Just size))- blanklines- return $ CodeBlock attr $ intercalate "\n" contents--codeBlockIndented :: GenParser Char ParserState Block-codeBlockIndented = do- contents <- many1 (indentedLine <|> - try (do b <- blanklines- l <- indentedLine- return $ b ++ l))- optional blanklines- st <- getState- return $ CodeBlock ("", stateIndentedCodeClasses st, []) $- stripTrailingNewlines $ concat contents--lhsCodeBlock :: GenParser Char ParserState Block-lhsCodeBlock = do- failUnlessLHS- liftM (CodeBlock ("",["sourceCode","literate","haskell"],[]))- (lhsCodeBlockBird <|> lhsCodeBlockLaTeX)- <|> liftM (CodeBlock ("",["sourceCode","haskell"],[]))- lhsCodeBlockInverseBird--lhsCodeBlockLaTeX :: GenParser Char ParserState String-lhsCodeBlockLaTeX = try $ do- string "\\begin{code}"- manyTill spaceChar newline- contents <- many1Till anyChar (try $ string "\\end{code}")- blanklines- return $ stripTrailingNewlines contents--lhsCodeBlockBird :: GenParser Char ParserState String-lhsCodeBlockBird = lhsCodeBlockBirdWith '>'--lhsCodeBlockInverseBird :: GenParser Char ParserState String-lhsCodeBlockInverseBird = lhsCodeBlockBirdWith '<'--lhsCodeBlockBirdWith :: Char -> GenParser Char ParserState String-lhsCodeBlockBirdWith c = try $ do- pos <- getPosition- when (sourceColumn pos /= 1) $ fail "Not in first column"- lns <- many1 $ birdTrackLine c- -- if (as is normal) there is always a space after >, drop it- let lns' = if all (\ln -> null ln || take 1 ln == " ") lns- then map (drop 1) lns- else lns- blanklines- return $ intercalate "\n" lns'--birdTrackLine :: Char -> GenParser Char st [Char]-birdTrackLine c = try $ do- char c- -- allow html tags on left margin:- when (c == '<') $ notFollowedBy letter- manyTill anyChar newline-------- block quotes-----emailBlockQuoteStart :: GenParser Char ParserState Char-emailBlockQuoteStart = try $ skipNonindentSpaces >> char '>' >>~ optional (char ' ')--emailBlockQuote :: GenParser Char ParserState [[Char]]-emailBlockQuote = try $ do- emailBlockQuoteStart- raw <- sepBy (many (nonEndline <|> - (try (endline >> notFollowedBy emailBlockQuoteStart >>- return '\n'))))- (try (newline >> emailBlockQuoteStart))- newline <|> (eof >> return '\n')- optional blanklines- return raw--blockQuote :: GenParser Char ParserState Block-blockQuote = do - raw <- emailBlockQuote- -- parse the extracted block, which may contain various block elements:- contents <- parseFromString parseBlocks $ (intercalate "\n" raw) ++ "\n\n"- return $ BlockQuote contents- ------ list blocks-----bulletListStart :: GenParser Char ParserState ()-bulletListStart = try $ do- optional newline -- if preceded by a Plain block in a list context- skipNonindentSpaces- notFollowedBy' hrule -- because hrules start out just like lists- satisfy isBulletListMarker- spaceChar- skipSpaces--anyOrderedListStart :: GenParser Char ParserState (Int, ListNumberStyle, ListNumberDelim) -anyOrderedListStart = try $ do- optional newline -- if preceded by a Plain block in a list context- skipNonindentSpaces- notFollowedBy $ string "p." >> spaceChar >> digit -- page number- state <- getState- if stateStrict state- then do many1 digit- char '.'- spaceChar- return (1, DefaultStyle, DefaultDelim)- else do (num, style, delim) <- anyOrderedListMarker- -- if it could be an abbreviated first name, insist on more than one space- if delim == Period && (style == UpperAlpha || (style == UpperRoman &&- num `elem` [1, 5, 10, 50, 100, 500, 1000]))- then char '\t' <|> (try $ char ' ' >> spaceChar)- else spaceChar- skipSpaces- return (num, style, delim)--listStart :: GenParser Char ParserState ()-listStart = bulletListStart <|> (anyOrderedListStart >> return ())---- parse a line of a list item (start = parser for beginning of list item)-listLine :: GenParser Char ParserState [Char]-listLine = try $ do- notFollowedBy blankline- notFollowedBy' (do indentSpaces- many (spaceChar)- listStart)- chunks <- manyTill (liftM snd (htmlTag isCommentTag) <|> count 1 anyChar) newline- return $ concat chunks ++ "\n"---- parse raw text for one list item, excluding start marker and continuations-rawListItem :: GenParser Char ParserState a- -> GenParser Char ParserState [Char]-rawListItem start = try $ do- start- first <- listLine- rest <- many (notFollowedBy listStart >> listLine)- blanks <- many blankline- return $ concat (first:rest) ++ blanks---- continuation of a list item - indented and separated by blankline --- or (in compact lists) endline.--- note: nested lists are parsed as continuations-listContinuation :: GenParser Char ParserState [Char]-listContinuation = try $ do- lookAhead indentSpaces- result <- many1 listContinuationLine- blanks <- many blankline- return $ concat result ++ blanks--listContinuationLine :: GenParser Char ParserState [Char]-listContinuationLine = try $ do- notFollowedBy blankline- notFollowedBy' listStart- optional indentSpaces- result <- manyTill anyChar newline- return $ result ++ "\n"--listItem :: GenParser Char ParserState a- -> GenParser Char ParserState [Block]-listItem start = try $ do- first <- rawListItem start- continuations <- many listContinuation- -- parsing with ListItemState forces markers at beginning of lines to- -- count as list item markers, even if not separated by blank space.- -- see definition of "endline"- state <- getState- let oldContext = stateParserContext state- setState $ state {stateParserContext = ListItemState}- -- parse the extracted block, which may contain various block elements:- let raw = concat (first:continuations)- contents <- parseFromString parseBlocks raw- updateState (\st -> st {stateParserContext = oldContext})- return contents--orderedList :: GenParser Char ParserState Block-orderedList = try $ do- (start, style, delim) <- lookAhead anyOrderedListStart- items <- many1 $ listItem $ try $- do optional newline -- if preceded by a Plain block in a list context- skipNonindentSpaces- orderedListMarker style delim- return $ OrderedList (start, style, delim) $ compactify items--bulletList :: GenParser Char ParserState Block-bulletList =- many1 (listItem bulletListStart) >>= return . BulletList . compactify---- definition lists--defListMarker :: GenParser Char ParserState ()-defListMarker = do- sps <- nonindentSpaces- char ':' <|> char '~'- st <- getState- let tabStop = stateTabStop st- let remaining = tabStop - (length sps + 1)- if remaining > 0- then count remaining (char ' ') <|> string "\t"- else pzero- return ()--definitionListItem :: GenParser Char ParserState ([Inline], [[Block]])-definitionListItem = try $ do- -- first, see if this has any chance of being a definition list:- lookAhead (anyLine >> optional blankline >> defListMarker)- term <- manyTill inline newline- optional blankline- raw <- many1 defRawBlock- state <- getState- let oldContext = stateParserContext state- -- parse the extracted block, which may contain various block elements:- contents <- mapM (parseFromString parseBlocks) raw- updateState (\st -> st {stateParserContext = oldContext})- return ((normalizeSpaces term), contents)--defRawBlock :: GenParser Char ParserState [Char]-defRawBlock = try $ do- defListMarker- firstline <- anyLine- rawlines <- many (notFollowedBy blankline >> indentSpaces >> anyLine)- trailing <- option "" blanklines- cont <- liftM concat $ many $ do- lns <- many1 $ notFollowedBy blankline >> indentSpaces >> anyLine- trl <- option "" blanklines- return $ unlines lns ++ trl- return $ firstline ++ "\n" ++ unlines rawlines ++ trailing ++ cont--definitionList :: GenParser Char ParserState Block-definitionList = do- items <- many1 definitionListItem- -- "compactify" the definition list:- let defs = map snd items- let defBlocks = reverse $ concat $ concat defs- let isPara (Para _) = True- isPara _ = False- let items' = case take 1 defBlocks of- [Para x] -> if not $ any isPara (drop 1 defBlocks)- then let (t,ds) = last items- lastDef = last ds- ds' = init ds ++- [init lastDef ++ [Plain x]]- in init items ++ [(t, ds')]- else items- _ -> items- return $ DefinitionList items'------- paragraph block-----isHtmlOrBlank :: Inline -> Bool-isHtmlOrBlank (RawInline "html" _) = True-isHtmlOrBlank (Space) = True-isHtmlOrBlank (LineBreak) = True-isHtmlOrBlank _ = False--para :: GenParser Char ParserState Block-para = try $ do - result <- liftM normalizeSpaces $ many1 inline- guard $ not . all isHtmlOrBlank $ result- option (Plain result) $ try $ do- newline- blanklines <|>- (getState >>= guard . stateStrict >>- lookAhead (blockQuote <|> header) >> return "")- return $ Para result--plain :: GenParser Char ParserState Block-plain = many1 inline >>~ spaces >>= return . Plain . normalizeSpaces---- --- raw html-----htmlElement :: GenParser Char ParserState [Char]-htmlElement = strictHtmlBlock <|> liftM snd (htmlTag isBlockTag)--htmlBlock :: GenParser Char ParserState Block-htmlBlock = try $ do- failUnlessBeginningOfLine- first <- htmlElement- finalSpace <- many spaceChar- finalNewlines <- many newline- return $ RawBlock "html" $ first ++ finalSpace ++ finalNewlines--strictHtmlBlock :: GenParser Char ParserState [Char]-strictHtmlBlock = do- failUnlessBeginningOfLine- htmlInBalanced (not . isInlineTag)--rawVerbatimBlock :: GenParser Char ParserState String-rawVerbatimBlock = try $ do- (TagOpen tag _, open) <- htmlTag (tagOpen (\t ->- t == "pre" || t == "style" || t == "script")- (const True))- contents <- manyTill anyChar (htmlTag (~== TagClose tag))- return $ open ++ contents ++ renderTags [TagClose tag]--rawTeXBlock :: GenParser Char ParserState Block-rawTeXBlock = do- failIfStrict- result <- liftM (RawBlock "latex") rawLaTeXBlock- <|> liftM (RawBlock "context") rawConTeXtEnvironment- spaces- return result--rawHtmlBlocks :: GenParser Char ParserState Block-rawHtmlBlocks = do- htmlBlocks <- many1 $ do blk <- rawVerbatimBlock <|>- liftM snd (htmlTag isBlockTag)- sps <- do sp1 <- many spaceChar- sp2 <- option "" (blankline >> return "\n")- sp3 <- many spaceChar- sp4 <- option "" blanklines- return $ sp1 ++ sp2 ++ sp3 ++ sp4- -- note: we want raw html to be able to- -- precede a code block, when separated- -- by a blank line- return $ blk ++ sps- let combined = concat htmlBlocks- let combined' = if last combined == '\n' then init combined else combined- return $ RawBlock "html" combined'------- Tables--- ---- Parse a dashed line with optional trailing spaces; return its length--- and the length including trailing space.-dashedLine :: Char - -> GenParser Char st (Int, Int)-dashedLine ch = do- dashes <- many1 (char ch)- sp <- many spaceChar- return $ (length dashes, length $ dashes ++ sp)---- Parse a table header with dashed lines of '-' preceded by --- one (or zero) line of text.-simpleTableHeader :: Bool -- ^ Headerless table - -> GenParser Char ParserState ([[Block]], [Alignment], [Int])-simpleTableHeader headless = try $ do- rawContent <- if headless- then return ""- else anyLine- initSp <- nonindentSpaces- dashes <- many1 (dashedLine '-')- newline- let (lengths, lines') = unzip dashes- let indices = scanl (+) (length initSp) lines'- -- If no header, calculate alignment on basis of first row of text- rawHeads <- liftM (tail . splitStringByIndices (init indices)) $- if headless- then lookAhead anyLine - else return rawContent- let aligns = zipWith alignType (map (\a -> [a]) rawHeads) lengths- let rawHeads' = if headless- then replicate (length dashes) ""- else rawHeads - heads <- mapM (parseFromString (many plain)) $- map removeLeadingTrailingSpace rawHeads'- return (heads, aligns, indices)---- Parse a table footer - dashed lines followed by blank line.-tableFooter :: GenParser Char ParserState [Char]-tableFooter = try $ skipNonindentSpaces >> many1 (dashedLine '-') >> blanklines---- Parse a table separator - dashed line.-tableSep :: GenParser Char ParserState Char-tableSep = try $ skipNonindentSpaces >> many1 (dashedLine '-') >> char '\n'---- Parse a raw line and split it into chunks by indices.-rawTableLine :: [Int]- -> GenParser Char ParserState [String]-rawTableLine indices = do- notFollowedBy' (blanklines <|> tableFooter)- line <- many1Till anyChar newline- return $ map removeLeadingTrailingSpace $ tail $ - splitStringByIndices (init indices) line---- Parse a table line and return a list of lists of blocks (columns).-tableLine :: [Int]- -> GenParser Char ParserState [[Block]]-tableLine indices = rawTableLine indices >>= mapM (parseFromString (many plain))---- Parse a multiline table row and return a list of blocks (columns).-multilineRow :: [Int]- -> GenParser Char ParserState [[Block]]-multilineRow indices = do- colLines <- many1 (rawTableLine indices)- let cols = map unlines $ transpose colLines- mapM (parseFromString (many plain)) cols---- Parses a table caption: inlines beginning with 'Table:'--- and followed by blank lines.-tableCaption :: GenParser Char ParserState [Inline]-tableCaption = try $ do- skipNonindentSpaces- string ":" <|> string "Table:"- result <- many1 inline- blanklines- return $ normalizeSpaces result---- Parse a simple table with '---' header and one line per row.-simpleTable :: Bool -- ^ Headerless table- -> GenParser Char ParserState Block-simpleTable headless = do- Table c a _w h l <- tableWith (simpleTableHeader headless) tableLine- (return ())- (if headless then tableFooter else tableFooter <|> blanklines)- tableCaption- -- Simple tables get 0s for relative column widths (i.e., use default)- return $ Table c a (replicate (length a) 0) h l---- Parse a multiline table: starts with row of '-' on top, then header--- (which may be multiline), then the rows,--- which may be multiline, separated by blank lines, and--- ending with a footer (dashed line followed by blank line).-multilineTable :: Bool -- ^ Headerless table- -> GenParser Char ParserState Block-multilineTable headless =- tableWith (multilineTableHeader headless) multilineRow blanklines tableFooter tableCaption--multilineTableHeader :: Bool -- ^ Headerless table- -> GenParser Char ParserState ([[Block]], [Alignment], [Int])-multilineTableHeader headless = try $ do- if headless- then return '\n'- else tableSep >>~ notFollowedBy blankline- rawContent <- if headless- then return $ repeat "" - else many1- (notFollowedBy tableSep >> many1Till anyChar newline)- initSp <- nonindentSpaces- dashes <- many1 (dashedLine '-')- newline- let (lengths, lines') = unzip dashes- let indices = scanl (+) (length initSp) lines'- rawHeadsList <- if headless- then liftM (map (:[]) . tail .- splitStringByIndices (init indices)) $ lookAhead anyLine- else return $ transpose $ map - (\ln -> tail $ splitStringByIndices (init indices) ln)- rawContent- let aligns = zipWith alignType rawHeadsList lengths- let rawHeads = if headless- then replicate (length dashes) ""- else map (intercalate " ") rawHeadsList- heads <- mapM (parseFromString (many plain)) $- map removeLeadingTrailingSpace rawHeads- return (heads, aligns, indices)---- Returns an alignment type for a table, based on a list of strings--- (the rows of the column header) and a number (the length of the--- dashed line under the rows.-alignType :: [String]- -> Int- -> Alignment-alignType [] _ = AlignDefault-alignType strLst len =- let nonempties = filter (not . null) $ map removeTrailingSpace strLst- (leftSpace, rightSpace) =- case sortBy (comparing length) nonempties of- (x:_) -> (head x `elem` " \t", length x < len)- [] -> (False, False)- in case (leftSpace, rightSpace) of- (True, False) -> AlignRight- (False, True) -> AlignLeft- (True, True) -> AlignCenter- (False, False) -> AlignDefault--gridTable :: Bool -- ^ Headerless table- -> GenParser Char ParserState Block-gridTable = gridTableWith block tableCaption--table :: GenParser Char ParserState Block-table = multilineTable False <|> simpleTable True <|>- simpleTable False <|> multilineTable True <|>- gridTable False <|> gridTable True <?> "table"---- --- inline-----inline :: GenParser Char ParserState Inline-inline = choice inlineParsers <?> "inline"--inlineParsers :: [GenParser Char ParserState Inline]-inlineParsers = [ whitespace- , str- , endline- , code- , fours- , strong- , emph- , note- , link- , cite- , image- , math- , strikeout- , superscript- , subscript- , inlineNote -- after superscript because of ^[link](/foo)^- , autoLink- , rawHtmlInline- , escapedChar- , rawLaTeXInline'- , exampleRef- , smartPunctuation inline- , charRef- , symbol- , ltSign ]--escapedChar' :: GenParser Char ParserState Char-escapedChar' = try $ do- char '\\'- state <- getState- if stateStrict state- then oneOf "\\`*_{}[]()>#+-.!~"- else satisfy (not . isAlphaNum)--escapedChar :: GenParser Char ParserState Inline-escapedChar = do- result <- escapedChar'- return $ case result of- ' ' -> Str "\160" -- "\ " is a nonbreaking space- '\n' -> LineBreak -- "\[newline]" is a linebreak- _ -> Str [result]--ltSign :: GenParser Char ParserState Inline-ltSign = do- st <- getState- if stateStrict st- then char '<'- else notFollowedBy' rawHtmlBlocks >> char '<' -- unless it starts html- return $ Str ['<']--exampleRef :: GenParser Char ParserState Inline-exampleRef = try $ do- char '@'- lab <- many1 (alphaNum <|> oneOf "-_")- -- We just return a Str. These are replaced with numbers- -- later. See the end of parseMarkdown.- return $ Str $ '@' : lab--symbol :: GenParser Char ParserState Inline-symbol = do - result <- noneOf "<\\\n\t "- <|> try (do lookAhead $ char '\\'- notFollowedBy' rawTeXBlock- char '\\')- return $ Str [result]---- parses inline code, between n `s and n `s-code :: GenParser Char ParserState Inline-code = try $ do - starts <- many1 (char '`')- skipSpaces- result <- many1Till (many1 (noneOf "`\n") <|> many1 (char '`') <|>- (char '\n' >> notFollowedBy' blankline >> return " "))- (try (skipSpaces >> count (length starts) (char '`') >> - notFollowedBy (char '`')))- attr <- option ([],[],[]) (try $ optional whitespace >> attributes)- return $ Code attr $ removeLeadingTrailingSpace $ concat result--mathWord :: GenParser Char st [Char]-mathWord = liftM concat $ many1 mathChunk--mathChunk :: GenParser Char st [Char]-mathChunk = do char '\\'- c <- anyChar- return ['\\',c]- <|> many1 (satisfy $ \c -> not (isBlank c || c == '\\' || c == '$'))--math :: GenParser Char ParserState Inline-math = (mathDisplay >>= applyMacros' >>= return . Math DisplayMath)- <|> (mathInline >>= applyMacros' >>= return . Math InlineMath)--mathDisplay :: GenParser Char ParserState String -mathDisplay = try $ do- failIfStrict- string "$$"- many1Till (noneOf "\n" <|> (newline >>~ notFollowedBy' blankline)) (try $ string "$$")--mathInline :: GenParser Char ParserState String-mathInline = try $ do- failIfStrict- char '$'- notFollowedBy space- words' <- sepBy1 mathWord (many1 (spaceChar <|> (newline >>~ notFollowedBy' blankline)))- char '$'- notFollowedBy digit- return $ intercalate " " words'---- to avoid performance problems, treat 4 or more _ or * or ~ or ^ in a row--- as a literal rather than attempting to parse for emph/strong/strikeout/super/sub-fours :: GenParser Char st Inline-fours = try $ do- x <- char '*' <|> char '_' <|> char '~' <|> char '^'- count 2 $ satisfy (==x)- rest <- many1 (satisfy (==x))- return $ Str (x:x:x:rest)---- | Parses a list of inlines between start and end delimiters.-inlinesBetween :: (Show b)- => GenParser Char ParserState a- -> GenParser Char ParserState b- -> GenParser Char ParserState [Inline]-inlinesBetween start end =- normalizeSpaces `liftM` try (start >> many1Till inner end)- where inner = innerSpace <|> (notFollowedBy' whitespace >> inline)- innerSpace = try $ whitespace >>~ notFollowedBy' end---- This is used to prevent exponential blowups for things like:--- a**a*a**a*a**a*a**a*a**a*a**a*a**-nested :: GenParser Char ParserState a- -> GenParser Char ParserState a-nested p = do- nestlevel <- stateMaxNestingLevel `fmap` getState- guard $ nestlevel > 0- updateState $ \st -> st{ stateMaxNestingLevel = stateMaxNestingLevel st - 1 }- res <- p- updateState $ \st -> st{ stateMaxNestingLevel = nestlevel }- return res--emph :: GenParser Char ParserState Inline-emph = Emph `fmap` nested- (inlinesBetween starStart starEnd <|> inlinesBetween ulStart ulEnd)- where starStart = char '*' >> lookAhead nonspaceChar- starEnd = notFollowedBy' strong >> char '*'- ulStart = char '_' >> lookAhead nonspaceChar- ulEnd = notFollowedBy' strong >> char '_'--strong :: GenParser Char ParserState Inline-strong = Strong `liftM` nested- (inlinesBetween starStart starEnd <|> inlinesBetween ulStart ulEnd)- where starStart = string "**" >> lookAhead nonspaceChar- starEnd = try $ string "**"- ulStart = string "__" >> lookAhead nonspaceChar- ulEnd = try $ string "__"--strikeout :: GenParser Char ParserState Inline-strikeout = Strikeout `liftM`- (failIfStrict >> inlinesBetween strikeStart strikeEnd)- where strikeStart = string "~~" >> lookAhead nonspaceChar- >> notFollowedBy (char '~')- strikeEnd = try $ string "~~"--superscript :: GenParser Char ParserState Inline-superscript = failIfStrict >> enclosed (char '^') (char '^') - (notFollowedBy spaceChar >> inline) >>= -- may not contain Space- return . Superscript--subscript :: GenParser Char ParserState Inline-subscript = failIfStrict >> enclosed (char '~') (char '~')- (notFollowedBy spaceChar >> inline) >>= -- may not contain Space- return . Subscript --whitespace :: GenParser Char ParserState Inline-whitespace = spaceChar >>- ( (spaceChar >> skipMany spaceChar >> option Space (endline >> return LineBreak))- <|> (skipMany spaceChar >> return Space) ) <?> "whitespace"--nonEndline :: GenParser Char st Char-nonEndline = satisfy (/='\n')--str :: GenParser Char ParserState Inline-str = do- smart <- stateSmart `fmap` getState- a <- alphaNum- as <- many $ alphaNum- <|> (try $ char '_' >>~ lookAhead alphaNum)- <|> if smart- then (try $ satisfy (\c -> c == '\'' || c == '\x2019') >>- lookAhead alphaNum >> return '\x2019')- -- for things like l'aide- else mzero- pos <- getPosition- updateState $ \s -> s{ stateLastStrPos = Just pos }- let result = a:as- let spacesToNbr = map (\c -> if c == ' ' then '\160' else c)- if smart- then case likelyAbbrev result of- [] -> return $ Str result- xs -> choice (map (\x ->- try (string x >> oneOf " \n" >>- lookAhead alphaNum >>- return (Str $ result ++ spacesToNbr x ++ "\160"))) xs)- <|> (return $ Str result)- else return $ Str result---- | if the string matches the beginning of an abbreviation (before--- the first period, return strings that would finish the abbreviation.-likelyAbbrev :: String -> [String]-likelyAbbrev x =- let abbrevs = [ "Mr.", "Mrs.", "Ms.", "Capt.", "Dr.", "Prof.",- "Gen.", "Gov.", "e.g.", "i.e.", "Sgt.", "St.",- "vol.", "vs.", "Sen.", "Rep.", "Pres.", "Hon.",- "Rev.", "Ph.D.", "M.D.", "M.A.", "p.", "pp.",- "ch.", "sec.", "cf.", "cp."]- abbrPairs = map (break (=='.')) abbrevs- in map snd $ filter (\(y,_) -> y == x) abbrPairs---- an endline character that can be treated as a space, not a structural break-endline :: GenParser Char ParserState Inline-endline = try $ do- newline- notFollowedBy blankline- st <- getState- when (stateStrict st) $ do- notFollowedBy emailBlockQuoteStart- notFollowedBy (char '#') -- atx header- -- parse potential list-starts differently if in a list:- when (stateParserContext st == ListItemState) $ do- notFollowedBy' bulletListStart- notFollowedBy' anyOrderedListStart- return Space------- links------- a reference label for a link-reference :: GenParser Char ParserState [Inline]-reference = do notFollowedBy' (string "[^") -- footnote reference- result <- inlinesInBalancedBrackets inline- return $ normalizeSpaces result---- source for a link, with optional title-source :: GenParser Char ParserState (String, [Char])-source =- (try $ charsInBalanced '(' ')' litChar >>= parseFromString source') <|>- -- the following is needed for cases like: [ref](/url(a).- (enclosed (char '(') (char ')') litChar >>= parseFromString source')---- auxiliary function for source-source' :: GenParser Char ParserState (String, [Char])-source' = do- skipSpaces- let nl = char '\n' >>~ notFollowedBy blankline- let sourceURL = liftM unwords $ many $ try $ do- notFollowedBy' linkTitle- skipMany spaceChar- optional nl- skipMany spaceChar- many1 $ escapedChar' <|> satisfy (not . isBlank)- let betweenAngles = try $- char '<' >> manyTill (escapedChar' <|> noneOf ">\n" <|> nl) (char '>')- src <- try betweenAngles <|> sourceURL- tit <- option "" linkTitle- skipSpaces- eof- return (escapeURI $ removeTrailingSpace src, tit)--linkTitle :: GenParser Char ParserState String-linkTitle = try $ do- (many1 spaceChar >> option '\n' newline) <|> newline- skipSpaces- delim <- oneOf "'\""- tit <- manyTill litChar (try (char delim >> skipSpaces >> eof))- return $ fromEntities tit--link :: GenParser Char ParserState Inline-link = try $ do- lab <- reference- (src, tit) <- source <|> referenceLink lab- return $ Link (delinkify lab) (src, tit)--delinkify :: [Inline] -> [Inline]-delinkify = bottomUp $ concatMap go- where go (Link lab _) = lab- go x = [x]---- a link like [this][ref] or [this][] or [this]-referenceLink :: [Inline]- -> GenParser Char ParserState (String, [Char])-referenceLink lab = do- ref <- option [] (try (optional (char ' ') >> - optional (newline >> skipSpaces) >> reference))- let ref' = if null ref then lab else ref- state <- getState- case lookupKeySrc (stateKeys state) (toKey ref') of- Nothing -> fail "no corresponding key" - Just target -> return target --autoLink :: GenParser Char ParserState Inline-autoLink = try $ do- char '<'- (orig, src) <- uri <|> emailAddress- char '>'- st <- getState- return $ if stateStrict st- then Link [Str orig] (src, "")- else Link [Code ("",["url"],[]) orig] (src, "")--image :: GenParser Char ParserState Inline-image = try $ do- char '!'- lab <- reference- (src, tit) <- source <|> referenceLink lab- return $ Image lab (src,tit)--note :: GenParser Char ParserState Inline-note = try $ do- failIfStrict- ref <- noteMarker- state <- getState- let notes = stateNotes state- case lookup ref notes of- Nothing -> fail "note not found"- Just raw -> do- -- We temporarily empty the note list while parsing the note,- -- so that we don't get infinite loops with notes inside notes...- -- Note references inside other notes do not work.- updateState $ \st -> st{ stateNotes = [] }- contents <- parseFromString parseBlocks raw- updateState $ \st -> st{ stateNotes = notes }- return $ Note contents--inlineNote :: GenParser Char ParserState Inline-inlineNote = try $ do- failIfStrict- char '^'- contents <- inlinesInBalancedBrackets inline- return $ Note [Para contents]--rawLaTeXInline' :: GenParser Char ParserState Inline-rawLaTeXInline' = try $ do- failIfStrict- lookAhead $ char '\\' >> notFollowedBy' (string "start") -- context env- RawInline _ s <- rawLaTeXInline- return $ RawInline "tex" s -- "tex" because it might be context or latex--rawConTeXtEnvironment :: GenParser Char st String-rawConTeXtEnvironment = try $ do- string "\\start"- completion <- inBrackets (letter <|> digit <|> spaceChar)- <|> (many1 letter)- contents <- manyTill (rawConTeXtEnvironment <|> (count 1 anyChar))- (try $ string "\\stop" >> string completion)- return $ "\\start" ++ completion ++ concat contents ++ "\\stop" ++ completion--inBrackets :: (GenParser Char st Char) -> GenParser Char st String-inBrackets parser = do- char '['- contents <- many parser- char ']'- return $ "[" ++ contents ++ "]"--rawHtmlInline :: GenParser Char ParserState Inline-rawHtmlInline = do- st <- getState- (_,result) <- if stateStrict st- then htmlTag (not . isTextTag)- else htmlTag isInlineTag- return $ RawInline "html" result---- Citations--cite :: GenParser Char ParserState Inline-cite = do- failIfStrict- citations <- textualCite <|> normalCite- return $ Cite citations []--spnl :: GenParser Char st ()-spnl = try $ do- skipSpaces- optional newline- skipSpaces- notFollowedBy (char '\n')--textualCite :: GenParser Char ParserState [Citation]-textualCite = try $ do- (_, key) <- citeKey- let first = Citation{ citationId = key- , citationPrefix = []- , citationSuffix = []- , citationMode = AuthorInText- , citationNoteNum = 0- , citationHash = 0- }- rest <- option [] $ try $ spnl >> normalCite- if null rest- then option [first] $ bareloc first- else return $ first : rest--bareloc :: Citation -> GenParser Char ParserState [Citation]-bareloc c = try $ do- spnl- char '['- suff <- suffix- rest <- option [] $ try $ char ';' >> citeList- spnl- char ']'- return $ c{ citationSuffix = suff } : rest--normalCite :: GenParser Char ParserState [Citation]-normalCite = try $ do- char '['- spnl- citations <- citeList- spnl- char ']'- return citations--citeKey :: GenParser Char ParserState (Bool, String)-citeKey = try $ do- suppress_author <- option False (char '-' >> return True)- char '@'- first <- letter- let internal p = try $ p >>~ lookAhead (letter <|> digit)- rest <- many $ letter <|> digit <|> internal (oneOf ":.#$%&-_?<>~")- let key = first:rest- st <- getState- guard $ key `elem` stateCitations st- return (suppress_author, key)--suffix :: GenParser Char ParserState [Inline]-suffix = try $ do- hasSpace <- option False (notFollowedBy nonspaceChar >> return True)- spnl- rest <- liftM normalizeSpaces $ many $ notFollowedBy (oneOf ";]") >> inline- return $ if hasSpace- then Space : rest- else rest--prefix :: GenParser Char ParserState [Inline]-prefix = liftM normalizeSpaces $- manyTill inline (char ']' <|> liftM (const ']') (lookAhead citeKey))--citeList :: GenParser Char ParserState [Citation]-citeList = sepBy1 citation (try $ char ';' >> spnl)--citation :: GenParser Char ParserState Citation-citation = try $ do- pref <- prefix- (suppress_author, key) <- citeKey- suff <- suffix- return $ Citation{ citationId = key- , citationPrefix = pref- , citationSuffix = suff- , citationMode = if suppress_author- then SuppressAuthor- else NormalCitation- , citationNoteNum = 0- , citationHash = 0- }-+ License : GNU GPL, version 2 or above++ Maintainer : John MacFarlane <jgm@berkeley.edu>+ Stability : alpha+ Portability : portable++Conversion of markdown-formatted plain text to 'Pandoc' document.+-}+module Text.Pandoc.Readers.Markdown ( readMarkdown,+ readMarkdownWithWarnings ) where++import Data.List ( transpose, sortBy, findIndex, intersperse, intercalate )+import qualified Data.Map as M+import Data.Ord ( comparing )+import Data.Char ( isAlphaNum, toLower )+import Data.Maybe+import Text.Pandoc.Definition+import qualified Text.Pandoc.Builder as B+import Text.Pandoc.Builder (Inlines, Blocks, trimInlines, (<>))+import Text.Pandoc.Options+import Text.Pandoc.Shared+import Text.Pandoc.Parsing hiding (tableWith)+import Text.Pandoc.Readers.LaTeX ( rawLaTeXInline, rawLaTeXBlock )+import Text.Pandoc.Readers.HTML ( htmlTag, htmlInBalanced, isInlineTag, isBlockTag,+ isTextTag, isCommentTag )+import Text.Pandoc.XML ( fromEntities )+import Text.Pandoc.Biblio (processBiblio)+import qualified Text.CSL as CSL+import Data.Monoid (mconcat, mempty)+import Control.Applicative ((<$>), (<*), (*>), (<$))+import Control.Monad+import Text.HTML.TagSoup+import Text.HTML.TagSoup.Match (tagOpen)+import qualified Data.Set as Set++type MarkdownParser = Parser [Char] ParserState++-- | Read markdown from an input string and return a Pandoc document.+readMarkdown :: ReaderOptions -- ^ Reader options+ -> String -- ^ String to parse (assuming @'\n'@ line endings)+ -> Pandoc+readMarkdown opts s =+ (readWith parseMarkdown) def{ stateOptions = opts } (s ++ "\n\n")++-- | Read markdown from an input string and return a pair of a Pandoc document+-- and a list of warnings.+readMarkdownWithWarnings :: ReaderOptions -- ^ Reader options+ -> String -- ^ String to parse (assuming @'\n'@ line endings)+ -> (Pandoc, [String])+readMarkdownWithWarnings opts s =+ (readWith parseMarkdownWithWarnings) def{ stateOptions = opts } (s ++ "\n\n")+ where parseMarkdownWithWarnings = do+ doc <- parseMarkdown+ warnings <- stateWarnings <$> getState+ return (doc, warnings)++trimInlinesF :: F Inlines -> F Inlines+trimInlinesF = liftM trimInlines++--+-- Constants and data structure definitions+--++isBulletListMarker :: Char -> Bool+isBulletListMarker '*' = True+isBulletListMarker '+' = True+isBulletListMarker '-' = True+isBulletListMarker _ = False++isHruleChar :: Char -> Bool+isHruleChar '*' = True+isHruleChar '-' = True+isHruleChar '_' = True+isHruleChar _ = False++setextHChars :: String+setextHChars = "=-"++isBlank :: Char -> Bool+isBlank ' ' = True+isBlank '\t' = True+isBlank '\n' = True+isBlank _ = False++--+-- auxiliary functions+--++isNull :: F Inlines -> Bool+isNull ils = B.isNull $ runF ils def++spnl :: Parser [Char] st ()+spnl = try $ do+ skipSpaces+ optional newline+ skipSpaces+ notFollowedBy (char '\n')++indentSpaces :: MarkdownParser String+indentSpaces = try $ do+ tabStop <- getOption readerTabStop+ count tabStop (char ' ') <|>+ string "\t" <?> "indentation"++nonindentSpaces :: MarkdownParser String+nonindentSpaces = do+ tabStop <- getOption readerTabStop+ sps <- many (char ' ')+ if length sps < tabStop+ then return sps+ else unexpected "indented line"++skipNonindentSpaces :: MarkdownParser ()+skipNonindentSpaces = do+ tabStop <- getOption readerTabStop+ atMostSpaces (tabStop - 1)++atMostSpaces :: Int -> MarkdownParser ()+atMostSpaces 0 = notFollowedBy (char ' ')+atMostSpaces n = (char ' ' >> atMostSpaces (n-1)) <|> return ()++litChar :: MarkdownParser Char+litChar = escapedChar'+ <|> noneOf "\n"+ <|> try (newline >> notFollowedBy blankline >> return ' ')++-- | Parse a sequence of inline elements between square brackets,+-- including inlines between balanced pairs of square brackets.+inlinesInBalancedBrackets :: MarkdownParser (F Inlines)+inlinesInBalancedBrackets = charsInBalancedBrackets >>=+ parseFromString (trimInlinesF . mconcat <$> many inline)++charsInBalancedBrackets :: MarkdownParser [Char]+charsInBalancedBrackets = do+ char '['+ result <- manyTill ( many1 (noneOf "`[]\n")+ <|> (snd <$> withRaw code)+ <|> ((\xs -> '[' : xs ++ "]") <$> charsInBalancedBrackets)+ <|> count 1 (satisfy (/='\n'))+ <|> (newline >> notFollowedBy blankline >> return "\n")+ ) (char ']')+ return $ concat result++--+-- document structure+--++titleLine :: MarkdownParser (F Inlines)+titleLine = try $ do+ char '%'+ skipSpaces+ res <- many $ (notFollowedBy newline >> inline)+ <|> try (endline >> whitespace)+ newline+ return $ trimInlinesF $ mconcat res++authorsLine :: MarkdownParser (F [Inlines])+authorsLine = try $ do+ char '%'+ skipSpaces+ authors <- sepEndBy (many (notFollowedBy (satisfy $ \c ->+ c == ';' || c == '\n') >> inline))+ (char ';' <|>+ try (newline >> notFollowedBy blankline >> spaceChar))+ newline+ return $ sequence $ filter (not . isNull) $ map (trimInlinesF . mconcat) authors++dateLine :: MarkdownParser (F Inlines)+dateLine = try $ do+ char '%'+ skipSpaces+ trimInlinesF . mconcat <$> manyTill inline newline++titleBlock :: MarkdownParser (F Inlines, F [Inlines], F Inlines)+titleBlock = pandocTitleBlock <|> mmdTitleBlock++pandocTitleBlock :: MarkdownParser (F Inlines, F [Inlines], F Inlines)+pandocTitleBlock = try $ do+ guardEnabled Ext_pandoc_title_block+ title <- option mempty titleLine+ author <- option (return []) authorsLine+ date <- option mempty dateLine+ optional blanklines+ return (title, author, date)++mmdTitleBlock :: MarkdownParser (F Inlines, F [Inlines], F Inlines)+mmdTitleBlock = try $ do+ guardEnabled Ext_mmd_title_block+ kvPairs <- many1 kvPair+ blanklines+ let title = maybe mempty return $ lookup "title" kvPairs+ let author = maybe mempty (\x -> return [x]) $ lookup "author" kvPairs+ let date = maybe mempty return $ lookup "date" kvPairs+ return (title, author, date)++kvPair :: MarkdownParser (String, Inlines)+kvPair = try $ do+ key <- many1Till (alphaNum <|> oneOf "_- ") (char ':')+ val <- manyTill anyChar+ (try $ newline >> lookAhead (blankline <|> nonspaceChar))+ let key' = concat $ words $ map toLower key+ let val' = trimInlines $ B.text val+ return (key',val')++parseMarkdown :: MarkdownParser Pandoc+parseMarkdown = do+ -- markdown allows raw HTML+ updateState $ \state -> state { stateOptions =+ let oldOpts = stateOptions state in+ oldOpts{ readerParseRaw = True } }+ (title, authors, date) <- option (mempty,return [],mempty) titleBlock+ blocks <- parseBlocks+ st <- getState+ mbsty <- getOption readerCitationStyle+ refs <- getOption readerReferences+ return $ processBiblio mbsty refs+ $ B.setTitle (runF title st)+ $ B.setAuthors (runF authors st)+ $ B.setDate (runF date st)+ $ B.doc $ runF blocks st++addWarning :: Maybe SourcePos -> String -> MarkdownParser ()+addWarning mbpos msg =+ updateState $ \st -> st{+ stateWarnings = (msg ++ maybe "" (\pos -> " " ++ show pos) mbpos) :+ stateWarnings st }++referenceKey :: MarkdownParser (F Blocks)+referenceKey = try $ do+ pos <- getPosition+ skipNonindentSpaces+ (_,raw) <- reference+ char ':'+ skipSpaces >> optional newline >> skipSpaces >> notFollowedBy (char '[')+ let sourceURL = liftM unwords $ many $ try $ do+ notFollowedBy' referenceTitle+ skipMany spaceChar+ optional $ newline >> notFollowedBy blankline+ skipMany spaceChar+ notFollowedBy' (() <$ reference)+ many1 $ escapedChar' <|> satisfy (not . isBlank)+ let betweenAngles = try $ char '<' >>+ manyTill (escapedChar' <|> litChar) (char '>')+ src <- try betweenAngles <|> sourceURL+ tit <- option "" referenceTitle+ -- currently we just ignore MMD-style link/image attributes+ _kvs <- option [] $ guardEnabled Ext_link_attributes+ >> many (spnl >> keyValAttr)+ blanklines+ let target = (escapeURI $ trimr src, tit)+ st <- getState+ let oldkeys = stateKeys st+ let key = toKey raw+ case M.lookup key oldkeys of+ Just _ -> addWarning (Just pos) $ "Duplicate link reference `" ++ raw ++ "'"+ Nothing -> return ()+ updateState $ \s -> s { stateKeys = M.insert key target oldkeys }+ return $ return mempty++referenceTitle :: MarkdownParser String+referenceTitle = try $ do+ skipSpaces >> optional newline >> skipSpaces+ let parenTit = charsInBalanced '(' ')' litChar+ fromEntities <$> (quotedTitle '"' <|> quotedTitle '\'' <|> parenTit)++-- A link title in quotes+quotedTitle :: Char -> MarkdownParser String+quotedTitle c = try $ do+ char c+ notFollowedBy spaces+ let pEnder = try $ char c >> notFollowedBy (satisfy isAlphaNum)+ let regChunk = many1 (noneOf ['\\','\n',c]) <|> count 1 litChar+ let nestedChunk = (\x -> [c] ++ x ++ [c]) <$> quotedTitle c+ unwords . words . concat <$> manyTill (nestedChunk <|> regChunk) pEnder++-- | PHP Markdown Extra style abbreviation key. Currently+-- we just skip them, since Pandoc doesn't have an element for+-- an abbreviation.+abbrevKey :: MarkdownParser (F Blocks)+abbrevKey = do+ guardEnabled Ext_abbreviations+ try $ do+ char '*'+ reference+ char ':'+ skipMany (satisfy (/= '\n'))+ blanklines+ return $ return mempty++noteMarker :: MarkdownParser String+noteMarker = string "[^" >> many1Till (satisfy $ not . isBlank) (char ']')++rawLine :: MarkdownParser String+rawLine = try $ do+ notFollowedBy blankline+ notFollowedBy' $ try $ skipNonindentSpaces >> noteMarker+ optional indentSpaces+ anyLine++rawLines :: MarkdownParser String+rawLines = do+ first <- anyLine+ rest <- many rawLine+ return $ unlines (first:rest)++noteBlock :: MarkdownParser (F Blocks)+noteBlock = try $ do+ pos <- getPosition+ skipNonindentSpaces+ ref <- noteMarker+ char ':'+ optional blankline+ optional indentSpaces+ first <- rawLines+ rest <- many $ try $ blanklines >> indentSpaces >> rawLines+ let raw = unlines (first:rest) ++ "\n"+ optional blanklines+ parsed <- parseFromString parseBlocks raw+ let newnote = (ref, parsed)+ oldnotes <- stateNotes' <$> getState+ case lookup ref oldnotes of+ Just _ -> addWarning (Just pos) $ "Duplicate note reference `" ++ ref ++ "'"+ Nothing -> return ()+ updateState $ \s -> s { stateNotes' = newnote : oldnotes }+ return mempty++--+-- parsing blocks+--++parseBlocks :: MarkdownParser (F Blocks)+parseBlocks = mconcat <$> manyTill block eof++block :: MarkdownParser (F Blocks)+block = choice [ codeBlockFenced+ , codeBlockBackticks+ , guardEnabled Ext_latex_macros *> (mempty <$ macro)+ , header+ , rawTeXBlock+ , htmlBlock+ , lineBlock+ , table+ , codeBlockIndented+ , lhsCodeBlock+ , blockQuote+ , hrule+ , bulletList+ , orderedList+ , definitionList+ , noteBlock+ , referenceKey+ , abbrevKey+ , para+ , plain+ ] <?> "block"++--+-- header blocks+--++header :: MarkdownParser (F Blocks)+header = setextHeader <|> atxHeader <?> "header"++-- returns unique identifier+addToHeaderList :: Attr -> F Inlines -> MarkdownParser Attr+addToHeaderList (ident,classes,kvs) text = do+ let headerList = B.toList $ runF text defaultParserState+ updateState $ \st -> st{ stateHeaders = headerList : stateHeaders st }+ (do guardEnabled Ext_auto_identifiers+ ids <- stateIdentifiers `fmap` getState+ let id' = if null ident+ then uniqueIdent headerList ids+ else ident+ updateState $ \st -> st{ stateIdentifiers = id' : ids }+ return (id',classes,kvs)) <|> return ("",classes,kvs)++atxHeader :: MarkdownParser (F Blocks)+atxHeader = try $ do+ level <- many1 (char '#') >>= return . length+ notFollowedBy (char '.' <|> char ')') -- this would be a list+ skipSpaces+ text <- trimInlinesF . mconcat <$> many (notFollowedBy atxClosing >> inline)+ attr <- atxClosing+ attr' <- addToHeaderList attr text+ return $ B.headerWith attr' level <$> text++atxClosing :: MarkdownParser Attr+atxClosing = try $ do+ attr' <- option nullAttr+ (guardEnabled Ext_mmd_header_identifiers >> mmdHeaderIdentifier)+ skipMany (char '#')+ skipSpaces+ attr <- option attr'+ (guardEnabled Ext_header_attributes >> attributes)+ blanklines+ return attr++setextHeaderEnd :: MarkdownParser Attr+setextHeaderEnd = try $ do+ attr <- option nullAttr+ $ (guardEnabled Ext_mmd_header_identifiers >> mmdHeaderIdentifier)+ <|> (guardEnabled Ext_header_attributes >> attributes)+ blanklines+ return attr++mmdHeaderIdentifier :: MarkdownParser Attr+mmdHeaderIdentifier = do+ ident <- stripFirstAndLast . snd <$> reference+ skipSpaces+ return (ident,[],[])++setextHeader :: MarkdownParser (F Blocks)+setextHeader = try $ do+ -- This lookahead prevents us from wasting time parsing Inlines+ -- unless necessary -- it gives a significant performance boost.+ lookAhead $ anyLine >> many1 (oneOf setextHChars) >> blankline+ text <- trimInlinesF . mconcat <$> many1 (notFollowedBy setextHeaderEnd >> inline)+ attr <- setextHeaderEnd+ underlineChar <- oneOf setextHChars+ many (char underlineChar)+ blanklines+ let level = (fromMaybe 0 $ findIndex (== underlineChar) setextHChars) + 1+ attr' <- addToHeaderList attr text+ return $ B.headerWith attr' level <$> text++--+-- hrule block+--++hrule :: Parser [Char] st (F Blocks)+hrule = try $ do+ skipSpaces+ start <- satisfy isHruleChar+ count 2 (skipSpaces >> char start)+ skipMany (spaceChar <|> char start)+ newline+ optional blanklines+ return $ return B.horizontalRule++--+-- code blocks+--++indentedLine :: MarkdownParser String+indentedLine = indentSpaces >> manyTill anyChar newline >>= return . (++ "\n")++blockDelimiter :: (Char -> Bool)+ -> Maybe Int+ -> Parser [Char] st Int+blockDelimiter f len = try $ do+ c <- lookAhead (satisfy f)+ case len of+ Just l -> count l (char c) >> many (char c) >> return l+ Nothing -> count 3 (char c) >> many (char c) >>=+ return . (+ 3) . length++attributes :: Parser [Char] st (String, [String], [(String, String)])+attributes = try $ do+ char '{'+ spnl+ attrs <- many (attribute >>~ spnl)+ char '}'+ let (ids, classes, keyvals) = unzip3 attrs+ let firstNonNull [] = ""+ firstNonNull (x:xs) | not (null x) = x+ | otherwise = firstNonNull xs+ return (firstNonNull $ reverse ids, concat classes, concat keyvals)++attribute :: Parser [Char] st (String, [String], [(String, String)])+attribute = identifierAttr <|> classAttr <|> keyValAttr++identifier :: Parser [Char] st String+identifier = do+ first <- letter+ rest <- many $ alphaNum <|> oneOf "-_:."+ return (first:rest)++identifierAttr :: Parser [Char] st (String, [a], [a1])+identifierAttr = try $ do+ char '#'+ result <- identifier+ return (result,[],[])++classAttr :: Parser [Char] st (String, [String], [a])+classAttr = try $ do+ char '.'+ result <- identifier+ return ("",[result],[])++keyValAttr :: Parser [Char] st (String, [a], [(String, String)])+keyValAttr = try $ do+ key <- identifier+ char '='+ val <- enclosed (char '"') (char '"') anyChar+ <|> enclosed (char '\'') (char '\'') anyChar+ <|> many nonspaceChar+ return ("",[],[(key,val)])++codeBlockFenced :: MarkdownParser (F Blocks)+codeBlockFenced = try $ do+ guardEnabled Ext_fenced_code_blocks+ size <- blockDelimiter (=='~') Nothing+ skipMany spaceChar+ attr <- option ([],[],[]) $+ guardEnabled Ext_fenced_code_attributes >> attributes+ blankline+ contents <- manyTill anyLine (blockDelimiter (=='~') (Just size))+ blanklines+ return $ return $ B.codeBlockWith attr $ intercalate "\n" contents++codeBlockBackticks :: MarkdownParser (F Blocks)+codeBlockBackticks = try $ do+ guardEnabled Ext_backtick_code_blocks+ blockDelimiter (=='`') (Just 3)+ skipMany spaceChar+ cls <- many1 alphaNum+ blankline+ contents <- manyTill anyLine $ blockDelimiter (=='`') (Just 3)+ blanklines+ return $ return $ B.codeBlockWith ("",[cls],[]) $ intercalate "\n" contents++codeBlockIndented :: MarkdownParser (F Blocks)+codeBlockIndented = do+ contents <- many1 (indentedLine <|>+ try (do b <- blanklines+ l <- indentedLine+ return $ b ++ l))+ optional blanklines+ classes <- getOption readerIndentedCodeClasses+ return $ return $ B.codeBlockWith ("", classes, []) $+ stripTrailingNewlines $ concat contents++lhsCodeBlock :: MarkdownParser (F Blocks)+lhsCodeBlock = do+ guardEnabled Ext_literate_haskell+ (return . B.codeBlockWith ("",["sourceCode","literate","haskell"],[]) <$>+ (lhsCodeBlockBird <|> lhsCodeBlockLaTeX))+ <|> (return . B.codeBlockWith ("",["sourceCode","haskell"],[]) <$>+ lhsCodeBlockInverseBird)++lhsCodeBlockLaTeX :: MarkdownParser String+lhsCodeBlockLaTeX = try $ do+ string "\\begin{code}"+ manyTill spaceChar newline+ contents <- many1Till anyChar (try $ string "\\end{code}")+ blanklines+ return $ stripTrailingNewlines contents++lhsCodeBlockBird :: MarkdownParser String+lhsCodeBlockBird = lhsCodeBlockBirdWith '>'++lhsCodeBlockInverseBird :: MarkdownParser String+lhsCodeBlockInverseBird = lhsCodeBlockBirdWith '<'++lhsCodeBlockBirdWith :: Char -> MarkdownParser String+lhsCodeBlockBirdWith c = try $ do+ pos <- getPosition+ when (sourceColumn pos /= 1) $ fail "Not in first column"+ lns <- many1 $ birdTrackLine c+ -- if (as is normal) there is always a space after >, drop it+ let lns' = if all (\ln -> null ln || take 1 ln == " ") lns+ then map (drop 1) lns+ else lns+ blanklines+ return $ intercalate "\n" lns'++birdTrackLine :: Char -> Parser [Char] st String+birdTrackLine c = try $ do+ char c+ -- allow html tags on left margin:+ when (c == '<') $ notFollowedBy letter+ manyTill anyChar newline++--+-- block quotes+--++emailBlockQuoteStart :: MarkdownParser Char+emailBlockQuoteStart = try $ skipNonindentSpaces >> char '>' >>~ optional (char ' ')++emailBlockQuote :: MarkdownParser [String]+emailBlockQuote = try $ do+ emailBlockQuoteStart+ let emailLine = many $ nonEndline <|> try+ (endline >> notFollowedBy emailBlockQuoteStart >>+ return '\n')+ let emailSep = try (newline >> emailBlockQuoteStart)+ first <- emailLine+ rest <- many $ try $ emailSep >> emailLine+ let raw = first:rest+ newline <|> (eof >> return '\n')+ optional blanklines+ return raw++blockQuote :: MarkdownParser (F Blocks)+blockQuote = do+ raw <- emailBlockQuote+ -- parse the extracted block, which may contain various block elements:+ contents <- parseFromString parseBlocks $ (intercalate "\n" raw) ++ "\n\n"+ return $ B.blockQuote <$> contents++--+-- list blocks+--++bulletListStart :: MarkdownParser ()+bulletListStart = try $ do+ optional newline -- if preceded by a Plain block in a list context+ skipNonindentSpaces+ notFollowedBy' (() <$ hrule) -- because hrules start out just like lists+ satisfy isBulletListMarker+ spaceChar+ skipSpaces++anyOrderedListStart :: MarkdownParser (Int, ListNumberStyle, ListNumberDelim)+anyOrderedListStart = try $ do+ optional newline -- if preceded by a Plain block in a list context+ skipNonindentSpaces+ notFollowedBy $ string "p." >> spaceChar >> digit -- page number+ (guardDisabled Ext_fancy_lists >>+ do many1 digit+ char '.'+ spaceChar+ return (1, DefaultStyle, DefaultDelim))+ <|> do (num, style, delim) <- anyOrderedListMarker+ -- if it could be an abbreviated first name, insist on more than one space+ if delim == Period && (style == UpperAlpha || (style == UpperRoman &&+ num `elem` [1, 5, 10, 50, 100, 500, 1000]))+ then char '\t' <|> (try $ char ' ' >> spaceChar)+ else spaceChar+ skipSpaces+ return (num, style, delim)++listStart :: MarkdownParser ()+listStart = bulletListStart <|> (anyOrderedListStart >> return ())++-- parse a line of a list item (start = parser for beginning of list item)+listLine :: MarkdownParser String+listLine = try $ do+ notFollowedBy blankline+ notFollowedBy' (do indentSpaces+ many (spaceChar)+ listStart)+ chunks <- manyTill (liftM snd (htmlTag isCommentTag) <|> count 1 anyChar) newline+ return $ concat chunks ++ "\n"++-- parse raw text for one list item, excluding start marker and continuations+rawListItem :: MarkdownParser a+ -> MarkdownParser String+rawListItem start = try $ do+ start+ first <- listLine+ rest <- many (notFollowedBy listStart >> listLine)+ blanks <- many blankline+ return $ concat (first:rest) ++ blanks++-- continuation of a list item - indented and separated by blankline+-- or (in compact lists) endline.+-- note: nested lists are parsed as continuations+listContinuation :: MarkdownParser String+listContinuation = try $ do+ lookAhead indentSpaces+ result <- many1 listContinuationLine+ blanks <- many blankline+ return $ concat result ++ blanks++listContinuationLine :: MarkdownParser String+listContinuationLine = try $ do+ notFollowedBy blankline+ notFollowedBy' listStart+ optional indentSpaces+ result <- manyTill anyChar newline+ return $ result ++ "\n"++listItem :: MarkdownParser a+ -> MarkdownParser (F Blocks)+listItem start = try $ do+ first <- rawListItem start+ continuations <- many listContinuation+ -- parsing with ListItemState forces markers at beginning of lines to+ -- count as list item markers, even if not separated by blank space.+ -- see definition of "endline"+ state <- getState+ let oldContext = stateParserContext state+ setState $ state {stateParserContext = ListItemState}+ -- parse the extracted block, which may contain various block elements:+ let raw = concat (first:continuations)+ contents <- parseFromString parseBlocks raw+ updateState (\st -> st {stateParserContext = oldContext})+ return contents++orderedList :: MarkdownParser (F Blocks)+orderedList = try $ do+ (start, style, delim) <- lookAhead anyOrderedListStart+ unless ((style == DefaultStyle || style == Decimal || style == Example) &&+ (delim == DefaultDelim || delim == Period)) $+ guardEnabled Ext_fancy_lists+ when (style == Example) $ guardEnabled Ext_example_lists+ items <- fmap sequence $ many1 $ listItem+ ( try $ do+ optional newline -- if preceded by Plain block in a list+ skipNonindentSpaces+ orderedListMarker style delim )+ start' <- option 1 $ guardEnabled Ext_startnum >> return start+ return $ B.orderedListWith (start', style, delim) <$> fmap compactify' items++bulletList :: MarkdownParser (F Blocks)+bulletList = do+ items <- fmap sequence $ many1 $ listItem bulletListStart+ return $ B.bulletList <$> fmap compactify' items++-- definition lists++defListMarker :: MarkdownParser ()+defListMarker = do+ sps <- nonindentSpaces+ char ':' <|> char '~'+ tabStop <- getOption readerTabStop+ let remaining = tabStop - (length sps + 1)+ if remaining > 0+ then count remaining (char ' ') <|> string "\t"+ else mzero+ return ()++definitionListItem :: MarkdownParser (F (Inlines, [Blocks]))+definitionListItem = try $ do+ guardEnabled Ext_definition_lists+ -- first, see if this has any chance of being a definition list:+ lookAhead (anyLine >> optional blankline >> defListMarker)+ term <- trimInlinesF . mconcat <$> manyTill inline newline+ optional blankline+ raw <- many1 defRawBlock+ state <- getState+ let oldContext = stateParserContext state+ -- parse the extracted block, which may contain various block elements:+ contents <- mapM (parseFromString parseBlocks) raw+ updateState (\st -> st {stateParserContext = oldContext})+ return $ liftM2 (,) term (sequence contents)++defRawBlock :: MarkdownParser String+defRawBlock = try $ do+ defListMarker+ firstline <- anyLine+ rawlines <- many (notFollowedBy blankline >> indentSpaces >> anyLine)+ trailing <- option "" blanklines+ cont <- liftM concat $ many $ do+ lns <- many1 $ notFollowedBy blankline >> indentSpaces >> anyLine+ trl <- option "" blanklines+ return $ unlines lns ++ trl+ return $ firstline ++ "\n" ++ unlines rawlines ++ trailing ++ cont++definitionList :: MarkdownParser (F Blocks)+definitionList = do+ items <- fmap sequence $ many1 definitionListItem+ return $ B.definitionList <$> fmap compactify'DL items++compactify'DL :: [(Inlines, [Blocks])] -> [(Inlines, [Blocks])]+compactify'DL items =+ let defs = concatMap snd items+ defBlocks = reverse $ concatMap B.toList defs+ isPara (Para _) = True+ isPara _ = False+ in case defBlocks of+ (Para x:_) -> if not $ any isPara (drop 1 defBlocks)+ then let (t,ds) = last items+ lastDef = B.toList $ last ds+ ds' = init ds +++ [B.fromList $ init lastDef ++ [Plain x]]+ in init items ++ [(t, ds')]+ else items+ _ -> items++--+-- paragraph block+--++para :: MarkdownParser (F Blocks)+para = try $ do+ exts <- getOption readerExtensions+ result <- trimInlinesF . mconcat <$> many1 inline+ option (B.plain <$> result)+ $ try $ do+ newline+ (blanklines >> return mempty)+ <|> (guardDisabled Ext_blank_before_blockquote >> lookAhead blockQuote)+ <|> (guardDisabled Ext_blank_before_header >> lookAhead header)+ return $ do+ result' <- result+ case B.toList result' of+ [Image alt (src,tit)]+ | Ext_implicit_figures `Set.member` exts ->+ -- the fig: at beginning of title indicates a figure+ return $ B.para $ B.singleton+ $ Image alt (src,'f':'i':'g':':':tit)+ _ -> return $ B.para result'++plain :: MarkdownParser (F Blocks)+plain = fmap B.plain . trimInlinesF . mconcat <$> many1 inline <* spaces++--+-- raw html+--++htmlElement :: MarkdownParser String+htmlElement = strictHtmlBlock <|> liftM snd (htmlTag isBlockTag)++htmlBlock :: MarkdownParser (F Blocks)+htmlBlock = do+ guardEnabled Ext_raw_html+ res <- (guardEnabled Ext_markdown_in_html_blocks >> rawHtmlBlocks)+ <|> htmlBlock'+ return $ return $ B.rawBlock "html" res++htmlBlock' :: MarkdownParser String+htmlBlock' = try $ do+ first <- htmlElement+ finalSpace <- many spaceChar+ finalNewlines <- many newline+ return $ first ++ finalSpace ++ finalNewlines++strictHtmlBlock :: MarkdownParser String+strictHtmlBlock = htmlInBalanced (not . isInlineTag)++rawVerbatimBlock :: MarkdownParser String+rawVerbatimBlock = try $ do+ (TagOpen tag _, open) <- htmlTag (tagOpen (\t ->+ t == "pre" || t == "style" || t == "script")+ (const True))+ contents <- manyTill anyChar (htmlTag (~== TagClose tag))+ return $ open ++ contents ++ renderTags [TagClose tag]++rawTeXBlock :: MarkdownParser (F Blocks)+rawTeXBlock = do+ guardEnabled Ext_raw_tex+ result <- (B.rawBlock "latex" <$> rawLaTeXBlock)+ <|> (B.rawBlock "context" <$> rawConTeXtEnvironment)+ spaces+ return $ return result++rawHtmlBlocks :: MarkdownParser String+rawHtmlBlocks = do+ htmlBlocks <- many1 $ try $ do+ s <- rawVerbatimBlock <|> try (+ do (t,raw) <- htmlTag isBlockTag+ exts <- getOption readerExtensions+ -- if open tag, need markdown="1" if+ -- markdown_attributes extension is set+ case t of+ TagOpen _ as+ | Ext_markdown_attribute `Set.member`+ exts ->+ if "markdown" `notElem`+ map fst as+ then mzero+ else return $+ stripMarkdownAttribute raw+ | otherwise -> return raw+ _ -> return raw )+ sps <- do sp1 <- many spaceChar+ sp2 <- option "" (blankline >> return "\n")+ sp3 <- many spaceChar+ sp4 <- option "" blanklines+ return $ sp1 ++ sp2 ++ sp3 ++ sp4+ -- note: we want raw html to be able to+ -- precede a code block, when separated+ -- by a blank line+ return $ s ++ sps+ let combined = concat htmlBlocks+ return $ if last combined == '\n' then init combined else combined++-- remove markdown="1" attribute+stripMarkdownAttribute :: String -> String+stripMarkdownAttribute s = renderTags' $ map filterAttrib $ parseTags s+ where filterAttrib (TagOpen t as) = TagOpen t+ [(k,v) | (k,v) <- as, k /= "markdown"]+ filterAttrib x = x++--+-- line block+--++lineBlock :: MarkdownParser (F Blocks)+lineBlock = try $ do+ guardEnabled Ext_line_blocks+ lines' <- lineBlockLines >>=+ mapM (parseFromString (trimInlinesF . mconcat <$> many inline))+ return $ B.para <$> (mconcat $ intersperse (return B.linebreak) lines')++--+-- Tables+--++-- Parse a dashed line with optional trailing spaces; return its length+-- and the length including trailing space.+dashedLine :: Char+ -> Parser [Char] st (Int, Int)+dashedLine ch = do+ dashes <- many1 (char ch)+ sp <- many spaceChar+ return $ (length dashes, length $ dashes ++ sp)++-- Parse a table header with dashed lines of '-' preceded by+-- one (or zero) line of text.+simpleTableHeader :: Bool -- ^ Headerless table+ -> MarkdownParser (F [Blocks], [Alignment], [Int])+simpleTableHeader headless = try $ do+ rawContent <- if headless+ then return ""+ else anyLine+ initSp <- nonindentSpaces+ dashes <- many1 (dashedLine '-')+ newline+ let (lengths, lines') = unzip dashes+ let indices = scanl (+) (length initSp) lines'+ -- If no header, calculate alignment on basis of first row of text+ rawHeads <- liftM (tail . splitStringByIndices (init indices)) $+ if headless+ then lookAhead anyLine+ else return rawContent+ let aligns = zipWith alignType (map (\a -> [a]) rawHeads) lengths+ let rawHeads' = if headless+ then replicate (length dashes) ""+ else rawHeads+ heads <- fmap sequence+ $ mapM (parseFromString (mconcat <$> many plain))+ $ map trim rawHeads'+ return (heads, aligns, indices)++-- Returns an alignment type for a table, based on a list of strings+-- (the rows of the column header) and a number (the length of the+-- dashed line under the rows.+alignType :: [String]+ -> Int+ -> Alignment+alignType [] _ = AlignDefault+alignType strLst len =+ let nonempties = filter (not . null) $ map trimr strLst+ (leftSpace, rightSpace) =+ case sortBy (comparing length) nonempties of+ (x:_) -> (head x `elem` " \t", length x < len)+ [] -> (False, False)+ in case (leftSpace, rightSpace) of+ (True, False) -> AlignRight+ (False, True) -> AlignLeft+ (True, True) -> AlignCenter+ (False, False) -> AlignDefault++-- Parse a table footer - dashed lines followed by blank line.+tableFooter :: MarkdownParser String+tableFooter = try $ skipNonindentSpaces >> many1 (dashedLine '-') >> blanklines++-- Parse a table separator - dashed line.+tableSep :: MarkdownParser Char+tableSep = try $ skipNonindentSpaces >> many1 (dashedLine '-') >> char '\n'++-- Parse a raw line and split it into chunks by indices.+rawTableLine :: [Int]+ -> MarkdownParser [String]+rawTableLine indices = do+ notFollowedBy' (blanklines <|> tableFooter)+ line <- many1Till anyChar newline+ return $ map trim $ tail $+ splitStringByIndices (init indices) line++-- Parse a table line and return a list of lists of blocks (columns).+tableLine :: [Int]+ -> MarkdownParser (F [Blocks])+tableLine indices = rawTableLine indices >>=+ fmap sequence . mapM (parseFromString (mconcat <$> many plain))++-- Parse a multiline table row and return a list of blocks (columns).+multilineRow :: [Int]+ -> MarkdownParser (F [Blocks])+multilineRow indices = do+ colLines <- many1 (rawTableLine indices)+ let cols = map unlines $ transpose colLines+ fmap sequence $ mapM (parseFromString (mconcat <$> many plain)) cols++-- Parses a table caption: inlines beginning with 'Table:'+-- and followed by blank lines.+tableCaption :: MarkdownParser (F Inlines)+tableCaption = try $ do+ guardEnabled Ext_table_captions+ skipNonindentSpaces+ string ":" <|> string "Table:"+ trimInlinesF . mconcat <$> many1 inline <* blanklines++-- Parse a simple table with '---' header and one line per row.+simpleTable :: Bool -- ^ Headerless table+ -> MarkdownParser ([Alignment], [Double], F [Blocks], F [[Blocks]])+simpleTable headless = do+ (aligns, _widths, heads', lines') <-+ tableWith (simpleTableHeader headless) tableLine+ (return ())+ (if headless then tableFooter else tableFooter <|> blanklines)+ -- Simple tables get 0s for relative column widths (i.e., use default)+ return (aligns, replicate (length aligns) 0, heads', lines')++-- Parse a multiline table: starts with row of '-' on top, then header+-- (which may be multiline), then the rows,+-- which may be multiline, separated by blank lines, and+-- ending with a footer (dashed line followed by blank line).+multilineTable :: Bool -- ^ Headerless table+ -> MarkdownParser ([Alignment], [Double], F [Blocks], F [[Blocks]])+multilineTable headless =+ tableWith (multilineTableHeader headless) multilineRow blanklines tableFooter++multilineTableHeader :: Bool -- ^ Headerless table+ -> MarkdownParser (F [Blocks], [Alignment], [Int])+multilineTableHeader headless = try $ do+ if headless+ then return '\n'+ else tableSep >>~ notFollowedBy blankline+ rawContent <- if headless+ then return $ repeat ""+ else many1+ (notFollowedBy tableSep >> many1Till anyChar newline)+ initSp <- nonindentSpaces+ dashes <- many1 (dashedLine '-')+ newline+ let (lengths, lines') = unzip dashes+ let indices = scanl (+) (length initSp) lines'+ rawHeadsList <- if headless+ then liftM (map (:[]) . tail .+ splitStringByIndices (init indices)) $ lookAhead anyLine+ else return $ transpose $ map+ (\ln -> tail $ splitStringByIndices (init indices) ln)+ rawContent+ let aligns = zipWith alignType rawHeadsList lengths+ let rawHeads = if headless+ then replicate (length dashes) ""+ else map (intercalate " ") rawHeadsList+ heads <- fmap sequence $+ mapM (parseFromString (mconcat <$> many plain)) $+ map trim rawHeads+ return (heads, aligns, indices)++-- Parse a grid table: starts with row of '-' on top, then header+-- (which may be grid), then the rows,+-- which may be grid, separated by blank lines, and+-- ending with a footer (dashed line followed by blank line).+gridTable :: Bool -- ^ Headerless table+ -> MarkdownParser ([Alignment], [Double], F [Blocks], F [[Blocks]])+gridTable headless =+ tableWith (gridTableHeader headless) gridTableRow+ (gridTableSep '-') gridTableFooter++gridTableSplitLine :: [Int] -> String -> [String]+gridTableSplitLine indices line = map removeFinalBar $ tail $+ splitStringByIndices (init indices) $ trimr line++gridPart :: Char -> Parser [Char] st (Int, Int)+gridPart ch = do+ dashes <- many1 (char ch)+ char '+'+ return (length dashes, length dashes + 1)++gridDashedLines :: Char -> Parser [Char] st [(Int,Int)]+gridDashedLines ch = try $ char '+' >> many1 (gridPart ch) >>~ blankline++removeFinalBar :: String -> String+removeFinalBar =+ reverse . dropWhile (`elem` " \t") . dropWhile (=='|') . reverse++-- | Separator between rows of grid table.+gridTableSep :: Char -> MarkdownParser Char+gridTableSep ch = try $ gridDashedLines ch >> return '\n'++-- | Parse header for a grid table.+gridTableHeader :: Bool -- ^ Headerless table+ -> MarkdownParser (F [Blocks], [Alignment], [Int])+gridTableHeader headless = try $ do+ optional blanklines+ dashes <- gridDashedLines '-'+ rawContent <- if headless+ then return $ repeat ""+ else many1+ (notFollowedBy (gridTableSep '=') >> char '|' >>+ many1Till anyChar newline)+ if headless+ then return ()+ else gridTableSep '=' >> return ()+ let lines' = map snd dashes+ let indices = scanl (+) 0 lines'+ let aligns = replicate (length lines') AlignDefault+ -- RST does not have a notion of alignments+ let rawHeads = if headless+ then replicate (length dashes) ""+ else map (intercalate " ") $ transpose+ $ map (gridTableSplitLine indices) rawContent+ heads <- fmap sequence $ mapM (parseFromString block) $+ map trim rawHeads+ return (heads, aligns, indices)++gridTableRawLine :: [Int] -> MarkdownParser [String]+gridTableRawLine indices = do+ char '|'+ line <- many1Till anyChar newline+ return (gridTableSplitLine indices line)++-- | Parse row of grid table.+gridTableRow :: [Int]+ -> MarkdownParser (F [Blocks])+gridTableRow indices = do+ colLines <- many1 (gridTableRawLine indices)+ let cols = map ((++ "\n") . unlines . removeOneLeadingSpace) $+ transpose colLines+ fmap compactify' <$> fmap sequence (mapM (parseFromString block) cols)++removeOneLeadingSpace :: [String] -> [String]+removeOneLeadingSpace xs =+ if all startsWithSpace xs+ then map (drop 1) xs+ else xs+ where startsWithSpace "" = True+ startsWithSpace (y:_) = y == ' '++-- | Parse footer for a grid table.+gridTableFooter :: MarkdownParser [Char]+gridTableFooter = blanklines++pipeTable :: MarkdownParser ([Alignment], [Double], F [Blocks], F [[Blocks]])+pipeTable = try $ do+ let pipeBreak = nonindentSpaces *> optional (char '|') *>+ pipeTableHeaderPart `sepBy1` sepPipe <*+ optional (char '|') <* blankline+ (heads,aligns) <- try ( pipeBreak >>= \als ->+ return (return $ replicate (length als) mempty, als))+ <|> ( pipeTableRow >>= \row -> pipeBreak >>= \als ->++ return (row, als) )+ lines' <- sequence <$> many1 pipeTableRow+ blanklines+ let widths = replicate (length aligns) 0.0+ return $ (aligns, widths, heads, lines')++sepPipe :: MarkdownParser ()+sepPipe = try $ do+ char '|' <|> char '+'+ notFollowedBy blankline++-- parse a row, also returning probable alignments for org-table cells+pipeTableRow :: MarkdownParser (F [Blocks])+pipeTableRow = do+ nonindentSpaces+ optional (char '|')+ let cell = mconcat <$>+ many (notFollowedBy (blankline <|> char '|') >> inline)+ first <- cell+ sepPipe+ rest <- cell `sepBy1` sepPipe+ optional (char '|')+ blankline+ let cells = sequence (first:rest)+ return $ do+ cells' <- cells+ return $ map+ (\ils ->+ case trimInlines ils of+ ils' | B.isNull ils' -> mempty+ | otherwise -> B.plain $ ils') cells'++pipeTableHeaderPart :: Parser [Char] st Alignment+pipeTableHeaderPart = do+ left <- optionMaybe (char ':')+ many1 (char '-')+ right <- optionMaybe (char ':')+ return $+ case (left,right) of+ (Nothing,Nothing) -> AlignDefault+ (Just _,Nothing) -> AlignLeft+ (Nothing,Just _) -> AlignRight+ (Just _,Just _) -> AlignCenter++-- Succeed only if current line contains a pipe.+scanForPipe :: Parser [Char] st ()+scanForPipe = lookAhead (manyTill (satisfy (/='\n')) (char '|')) >> return ()++-- | Parse a table using 'headerParser', 'rowParser',+-- 'lineParser', and 'footerParser'. Variant of the version in+-- Text.Pandoc.Parsing.+tableWith :: MarkdownParser (F [Blocks], [Alignment], [Int])+ -> ([Int] -> MarkdownParser (F [Blocks]))+ -> MarkdownParser sep+ -> MarkdownParser end+ -> MarkdownParser ([Alignment], [Double], F [Blocks], F [[Blocks]])+tableWith headerParser rowParser lineParser footerParser = try $ do+ (heads, aligns, indices) <- headerParser+ lines' <- fmap sequence $ rowParser indices `sepEndBy1` lineParser+ footerParser+ numColumns <- getOption readerColumns+ let widths = if (indices == [])+ then replicate (length aligns) 0.0+ else widthsFromIndices numColumns indices+ return $ (aligns, widths, heads, lines')++table :: MarkdownParser (F Blocks)+table = try $ do+ frontCaption <- option Nothing (Just <$> tableCaption)+ (aligns, widths, heads, lns) <-+ try (guardEnabled Ext_pipe_tables >> scanForPipe >> pipeTable) <|>+ try (guardEnabled Ext_multiline_tables >>+ multilineTable False) <|>+ try (guardEnabled Ext_simple_tables >>+ (simpleTable True <|> simpleTable False)) <|>+ try (guardEnabled Ext_multiline_tables >>+ multilineTable True) <|>+ try (guardEnabled Ext_grid_tables >>+ (gridTable False <|> gridTable True)) <?> "table"+ optional blanklines+ caption <- case frontCaption of+ Nothing -> option (return mempty) tableCaption+ Just c -> return c+ return $ do+ caption' <- caption+ heads' <- heads+ lns' <- lns+ return $ B.table caption' (zip aligns widths) heads' lns'++--+-- inline+--++inline :: MarkdownParser (F Inlines)+inline = choice [ whitespace+ , bareURL+ , str+ , endline+ , code+ , fours+ , strong+ , emph+ , note+ , cite+ , link+ , image+ , math+ , strikeout+ , superscript+ , subscript+ , inlineNote -- after superscript because of ^[link](/foo)^+ , autoLink+ , rawHtmlInline+ , escapedChar+ , rawLaTeXInline'+ , exampleRef+ , smart+ , return . B.singleton <$> charRef+ , symbol+ , ltSign+ ] <?> "inline"++escapedChar' :: MarkdownParser Char+escapedChar' = try $ do+ char '\\'+ (guardEnabled Ext_all_symbols_escapable >> satisfy (not . isAlphaNum))+ <|> oneOf "\\`*_{}[]()>#+-.!~\""++escapedChar :: MarkdownParser (F Inlines)+escapedChar = do+ result <- escapedChar'+ case result of+ ' ' -> return $ return $ B.str "\160" -- "\ " is a nonbreaking space+ '\n' -> guardEnabled Ext_escaped_line_breaks >>+ return (return B.linebreak) -- "\[newline]" is a linebreak+ _ -> return $ return $ B.str [result]++ltSign :: MarkdownParser (F Inlines)+ltSign = do+ guardDisabled Ext_raw_html+ <|> guardDisabled Ext_markdown_in_html_blocks+ <|> (notFollowedBy' rawHtmlBlocks >> return ())+ char '<'+ return $ return $ B.str "<"++exampleRef :: MarkdownParser (F Inlines)+exampleRef = try $ do+ guardEnabled Ext_example_lists+ char '@'+ lab <- many1 (alphaNum <|> oneOf "-_")+ return $ do+ st <- askF+ return $ case M.lookup lab (stateExamples st) of+ Just n -> B.str (show n)+ Nothing -> B.str ('@':lab)++symbol :: MarkdownParser (F Inlines)+symbol = do+ result <- noneOf "<\\\n\t "+ <|> try (do lookAhead $ char '\\'+ notFollowedBy' (() <$ rawTeXBlock)+ char '\\')+ return $ return $ B.str [result]++-- parses inline code, between n `s and n `s+code :: MarkdownParser (F Inlines)+code = try $ do+ starts <- many1 (char '`')+ skipSpaces+ result <- many1Till (many1 (noneOf "`\n") <|> many1 (char '`') <|>+ (char '\n' >> notFollowedBy' blankline >> return " "))+ (try (skipSpaces >> count (length starts) (char '`') >>+ notFollowedBy (char '`')))+ attr <- option ([],[],[]) (try $ guardEnabled Ext_inline_code_attributes >>+ optional whitespace >> attributes)+ return $ return $ B.codeWith attr $ trim $ concat result++math :: MarkdownParser (F Inlines)+math = (return . B.displayMath <$> (mathDisplay >>= applyMacros'))+ <|> (return . B.math <$> (mathInline >>= applyMacros'))++mathDisplay :: MarkdownParser String+mathDisplay =+ (guardEnabled Ext_tex_math_dollars >> mathDisplayWith "$$" "$$")+ <|> (guardEnabled Ext_tex_math_single_backslash >>+ mathDisplayWith "\\[" "\\]")+ <|> (guardEnabled Ext_tex_math_double_backslash >>+ mathDisplayWith "\\\\[" "\\\\]")++mathDisplayWith :: String -> String -> MarkdownParser String+mathDisplayWith op cl = try $ do+ string op+ many1Till (noneOf "\n" <|> (newline >>~ notFollowedBy' blankline)) (try $ string cl)++mathInline :: MarkdownParser String+mathInline =+ (guardEnabled Ext_tex_math_dollars >> mathInlineWith "$" "$")+ <|> (guardEnabled Ext_tex_math_single_backslash >>+ mathInlineWith "\\(" "\\)")+ <|> (guardEnabled Ext_tex_math_double_backslash >>+ mathInlineWith "\\\\(" "\\\\)")++mathInlineWith :: String -> String -> MarkdownParser String+mathInlineWith op cl = try $ do+ string op+ notFollowedBy space+ words' <- many1Till (count 1 (noneOf "\n\\")+ <|> (char '\\' >> anyChar >>= \c -> return ['\\',c])+ <|> count 1 newline <* notFollowedBy' blankline+ *> return " ")+ (try $ string cl)+ notFollowedBy digit -- to prevent capture of $5+ return $ concat words'++-- to avoid performance problems, treat 4 or more _ or * or ~ or ^ in a row+-- as a literal rather than attempting to parse for emph/strong/strikeout/super/sub+fours :: Parser [Char] st (F Inlines)+fours = try $ do+ x <- char '*' <|> char '_' <|> char '~' <|> char '^'+ count 2 $ satisfy (==x)+ rest <- many1 (satisfy (==x))+ return $ return $ B.str (x:x:x:rest)++-- | Parses a list of inlines between start and end delimiters.+inlinesBetween :: (Show b)+ => MarkdownParser a+ -> MarkdownParser b+ -> MarkdownParser (F Inlines)+inlinesBetween start end =+ (trimInlinesF . mconcat) <$> try (start >> many1Till inner end)+ where inner = innerSpace <|> (notFollowedBy' (() <$ whitespace) >> inline)+ innerSpace = try $ whitespace >>~ notFollowedBy' end++emph :: MarkdownParser (F Inlines)+emph = fmap B.emph <$> nested+ (inlinesBetween starStart starEnd <|> inlinesBetween ulStart ulEnd)+ where starStart = char '*' >> lookAhead nonspaceChar+ starEnd = notFollowedBy' (() <$ strong) >> char '*'+ ulStart = char '_' >> lookAhead nonspaceChar+ ulEnd = notFollowedBy' (() <$ strong) >> char '_'++strong :: MarkdownParser (F Inlines)+strong = fmap B.strong <$> nested+ (inlinesBetween starStart starEnd <|> inlinesBetween ulStart ulEnd)+ where starStart = string "**" >> lookAhead nonspaceChar+ starEnd = try $ string "**"+ ulStart = string "__" >> lookAhead nonspaceChar+ ulEnd = try $ string "__"++strikeout :: MarkdownParser (F Inlines)+strikeout = fmap B.strikeout <$>+ (guardEnabled Ext_strikeout >> inlinesBetween strikeStart strikeEnd)+ where strikeStart = string "~~" >> lookAhead nonspaceChar+ >> notFollowedBy (char '~')+ strikeEnd = try $ string "~~"++superscript :: MarkdownParser (F Inlines)+superscript = fmap B.superscript <$> try (do+ guardEnabled Ext_superscript+ char '^'+ mconcat <$> many1Till (notFollowedBy spaceChar >> inline) (char '^'))++subscript :: MarkdownParser (F Inlines)+subscript = fmap B.subscript <$> try (do+ guardEnabled Ext_subscript+ char '~'+ mconcat <$> many1Till (notFollowedBy spaceChar >> inline) (char '~'))++whitespace :: MarkdownParser (F Inlines)+whitespace = spaceChar >> return <$> (lb <|> regsp) <?> "whitespace"+ where lb = spaceChar >> skipMany spaceChar >> option B.space (endline >> return B.linebreak)+ regsp = skipMany spaceChar >> return B.space++nonEndline :: Parser [Char] st Char+nonEndline = satisfy (/='\n')++str :: MarkdownParser (F Inlines)+str = do+ isSmart <- readerSmart . stateOptions <$> getState+ a <- alphaNum+ as <- many $ alphaNum+ <|> (guardEnabled Ext_intraword_underscores >>+ try (char '_' >>~ lookAhead alphaNum))+ <|> if isSmart+ then (try $ satisfy (\c -> c == '\'' || c == '\x2019') >>+ lookAhead alphaNum >> return '\x2019')+ -- for things like l'aide+ else mzero+ pos <- getPosition+ updateState $ \s -> s{ stateLastStrPos = Just pos }+ let result = a:as+ let spacesToNbr = map (\c -> if c == ' ' then '\160' else c)+ if isSmart+ then case likelyAbbrev result of+ [] -> return $ return $ B.str result+ xs -> choice (map (\x ->+ try (string x >> oneOf " \n" >>+ lookAhead alphaNum >>+ return (return $ B.str+ $ result ++ spacesToNbr x ++ "\160"))) xs)+ <|> (return $ return $ B.str result)+ else return $ return $ B.str result++-- | if the string matches the beginning of an abbreviation (before+-- the first period, return strings that would finish the abbreviation.+likelyAbbrev :: String -> [String]+likelyAbbrev x =+ let abbrevs = [ "Mr.", "Mrs.", "Ms.", "Capt.", "Dr.", "Prof.",+ "Gen.", "Gov.", "e.g.", "i.e.", "Sgt.", "St.",+ "vol.", "vs.", "Sen.", "Rep.", "Pres.", "Hon.",+ "Rev.", "Ph.D.", "M.D.", "M.A.", "p.", "pp.",+ "ch.", "sec.", "cf.", "cp."]+ abbrPairs = map (break (=='.')) abbrevs+ in map snd $ filter (\(y,_) -> y == x) abbrPairs++-- an endline character that can be treated as a space, not a structural break+endline :: MarkdownParser (F Inlines)+endline = try $ do+ newline+ notFollowedBy blankline+ guardEnabled Ext_blank_before_blockquote <|> notFollowedBy emailBlockQuoteStart+ guardEnabled Ext_blank_before_header <|> notFollowedBy (char '#') -- atx header+ -- parse potential list-starts differently if in a list:+ st <- getState+ when (stateParserContext st == ListItemState) $ do+ notFollowedBy' bulletListStart+ notFollowedBy' anyOrderedListStart+ (guardEnabled Ext_hard_line_breaks >> return (return B.linebreak))+ <|> (return $ return B.space)++--+-- links+--++-- a reference label for a link+reference :: MarkdownParser (F Inlines, String)+reference = do notFollowedBy' (string "[^") -- footnote reference+ withRaw $ trimInlinesF <$> inlinesInBalancedBrackets++-- source for a link, with optional title+source :: MarkdownParser (String, String)+source = do+ char '('+ skipSpaces+ let urlChunk = try $ notFollowedBy (oneOf "\"')") >>+ (charsInBalanced '(' ')' litChar <|> count 1 litChar)+ let sourceURL = (unwords . words . concat) <$> many urlChunk+ let betweenAngles = try $+ char '<' >> manyTill litChar (char '>')+ src <- try betweenAngles <|> sourceURL+ tit <- option "" $ try $ spnl >> linkTitle+ skipSpaces+ char ')'+ return (escapeURI $ trimr src, tit)++linkTitle :: MarkdownParser String+linkTitle = fromEntities <$> (quotedTitle '"' <|> quotedTitle '\'')++link :: MarkdownParser (F Inlines)+link = try $ do+ st <- getState+ guard $ stateAllowLinks st+ setState $ st{ stateAllowLinks = False }+ (lab,raw) <- reference+ setState $ st{ stateAllowLinks = True }+ regLink B.link lab <|> referenceLink B.link (lab,raw)++regLink :: (String -> String -> Inlines -> Inlines)+ -> F Inlines -> MarkdownParser (F Inlines)+regLink constructor lab = try $ do+ (src, tit) <- source+ return $ constructor src tit <$> lab++-- a link like [this][ref] or [this][] or [this]+referenceLink :: (String -> String -> Inlines -> Inlines)+ -> (F Inlines, String) -> MarkdownParser (F Inlines)+referenceLink constructor (lab, raw) = do+ (ref,raw') <- try (optional (char ' ') >>+ optional (newline >> skipSpaces) >>+ reference) <|> return (mempty, "")+ let labIsRef = raw' == "" || raw' == "[]"+ let key = toKey $ if labIsRef then raw else raw'+ let dropRB (']':xs) = xs+ dropRB xs = xs+ let dropLB ('[':xs) = xs+ dropLB xs = xs+ let dropBrackets = reverse . dropRB . reverse . dropLB+ fallback <- parseFromString (mconcat <$> many inline) $ dropBrackets raw+ implicitHeaderRefs <- option False $+ True <$ guardEnabled Ext_implicit_header_references+ return $ do+ keys <- asksF stateKeys+ case M.lookup key keys of+ Nothing -> do+ headers <- asksF stateHeaders+ let ref' = B.toList $ runF (if labIsRef then lab else ref)+ defaultParserState+ if implicitHeaderRefs && ref' `elem` headers+ then do+ let src = '#' : uniqueIdent ref' []+ constructor src "" <$> lab+ else (\x -> B.str "[" <> x <> B.str "]" <> B.str raw') <$> fallback+ Just (src,tit) -> constructor src tit <$> lab++bareURL :: MarkdownParser (F Inlines)+bareURL = try $ do+ guardEnabled Ext_autolink_bare_uris+ (orig, src) <- uri <|> emailAddress+ return $ return $ B.link src "" (B.str orig)++autoLink :: MarkdownParser (F Inlines)+autoLink = try $ do+ char '<'+ (orig, src) <- uri <|> emailAddress+ char '>'+ return $ return $ B.link src "" (B.str orig)++image :: MarkdownParser (F Inlines)+image = try $ do+ char '!'+ (lab,raw) <- reference+ regLink B.image lab <|> referenceLink B.image (lab,raw)++note :: MarkdownParser (F Inlines)+note = try $ do+ guardEnabled Ext_footnotes+ ref <- noteMarker+ return $ do+ notes <- asksF stateNotes'+ case lookup ref notes of+ Nothing -> return $ B.str $ "[^" ++ ref ++ "]"+ Just contents -> do+ st <- askF+ -- process the note in a context that doesn't resolve+ -- notes, to avoid infinite looping with notes inside+ -- notes:+ let contents' = runF contents st{ stateNotes' = [] }+ return $ B.note contents'++inlineNote :: MarkdownParser (F Inlines)+inlineNote = try $ do+ guardEnabled Ext_inline_notes+ char '^'+ contents <- inlinesInBalancedBrackets+ return $ B.note . B.para <$> contents++rawLaTeXInline' :: MarkdownParser (F Inlines)+rawLaTeXInline' = try $ do+ guardEnabled Ext_raw_tex+ lookAhead $ char '\\' >> notFollowedBy' (string "start") -- context env+ RawInline _ s <- rawLaTeXInline+ return $ return $ B.rawInline "tex" s+ -- "tex" because it might be context or latex++rawConTeXtEnvironment :: Parser [Char] st String+rawConTeXtEnvironment = try $ do+ string "\\start"+ completion <- inBrackets (letter <|> digit <|> spaceChar)+ <|> (many1 letter)+ contents <- manyTill (rawConTeXtEnvironment <|> (count 1 anyChar))+ (try $ string "\\stop" >> string completion)+ return $ "\\start" ++ completion ++ concat contents ++ "\\stop" ++ completion++inBrackets :: (Parser [Char] st Char) -> Parser [Char] st String+inBrackets parser = do+ char '['+ contents <- many parser+ char ']'+ return $ "[" ++ contents ++ "]"++rawHtmlInline :: MarkdownParser (F Inlines)+rawHtmlInline = do+ guardEnabled Ext_raw_html+ mdInHtml <- option False $+ guardEnabled Ext_markdown_in_html_blocks >> return True+ (_,result) <- if mdInHtml+ then htmlTag isInlineTag+ else htmlTag (not . isTextTag)+ return $ return $ B.rawInline "html" result++-- Citations++cite :: MarkdownParser (F Inlines)+cite = do+ guardEnabled Ext_citations+ getOption readerReferences >>= guard . not . null+ citations <- textualCite <|> normalCite+ return $ flip B.cite mempty <$> citations++textualCite :: MarkdownParser (F [Citation])+textualCite = try $ do+ (_, key) <- citeKey+ let first = Citation{ citationId = key+ , citationPrefix = []+ , citationSuffix = []+ , citationMode = AuthorInText+ , citationNoteNum = 0+ , citationHash = 0+ }+ mbrest <- option Nothing $ try $ spnl >> Just <$> normalCite+ case mbrest of+ Just rest -> return $ (first:) <$> rest+ Nothing -> option (return [first]) $ bareloc first++bareloc :: Citation -> MarkdownParser (F [Citation])+bareloc c = try $ do+ spnl+ char '['+ suff <- suffix+ rest <- option (return []) $ try $ char ';' >> citeList+ spnl+ char ']'+ return $ do+ suff' <- suff+ rest' <- rest+ return $ c{ citationSuffix = B.toList suff' } : rest'++normalCite :: MarkdownParser (F [Citation])+normalCite = try $ do+ char '['+ spnl+ citations <- citeList+ spnl+ char ']'+ return citations++citeKey :: MarkdownParser (Bool, String)+citeKey = try $ do+ suppress_author <- option False (char '-' >> return True)+ char '@'+ first <- letter+ let internal p = try $ p >>~ lookAhead (letter <|> digit)+ rest <- many $ letter <|> digit <|> internal (oneOf ":.#$%&-_?<>~/")+ let key = first:rest+ citations' <- map CSL.refId <$> getOption readerReferences+ guard $ key `elem` citations'+ return (suppress_author, key)++suffix :: MarkdownParser (F Inlines)+suffix = try $ do+ hasSpace <- option False (notFollowedBy nonspaceChar >> return True)+ spnl+ rest <- trimInlinesF . mconcat <$> many (notFollowedBy (oneOf ";]") >> inline)+ return $ if hasSpace+ then (B.space <>) <$> rest+ else rest++prefix :: MarkdownParser (F Inlines)+prefix = trimInlinesF . mconcat <$>+ manyTill inline (char ']' <|> liftM (const ']') (lookAhead citeKey))++citeList :: MarkdownParser (F [Citation])+citeList = fmap sequence $ sepBy1 citation (try $ char ';' >> spnl)++citation :: MarkdownParser (F Citation)+citation = try $ do+ pref <- prefix+ (suppress_author, key) <- citeKey+ suff <- suffix+ return $ do+ x <- pref+ y <- suff+ return $ Citation{ citationId = key+ , citationPrefix = B.toList x+ , citationSuffix = B.toList y+ , citationMode = if suppress_author+ then SuppressAuthor+ else NormalCitation+ , citationNoteNum = 0+ , citationHash = 0+ }++smart :: MarkdownParser (F Inlines)+smart = do+ getOption readerSmart >>= guard+ doubleQuoted <|> singleQuoted <|>+ choice (map (return . B.singleton <$>) [apostrophe, dash, ellipses])++singleQuoted :: MarkdownParser (F Inlines)+singleQuoted = try $ do+ singleQuoteStart+ withQuoteContext InSingleQuote $+ fmap B.singleQuoted . trimInlinesF . mconcat <$>+ many1Till inline singleQuoteEnd++doubleQuoted :: MarkdownParser (F Inlines)+doubleQuoted = try $ do+ doubleQuoteStart+ withQuoteContext InDoubleQuote $+ fmap B.doubleQuoted . trimInlinesF . mconcat <$>+ many1Till inline doubleQuoteEnd
@@ -0,0 +1,593 @@+{-# LANGUAGE RelaxedPolyRec #-} -- needed for inlinesBetween on GHC < 7+{-+ Copyright (C) 2012 John MacFarlane <jgm@berkeley.edu>++This program is free software; you can redistribute it and/or modify+it under the terms of the GNU General Public License as published by+the Free Software Foundation; either version 2 of the License, or+(at your option) any later version.++This program is distributed in the hope that it will be useful,+but WITHOUT ANY WARRANTY; without even the implied warranty of+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+GNU General Public License for more details.++You should have received a copy of the GNU General Public License+along with this program; if not, write to the Free Software+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA+-}++{- |+ Module : Text.Pandoc.Readers.MediaWiki+ Copyright : Copyright (C) 2012 John MacFarlane+ License : GNU GPL, version 2 or above++ Maintainer : John MacFarlane <jgm@berkeley.edu>+ Stability : alpha+ Portability : portable++Conversion of mediawiki text to 'Pandoc' document.+-}+{-+TODO:+_ correctly handle tables within tables+_ parse templates?+-}+module Text.Pandoc.Readers.MediaWiki ( readMediaWiki ) where++import Text.Pandoc.Definition+import qualified Text.Pandoc.Builder as B+import Text.Pandoc.Builder (Inlines, Blocks, trimInlines, (<>))+import Text.Pandoc.Options+import Text.Pandoc.Readers.HTML ( htmlTag, isBlockTag, isCommentTag )+import Text.Pandoc.XML ( fromEntities )+import Text.Pandoc.Parsing hiding ( nested )+import Text.Pandoc.Generic ( bottomUp )+import Text.Pandoc.Shared ( stripTrailingNewlines, safeRead )+import Data.Monoid (mconcat, mempty)+import Control.Applicative ((<$>), (<*), (*>), (<$))+import Control.Monad+import Data.List (intersperse, intercalate, isPrefixOf )+import Text.HTML.TagSoup+import Data.Sequence (viewl, ViewL(..), (<|))+import Data.Char (isDigit)++-- | Read mediawiki from an input string and return a Pandoc document.+readMediaWiki :: ReaderOptions -- ^ Reader options+ -> String -- ^ String to parse (assuming @'\n'@ line endings)+ -> Pandoc+readMediaWiki opts s =+ case runParser parseMediaWiki MWState{ mwOptions = opts+ , mwMaxNestingLevel = 4+ , mwNextLinkNumber = 1+ , mwCategoryLinks = []+ }+ "source" (s ++ "\n") of+ Left err' -> error $ "\nError:\n" ++ show err'+ Right result -> result++data MWState = MWState { mwOptions :: ReaderOptions+ , mwMaxNestingLevel :: Int+ , mwNextLinkNumber :: Int+ , mwCategoryLinks :: [Inlines]+ }++type MWParser = Parser [Char] MWState++--+-- auxiliary functions+--++-- This is used to prevent exponential blowups for things like:+-- ''a'''a''a'''a''a'''a''a'''a+nested :: MWParser a -> MWParser a+nested p = do+ nestlevel <- mwMaxNestingLevel `fmap` getState+ guard $ nestlevel > 0+ updateState $ \st -> st{ mwMaxNestingLevel = mwMaxNestingLevel st - 1 }+ res <- p+ updateState $ \st -> st{ mwMaxNestingLevel = nestlevel }+ return res++specialChars :: [Char]+specialChars = "'[]<=&*{}|\""++spaceChars :: [Char]+spaceChars = " \n\t"++sym :: String -> MWParser ()+sym s = () <$ try (string s)++newBlockTags :: [String]+newBlockTags = ["haskell","syntaxhighlight","source","gallery","references"]++isBlockTag' :: Tag String -> Bool+isBlockTag' tag@(TagOpen t _) = (isBlockTag tag || t `elem` newBlockTags) &&+ t `notElem` eitherBlockOrInline+isBlockTag' tag@(TagClose t) = (isBlockTag tag || t `elem` newBlockTags) &&+ t `notElem` eitherBlockOrInline+isBlockTag' tag = isBlockTag tag++isInlineTag' :: Tag String -> Bool+isInlineTag' (TagComment _) = True+isInlineTag' t = not (isBlockTag' t)++eitherBlockOrInline :: [String]+eitherBlockOrInline = ["applet", "button", "del", "iframe", "ins",+ "map", "area", "object"]++htmlComment :: MWParser ()+htmlComment = () <$ htmlTag isCommentTag++inlinesInTags :: String -> MWParser Inlines+inlinesInTags tag = try $ do+ (_,raw) <- htmlTag (~== TagOpen tag [])+ if '/' `elem` raw -- self-closing tag+ then return mempty+ else trimInlines . mconcat <$>+ manyTill inline (htmlTag (~== TagClose tag))++blocksInTags :: String -> MWParser Blocks+blocksInTags tag = try $ do+ (_,raw) <- htmlTag (~== TagOpen tag [])+ if '/' `elem` raw -- self-closing tag+ then return mempty+ else mconcat <$> manyTill block (htmlTag (~== TagClose tag))++charsInTags :: String -> MWParser [Char]+charsInTags tag = try $ do+ (_,raw) <- htmlTag (~== TagOpen tag [])+ if '/' `elem` raw -- self-closing tag+ then return ""+ else manyTill anyChar (htmlTag (~== TagClose tag))++--+-- main parser+--++parseMediaWiki :: MWParser Pandoc+parseMediaWiki = do+ bs <- mconcat <$> many block+ spaces+ eof+ categoryLinks <- reverse . mwCategoryLinks <$> getState+ let categories = if null categoryLinks+ then mempty+ else B.para $ mconcat $ intersperse B.space categoryLinks+ return $ B.doc $ bs <> categories++--+-- block parsers+--++block :: MWParser Blocks+block = mempty <$ skipMany1 blankline+ <|> table+ <|> header+ <|> hrule+ <|> orderedList+ <|> bulletList+ <|> definitionList+ <|> mempty <$ try (spaces *> htmlComment)+ <|> preformatted+ <|> blockTag+ <|> (B.rawBlock "mediawiki" <$> template)+ <|> para++para :: MWParser Blocks+para = B.para . trimInlines . mconcat <$> many1 inline++table :: MWParser Blocks+table = do+ tableStart+ styles <- manyTill anyChar newline+ let tableWidth = case lookup "width" $ parseAttrs styles of+ Just w -> maybe 1.0 id $ parseWidth w+ Nothing -> 1.0+ caption <- option mempty tableCaption+ optional rowsep+ hasheader <- option False $ True <$ (lookAhead (char '!'))+ (cellspecs',hdr) <- unzip <$> tableRow+ let widths = map ((tableWidth *) . snd) cellspecs'+ let restwidth = tableWidth - sum widths+ let zerocols = length $ filter (==0.0) widths+ let defaultwidth = if zerocols == 0 || zerocols == length widths+ then 0.0+ else restwidth / fromIntegral zerocols+ let widths' = map (\w -> if w == 0 then defaultwidth else w) widths+ let cellspecs = zip (map fst cellspecs') widths'+ rows' <- many $ try $ rowsep *> (map snd <$> tableRow)+ tableEnd+ let cols = length hdr+ let (headers,rows) = if hasheader+ then (hdr, rows')+ else (replicate cols mempty, hdr:rows')+ return $ B.table caption cellspecs headers rows++parseAttrs :: String -> [(String,String)]+parseAttrs s = case parse (many parseAttr) "attributes" s of+ Right r -> r+ Left _ -> []++parseAttr :: Parser String () (String, String)+parseAttr = try $ do+ skipMany spaceChar+ k <- many1 letter+ char '='+ char '"'+ v <- many1Till anyChar (char '"')+ return (k,v)++tableStart :: MWParser ()+tableStart = try $ guardColumnOne *> sym "{|"++tableEnd :: MWParser ()+tableEnd = try $ guardColumnOne *> sym "|}" <* blanklines++rowsep :: MWParser ()+rowsep = try $ guardColumnOne *> sym "|-" <* blanklines++cellsep :: MWParser ()+cellsep = try $+ (guardColumnOne <*+ ( (char '|' <* notFollowedBy (oneOf "-}+"))+ <|> (char '!')+ )+ )+ <|> (() <$ try (string "||"))+ <|> (() <$ try (string "!!"))++tableCaption :: MWParser Inlines+tableCaption = try $ do+ guardColumnOne+ sym "|+"+ skipMany spaceChar+ res <- manyTill anyChar newline >>= parseFromString (many inline)+ return $ trimInlines $ mconcat res++tableRow :: MWParser [((Alignment, Double), Blocks)]+tableRow = try $ many tableCell++tableCell :: MWParser ((Alignment, Double), Blocks)+tableCell = try $ do+ cellsep+ skipMany spaceChar+ attrs <- option [] $ try $ parseAttrs <$>+ manyTill (satisfy (/='\n')) (char '|' <* notFollowedBy (char '|'))+ skipMany spaceChar+ ls <- concat <$> many (notFollowedBy (cellsep <|> rowsep <|> tableEnd) *>+ ((snd <$> withRaw table) <|> count 1 anyChar))+ bs <- parseFromString (mconcat <$> many block) ls+ let align = case lookup "align" attrs of+ Just "left" -> AlignLeft+ Just "right" -> AlignRight+ Just "center" -> AlignCenter+ _ -> AlignDefault+ let width = case lookup "width" attrs of+ Just xs -> maybe 0.0 id $ parseWidth xs+ Nothing -> 0.0+ return ((align, width), bs)++parseWidth :: String -> Maybe Double+parseWidth s =+ case reverse s of+ ('%':ds) | all isDigit ds -> safeRead ('0':'.':reverse ds)+ _ -> Nothing++template :: MWParser String+template = try $ do+ string "{{"+ notFollowedBy (char '{')+ let chunk = template <|> variable <|> many1 (noneOf "{}") <|> count 1 anyChar+ contents <- manyTill chunk (try $ string "}}")+ return $ "{{" ++ concat contents ++ "}}"++blockTag :: MWParser Blocks+blockTag = do+ (tag, _) <- lookAhead $ htmlTag isBlockTag'+ case tag of+ TagOpen "blockquote" _ -> B.blockQuote <$> blocksInTags "blockquote"+ TagOpen "pre" _ -> B.codeBlock . trimCode <$> charsInTags "pre"+ TagOpen "syntaxhighlight" attrs -> syntaxhighlight "syntaxhighlight" attrs+ TagOpen "source" attrs -> syntaxhighlight "source" attrs+ TagOpen "haskell" _ -> B.codeBlockWith ("",["haskell"],[]) . trimCode <$>+ charsInTags "haskell"+ TagOpen "gallery" _ -> blocksInTags "gallery"+ TagOpen "p" _ -> mempty <$ htmlTag (~== tag)+ TagClose "p" -> mempty <$ htmlTag (~== tag)+ _ -> B.rawBlock "html" . snd <$> htmlTag (~== tag)++trimCode :: String -> String+trimCode ('\n':xs) = stripTrailingNewlines xs+trimCode xs = stripTrailingNewlines xs++syntaxhighlight :: String -> [Attribute String] -> MWParser Blocks+syntaxhighlight tag attrs = try $ do+ let mblang = lookup "lang" attrs+ let mbstart = lookup "start" attrs+ let mbline = lookup "line" attrs+ let classes = maybe [] (:[]) mblang ++ maybe [] (const ["numberLines"]) mbline+ let kvs = maybe [] (\x -> [("startFrom",x)]) mbstart+ contents <- charsInTags tag+ return $ B.codeBlockWith ("",classes,kvs) $ trimCode contents++hrule :: MWParser Blocks+hrule = B.horizontalRule <$ try (string "----" *> many (char '-') *> newline)++guardColumnOne :: MWParser ()+guardColumnOne = getPosition >>= \pos -> guard (sourceColumn pos == 1)++preformatted :: MWParser Blocks+preformatted = try $ do+ guardColumnOne+ char ' '+ let endline' = B.linebreak <$ (try $ newline <* char ' ')+ let whitespace' = B.str <$> many1 ('\160' <$ spaceChar)+ let spToNbsp ' ' = '\160'+ spToNbsp x = x+ let nowiki' = mconcat . intersperse B.linebreak . map B.str .+ lines . fromEntities . map spToNbsp <$> try+ (htmlTag (~== TagOpen "nowiki" []) *>+ manyTill anyChar (htmlTag (~== TagClose "nowiki")))+ let inline' = whitespace' <|> endline' <|> nowiki' <|> inline+ let strToCode (Str s) = Code ("",[],[]) s+ strToCode x = x+ B.para . bottomUp strToCode . mconcat <$> many1 inline'++header :: MWParser Blocks+header = try $ do+ guardColumnOne+ eqs <- many1 (char '=')+ let lev = length eqs+ guard $ lev <= 6+ contents <- trimInlines . mconcat <$> manyTill inline (count lev $ char '=')+ return $ B.header lev contents++bulletList :: MWParser Blocks+bulletList = B.bulletList <$>+ ( many1 (listItem '*')+ <|> (htmlTag (~== TagOpen "ul" []) *> spaces *> many (listItem '*' <|> li) <*+ optional (htmlTag (~== TagClose "ul"))) )++orderedList :: MWParser Blocks+orderedList =+ (B.orderedList <$> many1 (listItem '#'))+ <|> (B.orderedList <$> (htmlTag (~== TagOpen "ul" []) *> spaces *>+ many (listItem '#' <|> li) <*+ optional (htmlTag (~== TagClose "ul"))))+ <|> do (tag,_) <- htmlTag (~== TagOpen "ol" [])+ spaces+ items <- many (listItem '#' <|> li)+ optional (htmlTag (~== TagClose "ol"))+ let start = maybe 1 id $ safeRead $ fromAttrib "start" tag+ return $ B.orderedListWith (start, DefaultStyle, DefaultDelim) items++definitionList :: MWParser Blocks+definitionList = B.definitionList <$> many1 defListItem++defListItem :: MWParser (Inlines, [Blocks])+defListItem = try $ do+ terms <- mconcat . intersperse B.linebreak <$> many defListTerm+ -- we allow dd with no dt, or dt with no dd+ defs <- if B.isNull terms+ then many1 $ listItem ':'+ else many $ listItem ':'+ return (terms, defs)++defListTerm :: MWParser Inlines+defListTerm = char ';' >> skipMany spaceChar >> manyTill anyChar newline >>=+ parseFromString (trimInlines . mconcat <$> many inline)++listStart :: Char -> MWParser ()+listStart c = char c *> notFollowedBy listStartChar++listStartChar :: MWParser Char+listStartChar = oneOf "*#;:"++anyListStart :: MWParser Char+anyListStart = char '*'+ <|> char '#'+ <|> char ':'+ <|> char ';'++li :: MWParser Blocks+li = lookAhead (htmlTag (~== TagOpen "li" [])) *>+ (firstParaToPlain <$> blocksInTags "li") <* spaces++listItem :: Char -> MWParser Blocks+listItem c = try $ do+ extras <- many (try $ char c <* lookAhead listStartChar)+ if null extras+ then listItem' c+ else do+ skipMany spaceChar+ first <- concat <$> manyTill listChunk newline+ rest <- many+ (try $ string extras *> (concat <$> manyTill listChunk newline))+ contents <- parseFromString (many1 $ listItem' c)+ (unlines (first : rest))+ case c of+ '*' -> return $ B.bulletList contents+ '#' -> return $ B.orderedList contents+ ':' -> return $ B.definitionList [(mempty, contents)]+ _ -> mzero++-- The point of this is to handle stuff like+-- * {{cite book+-- | blah+-- | blah+-- }}+-- * next list item+-- which seems to be valid mediawiki.+listChunk :: MWParser String+listChunk = template <|> count 1 anyChar++listItem' :: Char -> MWParser Blocks+listItem' c = try $ do+ listStart c+ skipMany spaceChar+ first <- concat <$> manyTill listChunk newline+ rest <- many (try $ char c *> lookAhead listStartChar *>+ (concat <$> manyTill listChunk newline))+ parseFromString (firstParaToPlain . mconcat <$> many1 block)+ $ unlines $ first : rest++firstParaToPlain :: Blocks -> Blocks+firstParaToPlain contents =+ case viewl (B.unMany contents) of+ (Para xs) :< ys -> B.Many $ (Plain xs) <| ys+ _ -> contents++--+-- inline parsers+--++inline :: MWParser Inlines+inline = whitespace+ <|> url+ <|> str+ <|> doubleQuotes+ <|> strong+ <|> emph+ <|> image+ <|> internalLink+ <|> externalLink+ <|> inlineTag+ <|> B.singleton <$> charRef+ <|> inlineHtml+ <|> (B.rawInline "mediawiki" <$> variable)+ <|> (B.rawInline "mediawiki" <$> template)+ <|> special++str :: MWParser Inlines+str = B.str <$> many1 (noneOf $ specialChars ++ spaceChars)++variable :: MWParser String+variable = try $ do+ string "{{{"+ contents <- manyTill anyChar (try $ string "}}}")+ return $ "{{{" ++ contents ++ "}}}"++inlineTag :: MWParser Inlines+inlineTag = do+ (tag, _) <- lookAhead $ htmlTag isInlineTag'+ case tag of+ TagOpen "ref" _ -> B.note . B.plain <$> inlinesInTags "ref"+ TagOpen "nowiki" _ -> try $ do+ (_,raw) <- htmlTag (~== tag)+ if '/' `elem` raw+ then return mempty+ else B.text . fromEntities <$>+ manyTill anyChar (htmlTag (~== TagClose "nowiki"))+ TagOpen "br" _ -> B.linebreak <$ (htmlTag (~== TagOpen "br" []) -- will get /> too+ *> optional blankline)+ TagOpen "strike" _ -> B.strikeout <$> inlinesInTags "strike"+ TagOpen "del" _ -> B.strikeout <$> inlinesInTags "del"+ TagOpen "sub" _ -> B.subscript <$> inlinesInTags "sub"+ TagOpen "sup" _ -> B.superscript <$> inlinesInTags "sup"+ TagOpen "math" _ -> B.math <$> charsInTags "math"+ TagOpen "code" _ -> B.code <$> charsInTags "code"+ TagOpen "tt" _ -> B.code <$> charsInTags "tt"+ TagOpen "hask" _ -> B.codeWith ("",["haskell"],[]) <$> charsInTags "hask"+ _ -> B.rawInline "html" . snd <$> htmlTag (~== tag)++special :: MWParser Inlines+special = B.str <$> count 1 (notFollowedBy' (htmlTag isBlockTag') *>+ oneOf specialChars)++inlineHtml :: MWParser Inlines+inlineHtml = B.rawInline "html" . snd <$> htmlTag isInlineTag'++whitespace :: MWParser Inlines+whitespace = B.space <$ (skipMany1 spaceChar <|> endline <|> htmlComment)++endline :: MWParser ()+endline = () <$ try (newline <*+ notFollowedBy blankline <*+ notFollowedBy' hrule <*+ notFollowedBy tableStart <*+ notFollowedBy' header <*+ notFollowedBy anyListStart)++image :: MWParser Inlines+image = try $ do+ sym "[["+ sym "File:"+ fname <- many1 (noneOf "|]")+ _ <- many (try $ char '|' *> imageOption)+ caption <- (B.str fname <$ sym "]]")+ <|> try (char '|' *> (mconcat <$> manyTill inline (sym "]]")))+ return $ B.image fname "image" caption++imageOption :: MWParser String+imageOption =+ try (oneOfStrings [ "border", "thumbnail", "frameless"+ , "thumb", "upright", "left", "right"+ , "center", "none", "baseline", "sub"+ , "super", "top", "text-top", "middle"+ , "bottom", "text-bottom" ])+ <|> try (string "frame")+ <|> try (many1 (oneOf "x0123456789") <* string "px")+ <|> try (oneOfStrings ["link=","alt=","page=","class="] <* many (noneOf "|]"))++internalLink :: MWParser Inlines+internalLink = try $ do+ sym "[["+ let addUnderscores x = let (pref,suff) = break (=='#') x+ in pref ++ intercalate "_" (words suff)+ pagename <- unwords . words <$> many (noneOf "|]")+ label <- option (B.text pagename) $ char '|' *>+ ( (mconcat <$> many1 (notFollowedBy (char ']') *> inline))+ -- the "pipe trick"+ -- [[Help:Contents|] -> "Contents"+ <|> (return $ B.text $ drop 1 $ dropWhile (/=':') pagename) )+ sym "]]"+ linktrail <- B.text <$> many letter+ let link = B.link (addUnderscores pagename) "wikilink" (label <> linktrail)+ if "Category:" `isPrefixOf` pagename+ then do+ updateState $ \st -> st{ mwCategoryLinks = link : mwCategoryLinks st }+ return mempty+ else return link++externalLink :: MWParser Inlines+externalLink = try $ do+ char '['+ (_, src) <- uri+ lab <- try (trimInlines . mconcat <$>+ (skipMany1 spaceChar *> manyTill inline (char ']')))+ <|> do char ']'+ num <- mwNextLinkNumber <$> getState+ updateState $ \st -> st{ mwNextLinkNumber = num + 1 }+ return $ B.str $ show num+ return $ B.link src "" lab++url :: MWParser Inlines+url = do+ (orig, src) <- uri+ return $ B.link src "" (B.str orig)++-- | Parses a list of inlines between start and end delimiters.+inlinesBetween :: (Show b) => MWParser a -> MWParser b -> MWParser Inlines+inlinesBetween start end =+ (trimInlines . mconcat) <$> try (start >> many1Till inner end)+ where inner = innerSpace <|> (notFollowedBy' (() <$ whitespace) >> inline)+ innerSpace = try $ whitespace >>~ notFollowedBy' end++emph :: MWParser Inlines+emph = B.emph <$> nested (inlinesBetween start end)+ where start = sym "''" >> lookAhead nonspaceChar+ end = try $ notFollowedBy' (() <$ strong) >> sym "''"++strong :: MWParser Inlines+strong = B.strong <$> nested (inlinesBetween start end)+ where start = sym "'''" >> lookAhead nonspaceChar+ end = try $ sym "'''"++doubleQuotes :: MWParser Inlines+doubleQuotes = B.doubleQuoted . trimInlines . mconcat <$> try+ ((getState >>= guard . readerSmart . mwOptions) *>+ openDoubleQuote *> manyTill inline closeDoubleQuote )+ where openDoubleQuote = char '"' <* lookAhead alphaNum+ closeDoubleQuote = char '"' <* notFollowedBy alphaNum+
@@ -19,7 +19,7 @@ {- | Module : Text.Pandoc.Readers.Native Copyright : Copyright (C) 2011 John MacFarlane- License : GNU GPL, version 2 or above + License : GNU GPL, version 2 or above Maintainer : John MacFarlane <jgm@berkeley.edu> Stability : alpha@@ -31,6 +31,7 @@ module Text.Pandoc.Readers.Native ( readNative ) where import Text.Pandoc.Definition+import Text.Pandoc.Shared (safeRead) nullMeta :: Meta nullMeta = Meta{ docTitle = []@@ -51,31 +52,31 @@ readNative :: String -- ^ String to parse (assuming @'\n'@ line endings) -> Pandoc readNative s =- case reads s of- (d,_):_ -> d- [] -> Pandoc nullMeta $ readBlocks s+ case safeRead s of+ Just d -> d+ Nothing -> Pandoc nullMeta $ readBlocks s readBlocks :: String -> [Block] readBlocks s =- case reads s of- (d,_):_ -> d- [] -> [readBlock s]+ case safeRead s of+ Just d -> d+ Nothing -> [readBlock s] readBlock :: String -> Block readBlock s =- case reads s of- (d,_):_ -> d- [] -> Plain $ readInlines s+ case safeRead s of+ Just d -> d+ Nothing -> Plain $ readInlines s readInlines :: String -> [Inline] readInlines s =- case reads s of- (d,_):_ -> d- [] -> [readInline s]+ case safeRead s of+ Just d -> d+ Nothing -> [readInline s] readInline :: String -> Inline readInline s =- case reads s of- (d,_):_ -> d- [] -> error "Cannot parse document"+ case safeRead s of+ Just d -> d+ Nothing -> error "Cannot parse document"
@@ -17,9 +17,9 @@ -} {- |- Module : Text.Pandoc.Readers.RST + Module : Text.Pandoc.Readers.RST Copyright : Copyright (C) 2006-2010 John MacFarlane- License : GNU GPL, version 2 or above + License : GNU GPL, version 2 or above Maintainer : John MacFarlane <jgm@berkeley.edu> Stability : alpha@@ -27,25 +27,34 @@ Conversion from reStructuredText to 'Pandoc' document. -}-module Text.Pandoc.Readers.RST ( +module Text.Pandoc.Readers.RST ( readRST ) where import Text.Pandoc.Definition import Text.Pandoc.Shared import Text.Pandoc.Parsing-import Text.ParserCombinators.Parsec-import Control.Monad ( when, liftM )-import Data.List ( findIndex, intercalate, transpose, sort, deleteFirstsBy )+import Text.Pandoc.Options+import Control.Monad ( when, liftM, guard, mzero )+import Data.List ( findIndex, intersperse, intercalate,+ transpose, sort, deleteFirstsBy, isSuffixOf ) import qualified Data.Map as M import Text.Printf ( printf ) import Data.Maybe ( catMaybes )+import Control.Applicative ((<$>), (<$), (<*), (*>))+import Text.Pandoc.Builder (Inlines, Blocks, trimInlines, (<>))+import qualified Text.Pandoc.Builder as B+import Data.Monoid (mconcat, mempty)+import Data.Sequence (viewr, ViewR(..))+import Data.Char (toLower) -- | Parse reStructuredText string and return Pandoc document.-readRST :: ParserState -- ^ Parser state, including options for parser- -> String -- ^ String to parse (assuming @'\n'@ line endings)+readRST :: ReaderOptions -- ^ Reader options+ -> String -- ^ String to parse (assuming @'\n'@ line endings) -> Pandoc-readRST state s = (readWith parseRST) state (s ++ "\n\n")+readRST opts s = (readWith parseRST) def{ stateOptions = opts } (s ++ "\n\n") +type RSTParser = Parser [Char] ParserState+ -- -- Constants and data structure definitions ---@@ -58,80 +67,75 @@ -- treat these as potentially non-text when parsing inline: specialChars :: [Char]-specialChars = "\\`|*_<>$:[]()-.\"'\8216\8217\8220\8221"+specialChars = "\\`|*_<>$:/[]{}()-.\"'\8216\8217\8220\8221" -- -- parsing documents -- isHeader :: Int -> Block -> Bool-isHeader n (Header x _) = x == n-isHeader _ _ = False+isHeader n (Header x _ _) = x == n+isHeader _ _ = False -- | Promote all headers in a list of blocks. (Part of -- title transformation for RST.) promoteHeaders :: Int -> [Block] -> [Block]-promoteHeaders num ((Header level text):rest) = - (Header (level - num) text):(promoteHeaders num rest)+promoteHeaders num ((Header level attr text):rest) =+ (Header (level - num) attr text):(promoteHeaders num rest) promoteHeaders num (other:rest) = other:(promoteHeaders num rest) promoteHeaders _ [] = [] -- | If list of blocks starts with a header (or a header and subheader) -- of level that are not found elsewhere, return it as a title and--- promote all the other headers. +-- promote all the other headers. titleTransform :: [Block] -- ^ list of blocks -> ([Block], [Inline]) -- ^ modified list of blocks, title-titleTransform ((Header 1 head1):(Header 2 head2):rest) |+titleTransform ((Header 1 _ head1):(Header 2 _ head2):rest) | not (any (isHeader 1) rest || any (isHeader 2) rest) = -- both title & subtitle (promoteHeaders 2 rest, head1 ++ [Str ":", Space] ++ head2)-titleTransform ((Header 1 head1):rest) |+titleTransform ((Header 1 _ head1):rest) | not (any (isHeader 1) rest) = -- title, no subtitle (promoteHeaders 1 rest, head1) titleTransform blocks = (blocks, []) -parseRST :: GenParser Char ParserState Pandoc+parseRST :: RSTParser Pandoc parseRST = do optional blanklines -- skip blank lines at beginning of file startPos <- getPosition -- go through once just to get list of reference keys and notes -- docMinusKeys is the raw document with blanks where the keys were...- docMinusKeys <- manyTill (referenceKey <|> noteBlock <|> lineClump) eof >>=- return . concat+ docMinusKeys <- concat <$>+ manyTill (referenceKey <|> noteBlock <|> lineClump) eof setInput docMinusKeys setPosition startPos st' <- getState let reversedNotes = stateNotes st' updateState $ \s -> s { stateNotes = reverse reversedNotes } -- now parse it for real...- blocks <- parseBlocks - let blocks' = filter (/= Null) blocks+ blocks <- B.toList <$> parseBlocks+ standalone <- getOption readerStandalone+ let (blocks', title) = if standalone+ then titleTransform blocks+ else (blocks, []) state <- getState- let (blocks'', title) = if stateStandalone state- then titleTransform blocks'- else (blocks', []) let authors = stateAuthors state let date = stateDate state- let title' = if (null title) then (stateTitle state) else title- return $ Pandoc (Meta title' authors date) blocks''+ let title' = if null title then stateTitle state else title+ return $ Pandoc (Meta title' authors date) blocks' -- -- parsing blocks -- -parseBlocks :: GenParser Char ParserState [Block]-parseBlocks = manyTill block eof+parseBlocks :: RSTParser Blocks+parseBlocks = mconcat <$> manyTill block eof -block :: GenParser Char ParserState Block+block :: RSTParser Blocks block = choice [ codeBlock- , rawBlock , blockQuote , fieldList- , imageBlock- , figureBlock- , customCodeBlock- , mathBlock- , defaultRoleBlock- , unknownDirective+ , directive+ , comment , header , hrule , lineBlock -- must go before definitionList@@ -139,34 +143,32 @@ , list , lhsCodeBlock , para- , plain- , nullBlock ] <?> "block"+ ] <?> "block" -- -- field list -- -rawFieldListItem :: String -> GenParser Char ParserState (String, String)+rawFieldListItem :: String -> RSTParser (String, String) rawFieldListItem indent = try $ do string indent char ':'- name <- many1 $ alphaNum <|> spaceChar- string ": "- skipSpaces+ name <- many1Till (noneOf "\n") (char ':')+ (() <$ lookAhead newline) <|> skipMany1 spaceChar first <- manyTill anyChar newline rest <- option "" $ try $ do lookAhead (string indent >> spaceChar) indentedBlock- let raw = first ++ "\n" ++ rest ++ "\n"+ let raw = (if null first then "" else (first ++ "\n")) ++ rest ++ "\n" return (name, raw) fieldListItem :: String- -> GenParser Char ParserState (Maybe ([Inline], [[Block]]))+ -> RSTParser (Maybe (Inlines, [Blocks])) fieldListItem indent = try $ do (name, raw) <- rawFieldListItem indent- let term = [Str name]- contents <- parseFromString (many block) raw+ let term = B.str name+ contents <- parseFromString parseBlocks raw optional blanklines- case (name, contents) of+ case (name, B.toList contents) of ("Author", x) -> do updateState $ \st -> st{ stateAuthors = stateAuthors st ++ [extractContents x] }@@ -187,103 +189,69 @@ extractContents [Para auth] = auth extractContents _ = [] -fieldList :: GenParser Char ParserState Block+fieldList :: RSTParser Blocks fieldList = try $ do indent <- lookAhead $ many spaceChar items <- many1 $ fieldListItem indent- if null items- then return Null- else return $ DefinitionList $ catMaybes items+ case catMaybes items of+ [] -> return mempty+ items' -> return $ B.definitionList items' -- -- line block -- -lineBlockLine :: GenParser Char ParserState [Inline]-lineBlockLine = try $ do- char '|'- char ' ' <|> lookAhead (char '\n')- white <- many spaceChar- line <- many $ (notFollowedBy newline >> inline) <|> (try $ endline >>~ char ' ')- optional endline- return $ if null white- then normalizeSpaces line- else Str white : normalizeSpaces line--lineBlock :: GenParser Char ParserState Block+lineBlock :: RSTParser Blocks lineBlock = try $ do- lines' <- many1 lineBlockLine- blanklines- return $ Para (intercalate [LineBreak] lines')+ lines' <- lineBlockLines+ lines'' <- mapM (parseFromString+ (trimInlines . mconcat <$> many inline)) lines'+ return $ B.para (mconcat $ intersperse B.linebreak lines'') -- -- paragraph block -- -para :: GenParser Char ParserState Block-para = paraBeforeCodeBlock <|> paraNormal <?> "paragraph"--codeBlockStart :: GenParser Char st Char-codeBlockStart = string "::" >> blankline >> blankline---- paragraph that ends in a :: starting a code block-paraBeforeCodeBlock :: GenParser Char ParserState Block-paraBeforeCodeBlock = try $ do- result <- many1 (notFollowedBy' codeBlockStart >> inline)- lookAhead (string "::")- return $ Para $ if last result == Space- then normalizeSpaces result- else (normalizeSpaces result) ++ [Str ":"]---- regular paragraph-paraNormal :: GenParser Char ParserState Block-paraNormal = try $ do - result <- many1 inline- newline- blanklines- return $ Para $ normalizeSpaces result+-- note: paragraph can end in a :: starting a code block+para :: RSTParser Blocks+para = try $ do+ result <- trimInlines . mconcat <$> many1 inline+ option (B.plain result) $ try $ do+ newline+ blanklines+ case viewr (B.unMany result) of+ ys :> (Str xs) | "::" `isSuffixOf` xs -> do+ raw <- option mempty codeBlockBody+ return $ B.para (B.Many ys <> B.str (take (length xs - 1) xs))+ <> raw+ _ -> return (B.para result) -plain :: GenParser Char ParserState Block-plain = many1 inline >>= return . Plain . normalizeSpaces +plain :: RSTParser Blocks+plain = B.plain . trimInlines . mconcat <$> many1 inline ----- image block-----imageBlock :: GenParser Char ParserState Block-imageBlock = try $ do- string ".. image:: "- src <- manyTill anyChar newline- fields <- try $ do indent <- lookAhead $ many (oneOf " /t")- many $ rawFieldListItem indent- optional blanklines- case lookup "alt" fields of- Just alt -> return $ Plain [Image [Str $ removeTrailingSpace alt]- (src, "")]- Nothing -> return $ Plain [Image [Str "image"] (src, "")]--- -- header blocks -- -header :: GenParser Char ParserState Block+header :: RSTParser Blocks header = doubleHeader <|> singleHeader <?> "header" -- a header with lines on top and bottom-doubleHeader :: GenParser Char ParserState Block+doubleHeader :: RSTParser Blocks doubleHeader = try $ do c <- oneOf underlineChars rest <- many (char c) -- the top line let lenTop = length (c:rest) skipSpaces newline- txt <- many1 (notFollowedBy blankline >> inline)+ txt <- trimInlines . mconcat <$> many1 (notFollowedBy blankline >> inline) pos <- getPosition let len = (sourceColumn pos) - 1 if (len > lenTop) then fail "title longer than border" else return () blankline -- spaces and newline count lenTop (char c) -- the bottom line blanklines- -- check to see if we've had this kind of header before. + -- check to see if we've had this kind of header before. -- if so, get appropriate level. if not, add to list. state <- getState let headerTable = stateHeaderTable state@@ -291,13 +259,13 @@ Just ind -> (headerTable, ind + 1) Nothing -> (headerTable ++ [DoubleHeader c], (length headerTable) + 1) setState (state { stateHeaderTable = headerTable' })- return $ Header level (normalizeSpaces txt)+ return $ B.header level txt -- a header with line on the bottom only-singleHeader :: GenParser Char ParserState Block-singleHeader = try $ do +singleHeader :: RSTParser Blocks+singleHeader = try $ do notFollowedBy' whitespace- txt <- many1 (do {notFollowedBy blankline; inline})+ txt <- trimInlines . mconcat <$> many1 (do {notFollowedBy blankline; inline}) pos <- getPosition let len = (sourceColumn pos) - 1 blankline@@ -311,34 +279,34 @@ Just ind -> (headerTable, ind + 1) Nothing -> (headerTable ++ [SingleHeader c], (length headerTable) + 1) setState (state { stateHeaderTable = headerTable' })- return $ Header level (normalizeSpaces txt)+ return $ B.header level txt -- -- hrule block -- -hrule :: GenParser Char st Block+hrule :: Parser [Char] st Blocks hrule = try $ do chr <- oneOf underlineChars count 3 (char chr) skipMany (char chr) blankline blanklines- return HorizontalRule+ return B.horizontalRule -- -- code blocks -- -- read a line indented by a given string-indentedLine :: String -> GenParser Char st [Char]+indentedLine :: String -> Parser [Char] st [Char] indentedLine indents = try $ do string indents manyTill anyChar newline -- one or more indented lines, possibly separated by blank lines. -- any amount of indentation will work.-indentedBlock :: GenParser Char st [Char]+indentedBlock :: Parser [Char] st [Char] indentedBlock = try $ do indents <- lookAhead $ many1 spaceChar lns <- many1 $ try $ do b <- option "" blanklines@@ -347,127 +315,65 @@ optional blanklines return $ unlines lns -codeBlock :: GenParser Char st Block-codeBlock = try $ do- codeBlockStart- result <- indentedBlock- return $ CodeBlock ("",[],[]) $ stripTrailingNewlines result---- | The 'code-block' directive (from Sphinx) that allows a language to be--- specified.-customCodeBlock :: GenParser Char st Block-customCodeBlock = try $ do- string ".. code-block:: "- language <- manyTill anyChar newline- blanklines- result <- indentedBlock- return $ CodeBlock ("", ["sourceCode", language], []) $ stripTrailingNewlines result---figureBlock :: GenParser Char ParserState Block-figureBlock = try $ do- string ".. figure::"- src <- removeLeadingTrailingSpace `fmap` manyTill anyChar newline- body <- indentedBlock- caption <- parseFromString extractCaption body- return $ Para [Image caption (src,"")]--extractCaption :: GenParser Char ParserState [Inline]-extractCaption = try $ do- manyTill anyLine blanklines- many inline---- | The 'math' directive (from Sphinx) for display math.-mathBlock :: GenParser Char st Block-mathBlock = try $ do- string ".. math::"- mathBlockMultiline <|> mathBlockOneLine+codeBlockStart :: Parser [Char] st Char+codeBlockStart = string "::" >> blankline >> blankline -mathBlockOneLine :: GenParser Char st Block-mathBlockOneLine = try $ do- result <- manyTill anyChar newline- blanklines- return $ Para [Math DisplayMath $ removeLeadingTrailingSpace result]+codeBlock :: Parser [Char] st Blocks+codeBlock = try $ codeBlockStart >> codeBlockBody -mathBlockMultiline :: GenParser Char st Block-mathBlockMultiline = try $ do- blanklines- result <- indentedBlock- -- a single block can contain multiple equations, which need to go- -- in separate Pandoc math elements- let lns = map removeLeadingTrailingSpace $ lines result- -- drop :label, :nowrap, etc.- let startsWithColon (':':_) = True- startsWithColon _ = False- let lns' = dropWhile startsWithColon lns- let eqs = map (removeLeadingTrailingSpace . unlines)- $ filter (not . null) $ splitBy null lns'- return $ Para $ map (Math DisplayMath) eqs+codeBlockBody :: Parser [Char] st Blocks+codeBlockBody = try $ B.codeBlock . stripTrailingNewlines <$> indentedBlock -lhsCodeBlock :: GenParser Char ParserState Block+lhsCodeBlock :: RSTParser Blocks lhsCodeBlock = try $ do- failUnlessLHS+ getPosition >>= guard . (==1) . sourceColumn+ guardEnabled Ext_literate_haskell optional codeBlockStart- pos <- getPosition- when (sourceColumn pos /= 1) $ fail "Not in first column" lns <- many1 birdTrackLine -- if (as is normal) there is always a space after >, drop it let lns' = if all (\ln -> null ln || take 1 ln == " ") lns then map (drop 1) lns else lns blanklines- return $ CodeBlock ("", ["sourceCode", "literate", "haskell"], []) $ intercalate "\n" lns'--birdTrackLine :: GenParser Char st [Char]-birdTrackLine = do- char '>'- manyTill anyChar newline------- raw html/latex/etc---+ return $ B.codeBlockWith ("", ["sourceCode", "literate", "haskell"], [])+ $ intercalate "\n" lns' -rawBlock :: GenParser Char st Block-rawBlock = try $ do- string ".. raw:: "- lang <- many1 (letter <|> digit)- blanklines- result <- indentedBlock- return $ RawBlock lang result+birdTrackLine :: Parser [Char] st [Char]+birdTrackLine = char '>' >> manyTill anyChar newline -- -- block quotes -- -blockQuote :: GenParser Char ParserState Block+blockQuote :: RSTParser Blocks blockQuote = do raw <- indentedBlock -- parse the extracted block, which may contain various block elements: contents <- parseFromString parseBlocks $ raw ++ "\n\n"- return $ BlockQuote contents+ return $ B.blockQuote contents -- -- list blocks -- -list :: GenParser Char ParserState Block+list :: RSTParser Blocks list = choice [ bulletList, orderedList, definitionList ] <?> "list" -definitionListItem :: GenParser Char ParserState ([Inline], [[Block]])+definitionListItem :: RSTParser (Inlines, [Blocks]) definitionListItem = try $ do -- avoid capturing a directive or comment notFollowedBy (try $ char '.' >> char '.')- term <- many1Till inline endline+ term <- trimInlines . mconcat <$> many1Till inline endline raw <- indentedBlock -- parse the extracted block, which may contain various block elements: contents <- parseFromString parseBlocks $ raw ++ "\n"- return (normalizeSpaces term, [contents])+ return (term, [contents]) -definitionList :: GenParser Char ParserState Block-definitionList = many1 definitionListItem >>= return . DefinitionList+definitionList :: RSTParser Blocks+definitionList = B.definitionList <$> many1 definitionListItem -- parses bullet list start and returns its length (inc. following whitespace)-bulletListStart :: GenParser Char st Int+bulletListStart :: Parser [Char] st Int bulletListStart = try $ do notFollowedBy' hrule -- because hrules start out just like lists marker <- oneOf bulletListMarkers@@ -477,14 +383,14 @@ -- parses ordered list start and returns its length (inc following whitespace) orderedListStart :: ListNumberStyle -> ListNumberDelim- -> GenParser Char ParserState Int+ -> RSTParser Int orderedListStart style delim = try $ do (_, markerLen) <- withHorizDisplacement (orderedListMarker style delim) white <- many1 spaceChar return $ markerLen + length white -- parse a line of a list item-listLine :: Int -> GenParser Char ParserState [Char]+listLine :: Int -> RSTParser [Char] listLine markerLength = try $ do notFollowedBy blankline indentWith markerLength@@ -492,36 +398,35 @@ return $ line ++ "\n" -- indent by specified number of spaces (or equiv. tabs)-indentWith :: Int -> GenParser Char ParserState [Char]+indentWith :: Int -> RSTParser [Char] indentWith num = do- state <- getState- let tabStop = stateTabStop state+ tabStop <- getOption readerTabStop if (num < tabStop) then count num (char ' ')- else choice [ try (count num (char ' ')), - (try (char '\t' >> count (num - tabStop) (char ' '))) ] + else choice [ try (count num (char ' ')),+ (try (char '\t' >> count (num - tabStop) (char ' '))) ] -- parse raw text for one list item, excluding start marker and continuations-rawListItem :: GenParser Char ParserState Int- -> GenParser Char ParserState (Int, [Char])+rawListItem :: RSTParser Int+ -> RSTParser (Int, [Char]) rawListItem start = try $ do markerLength <- start firstLine <- manyTill anyChar newline restLines <- many (listLine markerLength) return (markerLength, (firstLine ++ "\n" ++ (concat restLines))) --- continuation of a list item - indented and separated by blankline or --- (in compact lists) endline. +-- continuation of a list item - indented and separated by blankline or+-- (in compact lists) endline. -- Note: nested lists are parsed as continuations.-listContinuation :: Int -> GenParser Char ParserState [Char]+listContinuation :: Int -> RSTParser [Char] listContinuation markerLength = try $ do blanks <- many1 blankline result <- many1 (listLine markerLength) return $ blanks ++ concat result -listItem :: GenParser Char ParserState Int- -> GenParser Char ParserState [Block]-listItem start = try $ do +listItem :: RSTParser Int+ -> RSTParser Blocks+listItem start = try $ do (markerLength, first) <- rawListItem start rest <- many (listContinuation markerLength) blanks <- choice [ try (many blankline >>~ lookAhead start),@@ -537,52 +442,181 @@ updateState (\st -> st {stateParserContext = oldContext}) return parsed -orderedList :: GenParser Char ParserState Block+orderedList :: RSTParser Blocks orderedList = try $ do (start, style, delim) <- lookAhead (anyOrderedListMarker >>~ spaceChar) items <- many1 (listItem (orderedListStart style delim))- let items' = compactify items- return $ OrderedList (start, style, delim) items'+ let items' = compactify' items+ return $ B.orderedListWith (start, style, delim) items' -bulletList :: GenParser Char ParserState Block-bulletList = many1 (listItem bulletListStart) >>= - return . BulletList . compactify+bulletList :: RSTParser Blocks+bulletList = B.bulletList . compactify' <$> many1 (listItem bulletListStart) ----- default-role block+-- directive (e.g. comment, container, compound-paragraph) -- -defaultRoleBlock :: GenParser Char ParserState Block-defaultRoleBlock = try $ do- string ".. default-role::"- -- doesn't enforce any restrictions on the role name; embedded spaces shouldn't be allowed, for one- role <- manyTill anyChar newline >>= return . removeLeadingTrailingSpace- updateState $ \s -> s { stateRstDefaultRole =- if null role- then stateRstDefaultRole defaultParserState- else role- }- -- skip body of the directive if it exists- many $ blanklines <|> (spaceChar >> manyTill anyChar newline)- return Null+comment :: RSTParser Blocks+comment = try $ do+ string ".."+ skipMany1 spaceChar <|> (() <$ lookAhead newline)+ notFollowedBy' directiveLabel+ manyTill anyChar blanklines+ optional indentedBlock+ return mempty ------ unknown directive (e.g. comment)---+directiveLabel :: RSTParser String+directiveLabel = map toLower+ <$> many1Till (letter <|> char '-') (try $ string "::") -unknownDirective :: GenParser Char st Block-unknownDirective = try $ do+directive :: RSTParser Blocks+directive = try $ do string ".."- notFollowedBy (noneOf " \t\n")- manyTill anyChar newline- many $ blanklines <|> (spaceChar >> manyTill anyChar newline)- return Null+ directive' +-- TODO: line-block, parsed-literal, table, csv-table, list-table+-- date+-- include+-- class+-- title+directive' :: RSTParser Blocks+directive' = do+ skipMany1 spaceChar+ label <- directiveLabel+ skipMany spaceChar+ top <- many $ satisfy (/='\n')+ <|> try (char '\n' <*+ notFollowedBy' (rawFieldListItem " ") <*+ count 3 (char ' ') <*+ notFollowedBy blankline)+ newline+ fields <- many $ rawFieldListItem " "+ body <- option "" $ try $ blanklines >> indentedBlock+ optional blanklines+ let body' = body ++ "\n\n"+ case label of+ "raw" -> return $ B.rawBlock (trim top) (stripTrailingNewlines body)+ "role" -> return mempty+ "container" -> parseFromString parseBlocks body'+ "replace" -> B.para <$> -- consumed by substKey+ parseFromString (trimInlines . mconcat <$> many inline)+ (trim top)+ "unicode" -> B.para <$> -- consumed by substKey+ parseFromString (trimInlines . mconcat <$> many inline)+ (trim $ unicodeTransform top)+ "compound" -> parseFromString parseBlocks body'+ "pull-quote" -> B.blockQuote <$> parseFromString parseBlocks body'+ "epigraph" -> B.blockQuote <$> parseFromString parseBlocks body'+ "highlights" -> B.blockQuote <$> parseFromString parseBlocks body'+ "rubric" -> B.para . B.strong <$> parseFromString+ (trimInlines . mconcat <$> many inline) top+ _ | label `elem` ["attention","caution","danger","error","hint",+ "important","note","tip","warning"] ->+ do let tit = B.para $ B.strong $ B.str label+ bod <- parseFromString parseBlocks $ top ++ "\n\n" ++ body'+ return $ B.blockQuote $ tit <> bod+ "admonition" ->+ do tit <- B.para . B.strong <$> parseFromString+ (trimInlines . mconcat <$> many inline) top+ bod <- parseFromString parseBlocks body'+ return $ B.blockQuote $ tit <> bod+ "sidebar" ->+ do let subtit = maybe "" trim $ lookup "subtitle" fields+ tit <- B.para . B.strong <$> parseFromString+ (trimInlines . mconcat <$> many inline)+ (trim top ++ if null subtit+ then ""+ else (": " ++ subtit))+ bod <- parseFromString parseBlocks body'+ return $ B.blockQuote $ tit <> bod+ "topic" ->+ do tit <- B.para . B.strong <$> parseFromString+ (trimInlines . mconcat <$> many inline) top+ bod <- parseFromString parseBlocks body'+ return $ tit <> bod+ "default-role" -> mempty <$ updateState (\s ->+ s { stateRstDefaultRole =+ case trim top of+ "" -> stateRstDefaultRole def+ role -> role })+ "code" -> codeblock (lookup "number-lines" fields) (trim top) body+ "code-block" -> codeblock (lookup "number-lines" fields) (trim top) body+ "math" -> return $ B.para $ mconcat $ map B.displayMath+ $ toChunks $ top ++ "\n\n" ++ body+ "figure" -> do+ (caption, legend) <- parseFromString extractCaption body'+ let src = escapeURI $ trim top+ return $ B.para (B.image src "" caption) <> legend+ "image" -> do+ let src = escapeURI $ trim top+ let alt = B.str $ maybe "image" trim $ lookup "alt" fields+ return $ B.para+ $ case lookup "target" fields of+ Just t -> B.link (escapeURI $ trim t) ""+ $ B.image src "" alt+ Nothing -> B.image src "" alt+ _ -> return mempty++-- Can contain haracter codes as decimal numbers or+-- hexadecimal numbers, prefixed by 0x, x, \x, U+, u, or \u+-- or as XML-style hexadecimal character entities, e.g. ᨫ+-- or text, which is used as-is. Comments start with ..+unicodeTransform :: String -> String+unicodeTransform t =+ case t of+ ('.':'.':xs) -> unicodeTransform $ dropWhile (/='\n') xs -- comment+ ('0':'x':xs) -> go "0x" xs+ ('x':xs) -> go "x" xs+ ('\\':'x':xs) -> go "\\x" xs+ ('U':'+':xs) -> go "U+" xs+ ('u':xs) -> go "u" xs+ ('\\':'u':xs) -> go "\\u" xs+ ('&':'#':'x':xs) -> maybe ("&#x" ++ unicodeTransform xs)+ -- drop semicolon+ (\(c,s) -> c : unicodeTransform (drop 1 s))+ $ extractUnicodeChar xs+ (x:xs) -> x : unicodeTransform xs+ [] -> []+ where go pref zs = maybe (pref ++ unicodeTransform zs)+ (\(c,s) -> c : unicodeTransform s)+ $ extractUnicodeChar zs++extractUnicodeChar :: String -> Maybe (Char, String)+extractUnicodeChar s = maybe Nothing (\c -> Just (c,rest)) mbc+ where (ds,rest) = span isHexDigit s+ mbc = safeRead ('\'':'\\':'x':ds ++ "'")++isHexDigit :: Char -> Bool+isHexDigit c = c `elem` "0123456789ABCDEFabcdef"++extractCaption :: RSTParser (Inlines, Blocks)+extractCaption = do+ capt <- trimInlines . mconcat <$> many inline+ legend <- optional blanklines >> (mconcat <$> many block)+ return (capt,legend)++-- divide string by blanklines+toChunks :: String -> [String]+toChunks = dropWhile null+ . map (trim . unlines)+ . splitBy (all (`elem` " \t")) . lines++codeblock :: Maybe String -> String -> String -> RSTParser Blocks+codeblock numberLines lang body =+ return $ B.codeBlockWith attribs $ stripTrailingNewlines body+ where attribs = ("", classes, kvs)+ classes = "sourceCode" : lang+ : maybe [] (\_ -> ["numberLines"]) numberLines+ kvs = case numberLines of+ Just "" -> []+ Nothing -> []+ Just n -> [("startFrom",n)]+ --- --- note block --- -noteBlock :: GenParser Char ParserState [Char]+noteBlock :: RSTParser [Char] noteBlock = try $ do startPos <- getPosition string ".."@@ -601,7 +635,7 @@ -- return blanks so line count isn't affected return $ replicate (sourceLine endPos - sourceLine startPos) '\n' -noteMarker :: GenParser Char ParserState [Char]+noteMarker :: RSTParser [Char] noteMarker = do char '[' res <- many1 digit@@ -614,82 +648,95 @@ -- reference key -- -quotedReferenceName :: GenParser Char ParserState [Inline]+quotedReferenceName :: RSTParser Inlines quotedReferenceName = try $ do char '`' >> notFollowedBy (char '`') -- `` means inline code!- label' <- many1Till inline (char '`') + label' <- trimInlines . mconcat <$> many1Till inline (char '`') return label' -unquotedReferenceName :: GenParser Char ParserState [Inline]+unquotedReferenceName :: RSTParser Inlines unquotedReferenceName = try $ do- label' <- many1Till inline (lookAhead $ char ':')+ label' <- trimInlines . mconcat <$> many1Till inline (lookAhead $ char ':') return label' -- Simple reference names are single words consisting of alphanumerics -- plus isolated (no two adjacent) internal hyphens, underscores, -- periods, colons and plus signs; no whitespace or other characters -- are allowed.-simpleReferenceName' :: GenParser Char st String+simpleReferenceName' :: Parser [Char] st String simpleReferenceName' = do x <- alphaNum xs <- many $ alphaNum <|> (try $ oneOf "-_:+." >> lookAhead alphaNum) return (x:xs) -simpleReferenceName :: GenParser Char st [Inline]+simpleReferenceName :: Parser [Char] st Inlines simpleReferenceName = do raw <- simpleReferenceName'- return [Str raw]+ return $ B.str raw -referenceName :: GenParser Char ParserState [Inline]+referenceName :: RSTParser Inlines referenceName = quotedReferenceName <|> (try $ simpleReferenceName >>~ lookAhead (char ':')) <|> unquotedReferenceName -referenceKey :: GenParser Char ParserState [Char]+referenceKey :: RSTParser [Char] referenceKey = do startPos <- getPosition- (key, target) <- choice [imageKey, anonymousKey, regularKey]- st <- getState- let oldkeys = stateKeys st- updateState $ \s -> s { stateKeys = M.insert key target oldkeys }+ choice [substKey, anonymousKey, regularKey] optional blanklines endPos <- getPosition -- return enough blanks to replace key return $ replicate (sourceLine endPos - sourceLine startPos) '\n' -targetURI :: GenParser Char st [Char]+targetURI :: Parser [Char] st [Char] targetURI = do skipSpaces optional newline- contents <- many1 (try (many spaceChar >> newline >> + contents <- many1 (try (many spaceChar >> newline >> many1 spaceChar >> noneOf " \t\n") <|> noneOf "\n") blanklines- return $ escapeURI $ removeLeadingTrailingSpace $ contents+ return $ escapeURI $ trim $ contents -imageKey :: GenParser Char ParserState (Key, Target)-imageKey = try $ do- string ".. |"- ref <- manyTill inline (char '|')- skipSpaces- string "image::"- src <- targetURI- return (toKey (normalizeSpaces ref), (src, ""))+substKey :: RSTParser ()+substKey = try $ do+ string ".."+ skipMany1 spaceChar+ (alt,ref) <- withRaw $ trimInlines . mconcat+ <$> enclosed (char '|') (char '|') inline+ res <- B.toList <$> directive'+ il <- case res of+ -- use alt unless :alt: attribute on image:+ [Para [Image [Str "image"] (src,tit)]] ->+ return $ B.image src tit alt+ [Para [Link [Image [Str "image"] (src,tit)] (src',tit')]] ->+ return $ B.link src' tit' (B.image src tit alt)+ [Para ils] -> return $ B.fromList ils+ _ -> mzero+ let key = toKey $ stripFirstAndLast ref+ updateState $ \s -> s{ stateSubstitutions = M.insert key il $ stateSubstitutions s } -anonymousKey :: GenParser Char st (Key, Target)+anonymousKey :: RSTParser () anonymousKey = try $ do oneOfStrings [".. __:", "__"] src <- targetURI pos <- getPosition- return (toKey [Str $ "_" ++ printf "%09d" (sourceLine pos)], (src, ""))+ let key = toKey $ "_" ++ printf "%09d" (sourceLine pos)+ updateState $ \s -> s { stateKeys = M.insert key (src,"") $ stateKeys s } -regularKey :: GenParser Char ParserState (Key, Target)+stripTicks :: String -> String+stripTicks = reverse . stripTick . reverse . stripTick+ where stripTick ('`':xs) = xs+ stripTick xs = xs++regularKey :: RSTParser () regularKey = try $ do string ".. _"- ref <- referenceName+ (_,ref) <- withRaw referenceName char ':' src <- targetURI- return (toKey (normalizeSpaces ref), (src, ""))+ let key = toKey $ stripTicks ref+ updateState $ \s -> s { stateKeys = M.insert key (src,"") $ stateKeys s } -- -- tables@@ -702,57 +749,57 @@ -- Simple tables TODO: -- - column spans -- - multiline support--- - ensure that rightmost column span does not need to reach end +-- - ensure that rightmost column span does not need to reach end -- - require at least 2 columns -- -- Grid tables TODO: -- - column spans -dashedLine :: Char -> GenParser Char st (Int, Int)+dashedLine :: Char -> Parser [Char] st (Int, Int) dashedLine ch = do dashes <- many1 (char ch) sp <- many (char ' ') return (length dashes, length $ dashes ++ sp) -simpleDashedLines :: Char -> GenParser Char st [(Int,Int)]+simpleDashedLines :: Char -> Parser [Char] st [(Int,Int)] simpleDashedLines ch = try $ many1 (dashedLine ch) -- Parse a table row separator-simpleTableSep :: Char -> GenParser Char ParserState Char+simpleTableSep :: Char -> RSTParser Char simpleTableSep ch = try $ simpleDashedLines ch >> newline -- Parse a table footer-simpleTableFooter :: GenParser Char ParserState [Char]+simpleTableFooter :: RSTParser [Char] simpleTableFooter = try $ simpleTableSep '=' >> blanklines -- Parse a raw line and split it into chunks by indices.-simpleTableRawLine :: [Int] -> GenParser Char ParserState [String]+simpleTableRawLine :: [Int] -> RSTParser [String] simpleTableRawLine indices = do line <- many1Till anyChar newline return (simpleTableSplitLine indices line) -- Parse a table row and return a list of blocks (columns).-simpleTableRow :: [Int] -> GenParser Char ParserState [[Block]]+simpleTableRow :: [Int] -> RSTParser [[Block]] simpleTableRow indices = do notFollowedBy' simpleTableFooter firstLine <- simpleTableRawLine indices colLines <- return [] -- TODO let cols = map unlines . transpose $ firstLine : colLines- mapM (parseFromString (many plain)) cols+ mapM (parseFromString (B.toList . mconcat <$> many plain)) cols simpleTableSplitLine :: [Int] -> String -> [String] simpleTableSplitLine indices line =- map removeLeadingTrailingSpace+ map trim $ tail $ splitByIndices (init indices) line -simpleTableHeader :: Bool -- ^ Headerless table - -> GenParser Char ParserState ([[Block]], [Alignment], [Int])+simpleTableHeader :: Bool -- ^ Headerless table+ -> RSTParser ([[Block]], [Alignment], [Int]) simpleTableHeader headless = try $ do optional blanklines rawContent <- if headless then return "" else simpleTableSep '=' >> anyLine- dashes <- simpleDashedLines '='+ dashes <- simpleDashedLines '=' <|> simpleDashedLines '-' newline let lines' = map snd dashes let indices = scanl (+) 0 lines'@@ -760,34 +807,34 @@ let rawHeads = if headless then replicate (length dashes) "" else simpleTableSplitLine indices rawContent- heads <- mapM (parseFromString (many plain)) $- map removeLeadingTrailingSpace rawHeads+ heads <- mapM (parseFromString (B.toList . mconcat <$> many plain)) $+ map trim rawHeads return (heads, aligns, indices) -- Parse a simple table. simpleTable :: Bool -- ^ Headerless table- -> GenParser Char ParserState Block+ -> RSTParser Blocks simpleTable headless = do- Table c a _w h l <- tableWith (simpleTableHeader headless) simpleTableRow sep simpleTableFooter (return [])+ Table c a _w h l <- tableWith (simpleTableHeader headless) simpleTableRow sep simpleTableFooter -- Simple tables get 0s for relative column widths (i.e., use default)- return $ Table c a (replicate (length a) 0) h l+ return $ B.singleton $ Table c a (replicate (length a) 0) h l where sep = return () -- optional (simpleTableSep '-') gridTable :: Bool -- ^ Headerless table- -> GenParser Char ParserState Block-gridTable = gridTableWith block (return [])+ -> RSTParser Blocks+gridTable headerless = B.singleton+ <$> gridTableWith (B.toList <$> parseBlocks) headerless -table :: GenParser Char ParserState Block+table :: RSTParser Blocks table = gridTable False <|> simpleTable False <|> gridTable True <|> simpleTable True <?> "table" -- -- - -- inline- --+--+-- inline+-- -inline :: GenParser Char ParserState Inline+inline :: RSTParser Inlines inline = choice [ whitespace , link , str@@ -795,91 +842,99 @@ , strong , emph , code- , image- , superscript- , subscript- , math+ , subst+ , interpretedRole , note- , smartPunctuation inline+ , smart , hyphens , escapedChar , symbol ] <?> "inline" -hyphens :: GenParser Char ParserState Inline+hyphens :: RSTParser Inlines hyphens = do result <- many1 (char '-')- option Space endline + optional endline -- don't want to treat endline after hyphen or dash as a space- return $ Str result+ return $ B.str result -escapedChar :: GenParser Char st Inline+escapedChar :: Parser [Char] st Inlines escapedChar = do c <- escaped anyChar return $ if c == ' ' -- '\ ' is null in RST- then Str ""- else Str [c]+ then mempty+ else B.str [c] -symbol :: GenParser Char ParserState Inline-symbol = do +symbol :: RSTParser Inlines+symbol = do result <- oneOf specialChars- return $ Str [result]+ return $ B.str [result] -- parses inline code, between codeStart and codeEnd-code :: GenParser Char ParserState Inline-code = try $ do +code :: RSTParser Inlines+code = try $ do string "``" result <- manyTill anyChar (try (string "``"))- return $ Code nullAttr- $ removeLeadingTrailingSpace $ intercalate " " $ lines result+ return $ B.code+ $ trim $ unwords $ lines result -emph :: GenParser Char ParserState Inline-emph = enclosed (char '*') (char '*') inline >>= - return . Emph . normalizeSpaces+-- succeeds only if we're not right after a str (ie. in middle of word)+atStart :: RSTParser a -> RSTParser a+atStart p = do+ pos <- getPosition+ st <- getState+ -- single quote start can't be right after str+ guard $ stateLastStrPos st /= Just pos+ p -strong :: GenParser Char ParserState Inline-strong = enclosed (string "**") (try $ string "**") inline >>= - return . Strong . normalizeSpaces+emph :: RSTParser Inlines+emph = B.emph . trimInlines . mconcat <$>+ enclosed (atStart $ char '*') (char '*') inline --- Parses inline interpreted text which is required to have the given role.--- This decision is based on the role marker (if present),--- and the current default interpreted text role.-interpreted :: [Char] -> GenParser Char ParserState [Char]-interpreted role = try $ do- state <- getState- if role == stateRstDefaultRole state- then try markedInterpretedText <|> unmarkedInterpretedText- else markedInterpretedText- where- markedInterpretedText = try (roleMarker >> unmarkedInterpretedText)- <|> (unmarkedInterpretedText >>= (\txt -> roleMarker >> return txt))- roleMarker = string $ ":" ++ role ++ ":"- -- Note, this doesn't precisely implement the complex rule in- -- http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#inline-markup-recognition-rules- -- but it should be good enough for most purposes- unmarkedInterpretedText = do- result <- enclosed (char '`') (char '`') anyChar- return result+strong :: RSTParser Inlines+strong = B.strong . trimInlines . mconcat <$>+ enclosed (atStart $ string "**") (try $ string "**") inline -superscript :: GenParser Char ParserState Inline-superscript = interpreted "sup" >>= \x -> return (Superscript [Str x])+-- Note, this doesn't precisely implement the complex rule in+-- http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#inline-markup-recognition-rules+-- but it should be good enough for most purposes+interpretedRole :: RSTParser Inlines+interpretedRole = try $ do+ (role, contents) <- roleBefore <|> roleAfter+ case role of+ "sup" -> return $ B.superscript $ B.str contents+ "sub" -> return $ B.subscript $ B.str contents+ "math" -> return $ B.math contents+ _ -> return $ B.str contents --unknown -subscript :: GenParser Char ParserState Inline-subscript = interpreted "sub" >>= \x -> return (Subscript [Str x])+roleMarker :: RSTParser String+roleMarker = char ':' *> many1Till (letter <|> char '-') (char ':') -math :: GenParser Char ParserState Inline-math = interpreted "math" >>= \x -> return (Math InlineMath x)+roleBefore :: RSTParser (String,String)+roleBefore = try $ do+ role <- roleMarker+ contents <- unmarkedInterpretedText+ return (role,contents) -whitespace :: GenParser Char ParserState Inline-whitespace = many1 spaceChar >> return Space <?> "whitespace"+roleAfter :: RSTParser (String,String)+roleAfter = try $ do+ contents <- unmarkedInterpretedText+ role <- roleMarker <|> (stateRstDefaultRole <$> getState)+ return (role,contents) -str :: GenParser Char ParserState Inline+unmarkedInterpretedText :: RSTParser [Char]+unmarkedInterpretedText = enclosed (atStart $ char '`') (char '`') anyChar++whitespace :: RSTParser Inlines+whitespace = B.space <$ skipMany1 spaceChar <?> "whitespace"++str :: RSTParser Inlines str = do- result <- many1 (noneOf (specialChars ++ "\t\n "))- pos <- getPosition- updateState $ \s -> s{ stateLastStrPos = Just pos }- return $ Str result+ let strChar = noneOf ("\t\n " ++ specialChars)+ result <- many1 strChar+ updateLastStrPos+ return $ B.str result -- an endline character that can be treated as a space, not a structural break-endline :: GenParser Char ParserState Inline+endline :: RSTParser Inlines endline = try $ do newline notFollowedBy blankline@@ -889,74 +944,70 @@ then notFollowedBy (anyOrderedListMarker >> spaceChar) >> notFollowedBy' bulletListStart else return ()- return Space+ return B.space -- -- links -- -link :: GenParser Char ParserState Inline+link :: RSTParser Inlines link = choice [explicitLink, referenceLink, autoLink] <?> "link" -explicitLink :: GenParser Char ParserState Inline+explicitLink :: RSTParser Inlines explicitLink = try $ do char '`' notFollowedBy (char '`') -- `` marks start of inline code- label' <- manyTill (notFollowedBy (char '`') >> inline) - (try (spaces >> char '<'))+ label' <- trimInlines . mconcat <$>+ manyTill (notFollowedBy (char '`') >> inline) (char '<') src <- manyTill (noneOf ">\n") (char '>') skipSpaces string "`_"- return $ Link (normalizeSpaces label')- (escapeURI $ removeLeadingTrailingSpace src, "")+ return $ B.link (escapeURI $ trim src) "" label' -referenceLink :: GenParser Char ParserState Inline+referenceLink :: RSTParser Inlines referenceLink = try $ do- label' <- (quotedReferenceName <|> simpleReferenceName) >>~ char '_'+ (label',ref) <- withRaw (quotedReferenceName <|> simpleReferenceName) >>~+ char '_' state <- getState let keyTable = stateKeys state- let isAnonKey x = case fromKey x of- [Str ('_':_)] -> True- _ -> False- key <- option (toKey label') $+ let isAnonKey (Key ('_':_)) = True+ isAnonKey _ = False+ key <- option (toKey $ stripTicks ref) $ do char '_' let anonKeys = sort $ filter isAnonKey $ M.keys keyTable if null anonKeys- then pzero+ then mzero else return (head anonKeys)- (src,tit) <- case lookupKeySrc keyTable key of+ (src,tit) <- case M.lookup key keyTable of Nothing -> fail "no corresponding key" Just target -> return target -- if anonymous link, remove key so it won't be used again when (isAnonKey key) $ updateState $ \s -> s{ stateKeys = M.delete key keyTable }- return $ Link (normalizeSpaces label') (src, tit) + return $ B.link src tit label' -autoURI :: GenParser Char ParserState Inline+autoURI :: RSTParser Inlines autoURI = do (orig, src) <- uri- return $ Link [Str orig] (src, "")+ return $ B.link src "" $ B.str orig -autoEmail :: GenParser Char ParserState Inline+autoEmail :: RSTParser Inlines autoEmail = do (orig, src) <- emailAddress- return $ Link [Str orig] (src, "")+ return $ B.link src "" $ B.str orig -autoLink :: GenParser Char ParserState Inline+autoLink :: RSTParser Inlines autoLink = autoURI <|> autoEmail --- For now, we assume that all substitution references are for images.-image :: GenParser Char ParserState Inline-image = try $ do- char '|'- ref <- manyTill inline (char '|')+subst :: RSTParser Inlines+subst = try $ do+ (_,ref) <- withRaw $ enclosed (char '|') (char '|') inline state <- getState- let keyTable = stateKeys state- (src,tit) <- case lookupKeySrc keyTable (toKey ref) of- Nothing -> fail "no corresponding key"- Just target -> return target- return $ Image (normalizeSpaces ref) (src, tit)+ let substTable = stateSubstitutions state+ case M.lookup (toKey $ stripFirstAndLast ref) substTable of+ Nothing -> fail "no corresponding key"+ Just target -> return target -note :: GenParser Char ParserState Inline+note :: RSTParser Inlines note = try $ do ref <- noteMarker char '_'@@ -977,4 +1028,24 @@ then deleteFirstsBy (==) notes [(ref,raw)] else notes updateState $ \st -> st{ stateNotes = newnotes }- return $ Note contents+ return $ B.note contents++smart :: RSTParser Inlines+smart = do+ getOption readerSmart >>= guard+ doubleQuoted <|> singleQuoted <|>+ choice (map (B.singleton <$>) [apostrophe, dash, ellipses])++singleQuoted :: RSTParser Inlines+singleQuoted = try $ do+ singleQuoteStart+ withQuoteContext InSingleQuote $+ B.singleQuoted . trimInlines . mconcat <$>+ many1Till inline singleQuoteEnd++doubleQuoted :: RSTParser Inlines+doubleQuoted = try $ do+ doubleQuoteStart+ withQuoteContext InDoubleQuote $+ B.doubleQuoted . trimInlines . mconcat <$>+ many1Till inline doubleQuoteEnd
@@ -19,7 +19,7 @@ {- | Module : Text.Pandoc.Readers.TeXMath Copyright : Copyright (C) 2007-2010 John MacFarlane- License : GNU GPL, version 2 or above + License : GNU GPL, version 2 or above Maintainer : John MacFarlane <jgm@berkeley.edu> Stability : alpha
@@ -19,7 +19,7 @@ {- | Module : Text.Pandoc.Readers.Textile Copyright : Copyright (C) 2010-2012 Paul Rivier and John MacFarlane- License : GNU GPL, version 2 or above + License : GNU GPL, version 2 or above Maintainer : Paul Rivier <paul*rivier#demotera*com> Stability : alpha@@ -46,8 +46,6 @@ - continued blocks (ex bq..) TODO : refactor common patterns across readers :- - autolink- - smartPunctuation - more ... -}@@ -56,29 +54,35 @@ module Text.Pandoc.Readers.Textile ( readTextile) where import Text.Pandoc.Definition-import Text.Pandoc.Shared +import Text.Pandoc.Shared+import Text.Pandoc.Options import Text.Pandoc.Parsing import Text.Pandoc.Readers.HTML ( htmlTag, isInlineTag, isBlockTag ) import Text.Pandoc.Readers.LaTeX ( rawLaTeXInline, rawLaTeXBlock )-import Text.ParserCombinators.Parsec import Text.HTML.TagSoup.Match+import Data.List ( intercalate ) import Data.Char ( digitToInt, isUpper ) import Control.Monad ( guard, liftM ) import Control.Applicative ((<$>), (*>), (<*)) -- | Parse a Textile text and return a Pandoc document.-readTextile :: ParserState -- ^ Parser state, including options for parser- -> String -- ^ String to parse (assuming @'\n'@ line endings)- -> Pandoc-readTextile state s =- (readWith parseTextile) state{ stateOldDashes = True } (s ++ "\n\n")+readTextile :: ReaderOptions -- ^ Reader options+ -> String -- ^ String to parse (assuming @'\n'@ line endings)+ -> Pandoc+readTextile opts s =+ (readWith parseTextile) def{ stateOptions = opts } (s ++ "\n\n") -- | Generate a Pandoc ADT from a textile document-parseTextile :: GenParser Char ParserState Pandoc+parseTextile :: Parser [Char] ParserState Pandoc parseTextile = do -- textile allows raw HTML and does smart punctuation by default- updateState (\state -> state { stateParseRaw = True, stateSmart = True })+ oldOpts <- stateOptions `fmap` getState+ updateState $ \state -> state{ stateOptions =+ oldOpts{ readerSmart = True+ , readerParseRaw = True+ , readerOldDashes = True+ } } many blankline startPos <- getPosition -- go through once just to get list of reference keys and notes@@ -93,10 +97,10 @@ blocks <- parseBlocks return $ Pandoc (Meta [] [] []) blocks -- FIXME -noteMarker :: GenParser Char ParserState [Char]+noteMarker :: Parser [Char] ParserState [Char] noteMarker = skipMany spaceChar >> string "fn" >> manyTill digit (char '.') -noteBlock :: GenParser Char ParserState [Char]+noteBlock :: Parser [Char] ParserState [Char] noteBlock = try $ do startPos <- getPosition ref <- noteMarker@@ -111,37 +115,44 @@ return $ replicate (sourceLine endPos - sourceLine startPos) '\n' -- | Parse document blocks-parseBlocks :: GenParser Char ParserState [Block]+parseBlocks :: Parser [Char] ParserState [Block] parseBlocks = manyTill block eof -- | Block parsers list tried in definition order-blockParsers :: [GenParser Char ParserState Block]+blockParsers :: [Parser [Char] ParserState Block] blockParsers = [ codeBlock , header , blockQuote , hrule+ , commentBlock , anyList , rawHtmlBlock , rawLaTeXBlock' , maybeExplicitBlock "table" table , maybeExplicitBlock "p" para- , nullBlock ]+ ] -- | Any block in the order of definition of blockParsers-block :: GenParser Char ParserState Block+block :: Parser [Char] ParserState Block block = choice blockParsers <?> "block" -codeBlock :: GenParser Char ParserState Block+commentBlock :: Parser [Char] ParserState Block+commentBlock = try $ do+ string "###."+ manyTill anyLine blanklines+ return Null++codeBlock :: Parser [Char] ParserState Block codeBlock = codeBlockBc <|> codeBlockPre -codeBlockBc :: GenParser Char ParserState Block+codeBlockBc :: Parser [Char] ParserState Block codeBlockBc = try $ do string "bc. " contents <- manyTill anyLine blanklines return $ CodeBlock ("",[],[]) $ unlines contents -- | Code Blocks in Textile are between <pre> and </pre>-codeBlockPre :: GenParser Char ParserState Block+codeBlockPre :: Parser [Char] ParserState Block codeBlockPre = try $ do htmlTag (tagOpen (=="pre") null) result' <- manyTill anyChar (try $ htmlTag (tagClose (=="pre")) >> blockBreak)@@ -156,23 +167,28 @@ return $ CodeBlock ("",[],[]) result''' -- | Header of the form "hN. content" with N in 1..6-header :: GenParser Char ParserState Block+header :: Parser [Char] ParserState Block header = try $ do char 'h' level <- digitToInt <$> oneOf "123456"- optional attributes >> char '.' >> whitespace+ attr <- option "" attributes+ let ident = case attr of+ '#':xs -> xs+ _ -> ""+ char '.'+ whitespace name <- normalizeSpaces <$> manyTill inline blockBreak- return $ Header level name+ return $ Header level (ident,[],[]) name -- | Blockquote of the form "bq. content"-blockQuote :: GenParser Char ParserState Block+blockQuote :: Parser [Char] ParserState Block blockQuote = try $ do string "bq" >> optional attributes >> char '.' >> whitespace BlockQuote . singleton <$> para -- Horizontal rule -hrule :: GenParser Char st Block+hrule :: Parser [Char] st Block hrule = try $ do skipSpaces start <- oneOf "-*"@@ -187,62 +203,72 @@ -- | Can be a bullet list or an ordered list. This implementation is -- strict in the nesting, sublist must start at exactly "parent depth -- plus one"-anyList :: GenParser Char ParserState Block-anyList = try $ ( (anyListAtDepth 1) <* blanklines )+anyList :: Parser [Char] ParserState Block+anyList = try $ anyListAtDepth 1 <* blanklines -- | This allow one type of list to be nested into an other type, -- provided correct nesting-anyListAtDepth :: Int -> GenParser Char ParserState Block+anyListAtDepth :: Int -> Parser [Char] ParserState Block anyListAtDepth depth = choice [ bulletListAtDepth depth, orderedListAtDepth depth, definitionList ] -- | Bullet List of given depth, depth being the number of leading '*'-bulletListAtDepth :: Int -> GenParser Char ParserState Block+bulletListAtDepth :: Int -> Parser [Char] ParserState Block bulletListAtDepth depth = try $ BulletList <$> many1 (bulletListItemAtDepth depth) -- | Bullet List Item of given depth, depth being the number of -- leading '*'-bulletListItemAtDepth :: Int -> GenParser Char ParserState [Block]+bulletListItemAtDepth :: Int -> Parser [Char] ParserState [Block] bulletListItemAtDepth = genericListItemAtDepth '*' -- | Ordered List of given depth, depth being the number of -- leading '#'-orderedListAtDepth :: Int -> GenParser Char ParserState Block+orderedListAtDepth :: Int -> Parser [Char] ParserState Block orderedListAtDepth depth = try $ do items <- many1 (orderedListItemAtDepth depth) return (OrderedList (1, DefaultStyle, DefaultDelim) items) -- | Ordered List Item of given depth, depth being the number of -- leading '#'-orderedListItemAtDepth :: Int -> GenParser Char ParserState [Block]+orderedListItemAtDepth :: Int -> Parser [Char] ParserState [Block] orderedListItemAtDepth = genericListItemAtDepth '#' -- | Common implementation of list items-genericListItemAtDepth :: Char -> Int -> GenParser Char ParserState [Block]+genericListItemAtDepth :: Char -> Int -> Parser [Char] ParserState [Block] genericListItemAtDepth c depth = try $ do count depth (char c) >> optional attributes >> whitespace- p <- inlines+ p <- many listInline+ newline sublist <- option [] (singleton <$> anyListAtDepth (depth + 1))- return ((Plain p):sublist)+ return (Plain p : sublist) -- | A definition list is a set of consecutive definition items-definitionList :: GenParser Char ParserState Block +definitionList :: Parser [Char] ParserState Block definitionList = try $ DefinitionList <$> many1 definitionListItem- ++-- | List start character.+listStart :: Parser [Char] st Char+listStart = oneOf "*#-"++listInline :: Parser [Char] ParserState Inline+listInline = try (notFollowedBy newline >> inline)+ <|> try (endline <* notFollowedBy listStart)+ -- | A definition list item in textile begins with '- ', followed by -- the term defined, then spaces and ":=". The definition follows, on -- the same single line, or spaned on multiple line, after a line -- break.-definitionListItem :: GenParser Char ParserState ([Inline], [[Block]])+definitionListItem :: Parser [Char] ParserState ([Inline], [[Block]]) definitionListItem = try $ do string "- " term <- many1Till inline (try (whitespace >> string ":="))- def <- inlineDef <|> multilineDef- return (term, def)- where inlineDef :: GenParser Char ParserState [[Block]]- inlineDef = liftM (\d -> [[Plain d]]) $ try (whitespace >> inlines)- multilineDef :: GenParser Char ParserState [[Block]]+ def' <- multilineDef <|> inlineDef+ return (term, def')+ where inlineDef :: Parser [Char] ParserState [[Block]]+ inlineDef = liftM (\d -> [[Plain d]])+ $ optional whitespace >> many listInline <* newline+ multilineDef :: Parser [Char] ParserState [[Block]] multilineDef = try $ do optional whitespace >> newline s <- many1Till anyChar (try (string "=:" >> newline))@@ -252,77 +278,78 @@ -- | This terminates a block such as a paragraph. Because of raw html -- blocks support, we have to lookAhead for a rawHtmlBlock.-blockBreak :: GenParser Char ParserState ()+blockBreak :: Parser [Char] ParserState () blockBreak = try (newline >> blanklines >> return ()) <|> (lookAhead rawHtmlBlock >> return ()) -- raw content -- | A raw Html Block, optionally followed by blanklines-rawHtmlBlock :: GenParser Char ParserState Block+rawHtmlBlock :: Parser [Char] ParserState Block rawHtmlBlock = try $ do (_,b) <- htmlTag isBlockTag optional blanklines return $ RawBlock "html" b -- | Raw block of LaTeX content-rawLaTeXBlock' :: GenParser Char ParserState Block+rawLaTeXBlock' :: Parser [Char] ParserState Block rawLaTeXBlock' = do- failIfStrict+ guardEnabled Ext_raw_tex RawBlock "latex" <$> (rawLaTeXBlock <* spaces) -- | In textile, paragraphs are separated by blank lines.-para :: GenParser Char ParserState Block+para :: Parser [Char] ParserState Block para = try $ Para . normalizeSpaces <$> manyTill inline blockBreak -- Tables- + -- | A table cell spans until a pipe |-tableCell :: GenParser Char ParserState TableCell+tableCell :: Parser [Char] ParserState TableCell tableCell = do c <- many1 (noneOf "|\n") content <- parseFromString (many1 inline) c return $ [ Plain $ normalizeSpaces content ] -- | A table row is made of many table cells-tableRow :: GenParser Char ParserState [TableCell]-tableRow = try $ ( char '|' *> (endBy1 tableCell (char '|')) <* newline)+tableRow :: Parser [Char] ParserState [TableCell]+tableRow = try $ ( char '|' *>+ (endBy1 tableCell (optional blankline *> char '|')) <* newline) -- | Many table rows-tableRows :: GenParser Char ParserState [[TableCell]]+tableRows :: Parser [Char] ParserState [[TableCell]] tableRows = many1 tableRow -- | Table headers are made of cells separated by a tag "|_."-tableHeaders :: GenParser Char ParserState [TableCell]+tableHeaders :: Parser [Char] ParserState [TableCell] tableHeaders = let separator = (try $ string "|_.") in try $ ( separator *> (sepBy1 tableCell separator) <* char '|' <* newline )- + -- | A table with an optional header. Current implementation can -- handle tables with and without header, but will parse cells -- alignment attributes as content.-table :: GenParser Char ParserState Block+table :: Parser [Char] ParserState Block table = try $ do headers <- option [] tableHeaders rows <- tableRows blanklines let nbOfCols = max (length headers) (length $ head rows)- return $ Table [] + return $ Table [] (replicate nbOfCols AlignDefault) (replicate nbOfCols 0.0) headers rows- + -- | Blocks like 'p' and 'table' do not need explicit block tag. -- However, they can be used to set HTML/CSS attributes when needed. maybeExplicitBlock :: String -- ^ block tag name- -> GenParser Char ParserState Block -- ^ implicit block- -> GenParser Char ParserState Block+ -> Parser [Char] ParserState Block -- ^ implicit block+ -> Parser [Char] ParserState Block maybeExplicitBlock name blk = try $ do- optional $ try $ string name >> optional attributes >> char '.' >> - ((try whitespace) <|> endline)+ optional $ try $ string name >> optional attributes >> char '.' >>+ optional whitespace >> optional endline blk @@ -333,17 +360,12 @@ -- | Any inline element-inline :: GenParser Char ParserState Inline+inline :: Parser [Char] ParserState Inline inline = choice inlineParsers <?> "inline" --- | List of consecutive inlines before a newline-inlines :: GenParser Char ParserState [Inline]-inlines = manyTill inline newline- -- | Inline parsers tried in order-inlineParsers :: [GenParser Char ParserState Inline]-inlineParsers = [ autoLink- , str+inlineParsers :: [Parser [Char] ParserState Inline]+inlineParsers = [ str , whitespace , endline , code@@ -362,42 +384,42 @@ ] -- | Inline markups-inlineMarkup :: GenParser Char ParserState Inline+inlineMarkup :: Parser [Char] ParserState Inline inlineMarkup = choice [ simpleInline (string "??") (Cite []) , simpleInline (string "**") Strong , simpleInline (string "__") Emph , simpleInline (char '*') Strong , simpleInline (char '_') Emph , simpleInline (char '+') Emph -- approximates underline- , simpleInline (char '-') Strikeout+ , simpleInline (char '-' <* notFollowedBy (char '-')) Strikeout , simpleInline (char '^') Superscript , simpleInline (char '~') Subscript ] -- | Trademark, registered, copyright-mark :: GenParser Char st Inline+mark :: Parser [Char] st Inline mark = try $ char '(' >> (try tm <|> try reg <|> copy) -reg :: GenParser Char st Inline+reg :: Parser [Char] st Inline reg = do oneOf "Rr" char ')' return $ Str "\174" -tm :: GenParser Char st Inline+tm :: Parser [Char] st Inline tm = do oneOf "Tt" oneOf "Mm" char ')' return $ Str "\8482" -copy :: GenParser Char st Inline+copy :: Parser [Char] st Inline copy = do oneOf "Cc" char ')' return $ Str "\169" -note :: GenParser Char ParserState Inline+note :: Parser [Char] ParserState Inline note = try $ do ref <- (char '[' *> many1 digit <* char ']') notes <- stateNotes <$> getState@@ -405,9 +427,9 @@ Nothing -> fail "note not found" Just raw -> liftM Note $ parseFromString parseBlocks raw --- | Special chars +-- | Special chars markupChars :: [Char]-markupChars = "\\[]*#_@~-+^|%="+markupChars = "\\*#_@~-+^|%=[]" -- | Break strings on following chars. Space tab and newline break for -- inlines breaking. Open paren breaks for mark. Quote, dash and dot@@ -415,23 +437,28 @@ -- punctuation. Double quote breaks for named links. > and < break -- for inline html. stringBreakers :: [Char]-stringBreakers = " \t\n('-.,:!?;\"<>"+stringBreakers = " \t\n\r.,\"'?!;:<>«»„“”‚‘’()[]" wordBoundaries :: [Char] wordBoundaries = markupChars ++ stringBreakers -- | Parse a hyphened sequence of words-hyphenedWords :: GenParser Char ParserState String-hyphenedWords = try $ do+hyphenedWords :: Parser [Char] ParserState String+hyphenedWords = do+ x <- wordChunk+ xs <- many (try $ char '-' >> wordChunk)+ return $ intercalate "-" (x:xs)++wordChunk :: Parser [Char] ParserState String+wordChunk = try $ do hd <- noneOf wordBoundaries- tl <- many ( (noneOf wordBoundaries) <|> - try (oneOf markupChars <* lookAhead (noneOf wordBoundaries) ) )- let wd = hd:tl- option wd $ try $ - (\r -> concat [wd, "-", r]) <$> (char '-' *> hyphenedWords)+ tl <- many ( (noneOf wordBoundaries) <|>+ try (notFollowedBy' note *> oneOf markupChars+ <* lookAhead (noneOf wordBoundaries) ) )+ return $ hd:tl -- | Any string-str :: GenParser Char ParserState Inline+str :: Parser [Char] ParserState Inline str = do baseStr <- hyphenedWords -- RedCloth compliance : if parsed word is uppercase and immediatly@@ -444,44 +471,53 @@ return $ Str fullStr -- | Textile allows HTML span infos, we discard them-htmlSpan :: GenParser Char ParserState Inline+htmlSpan :: Parser [Char] ParserState Inline htmlSpan = try $ Str <$> ( char '%' *> attributes *> manyTill anyChar (char '%') ) -- | Some number of space chars-whitespace :: GenParser Char ParserState Inline+whitespace :: Parser [Char] ParserState Inline whitespace = many1 spaceChar >> return Space <?> "whitespace" -- | In Textile, an isolated endline character is a line break-endline :: GenParser Char ParserState Inline+endline :: Parser [Char] ParserState Inline endline = try $ do newline >> notFollowedBy blankline return LineBreak -rawHtmlInline :: GenParser Char ParserState Inline+rawHtmlInline :: Parser [Char] ParserState Inline rawHtmlInline = RawInline "html" . snd <$> htmlTag isInlineTag- --- | Raw LaTeX Inline -rawLaTeXInline' :: GenParser Char ParserState Inline++-- | Raw LaTeX Inline+rawLaTeXInline' :: Parser [Char] ParserState Inline rawLaTeXInline' = try $ do- failIfStrict+ guardEnabled Ext_raw_tex rawLaTeXInline --- | Textile standard link syntax is "label":target-link :: GenParser Char ParserState Inline-link = try $ do+-- | Textile standard link syntax is "label":target. But we+-- can also have ["label":target].+link :: Parser [Char] ParserState Inline+link = linkB <|> linkNoB++linkNoB :: Parser [Char] ParserState Inline+linkNoB = try $ do name <- surrounded (char '"') inline char ':'- url <- manyTill (anyChar) (lookAhead $ (space <|> try (oneOf ".;,:" >> (space <|> newline))))- return $ Link name (url, "")+ let stopChars = "!.,;:"+ url <- manyTill nonspaceChar (lookAhead $ space <|> try (oneOf stopChars >> (space <|> newline)))+ let name' = if name == [Str "$"] then [Str url] else name+ return $ Link name' (url, "") --- | Detect plain links to http or email.-autoLink :: GenParser Char ParserState Inline-autoLink = do- (orig, src) <- (try uri <|> try emailAddress)- return $ Link [Str orig] (src, "")+linkB :: Parser [Char] ParserState Inline+linkB = try $ do+ char '['+ name <- surrounded (char '"') inline+ char ':'+ url <- manyTill nonspaceChar (char ']')+ let name' = if name == [Str "$"] then [Str url] else name+ return $ Link name' (url, "") -- | image embedding-image :: GenParser Char ParserState Inline+image :: Parser [Char] ParserState Inline image = try $ do char '!' >> notFollowedBy space src <- manyTill anyChar (lookAhead $ oneOf "!(")@@ -489,49 +525,49 @@ char '!' return $ Image [Str alt] (src, alt) -escapedInline :: GenParser Char ParserState Inline+escapedInline :: Parser [Char] ParserState Inline escapedInline = escapedEqs <|> escapedTag -escapedEqs :: GenParser Char ParserState Inline+escapedEqs :: Parser [Char] ParserState Inline escapedEqs = Str <$> (try $ string "==" *> manyTill anyChar (try $ string "==")) -- | literal text escaped btw <notextile> tags-escapedTag :: GenParser Char ParserState Inline+escapedTag :: Parser [Char] ParserState Inline escapedTag = Str <$> (try $ string "<notextile>" *> manyTill anyChar (try $ string "</notextile>")) -- | Any special symbol defined in wordBoundaries-symbol :: GenParser Char ParserState Inline-symbol = Str . singleton <$> oneOf wordBoundaries+symbol :: Parser [Char] ParserState Inline+symbol = Str . singleton <$> (oneOf wordBoundaries <|> oneOf markupChars) -- | Inline code-code :: GenParser Char ParserState Inline+code :: Parser [Char] ParserState Inline code = code1 <|> code2 -code1 :: GenParser Char ParserState Inline+code1 :: Parser [Char] ParserState Inline code1 = Code nullAttr <$> surrounded (char '@') anyChar -code2 :: GenParser Char ParserState Inline+code2 :: Parser [Char] ParserState Inline code2 = do htmlTag (tagOpen (=="tt") null) Code nullAttr <$> manyTill anyChar (try $ htmlTag $ tagClose (=="tt")) -- | Html / CSS attributes-attributes :: GenParser Char ParserState String+attributes :: Parser [Char] ParserState String attributes = choice [ enclosed (char '(') (char ')') anyChar, enclosed (char '{') (char '}') anyChar, enclosed (char '[') (char ']') anyChar] -- | Parses material surrounded by a parser.-surrounded :: GenParser Char st t -- ^ surrounding parser- -> GenParser Char st a -- ^ content parser (to be used repeatedly)- -> GenParser Char st [a]-surrounded border = enclosed border (try border)+surrounded :: Parser [Char] st t -- ^ surrounding parser+ -> Parser [Char] st a -- ^ content parser (to be used repeatedly)+ -> Parser [Char] st [a]+surrounded border = enclosed (border *> notFollowedBy (oneOf " \t\n\r")) (try border) -- | Inlines are most of the time of the same form-simpleInline :: GenParser Char ParserState t -- ^ surrounding parser+simpleInline :: Parser [Char] ParserState t -- ^ surrounding parser -> ([Inline] -> Inline) -- ^ Inline constructor- -> GenParser Char ParserState Inline -- ^ content parser (to be used repeatedly)+ -> Parser [Char] ParserState Inline -- ^ content parser (to be used repeatedly) simpleInline border construct = surrounded border (inlineWithAttribute) >>= return . construct . normalizeSpaces where inlineWithAttribute = (try $ optional attributes) >> inline
@@ -32,52 +32,19 @@ -} module Text.Pandoc.SelfContained ( makeSelfContained ) where import Text.HTML.TagSoup-import Network.URI (isAbsoluteURI, parseURI, escapeURIString)-import Network.HTTP+import Network.URI (isAbsoluteURI, escapeURIString) import Data.ByteString.Base64 import qualified Data.ByteString.Char8 as B import Data.ByteString (ByteString)-import Data.ByteString.UTF8 (toString, fromString) import System.FilePath (takeExtension, dropExtension, takeDirectory, (</>)) import Data.Char (toLower, isAscii, isAlphaNum) import Codec.Compression.GZip as Gzip import qualified Data.ByteString.Lazy as L-import Text.Pandoc.Shared (findDataFile)+import Text.Pandoc.Shared (renderTags', openURL, readDataFile)+import Text.Pandoc.UTF8 (toString, fromString) import Text.Pandoc.MIME (getMimeType) import System.Directory (doesFileExist) -getItem :: Maybe FilePath -> String -> IO (ByteString, Maybe String)-getItem userdata f =- if isAbsoluteURI f- then openURL f- else do- let mime = case takeExtension f of- ".gz" -> getMimeType $ dropExtension f- x -> getMimeType x- exists <- doesFileExist f- if exists- then do- cont <- B.readFile f- return (cont, mime)- else do- res <- findDataFile userdata f- exists' <- doesFileExist res- if exists'- then do- cont <- B.readFile res- return (cont, mime)- else error $ "Could not find `" ++ f ++ "'"---- TODO - have this return mime type too - then it can work for google--- chart API, e.g.-openURL :: String -> IO (ByteString, Maybe String)-openURL u = getBodyAndMimeType =<< simpleHTTP (getReq u)- where getReq v = case parseURI v of- Nothing -> error $ "Could not parse URI: " ++ v- Just u' -> mkRequest GET u'- getBodyAndMimeType (Left err) = fail (show err)- getBodyAndMimeType (Right r) = return (rspBody r, findHeader HdrContentType r)- isOk :: Char -> Bool isOk c = isAscii c && isAlphaNum c @@ -102,14 +69,14 @@ src -> do (raw, mime) <- getRaw userdata (fromAttrib "type" t) src let enc = "data:" ++ mime ++ "," ++ escapeURIString isOk (toString raw)- return $ TagOpen "script" (("src",enc) : [(x,y) | (x,y) <- as, x /= "src"]) + return $ TagOpen "script" (("src",enc) : [(x,y) | (x,y) <- as, x /= "src"]) convertTag userdata t@(TagOpen "link" as) = case fromAttrib "href" t of [] -> return t src -> do (raw, mime) <- getRaw userdata (fromAttrib "type" t) src let enc = "data:" ++ mime ++ "," ++ escapeURIString isOk (toString raw)- return $ TagOpen "link" (("href",enc) : [(x,y) | (x,y) <- as, x /= "href"]) + return $ TagOpen "link" (("href",enc) : [(x,y) | (x,y) <- as, x /= "href"]) convertTag _ t = return t cssURLs :: Maybe FilePath -> FilePath -> ByteString -> IO ByteString@@ -132,6 +99,18 @@ ";base64," `B.append` (encode raw) return $ x `B.append` "url(" `B.append` enc `B.append` rest +getItem :: Maybe FilePath -> String -> IO (ByteString, Maybe String)+getItem userdata f =+ if isAbsoluteURI f+ then openURL f+ else do+ let mime = case takeExtension f of+ ".gz" -> getMimeType $ dropExtension f+ x -> getMimeType x+ exists <- doesFileExist f+ cont <- if exists then B.readFile f else readDataFile userdata f+ return (cont, mime)+ getRaw :: Maybe FilePath -> String -> String -> IO (ByteString, String) getRaw userdata mimetype src = do let ext = map toLower $ takeExtension src@@ -163,14 +142,3 @@ out' <- mapM (convertTag userdata) tags return $ renderTags' out' --- repeated from HTML reader:-renderTags' :: [Tag String] -> String-renderTags' = renderTagsOptions- renderOptions{ optMinimize = \x ->- let y = map toLower x- in y == "hr" || y == "br" ||- y == "img" || y == "meta" ||- y == "link"- , optRawTag = \x ->- let y = map toLower x- in y == "script" || y == "style" }
@@ -1,4 +1,4 @@-{-# LANGUAGE DeriveDataTypeable #-}+{-# LANGUAGE DeriveDataTypeable, CPP, TemplateHaskell #-} {- Copyright (C) 2006-2010 John MacFarlane <jgm@berkeley.edu> @@ -20,7 +20,7 @@ {- | Module : Text.Pandoc.Shared Copyright : Copyright (C) 2006-2010 John MacFarlane- License : GNU GPL, version 2 or above + License : GNU GPL, version 2 or above Maintainer : John MacFarlane <jgm@berkeley.edu> Stability : alpha@@ -38,9 +38,9 @@ backslashEscapes, escapeStringUsing, stripTrailingNewlines,- removeLeadingTrailingSpace,- removeLeadingSpace,- removeTrailingSpace,+ trim,+ triml,+ trimr, stripFirstAndLast, camelCaseToHyphenated, toRomanNumeral,@@ -54,47 +54,59 @@ normalize, stringify, compactify,+ compactify', Element (..), hierarchicalize, uniqueIdent, isHeaderBlock, headerShift,- -- * Writer options- HTMLMathMethod (..),- CiteMethod (..),- ObfuscationMethod (..),- HTMLSlideVariant (..),- WriterOptions (..),- defaultWriterOptions,+ isTightList,+ -- * TagSoup HTML handling+ renderTags', -- * File handling inDirectory,- findDataFile, readDataFile,+ readDataFileUTF8,+ fetchItem,+ openURL, -- * Error handling err, warn,+ -- * Safe read+ safeRead ) where import Text.Pandoc.Definition import Text.Pandoc.Generic+import Text.Pandoc.Builder (Blocks)+import qualified Text.Pandoc.Builder as B import qualified Text.Pandoc.UTF8 as UTF8 import System.Environment (getProgName) import System.Exit (exitWith, ExitCode(..)) import Data.Char ( toLower, isLower, isUpper, isAlpha, isLetter, isDigit, isSpace ) import Data.List ( find, isPrefixOf, intercalate )-import Network.URI ( escapeURIString )+import Network.URI ( escapeURIString, isAbsoluteURI, parseURI ) import System.Directory-import System.FilePath ( (</>) )+import Text.Pandoc.MIME (getMimeType)+import System.FilePath ( (</>), takeExtension, dropExtension ) import Data.Generics (Typeable, Data) import qualified Control.Monad.State as S import Control.Monad (msum)-import Paths_pandoc (getDataFileName)-import Text.Pandoc.Highlighting (Style, pygments) import Text.Pandoc.Pretty (charWidth) import System.Locale (defaultTimeLocale) import Data.Time import System.IO (stderr)+import Text.HTML.TagSoup (renderTagsOptions, RenderOptions(..), Tag(..),+ renderOptions)+import qualified Data.ByteString as B+import Network.HTTP (findHeader, rspBody, simpleHTTP, RequestMethod(..),+ HeaderName(..), mkRequest)+#ifdef EMBED_DATA_FILES+import Data.FileEmbed+#else+import Paths_pandoc (getDataFileName)+#endif -- -- List processing@@ -149,7 +161,7 @@ -- characters and strings. escapeStringUsing :: [(Char, String)] -> String -> String escapeStringUsing _ [] = ""-escapeStringUsing escapeTable (x:xs) = +escapeStringUsing escapeTable (x:xs) = case (lookup x escapeTable) of Just str -> str ++ rest Nothing -> x:rest@@ -160,23 +172,23 @@ stripTrailingNewlines = reverse . dropWhile (== '\n') . reverse -- | Remove leading and trailing space (including newlines) from string.-removeLeadingTrailingSpace :: String -> String-removeLeadingTrailingSpace = removeLeadingSpace . removeTrailingSpace+trim :: String -> String+trim = triml . trimr -- | Remove leading space (including newlines) from string.-removeLeadingSpace :: String -> String-removeLeadingSpace = dropWhile (`elem` " \n\t")+triml :: String -> String+triml = dropWhile (`elem` " \r\n\t") -- | Remove trailing space (including newlines) from string.-removeTrailingSpace :: String -> String-removeTrailingSpace = reverse . removeLeadingSpace . reverse+trimr :: String -> String+trimr = reverse . triml . reverse -- | Strip leading and trailing characters from string stripFirstAndLast :: String -> String stripFirstAndLast str = drop 1 $ take ((length str) - 1) str --- | Change CamelCase word to hyphenated lowercase (e.g., camel-case). +-- | Change CamelCase word to hyphenated lowercase (e.g., camel-case). camelCaseToHyphenated :: String -> String camelCaseToHyphenated [] = "" camelCaseToHyphenated (a:b:rest) | isLower a && isUpper b =@@ -247,13 +259,13 @@ -- | Generate infinite lazy list of markers for an ordered list, -- depending on list attributes. orderedListMarkers :: (Int, ListNumberStyle, ListNumberDelim) -> [String]-orderedListMarkers (start, numstyle, numdelim) = +orderedListMarkers (start, numstyle, numdelim) = let singleton c = [c] nums = case numstyle of DefaultStyle -> map show [start..] Example -> map show [start..] Decimal -> map show [start..]- UpperAlpha -> drop (start - 1) $ cycle $ + UpperAlpha -> drop (start - 1) $ cycle $ map singleton ['A'..'Z'] LowerAlpha -> drop (start - 1) $ cycle $ map singleton ['a'..'z']@@ -271,13 +283,12 @@ -- remove empty Str elements. normalizeSpaces :: [Inline] -> [Inline] normalizeSpaces = cleanup . dropWhile isSpaceOrEmpty- where cleanup [] = []- cleanup (Space:rest) = let rest' = dropWhile isSpaceOrEmpty rest- in case rest' of- [] -> []- _ -> Space : cleanup rest'+ where cleanup [] = []+ cleanup (Space:rest) = case dropWhile isSpaceOrEmpty rest of+ [] -> []+ (x:xs) -> Space : x : cleanup xs cleanup ((Str ""):rest) = cleanup rest- cleanup (x:rest) = x : cleanup rest+ cleanup (x:rest) = x : cleanup rest isSpaceOrEmpty :: Inline -> Bool isSpaceOrEmpty Space = True@@ -381,12 +392,27 @@ _ -> items _ -> items +-- | Change final list item from @Para@ to @Plain@ if the list contains+-- no other @Para@ blocks. Like compactify, but operates on @Blocks@ rather+-- than @[Block]@.+compactify' :: [Blocks] -- ^ List of list items (each a list of blocks)+ -> [Blocks]+compactify' [] = []+compactify' items =+ let (others, final) = (init items, last items)+ in case reverse (B.toList final) of+ (Para a:xs) -> case [Para x | Para x <- concatMap B.toList items] of+ -- if this is only Para, change to Plain+ [_] -> others ++ [B.fromList (reverse $ Plain a : xs)]+ _ -> items+ _ -> items+ isPara :: Block -> Bool isPara (Para _) = True isPara _ = False -- | Data structure for defining hierarchical Pandoc documents-data Element = Blk Block +data Element = Blk Block | Sec Int [Int] String [Inline] [Element] -- lvl num ident label contents deriving (Eq, Read, Show, Typeable, Data)@@ -405,18 +431,17 @@ -- | Convert list of Pandoc blocks into (hierarchical) list of Elements hierarchicalize :: [Block] -> [Element]-hierarchicalize blocks = S.evalState (hierarchicalizeWithIds blocks) ([],[])+hierarchicalize blocks = S.evalState (hierarchicalizeWithIds blocks) [] -hierarchicalizeWithIds :: [Block] -> S.State ([Int],[String]) [Element]+hierarchicalizeWithIds :: [Block] -> S.State [Int] [Element] hierarchicalizeWithIds [] = return []-hierarchicalizeWithIds ((Header level title'):xs) = do- (lastnum, usedIdents) <- S.get- let ident = uniqueIdent title' usedIdents+hierarchicalizeWithIds ((Header level (ident,_,_) title'):xs) = do+ lastnum <- S.get let lastnum' = take level lastnum let newnum = if length lastnum' >= level- then init lastnum' ++ [last lastnum' + 1] + then init lastnum' ++ [last lastnum' + 1] else lastnum ++ replicate (level - length lastnum - 1) 0 ++ [1]- S.put (newnum, (ident : usedIdents))+ S.put newnum let (sectionContents, rest) = break (headerLtEq level) xs sectionContents' <- hierarchicalizeWithIds sectionContents rest' <- hierarchicalizeWithIds rest@@ -426,7 +451,7 @@ return $ (Blk x) : rest' headerLtEq :: Int -> Block -> Bool-headerLtEq level (Header l _) = l <= level+headerLtEq level (Header l _ _) = l <= level headerLtEq _ _ = False -- | Generate a unique identifier from a list of inlines.@@ -445,123 +470,37 @@ -- | True if block is a Header block. isHeaderBlock :: Block -> Bool-isHeaderBlock (Header _ _) = True+isHeaderBlock (Header _ _ _) = True isHeaderBlock _ = False -- | Shift header levels up or down. headerShift :: Int -> Pandoc -> Pandoc headerShift n = bottomUp shift where shift :: Block -> Block- shift (Header level inner) = Header (level + n) inner- shift x = x+ shift (Header level attr inner) = Header (level + n) attr inner+ shift x = x +-- | Detect if a list is tight.+isTightList :: [[Block]] -> Bool+isTightList = and . map firstIsPlain+ where firstIsPlain (Plain _ : _) = True+ firstIsPlain _ = False+ ----- Writer options+-- TagSoup HTML handling -- -data HTMLMathMethod = PlainMath - | LaTeXMathML (Maybe String) -- url of LaTeXMathML.js- | JsMath (Maybe String) -- url of jsMath load script- | GladTeX- | WebTeX String -- url of TeX->image script.- | MathML (Maybe String) -- url of MathMLinHTML.js- | MathJax String -- url of MathJax.js- deriving (Show, Read, Eq)--data CiteMethod = Citeproc -- use citeproc to render them- | Natbib -- output natbib cite commands- | Biblatex -- output biblatex cite commands- deriving (Show, Read, Eq)---- | Methods for obfuscating email addresses in HTML.-data ObfuscationMethod = NoObfuscation- | ReferenceObfuscation- | JavascriptObfuscation- deriving (Show, Read, Eq)---- | Varieties of HTML slide shows.-data HTMLSlideVariant = S5Slides- | SlidySlides- | SlideousSlides- | DZSlides- | NoSlides- deriving (Show, Read, Eq)---- | Options for writers-data WriterOptions = WriterOptions- { writerStandalone :: Bool -- ^ Include header and footer- , writerTemplate :: String -- ^ Template to use in standalone mode- , writerVariables :: [(String, String)] -- ^ Variables to set in template- , writerEPUBMetadata :: String -- ^ Metadata to include in EPUB- , writerTabStop :: Int -- ^ Tabstop for conversion btw spaces and tabs- , writerTableOfContents :: Bool -- ^ Include table of contents- , writerSlideVariant :: HTMLSlideVariant -- ^ Are we writing S5, Slidy or Slideous?- , writerIncremental :: Bool -- ^ True if lists should be incremental- , writerXeTeX :: Bool -- ^ Create latex suitable for use by xetex- , writerHTMLMathMethod :: HTMLMathMethod -- ^ How to print math in HTML- , writerIgnoreNotes :: Bool -- ^ Ignore footnotes (used in making toc)- , writerNumberSections :: Bool -- ^ Number sections in LaTeX- , writerSectionDivs :: Bool -- ^ Put sections in div tags in HTML- , writerStrictMarkdown :: Bool -- ^ Use strict markdown syntax- , writerReferenceLinks :: Bool -- ^ Use reference links in writing markdown, rst- , writerWrapText :: Bool -- ^ Wrap text to line length- , writerColumns :: Int -- ^ Characters in a line (for text wrapping)- , writerLiterateHaskell :: Bool -- ^ Write as literate haskell- , writerEmailObfuscation :: ObfuscationMethod -- ^ How to obfuscate emails- , writerIdentifierPrefix :: String -- ^ Prefix for section & note ids in HTML- , writerSourceDirectory :: FilePath -- ^ Directory path of 1st source file- , writerUserDataDir :: Maybe FilePath -- ^ Path of user data directory- , writerCiteMethod :: CiteMethod -- ^ How to print cites- , writerBiblioFiles :: [FilePath] -- ^ Biblio files to use for citations- , writerHtml5 :: Bool -- ^ Produce HTML5- , writerBeamer :: Bool -- ^ Produce beamer LaTeX slide show- , writerSlideLevel :: Maybe Int -- ^ Force header level of slides- , writerChapters :: Bool -- ^ Use "chapter" for top-level sects- , writerListings :: Bool -- ^ Use listings package for code- , writerHighlight :: Bool -- ^ Highlight source code- , writerHighlightStyle :: Style -- ^ Style to use for highlighting- , writerSetextHeaders :: Bool -- ^ Use setext headers for levels 1-2 in markdown- , writerTeXLigatures :: Bool -- ^ Use tex ligatures quotes, dashes in latex- } deriving Show--{-# DEPRECATED writerXeTeX "writerXeTeX no longer does anything" #-}--- | Default writer options.-defaultWriterOptions :: WriterOptions-defaultWriterOptions = - WriterOptions { writerStandalone = False- , writerTemplate = ""- , writerVariables = []- , writerEPUBMetadata = ""- , writerTabStop = 4- , writerTableOfContents = False- , writerSlideVariant = NoSlides- , writerIncremental = False- , writerXeTeX = False- , writerHTMLMathMethod = PlainMath- , writerIgnoreNotes = False- , writerNumberSections = False- , writerSectionDivs = False- , writerStrictMarkdown = False- , writerReferenceLinks = False- , writerWrapText = True- , writerColumns = 72- , writerLiterateHaskell = False- , writerEmailObfuscation = JavascriptObfuscation- , writerIdentifierPrefix = ""- , writerSourceDirectory = "."- , writerUserDataDir = Nothing- , writerCiteMethod = Citeproc- , writerBiblioFiles = []- , writerHtml5 = False- , writerBeamer = False- , writerSlideLevel = Nothing- , writerChapters = False- , writerListings = False- , writerHighlight = False- , writerHighlightStyle = pygments- , writerSetextHeaders = True- , writerTeXLigatures = True- }+-- | Render HTML tags.+renderTags' :: [Tag String] -> String+renderTags' = renderTagsOptions+ renderOptions{ optMinimize = \x ->+ let y = map toLower x+ in y == "hr" || y == "br" ||+ y == "img" || y == "meta" ||+ y == "link"+ , optRawTag = \x ->+ let y = map toLower x+ in y == "script" || y == "style" } -- -- File handling@@ -576,21 +515,63 @@ setCurrentDirectory oldDir return result --- | Get file path for data file, either from specified user data directory,--- or, if not found there, from Cabal data directory.-findDataFile :: Maybe FilePath -> FilePath -> IO FilePath-findDataFile Nothing f = getDataFileName f-findDataFile (Just u) f = do- ex <- doesFileExist (u </> f)- if ex- then return (u </> f)- else getDataFileName f+#ifdef EMBED_DATA_FILES+dataFiles :: [(FilePath, B.ByteString)]+dataFiles = $(embedDir "data")+#endif +readDefaultDataFile :: FilePath -> IO B.ByteString+readDefaultDataFile fname =+#ifdef EMBED_DATA_FILES+ case lookup fname dataFiles of+ Nothing -> ioError $ userError+ $ "Data file `" ++ fname ++ "' does not exist"+ Just contents -> return contents+#else+ getDataFileName ("data" </> fname) >>= B.readFile+#endif+ -- | Read file from specified user data directory or, if not found there, from -- Cabal data directory.-readDataFile :: Maybe FilePath -> FilePath -> IO String-readDataFile userDir fname = findDataFile userDir fname >>= UTF8.readFile+readDataFile :: Maybe FilePath -> FilePath -> IO B.ByteString+readDataFile Nothing fname = readDefaultDataFile fname+readDataFile (Just userDir) fname = do+ exists <- doesFileExist (userDir </> fname)+ if exists+ then B.readFile (userDir </> fname)+ else readDefaultDataFile fname +-- | Same as 'readDataFile' but returns a String instead of a ByteString.+readDataFileUTF8 :: Maybe FilePath -> FilePath -> IO String+readDataFileUTF8 userDir fname =+ UTF8.toString `fmap` readDataFile userDir fname++-- | Fetch an image or other item from the local filesystem or the net.+-- Returns raw content and maybe mime type.+fetchItem :: String -> String -> IO (B.ByteString, Maybe String)+fetchItem sourceDir s =+ case s of+ _ | isAbsoluteURI s -> openURL s+ | isAbsoluteURI sourceDir -> openURL $ sourceDir ++ "/" ++ s+ | otherwise -> do+ let mime = case takeExtension s of+ ".gz" -> getMimeType $ dropExtension s+ x -> getMimeType x+ let f = sourceDir </> s+ cont <- B.readFile f+ return (cont, mime)++-- TODO - have this return mime type too - then it can work for google+-- chart API, e.g.+-- | Read from a URL and return raw data and maybe mime type.+openURL :: String -> IO (B.ByteString, Maybe String)+openURL u = getBodyAndMimeType =<< simpleHTTP (getReq u)+ where getReq v = case parseURI v of+ Nothing -> error $ "Could not parse URI: " ++ v+ Just u' -> mkRequest GET u'+ getBodyAndMimeType (Left e) = fail (show e)+ getBodyAndMimeType (Right r) = return (rspBody r, findHeader HdrContentType r)+ -- -- Error reporting --@@ -606,3 +587,15 @@ warn msg = do name <- getProgName UTF8.hPutStrLn stderr $ name ++ ": " ++ msg++--+-- Safe read+--++safeRead :: (Monad m, Read a) => String -> m a+safeRead s = case reads s of+ (d,x):_+ | all isSpace x -> return d+ _ -> fail $ "Could not read `" ++ s ++ "'"++
@@ -35,24 +35,24 @@ -- level that occurs before a non-header/non-hrule in the blocks). getSlideLevel :: [Block] -> Int getSlideLevel = go 6- where go least (Header n _ : x : xs)+ where go least (Header n _ _ : x : xs) | n < least && nonHOrHR x = go n xs | otherwise = go least (x:xs) go least (_ : xs) = go least xs go least [] = least- nonHOrHR (Header _ _) = False+ nonHOrHR (Header _ _ _) = False nonHOrHR (HorizontalRule) = False nonHOrHR _ = True -- | Prepare a block list to be passed to hierarchicalize. prepSlides :: Int -> [Block] -> [Block] prepSlides slideLevel = ensureStartWithH . splitHrule- where splitHrule (HorizontalRule : Header n xs : ys)- | n == slideLevel = Header slideLevel xs : splitHrule ys- splitHrule (HorizontalRule : xs) = Header slideLevel [Str "\0"] :+ where splitHrule (HorizontalRule : Header n attr xs : ys)+ | n == slideLevel = Header slideLevel attr xs : splitHrule ys+ splitHrule (HorizontalRule : xs) = Header slideLevel nullAttr [Str "\0"] : splitHrule xs splitHrule (x : xs) = x : splitHrule xs splitHrule [] = []- ensureStartWithH bs@(Header n _:_)+ ensureStartWithH bs@(Header n _ _:_) | n <= slideLevel = bs- ensureStartWithH bs = Header slideLevel [Str "\0"] : bs+ ensureStartWithH bs = Header slideLevel nullAttr [Str "\0"] : bs
@@ -30,7 +30,7 @@ Example: > renderTemplate [("name","Sam"),("salary","50,000")] $-> "Hi, $name$. $if(salary)$You make $$$salary$.$else$No salary data.$endif$" +> "Hi, $name$. $if(salary)$You make $$$salary$.$else$No salary data.$endif$" > "Hi, John. You make $50,000." A slot for an interpolated variable is a variable name surrounded@@ -68,8 +68,8 @@ , TemplateTarget , getDefaultTemplate ) where -import Text.ParserCombinators.Parsec-import Control.Monad (liftM, when, forM)+import Text.Parsec+import Control.Monad (liftM, when, forM, mzero) import System.FilePath import Data.List (intercalate, intersperse) #if MIN_VERSION_blaze_html(0,5,0)@@ -78,27 +78,31 @@ #else import Text.Blaze (preEscapedString, Html) #endif-import Data.ByteString.Lazy.UTF8 (ByteString, fromString)-import Text.Pandoc.Shared (readDataFile)+import Text.Pandoc.UTF8 (fromStringLazy)+import Data.ByteString.Lazy (ByteString)+import Text.Pandoc.Shared (readDataFileUTF8) import qualified Control.Exception.Extensible as E (try, IOException) -- | Get default template for the specified writer.-getDefaultTemplate :: (Maybe FilePath) -- ^ User data directory to search first - -> String -- ^ Name of writer +getDefaultTemplate :: (Maybe FilePath) -- ^ User data directory to search first+ -> String -- ^ Name of writer -> IO (Either E.IOException String)-getDefaultTemplate _ "native" = return $ Right ""-getDefaultTemplate _ "json" = return $ Right ""-getDefaultTemplate _ "docx" = return $ Right ""-getDefaultTemplate user "odt" = getDefaultTemplate user "opendocument"-getDefaultTemplate user "epub" = getDefaultTemplate user "html" getDefaultTemplate user writer = do- let format = takeWhile (/='+') writer -- strip off "+lhs" if present- let fname = "templates" </> "default" <.> format- E.try $ readDataFile user fname+ let format = takeWhile (`notElem` "+-") writer -- strip off extensions+ case format of+ "native" -> return $ Right ""+ "json" -> return $ Right ""+ "docx" -> return $ Right ""+ "odt" -> getDefaultTemplate user "opendocument"+ "markdown_strict" -> getDefaultTemplate user "markdown"+ "multimarkdown" -> getDefaultTemplate user "markdown"+ "markdown_github" -> getDefaultTemplate user "markdown"+ _ -> let fname = "templates" </> "default" <.> format+ in E.try $ readDataFileUTF8 user fname data TemplateState = TemplateState Int [(String,String)] -adjustPosition :: String -> GenParser Char TemplateState String+adjustPosition :: String -> Parsec [Char] TemplateState String adjustPosition str = do let lastline = takeWhile (/= '\n') $ reverse str updateState $ \(TemplateState pos x) ->@@ -108,18 +112,18 @@ return str class TemplateTarget a where- toTarget :: String -> a + toTarget :: String -> a instance TemplateTarget String where toTarget = id -instance TemplateTarget ByteString where - toTarget = fromString+instance TemplateTarget ByteString where+ toTarget = fromStringLazy instance TemplateTarget Html where toTarget = preEscapedString --- | Renders a template +-- | Renders a template renderTemplate :: TemplateTarget a => [(String,String)] -- ^ Assoc. list of values for variables -> String -- ^ Template@@ -132,21 +136,21 @@ reservedWords :: [String] reservedWords = ["else","endif","for","endfor","sep"] -parseTemplate :: GenParser Char TemplateState [String]+parseTemplate :: Parsec [Char] TemplateState [String] parseTemplate = many $ (plaintext <|> escapedDollar <|> conditional <|> for <|> variable) >>= adjustPosition -plaintext :: GenParser Char TemplateState String+plaintext :: Parsec [Char] TemplateState String plaintext = many1 $ noneOf "$" -escapedDollar :: GenParser Char TemplateState String+escapedDollar :: Parsec [Char] TemplateState String escapedDollar = try $ string "$$" >> return "$" -skipEndline :: GenParser Char st ()+skipEndline :: Parsec [Char] st () skipEndline = try $ skipMany (oneOf " \t") >> newline >> return () -conditional :: GenParser Char TemplateState String+conditional :: Parsec [Char] TemplateState String conditional = try $ do TemplateState pos vars <- getState string "$if("@@ -170,7 +174,7 @@ then ifContents else elseContents -for :: GenParser Char TemplateState String+for :: Parsec [Char] TemplateState String for = try $ do TemplateState pos vars <- getState string "$for("@@ -178,14 +182,14 @@ string ")$" -- if newline after the "for", then a newline after "endfor" will be swallowed multiline <- option False $ try $ skipEndline >> return True- let matches = filter (\(k,_) -> k == id') vars + let matches = filter (\(k,_) -> k == id') vars let indent = replicate pos ' ' contents <- forM matches $ \m -> do updateState $ \(TemplateState p v) -> TemplateState p (m:v) raw <- liftM concat $ lookAhead parseTemplate return $ intercalate ('\n':indent) $ lines $ raw ++ "\n" parseTemplate- sep <- option "" $ do try (string "$sep$") + sep <- option "" $ do try (string "$sep$") when multiline $ optional skipEndline liftM concat parseTemplate string "$endfor$"@@ -193,16 +197,16 @@ setState $ TemplateState pos vars return $ concat $ intersperse sep contents -ident :: GenParser Char TemplateState String+ident :: Parsec [Char] TemplateState String ident = do first <- letter rest <- many (alphaNum <|> oneOf "_-") let id' = first : rest if id' `elem` reservedWords- then pzero+ then mzero else return id' -variable :: GenParser Char TemplateState String+variable :: Parsec [Char] TemplateState String variable = try $ do char '$' id' <- ident
@@ -19,7 +19,7 @@ {- | Module : Text.Pandoc.UTF8 Copyright : Copyright (C) 2010 John MacFarlane- License : GNU GPL, version 2 or above + License : GNU GPL, version 2 or above Maintainer : John MacFarlane <jgm@berkeley.edu> Stability : alpha@@ -35,21 +35,27 @@ , hPutStr , hPutStrLn , hGetContents+ , toString+ , fromString+ , toStringLazy+ , fromStringLazy+ , encodePath+ , decodeArg ) where -#if MIN_VERSION_base(4,4,0)-#else-import Codec.Binary.UTF8.String (encodeString)-#endif--#if MIN_VERSION_base(4,2,0)- import System.IO hiding (readFile, writeFile, getContents, putStr, putStrLn, hPutStr, hPutStrLn, hGetContents)-import Prelude hiding (readFile, writeFile, getContents, putStr, putStrLn )+import Prelude hiding (readFile, writeFile, getContents, putStr, putStrLn,+ catch) import qualified System.IO as IO+import qualified Data.ByteString.Char8 as B+import qualified Data.ByteString.Lazy as BL+import qualified Data.Text.Encoding as T+import qualified Data.Text as T+import qualified Data.Text.Lazy as TL+import qualified Data.Text.Lazy.Encoding as TL readFile :: FilePath -> IO String readFile f = do@@ -75,53 +81,33 @@ hPutStrLn h s = hSetEncoding h utf8 >> IO.hPutStrLn h s hGetContents :: Handle -> IO String-hGetContents h = hSetEncoding h utf8_bom >> IO.hGetContents h--#else--import qualified Data.ByteString as B-import Data.ByteString.UTF8 (toString, fromString)-import Prelude hiding (readFile, writeFile, getContents, putStr, putStrLn)-import System.IO (Handle)-import Control.Monad (liftM)---bom :: B.ByteString-bom = B.pack [0xEF, 0xBB, 0xBF]--stripBOM :: B.ByteString -> B.ByteString-stripBOM s | bom `B.isPrefixOf` s = B.drop 3 s-stripBOM s = s--readFile :: FilePath -> IO String-readFile = liftM (toString . stripBOM) . B.readFile . encodePath--writeFile :: FilePath -> String -> IO ()-writeFile f = B.writeFile (encodePath f) . fromString--getContents :: IO String-getContents = liftM (toString . stripBOM) B.getContents--hGetContents :: Handle -> IO String-hGetContents h = liftM (toString . stripBOM) (B.hGetContents h)--putStr :: String -> IO ()-putStr = B.putStr . fromString+hGetContents = fmap toStringLazy . BL.hGetContents+-- hGetContents h = hSetEncoding h utf8_bom+-- >> hSetNewlineMode h universalNewlineMode+-- >> IO.hGetContents h -putStrLn :: String -> IO ()-putStrLn = B.putStrLn . fromString+-- | Convert UTF8-encoded ByteString to String, also+-- removing '\r' characters.+toString :: B.ByteString -> String+toString = filter (/='\r') . T.unpack . T.decodeUtf8 -hPutStr :: Handle -> String -> IO ()-hPutStr h = B.hPutStr h . fromString+fromString :: String -> B.ByteString+fromString = T.encodeUtf8 . T.pack -hPutStrLn :: Handle -> String -> IO ()-hPutStrLn h s = hPutStr h (s ++ "\n")+-- | Convert UTF8-encoded ByteString to String, also+-- removing '\r' characters.+toStringLazy :: BL.ByteString -> String+toStringLazy = filter (/='\r') . TL.unpack . TL.decodeUtf8 -#endif+fromStringLazy :: String -> BL.ByteString+fromStringLazy = TL.encodeUtf8 . TL.pack encodePath :: FilePath -> FilePath+decodeArg :: String -> String #if MIN_VERSION_base(4,4,0) encodePath = id+decodeArg = id #else-encodePath = encodeString+encodePath = B.unpack . fromString+decodeArg = toString . B.pack #endif
@@ -40,8 +40,8 @@ import Text.Pandoc.Definition import Text.Pandoc.Templates (renderTemplate) import Text.Pandoc.Shared-import Text.Pandoc.Parsing hiding (blankline)-import Text.ParserCombinators.Parsec ( runParser, GenParser )+import Text.Pandoc.Options+import Text.Pandoc.Parsing hiding (blankline, space) import Data.List ( isPrefixOf, intersperse, intercalate ) import Text.Pandoc.Pretty import Control.Monad.State@@ -93,7 +93,7 @@ where escs = backslashEscapes "{" -- | Ordered list start parser for use in Para below.-olMarker :: GenParser Char ParserState Char+olMarker :: Parser [Char] ParserState Char olMarker = do (start, style', delim) <- anyOrderedListMarker if delim == Period && (style' == UpperAlpha || (style' == UpperRoman &&@@ -116,6 +116,8 @@ blockToAsciiDoc opts (Plain inlines) = do contents <- inlineListToAsciiDoc opts inlines return $ contents <> cr+blockToAsciiDoc opts (Para [Image alt (src,'f':'i':'g':':':tit)]) =+ blockToAsciiDoc opts (Para [Image alt (src,tit)]) blockToAsciiDoc opts (Para inlines) = do contents <- inlineListToAsciiDoc opts inlines -- escape if para starts with ordered list marker@@ -126,10 +128,10 @@ blockToAsciiDoc _ (RawBlock _ _) = return empty blockToAsciiDoc _ HorizontalRule = return $ blankline <> text "'''''" <> blankline-blockToAsciiDoc opts (Header level inlines) = do+blockToAsciiDoc opts (Header level (ident,_,_) inlines) = do contents <- inlineListToAsciiDoc opts inlines let len = offset contents- return $ contents <> cr <>+ return $ ("[[" <> text ident <> "]]") $$ contents $$ (case level of 1 -> text $ replicate len '-' 2 -> text $ replicate len '~'@@ -343,8 +345,8 @@ else empty let srcSuffix = if isPrefixOf "mailto:" src then drop 7 src else src let useAuto = case txt of- [Code _ s] | s == srcSuffix -> True- _ -> False+ [Str s] | escapeURI s == srcSuffix -> True+ _ -> False return $ if useAuto then text srcSuffix else prefix <> text src <> "[" <> linktext <> "]"
@@ -20,10 +20,10 @@ {- | Module : Text.Pandoc.Writers.ConTeXt Copyright : Copyright (C) 2007-2010 John MacFarlane- License : GNU GPL, version 2 or above + License : GNU GPL, version 2 or above Maintainer : John MacFarlane <jgm@berkeley.edu>- Stability : alpha + Stability : alpha Portability : portable Conversion of 'Pandoc' format into ConTeXt.@@ -31,31 +31,32 @@ module Text.Pandoc.Writers.ConTeXt ( writeConTeXt ) where import Text.Pandoc.Definition import Text.Pandoc.Shared+import Text.Pandoc.Options import Text.Pandoc.Generic (queryWith) import Text.Printf ( printf )-import Data.List ( intercalate )+import Data.List ( intercalate, isPrefixOf ) import Control.Monad.State import Text.Pandoc.Pretty import Text.Pandoc.Templates ( renderTemplate ) import Network.URI ( isURI, unEscapeString ) -data WriterState = +data WriterState = WriterState { stNextRef :: Int -- number of next URL reference , stOrderedListLevel :: Int -- level of ordered list , stOptions :: WriterOptions -- writer options } -orderedListStyles :: [[Char]]-orderedListStyles = cycle ["[n]","[a]", "[r]", "[g]"] +orderedListStyles :: [Char]+orderedListStyles = cycle "narg" -- | Convert Pandoc to ConTeXt. writeConTeXt :: WriterOptions -> Pandoc -> String-writeConTeXt options document = +writeConTeXt options document = let defaultWriterState = WriterState { stNextRef = 1 , stOrderedListLevel = 0 , stOptions = options- } - in evalState (pandocToConTeXt options document) defaultWriterState + }+ in evalState (pandocToConTeXt options document) defaultWriterState pandocToConTeXt :: WriterOptions -> Pandoc -> State WriterState String pandocToConTeXt options (Pandoc (Meta title authors date) blocks) = do@@ -73,6 +74,12 @@ let main = (render colwidth . vcat) body let context = writerVariables options ++ [ ("toc", if writerTableOfContents options then "yes" else "")+ , ("placelist", intercalate "," $+ take (writerTOCDepth options + if writerChapters options+ then 0+ else 1)+ ["chapter","section","subsection","subsubsection",+ "subsubsubsection","subsubsubsubsection"]) , ("body", main) , ("title", titletext) , ("date", datetext) ] ++@@ -120,15 +127,16 @@ return $ vcat (header' : innerContents) -- | Convert Pandoc block element to ConTeXt.-blockToConTeXt :: Block +blockToConTeXt :: Block -> State WriterState Doc blockToConTeXt Null = return empty blockToConTeXt (Plain lst) = inlineListToConTeXt lst-blockToConTeXt (Para [Image txt (src,_)]) = do+-- title beginning with fig: indicates that the image is a figure+blockToConTeXt (Para [Image txt (src,'f':'i':'g':':':_)]) = do capt <- inlineListToConTeXt txt return $ blankline $$ "\\placefigure[here,nonumber]" <> braces capt <> braces ("\\externalfigure" <> brackets (text src)) <> blankline-blockToConTeXt (Para lst) = do +blockToConTeXt (Para lst) = do contents <- inlineListToConTeXt lst return $ contents <> blankline blockToConTeXt (BlockQuote lst) = do@@ -141,37 +149,41 @@ blockToConTeXt (RawBlock _ _ ) = return empty blockToConTeXt (BulletList lst) = do contents <- mapM listItemToConTeXt lst- return $ "\\startitemize" $$ vcat contents $$ text "\\stopitemize" <> blankline+ return $ ("\\startitemize" <> if isTightList lst+ then brackets "packed"+ else empty) $$+ vcat contents $$ text "\\stopitemize" <> blankline blockToConTeXt (OrderedList (start, style', delim) lst) = do st <- get let level = stOrderedListLevel st put $ st {stOrderedListLevel = level + 1} contents <- mapM listItemToConTeXt lst- put $ st {stOrderedListLevel = level} + put $ st {stOrderedListLevel = level} let start' = if start == 1 then "" else "start=" ++ show start let delim' = case delim of DefaultDelim -> ""- Period -> "stopper=." - OneParen -> "stopper=)" + Period -> "stopper=."+ OneParen -> "stopper=)" TwoParens -> "left=(,stopper=)"- let width = maximum $ map length $ take (length contents) + let width = maximum $ map length $ take (length contents) (orderedListMarkers (start, style', delim)) let width' = (toEnum width + 1) / 2- let width'' = if width' > (1.5 :: Double) - then "width=" ++ show width' ++ "em" + let width'' = if width' > (1.5 :: Double)+ then "width=" ++ show width' ++ "em" else "" let specs2Items = filter (not . null) [start', delim', width''] let specs2 = if null specs2Items then "" else "[" ++ intercalate "," specs2Items ++ "]"- let style'' = case style' of- DefaultStyle -> orderedListStyles !! level- Decimal -> "[n]" - Example -> "[n]" - LowerRoman -> "[r]"- UpperRoman -> "[R]"- LowerAlpha -> "[a]"- UpperAlpha -> "[A]"+ let style'' = '[': (case style' of+ DefaultStyle -> orderedListStyles !! level+ Decimal -> 'n'+ Example -> 'n'+ LowerRoman -> 'r'+ UpperRoman -> 'R'+ LowerAlpha -> 'a'+ UpperAlpha -> 'A') :+ if isTightList lst then ",packed]" else "]" let specs = style'' ++ specs2 return $ "\\startitemize" <> text specs $$ vcat contents $$ "\\stopitemize" <> blankline@@ -179,24 +191,24 @@ liftM vcat $ mapM defListItemToConTeXt lst blockToConTeXt HorizontalRule = return $ "\\thinrule" <> blankline -- If this is ever executed, provide a default for the reference identifier.-blockToConTeXt (Header level lst) = sectionHeader "" level lst+blockToConTeXt (Header level (ident,_,_) lst) = sectionHeader ident level lst blockToConTeXt (Table caption aligns widths heads rows) = do let colDescriptor colWidth alignment = (case alignment of- AlignLeft -> 'l' + AlignLeft -> 'l' AlignRight -> 'r' AlignCenter -> 'c' AlignDefault -> 'l'): if colWidth == 0 then "|" else ("p(" ++ printf "%.2f" colWidth ++ "\\textwidth)|")- let colDescriptors = "|" ++ (concat $ + let colDescriptors = "|" ++ (concat $ zipWith colDescriptor widths aligns) headers <- if all null heads then return empty- else liftM ($$ "\\HL") $ tableRowToConTeXt heads - captionText <- inlineListToConTeXt caption + else liftM ($$ "\\HL") $ tableRowToConTeXt heads+ captionText <- inlineListToConTeXt caption let captionText' = if null caption then text "none" else captionText- rows' <- mapM tableRowToConTeXt rows + rows' <- mapM tableRowToConTeXt rows return $ "\\placetable[here]" <> braces captionText' $$ "\\starttable" <> brackets (text colDescriptors) $$ "\\HL" $$ headers $$@@ -230,7 +242,7 @@ -- | Convert inline element to ConTeXt inlineToConTeXt :: Inline -- ^ Inline to convert -> State WriterState Doc-inlineToConTeXt (Emph lst) = do +inlineToConTeXt (Emph lst) = do contents <- inlineListToConTeXt lst return $ braces $ "\\em " <> contents inlineToConTeXt (Strong lst) = do@@ -273,7 +285,11 @@ inlineToConTeXt (LineBreak) = return $ text "\\crlf" <> cr inlineToConTeXt Space = return space -- autolink-inlineToConTeXt (Link [Code _ str] (src, tit)) = inlineToConTeXt (Link+inlineToConTeXt (Link [Str str] (src, tit))+ | if "mailto:" `isPrefixOf` src+ then src == escapeURI ("mailto:" ++ str)+ else src == escapeURI str =+ inlineToConTeXt (Link [RawInline "context" "\\hyphenatedurl{", Str str, RawInline "context" "}"] (src, tit)) -- Handle HTML-like internal document references to sections
@@ -19,7 +19,7 @@ {- | Module : Text.Pandoc.Writers.Docbook Copyright : Copyright (C) 2006-2010 John MacFarlane- License : GNU GPL, version 2 or above + License : GNU GPL, version 2 or above Maintainer : John MacFarlane <jgm@berkeley.edu> Stability : alpha@@ -31,6 +31,7 @@ import Text.Pandoc.Definition import Text.Pandoc.XML import Text.Pandoc.Shared+import Text.Pandoc.Options import Text.Pandoc.Templates (renderTemplate) import Text.Pandoc.Readers.TeXMath import Data.List ( isPrefixOf, intercalate, isSuffixOf )@@ -47,23 +48,23 @@ let name = render Nothing $ inlinesToDocbook opts name' in if ',' `elem` name then -- last name first- let (lastname, rest) = break (==',') name - firstname = removeLeadingSpace rest in- inTagsSimple "firstname" (text $ escapeStringForXML firstname) <> - inTagsSimple "surname" (text $ escapeStringForXML lastname) + let (lastname, rest) = break (==',') name+ firstname = triml rest in+ inTagsSimple "firstname" (text $ escapeStringForXML firstname) <>+ inTagsSimple "surname" (text $ escapeStringForXML lastname) else -- last name last let namewords = words name- lengthname = length namewords + lengthname = length namewords (firstname, lastname) = case lengthname of- 0 -> ("","") + 0 -> ("","") 1 -> ("", name) n -> (intercalate " " (take (n-1) namewords), last namewords)- in inTagsSimple "firstname" (text $ escapeStringForXML firstname) $$ - inTagsSimple "surname" (text $ escapeStringForXML lastname) + in inTagsSimple "firstname" (text $ escapeStringForXML firstname) $$+ inTagsSimple "surname" (text $ escapeStringForXML lastname) -- | Convert Pandoc document to string in Docbook format. writeDocbook :: WriterOptions -> Pandoc -> String-writeDocbook opts (Pandoc (Meta tit auths dat) blocks) = +writeDocbook opts (Pandoc (Meta tit auths dat) blocks) = let title = inlinesToDocbook opts tit authors = map (authorToDocbook opts) auths date = inlinesToDocbook opts dat@@ -73,7 +74,7 @@ else Nothing render' = render colwidth opts' = if "/book>" `isSuffixOf`- (removeTrailingSpace $ writerTemplate opts)+ (trimr $ writerTemplate opts) then opts{ writerChapters = True } else opts startLvl = if writerChapters opts' then 0 else 1@@ -92,7 +93,7 @@ -- | Convert an Element to Docbook. elementToDocbook :: WriterOptions -> Int -> Element -> Doc-elementToDocbook opts _ (Blk block) = blockToDocbook opts block +elementToDocbook opts _ (Blk block) = blockToDocbook opts block elementToDocbook opts lvl (Sec _ _num id' title elements) = -- Docbook doesn't allow sections with no content, so insert some if needed let elements' = if null elements@@ -102,7 +103,7 @@ n | n == 0 -> "chapter" | n >= 1 && n <= 5 -> "sect" ++ show n | otherwise -> "simplesect"- in inTags True tag [("id",id')] $+ in inTags True tag [("id", writerIdentifierPrefix opts ++ id')] $ inTagsSimple "title" (inlinesToDocbook opts title) $$ vcat (map (elementToDocbook opts (lvl + 1)) elements') @@ -115,10 +116,10 @@ plainToPara (Plain x) = Para x plainToPara x = x --- | Convert a list of pairs of terms and definitions into a list of +-- | Convert a list of pairs of terms and definitions into a list of -- Docbook varlistentrys. deflistItemsToDocbook :: WriterOptions -> [([Inline],[[Block]])] -> Doc-deflistItemsToDocbook opts items = +deflistItemsToDocbook opts items = vcat $ map (\(term, defs) -> deflistItemToDocbook opts term defs) items -- | Convert a term and a list of blocks into a Docbook varlistentry.@@ -141,16 +142,20 @@ -- | Convert a Pandoc block element to Docbook. blockToDocbook :: WriterOptions -> Block -> Doc blockToDocbook _ Null = empty-blockToDocbook _ (Header _ _) = empty -- should not occur after hierarchicalize+blockToDocbook _ (Header _ _ _) = empty -- should not occur after hierarchicalize blockToDocbook opts (Plain lst) = inlinesToDocbook opts lst-blockToDocbook opts (Para [Image txt (src,_)]) =- let capt = inlinesToDocbook opts txt+-- title beginning with fig: indicates that the image is a figure+blockToDocbook opts (Para [Image txt (src,'f':'i':'g':':':_)]) =+ let alt = inlinesToDocbook opts txt+ capt = if null txt+ then empty+ else inTagsSimple "title" alt in inTagsIndented "figure" $- inTagsSimple "title" capt $$+ capt $$ (inTagsIndented "mediaobject" $ (inTagsIndented "imageobject" (selfClosingTag "imagedata" [("fileref",src)])) $$- inTagsSimple "textobject" (inTagsSimple "phrase" capt))+ inTagsSimple "textobject" (inTagsSimple "phrase" alt)) blockToDocbook opts (Para lst) = inTagsIndented "para" $ inlinesToDocbook opts lst blockToDocbook opts (BlockQuote blocks) =@@ -167,9 +172,9 @@ then [s] else languagesByExtension . map toLower $ s langs = concatMap langsFrom classes-blockToDocbook opts (BulletList lst) = - inTagsIndented "itemizedlist" $ listItemsToDocbook opts lst -blockToDocbook _ (OrderedList _ []) = empty +blockToDocbook opts (BulletList lst) =+ inTagsIndented "itemizedlist" $ listItemsToDocbook opts lst+blockToDocbook _ (OrderedList _ []) = empty blockToDocbook opts (OrderedList (start, numstyle, _) (first:rest)) = let attribs = case numstyle of DefaultStyle -> []@@ -182,12 +187,12 @@ items = if start == 1 then listItemsToDocbook opts (first:rest) else (inTags True "listitem" [("override",show start)]- (blocksToDocbook opts $ map plainToPara first)) $$ - listItemsToDocbook opts rest + (blocksToDocbook opts $ map plainToPara first)) $$+ listItemsToDocbook opts rest in inTags True "orderedlist" attribs items-blockToDocbook opts (DefinitionList lst) = - inTagsIndented "variablelist" $ deflistItemsToDocbook opts lst -blockToDocbook _ (RawBlock "docbook" str) = text str -- raw XML block +blockToDocbook opts (DefinitionList lst) =+ inTagsIndented "variablelist" $ deflistItemsToDocbook opts lst+blockToDocbook _ (RawBlock "docbook" str) = text str -- raw XML block -- we allow html for compatibility with earlier versions of pandoc blockToDocbook _ (RawBlock "html" str) = text str -- raw XML block blockToDocbook _ (RawBlock _ _) = empty@@ -237,26 +242,26 @@ -- | Convert an inline element to Docbook. inlineToDocbook :: WriterOptions -> Inline -> Doc-inlineToDocbook _ (Str str) = text $ escapeStringForXML str -inlineToDocbook opts (Emph lst) = +inlineToDocbook _ (Str str) = text $ escapeStringForXML str+inlineToDocbook opts (Emph lst) = inTagsSimple "emphasis" $ inlinesToDocbook opts lst-inlineToDocbook opts (Strong lst) = +inlineToDocbook opts (Strong lst) = inTags False "emphasis" [("role", "strong")] $ inlinesToDocbook opts lst-inlineToDocbook opts (Strikeout lst) = +inlineToDocbook opts (Strikeout lst) = inTags False "emphasis" [("role", "strikethrough")] $ inlinesToDocbook opts lst-inlineToDocbook opts (Superscript lst) = +inlineToDocbook opts (Superscript lst) = inTagsSimple "superscript" $ inlinesToDocbook opts lst-inlineToDocbook opts (Subscript lst) = +inlineToDocbook opts (Subscript lst) = inTagsSimple "subscript" $ inlinesToDocbook opts lst-inlineToDocbook opts (SmallCaps lst) = +inlineToDocbook opts (SmallCaps lst) = inTags False "emphasis" [("role", "smallcaps")] $ inlinesToDocbook opts lst-inlineToDocbook opts (Quoted _ lst) = +inlineToDocbook opts (Quoted _ lst) = inTagsSimple "quote" $ inlinesToDocbook opts lst inlineToDocbook opts (Cite _ lst) =- inlinesToDocbook opts lst -inlineToDocbook _ (Code _ str) = + inlinesToDocbook opts lst+inlineToDocbook _ (Code _ str) = inTagsSimple "literal" $ text (escapeStringForXML str) inlineToDocbook opts (Math t str) | isMathML (writerHTMLMathMethod opts) =@@ -282,24 +287,24 @@ inlineToDocbook opts (Link txt (src, _)) = if isPrefixOf "mailto:" src then let src' = drop 7 src- emailLink = inTagsSimple "email" $ text $ + emailLink = inTagsSimple "email" $ text $ escapeStringForXML $ src' in case txt of- [Code _ s] | s == src' -> emailLink+ [Str s] | escapeURI s == src' -> emailLink _ -> inlinesToDocbook opts txt <+> char '(' <> emailLink <> char ')' else (if isPrefixOf "#" src then inTags False "link" [("linkend", drop 1 src)] else inTags False "ulink" [("url", src)]) $ inlinesToDocbook opts txt-inlineToDocbook _ (Image _ (src, tit)) = +inlineToDocbook _ (Image _ (src, tit)) = let titleDoc = if null tit then empty else inTagsIndented "objectinfo" $ inTagsIndented "title" (text $ escapeStringForXML tit) in inTagsIndented "inlinemediaobject" $ inTagsIndented "imageobject" $ titleDoc $$ selfClosingTag "imagedata" [("fileref", src)]-inlineToDocbook opts (Note contents) = +inlineToDocbook opts (Note contents) = inTagsIndented "footnote" $ blocksToDocbook opts contents isMathML :: HTMLMathMethod -> Bool
@@ -1,3 +1,4 @@+{-# LANGUAGE ScopedTypeVariables #-} {- Copyright (C) 2012 John MacFarlane <jgm@berkeley.edu> @@ -29,20 +30,17 @@ -} module Text.Pandoc.Writers.Docx ( writeDocx ) where import Data.List ( intercalate )-import System.FilePath ( (</>) )-import qualified Data.ByteString.Lazy as B+import qualified Data.ByteString as B+import qualified Data.ByteString.Lazy as BL import qualified Data.Map as M-import Data.ByteString.Lazy.UTF8 ( fromString, toString )-import Text.Pandoc.UTF8 as UTF8-import System.IO ( stderr )+import qualified Text.Pandoc.UTF8 as UTF8 import Codec.Archive.Zip import Data.Time.Clock.POSIX-import Paths_pandoc ( getDataFileName ) import Text.Pandoc.Definition import Text.Pandoc.Generic-import System.Directory import Text.Pandoc.ImageSize import Text.Pandoc.Shared hiding (Element)+import Text.Pandoc.Options import Text.Pandoc.Readers.TeXMath import Text.Pandoc.Highlighting ( highlight ) import Text.Highlighting.Kate.Types ()@@ -50,6 +48,10 @@ import Text.TeXMath import Control.Monad.State import Text.Highlighting.Kate+import Data.Unique (hashUnique, newUnique)+import System.Random (randomRIO)+import Text.Printf (printf)+import qualified Control.Exception as E data WriterState = WriterState{ stTextProperties :: [Element]@@ -57,9 +59,9 @@ , stFootnotes :: [Element] , stSectionIds :: [String] , stExternalLinks :: M.Map String String- , stImages :: M.Map FilePath (String, B.ByteString)+ , stImages :: M.Map FilePath (String, String, Element, B.ByteString) , stListLevel :: Int- , stListMarker :: ListMarker+ , stListNumId :: Int , stNumStyles :: M.Map ListMarker Int , stLists :: [ListMarker] }@@ -78,7 +80,7 @@ , stExternalLinks = M.empty , stImages = M.empty , stListLevel = -1- , stListMarker = NoMarker+ , stListNumId = 1 , stNumStyles = M.fromList [(NoMarker, 0)] , stLists = [NoMarker] }@@ -92,68 +94,62 @@ mknode s attrs = add_attrs (map (\(k,v) -> Attr (unqual k) v) attrs) . node (unqual s) +toLazy :: B.ByteString -> BL.ByteString+toLazy = BL.fromChunks . (:[])+ -- | Produce an Docx file from a Pandoc document.-writeDocx :: Maybe FilePath -- ^ Path specified by --reference-docx- -> WriterOptions -- ^ Writer options+writeDocx :: WriterOptions -- ^ Writer options -> Pandoc -- ^ Document to convert- -> IO B.ByteString-writeDocx mbRefDocx opts doc@(Pandoc (Meta tit auths date) _) = do+ -> IO BL.ByteString+writeDocx opts doc@(Pandoc (Meta tit auths date) _) = do let datadir = writerUserDataDir opts- refArchive <- liftM toArchive $- case mbRefDocx of- Just f -> B.readFile f- Nothing -> do- let defaultDocx = getDataFileName "reference.docx" >>= B.readFile- case datadir of- Nothing -> defaultDocx- Just d -> do- exists <- doesFileExist (d </> "reference.docx")- if exists- then B.readFile (d </> "reference.docx")- else defaultDocx+ refArchive <- liftM (toArchive . toLazy) $+ case writerReferenceDocx opts of+ Just f -> B.readFile f+ Nothing -> readDataFile datadir "reference.docx" - (newContents, st) <- runStateT (writeOpenXML opts{writerWrapText = False} doc)+ ((contents, footnotes), st) <- runStateT (writeOpenXML opts{writerWrapText = False} doc) defaultWriterState epochtime <- floor `fmap` getPOSIXTime let imgs = M.elems $ stImages st- let imgPath ident img = "media/" ++ ident ++- case imageType img of- Just Png -> ".png"- Just Jpeg -> ".jpeg"- Just Gif -> ".gif"- Nothing -> ""- let toImgRel (ident,img) = mknode "Relationship" [("Type","http://schemas.openxmlformats.org/officeDocument/2006/relationships/image"),("Id",ident),("Target",imgPath ident img)] ()+ let toImgRel (ident,path,_,_) = mknode "Relationship" [("Type","http://schemas.openxmlformats.org/officeDocument/2006/relationships/image"),("Id",ident),("Target",path)] () let newrels = map toImgRel imgs let relpath = "word/_rels/document.xml.rels" let reldoc = case findEntryByPath relpath refArchive >>=- parseXMLDoc . toString . fromEntry of+ parseXMLDoc . UTF8.toStringLazy . fromEntry of Just d -> d Nothing -> error $ relpath ++ "missing in reference docx" let reldoc' = reldoc{ elContent = elContent reldoc ++ map Elem newrels } -- create entries for images- let toImageEntry (ident,img) = toEntry ("word/" ++ imgPath ident img)- epochtime img+ let toImageEntry (_,path,_,img) = toEntry ("word/" ++ path) epochtime $ toLazy img let imageEntries = map toImageEntry imgs -- NOW get list of external links and images from this, and do what's needed let toLinkRel (src,ident) = mknode "Relationship" [("Type","http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink"),("Id",ident),("Target",src),("TargetMode","External") ] () let newrels' = map toLinkRel $ M.toList $ stExternalLinks st let reldoc'' = reldoc' { elContent = elContent reldoc' ++ map Elem newrels' }- let relEntry = toEntry relpath epochtime $ fromString $ showTopElement' reldoc''- let contentEntry = toEntry "word/document.xml" epochtime $ fromString $ showTopElement' newContents+ let relEntry = toEntry relpath epochtime $ UTF8.fromStringLazy $ showTopElement' reldoc''+ let contentEntry = toEntry "word/document.xml" epochtime $ UTF8.fromStringLazy $ showTopElement' contents+ -- footnotes+ let footnotesEntry = toEntry "word/footnotes.xml" epochtime $ UTF8.fromStringLazy $+ showTopElement' footnotes+ -- footnote rels+ let footnoteRelEntry = toEntry "word/_rels/footnotes.xml.rels" epochtime $ UTF8.fromStringLazy $+ showTopElement' $ mknode "Relationships" [("xmlns","http://schemas.openxmlformats.org/package/2006/relationships")]+ $ newrels' -- styles let newstyles = styleToOpenXml $ writerHighlightStyle opts let stylepath = "word/styles.xml" let styledoc = case findEntryByPath stylepath refArchive >>=- parseXMLDoc . toString . fromEntry of+ parseXMLDoc . UTF8.toStringLazy . fromEntry of Just d -> d Nothing -> error $ "Unable to parse " ++ stylepath ++ " from reference.docx" let styledoc' = styledoc{ elContent = elContent styledoc ++ map Elem newstyles }- let styleEntry = toEntry stylepath epochtime $ fromString $ showTopElement' styledoc'+ let styleEntry = toEntry stylepath epochtime $ UTF8.fromStringLazy $ showTopElement' styledoc' -- construct word/numbering.xml let numpath = "word/numbering.xml"- let numEntry = toEntry numpath epochtime $ fromString $ showTopElement'- $ mkNumbering (stNumStyles st) (stLists st)+ numEntry <- (toEntry numpath epochtime . UTF8.fromStringLazy . showTopElement')+ `fmap` mkNumbering (stNumStyles st) (stLists st) let docPropsPath = "docProps/core.xml" let docProps = mknode "cp:coreProperties" [("xmlns:cp","http://schemas.openxmlformats.org/package/2006/metadata/core-properties")@@ -166,18 +162,18 @@ (maybe "" id $ normalizeDate $ stringify date) : mknode "dcterms:modified" [("xsi:type","dcterms:W3CDTF")] () -- put current time here : map (mknode "dc:creator" [] . stringify) auths- let docPropsEntry = toEntry docPropsPath epochtime $ fromString $ showTopElement' docProps+ let docPropsEntry = toEntry docPropsPath epochtime $ UTF8.fromStringLazy $ showTopElement' docProps let relsPath = "_rels/.rels" rels <- case findEntryByPath relsPath refArchive of- Just e -> return $ toString $ fromEntry e+ Just e -> return $ UTF8.toStringLazy $ fromEntry e Nothing -> err 57 "could not find .rels/_rels in reference docx" -- fix .rels/_rels, which can get screwed up when reference.docx is edited by Word let rels' = substitute "http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties" "http://schemas.openxmlformats.org/officedocument/2006/relationships/metadata/core-properties" rels- let relsEntry = toEntry relsPath epochtime $ fromString rels'+ let relsEntry = toEntry relsPath epochtime $ UTF8.fromStringLazy rels' let archive = foldr addEntryToArchive refArchive $- relsEntry : contentEntry : relEntry : numEntry : styleEntry : docPropsEntry : imageEntries+ relsEntry : contentEntry : relEntry : footnoteRelEntry : numEntry : styleEntry : footnotesEntry : docPropsEntry : imageEntries return $ fromArchive archive styleToOpenXml :: Style -> [Element]@@ -215,11 +211,12 @@ $ backgroundColor style ) ] -mkNumbering :: M.Map ListMarker Int -> [ListMarker] -> Element-mkNumbering markers lists =- mknode "w:numbering" [("xmlns:w","http://schemas.openxmlformats.org/wordprocessingml/2006/main")]- $ map mkAbstractNum (M.toList markers)- ++ zipWith (mkNum markers) lists [1..(length lists)]+mkNumbering :: M.Map ListMarker Int -> [ListMarker] -> IO Element+mkNumbering markers lists = do+ elts <- mapM mkAbstractNum (M.toList markers)+ return $ mknode "w:numbering"+ [("xmlns:w","http://schemas.openxmlformats.org/wordprocessingml/2006/main")]+ $ elts ++ zipWith (mkNum markers) lists [1..(length lists)] mkNum :: M.Map ListMarker Int -> ListMarker -> Int -> Element mkNum markers marker numid =@@ -233,10 +230,12 @@ $ mknode "w:startOverride" [("w:val",show start)] ()) [0..6] where absnumid = maybe 0 id $ M.lookup marker markers -mkAbstractNum :: (ListMarker,Int) -> Element-mkAbstractNum (marker,numid) =- mknode "w:abstractNum" [("w:abstractNumId",show numid)]- $ mknode "w:multiLevelType" [("w:val","multilevel")] ()+mkAbstractNum :: (ListMarker,Int) -> IO Element+mkAbstractNum (marker,numid) = do+ nsid <- randomRIO (0x10000000 :: Integer, 0xFFFFFFFF :: Integer)+ return $ mknode "w:abstractNum" [("w:abstractNumId",show numid)]+ $ mknode "w:nsid" [("w:val", printf "%8x" nsid)] ()+ : mknode "w:multiLevelType" [("w:val","multilevel")] () : map (mkLvl marker) [0..6] mkLvl :: ListMarker -> Int -> Element@@ -285,8 +284,11 @@ patternFor TwoParens s = "(" ++ s ++ ")" patternFor _ s = s ++ "." --- | Convert Pandoc document to string in OpenXML format.-writeOpenXML :: WriterOptions -> Pandoc -> WS Element+getNumId :: WS Int+getNumId = length `fmap` gets stLists++-- | Convert Pandoc document to two OpenXML elements (the main document and footnotes).+writeOpenXML :: WriterOptions -> Pandoc -> WS (Element, Element) writeOpenXML opts (Pandoc (Meta tit auths dat) blocks) = do title <- withParaProp (pStyle "Title") $ blocksToOpenXML opts [Para tit | not (null tit)] authors <- withParaProp (pStyle "Authors") $ blocksToOpenXML opts@@ -296,13 +298,10 @@ convertSpace (Str x : Str y : xs) = Str (x ++ y) : xs convertSpace xs = xs let blocks' = bottomUp convertSpace $ blocks- doc <- blocksToOpenXML opts blocks'+ doc' <- blocksToOpenXML opts blocks' notes' <- reverse `fmap` gets stFootnotes- let notes = case notes' of- [] -> []- ns -> [mknode "w:footnotes" [] ns] let meta = title ++ authors ++ date- return $ mknode "w:document"+ let stdAttributes = [("xmlns:w","http://schemas.openxmlformats.org/wordprocessingml/2006/main") ,("xmlns:m","http://schemas.openxmlformats.org/officeDocument/2006/math") ,("xmlns:r","http://schemas.openxmlformats.org/officeDocument/2006/relationships")@@ -312,7 +311,9 @@ ,("xmlns:a","http://schemas.openxmlformats.org/drawingml/2006/main") ,("xmlns:pic","http://schemas.openxmlformats.org/drawingml/2006/picture") ,("xmlns:wp","http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing")]- $ mknode "w:body" [] (meta ++ doc ++ notes)+ let doc = mknode "w:document" stdAttributes $ mknode "w:body" [] (meta ++ doc')+ let notes = mknode "w:footnotes" stdAttributes notes'+ return (doc, notes) -- | Convert a list of Pandoc blocks to OpenXML. blocksToOpenXML :: WriterOptions -> [Block] -> WS [Element]@@ -324,23 +325,32 @@ rStyle :: String -> Element rStyle sty = mknode "w:rStyle" [("w:val",sty)] () +getUniqueId :: MonadIO m => m String+-- the + 20 is to ensure that there are no clashes with the rIds+-- already in word/document.xml.rel+getUniqueId = liftIO $ (show . (+ 20) . hashUnique) `fmap` newUnique+ -- | Convert a Pandoc block element to OpenXML. blockToOpenXML :: WriterOptions -> Block -> WS [Element] blockToOpenXML _ Null = return []-blockToOpenXML opts (Header lev lst) = do+blockToOpenXML opts (Header lev (ident,_,_) lst) = do contents <- withParaProp (pStyle $ "Heading" ++ show lev) $ blockToOpenXML opts (Para lst) usedIdents <- gets stSectionIds- let ident = uniqueIdent lst usedIdents- modify $ \s -> s{ stSectionIds = ident : stSectionIds s }- let bookmarkStart = mknode "w:bookmarkStart" [("w:id",ident)- ,("w:name",ident)] ()- let bookmarkEnd = mknode "w:bookmarkEnd" [("w:id",ident)] ()+ let bookmarkName = if null ident+ then uniqueIdent lst usedIdents+ else ident+ modify $ \s -> s{ stSectionIds = bookmarkName : stSectionIds s }+ id' <- getUniqueId+ let bookmarkStart = mknode "w:bookmarkStart" [("w:id", id')+ ,("w:name",bookmarkName)] ()+ let bookmarkEnd = mknode "w:bookmarkEnd" [("w:id", id')] () return $ [bookmarkStart] ++ contents ++ [bookmarkEnd] blockToOpenXML opts (Plain lst) = blockToOpenXML opts (Para lst)-blockToOpenXML opts (Para x@[Image alt _]) = do+-- title beginning with fig: indicates that the image is a figure+blockToOpenXML opts (Para [Image alt (src,'f':'i':'g':':':tit)]) = do paraProps <- getParaProps- contents <- inlinesToOpenXML opts x+ contents <- inlinesToOpenXML opts [Image alt (src,tit)] captionNode <- withParaProp (pStyle "ImageCaption") $ blockToOpenXML opts (Para alt) return $ mknode "w:p" [] (paraProps ++ contents) : captionNode@@ -402,11 +412,13 @@ blockToOpenXML opts (BulletList lst) = do let marker = BulletMarker addList marker- asList $ concat `fmap` mapM (listItemToOpenXML opts marker) lst+ numid <- getNumId+ asList $ concat `fmap` mapM (listItemToOpenXML opts numid) lst blockToOpenXML opts (OrderedList (start, numstyle, numdelim) lst) = do let marker = NumberMarker numstyle numdelim start addList marker- asList $ concat `fmap` mapM (listItemToOpenXML opts marker) lst+ numid <- getNumId+ asList $ concat `fmap` mapM (listItemToOpenXML opts numid) lst blockToOpenXML opts (DefinitionList items) = concat `fmap` mapM (definitionListItemToOpenXML opts) items @@ -418,9 +430,6 @@ $ concat `fmap` mapM (blocksToOpenXML opts) defs return $ term' ++ defs' -getNumId :: WS Int-getNumId = length `fmap` gets stLists- addList :: ListMarker -> WS () addList marker = do lists <- gets stLists@@ -431,11 +440,11 @@ Nothing -> modify $ \st -> st{ stNumStyles = M.insert marker (M.size numStyles + 1) numStyles } -listItemToOpenXML :: WriterOptions -> ListMarker -> [Block] -> WS [Element]+listItemToOpenXML :: WriterOptions -> Int -> [Block] -> WS [Element] listItemToOpenXML _ _ [] = return []-listItemToOpenXML opts marker (first:rest) = do- first' <- withMarker marker $ blockToOpenXML opts first- rest' <- withMarker NoMarker $ blocksToOpenXML opts rest+listItemToOpenXML opts numid (first:rest) = do+ first' <- withNumId numid $ blockToOpenXML opts first+ rest' <- withNumId 1 $ blocksToOpenXML opts rest return $ first' ++ rest' alignmentToString :: Alignment -> [Char]@@ -449,12 +458,12 @@ inlinesToOpenXML :: WriterOptions -> [Inline] -> WS [Element] inlinesToOpenXML opts lst = concat `fmap` mapM (inlineToOpenXML opts) lst -withMarker :: ListMarker -> WS a -> WS a-withMarker m p = do- origMarker <- gets stListMarker- modify $ \st -> st{ stListMarker = m }+withNumId :: Int -> WS a -> WS a+withNumId numid p = do+ origNumId <- gets stListNumId+ modify $ \st -> st{ stListNumId = numid } result <- p- modify $ \st -> st{ stListMarker = origMarker }+ modify $ \st -> st{ stListNumId = origNumId } return result asList :: WS a -> WS a@@ -489,10 +498,7 @@ getParaProps = do props <- gets stParaProperties listLevel <- gets stListLevel- listMarker <- gets stListMarker- numid <- case listMarker of- NoMarker -> return 1- _ -> getNumId+ numid <- gets stListNumId let listPr = if listLevel >= 0 then [ mknode "w:numPr" [] [ mknode "w:numId" [("w:val",show numid)] ()@@ -543,7 +549,7 @@ inlineToOpenXML opts (Strikeout lst) = withTextProp (mknode "w:strike" [] ()) $ inlinesToOpenXML opts lst-inlineToOpenXML _ LineBreak = return [ mknode "w:br" [] () ]+inlineToOpenXML _ LineBreak = return [br] inlineToOpenXML _ (RawInline f str) | f == "openxml" = return [ x | Elem x <- parseXML str ] | otherwise = return []@@ -562,23 +568,21 @@ Left _ -> do fallback <- inlinesToOpenXML opts (readTeXMath str) return $ [br] ++ fallback ++ [br]- where br = mknode "w:br" [] () inlineToOpenXML opts (Cite _ lst) = inlinesToOpenXML opts lst inlineToOpenXML _ (Code attrs str) = withTextProp (rStyle "VerbatimChar") $ case highlight formatOpenXML attrs str of- Nothing -> intercalate [mknode "w:br" [] ()]+ Nothing -> intercalate [br] `fmap` (mapM formattedString $ lines str) Just h -> return h- where formatOpenXML _fmtOpts = intercalate [mknode "w:br" [] ()] .- map (map toHlTok)+ where formatOpenXML _fmtOpts = intercalate [br] . map (map toHlTok) toHlTok (toktype,tok) = mknode "w:r" [] [ mknode "w:rPr" [] [ rStyle $ show toktype ] , mknode "w:t" [("xml:space","preserve")] tok ] inlineToOpenXML opts (Note bs) = do notes <- gets stFootnotes- let notenum = length notes + 1+ notenum <- getUniqueId let notemarker = mknode "w:r" [] [ mknode "w:rPr" [] (rStyle "FootnoteReference") , mknode "w:footnoteRef" [] () ]@@ -594,11 +598,11 @@ $ insertNoteRef bs modify $ \st -> st{ stListLevel = oldListLevel, stParaProperties = oldParaProperties, stTextProperties = oldTextProperties }- let newnote = mknode "w:footnote" [("w:id",show notenum)] $ contents+ let newnote = mknode "w:footnote" [("w:id", notenum)] $ contents modify $ \s -> s{ stFootnotes = newnote : notes } return [ mknode "w:r" [] [ mknode "w:rPr" [] (rStyle "FootnoteReference")- , mknode "w:footnoteReference" [("w:id", show notenum)] () ] ]+ , mknode "w:footnoteReference" [("w:id", notenum)] () ] ] -- internal link: inlineToOpenXML opts (Link txt ('#':xs,_)) = do contents <- withTextProp (rStyle "Hyperlink") $ inlinesToOpenXML opts txt@@ -607,65 +611,76 @@ inlineToOpenXML opts (Link txt (src,_)) = do contents <- withTextProp (rStyle "Hyperlink") $ inlinesToOpenXML opts txt extlinks <- gets stExternalLinks- ind <- case M.lookup src extlinks of+ id' <- case M.lookup src extlinks of Just i -> return i Nothing -> do- let i = "link" ++ show (M.size extlinks)+ i <- ("rId"++) `fmap` getUniqueId modify $ \st -> st{ stExternalLinks = M.insert src i extlinks } return i- return [ mknode "w:hyperlink" [("r:id",ind)] contents ]+ return [ mknode "w:hyperlink" [("r:id",id')] contents ] inlineToOpenXML opts (Image alt (src, tit)) = do- exists <- liftIO $ doesFileExist src- if exists- then do- imgs <- gets stImages- (ident,size) <- case M.lookup src imgs of- Just (i,img) -> return (i, imageSize img)- Nothing -> do- img <- liftIO $ B.readFile src- let ident' = "image" ++ show (M.size imgs + 1)- let size' = imageSize img- modify $ \st -> st{- stImages = M.insert src (ident',img) $ stImages st }- return (ident',size')- let (xpt,ypt) = maybe (120,120) sizeInPoints size- -- 12700 emu = 1 pt- let (xemu,yemu) = (xpt * 12700, ypt * 12700)- let cNvPicPr = mknode "pic:cNvPicPr" [] $- mknode "a:picLocks" [("noChangeArrowheads","1"),("noChangeAspect","1")] ()- let nvPicPr = mknode "pic:nvPicPr" []- [ mknode "pic:cNvPr"- [("descr",src),("id","0"),("name","Picture")] ()- , cNvPicPr ]- let blipFill = mknode "pic:blipFill" []- [ mknode "a:blip" [("r:embed",ident)] ()- , mknode "a:stretch" [] $ mknode "a:fillRect" [] () ]- let xfrm = mknode "a:xfrm" []- [ mknode "a:off" [("x","0"),("y","0")] ()- , mknode "a:ext" [("cx",show xemu),("cy",show yemu)] () ]- let prstGeom = mknode "a:prstGeom" [("prst","rect")] $- mknode "a:avLst" [] ()- let ln = mknode "a:ln" [("w","9525")]- [ mknode "a:noFill" [] ()- , mknode "a:headEnd" [] ()- , mknode "a:tailEnd" [] () ]- let spPr = mknode "pic:spPr" [("bwMode","auto")]- [xfrm, prstGeom, mknode "a:noFill" [] (), ln]- let graphic = mknode "a:graphic" [] $- mknode "a:graphicData" [("uri","http://schemas.openxmlformats.org/drawingml/2006/picture")]- [ mknode "pic:pic" []- [ nvPicPr- , blipFill- , spPr ] ]- return [ mknode "w:r" [] $- mknode "w:drawing" [] $- mknode "wp:inline" []- [ mknode "wp:extent" [("cx",show xemu),("cy",show yemu)] ()- , mknode "wp:effectExtent" [("b","0"),("l","0"),("r","0"),("t","0")] ()- , mknode "wp:docPr" [("descr",tit),("id","1"),("name","Picture")] ()- , graphic ] ]- else do- liftIO $ UTF8.hPutStrLn stderr $- "Could not find image `" ++ src ++ "', skipping..."- inlinesToOpenXML opts alt+ -- first, check to see if we've already done this image+ imgs <- gets stImages+ case M.lookup src imgs of+ Just (_,_,elt,_) -> return [elt]+ Nothing -> do+ let sourceDir = writerSourceDirectory opts+ res <- liftIO $ E.try $ fetchItem sourceDir src+ case res of+ Left (_ :: E.SomeException) -> do+ liftIO $ warn $ "Could not find image `" ++ src ++ "', skipping..."+ -- emit alt text+ inlinesToOpenXML opts alt+ Right (img, _) -> do+ ident <- ("rId"++) `fmap` getUniqueId+ let size = imageSize img+ let (xpt,ypt) = maybe (120,120) sizeInPoints size+ -- 12700 emu = 1 pt+ let (xemu,yemu) = (xpt * 12700, ypt * 12700)+ let cNvPicPr = mknode "pic:cNvPicPr" [] $+ mknode "a:picLocks" [("noChangeArrowheads","1"),("noChangeAspect","1")] ()+ let nvPicPr = mknode "pic:nvPicPr" []+ [ mknode "pic:cNvPr"+ [("descr",src),("id","0"),("name","Picture")] ()+ , cNvPicPr ]+ let blipFill = mknode "pic:blipFill" []+ [ mknode "a:blip" [("r:embed",ident)] ()+ , mknode "a:stretch" [] $ mknode "a:fillRect" [] () ]+ let xfrm = mknode "a:xfrm" []+ [ mknode "a:off" [("x","0"),("y","0")] ()+ , mknode "a:ext" [("cx",show xemu),("cy",show yemu)] () ]+ let prstGeom = mknode "a:prstGeom" [("prst","rect")] $+ mknode "a:avLst" [] ()+ let ln = mknode "a:ln" [("w","9525")]+ [ mknode "a:noFill" [] ()+ , mknode "a:headEnd" [] ()+ , mknode "a:tailEnd" [] () ]+ let spPr = mknode "pic:spPr" [("bwMode","auto")]+ [xfrm, prstGeom, mknode "a:noFill" [] (), ln]+ let graphic = mknode "a:graphic" [] $+ mknode "a:graphicData" [("uri","http://schemas.openxmlformats.org/drawingml/2006/picture")]+ [ mknode "pic:pic" []+ [ nvPicPr+ , blipFill+ , spPr ] ]+ let imgElt = mknode "w:r" [] $+ mknode "w:drawing" [] $+ mknode "wp:inline" []+ [ mknode "wp:extent" [("cx",show xemu),("cy",show yemu)] ()+ , mknode "wp:effectExtent" [("b","0"),("l","0"),("r","0"),("t","0")] ()+ , mknode "wp:docPr" [("descr",tit),("id","1"),("name","Picture")] ()+ , graphic ]+ modify $ \st -> st{ stImages = M.insert src (ident, imgPath ident img, imgElt, img) $ stImages st }+ return [imgElt]++imgPath :: String -> B.ByteString -> String+imgPath ident img = "media/" ++ ident +++ case imageType img of+ Just Png -> ".png"+ Just Jpeg -> ".jpeg"+ Just Gif -> ".gif"+ Nothing -> ""++br :: Element+br = mknode "w:r" [] [mknode "w:cr" [] () ]
@@ -30,14 +30,20 @@ module Text.Pandoc.Writers.EPUB ( writeEPUB ) where import Data.IORef import Data.Maybe ( fromMaybe, isNothing )-import Data.List ( findIndices, isPrefixOf )+import Data.List ( isInfixOf, intercalate ) import System.Environment ( getEnv )-import System.FilePath ( (</>), (<.>), takeBaseName, takeExtension, takeFileName )+import Text.Printf (printf)+import System.FilePath ( (</>), takeBaseName, takeExtension, takeFileName ) import qualified Data.ByteString.Lazy as B-import Data.ByteString.Lazy.UTF8 ( fromString )+import qualified Data.ByteString.Lazy.Char8 as B8+import Text.Pandoc.UTF8 ( fromStringLazy, toString ) import Codec.Archive.Zip import Data.Time.Clock.POSIX+import Data.Time+import System.Locale import Text.Pandoc.Shared hiding ( Element )+import qualified Text.Pandoc.Shared as Shared+import Text.Pandoc.Options import Text.Pandoc.Definition import Text.Pandoc.Generic import Control.Monad.State@@ -48,87 +54,106 @@ import Data.Char ( toLower ) import Network.URI ( unEscapeString ) import Text.Pandoc.MIME (getMimeType)-#if ! MIN_VERSION_base(4,6,0) import Prelude hiding (catch)-#endif import Control.Exception (catch, SomeException)+import Text.Blaze.Html.Renderer.Utf8 (renderHtml) -- | Produce an EPUB file from a Pandoc document.-writeEPUB :: Maybe String -- ^ EPUB stylesheet specified at command line- -> [FilePath] -- ^ Paths to fonts to embed- -> WriterOptions -- ^ Writer options+writeEPUB :: WriterOptions -- ^ Writer options -> Pandoc -- ^ Document to convert -> IO B.ByteString-writeEPUB mbStylesheet fonts opts doc@(Pandoc meta _) = do+writeEPUB opts doc@(Pandoc meta _) = do+ let version = maybe EPUB2 id (writerEpubVersion opts)+ let epub3 = version == EPUB3 epochtime <- floor `fmap` getPOSIXTime let mkEntry path content = toEntry path epochtime content+ let vars = ("epub3", if epub3 then "true" else "false")+ : ("css", "stylesheet.css")+ : writerVariables opts let opts' = opts{ writerEmailObfuscation = NoObfuscation , writerStandalone = True+ , writerSectionDivs = True+ , writerHtml5 = epub3+ , writerTableOfContents = False -- we always have one in epub+ , writerVariables = vars+ , writerHTMLMathMethod =+ if epub3+ then MathML Nothing+ else writerHTMLMathMethod opts , writerWrapText = False } let sourceDir = writerSourceDirectory opts'- let vars = writerVariables opts' let mbCoverImage = lookup "epub-cover-image" vars - titlePageTemplate <- readDataFile (writerUserDataDir opts)- $ "templates" </> "epub-titlepage" <.> "html"-- coverImageTemplate <- readDataFile (writerUserDataDir opts)- $ "templates" </> "epub-coverimage" <.> "html"-- pageTemplate <- readDataFile (writerUserDataDir opts)- $ "templates" </> "epub-page" <.> "html"- -- cover page (cpgEntry, cpicEntry) <- case mbCoverImage of Nothing -> return ([],[]) Just img -> do let coverImage = "cover-image" ++ takeExtension img- let cpContent = fromString $ writeHtmlString- opts'{writerTemplate = coverImageTemplate,- writerVariables = ("coverimage",coverImage):vars}- (Pandoc meta [])+ let cpContent = renderHtml $ writeHtml opts'+ (Pandoc meta [RawBlock "html" $ "<div id=\"cover-image\">\n<img src=\"" ++ coverImage ++ "\" alt=\"cover image\" />\n</div>"]) imgContent <- B.readFile img return ( [mkEntry "cover.xhtml" cpContent] , [mkEntry coverImage imgContent] ) -- title page- let tpContent = fromString $ writeHtmlString- opts'{writerTemplate = titlePageTemplate}- (Pandoc meta [])+ let tpContent = renderHtml $ writeHtml opts'{+ writerVariables = ("titlepage","true"):vars }+ (Pandoc meta []) let tpEntry = mkEntry "title_page.xhtml" tpContent -- handle pictures picsRef <- newIORef [] Pandoc _ blocks <- bottomUpM- (transformInlines (writerHTMLMathMethod opts) sourceDir picsRef) doc+ (transformInlines (writerHTMLMathMethod opts') sourceDir picsRef) doc pics <- readIORef picsRef- let readPicEntry (oldsrc, newsrc) = readEntry [] oldsrc >>= \e ->- return e{ eRelativePath = newsrc }+ let readPicEntry (oldsrc, newsrc) = do+ (img,_) <- fetchItem sourceDir oldsrc+ return $ toEntry newsrc epochtime $ B.fromChunks . (:[]) $ img picEntries <- mapM readPicEntry pics -- handle fonts let mkFontEntry f = mkEntry (takeFileName f) `fmap` B.readFile f- fontEntries <- mapM mkFontEntry fonts+ fontEntries <- mapM mkFontEntry $ writerEpubFonts opts' -- body pages- let isH1 (Header 1 _) = True- isH1 _ = False++ -- add level 1 header to beginning if none there+ let blocks' = addIdentifiers+ $ case blocks of+ (Header 1 _ _ : _) -> blocks+ _ -> Header 1 ("",[],[]) (docTitle meta) : blocks++ let chapterHeaderLevel = writerEpubChapterLevel opts -- internal reference IDs change when we chunk the file,- -- so the next two lines fix that:- let reftable = correlateRefs blocks- let blocks' = replaceRefs reftable blocks- let h1Indices = dropWhile (== 0) $ findIndices isH1 blocks'- let chunks = splitByIndices h1Indices blocks'- let titleize (Header 1 xs : ys) = Pandoc meta{docTitle = xs} ys- titleize xs = Pandoc meta xs- let chapters = map titleize chunks- let chapToHtml = writeHtmlString opts'{ writerTemplate = pageTemplate }- let chapterToEntry :: Int -> Pandoc -> Entry- chapterToEntry num chap = mkEntry ("ch" ++ show num ++ ".xhtml") $- fromString $ chapToHtml chap- let chapterEntries = zipWith chapterToEntry [1..] chapters+ -- so that '#my-header-1' might turn into 'chap004.xhtml#my-header'.+ -- the next two lines fix that:+ let reftable = correlateRefs chapterHeaderLevel blocks'+ let blocks'' = replaceRefs reftable blocks' + let isChapterHeader (Header n _ _) = n <= chapterHeaderLevel+ isChapterHeader _ = False++ let toChunks :: [Block] -> [[Block]]+ toChunks [] = []+ toChunks (b:bs) = (b:xs) : toChunks ys+ where (xs,ys) = break isChapterHeader bs++ let chunks = toChunks blocks''++ let chapToEntry :: Int -> [Block] -> Entry+ chapToEntry num bs = mkEntry (showChapter num)+ $ renderHtml+ $ writeHtml opts'+ $ case bs of+ (Header _ _ xs : _) -> Pandoc (Meta xs [] []) bs+ _ -> Pandoc (Meta [] [] []) bs++ let chapterEntries = zipWith chapToEntry [1..] chunks++ -- incredibly inefficient (TODO):+ let containsMathML ent = "<math" `isInfixOf` (B8.unpack $ fromEntry ent)+ -- contents.opf localeLang <- catch (liftM (map (\c -> if c == '_' then '-' else c) . takeWhile (/='.')) $ getEnv "LANG")@@ -138,9 +163,11 @@ Nothing -> localeLang uuid <- getRandomUUID let chapterNode ent = unode "item" !- [("id", takeBaseName $ eRelativePath ent),- ("href", eRelativePath ent),- ("media-type", "application/xhtml+xml")] $ ()+ ([("id", takeBaseName $ eRelativePath ent),+ ("href", eRelativePath ent),+ ("media-type", "application/xhtml+xml")]+ ++ [("properties","mathml") | epub3 &&+ containsMathML ent]) $ () let chapterRefNode ent = unode "itemref" ! [("idref", takeBaseName $ eRelativePath ent)] $ () let pictureNode ent = unode "item" !@@ -152,24 +179,34 @@ [("id", takeBaseName $ eRelativePath ent), ("href", eRelativePath ent), ("media-type", maybe "" id $ getMimeType $ eRelativePath ent)] $ ()- let plainify t = removeTrailingSpace $+ let plainify t = trimr $ writePlain opts'{ writerStandalone = False } $ Pandoc meta [Plain t] let plainTitle = plainify $ docTitle meta let plainAuthors = map plainify $ docAuthors meta- let plainDate = maybe "" id $ normalizeDate $ stringify $ docDate meta- let contentsData = fromString $ ppTopElement $- unode "package" ! [("version","2.0")+ currentTime <- getCurrentTime+ let plainDate = maybe (showDateTimeISO8601 currentTime) id+ $ normalizeDate $ stringify $ docDate meta+ let contentsData = fromStringLazy $ ppTopElement $+ unode "package" ! [("version", case version of+ EPUB2 -> "2.0"+ EPUB3 -> "3.0") ,("xmlns","http://www.idpf.org/2007/opf") ,("unique-identifier","BookId")] $- [ metadataElement (writerEPUBMetadata opts')- uuid lang plainTitle plainAuthors plainDate mbCoverImage+ [ metadataElement version (writerEpubMetadata opts')+ uuid lang plainTitle plainAuthors plainDate currentTime mbCoverImage , unode "manifest" $ [ unode "item" ! [("id","ncx"), ("href","toc.ncx") ,("media-type","application/x-dtbncx+xml")] $ () , unode "item" ! [("id","style"), ("href","stylesheet.css") ,("media-type","text/css")] $ () ] +++ [ unode "item" ! [("id","nav")+ ,("href","nav.xhtml")+ ,("properties","nav")+ ,("media-type","application/xhtml+xml")] $ ()+ | version == EPUB3+ ] ++ map chapterNode (cpgEntry ++ (tpEntry : chapterEntries)) ++ map pictureNode (cpicEntry ++ picEntries) ++ map fontNode fontEntries@@ -183,14 +220,44 @@ let contentsEntry = mkEntry "content.opf" contentsData -- toc.ncx- let navPointNode ent n tit = unode "navPoint" !- [("id", "navPoint-" ++ show n)- ,("playOrder", show n)] $- [ unode "navLabel" $ unode "text" tit- , unode "content" ! [("src",- eRelativePath ent)] $ ()- ]- let tocData = fromString $ ppTopElement $+ let secs = hierarchicalize blocks''++ let tocLevel = writerTOCDepth opts++ let navPointNode :: (Int -> String -> String -> [Element] -> Element)+ -> Shared.Element -> State Int Element+ navPointNode formatter (Sec _ nums ident ils children) = do+ n <- get+ modify (+1)+ let showNums :: [Int] -> String+ showNums = intercalate "." . map show+ let tit' = plainify ils+ let tit = if writerNumberSections opts+ then showNums nums ++ " " ++ tit'+ else tit'+ let src = case lookup ident reftable of+ Just x -> x+ Nothing -> error (ident ++ " not found in reftable")+ let isSec (Sec lev _ _ _ _) = lev <= tocLevel+ isSec _ = False+ let subsecs = filter isSec children+ subs <- mapM (navPointNode formatter) subsecs+ return $ formatter n tit src subs+ navPointNode _ (Blk _) = error "navPointNode encountered Blk"++ let navMapFormatter :: Int -> String -> String -> [Element] -> Element+ navMapFormatter n tit src subs = unode "navPoint" !+ [("id", "navPoint-" ++ show n)+ ,("playOrder", show n)] $+ [ unode "navLabel" $ unode "text" tit+ , unode "content" ! [("src", src)] $ ()+ ] ++ subs++ let tpNode = unode "navPoint" ! [("id", "navPoint-0")] $+ [ unode "navLabel" $ unode "text" (plainify $ docTitle meta)+ , unode "content" ! [("src","title_page.xhtml")] $ () ]++ let tocData = fromStringLazy $ ppTopElement $ unode "ncx" ! [("version","2005-1") ,("xmlns","http://www.daisy.org/z3986/2005/ncx/")] $ [ unode "head" $@@ -207,18 +274,36 @@ Just _ -> [unode "meta" ! [("name","cover"), ("content","cover-image")] $ ()] , unode "docTitle" $ unode "text" $ plainTitle- , unode "navMap" $ zipWith3 navPointNode (tpEntry : chapterEntries)- [1..(length chapterEntries + 1)]- ("Title Page" : map (\(Pandoc m _) ->- plainify $ docTitle m) chapters)+ , unode "navMap" $+ tpNode : evalState (mapM (navPointNode navMapFormatter) secs) 1 ] let tocEntry = mkEntry "toc.ncx" tocData + let navXhtmlFormatter :: Int -> String -> String -> [Element] -> Element+ navXhtmlFormatter n tit src subs = unode "li" !+ [("id", "toc-li-" ++ show n)] $+ (unode "a" ! [("href",src)]+ $ (unode "span" tit))+ : case subs of+ [] -> []+ (_:_) -> [unode "ol" subs]++ let navData = fromStringLazy $ ppTopElement $+ unode "html" ! [("xmlns","http://www.w3.org/1999/xhtml")+ ,("xmlns:epub","http://www.idpf.org/2007/ops")] $+ [ unode "head" $ unode "title" plainTitle+ , unode "body" $+ unode "nav" ! [("epub:type","toc")] $+ [ unode "h1" plainTitle+ , unode "ol" $ evalState (mapM (navPointNode navXhtmlFormatter) secs) 1]+ ]+ let navEntry = mkEntry "nav.xhtml" navData+ -- mimetype- let mimetypeEntry = mkEntry "mimetype" $ fromString "application/epub+zip"+ let mimetypeEntry = mkEntry "mimetype" $ fromStringLazy "application/epub+zip" -- container.xml- let containerData = fromString $ ppTopElement $+ let containerData = fromStringLazy $ ppTopElement $ unode "container" ! [("version","1.0") ,("xmlns","urn:oasis:names:tc:opendocument:xmlns:container")] $ unode "rootfiles" $@@ -227,54 +312,65 @@ let containerEntry = mkEntry "META-INF/container.xml" containerData -- com.apple.ibooks.display-options.xml- let apple = fromString $ ppTopElement $+ let apple = fromStringLazy $ ppTopElement $ unode "display_options" $ unode "platform" ! [("name","*")] $ unode "option" ! [("name","specified-fonts")] $ "true" let appleEntry = mkEntry "META-INF/com.apple.ibooks.display-options.xml" apple -- stylesheet- stylesheet <- case mbStylesheet of+ stylesheet <- case writerEpubStylesheet opts of Just s -> return s- Nothing -> readDataFile (writerUserDataDir opts) "epub.css"- let stylesheetEntry = mkEntry "stylesheet.css" $ fromString stylesheet+ Nothing -> toString `fmap`+ readDataFile (writerUserDataDir opts) "epub.css"+ let stylesheetEntry = mkEntry "stylesheet.css" $ fromStringLazy stylesheet -- construct archive let archive = foldr addEntryToArchive emptyArchive (mimetypeEntry : containerEntry : appleEntry : stylesheetEntry : tpEntry : contentsEntry : tocEntry :- (picEntries ++ cpicEntry ++ cpgEntry ++ chapterEntries ++ fontEntries) )+ ([navEntry | version == EPUB3] ++ picEntries ++ cpicEntry ++ cpgEntry +++ chapterEntries ++ fontEntries) ) return $ fromArchive archive -metadataElement :: String -> UUID -> String -> String -> [String] -> String -> Maybe a -> Element-metadataElement metadataXML uuid lang title authors date mbCoverImage =+metadataElement :: EPUBVersion -> String -> UUID -> String -> String -> [String]+ -> String -> UTCTime -> Maybe a -> Element+metadataElement version metadataXML uuid lang title authors date currentTime mbCoverImage = let userNodes = parseXML metadataXML elt = unode "metadata" ! [("xmlns:dc","http://purl.org/dc/elements/1.1/") ,("xmlns:opf","http://www.idpf.org/2007/opf")] $- filter isDublinCoreElement $ onlyElems userNodes+ filter isMetadataElement $ onlyElems userNodes dublinElements = ["contributor","coverage","creator","date", "description","format","identifier","language","publisher", "relation","rights","source","subject","title","type"]- isDublinCoreElement e = qPrefix (elName e) == Just "dc" &&- qName (elName e) `elem` dublinElements+ isMetadataElement e = (qPrefix (elName e) == Just "dc" &&+ qName (elName e) `elem` dublinElements) ||+ (qPrefix (elName e) == Nothing &&+ qName (elName e) `elem` ["link","meta"]) contains e n = not (null (findElements (QName n Nothing (Just "dc")) e)) newNodes = [ unode "dc:title" title | not (elt `contains` "title") ] ++ [ unode "dc:language" lang | not (elt `contains` "language") ] ++ [ unode "dc:identifier" ! [("id","BookId")] $ show uuid | not (elt `contains` "identifier") ] ++- [ unode "dc:creator" ! [("opf:role","aut")] $ a | a <- authors ] +++ [ unode "dc:creator" ! [("opf:role","aut") | version == EPUB2]+ $ a | a <- authors ] ++ [ unode "dc:date" date | not (elt `contains` "date") ] +++ [ unode "meta" ! [("property", "dcterms:modified")] $+ (showDateTimeISO8601 currentTime) | version == EPUB3 ] ++ [ unode "meta" ! [("name","cover"), ("content","cover-image")] $ () | not (isNothing mbCoverImage) ] in elt{ elContent = elContent elt ++ map Elem newNodes } +showDateTimeISO8601 :: UTCTime -> String+showDateTimeISO8601 = formatTime defaultTimeLocale "%FT%TZ"+ transformInlines :: HTMLMathMethod -> FilePath -> IORef [(FilePath, FilePath)] -- ^ (oldpath, newpath) images -> [Inline] -> IO [Inline]-transformInlines _ _ _ (Image lab (src,_) : xs) | isNothing (imageTypeOf src) =- return $ Emph lab : xs+transformInlines _ _ _ (Image lab (src,_) : xs)+ | isNothing (imageTypeOf src) = return $ Emph lab : xs transformInlines _ sourceDir picsRef (Image lab (src,tit) : xs) = do let src' = unEscapeString src pics <- readIORef picsRef@@ -288,17 +384,12 @@ return new return $ Image lab (newsrc, tit) : xs transformInlines (MathML _) _ _ (x@(Math _ _) : xs) = do- let writeHtmlInline opts z = removeTrailingSpace $+ -- note: ideally we'd use a switch statement to provide a fallback+ -- but switch does not seem to be widely implemented yet, so we just+ -- provide the mathml+ let writeHtmlInline opts z = trimr $ writeHtmlString opts $ Pandoc (Meta [] [] []) [Plain [z]]- mathml = writeHtmlInline defaultWriterOptions{- writerHTMLMathMethod = MathML Nothing } x- fallback = writeHtmlInline defaultWriterOptions{- writerHTMLMathMethod = PlainMath } x- inOps = "<ops:switch xmlns:ops=\"http://www.idpf.org/2007/ops\">" ++- "<ops:case required-namespace=\"http://www.w3.org/1998/Math/MathML\">" ++- mathml ++ "</ops:case><ops:default>" ++ fallback ++ "</ops:default>" ++- "</ops:switch>"- result = if "<math" `isPrefixOf` mathml then inOps else mathml+ result = writeHtmlInline def{writerHTMLMathMethod = MathML Nothing } x return $ RawInline "html" result : xs transformInlines _ _ _ xs = return xs @@ -314,9 +405,9 @@ unEntity ('&':'#':xs) = let (ds,ys) = break (==';') xs rest = drop 1 ys- in case reads ('\'':'\\':ds ++ "'") of- ((x,_):_) -> x : unEntity rest- _ -> '&':'#':unEntity xs+ in case safeRead ('\'':'\\':ds ++ "'") of+ Just x -> x : unEntity rest+ Nothing -> '&':'#':unEntity xs unEntity (x:xs) = x : unEntity xs imageTypeOf :: FilePath -> Maybe String@@ -332,38 +423,45 @@ data IdentState = IdentState{ chapterNumber :: Int,- runningIdents :: [String],- chapterIdents :: [String], identTable :: [(String,String)] } deriving (Read, Show) +-- Returns filename for chapter number.+showChapter :: Int -> String+showChapter = printf "ch%03d.xhtml"++-- Add identifiers to any headers without them.+addIdentifiers :: [Block] -> [Block]+addIdentifiers bs = evalState (mapM go bs) []+ where go (Header n (ident,classes,kvs) ils) = do+ ids <- get+ let ident' = if null ident+ then uniqueIdent ils ids+ else ident+ put $ ident' : ids+ return $ Header n (ident',classes,kvs) ils+ go x = return x+ -- Go through a block list and construct a table -- correlating the automatically constructed references -- that would be used in a normal pandoc document with -- new URLs to be used in the EPUB. For example, what--- was "header-1" might turn into "ch6.xhtml#header".-correlateRefs :: [Block] -> [(String,String)]-correlateRefs bs = identTable $ execState (mapM_ go bs)- IdentState{ chapterNumber = 0- , runningIdents = []- , chapterIdents = []- , identTable = [] }+-- was "header-1" might turn into "ch006.xhtml#header".+correlateRefs :: Int -> [Block] -> [(String,String)]+correlateRefs chapterHeaderLevel bs =+ identTable $ execState (mapM_ go bs)+ IdentState{ chapterNumber = 0+ , identTable = [] } where go :: Block -> State IdentState ()- go (Header n ils) = do- when (n == 1) $- modify $ \s -> s{ chapterNumber = chapterNumber s + 1- , chapterIdents = [] }+ go (Header n (ident,_,_) _) = do+ when (n <= chapterHeaderLevel) $+ modify $ \s -> s{ chapterNumber = chapterNumber s + 1 } st <- get- let runningid = uniqueIdent ils (runningIdents st)- let chapid = if n == 1- then Nothing- else Just $ uniqueIdent ils (chapterIdents st)- modify $ \s -> s{ runningIdents = runningid : runningIdents st- , chapterIdents = maybe (chapterIdents st)- (: chapterIdents st) chapid- , identTable = (runningid, "ch" ++ show (chapterNumber st) ++- ".xhtml" ++ maybe "" ('#':) chapid) : identTable st- }+ let chapterid = showChapter (chapterNumber st) +++ if n <= chapterHeaderLevel+ then ""+ else '#' : ident+ modify $ \s -> s{ identTable = (ident, chapterid) : identTable st } go _ = return () -- Replace internal link references using the table produced
@@ -0,0 +1,618 @@+{-+Copyright (c) 2011-2012, Sergey Astanin+All rights reserved.++This program is free software; you can redistribute it and/or modify+it under the terms of the GNU General Public License as published by+the Free Software Foundation; either version 2 of the License, or+(at your option) any later version.++This program is distributed in the hope that it will be useful,+but WITHOUT ANY WARRANTY; without even the implied warranty of+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+GNU General Public License for more details.++You should have received a copy of the GNU General Public License+along with this program; if not, write to the Free Software+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA+-}++{- | Conversion of 'Pandoc' documents to FB2 (FictionBook2) format.++FictionBook is an XML-based e-book format. For more information see:+<http://www.fictionbook.org/index.php/Eng:XML_Schema_Fictionbook_2.1>++-}+module Text.Pandoc.Writers.FB2 (writeFB2) where++import Control.Monad.State (StateT, evalStateT, get, modify)+import Control.Monad.State (liftM, liftM2, liftIO)+import Data.ByteString.Base64 (encode)+import Data.Char (toUpper, toLower, isSpace, isAscii, isControl)+import Data.List (intersperse, intercalate, isPrefixOf)+import Data.Either (lefts, rights)+import Network.Browser (browse, request, setAllowRedirects, setOutHandler)+import Network.HTTP (catchIO_, getRequest, getHeaders, getResponseBody)+import Network.HTTP (lookupHeader, HeaderName(..), urlEncode)+import Network.URI (isURI, unEscapeString)+import System.FilePath (takeExtension)+import Text.XML.Light+import qualified Control.Exception as E+import qualified Data.ByteString as B+import qualified Text.XML.Light as X+import qualified Text.XML.Light.Cursor as XC++import Text.Pandoc.Definition+import Text.Pandoc.Options (WriterOptions(..), HTMLMathMethod(..), def)+import Text.Pandoc.Shared (orderedListMarkers)+import Text.Pandoc.Generic (bottomUp)++-- | Data to be written at the end of the document:+-- (foot)notes, URLs, references, images.+data FbRenderState = FbRenderState+ { footnotes :: [ (Int, String, [Content]) ] -- ^ #, ID, text+ , imagesToFetch :: [ (String, String) ] -- ^ filename, URL or path+ , parentListMarker :: String -- ^ list marker of the parent ordered list+ , parentBulletLevel :: Int -- ^ nesting level of the unordered list+ , writerOptions :: WriterOptions+ } deriving (Show)++-- | FictionBook building monad.+type FBM = StateT FbRenderState IO++newFB :: FbRenderState+newFB = FbRenderState { footnotes = [], imagesToFetch = []+ , parentListMarker = "", parentBulletLevel = 0+ , writerOptions = def }++data ImageMode = NormalImage | InlineImage deriving (Eq)+instance Show ImageMode where+ show NormalImage = "imageType"+ show InlineImage = "inlineImageType"++-- | Produce an FB2 document from a 'Pandoc' document.+writeFB2 :: WriterOptions -- ^ conversion options+ -> Pandoc -- ^ document to convert+ -> IO String -- ^ FictionBook2 document (not encoded yet)+writeFB2 opts (Pandoc meta blocks) = flip evalStateT newFB $ do+ modify (\s -> s { writerOptions = opts { writerStandalone = True } })+ desc <- description meta+ fp <- frontpage meta+ secs <- renderSections 1 blocks+ let body = el "body" $ fp ++ secs+ notes <- renderFootnotes+ (imgs,missing) <- liftM imagesToFetch get >>= \s -> liftIO (fetchImages s)+ let body' = replaceImagesWithAlt missing body+ let fb2_xml = el "FictionBook" (fb2_attrs, [desc, body'] ++ notes ++ imgs)+ return $ xml_head ++ (showContent fb2_xml)+ where+ xml_head = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"+ fb2_attrs =+ let xmlns = "http://www.gribuser.ru/xml/fictionbook/2.0"+ xlink = "http://www.w3.org/1999/xlink"+ in [ uattr "xmlns" xmlns+ , attr ("xmlns", "l") xlink ]+ --+ frontpage :: Meta -> FBM [Content]+ frontpage meta' = do+ t <- cMapM toXml . docTitle $ meta'+ return $+ [ el "title" (el "p" t)+ , el "annotation" (map (el "p" . cMap plain)+ (docAuthors meta' ++ [docDate meta']))+ ]+ description :: Meta -> FBM Content+ description meta' = do+ bt <- booktitle meta'+ let as = authors meta'+ dd <- docdate meta'+ return $ el "description"+ [ el "title-info" (bt ++ as ++ dd)+ , el "document-info" [ el "program-used" "pandoc" ] -- FIXME: +version+ ]+ booktitle :: Meta -> FBM [Content]+ booktitle meta' = do+ t <- cMapM toXml . docTitle $ meta'+ return $ if null t+ then []+ else [ el "book-title" t ]+ authors :: Meta -> [Content]+ authors meta' = cMap author (docAuthors meta')+ author :: [Inline] -> [Content]+ author ss =+ let ws = words . cMap plain $ ss+ email = (el "email") `fmap` (take 1 $ filter ('@' `elem`) ws)+ ws' = filter ('@' `notElem`) ws+ names = case ws' of+ (nickname:[]) -> [ el "nickname" nickname ]+ (fname:lname:[]) -> [ el "first-name" fname+ , el "last-name" lname ]+ (fname:rest) -> [ el "first-name" fname+ , el "middle-name" (concat . init $ rest)+ , el "last-name" (last rest) ]+ ([]) -> []+ in list $ el "author" (names ++ email)+ docdate :: Meta -> FBM [Content]+ docdate meta' = do+ let ss = docDate meta'+ d <- cMapM toXml ss+ return $ if null d+ then []+ else [el "date" d]++-- | Divide the stream of blocks into sections and convert to XML+-- representation.+renderSections :: Int -> [Block] -> FBM [Content]+renderSections level blocks = do+ let secs = splitSections level blocks+ mapM (renderSection level) secs++renderSection :: Int -> ([Inline], [Block]) -> FBM Content+renderSection level (ttl, body) = do+ title <- if null ttl+ then return []+ else return . list . el "title" . formatTitle $ ttl+ content <- if (hasSubsections body)+ then renderSections (level + 1) body+ else cMapM blockToXml body+ return $ el "section" (title ++ content)+ where+ hasSubsections = any isHeader+ isHeader (Header _ _ _) = True+ isHeader _ = False++-- | Only <p> and <empty-line> are allowed within <title> in FB2.+formatTitle :: [Inline] -> [Content]+formatTitle inlines =+ let lns = split isLineBreak inlines+ lns' = map (el "p" . cMap plain) lns+ in intersperse (el "empty-line" ()) lns'++split :: (a -> Bool) -> [a] -> [[a]]+split _ [] = []+split cond xs = let (b,a) = break cond xs+ in (b:split cond (drop 1 a))++isLineBreak :: Inline -> Bool+isLineBreak LineBreak = True+isLineBreak _ = False++-- | Divide the stream of block elements into sections: [(title, blocks)].+splitSections :: Int -> [Block] -> [([Inline], [Block])]+splitSections level blocks = reverse $ revSplit (reverse blocks)+ where+ revSplit [] = []+ revSplit rblocks =+ let (lastsec, before) = break sameLevel rblocks+ (header, prevblocks) =+ case before of+ ((Header n _ title):prevblocks') ->+ if n == level+ then (title, prevblocks')+ else ([], before)+ _ -> ([], before)+ in (header, reverse lastsec) : revSplit prevblocks+ sameLevel (Header n _ _) = n == level+ sameLevel _ = False++-- | Make another FictionBook body with footnotes.+renderFootnotes :: FBM [Content]+renderFootnotes = do+ fns <- footnotes `liftM` get+ if null fns+ then return [] -- no footnotes+ else return . list $+ el "body" ([uattr "name" "notes"], map renderFN (reverse fns))+ where+ renderFN (n, idstr, cs) =+ let fn_texts = (el "title" (el "p" (show n))) : cs+ in el "section" ([uattr "id" idstr], fn_texts)++-- | Fetch images and encode them for the FictionBook XML.+-- Return image data and a list of hrefs of the missing images.+fetchImages :: [(String,String)] -> IO ([Content],[String])+fetchImages links = do+ imgs <- mapM (uncurry fetchImage) links+ return $ (rights imgs, lefts imgs)++-- | Fetch image data from disk or from network and make a <binary> XML section.+-- Return either (Left hrefOfMissingImage) or (Right xmlContent).+fetchImage :: String -> String -> IO (Either String Content)+fetchImage href link = do+ mbimg <-+ case (isURI link, readDataURI link) of+ (True, Just (mime,_,True,base64)) ->+ let mime' = map toLower mime+ in if mime' == "image/png" || mime' == "image/jpeg"+ then return (Just (mime',base64))+ else return Nothing+ (True, Just _) -> return Nothing -- not base64-encoded+ (True, Nothing) -> fetchURL link+ (False, _) -> do+ d <- nothingOnError $ B.readFile (unEscapeString link)+ let t = case map toLower (takeExtension link) of+ ".png" -> Just "image/png"+ ".jpg" -> Just "image/jpeg"+ ".jpeg" -> Just "image/jpeg"+ ".jpe" -> Just "image/jpeg"+ _ -> Nothing -- only PNG and JPEG are supported in FB2+ return $ liftM2 (,) t (liftM (toStr . encode) d)+ case mbimg of+ Just (imgtype, imgdata) -> do+ return . Right $ el "binary"+ ( [uattr "id" href+ , uattr "content-type" imgtype]+ , txt imgdata )+ _ -> return (Left ('#':href))+ where+ nothingOnError :: (IO B.ByteString) -> (IO (Maybe B.ByteString))+ nothingOnError action = liftM Just action `E.catch` omnihandler+ omnihandler :: E.SomeException -> IO (Maybe B.ByteString)+ omnihandler _ = return Nothing++-- | Extract mime type and encoded data from the Data URI.+readDataURI :: String -- ^ URI+ -> Maybe (String,String,Bool,String)+ -- ^ Maybe (mime,charset,isBase64,data)+readDataURI uri =+ let prefix = "data:"+ in if not (prefix `isPrefixOf` uri)+ then Nothing+ else+ let rest = drop (length prefix) uri+ meta = takeWhile (/= ',') rest -- without trailing ','+ uridata = drop (length meta + 1) rest+ parts = split (== ';') meta+ (mime,cs,enc)=foldr upd ("text/plain","US-ASCII",False) parts+ in Just (mime,cs,enc,uridata)+ where+ upd str m@(mime,cs,enc)+ | isMimeType str = (str,cs,enc)+ | "charset=" `isPrefixOf` str = (mime,drop (length "charset=") str,enc)+ | str == "base64" = (mime,cs,True)+ | otherwise = m++-- Without parameters like ;charset=...; see RFC 2045, 5.1+isMimeType :: String -> Bool+isMimeType s =+ case split (=='/') s of+ [mtype,msubtype] ->+ ((map toLower mtype) `elem` types+ || "x-" `isPrefixOf` (map toLower mtype))+ && all valid mtype+ && all valid msubtype+ _ -> False+ where+ types = ["text","image","audio","video","application","message","multipart"]+ valid c = isAscii c && not (isControl c) && not (isSpace c) &&+ c `notElem` "()<>@,;:\\\"/[]?="++-- | Fetch URL, return its Content-Type and binary data on success.+fetchURL :: String -> IO (Maybe (String, String))+fetchURL url = do+ flip catchIO_ (return Nothing) $ do+ r <- browse $ do+ setOutHandler (const (return ()))+ setAllowRedirects True+ liftM snd . request . getRequest $ url+ let content_type = lookupHeader HdrContentType (getHeaders r)+ content <- liftM (Just . toStr . encode . toBS) . getResponseBody $ Right r+ return $ liftM2 (,) content_type content+ where++toBS :: String -> B.ByteString+toBS = B.pack . map (toEnum . fromEnum)++toStr :: B.ByteString -> String+toStr = map (toEnum . fromEnum) . B.unpack++footnoteID :: Int -> String+footnoteID i = "n" ++ (show i)++linkID :: Int -> String+linkID i = "l" ++ (show i)++-- | Convert a block-level Pandoc's element to FictionBook XML representation.+blockToXml :: Block -> FBM [Content]+blockToXml (Plain ss) = cMapM toXml ss -- FIXME: can lead to malformed FB2+blockToXml (Para [Math DisplayMath formula]) = insertMath NormalImage formula+-- title beginning with fig: indicates that the image is a figure+blockToXml (Para [Image alt (src,'f':'i':'g':':':tit)]) =+ insertImage NormalImage (Image alt (src,tit))+blockToXml (Para ss) = liftM (list . el "p") $ cMapM toXml ss+blockToXml (CodeBlock _ s) = return . spaceBeforeAfter .+ map (el "p" . el "code") . lines $ s+blockToXml (RawBlock _ s) = return . spaceBeforeAfter .+ map (el "p" . el "code") . lines $ s+blockToXml (BlockQuote bs) = liftM (list . el "cite") $ cMapM blockToXml bs+blockToXml (OrderedList a bss) = do+ state <- get+ let pmrk = parentListMarker state+ let markers = map ((pmrk ++ " ") ++) $ orderedListMarkers a+ let mkitem mrk bs = do+ modify (\s -> s { parentListMarker = mrk })+ itemtext <- cMapM blockToXml . paraToPlain $ bs+ modify (\s -> s { parentListMarker = pmrk }) -- old parent marker+ return . el "p" $ [ txt mrk, txt " " ] ++ itemtext+ mapM (uncurry mkitem) (zip markers bss)+blockToXml (BulletList bss) = do+ state <- get+ let level = parentBulletLevel state+ let pmrk = parentListMarker state+ let prefix = replicate (length pmrk) ' '+ let bullets = ["\x2022", "\x25e6", "*", "\x2043", "\x2023"]+ let mrk = prefix ++ bullets !! (level `mod` (length bullets))+ let mkitem bs = do+ modify (\s -> s { parentBulletLevel = (level+1) })+ itemtext <- cMapM blockToXml . paraToPlain $ bs+ modify (\s -> s { parentBulletLevel = level }) -- restore bullet level+ return $ el "p" $ [ txt (mrk ++ " ") ] ++ itemtext+ mapM mkitem bss+blockToXml (DefinitionList defs) =+ cMapM mkdef defs+ where+ mkdef (term, bss) = do+ def' <- cMapM (cMapM blockToXml . sep . paraToPlain . map indent) bss+ t <- wrap "strong" term+ return [ el "p" t, el "p" def' ]+ sep blocks =+ if all needsBreak blocks then+ blocks ++ [Plain [LineBreak]]+ else+ blocks+ needsBreak (Para _) = False+ needsBreak (Plain ins) = LineBreak `notElem` ins+ needsBreak _ = True+blockToXml (Header _ _ _) = -- should never happen, see renderSections+ error "unexpected header in section text"+blockToXml HorizontalRule = return+ [ el "empty-line" ()+ , el "p" (txt (replicate 10 '—'))+ , el "empty-line" () ]+blockToXml (Table caption aligns _ headers rows) = do+ hd <- mkrow "th" headers aligns+ bd <- mapM (\r -> mkrow "td" r aligns) rows+ c <- return . el "emphasis" =<< cMapM toXml caption+ return [el "table" (hd : bd), el "p" c]+ where+ mkrow :: String -> [TableCell] -> [Alignment] -> FBM Content+ mkrow tag cells aligns' =+ (el "tr") `liftM` (mapM (mkcell tag) (zip cells aligns'))+ --+ mkcell :: String -> (TableCell, Alignment) -> FBM Content+ mkcell tag (cell, align) = do+ cblocks <- cMapM blockToXml cell+ return $ el tag ([align_attr align], cblocks)+ --+ align_attr a = Attr (QName "align" Nothing Nothing) (align_str a)+ align_str AlignLeft = "left"+ align_str AlignCenter = "center"+ align_str AlignRight = "right"+ align_str AlignDefault = "left"+blockToXml Null = return []++-- Replace paragraphs with plain text and line break.+-- Necessary to simulate multi-paragraph lists in FB2.+paraToPlain :: [Block] -> [Block]+paraToPlain [] = []+paraToPlain (Para inlines : rest) =+ let p = (Plain (inlines ++ [LineBreak]))+ in p : paraToPlain rest+paraToPlain (p:rest) = p : paraToPlain rest++-- Simulate increased indentation level. Will not really work+-- for multi-line paragraphs.+indent :: Block -> Block+indent = indentBlock+ where+ -- indentation space+ spacer :: String+ spacer = replicate 4 ' '+ --+ indentBlock (Plain ins) = Plain ((Str spacer):ins)+ indentBlock (Para ins) = Para ((Str spacer):ins)+ indentBlock (CodeBlock a s) =+ let s' = unlines . map (spacer++) . lines $ s+ in CodeBlock a s'+ indentBlock (BlockQuote bs) = BlockQuote (map indent bs)+ indentBlock (Header l attr' ins) = Header l attr' (indentLines ins)+ indentBlock everythingElse = everythingElse+ -- indent every (explicit) line+ indentLines :: [Inline] -> [Inline]+ indentLines ins = let lns = split isLineBreak ins :: [[Inline]]+ in intercalate [LineBreak] $ map ((Str spacer):) lns++-- | Convert a Pandoc's Inline element to FictionBook XML representation.+toXml :: Inline -> FBM [Content]+toXml (Str s) = return [txt s]+toXml (Emph ss) = list `liftM` wrap "emphasis" ss+toXml (Strong ss) = list `liftM` wrap "strong" ss+toXml (Strikeout ss) = list `liftM` wrap "strikethrough" ss+toXml (Superscript ss) = list `liftM` wrap "sup" ss+toXml (Subscript ss) = list `liftM` wrap "sub" ss+toXml (SmallCaps ss) = cMapM toXml $ bottomUp (map toUpper) ss+toXml (Quoted SingleQuote ss) = do -- FIXME: should be language-specific+ inner <- cMapM toXml ss+ return $ [txt "‘"] ++ inner ++ [txt "’"]+toXml (Quoted DoubleQuote ss) = do+ inner <- cMapM toXml ss+ return $ [txt "“"] ++ inner ++ [txt "”"]+toXml (Cite _ ss) = cMapM toXml ss -- FIXME: support citation styles+toXml (Code _ s) = return [el "code" s]+toXml Space = return [txt " "]+toXml LineBreak = return [el "empty-line" ()]+toXml (Math _ formula) = insertMath InlineImage formula+toXml (RawInline _ _) = return [] -- raw TeX and raw HTML are suppressed+toXml (Link text (url,ttl)) = do+ fns <- footnotes `liftM` get+ let n = 1 + length fns+ let ln_id = linkID n+ let ln_ref = list . el "sup" . txt $ "[" ++ show n ++ "]"+ ln_text <- cMapM toXml text+ let ln_desc =+ let ttl' = dropWhile isSpace ttl+ in if null ttl'+ then list . el "p" $ el "code" url+ else list . el "p" $ [ txt (ttl' ++ ": "), el "code" url ]+ modify (\s -> s { footnotes = (n, ln_id, ln_desc) : fns })+ return $ ln_text +++ [ el "a"+ ( [ attr ("l","href") ('#':ln_id)+ , uattr "type" "note" ]+ , ln_ref) ]+toXml img@(Image _ _) = insertImage InlineImage img+toXml (Note bs) = do+ fns <- footnotes `liftM` get+ let n = 1 + length fns+ let fn_id = footnoteID n+ fn_desc <- cMapM blockToXml bs+ modify (\s -> s { footnotes = (n, fn_id, fn_desc) : fns })+ let fn_ref = el "sup" . txt $ "[" ++ show n ++ "]"+ return . list $ el "a" ( [ attr ("l","href") ('#':fn_id)+ , uattr "type" "note" ]+ , fn_ref )++insertMath :: ImageMode -> String -> FBM [Content]+insertMath immode formula = do+ htmlMath <- return . writerHTMLMathMethod . writerOptions =<< get+ case htmlMath of+ WebTeX url -> do+ let alt = [Code nullAttr formula]+ let imgurl = url ++ urlEncode formula+ let img = Image alt (imgurl, "")+ insertImage immode img+ _ -> return [el "code" formula]++insertImage :: ImageMode -> Inline -> FBM [Content]+insertImage immode (Image alt (url,ttl)) = do+ images <- imagesToFetch `liftM` get+ let n = 1 + length images+ let fname = "image" ++ show n+ modify (\s -> s { imagesToFetch = (fname, url) : images })+ let ttlattr = case (immode, null ttl) of+ (NormalImage, False) -> [ uattr "title" ttl ]+ _ -> []+ return . list $+ el "image" $+ [ attr ("l","href") ('#':fname)+ , attr ("l","type") (show immode)+ , uattr "alt" (cMap plain alt) ]+ ++ ttlattr+insertImage _ _ = error "unexpected inline instead of image"++replaceImagesWithAlt :: [String] -> Content -> Content+replaceImagesWithAlt missingHrefs body =+ let cur = XC.fromContent body+ cur' = replaceAll cur+ in XC.toTree . XC.root $ cur'+ where+ --+ replaceAll :: XC.Cursor -> XC.Cursor+ replaceAll c =+ let n = XC.current c+ c' = if isImage n && isMissing n+ then XC.modifyContent replaceNode c+ else c+ in case XC.nextDF c' of+ (Just cnext) -> replaceAll cnext+ Nothing -> c' -- end of document+ --+ isImage :: Content -> Bool+ isImage (Elem e) = (elName e) == (uname "image")+ isImage _ = False+ --+ isMissing (Elem img@(Element _ _ _ _)) =+ let imgAttrs = elAttribs img+ badAttrs = map (attr ("l","href")) missingHrefs+ in any (`elem` imgAttrs) badAttrs+ isMissing _ = False+ --+ replaceNode :: Content -> Content+ replaceNode n@(Elem img@(Element _ _ _ _)) =+ let attrs = elAttribs img+ alt = getAttrVal attrs (uname "alt")+ imtype = getAttrVal attrs (qname "l" "type")+ in case (alt, imtype) of+ (Just alt', Just imtype') ->+ if imtype' == show NormalImage+ then el "p" alt'+ else txt alt'+ (Just alt', Nothing) -> txt alt' -- no type attribute+ _ -> n -- don't replace if alt text is not found+ replaceNode n = n+ --+ getAttrVal :: [X.Attr] -> QName -> Maybe String+ getAttrVal attrs name =+ case filter ((name ==) . attrKey) attrs of+ (a:_) -> Just (attrVal a)+ _ -> Nothing+++-- | Wrap all inlines with an XML tag (given its unqualified name).+wrap :: String -> [Inline] -> FBM Content+wrap tagname inlines = el tagname `liftM` cMapM toXml inlines++-- " Create a singleton list.+list :: a -> [a]+list = (:[])++-- | Convert an 'Inline' to plaintext.+plain :: Inline -> String+plain (Str s) = s+plain (Emph ss) = concat (map plain ss)+plain (Strong ss) = concat (map plain ss)+plain (Strikeout ss) = concat (map plain ss)+plain (Superscript ss) = concat (map plain ss)+plain (Subscript ss) = concat (map plain ss)+plain (SmallCaps ss) = concat (map plain ss)+plain (Quoted _ ss) = concat (map plain ss)+plain (Cite _ ss) = concat (map plain ss) -- FIXME+plain (Code _ s) = s+plain Space = " "+plain LineBreak = "\n"+plain (Math _ s) = s+plain (RawInline _ s) = s+plain (Link text (url,_)) = concat (map plain text ++ [" <", url, ">"])+plain (Image alt _) = concat (map plain alt)+plain (Note _) = "" -- FIXME++-- | Create an XML element.+el :: (Node t)+ => String -- ^ unqualified element name+ -> t -- ^ node contents+ -> Content -- ^ XML content+el name cs = Elem $ unode name cs++-- | Put empty lines around content+spaceBeforeAfter :: [Content] -> [Content]+spaceBeforeAfter cs =+ let emptyline = el "empty-line" ()+ in [emptyline] ++ cs ++ [emptyline]++-- | Create a plain-text XML content.+txt :: String -> Content+txt s = Text $ CData CDataText s Nothing++-- | Create an XML attribute with an unqualified name.+uattr :: String -> String -> Text.XML.Light.Attr+uattr name val = Attr (uname name) val++-- | Create an XML attribute with a qualified name from given namespace.+attr :: (String, String) -> String -> Text.XML.Light.Attr+attr (ns, name) val = Attr (qname ns name) val++-- | Unqualified name+uname :: String -> QName+uname name = QName name Nothing Nothing++-- | Qualified name+qname :: String -> String -> QName+qname ns name = QName name Nothing (Just ns)++-- | Abbreviation for 'concatMap'.+cMap :: (a -> [b]) -> [a] -> [b]+cMap = concatMap++-- | Monadic equivalent of 'concatMap'.+cMapM :: (Monad m) => (a -> m [b]) -> [a] -> m [b]+cMapM f xs = concat `liftM` mapM f xs
@@ -32,13 +32,14 @@ module Text.Pandoc.Writers.HTML ( writeHtml , writeHtmlString ) where import Text.Pandoc.Definition import Text.Pandoc.Shared+import Text.Pandoc.Options import Text.Pandoc.Templates import Text.Pandoc.Generic import Text.Pandoc.Readers.TeXMath import Text.Pandoc.Slides import Text.Pandoc.Highlighting ( highlight, styleToCss, formatHtmlInline, formatHtmlBlock )-import Text.Pandoc.XML (stripTags, escapeStringForXML, fromEntities)+import Text.Pandoc.XML (stripTags, fromEntities) import Network.HTTP ( urlEncode ) import Numeric ( showHex ) import Data.Char ( ord, toLower )@@ -52,14 +53,18 @@ #else import Text.Blaze #endif+#if MIN_VERSION_blaze_html(0,5,1)+import qualified Text.Blaze.XHtml5 as H5+#else import qualified Text.Blaze.Html5 as H5+#endif import qualified Text.Blaze.XHtml1.Transitional as H import qualified Text.Blaze.XHtml1.Transitional.Attributes as A import Text.Blaze.Renderer.String (renderHtml) import Text.TeXMath import Text.XML.Light.Output import System.FilePath (takeExtension)-import Data.Monoid (mempty, mconcat)+import Data.Monoid data WriterState = WriterState { stNotes :: [Html] -- ^ List of notes@@ -76,8 +81,11 @@ -- Helpers to render HTML with the appropriate function. strToHtml :: String -> Html-strToHtml = preEscapedString . escapeStringForXML--- strToHtml = toHtml+strToHtml ('\'':xs) = preEscapedString "\'" `mappend` strToHtml xs+strToHtml xs@(_:_) = case break (=='\'') xs of+ (_ ,[]) -> toHtml xs+ (ys,zs) -> toHtml ys `mappend` strToHtml zs+strToHtml [] = "" -- | Hard linebreak. nl :: WriterOptions -> Html@@ -211,7 +219,10 @@ -- | Like Text.XHtml's identifier, but adds the writerIdentifierPrefix prefixedId :: WriterOptions -> String -> Attribute-prefixedId opts s = A.id $ toValue $ writerIdentifierPrefix opts ++ s+prefixedId opts s =+ case s of+ "" -> mempty+ _ -> A.id $ toValue $ writerIdentifierPrefix opts ++ s -- | Replacement for Text.XHtml's unordList. unordList :: WriterOptions -> ([Html] -> Html)@@ -239,8 +250,8 @@ -- | Converts an Element to a list item for a table of contents, -- retrieving the appropriate identifier from state. elementToListItem :: WriterOptions -> Element -> State WriterState (Maybe Html)-elementToListItem _ (Blk _) = return Nothing-elementToListItem opts (Sec _ num id' headerText subsecs) = do+elementToListItem opts (Sec lev num id' headerText subsecs)+ | lev <= writerTOCDepth opts = do let sectnum = if writerNumberSections opts then (H.span ! A.class_ "toc-section-number" $ toHtml $ showSecNum num) >> preEscapedString " "@@ -250,8 +261,12 @@ let subList = if null subHeads then mempty else unordList opts subHeads- return $ Just $ (H.a ! A.href (toValue $ "#" ++ writerIdentifierPrefix opts ++ id')+ return $ Just+ $ if null id'+ then (H.a $ toHtml txt) >> subList+ else (H.a ! A.href (toValue $ "#" ++ writerIdentifierPrefix opts ++ id') $ toHtml txt) >> subList+elementToListItem _ _ = return Nothing -- | Convert an Element to Html. elementToHtml :: Int -> WriterOptions -> Element -> State WriterState Html@@ -264,7 +279,7 @@ let titleSlide = slide && level < slideLevel header' <- if title' == [Str "\0"] -- marker for hrule then return mempty- else blockToHtml opts (Header level' title')+ else blockToHtml opts (Header level' (id',[],[]) title') let isSec (Sec _ _ _ _ _) = True isSec (Blk _) = False innerContents <- mapM (elementToHtml slideLevel opts)@@ -272,8 +287,9 @@ -- title slides have no content of their own then filter isSec elements else elements- let header'' = if (writerStrictMarkdown opts || writerSectionDivs opts ||- writerSlideVariant opts == S5Slides || slide)+ let header'' = if (writerSectionDivs opts ||+ writerSlideVariant opts == S5Slides ||+ slide) then header' else header' ! prefixedId opts id' let inNl x = mconcat $ nl opts : intersperse (nl opts) x ++ [nl opts]@@ -376,15 +392,20 @@ blockToHtml :: WriterOptions -> Block -> State WriterState Html blockToHtml _ Null = return mempty blockToHtml opts (Plain lst) = inlineListToHtml opts lst-blockToHtml opts (Para [Image txt (s,tit)]) = do+-- title beginning with fig: indicates that the image is a figure+blockToHtml opts (Para [Image txt (s,'f':'i':'g':':':tit)]) = do img <- inlineToHtml opts (Image txt (s,tit))- capt <- inlineListToHtml opts txt+ let tocapt = if writerHtml5 opts+ then H5.figcaption+ else H.p ! A.class_ "caption"+ capt <- if null txt+ then return mempty+ else tocapt `fmap` inlineListToHtml opts txt return $ if writerHtml5 opts then H5.figure $ mconcat- [nl opts, img, H5.figcaption capt, nl opts]+ [nl opts, img, capt, nl opts] else H.div ! A.class_ "figure" $ mconcat- [nl opts, img, H.p ! A.class_ "caption" $ capt,- nl opts]+ [nl opts, img, capt, nl opts] blockToHtml opts (Para lst) = do contents <- inlineListToHtml opts lst return $ H.p contents@@ -392,7 +413,7 @@ blockToHtml _ (RawBlock _ _) = return mempty blockToHtml opts (HorizontalRule) = return $ if writerHtml5 opts then H5.hr else H.hr blockToHtml opts (CodeBlock (id',classes,keyvals) rawCode) = do- let tolhs = writerLiterateHaskell opts &&+ let tolhs = isEnabled Ext_literate_haskell opts && any (\c -> map toLower c == "haskell") classes && any (\c -> map toLower c == "literate") classes classes' = if tolhs@@ -427,15 +448,16 @@ else do contents <- blockListToHtml opts blocks return $ H.blockquote $ nl opts >> contents >> nl opts-blockToHtml opts (Header level lst) = do+blockToHtml opts (Header level (ident,_,_) lst) = do contents <- inlineListToHtml opts lst secnum <- liftM stSecNum get let contents' = if writerNumberSections opts then (H.span ! A.class_ "header-section-number" $ toHtml $ showSecNum secnum) >> strToHtml " " >> contents else contents- let contents'' = if writerTableOfContents opts- then H.a ! A.href (toValue $ "#" ++ writerIdentifierPrefix opts ++ "TOC") $ contents'+ let contents'' = if writerTableOfContents opts && not (null ident)+ then H.a ! A.href (toValue $+ '#' : writerIdentifierPrefix opts ++ ident) $ contents' else contents' return $ (case level of 1 -> H.h1 contents''@@ -477,10 +499,13 @@ return $ foldl (!) (ordList opts contents) attribs blockToHtml opts (DefinitionList lst) = do contents <- mapM (\(term, defs) ->- do term' <- liftM (H.dt) $ inlineListToHtml opts term+ do term' <- if null term+ then return mempty+ else liftM (H.dt) $ inlineListToHtml opts term defs' <- mapM ((liftM (\x -> H.dd $ (x >> nl opts))) . blockListToHtml opts) defs- return $ mconcat $ nl opts : term' : nl opts : defs') lst+ return $ mconcat $ nl opts : term' : nl opts :+ intersperse (nl opts) defs') lst let lst' = H.dl $ mconcat contents >> nl opts let lst'' = if writerIncremental opts then lst' ! A.class_ "incremental"@@ -576,7 +601,9 @@ Nothing -> return $ foldl (!) H.code (attrsToHtml opts attr) $ strToHtml str- Just h -> return $ foldl (!) h $+ Just h -> do+ modify $ \st -> st{ stHighlighting = True }+ return $ foldl (!) h $ attrsToHtml opts (id',[],keyvals) where (id',_,keyvals) = attr (Strikeout lst) -> inlineListToHtml opts lst >>=@@ -591,7 +618,7 @@ strToHtml "’") DoubleQuote -> (strToHtml "“", strToHtml "”")- in if writerHtml5 opts+ in if writerHtmlQTags opts then do modify $ \st -> st{ stQuotes = True } H.q `fmap` inlineListToHtml opts lst@@ -618,7 +645,7 @@ ! A.src (toValue $ url ++ urlEncode str) ! A.alt (toValue str) ! A.title (toValue str)- let brtag = if writerHtml5 opts then H5.br else H.br + let brtag = if writerHtml5 opts then H5.br else H.br return $ case t of InlineMath -> m DisplayMath -> brtag >> m >> brtag@@ -638,7 +665,7 @@ Left _ -> inlineListToHtml opts (readTeXMath str) >>= return . (H.span ! A.class_ "math")- MathJax _ -> return $ toHtml $+ MathJax _ -> return $ H.span ! A.class_ "math" $ toHtml $ case t of InlineMath -> "\\(" ++ str ++ "\\)" DisplayMath -> "\\[" ++ str ++ "\\]"@@ -655,7 +682,9 @@ _ -> return mempty (RawInline "html" str) -> return $ preEscapedString str (RawInline _ _) -> return mempty- (Link [Code _ str] (s,_)) | "mailto:" `isPrefixOf` s ->+ (Link [Str str] (s,_)) | "mailto:" `isPrefixOf` s &&+ s == escapeURI ("mailto" ++ str) ->+ -- autolink return $ obfuscateLink opts str s (Link txt (s,_)) | "mailto:" `isPrefixOf` s -> do linkText <- inlineListToHtml opts txt@@ -693,13 +722,21 @@ htmlContents <- blockListToNote opts ref contents -- push contents onto front of notes put $ st {stNotes = (htmlContents:notes)}- return $ H.sup $- H.a ! A.href (toValue $ "#" ++ writerIdentifierPrefix opts ++ "fn" ++ ref)- ! A.class_ "footnoteRef"- ! prefixedId opts ("fnref" ++ ref)- $ toHtml ref- (Cite _ il) -> do contents <- inlineListToHtml opts il- return $ H.span ! A.class_ "citation" $ contents+ let link = H.a ! A.href (toValue $ "#" +++ writerIdentifierPrefix opts ++ "fn" ++ ref)+ ! A.class_ "footnoteRef"+ ! prefixedId opts ("fnref" ++ ref)+ $ toHtml ref+ let link' = case writerEpubVersion opts of+ Just EPUB3 -> link ! customAttribute "epub:type" "noteref"+ _ -> link+ return $ H.sup $ link'+ (Cite cits il)-> do contents <- inlineListToHtml opts il+ let citationIds = unwords $ map citationId cits+ let result = H.span ! A.class_ "citation" $ contents+ return $ if writerHtml5 opts+ then result ! customAttribute "data-cites" (toValue citationIds)+ else result blockListToNote :: WriterOptions -> String -> [Block] -> State WriterState Html blockListToNote opts ref blocks =@@ -718,4 +755,8 @@ _ -> otherBlocks ++ [lastBlock, Plain backlink] in do contents <- blockListToHtml opts blocks'- return $ nl opts >> (H.li ! (prefixedId opts ("fn" ++ ref)) $ contents)+ let noteItem = H.li ! (prefixedId opts ("fn" ++ ref)) $ contents+ let noteItem' = case writerEpubVersion opts of+ Just EPUB3 -> noteItem ! customAttribute "epub:type" "footnote"+ _ -> noteItem+ return $ nl opts >> noteItem'
@@ -32,13 +32,16 @@ import Text.Pandoc.Definition import Text.Pandoc.Generic import Text.Pandoc.Shared+import Text.Pandoc.Options import Text.Pandoc.Templates import Text.Printf ( printf )+import qualified Data.Map as M import Network.URI ( isAbsoluteURI, unEscapeString ) import Data.List ( (\\), isSuffixOf, isInfixOf, isPrefixOf, intercalate, intersperse ) import Data.Char ( toLower, isPunctuation ) import Control.Monad.State+import Control.Applicative ((<|>)) import Text.Pandoc.Pretty import System.FilePath (dropExtension) import Text.Pandoc.Slides@@ -48,12 +51,10 @@ data WriterState = WriterState { stInNote :: Bool -- true if we're in a note , stInTable :: Bool -- true if we're in a table- , stTableNotes :: [(Char, Doc)] -- List of markers, notes- -- in current table+ , stTableNotes :: [Doc] -- List of notes in current table , stOLLevel :: Int -- level of ordered list nesting , stOptions :: WriterOptions -- writer options, so they don't have to be parameter , stVerbInNote :: Bool -- true if document has verbatim text in note- , stEnumerate :: Bool -- true if document needs fancy enumerated lists , stTable :: Bool -- true if document has a table , stStrikeout :: Bool -- true if document has strikeout , stUrl :: Bool -- true if document has visible URL link@@ -73,7 +74,7 @@ evalState (pandocToLaTeX options document) $ WriterState { stInNote = False, stInTable = False, stTableNotes = [], stOLLevel = 1, stOptions = options,- stVerbInNote = False, stEnumerate = False,+ stVerbInNote = False, stTable = False, stStrikeout = False, stUrl = False, stGraphics = False, stLHS = False, stBook = writerChapters options,@@ -110,8 +111,8 @@ let (blocks', lastHeader) = if writerCiteMethod options == Citeproc then (blocks, []) else case last blocks of- Header 1 il -> (init blocks, il)- _ -> (blocks, [])+ Header 1 _ il -> (init blocks, il)+ _ -> (blocks, []) blocks'' <- if writerBeamer options then toSlides blocks' else return blocks'@@ -132,6 +133,10 @@ _ -> [] context = writerVariables options ++ [ ("toc", if writerTableOfContents options then "yes" else "")+ , ("toc-depth", show (writerTOCDepth options -+ if writerChapters options+ then 1+ else 0)) , ("body", main) , ("title", titletext) , ("title-meta", stringify title)@@ -144,7 +149,6 @@ else "article") ] ++ [ ("author", a) | a <- authorsText ] ++ [ ("verbatim-in-note", "yes") | stVerbInNote st ] ++- [ ("fancy-enums", "yes") | stEnumerate st ] ++ [ ("tables", "yes") | stTable st ] ++ [ ("strikeout", "yes") | stStrikeout st ] ++ [ ("url", "yes") | stUrl st ] ++@@ -189,7 +193,7 @@ '$' -> "\\$" ++ rest '%' -> "\\%" ++ rest '&' -> "\\&" ++ rest- '_' -> "\\_" ++ rest+ '_' | not isUrl -> "\\_" ++ rest '#' -> "\\#" ++ rest '-' -> case xs of -- prevent adjacent hyphens from forming ligatures ('-':_) -> "-{}" ++ rest@@ -212,6 +216,13 @@ '\x2013' | ligatures -> "--" ++ rest _ -> x : rest +-- This is needed because | in math mode interacts badly with+-- highlighting-kate, which redefines | as a short verb command.+escapeMath :: String -> String+escapeMath ('|':xs) = "\\vert " ++ escapeMath xs+escapeMath (x:xs) = x : escapeMath xs+escapeMath [] = ""+ -- | Puts contents into LaTeX command. inCmd :: String -> Doc -> Doc inCmd cmd contents = char '\\' <> text cmd <> braces contents@@ -225,7 +236,7 @@ elementToBeamer :: Int -> Element -> State WriterState [Block] elementToBeamer _slideLevel (Blk b) = return [b]-elementToBeamer slideLevel (Sec lvl _num _ident tit elts)+elementToBeamer slideLevel (Sec lvl _num ident tit elts) | lvl > slideLevel = do bs <- concat `fmap` mapM (elementToBeamer slideLevel) elts return $ Para ( RawInline "latex" "\\begin{block}{"@@ -233,14 +244,18 @@ : bs ++ [RawBlock "latex" "\\end{block}"] | lvl < slideLevel = do bs <- concat `fmap` mapM (elementToBeamer slideLevel) elts- return $ (Header lvl tit) : bs+ return $ (Header lvl (ident,[],[]) tit) : bs | otherwise = do -- lvl == slideLevel -- note: [fragile] is required or verbatim breaks let hasCodeBlock (CodeBlock _ _) = [True] hasCodeBlock _ = [] let hasCode (Code _ _) = [True] hasCode _ = []- let fragile = if not $ null $ queryWith hasCodeBlock elts ++ queryWith hasCode elts+ opts <- gets stOptions+ let fragile = if not $ null $ queryWith hasCodeBlock elts +++ if writerListings opts+ then queryWith hasCode elts+ else [] then "[fragile]" else "" let slideStart = Para $ RawInline "latex" ("\\begin{frame}" ++ fragile) :@@ -259,19 +274,27 @@ isListBlock (DefinitionList _) = True isListBlock _ = False +isLineBreakOrSpace :: Inline -> Bool+isLineBreakOrSpace LineBreak = True+isLineBreakOrSpace Space = True+isLineBreakOrSpace _ = False+ -- | Convert Pandoc block element to LaTeX. blockToLaTeX :: Block -- ^ Block to convert -> State WriterState Doc blockToLaTeX Null = return empty-blockToLaTeX (Plain lst) = inlineListToLaTeX lst-blockToLaTeX (Para [Image txt (src,tit)]) = do- capt <- inlineListToLaTeX txt+blockToLaTeX (Plain lst) =+ inlineListToLaTeX $ dropWhile isLineBreakOrSpace lst+-- title beginning with fig: indicates that the image is a figure+blockToLaTeX (Para [Image txt (src,'f':'i':'g':':':tit)]) = do+ capt <- if null txt+ then return empty+ else (\c -> "\\caption" <> braces c) `fmap` inlineListToLaTeX txt img <- inlineToLaTeX (Image txt (src,tit)) return $ "\\begin{figure}[htbp]" $$ "\\centering" $$ img $$- ("\\caption{" <> capt <> char '}') $$ "\\end{figure}"-blockToLaTeX (Para lst) = do- result <- inlineListToLaTeX lst- return result+ capt $$ "\\end{figure}"+blockToLaTeX (Para lst) =+ inlineListToLaTeX $ dropWhile isLineBreakOrSpace lst blockToLaTeX (BlockQuote lst) = do beamer <- writerBeamer `fmap` gets stOptions case lst of@@ -287,7 +310,7 @@ blockToLaTeX (CodeBlock (_,classes,keyvalAttr) str) = do opts <- gets stOptions case () of- _ | writerLiterateHaskell opts && "haskell" `elem` classes &&+ _ | isEnabled Ext_literate_haskell opts && "haskell" `elem` classes && "literate" `elem` classes -> lhsCodeBlock | writerListings opts -> listingsCodeBlock | writerHighlight opts && not (null classes) -> highlightedCodeBlock@@ -306,25 +329,9 @@ listingsCodeBlock = do st <- get let params = if writerListings (stOptions st)- then take 1- [ "language=" ++ lang | lang <- classes- , lang `elem` ["ABAP","IDL","Plasm","ACSL","inform"- ,"POV","Ada","Java","Prolog","Algol"- ,"JVMIS","Promela","Ant","ksh","Python"- ,"Assembler","Lisp","R","Awk","Logo"- ,"Reduce","bash","make","Rexx","Basic"- ,"Mathematica","RSL","C","Matlab","Ruby"- ,"C++","Mercury","S","Caml","MetaPost"- ,"SAS","Clean","Miranda","Scilab","Cobol"- ,"Mizar","sh","Comal","ML","SHELXL","csh"- ,"Modula-2","Simula","Delphi","MuPAD"- ,"SQL","Eiffel","NASTRAN","tcl","Elan"- ,"Oberon-2","TeX","erlang","OCL"- ,"VBScript","Euphoria","Octave","Verilog"- ,"Fortran","Oz","VHDL","GCL","Pascal"- ,"VRML","Gnuplot","Perl","XML","Haskell"- ,"PHP","XSLT","HTML","PL/I"]- ] +++ then (case getListingsLanguage classes of+ Just l -> [ "language=" ++ l ]+ Nothing -> []) ++ [ key ++ "=" ++ attr | (key,attr) <- keyvalAttr ] else [] printParams@@ -343,7 +350,10 @@ incremental <- gets stIncremental let inc = if incremental then "[<+->]" else "" items <- mapM listItemToLaTeX lst- return $ text ("\\begin{itemize}" ++ inc) $$ vcat items $$+ let spacing = if isTightList lst+ then text "\\itemsep1pt\\parskip0pt\\parsep0pt"+ else empty+ return $ text ("\\begin{itemize}" ++ inc) $$ spacing $$ vcat items $$ "\\end{itemize}" blockToLaTeX (OrderedList (start, numstyle, numdelim) lst) = do st <- get@@ -352,54 +362,74 @@ put $ st {stOLLevel = oldlevel + 1} items <- mapM listItemToLaTeX lst modify (\s -> s {stOLLevel = oldlevel})- exemplar <- if numstyle /= DefaultStyle || numdelim /= DefaultDelim- then do- modify $ \s -> s{ stEnumerate = True }- return $ char '[' <>- text (head (orderedListMarkers (1, numstyle,- numdelim))) <> char ']'- else return empty- let resetcounter = if start /= 1 && oldlevel <= 4- then text $ "\\setcounter{enum" ++- map toLower (toRomanNumeral oldlevel) ++- "}{" ++ show (start - 1) ++ "}"- else empty- return $ text ("\\begin{enumerate}" ++ inc) <> exemplar $$ resetcounter $$- vcat items $$ "\\end{enumerate}"+ let tostyle x = case numstyle of+ Decimal -> "\\arabic" <> braces x+ UpperRoman -> "\\Roman" <> braces x+ LowerRoman -> "\\roman" <> braces x+ UpperAlpha -> "\\Alph" <> braces x+ LowerAlpha -> "\\alph" <> braces x+ Example -> "\\arabic" <> braces x+ DefaultStyle -> "\\arabic" <> braces x+ let todelim x = case numdelim of+ OneParen -> x <> ")"+ TwoParens -> parens x+ Period -> x <> "."+ _ -> x <> "."+ let enum = text $ "enum" ++ map toLower (toRomanNumeral oldlevel)+ let stylecommand = if numstyle == DefaultStyle && numdelim == DefaultDelim+ then empty+ else "\\def" <> "\\label" <> enum <>+ braces (todelim $ tostyle enum)+ let resetcounter = if start == 1 || oldlevel > 4+ then empty+ else "\\setcounter" <> braces enum <>+ braces (text $ show $ start - 1)+ let spacing = if isTightList lst+ then text "\\itemsep1pt\\parskip0pt\\parsep0pt"+ else empty+ return $ text ("\\begin{enumerate}" ++ inc)+ $$ stylecommand+ $$ resetcounter+ $$ spacing+ $$ vcat items+ $$ "\\end{enumerate}" blockToLaTeX (DefinitionList lst) = do incremental <- gets stIncremental let inc = if incremental then "[<+->]" else "" items <- mapM defListItemToLaTeX lst- return $ text ("\\begin{description}" ++ inc) $$ vcat items $$+ let spacing = if and $ map isTightList (map snd lst)+ then text "\\itemsep1pt\\parskip0pt\\parsep0pt"+ else empty+ return $ text ("\\begin{description}" ++ inc) $$ spacing $$ vcat items $$ "\\end{description}" blockToLaTeX HorizontalRule = return $ "\\begin{center}\\rule{3in}{0.4pt}\\end{center}"-blockToLaTeX (Header level lst) = sectionHeader "" level lst+blockToLaTeX (Header level (id',_,_) lst) = sectionHeader id' level lst blockToLaTeX (Table caption aligns widths heads rows) = do modify $ \s -> s{ stInTable = True, stTableNotes = [] } headers <- if all null heads then return empty- else liftM ($$ "\\ML")- $ (tableRowToLaTeX True aligns widths) heads+ else ($$ "\\hline\\noalign{\\medskip}") `fmap`+ (tableRowToLaTeX True aligns widths) heads captionText <- inlineListToLaTeX caption let capt = if isEmpty captionText then empty- else text "caption = {" <> captionText <> "}," <> space+ else text "\\noalign{\\medskip}"+ $$ text "\\caption" <> braces captionText rows' <- mapM (tableRowToLaTeX False aligns widths) rows- let rows'' = intersperse ("\\\\\\noalign{\\medskip}") rows' tableNotes <- liftM (reverse . stTableNotes) get- let toNote (marker, x) = "\\tnote" <> brackets (char marker) <>- braces (nest 2 x)+ let toNote x = "\\footnotetext" <> braces (nest 2 x) let notes = vcat $ map toNote tableNotes let colDescriptors = text $ concat $ map toColDescriptor aligns- let tableBody =- ("\\ctable" <> brackets (capt <> text "pos = H, center, botcap"))- <> braces colDescriptors- $$ braces ("% notes" <> cr <> notes <> cr)- $$ braces (text "% rows" $$ "\\FL" $$- vcat (headers : rows'') $$ "\\LL" <> cr) modify $ \s -> s{ stTable = True, stInTable = False, stTableNotes = [] }- return $ tableBody+ return $ "\\begin{longtable}[c]" <> braces colDescriptors+ $$ "\\hline\\noalign{\\medskip}"+ $$ headers+ $$ vcat rows'+ $$ "\\hline"+ $$ capt+ $$ notes+ $$ "\\end{longtable}" toColDescriptor :: Alignment -> String toColDescriptor align =@@ -426,11 +456,11 @@ AlignCenter -> "\\centering" AlignDefault -> "\\raggedright" let toCell 0 _ c = c- toCell w a c = "\\parbox" <> valign <>+ toCell w a c = "\\begin{minipage}" <> valign <> braces (text (printf "%.2f\\columnwidth" w)) <>- braces (halign a <> cr <> c <> cr)+ (halign a <> cr <> c <> cr) <> "\\end{minipage}" let cells = zipWith3 toCell widths aligns renderedCells- return $ hcat $ intersperse (" & ") cells+ return $ hsep (intersperse "&" cells) $$ "\\\\\\noalign{\\medskip}" listItemToLaTeX :: [Block] -> State WriterState Doc listItemToLaTeX lst = blockListToLaTeX lst >>= return . (text "\\item" $$) .@@ -487,7 +517,19 @@ -- | Convert list of inline elements to LaTeX. inlineListToLaTeX :: [Inline] -- ^ Inlines to convert -> State WriterState Doc-inlineListToLaTeX lst = mapM inlineToLaTeX lst >>= return . hcat+inlineListToLaTeX lst =+ mapM inlineToLaTeX (fixLineInitialSpaces lst)+ >>= return . hcat+ -- nonbreaking spaces (~) in LaTeX don't work after line breaks,+ -- so we turn nbsps after hard breaks to \hspace commands.+ -- this is mostly used in verse.+ where fixLineInitialSpaces [] = []+ fixLineInitialSpaces (LineBreak : Str s@('\160':_) : xs) =+ LineBreak : fixNbsps s ++ fixLineInitialSpaces xs+ fixLineInitialSpaces (x:xs) = x : fixLineInitialSpaces xs+ fixNbsps s = let (ys,zs) = span (=='\160') s+ in replicate (length ys) hspace ++ [Str zs]+ hspace = RawInline "latex" "\\hspace*{0.333em}" isQuoted :: Inline -> Bool isQuoted (Quoted _ _) = True@@ -560,8 +602,10 @@ then char '`' <> inner <> char '\'' else char '\x2018' <> inner <> char '\x2019' inlineToLaTeX (Str str) = liftM text $ stringToLaTeX False str-inlineToLaTeX (Math InlineMath str) = return $ char '$' <> text str <> char '$'-inlineToLaTeX (Math DisplayMath str) = return $ "\\[" <> text str <> "\\]"+inlineToLaTeX (Math InlineMath str) =+ return $ char '$' <> text (escapeMath str) <> char '$'+inlineToLaTeX (Math DisplayMath str) =+ return $ "\\[" <> text (escapeMath str) <> "\\]" inlineToLaTeX (RawInline "latex" str) = return $ text str inlineToLaTeX (RawInline "tex" str) = return $ text str inlineToLaTeX (RawInline _ _) = return empty@@ -569,13 +613,14 @@ inlineToLaTeX Space = return space inlineToLaTeX (Link txt ('#':ident, _)) = do contents <- inlineListToLaTeX txt- ident' <- stringToLaTeX False ident+ ident' <- stringToLaTeX True ident return $ text "\\hyperref" <> brackets (text ident') <> braces contents inlineToLaTeX (Link txt (src, _)) = case txt of- [Code _ x] | x == src -> -- autolink+ [Str x] | x == src -> -- autolink do modify $ \s -> s{ stUrl = True }- return $ text $ "\\url{" ++ x ++ "}"+ src' <- stringToLaTeX True x+ return $ text $ "\\url{" ++ src' ++ "}" _ -> do contents <- inlineListToLaTeX txt src' <- stringToLaTeX True src return $ text ("\\href{" ++ src' ++ "}{") <>@@ -597,9 +642,8 @@ if inTable then do curnotes <- liftM stTableNotes get- let marker = cycle ['a'..'z'] !! length curnotes- modify $ \s -> s{ stTableNotes = (marker, contents') : curnotes }- return $ "\\tmark" <> brackets (char marker) <> space+ modify $ \s -> s{ stTableNotes = contents' : curnotes }+ return $ "\\footnotemark" <> space else return $ "\\footnote" <> braces (nest 2 contents' <> optnl) -- note: a \n before } needed when note ends with a Verbatim environment @@ -697,3 +741,61 @@ = citeArguments p s k citationsToBiblatex _ = return empty++-- correlate pandoc language names with listings names+langsMap :: M.Map String String+langsMap = M.fromList+ [("ada","Ada")+ ,("java","Java")+ ,("prolog","Prolog")+ ,("python","Python")+ ,("gnuassembler","Assembler")+ ,("commonlisp","Lisp")+ ,("r","R")+ ,("awk","Awk")+ ,("bash","bash")+ ,("makefile","make")+ ,("c","C")+ ,("matlab","Matlab")+ ,("ruby","Ruby")+ ,("cpp","C++")+ ,("ocaml","Caml")+ ,("modula2","Modula-2")+ ,("sql","SQL")+ ,("eiffel","Eiffel")+ ,("tcl","tcl")+ ,("erlang","erlang")+ ,("verilog","Verilog")+ ,("fortran","Fortran")+ ,("vhdl","VHDL")+ ,("pascal","Pascal")+ ,("perl","Perl")+ ,("xml","XML")+ ,("haskell","Haskell")+ ,("php","PHP")+ ,("xslt","XSLT")+ ,("html","HTML")+ ]++listingsLangs :: [String]+listingsLangs = ["Ada","Java","Prolog","Algol","JVMIS","Promela",+ "Ant","ksh","Python","Assembler","Lisp","R","Awk",+ "Logo","Reduce","bash","make","Rexx","Basic",+ "Mathematica","RSL","C","Matlab","Ruby","C++",+ "Mercury","S","Caml","MetaPost","SAS","Clean",+ "Miranda","Scilab","Cobol","Mizar","sh","Comal",+ "ML","SHELXL","csh","Modula-2","Simula","Delphi",+ "MuPAD","SQL","Eiffel","NASTRAN","tcl","Elan",+ "Oberon-2","TeX","erlang","OCL","VBScript","Euphoria",+ "Octave","Verilog","Fortran","Oz","VHDL","GCL",+ "Pascal","VRML","Gnuplot","Perl","XML","Haskell",+ "PHP","XSLT","HTML","PL/I"]++-- Determine listings language from list of class attributes.+getListingsLanguage :: [String] -> Maybe String+getListingsLanguage [] = Nothing+getListingsLanguage (x:xs) = (if x `elem` listingsLangs+ then Just x+ else Nothing) <|>+ M.lookup (map toLower x) langsMap <|>+ getListingsLanguage xs
@@ -17,9 +17,9 @@ -} {- |- Module : Text.Pandoc.Writers.Man + Module : Text.Pandoc.Writers.Man Copyright : Copyright (C) 2007-2010 John MacFarlane- License : GNU GPL, version 2 or above + License : GNU GPL, version 2 or above Maintainer : John MacFarlane <jgm@berkeley.edu> Stability : alpha@@ -32,6 +32,7 @@ import Text.Pandoc.Definition import Text.Pandoc.Templates import Text.Pandoc.Shared+import Text.Pandoc.Options import Text.Pandoc.Readers.TeXMath import Text.Printf ( printf ) import Data.List ( isPrefixOf, intersperse, intercalate )@@ -44,26 +45,25 @@ -- | Convert Pandoc to Man. writeMan :: WriterOptions -> Pandoc -> String-writeMan opts document = evalState (pandocToMan opts document) (WriterState [] False) +writeMan opts document = evalState (pandocToMan opts document) (WriterState [] False) -- | Return groff man representation of document. pandocToMan :: WriterOptions -> Pandoc -> State WriterState String pandocToMan opts (Pandoc (Meta title authors date) blocks) = do titleText <- inlineListToMan opts title authors' <- mapM (inlineListToMan opts) authors- date' <- inlineListToMan opts date + date' <- inlineListToMan opts date let colwidth = if writerWrapText opts then Just $ writerColumns opts else Nothing let render' = render colwidth let (cmdName, rest) = break (== ' ') $ render' titleText let (title', section) = case reverse cmdName of- (')':d:'(':xs) | d `elem` ['0'..'9'] -> + (')':d:'(':xs) | d `elem` ['0'..'9'] -> (text (reverse xs), char d) xs -> (text (reverse xs), doubleQuotes empty) let description = hsep $- map (doubleQuotes . text . removeLeadingTrailingSpace) $- splitBy (== '|') rest+ map (doubleQuotes . text . trim) $ splitBy (== '|') rest body <- blockListToMan opts blocks notes <- liftM stNotes get notes' <- notesToMan opts (reverse notes)@@ -86,7 +86,7 @@ notesToMan opts notes = if null notes then return empty- else mapM (\(num, note) -> noteToMan opts num note) (zip [1..] notes) >>= + else mapM (\(num, note) -> noteToMan opts num note) (zip [1..] notes) >>= return . (text ".SH NOTES" $$) . vcat -- | Return man representation of a note.@@ -94,7 +94,7 @@ noteToMan opts num note = do contents <- blockListToMan opts note let marker = cr <> text ".SS " <> brackets (text (show num))- return $ marker $$ contents + return $ marker $$ contents -- | Association list of characters to escape. manEscapes :: [(Char, String)]@@ -104,7 +104,7 @@ , ('\x2014', "\\[em]") , ('\x2013', "\\[en]") , ('\x2026', "\\&...")- ] ++ backslashEscapes "@\\"+ ] ++ backslashEscapes "-@\\" -- | Escape special characters for Man. escapeString :: String -> String@@ -113,7 +113,7 @@ -- | Escape a literal (code) section for Man. escapeCode :: String -> String escapeCode = concat . intersperse "\n" . map escapeLine . lines where- escapeLine codeline = + escapeLine codeline = case escapeStringUsing (manEscapes ++ backslashEscapes "\t ") codeline of a@('.':_) -> "\\&" ++ a b -> b@@ -150,23 +150,23 @@ -- | Convert Pandoc block element to man. blockToMan :: WriterOptions -- ^ Options -> Block -- ^ Block element- -> State WriterState Doc + -> State WriterState Doc blockToMan _ Null = return empty-blockToMan opts (Plain inlines) = +blockToMan opts (Plain inlines) = liftM vcat $ mapM (inlineListToMan opts) $ splitSentences inlines blockToMan opts (Para inlines) = do contents <- liftM vcat $ mapM (inlineListToMan opts) $ splitSentences inlines- return $ text ".PP" $$ contents + return $ text ".PP" $$ contents blockToMan _ (RawBlock "man" str) = return $ text str blockToMan _ (RawBlock _ _) = return empty blockToMan _ HorizontalRule = return $ text ".PP" $$ text " * * * * *"-blockToMan opts (Header level inlines) = do+blockToMan opts (Header level _ inlines) = do contents <- inlineListToMan opts inlines let heading = case level of 1 -> ".SH " _ -> ".SS "- return $ text heading <> contents + return $ text heading <> contents blockToMan _ (CodeBlock _ str) = return $ text ".IP" $$ text ".nf" $$@@ -174,10 +174,10 @@ text (escapeCode str) $$ text "\\f[]" $$ text ".fi"-blockToMan opts (BlockQuote blocks) = do +blockToMan opts (BlockQuote blocks) = do contents <- blockListToMan opts blocks return $ text ".RS" $$ contents $$ text ".RE"-blockToMan opts (Table caption alignments widths headers rows) = +blockToMan opts (Table caption alignments widths headers rows) = let aligncode AlignLeft = "l" aligncode AlignRight = "r" aligncode AlignCenter = "c"@@ -190,53 +190,53 @@ else map (printf "w(%0.2fn)" . (70 *)) widths -- 78n default width - 8n indent = 70n let coldescriptions = text $ intercalate " "- (zipWith (\align width -> aligncode align ++ width) + (zipWith (\align width -> aligncode align ++ width) alignments iwidths) ++ "." colheadings <- mapM (blockListToMan opts) headers- let makeRow cols = text "T{" $$ - (vcat $ intersperse (text "T}@T{") cols) $$ + let makeRow cols = text "T{" $$+ (vcat $ intersperse (text "T}@T{") cols) $$ text "T}" let colheadings' = if all null headers then empty else makeRow colheadings $$ char '_'- body <- mapM (\row -> do + body <- mapM (\row -> do cols <- mapM (blockListToMan opts) row return $ makeRow cols) rows- return $ text ".PP" $$ caption' $$ - text ".TS" $$ text "tab(@);" $$ coldescriptions $$ + return $ text ".PP" $$ caption' $$+ text ".TS" $$ text "tab(@);" $$ coldescriptions $$ colheadings' $$ vcat body $$ text ".TE" blockToMan opts (BulletList items) = do contents <- mapM (bulletListItemToMan opts) items- return (vcat contents) + return (vcat contents) blockToMan opts (OrderedList attribs items) = do- let markers = take (length items) $ orderedListMarkers attribs + let markers = take (length items) $ orderedListMarkers attribs let indent = 1 + (maximum $ map length markers) contents <- mapM (\(num, item) -> orderedListItemToMan opts num indent item) $- zip markers items + zip markers items return (vcat contents)-blockToMan opts (DefinitionList items) = do +blockToMan opts (DefinitionList items) = do contents <- mapM (definitionListItemToMan opts) items return (vcat contents) -- | Convert bullet list item (list of blocks) to man. bulletListItemToMan :: WriterOptions -> [Block] -> State WriterState Doc bulletListItemToMan _ [] = return empty-bulletListItemToMan opts ((Para first):rest) = +bulletListItemToMan opts ((Para first):rest) = bulletListItemToMan opts ((Plain first):rest) bulletListItemToMan opts ((Plain first):rest) = do- first' <- blockToMan opts (Plain first) + first' <- blockToMan opts (Plain first) rest' <- blockListToMan opts rest let first'' = text ".IP \\[bu] 2" $$ first' let rest'' = if null rest then empty else text ".RS 2" $$ rest' $$ text ".RE"- return (first'' $$ rest'') + return (first'' $$ rest'') bulletListItemToMan opts (first:rest) = do first' <- blockToMan opts first rest' <- blockListToMan opts rest return $ text "\\[bu] .RS 2" $$ first' $$ rest' $$ text ".RE"- + -- | Convert ordered list item (a list of blocks) to man. orderedListItemToMan :: WriterOptions -- ^ options -> String -- ^ order marker for list item@@ -244,7 +244,7 @@ -> [Block] -- ^ list item (list of blocks) -> State WriterState Doc orderedListItemToMan _ _ _ [] = return empty-orderedListItemToMan opts num indent ((Para first):rest) = +orderedListItemToMan opts num indent ((Para first):rest) = orderedListItemToMan opts num indent ((Plain first):rest) orderedListItemToMan opts num indent (first:rest) = do first' <- blockToMan opts first@@ -254,17 +254,17 @@ let rest'' = if null rest then empty else text ".RS 4" $$ rest' $$ text ".RE"- return $ first'' $$ rest'' + return $ first'' $$ rest'' -- | Convert definition list item (label, list of blocks) to man. definitionListItemToMan :: WriterOptions- -> ([Inline],[[Block]]) + -> ([Inline],[[Block]]) -> State WriterState Doc definitionListItemToMan opts (label, defs) = do labelText <- inlineListToMan opts label- contents <- if null defs + contents <- if null defs then return empty- else liftM vcat $ forM defs $ \blocks -> do + else liftM vcat $ forM defs $ \blocks -> do let (first, rest) = case blocks of ((Para x):y) -> (Plain x,y) (x:y) -> (x,y)@@ -278,7 +278,7 @@ -- | Convert list of Pandoc block elements to man. blockListToMan :: WriterOptions -- ^ Options -> [Block] -- ^ List of block elements- -> State WriterState Doc + -> State WriterState Doc blockListToMan opts blocks = mapM (blockToMan opts) blocks >>= (return . vcat) @@ -292,7 +292,7 @@ -- | Convert Pandoc inline element to man. inlineToMan :: WriterOptions -> Inline -> State WriterState Doc-inlineToMan opts (Emph lst) = do +inlineToMan opts (Emph lst) = do contents <- inlineListToMan opts lst return $ text "\\f[I]" <> contents <> text "\\f[]" inlineToMan opts (Strong lst) = do@@ -332,17 +332,18 @@ linktext <- inlineListToMan opts txt let srcSuffix = if isPrefixOf "mailto:" src then drop 7 src else src return $ case txt of- [Code _ s]- | s == srcSuffix -> char '<' <> text srcSuffix <> char '>' + [Str s]+ | escapeURI s == srcSuffix ->+ char '<' <> text srcSuffix <> char '>' _ -> linktext <> text " (" <> text src <> char ')' inlineToMan opts (Image alternate (source, tit)) = do- let txt = if (null alternate) || (alternate == [Str ""]) || + let txt = if (null alternate) || (alternate == [Str ""]) || (alternate == [Str source]) -- to prevent autolinks then [Str "image"] else alternate- linkPart <- inlineToMan opts (Link txt (source, tit)) + linkPart <- inlineToMan opts (Link txt (source, tit)) return $ char '[' <> text "IMAGE: " <> linkPart <> char ']'-inlineToMan _ (Note contents) = do +inlineToMan _ (Note contents) = do -- add to notes in state modify $ \st -> st{ stNotes = contents : stNotes st } notes <- liftM stNotes get
@@ -1,4 +1,4 @@-{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE OverloadedStrings, TupleSections #-} {- Copyright (C) 2006-2010 John MacFarlane <jgm@berkeley.edu> @@ -18,9 +18,9 @@ -} {- |- Module : Text.Pandoc.Writers.Markdown + Module : Text.Pandoc.Writers.Markdown Copyright : Copyright (C) 2006-2010 John MacFarlane- License : GNU GPL, version 2 or above + License : GNU GPL, version 2 or above Maintainer : John MacFarlane <jgm@berkeley.edu> Stability : alpha@@ -35,33 +35,42 @@ import Text.Pandoc.Generic import Text.Pandoc.Templates (renderTemplate) import Text.Pandoc.Shared-import Text.Pandoc.Parsing hiding (blankline)-import Text.ParserCombinators.Parsec ( runParser, GenParser )+import Text.Pandoc.Options+import Text.Pandoc.Parsing hiding (blankline, char, space) import Data.List ( group, isPrefixOf, find, intersperse, transpose ) import Text.Pandoc.Pretty import Control.Monad.State+import qualified Data.Set as Set+import Text.Pandoc.Writers.HTML (writeHtmlString)+import Text.Pandoc.Readers.TeXMath (readTeXMath)+import Text.HTML.TagSoup (renderTags, parseTags, isTagText, Tag(..))+import Data.Default type Notes = [[Block]] type Refs = [([Inline], Target)] data WriterState = WriterState { stNotes :: Notes- , stRefs :: Refs+ , stRefs :: Refs+ , stIds :: [String] , stPlain :: Bool }+instance Default WriterState+ where def = WriterState{ stNotes = [], stRefs = [], stIds = [], stPlain = False } -- | Convert Pandoc to Markdown. writeMarkdown :: WriterOptions -> Pandoc -> String-writeMarkdown opts document = - evalState (pandocToMarkdown opts document) WriterState{ stNotes = []- , stRefs = []- , stPlain = False }+writeMarkdown opts document =+ evalState (pandocToMarkdown opts{+ writerWrapText = writerWrapText opts &&+ not (isEnabled Ext_hard_line_breaks opts) }+ document) def -- | Convert Pandoc to plain text (like markdown, but without links, -- pictures, or inline formatting). writePlain :: WriterOptions -> Pandoc -> String writePlain opts document =- evalState (pandocToMarkdown opts{writerStrictMarkdown = True}- document') WriterState{ stNotes = []- , stRefs = []- , stPlain = True }+ evalState (pandocToMarkdown opts{+ writerExtensions = Set.delete Ext_escaped_line_breaks $+ writerExtensions opts }+ document') def{ stPlain = True } where document' = plainify document plainify :: Pandoc -> Pandoc@@ -81,15 +90,41 @@ go (Cite _ cits) = SmallCaps cits go x = x +pandocTitleBlock :: Doc -> [Doc] -> Doc -> Doc+pandocTitleBlock tit auths dat =+ hang 2 (text "% ") tit <> cr <>+ hang 2 (text "% ") (hcat (intersperse (text "; ") auths)) <> cr <>+ hang 2 (text "% ") dat <> cr++mmdTitleBlock :: Doc -> [Doc] -> Doc -> Doc+mmdTitleBlock tit auths dat =+ hang 8 (text "Title: ") tit <> cr <>+ hang 8 (text "Author: ") (hcat (intersperse (text "; ") auths)) <> cr <>+ hang 8 (text "Date: ") dat <> cr++plainTitleBlock :: Doc -> [Doc] -> Doc -> Doc+plainTitleBlock tit auths dat =+ tit <> cr <>+ (hcat (intersperse (text "; ") auths)) <> cr <>+ dat <> cr+ -- | Return markdown representation of document. pandocToMarkdown :: WriterOptions -> Pandoc -> State WriterState String pandocToMarkdown opts (Pandoc (Meta title authors date) blocks) = do title' <- inlineListToMarkdown opts title authors' <- mapM (inlineListToMarkdown opts) authors date' <- inlineListToMarkdown opts date- let titleblock = not $ null title && null authors && null date+ isPlain <- gets stPlain+ let titleblock = case True of+ _ | isPlain ->+ plainTitleBlock title' authors' date'+ | isEnabled Ext_pandoc_title_block opts ->+ pandocTitleBlock title' authors' date'+ | isEnabled Ext_mmd_title_block opts ->+ mmdTitleBlock title' authors' date'+ | otherwise -> empty let headerBlocks = filter isHeaderBlock blocks- let toc = if writerTableOfContents opts + let toc = if writerTableOfContents opts then tableOfContents opts headerBlocks else empty body <- blockListToMarkdown opts blocks@@ -106,11 +141,9 @@ let context = writerVariables opts ++ [ ("toc", render colwidth toc) , ("body", main)- , ("title", render colwidth title')- , ("date", render colwidth date') ] ++- [ ("titleblock", "yes") | titleblock ] ++- [ ("author", render colwidth a) | a <- authors' ]+ [ ("titleblock", render colwidth titleblock)+ | not (null title && null authors && null date) ] if writerStandalone opts then return $ renderTemplate context $ writerTemplate opts else return main@@ -119,9 +152,9 @@ refsToMarkdown :: WriterOptions -> Refs -> State WriterState Doc refsToMarkdown opts refs = mapM (keyToMarkdown opts) refs >>= return . vcat --- | Return markdown representation of a reference key. -keyToMarkdown :: WriterOptions - -> ([Inline], (String, String)) +-- | Return markdown representation of a reference key.+keyToMarkdown :: WriterOptions+ -> ([Inline], (String, String)) -> State WriterState Doc keyToMarkdown opts (label, (src, tit)) = do label' <- inlineListToMarkdown opts label@@ -133,7 +166,7 @@ -- | Return markdown representation of notes. notesToMarkdown :: WriterOptions -> [[Block]] -> State WriterState Doc-notesToMarkdown opts notes = +notesToMarkdown opts notes = mapM (\(num, note) -> noteToMarkdown opts num note) (zip [1..] notes) >>= return . vsep @@ -141,13 +174,17 @@ noteToMarkdown :: WriterOptions -> Int -> [Block] -> State WriterState Doc noteToMarkdown opts num blocks = do contents <- blockListToMarkdown opts blocks- let num' = text $ show num- let marker = text "[^" <> num' <> text "]:"+ let num' = text $ writerIdentifierPrefix opts ++ show num+ let marker = if isEnabled Ext_footnotes opts+ then text "[^" <> num' <> text "]:"+ else text "[" <> num' <> text "]" let markerSize = 4 + offset num' let spacer = case writerTabStop opts - markerSize of n | n > 0 -> text $ replicate n ' ' _ -> text " "- return $ hang (writerTabStop opts) (marker <> spacer) contents+ return $ if isEnabled Ext_footnotes opts+ then hang (writerTabStop opts) (marker <> spacer) contents+ else marker <> spacer <> contents -- | Escape special characters for Markdown. escapeString :: String -> String@@ -155,21 +192,19 @@ where markdownEscapes = backslashEscapes "\\`*_$<>#~^" -- | Construct table of contents from list of header blocks.-tableOfContents :: WriterOptions -> [Block] -> Doc +tableOfContents :: WriterOptions -> [Block] -> Doc tableOfContents opts headers = let opts' = opts { writerIgnoreNotes = True }- contents = BulletList $ map elementToListItem $ hierarchicalize headers- in evalState (blockToMarkdown opts' contents) WriterState{ stNotes = []- , stRefs = []- , stPlain = False }+ contents = BulletList $ map (elementToListItem opts) $ hierarchicalize headers+ in evalState (blockToMarkdown opts' contents) def -- | Converts an Element to a list item for a table of contents,-elementToListItem :: Element -> [Block]-elementToListItem (Blk _) = []-elementToListItem (Sec _ _ _ headerText subsecs) = [Plain headerText] ++ - if null subsecs- then []- else [BulletList $ map elementToListItem subsecs]+elementToListItem :: WriterOptions -> Element -> [Block]+elementToListItem opts (Sec lev _ _ headerText subsecs)+ = Plain headerText :+ [ BulletList (map (elementToListItem opts) subsecs) |+ not (null subsecs) && lev < writerTOCDepth opts ]+elementToListItem _ (Blk _) = [] attrsToMarkdown :: Attr -> Doc attrsToMarkdown attribs = braces $ hsep [attribId, attribClasses, attribKeys]@@ -188,9 +223,9 @@ <> "=\"" <> text v <> "\"") ks -- | Ordered list start parser for use in Para below.-olMarker :: GenParser Char ParserState Char+olMarker :: Parser [Char] ParserState Char olMarker = do (start, style', delim) <- anyOrderedListMarker- if delim == Period && + if delim == Period && (style' == UpperAlpha || (style' == UpperRoman && start `elem` [1, 5, 10, 50, 100, 500, 1000])) then spaceChar >> spaceChar@@ -206,125 +241,209 @@ -- | Convert Pandoc block element to markdown. blockToMarkdown :: WriterOptions -- ^ Options -> Block -- ^ Block element- -> State WriterState Doc + -> State WriterState Doc blockToMarkdown _ Null = return empty blockToMarkdown opts (Plain inlines) = do contents <- inlineListToMarkdown opts inlines return $ contents <> cr+-- title beginning with fig: indicates figure+blockToMarkdown opts (Para [Image alt (src,'f':'i':'g':':':tit)]) =+ blockToMarkdown opts (Para [Image alt (src,tit)]) blockToMarkdown opts (Para inlines) = do contents <- inlineListToMarkdown opts inlines -- escape if para starts with ordered list marker st <- get- let esc = if (not (writerStrictMarkdown opts)) &&+ let esc = if isEnabled Ext_all_symbols_escapable opts && not (stPlain st) && beginsWithOrderedListMarker (render Nothing contents) then text "\x200B" -- zero-width space, a hack else empty return $ esc <> contents <> blankline-blockToMarkdown _ (RawBlock f str)- | f == "html" || f == "latex" || f == "tex" || f == "markdown" = do+blockToMarkdown opts (RawBlock f str)+ | f == "html" = do st <- get if stPlain st then return empty+ else return $ if isEnabled Ext_markdown_attribute opts+ then text (addMarkdownAttribute str) <> text "\n"+ else text str <> text "\n"+ | f == "latex" || f == "tex" || f == "markdown" = do+ st <- get+ if stPlain st+ then return empty else return $ text str <> text "\n" blockToMarkdown _ (RawBlock _ _) = return empty blockToMarkdown _ HorizontalRule = return $ blankline <> text "* * * * *" <> blankline-blockToMarkdown opts (Header level inlines) = do+blockToMarkdown opts (Header level attr inlines) = do+ -- we calculate the id that would be used by auto_identifiers+ -- so we know whether to print an explicit identifier+ ids <- gets stIds+ let autoId = uniqueIdent inlines ids+ modify $ \st -> st{ stIds = autoId : ids }+ let attr' = case attr of+ ("",[],[]) -> empty+ (id',[],[]) | isEnabled Ext_auto_identifiers opts+ && id' == autoId -> empty+ (id',_,_) | isEnabled Ext_mmd_header_identifiers opts ->+ space <> brackets (text id')+ _ | isEnabled Ext_header_attributes opts ->+ space <> attrsToMarkdown attr+ | otherwise -> empty contents <- inlineListToMarkdown opts inlines st <- get let setext = writerSetextHeaders opts return $ nowrap $ case level of 1 | setext ->- contents <> cr <> text (replicate (offset contents) '=') <>+ contents <> attr' <> cr <> text (replicate (offset contents) '=') <> blankline 2 | setext ->- contents <> cr <> text (replicate (offset contents) '-') <>+ contents <> attr' <> cr <> text (replicate (offset contents) '-') <> blankline -- ghc interprets '#' characters in column 1 as linenum specifiers.- _ | stPlain st || writerLiterateHaskell opts ->+ _ | stPlain st || isEnabled Ext_literate_haskell opts -> contents <> blankline- _ -> text (replicate level '#') <> space <> contents <> blankline+ _ -> text (replicate level '#') <> space <> contents <> attr' <> blankline blockToMarkdown opts (CodeBlock (_,classes,_) str) | "haskell" `elem` classes && "literate" `elem` classes &&- writerLiterateHaskell opts =+ isEnabled Ext_literate_haskell opts = return $ prefixed "> " (text str) <> blankline blockToMarkdown opts (CodeBlock attribs str) = return $- if writerStrictMarkdown opts || attribs == nullAttr- then nest (writerTabStop opts) (text str) <> blankline- else -- use delimited code block- (tildes <> space <> attrs <> cr <> text str <>- cr <> tildes) <> blankline- where tildes = text "~~~~"- attrs = attrsToMarkdown attribs+ case attribs of+ x | x /= nullAttr && isEnabled Ext_fenced_code_blocks opts ->+ tildes <> space <> attrs <> cr <> text str <>+ cr <> tildes <> blankline+ (_,(cls:_),_) | isEnabled Ext_backtick_code_blocks opts ->+ backticks <> space <> text cls <> cr <> text str <>+ cr <> backticks <> blankline+ _ -> nest (writerTabStop opts) (text str) <> blankline+ where tildes = text $ case [ln | ln <- lines str, all (=='~') ln] of+ [] -> "~~~~"+ xs -> case maximum $ map length xs of+ n | n < 3 -> "~~~~"+ | otherwise -> replicate (n+1) '~'+ backticks = text "```"+ attrs = if isEnabled Ext_fenced_code_attributes opts+ then attrsToMarkdown attribs+ else empty blockToMarkdown opts (BlockQuote blocks) = do st <- get -- if we're writing literate haskell, put a space before the bird tracks -- so they won't be interpreted as lhs...- let leader = if writerLiterateHaskell opts+ let leader = if isEnabled Ext_literate_haskell opts then " > " else if stPlain st then " " else "> " contents <- blockListToMarkdown opts blocks return $ (prefixed leader contents) <> blankline-blockToMarkdown opts (Table caption aligns widths headers rows) = do+blockToMarkdown opts t@(Table caption aligns widths headers rows) = do caption' <- inlineListToMarkdown opts caption- let caption'' = if null caption+ let caption'' = if null caption || not (isEnabled Ext_table_captions opts) then empty else blankline <> ": " <> caption' <> blankline- headers' <- mapM (blockListToMarkdown opts) headers+ rawHeaders <- mapM (blockListToMarkdown opts) headers+ rawRows <- mapM (mapM (blockListToMarkdown opts)) rows+ let isSimple = all (==0) widths+ (nst,tbl) <- case isSimple of+ True | isEnabled Ext_simple_tables opts -> fmap (nest 2,) $+ pandocTable opts (all null headers) aligns widths+ rawHeaders rawRows+ | isEnabled Ext_pipe_tables opts -> fmap (id,) $+ pipeTable (all null headers) aligns rawHeaders rawRows+ | otherwise -> fmap (id,) $+ return $ text $ writeHtmlString def+ $ Pandoc (Meta [] [] []) [t]+ False | isEnabled Ext_multiline_tables opts -> fmap (nest 2,) $+ pandocTable opts (all null headers) aligns widths+ rawHeaders rawRows+ | otherwise -> fmap (id,) $+ return $ text $ writeHtmlString def+ $ Pandoc (Meta [] [] []) [t]+ return $ nst $ tbl $$ blankline $$ caption'' $$ blankline+blockToMarkdown opts (BulletList items) = do+ contents <- mapM (bulletListItemToMarkdown opts) items+ return $ cat contents <> blankline+blockToMarkdown opts (OrderedList (start,sty,delim) items) = do+ let start' = if isEnabled Ext_startnum opts then start else 1+ let sty' = if isEnabled Ext_fancy_lists opts then sty else DefaultStyle+ let delim' = if isEnabled Ext_fancy_lists opts then delim else DefaultDelim+ let attribs = (start', sty', delim')+ let markers = orderedListMarkers attribs+ let markers' = map (\m -> if length m < 3+ then m ++ replicate (3 - length m) ' '+ else m) markers+ contents <- mapM (\(item, num) -> orderedListItemToMarkdown opts item num) $+ zip markers' items+ return $ cat contents <> blankline+blockToMarkdown opts (DefinitionList items) = do+ contents <- mapM (definitionListItemToMarkdown opts) items+ return $ cat contents <> blankline++addMarkdownAttribute :: String -> String+addMarkdownAttribute s =+ case span isTagText $ reverse $ parseTags s of+ (xs,(TagOpen t attrs:rest)) ->+ renderTags $ reverse rest ++ (TagOpen t attrs' : reverse xs)+ where attrs' = ("markdown","1"):[(x,y) | (x,y) <- attrs,+ x /= "markdown"]+ _ -> s++pipeTable :: Bool -> [Alignment] -> [Doc] -> [[Doc]] -> State WriterState Doc+pipeTable headless aligns rawHeaders rawRows = do+ let torow cs = nowrap $ text "|" <>+ hcat (intersperse (text "|") $ map chomp cs) <> text "|"+ let toborder (a, h) = let wid = max (offset h) 3+ in text $ case a of+ AlignLeft -> ':':replicate (wid - 1) '-'+ AlignCenter -> ':':replicate (wid - 2) '-' ++ ":"+ AlignRight -> replicate (wid - 1) '-' ++ ":"+ AlignDefault -> replicate wid '-'+ let header = if headless then empty else torow rawHeaders+ let border = torow $ map toborder $ zip aligns rawHeaders+ let body = vcat $ map torow rawRows+ return $ header $$ border $$ body++pandocTable :: WriterOptions -> Bool -> [Alignment] -> [Double]+ -> [Doc] -> [[Doc]] -> State WriterState Doc+pandocTable opts headless aligns widths rawHeaders rawRows = do+ let isSimple = all (==0) widths let alignHeader alignment = case alignment of AlignLeft -> lblock AlignCenter -> cblock AlignRight -> rblock AlignDefault -> lblock- rawRows <- mapM (mapM (blockListToMarkdown opts)) rows- let isSimple = all (==0) widths let numChars = maximum . map offset- let widthsInChars =- if isSimple- then map ((+2) . numChars) $ transpose (headers' : rawRows)- else map (floor . (fromIntegral (writerColumns opts) *)) widths+ let widthsInChars = if isSimple+ then map ((+2) . numChars)+ $ transpose (rawHeaders : rawRows)+ else map+ (floor . (fromIntegral (writerColumns opts) *))+ widths let makeRow = hcat . intersperse (lblock 1 (text " ")) . (zipWith3 alignHeader aligns widthsInChars) let rows' = map makeRow rawRows- let head' = makeRow headers'+ let head' = makeRow rawHeaders let maxRowHeight = maximum $ map height (head':rows') let underline = cat $ intersperse (text " ") $ map (\width -> text (replicate width '-')) widthsInChars let border = if maxRowHeight > 1 then text (replicate (sum widthsInChars + length widthsInChars - 1) '-')- else if all null headers+ else if headless then underline else empty- let head'' = if all null headers+ let head'' = if headless then empty else border <> cr <> head' let body = if maxRowHeight > 1 then vsep rows' else vcat rows'- let bottom = if all null headers+ let bottom = if headless then underline else border- return $ nest 2 $ head'' $$ underline $$ body $$- bottom $$ blankline $$ caption'' $$ blankline-blockToMarkdown opts (BulletList items) = do- contents <- mapM (bulletListItemToMarkdown opts) items- return $ cat contents <> blankline-blockToMarkdown opts (OrderedList attribs items) = do- let markers = orderedListMarkers attribs- let markers' = map (\m -> if length m < 3- then m ++ replicate (3 - length m) ' '- else m) markers- contents <- mapM (\(item, num) -> orderedListItemToMarkdown opts item num) $- zip markers' items- return $ cat contents <> blankline-blockToMarkdown opts (DefinitionList items) = do- contents <- mapM (definitionListItemToMarkdown opts) items- return $ cat contents <> blankline+ return $ head'' $$ underline $$ body $$ bottom -- | Convert bullet list item (list of blocks) to markdown. bulletListItemToMarkdown :: WriterOptions -> [Block] -> State WriterState Doc@@ -349,32 +468,38 @@ -- | Convert definition list item (label, list of blocks) to markdown. definitionListItemToMarkdown :: WriterOptions- -> ([Inline],[[Block]]) + -> ([Inline],[[Block]]) -> State WriterState Doc definitionListItemToMarkdown opts (label, defs) = do labelText <- inlineListToMarkdown opts label- let tabStop = writerTabStop opts- st <- get- let leader = if stPlain st then " " else ": "- let sps = case writerTabStop opts - 3 of- n | n > 0 -> text $ replicate n ' '- _ -> text " " defs' <- mapM (mapM (blockToMarkdown opts)) defs- let contents = vcat $ map (\d -> hang tabStop (leader <> sps) $ vcat d <> cr) defs'- return $ nowrap labelText <> cr <> contents <> cr+ if isEnabled Ext_definition_lists opts+ then do+ let tabStop = writerTabStop opts+ st <- get+ let leader = if stPlain st then " " else ": "+ let sps = case writerTabStop opts - 3 of+ n | n > 0 -> text $ replicate n ' '+ _ -> text " "+ let contents = vcat $ map (\d -> hang tabStop (leader <> sps) $ vcat d <> cr) defs'+ return $ nowrap labelText <> cr <> contents <> cr+ else do+ return $ nowrap labelText <> text " " <> cr <>+ vsep (map vsep defs') <> blankline -- | Convert list of Pandoc block elements to markdown. blockListToMarkdown :: WriterOptions -- ^ Options -> [Block] -- ^ List of block elements- -> State WriterState Doc + -> State WriterState Doc blockListToMarkdown opts blocks = mapM (blockToMarkdown opts) (fixBlocks blocks) >>= return . cat -- insert comment between list and indented code block, or the -- code block will be treated as a list continuation paragraph where fixBlocks (b : CodeBlock attr x : rest)- | (writerStrictMarkdown opts || attr == nullAttr) && isListBlock b =+ | (not (isEnabled Ext_fenced_code_blocks opts) || attr == nullAttr)+ && isListBlock b = b : RawBlock "html" "<!-- -->\n" : CodeBlock attr x :- fixBlocks rest+ fixBlocks rest fixBlocks (x : xs) = x : fixBlocks xs fixBlocks [] = [] isListBlock (BulletList _) = True@@ -412,7 +537,7 @@ -- | Convert Pandoc inline element to markdown. inlineToMarkdown :: WriterOptions -> Inline -> State WriterState Doc-inlineToMarkdown opts (Emph lst) = do +inlineToMarkdown opts (Emph lst) = do contents <- inlineListToMarkdown opts lst return $ "*" <> contents <> "*" inlineToMarkdown opts (Strong lst) = do@@ -420,15 +545,21 @@ return $ "**" <> contents <> "**" inlineToMarkdown opts (Strikeout lst) = do contents <- inlineListToMarkdown opts lst- return $ "~~" <> contents <> "~~"+ return $ if isEnabled Ext_strikeout opts+ then "~~" <> contents <> "~~"+ else "<s>" <> contents <> "</s>" inlineToMarkdown opts (Superscript lst) = do let lst' = bottomUp escapeSpaces lst contents <- inlineListToMarkdown opts lst'- return $ "^" <> contents <> "^"+ return $ if isEnabled Ext_superscript opts+ then "^" <> contents <> "^"+ else "<sup>" <> contents <> "</sup>" inlineToMarkdown opts (Subscript lst) = do let lst' = bottomUp escapeSpaces lst contents <- inlineListToMarkdown opts lst'- return $ "~" <> contents <> "~"+ return $ if isEnabled Ext_subscript opts+ then "~" <> contents <> "~"+ else "<sub>" <> contents <> "</sub>" inlineToMarkdown opts (SmallCaps lst) = inlineListToMarkdown opts lst inlineToMarkdown opts (Quoted SingleQuote lst) = do contents <- inlineListToMarkdown opts lst@@ -437,33 +568,47 @@ contents <- inlineListToMarkdown opts lst return $ "“" <> contents <> "”" inlineToMarkdown opts (Code attr str) =- let tickGroups = filter (\s -> '`' `elem` s) $ group str + let tickGroups = filter (\s -> '`' `elem` s) $ group str longest = if null tickGroups then 0- else maximum $ map length tickGroups - marker = replicate (longest + 1) '`' + else maximum $ map length tickGroups+ marker = replicate (longest + 1) '`' spacer = if (longest == 0) then "" else " "- attrs = if writerStrictMarkdown opts || attr == nullAttr- then empty- else attrsToMarkdown attr+ attrs = if isEnabled Ext_inline_code_attributes opts && attr /= nullAttr+ then attrsToMarkdown attr+ else empty in return $ text (marker ++ spacer ++ str ++ spacer ++ marker) <> attrs inlineToMarkdown _ (Str str) = do st <- get if stPlain st then return $ text str else return $ text $ escapeString str-inlineToMarkdown _ (Math InlineMath str) =- return $ "$" <> text str <> "$"-inlineToMarkdown _ (Math DisplayMath str) =- return $ "$$" <> text str <> "$$"-inlineToMarkdown _ (RawInline f str)- | f == "html" || f == "latex" || f == "tex" || f == "markdown" =+inlineToMarkdown opts (Math InlineMath str)+ | isEnabled Ext_tex_math_dollars opts =+ return $ "$" <> text str <> "$"+ | isEnabled Ext_tex_math_single_backslash opts =+ return $ "\\(" <> text str <> "\\)"+ | isEnabled Ext_tex_math_double_backslash opts =+ return $ "\\\\(" <> text str <> "\\\\)"+ | otherwise = inlineListToMarkdown opts $ readTeXMath str+inlineToMarkdown opts (Math DisplayMath str)+ | isEnabled Ext_tex_math_dollars opts =+ return $ "$$" <> text str <> "$$"+ | isEnabled Ext_tex_math_single_backslash opts =+ return $ "\\[" <> text str <> "\\]"+ | isEnabled Ext_tex_math_double_backslash opts =+ return $ "\\\\[" <> text str <> "\\\\]"+ | otherwise = (\x -> cr <> x <> cr) `fmap`+ inlineListToMarkdown opts (readTeXMath str)+inlineToMarkdown opts (RawInline f str)+ | f == "html" || f == "markdown" ||+ (isEnabled Ext_raw_tex opts && (f == "latex" || f == "tex")) = return $ text str inlineToMarkdown _ (RawInline _ _) = return empty-inlineToMarkdown opts (LineBreak) = return $- if writerStrictMarkdown opts- then " " <> cr- else "\\" <> cr+inlineToMarkdown opts (LineBreak)+ | isEnabled Ext_hard_line_breaks opts = return cr+ | isEnabled Ext_escaped_line_breaks opts = return $ "\\" <> cr+ | otherwise = return $ " " <> cr inlineToMarkdown _ Space = return space inlineToMarkdown opts (Cite (c:cs) lst) | writerCiteMethod opts == Citeproc = inlineListToMarkdown opts lst@@ -500,8 +645,8 @@ else text $ " \"" ++ tit ++ "\"" let srcSuffix = if isPrefixOf "mailto:" src then drop 7 src else src let useAuto = case (tit,txt) of- ("", [Code _ s]) | s == srcSuffix -> True- _ -> False+ ("", [Str s]) | escapeURI s == srcSuffix -> True+ _ -> False let useRefLinks = writerReferenceLinks opts && not useAuto ref <- if useRefLinks then getReference txt (src, tit) else return [] reftext <- inlineListToMarkdown opts ref@@ -513,7 +658,7 @@ then "[]" else "[" <> reftext <> "]" in first <> second- else "[" <> linktext <> "](" <> + else "[" <> linktext <> "](" <> text src <> linktitle <> ")" inlineToMarkdown opts (Image alternate (source, tit)) = do let txt = if null alternate || alternate == [Str source]@@ -522,8 +667,10 @@ else alternate linkPart <- inlineToMarkdown opts (Link txt (source, tit)) return $ "!" <> linkPart-inlineToMarkdown _ (Note contents) = do +inlineToMarkdown opts (Note contents) = do modify (\st -> st{ stNotes = contents : stNotes st }) st <- get- let ref = show $ (length $ stNotes st)- return $ "[^" <> text ref <> "]"+ let ref = text $ writerIdentifierPrefix opts ++ show (length $ stNotes st)+ if isEnabled Ext_footnotes opts+ then return $ "[^" <> ref <> "]"+ else return $ "[" <> ref <> "]"
@@ -17,9 +17,9 @@ -} {- |- Module : Text.Pandoc.Writers.MediaWiki + Module : Text.Pandoc.Writers.MediaWiki Copyright : Copyright (C) 2008-2010 John MacFarlane- License : GNU GPL, version 2 or above + License : GNU GPL, version 2 or above Maintainer : John MacFarlane <jgm@berkeley.edu> Stability : alpha@@ -31,7 +31,8 @@ -} module Text.Pandoc.Writers.MediaWiki ( writeMediaWiki ) where import Text.Pandoc.Definition-import Text.Pandoc.Shared +import Text.Pandoc.Options+import Text.Pandoc.Shared import Text.Pandoc.Templates (renderTemplate) import Text.Pandoc.XML ( escapeStringForXML ) import Data.List ( intersect, intercalate )@@ -46,9 +47,9 @@ -- | Convert Pandoc to MediaWiki. writeMediaWiki :: WriterOptions -> Pandoc -> String-writeMediaWiki opts document = - evalState (pandocToMediaWiki opts document) - (WriterState { stNotes = False, stListLevel = [], stUseTags = False }) +writeMediaWiki opts document =+ evalState (pandocToMediaWiki opts document)+ (WriterState { stNotes = False, stListLevel = [], stUseTags = False }) -- | Return MediaWiki representation of document. pandocToMediaWiki :: WriterOptions -> Pandoc -> State WriterState String@@ -57,7 +58,7 @@ notesExist <- get >>= return . stNotes let notes = if notesExist then "\n<references />"- else "" + else "" let main = body ++ notes let context = writerVariables opts ++ [ ("body", main) ] ++@@ -70,22 +71,24 @@ escapeString :: String -> String escapeString = escapeStringForXML --- | Convert Pandoc block element to MediaWiki. +-- | Convert Pandoc block element to MediaWiki. blockToMediaWiki :: WriterOptions -- ^ Options -> Block -- ^ Block element- -> State WriterState String + -> State WriterState String blockToMediaWiki _ Null = return "" -blockToMediaWiki opts (Plain inlines) = +blockToMediaWiki opts (Plain inlines) = inlineListToMediaWiki opts inlines -blockToMediaWiki opts (Para [Image txt (src,tit)]) = do- capt <- inlineListToMediaWiki opts txt +-- title beginning with fig: indicates that the image is a figure+blockToMediaWiki opts (Para [Image txt (src,'f':'i':'g':':':tit)]) = do+ capt <- if null txt+ then return ""+ else ("|caption " ++) `fmap` inlineListToMediaWiki opts txt let opt = if null txt then ""- else "|alt=" ++ if null tit then capt else tit ++- "|caption " ++ capt+ else "|alt=" ++ if null tit then capt else tit ++ capt return $ "[[Image:" ++ src ++ "|frame|none" ++ opt ++ "]]\n" blockToMediaWiki opts (Para inlines) = do@@ -102,7 +105,7 @@ blockToMediaWiki _ HorizontalRule = return "\n-----\n" -blockToMediaWiki opts (Header level inlines) = do+blockToMediaWiki opts (Header level _ inlines) = do contents <- inlineListToMediaWiki opts inlines let eqs = replicate level '=' return $ eqs ++ " " ++ contents ++ " " ++ eqs ++ "\n"@@ -115,7 +118,7 @@ "javascript", "latex", "lisp", "lua", "matlab", "mirc", "mpasm", "mysql", "nsis", "objc", "ocaml", "ocaml-brief", "oobas", "oracle8", "pascal", "perl", "php", "php-brief", "plsql", "python", "qbasic", "rails", "reg", "robots", "ruby", "sas", "scheme", "sdlbasic",- "smalltalk", "smarty", "sql", "tcl", "", "thinbasic", "tsql", "vb", "vbnet", "vhdl", + "smalltalk", "smarty", "sql", "tcl", "", "thinbasic", "tsql", "vb", "vbnet", "vhdl", "visualfoxpro", "winbatch", "xml", "xpp", "z80"] let (beg, end) = if null at then ("<pre" ++ if null classes then ">" else " class=\"" ++ unwords classes ++ "\">", "</pre>")@@ -124,7 +127,7 @@ blockToMediaWiki opts (BlockQuote blocks) = do contents <- blockListToMediaWiki opts blocks- return $ "<blockquote>" ++ contents ++ "</blockquote>" + return $ "<blockquote>" ++ contents ++ "</blockquote>" blockToMediaWiki opts (Table capt aligns widths headers rows') = do let alignStrings = map alignmentToString aligns@@ -221,7 +224,7 @@ -- | Convert definition list item (label, list of blocks) to MediaWiki. definitionListItemToMediaWiki :: WriterOptions- -> ([Inline],[[Block]]) + -> ([Inline],[[Block]]) -> State WriterState String definitionListItemToMediaWiki opts (label, items) = do labelText <- inlineListToMediaWiki opts label@@ -242,7 +245,7 @@ BulletList items -> all isSimpleListItem items OrderedList (num, sty, _) items -> all isSimpleListItem items && num == 1 && sty `elem` [DefaultStyle, Decimal]- DefinitionList items -> all isSimpleListItem $ concatMap snd items + DefinitionList items -> all isSimpleListItem $ concatMap snd items _ -> False -- | True if list item can be handled with the simple wiki syntax. False if@@ -287,8 +290,8 @@ 0 -> "header" x | x `rem` 2 == 1 -> "odd" _ -> "even"- cols'' <- sequence $ zipWith - (\alignment item -> tableItemToMediaWiki opts celltype alignment item) + cols'' <- sequence $ zipWith+ (\alignment item -> tableItemToMediaWiki opts celltype alignment item) alignStrings cols' return $ "<tr class=\"" ++ rowclass ++ "\">\n" ++ unlines cols'' ++ "</tr>" @@ -313,7 +316,7 @@ -- | Convert list of Pandoc block elements to MediaWiki. blockListToMediaWiki :: WriterOptions -- ^ Options -> [Block] -- ^ List of block elements- -> State WriterState String + -> State WriterState String blockListToMediaWiki opts blocks = mapM (blockToMediaWiki opts) blocks >>= return . vcat @@ -325,9 +328,9 @@ -- | Convert Pandoc inline element to MediaWiki. inlineToMediaWiki :: WriterOptions -> Inline -> State WriterState String -inlineToMediaWiki opts (Emph lst) = do +inlineToMediaWiki opts (Emph lst) = do contents <- inlineListToMediaWiki opts lst- return $ "''" ++ contents ++ "''" + return $ "''" ++ contents ++ "''" inlineToMediaWiki opts (Strong lst) = do contents <- inlineListToMediaWiki opts lst@@ -358,25 +361,25 @@ inlineToMediaWiki opts (Cite _ lst) = inlineListToMediaWiki opts lst inlineToMediaWiki _ (Code _ str) =- return $ "<tt>" ++ (escapeString str) ++ "</tt>"+ return $ "<code>" ++ (escapeString str) ++ "</code>" inlineToMediaWiki _ (Str str) = return $ escapeString str inlineToMediaWiki _ (Math _ str) = return $ "<math>" ++ str ++ "</math>" -- note: str should NOT be escaped -inlineToMediaWiki _ (RawInline "mediawiki" str) = return str -inlineToMediaWiki _ (RawInline "html" str) = return str +inlineToMediaWiki _ (RawInline "mediawiki" str) = return str+inlineToMediaWiki _ (RawInline "html" str) = return str inlineToMediaWiki _ (RawInline _ _) = return "" -inlineToMediaWiki _ (LineBreak) = return "<br />\n"+inlineToMediaWiki _ (LineBreak) = return "<br />" inlineToMediaWiki _ Space = return " " inlineToMediaWiki opts (Link txt (src, _)) = do label <- inlineListToMediaWiki opts txt case txt of- [Code _ s] | s == src -> return src+ [Str s] | escapeURI s == src -> return src _ -> if isURI src then return $ "[" ++ src ++ " " ++ label ++ "]" else return $ "[[" ++ src' ++ "|" ++ label ++ "]]"@@ -392,7 +395,7 @@ else "|" ++ tit return $ "[[Image:" ++ source ++ txt ++ "]]" -inlineToMediaWiki opts (Note contents) = do +inlineToMediaWiki opts (Note contents) = do contents' <- blockListToMediaWiki opts contents modify (\s -> s { stNotes = True }) return $ "<ref>" ++ contents' ++ "</ref>"
@@ -20,7 +20,7 @@ {- | Module : Text.Pandoc.Writers.Native Copyright : Copyright (C) 2006-2010 John MacFarlane- License : GNU GPL, version 2 or above + License : GNU GPL, version 2 or above Maintainer : John MacFarlane <jgm@berkeley.edu> Stability : alpha@@ -34,7 +34,7 @@ -} module Text.Pandoc.Writers.Native ( writeNative ) where-import Text.Pandoc.Shared ( WriterOptions(..) )+import Text.Pandoc.Options ( WriterOptions(..) ) import Data.List ( intersperse ) import Text.Pandoc.Definition import Text.Pandoc.Pretty@@ -47,17 +47,17 @@ prettyBlock :: Block -> Doc prettyBlock (BlockQuote blocks) = "BlockQuote" $$ prettyList (map prettyBlock blocks)-prettyBlock (OrderedList attribs blockLists) = +prettyBlock (OrderedList attribs blockLists) = "OrderedList" <> space <> text (show attribs) $$ (prettyList $ map (prettyList . map prettyBlock) blockLists)-prettyBlock (BulletList blockLists) = +prettyBlock (BulletList blockLists) = "BulletList" $$ (prettyList $ map (prettyList . map prettyBlock) blockLists) prettyBlock (DefinitionList items) = "DefinitionList" $$ (prettyList $ map deflistitem items) where deflistitem (term, defs) = "(" <> text (show term) <> "," <> cr <> nest 1 (prettyList $ map (prettyList . map prettyBlock) defs) <> ")"-prettyBlock (Table caption aligns widths header rows) = +prettyBlock (Table caption aligns widths header rows) = "Table " <> text (show caption) <> " " <> text (show aligns) <> " " <> text (show widths) $$ prettyRow header $$
@@ -1,3 +1,4 @@+{-# LANGUAGE ScopedTypeVariables #-} {- Copyright (C) 2008-2010 John MacFarlane <jgm@berkeley.edu> @@ -27,55 +28,45 @@ Conversion of 'Pandoc' documents to ODT. -}-{-# LANGUAGE ScopedTypeVariables #-} module Text.Pandoc.Writers.ODT ( writeODT ) where import Data.IORef import Data.List ( isPrefixOf )-import System.FilePath ( (</>), takeExtension ) import qualified Data.ByteString.Lazy as B-import Data.ByteString.Lazy.UTF8 ( fromString )+import Text.Pandoc.UTF8 ( fromStringLazy ) import Codec.Archive.Zip-import Data.Time.Clock.POSIX-import Paths_pandoc ( getDataFileName )-import Text.Pandoc.Shared ( WriterOptions(..) )-import Text.Pandoc.ImageSize ( readImageSize, sizeInPoints )+import Text.Pandoc.Options ( WriterOptions(..) )+import Text.Pandoc.Shared ( stringify, readDataFile, fetchItem, warn )+import Text.Pandoc.ImageSize ( imageSize, sizeInPoints ) import Text.Pandoc.MIME ( getMimeType ) import Text.Pandoc.Definition import Text.Pandoc.Generic import Text.Pandoc.Writers.OpenDocument ( writeOpenDocument )-import System.Directory import Control.Monad (liftM)-import Network.URI ( unEscapeString )+import Control.Monad.Trans (liftIO) import Text.Pandoc.XML import Text.Pandoc.Pretty-import qualified Control.Exception as E (catch, IOException)+import qualified Control.Exception as E+import Data.Time.Clock.POSIX ( getPOSIXTime )+import System.FilePath ( takeExtension ) -- | Produce an ODT file from a Pandoc document.-writeODT :: Maybe FilePath -- ^ Path specified by --reference-odt- -> WriterOptions -- ^ Writer options+writeODT :: WriterOptions -- ^ Writer options -> Pandoc -- ^ Document to convert -> IO B.ByteString-writeODT mbRefOdt opts doc = do+writeODT opts doc@(Pandoc (Meta title _ _) _) = do let datadir = writerUserDataDir opts refArchive <- liftM toArchive $- case mbRefOdt of+ case writerReferenceODT opts of Just f -> B.readFile f- Nothing -> do- let defaultODT = getDataFileName "reference.odt" >>= B.readFile- case datadir of- Nothing -> defaultODT- Just d -> do- exists <- doesFileExist (d </> "reference.odt")- if exists- then B.readFile (d </> "reference.odt")- else defaultODT+ Nothing -> (B.fromChunks . (:[])) `fmap`+ readDataFile datadir "reference.odt" -- handle pictures picEntriesRef <- newIORef ([] :: [Entry]) let sourceDir = writerSourceDirectory opts doc' <- bottomUpM (transformPic sourceDir picEntriesRef) doc let newContents = writeOpenDocument opts{writerWrapText = False} doc' epochtime <- floor `fmap` getPOSIXTime- let contentEntry = toEntry "content.xml" epochtime $ fromString newContents+ let contentEntry = toEntry "content.xml" epochtime $ fromStringLazy newContents picEntries <- readIORef picEntriesRef let archive = foldr addEntryToArchive refArchive $ contentEntry : picEntries -- construct META-INF/manifest.xml based on archive@@ -87,7 +78,7 @@ ] let files = [ ent | ent <- filesInArchive archive, not ("META-INF" `isPrefixOf` ent) ] let manifestEntry = toEntry "META-INF/manifest.xml" epochtime- $ fromString $ show+ $ fromStringLazy $ show $ text "<?xml version=\"1.0\" encoding=\"utf-8\"?>" $$ ( inTags True "manifest:manifest"@@ -100,21 +91,43 @@ ) ) let archive' = addEntryToArchive manifestEntry archive- return $ fromArchive archive'+ let metaEntry = toEntry "meta.xml" epochtime+ $ fromStringLazy $ show+ $ text "<?xml version=\"1.0\" encoding=\"utf-8\"?>"+ $$+ ( inTags True "office:document-meta"+ [("xmlns:office","urn:oasis:names:tc:opendocument:xmlns:office:1.0")+ ,("xmlns:xlink","http://www.w3.org/1999/xlink")+ ,("xmlns:dc","http://purl.org/dc/elements/1.1/")+ ,("xmlns:meta","urn:oasis:names:tc:opendocument:xmlns:meta:1.0")+ ,("xmlns:ooo","http://openoffice.org/2004/office")+ ,("xmlns:grddl","http://www.w3.org/2003/g/data-view#")+ ,("office:version","1.2")]+ $ ( inTagsSimple "office:meta"+ $ ( inTagsSimple "dc:title" (text $ escapeStringForXML (stringify title))+ )+ )+ )+ let archive'' = addEntryToArchive metaEntry archive'+ return $ fromArchive archive'' transformPic :: FilePath -> IORef [Entry] -> Inline -> IO Inline-transformPic sourceDir entriesRef (Image lab (src,tit)) = do- let src' = unEscapeString src- mbSize <- readImageSize src'- let tit' = case mbSize of- Just s -> let (w,h) = sizeInPoints s- in show w ++ "x" ++ show h- Nothing -> tit- entries <- readIORef entriesRef- let newsrc = "Pictures/" ++ show (length entries) ++ takeExtension src'- E.catch (readEntry [] (sourceDir </> src') >>= \entry ->- modifyIORef entriesRef (entry{ eRelativePath = newsrc } :) >>- return (Image lab (newsrc, tit')))- (\(_::E.IOException) -> return (Emph lab))+transformPic sourceDir entriesRef (Image lab (src,_)) = do+ res <- liftIO $ E.try $ fetchItem sourceDir src+ case res of+ Left (_ :: E.SomeException) -> do+ liftIO $ warn $ "Could not find image `" ++ src ++ "', skipping..."+ return $ Emph lab+ Right (img, _) -> do+ let size = imageSize img+ let (w,h) = maybe (0,0) id $ sizeInPoints `fmap` size+ let tit' = show w ++ "x" ++ show h+ entries <- readIORef entriesRef+ let newsrc = "Pictures/" ++ show (length entries) ++ takeExtension src+ let toLazy = B.fromChunks . (:[])+ epochtime <- floor `fmap` getPOSIXTime+ let entry = toEntry newsrc epochtime $ toLazy img+ modifyIORef entriesRef (entry:)+ return $ Image lab (newsrc, tit') transformPic _ _ x = return x
@@ -31,7 +31,7 @@ -} module Text.Pandoc.Writers.OpenDocument ( writeOpenDocument ) where import Text.Pandoc.Definition-import Text.Pandoc.Shared+import Text.Pandoc.Options import Text.Pandoc.XML import Text.Pandoc.Templates (renderTemplate) import Text.Pandoc.Readers.TeXMath@@ -287,7 +287,7 @@ blockToOpenDocument o bs | Plain b <- bs = inParagraphTags =<< inlinesToOpenDocument o b | Para b <- bs = inParagraphTags =<< inlinesToOpenDocument o b- | Header i b <- bs = setFirstPara >>+ | Header i _ b <- bs = setFirstPara >> (inHeaderTags i =<< inlinesToOpenDocument o b) | BlockQuote b <- bs = setFirstPara >> mkBlockQuote b | DefinitionList b <- bs = setFirstPara >> defList b
@@ -20,7 +20,7 @@ {- | Module : Text.Pandoc.Writers.Org Copyright : Copyright (C) 2010 Puneeth Chaganti- License : GNU GPL, version 2 or above + License : GNU GPL, version 2 or above Maintainer : Puneeth Chaganti <punchagan@gmail.com> Stability : alpha@@ -32,14 +32,15 @@ -} module Text.Pandoc.Writers.Org ( writeOrg) where import Text.Pandoc.Definition-import Text.Pandoc.Shared +import Text.Pandoc.Options+import Text.Pandoc.Shared import Text.Pandoc.Pretty import Text.Pandoc.Templates (renderTemplate) import Data.List ( intersect, intersperse, transpose ) import Control.Monad.State import Control.Applicative ( (<$>) ) -data WriterState = +data WriterState = WriterState { stNotes :: [[Block]] , stLinks :: Bool , stImages :: Bool@@ -49,7 +50,7 @@ -- | Convert Pandoc to Org. writeOrg :: WriterOptions -> Pandoc -> String-writeOrg opts document = +writeOrg opts document = let st = WriterState { stNotes = [], stLinks = False, stImages = False, stHasMath = False, stOptions = opts }@@ -82,8 +83,8 @@ -- | Return Org representation of notes. notesToOrg :: [[Block]] -> State WriterState Doc-notesToOrg notes = - mapM (\(num, note) -> noteToOrg num note) (zip [1..] notes) >>= +notesToOrg notes =+ mapM (\(num, note) -> noteToOrg num note) (zip [1..] notes) >>= return . vsep -- | Return Org representation of a note.@@ -106,45 +107,49 @@ titleToOrg [] = return empty titleToOrg lst = do contents <- inlineListToOrg lst- return $ "#+TITLE: " <> contents + return $ "#+TITLE: " <> contents --- | Convert Pandoc block element to Org. +-- | Convert Pandoc block element to Org. blockToOrg :: Block -- ^ Block element- -> State WriterState Doc + -> State WriterState Doc blockToOrg Null = return empty blockToOrg (Plain inlines) = inlineListToOrg inlines-blockToOrg (Para [Image txt (src,tit)]) = do- capt <- inlineListToOrg txt+-- title beginning with fig: indicates that the image is a figure+blockToOrg (Para [Image txt (src,'f':'i':'g':':':tit)]) = do+ capt <- if null txt+ then return empty+ else (\c -> "#+CAPTION: " <> c <> blankline) `fmap`+ inlineListToOrg txt img <- inlineToOrg (Image txt (src,tit))- return $ "#+CAPTION: " <> capt <> blankline <> img+ return $ capt <> img blockToOrg (Para inlines) = do contents <- inlineListToOrg inlines return $ contents <> blankline-blockToOrg (RawBlock "html" str) = +blockToOrg (RawBlock "html" str) = return $ blankline $$ "#+BEGIN_HTML" $$ nest 2 (text str) $$ "#+END_HTML" $$ blankline blockToOrg (RawBlock f str) | f == "org" || f == "latex" || f == "tex" = return $ text str blockToOrg (RawBlock _ _) = return empty blockToOrg HorizontalRule = return $ blankline $$ "--------------" $$ blankline-blockToOrg (Header level inlines) = do+blockToOrg (Header level _ inlines) = do contents <- inlineListToOrg inlines let headerStr = text $ if level > 999 then " " else replicate level '*' return $ headerStr <> " " <> contents <> blankline blockToOrg (CodeBlock (_,classes,_) str) = do opts <- stOptions <$> get let tabstop = writerTabStop opts- let at = classes `intersect` ["asymptote", "C", "clojure", "css", "ditaa", - "dot", "emacs-lisp", "gnuplot", "haskell", "js", "latex", - "ledger", "lisp", "matlab", "mscgen", "ocaml", "octave", - "oz", "perl", "plantuml", "python", "R", "ruby", "sass", + let at = classes `intersect` ["asymptote", "C", "clojure", "css", "ditaa",+ "dot", "emacs-lisp", "gnuplot", "haskell", "js", "latex",+ "ledger", "lisp", "matlab", "mscgen", "ocaml", "octave",+ "oz", "perl", "plantuml", "python", "R", "ruby", "sass", "scheme", "screen", "sh", "sql", "sqlite"] let (beg, end) = case at of [] -> ("#+BEGIN_EXAMPLE", "#+END_EXAMPLE") (x:_) -> ("#+BEGIN_SRC " ++ x, "#+END_SRC") return $ text beg $$ nest tabstop (text str) $$ text end $$ blankline blockToOrg (BlockQuote blocks) = do- contents <- blockListToOrg blocks + contents <- blockListToOrg blocks return $ blankline $$ "#+BEGIN_QUOTE" $$ nest 2 contents $$ "#+END_QUOTE" $$ blankline blockToOrg (Table caption' _ _ headers rows) = do@@ -155,11 +160,11 @@ headers' <- mapM blockListToOrg headers rawRows <- mapM (mapM blockListToOrg) rows let numChars = maximum . map offset- -- FIXME: width is not being used. + -- FIXME: width is not being used. let widthsInChars = map ((+2) . numChars) $ transpose (headers' : rawRows)- -- FIXME: Org doesn't allow blocks with height more than 1. - let hpipeBlocks blocks = hcat [beg, middle, end] + -- FIXME: Org doesn't allow blocks with height more than 1.+ let hpipeBlocks blocks = hcat [beg, middle, end] where h = maximum (map height blocks) sep' = lblock 3 $ vcat (map text $ replicate h " | ") beg = lblock 2 $ vcat (map text $ replicate h "| ")@@ -170,7 +175,7 @@ rows' <- mapM (\row -> do cols <- mapM blockListToOrg row return $ makeRow cols) rows let border ch = char '|' <> char ch <>- (hcat $ intersperse (char ch <> char '+' <> char ch) $ + (hcat $ intersperse (char ch <> char '+' <> char ch) $ map (\l -> text $ replicate l ch) widthsInChars) <> char ch <> char '|' let body = vcat rows'@@ -186,7 +191,7 @@ let delim' = case delim of TwoParens -> OneParen x -> x- let markers = take (length items) $ orderedListMarkers + let markers = take (length items) $ orderedListMarkers (start, Decimal, delim') let maxMarkerLength = maximum $ map length markers let markers' = map (\m -> let s = maxMarkerLength - length m@@ -222,7 +227,7 @@ -- | Convert list of Pandoc block elements to Org. blockListToOrg :: [Block] -- ^ List of block elements- -> State WriterState Doc + -> State WriterState Doc blockListToOrg blocks = mapM blockToOrg blocks >>= return . vcat -- | Convert list of Pandoc inline elements to Org.@@ -231,19 +236,19 @@ -- | Convert Pandoc inline element to Org. inlineToOrg :: Inline -> State WriterState Doc-inlineToOrg (Emph lst) = do +inlineToOrg (Emph lst) = do contents <- inlineListToOrg lst return $ "/" <> contents <> "/" inlineToOrg (Strong lst) = do contents <- inlineListToOrg lst return $ "*" <> contents <> "*"-inlineToOrg (Strikeout lst) = do +inlineToOrg (Strikeout lst) = do contents <- inlineListToOrg lst return $ "+" <> contents <> "+"-inlineToOrg (Superscript lst) = do +inlineToOrg (Superscript lst) = do contents <- inlineListToOrg lst return $ "^{" <> contents <> "}"-inlineToOrg (Subscript lst) = do +inlineToOrg (Subscript lst) = do contents <- inlineListToOrg lst return $ "_{" <> contents <> "}" inlineToOrg (SmallCaps lst) = inlineListToOrg lst@@ -267,7 +272,7 @@ inlineToOrg Space = return space inlineToOrg (Link txt (src, _)) = do case txt of- [Code _ x] | x == src -> -- autolink+ [Str x] | escapeURI x == src -> -- autolink do modify $ \s -> s{ stLinks = True } return $ "[[" <> text x <> "]]" _ -> do contents <- inlineListToOrg txt@@ -276,7 +281,7 @@ inlineToOrg (Image _ (source, _)) = do modify $ \s -> s{ stImages = True } return $ "[[" <> text source <> "]]"-inlineToOrg (Note contents) = do +inlineToOrg (Note contents) = do -- add to notes in state notes <- get >>= (return . stNotes) modify $ \st -> st { stNotes = contents:notes }
@@ -18,9 +18,9 @@ -} {- |- Module : Text.Pandoc.Writers.RST + Module : Text.Pandoc.Writers.RST Copyright : Copyright (C) 2006-2010 John MacFarlane- License : GNU GPL, version 2 or above + License : GNU GPL, version 2 or above Maintainer : John MacFarlane <jgm@berkeley.edu> Stability : alpha@@ -32,7 +32,8 @@ -} module Text.Pandoc.Writers.RST ( writeRST) where import Text.Pandoc.Definition-import Text.Pandoc.Shared +import Text.Pandoc.Options+import Text.Pandoc.Shared import Text.Pandoc.Templates (renderTemplate) import Data.List ( isPrefixOf, intersperse, transpose ) import Text.Pandoc.Pretty@@ -42,17 +43,17 @@ type Refs = [([Inline], Target)] -data WriterState = +data WriterState = WriterState { stNotes :: [[Block]] , stLinks :: Refs- , stImages :: Refs+ , stImages :: [([Inline], (String, String, Maybe String))] , stHasMath :: Bool , stOptions :: WriterOptions } -- | Convert Pandoc to RST. writeRST :: WriterOptions -> Pandoc -> String-writeRST opts document = +writeRST opts document = let st = WriterState { stNotes = [], stLinks = [], stImages = [], stHasMath = False, stOptions = opts }@@ -78,7 +79,9 @@ let context = writerVariables opts ++ [ ("body", main) , ("title", render Nothing title)- , ("date", render colwidth date) ] +++ , ("date", render colwidth date)+ , ("toc", if writerTableOfContents opts then "yes" else "")+ , ("toc-depth", show (writerTOCDepth opts)) ] ++ [ ("math", "yes") | hasMath ] ++ [ ("author", render colwidth a) | a <- authors ] if writerStandalone opts@@ -89,8 +92,8 @@ refsToRST :: Refs -> State WriterState Doc refsToRST refs = mapM keyToRST refs >>= return . vcat --- | Return RST representation of a reference key. -keyToRST :: ([Inline], (String, String)) +-- | Return RST representation of a reference key.+keyToRST :: ([Inline], (String, String)) -> State WriterState Doc keyToRST (label, (src, _)) = do label' <- inlineListToRST label@@ -101,7 +104,7 @@ -- | Return RST representation of notes. notesToRST :: [[Block]] -> State WriterState Doc-notesToRST notes = +notesToRST notes = mapM (\(num, note) -> noteToRST num note) (zip [1..] notes) >>= return . vsep @@ -110,18 +113,23 @@ noteToRST num note = do contents <- blockListToRST note let marker = ".. [" <> text (show num) <> "]"- return $ marker $$ nest 3 contents+ return $ nowrap $ marker $$ nest 3 contents -- | Return RST representation of picture reference table.-pictRefsToRST :: Refs -> State WriterState Doc+pictRefsToRST :: [([Inline], (String, String, Maybe String))]+ -> State WriterState Doc pictRefsToRST refs = mapM pictToRST refs >>= return . vcat --- | Return RST representation of a picture substitution reference. -pictToRST :: ([Inline], (String, String)) +-- | Return RST representation of a picture substitution reference.+pictToRST :: ([Inline], (String, String,Maybe String)) -> State WriterState Doc-pictToRST (label, (src, _)) = do+pictToRST (label, (src, _, mbtarget)) = do label' <- inlineListToRST label- return $ ".. |" <> label' <> "| image:: " <> text src+ return $ nowrap+ $ ".. |" <> label' <> "| image:: " <> text src+ $$ case mbtarget of+ Nothing -> empty+ Just t -> " :target: " <> text t -- | Escape special characters for RST. escapeString :: String -> String@@ -135,26 +143,30 @@ let border = text (replicate titleLength '=') return $ border $$ contents $$ border --- | Convert Pandoc block element to RST. +-- | Convert Pandoc block element to RST. blockToRST :: Block -- ^ Block element- -> State WriterState Doc + -> State WriterState Doc blockToRST Null = return empty blockToRST (Plain inlines) = inlineListToRST inlines-blockToRST (Para [Image txt (src,tit)]) = do+-- title beginning with fig: indicates that the image is a figure+blockToRST (Para [Image txt (src,'f':'i':'g':':':tit)]) = do capt <- inlineListToRST txt let fig = "figure:: " <> text src- let align = ":align: center" let alt = ":alt: " <> if null tit then capt else text tit- return $ hang 3 ".. " $ fig $$ align $$ alt $+$ capt $$ blankline-blockToRST (Para inlines) = do- contents <- inlineListToRST inlines- return $ contents <> blankline+ return $ hang 3 ".. " $ fig $$ alt $+$ capt $$ blankline+blockToRST (Para inlines)+ | LineBreak `elem` inlines = do -- use line block if LineBreaks + lns <- mapM inlineListToRST $ splitBy (==LineBreak) inlines+ return $ (vcat $ map (text "| " <>) lns) <> blankline+ | otherwise = do+ contents <- inlineListToRST inlines+ return $ contents <> blankline blockToRST (RawBlock f str) = return $ blankline <> ".. raw:: " <> text f $+$ (nest 3 $ text str) $$ blankline blockToRST HorizontalRule = return $ blankline $$ "--------------" $$ blankline-blockToRST (Header level inlines) = do+blockToRST (Header level _ inlines) = do contents <- inlineListToRST inlines let headerChar = if level > 5 then ' ' else "=-~^'" !! (level - 1) let border = text $ replicate (offset contents) headerChar@@ -163,12 +175,12 @@ opts <- stOptions <$> get let tabstop = writerTabStop opts if "haskell" `elem` classes && "literate" `elem` classes &&- writerLiterateHaskell opts+ isEnabled Ext_literate_haskell opts then return $ prefixed "> " (text str) $$ blankline else return $ "::" $+$ nest tabstop (text str) $$ blankline blockToRST (BlockQuote blocks) = do tabstop <- get >>= (return . writerTabStop . stOptions)- contents <- blockListToRST blocks + contents <- blockListToRST blocks return $ (nest tabstop contents) <> blankline blockToRST (Table caption _ widths headers rows) = do caption' <- inlineListToRST caption@@ -184,7 +196,7 @@ if isSimple then map ((+2) . numChars) $ transpose (headers' : rawRows) else map (floor . (fromIntegral (writerColumns opts) *)) widths- let hpipeBlocks blocks = hcat [beg, middle, end] + let hpipeBlocks blocks = hcat [beg, middle, end] where h = maximum (map height blocks) sep' = lblock 3 $ vcat (map text $ replicate h " | ") beg = lblock 2 $ vcat (map text $ replicate h "| ")@@ -195,7 +207,7 @@ rows' <- mapM (\row -> do cols <- mapM blockListToRST row return $ makeRow cols) rows let border ch = char '+' <> char ch <>- (hcat $ intersperse (char ch <> char '+' <> char ch) $ + (hcat $ intersperse (char ch <> char '+' <> char ch) $ map (\l -> text $ replicate l ch) widthsInChars) <> char ch <> char '+' let body = vcat $ intersperse (border '-') rows'@@ -208,9 +220,9 @@ -- ensure that sublists have preceding blank line return $ blankline $$ vcat contents $$ blankline blockToRST (OrderedList (start, style', delim) items) = do- let markers = if start == 1 && style' == DefaultStyle && delim == DefaultDelim + let markers = if start == 1 && style' == DefaultStyle && delim == DefaultDelim then take (length items) $ repeat "#."- else take (length items) $ orderedListMarkers + else take (length items) $ orderedListMarkers (start, style', delim) let maxMarkerLength = maximum $ map length markers let markers' = map (\m -> let s = maxMarkerLength - length m@@ -249,7 +261,7 @@ -- | Convert list of Pandoc block elements to RST. blockListToRST :: [Block] -- ^ List of block elements- -> State WriterState Doc + -> State WriterState Doc blockListToRST blocks = mapM blockToRST blocks >>= return . vcat -- | Convert list of Pandoc inline elements to RST.@@ -303,19 +315,19 @@ -- | Convert Pandoc inline element to RST. inlineToRST :: Inline -> State WriterState Doc-inlineToRST (Emph lst) = do +inlineToRST (Emph lst) = do contents <- inlineListToRST lst return $ "*" <> contents <> "*" inlineToRST (Strong lst) = do contents <- inlineListToRST lst return $ "**" <> contents <> "**"-inlineToRST (Strikeout lst) = do +inlineToRST (Strikeout lst) = do contents <- inlineListToRST lst return $ "[STRIKEOUT:" <> contents <> "]"-inlineToRST (Superscript lst) = do +inlineToRST (Superscript lst) = do contents <- inlineListToRST lst return $ ":sup:`" <> contents <> "`"-inlineToRST (Subscript lst) = do +inlineToRST (Subscript lst) = do contents <- inlineListToRST lst return $ ":sub:`" <> contents <> "`" inlineToRST (SmallCaps lst) = inlineListToRST lst@@ -339,39 +351,53 @@ else blankline $$ (".. math:: " <> text str) $$ blankline inlineToRST (RawInline "rst" x) = return $ text x inlineToRST (RawInline _ _) = return empty-inlineToRST (LineBreak) = return cr -- there's no line break in RST+inlineToRST (LineBreak) = return cr -- there's no line break in RST (see Para) inlineToRST Space = return space-inlineToRST (Link [Code _ str] (src, _)) | src == str ||- src == "mailto:" ++ str = do+-- autolink+inlineToRST (Link [Str str] (src, _))+ | if "mailto:" `isPrefixOf` src+ then src == escapeURI ("mailto:" ++ str)+ else src == escapeURI str = do let srcSuffix = if isPrefixOf "mailto:" src then drop 7 src else src return $ text srcSuffix+inlineToRST (Link [Image alt (imgsrc,imgtit)] (src, _tit)) = do+ label <- registerImage alt (imgsrc,imgtit) (Just src)+ return $ "|" <> label <> "|" inlineToRST (Link txt (src, tit)) = do useReferenceLinks <- get >>= return . writerReferenceLinks . stOptions linktext <- inlineListToRST $ normalizeSpaces txt if useReferenceLinks then do refs <- get >>= return . stLinks- let refs' = if (txt, (src, tit)) `elem` refs- then refs- else (txt, (src, tit)):refs- modify $ \st -> st { stLinks = refs' }- return $ "`" <> linktext <> "`_"- else return $ "`" <> linktext <> " <" <> text src <> ">`_"+ case lookup txt refs of+ Just (src',tit') ->+ if src == src' && tit == tit'+ then return $ "`" <> linktext <> "`_"+ else do -- duplicate label, use non-reference link+ return $ "`" <> linktext <> " <" <> text src <> ">`__"+ Nothing -> do+ modify $ \st -> st { stLinks = (txt,(src,tit)):refs }+ return $ "`" <> linktext <> "`_"+ else return $ "`" <> linktext <> " <" <> text src <> ">`__" inlineToRST (Image alternate (source, tit)) = do- pics <- get >>= return . stImages- let labelsUsed = map fst pics - let txt = if null alternate || alternate == [Str ""] ||- alternate `elem` labelsUsed- then [Str $ "image" ++ show (length pics)]- else alternate- let pics' = if (txt, (source, tit)) `elem` pics- then pics- else (txt, (source, tit)):pics- modify $ \st -> st { stImages = pics' }- label <- inlineListToRST txt+ label <- registerImage alternate (source,tit) Nothing return $ "|" <> label <> "|"-inlineToRST (Note contents) = do +inlineToRST (Note contents) = do -- add to notes in state notes <- get >>= return . stNotes modify $ \st -> st { stNotes = contents:notes } let ref = show $ (length notes) + 1 return $ " [" <> text ref <> "]_"++registerImage :: [Inline] -> Target -> Maybe String -> State WriterState Doc+registerImage alt (src,tit) mbtarget = do+ pics <- get >>= return . stImages+ txt <- case lookup alt pics of+ Just (s,t,mbt) | (s,t,mbt) == (src,tit,mbtarget) -> return alt+ _ -> do+ let alt' = if null alt || alt == [Str ""]+ then [Str $ "image" ++ show (length pics)]+ else alt+ modify $ \st -> st { stImages =+ (alt', (src,tit, mbtarget)):stImages st }+ return alt'+ inlineListToRST txt
@@ -19,27 +19,28 @@ {- | Module : Text.Pandoc.Writers.RTF Copyright : Copyright (C) 2006-2010 John MacFarlane- License : GNU GPL, version 2 or above + License : GNU GPL, version 2 or above Maintainer : John MacFarlane <jgm@berkeley.edu>- Stability : alpha + Stability : alpha Portability : portable Conversion of 'Pandoc' documents to RTF (rich text format). -}-{-# LANGUAGE ScopedTypeVariables #-}-module Text.Pandoc.Writers.RTF ( writeRTF, rtfEmbedImage ) where+module Text.Pandoc.Writers.RTF ( writeRTF, writeRTFWithEmbeddedImages ) where import Text.Pandoc.Definition+import Text.Pandoc.Options import Text.Pandoc.Shared import Text.Pandoc.Readers.TeXMath import Text.Pandoc.Templates (renderTemplate)+import Text.Pandoc.Generic (bottomUpM) import Data.List ( isSuffixOf, intercalate ) import Data.Char ( ord, isDigit, toLower ) import System.FilePath ( takeExtension ) import qualified Data.ByteString as B import Text.Printf ( printf ) import Network.URI ( isAbsoluteURI, unEscapeString )-import qualified Control.Exception as E (catch, IOException)+import qualified Control.Exception as E -- | Convert Image inlines into a raw RTF embedded image, read from a file. -- If file not found or filetype not jpeg or png, leave the inline unchanged.@@ -49,7 +50,8 @@ if ext `elem` [".jpg",".jpeg",".png"] && not (isAbsoluteURI src) then do let src' = unEscapeString src- imgdata <- E.catch (B.readFile src') (\(_::E.IOException) -> return B.empty)+ imgdata <- E.catch (B.readFile src')+ (\e -> let _ = (e :: E.SomeException) in return B.empty) let bytes = map (printf "%02x") $ B.unpack imgdata let filetype = case ext of ".jpg" -> "\\jpegblip"@@ -63,32 +65,40 @@ else return x rtfEmbedImage x = return x +-- | Convert Pandoc to a string in rich text format, with+-- images embedded as encoded binary data.+writeRTFWithEmbeddedImages :: WriterOptions -> Pandoc -> IO String+writeRTFWithEmbeddedImages options doc =+ writeRTF options `fmap` bottomUpM rtfEmbedImage doc+ -- | Convert Pandoc to a string in rich text format. writeRTF :: WriterOptions -> Pandoc -> String-writeRTF options (Pandoc (Meta title authors date) blocks) = +writeRTF options (Pandoc (Meta title authors date) blocks) = let titletext = inlineListToRTF title authorstext = map inlineListToRTF authors datetext = inlineListToRTF date spacer = not $ all null $ titletext : datetext : authorstext body = concatMap (blockToRTF 0 AlignDefault) blocks+ isTOCHeader (Header lev _ _) = lev <= writerTOCDepth options+ isTOCHeader _ = False context = writerVariables options ++ [ ("body", body) , ("title", titletext) , ("date", datetext) ] ++ [ ("author", a) | a <- authorstext ] ++ [ ("spacer", "yes") | spacer ] ++- [ ("toc", tableOfContents $ filter isHeaderBlock blocks) |+ [ ("toc", tableOfContents $ filter isTOCHeader blocks) | writerTableOfContents options ] in if writerStandalone options then renderTemplate context $ writerTemplate options else body -- | Construct table of contents from list of header blocks.-tableOfContents :: [Block] -> String +tableOfContents :: [Block] -> String tableOfContents headers = let contentsTree = hierarchicalize headers- in concatMap (blockToRTF 0 AlignDefault) $ - [Header 1 [Str "Contents"], + in concatMap (blockToRTF 0 AlignDefault) $+ [Header 1 nullAttr [Str "Contents"], BulletList (map elementToListItem contentsTree)] elementToListItem :: Element -> [Block]@@ -102,7 +112,7 @@ handleUnicode :: String -> String handleUnicode [] = [] handleUnicode (c:cs) =- if ord c > 127 + if ord c > 127 then '\\':'u':(show (ord c)) ++ "?" ++ handleUnicode cs else c:(handleUnicode cs) @@ -132,32 +142,32 @@ -> Int -- ^ first line indent (relative to block) (in twips) -> Alignment -- ^ alignment -> String -- ^ string with content- -> String -rtfParSpaced spaceAfter indent firstLineIndent alignment content = + -> String+rtfParSpaced spaceAfter indent firstLineIndent alignment content = let alignString = case alignment of AlignLeft -> "\\ql " AlignRight -> "\\qr " AlignCenter -> "\\qc " AlignDefault -> "\\ql " in "{\\pard " ++ alignString ++- "\\f0 \\sa" ++ (show spaceAfter) ++ " \\li" ++ (show indent) ++ + "\\f0 \\sa" ++ (show spaceAfter) ++ " \\li" ++ (show indent) ++ " \\fi" ++ (show firstLineIndent) ++ " " ++ content ++ "\\par}\n" --- | Default paragraph. +-- | Default paragraph. rtfPar :: Int -- ^ block indent (in twips) -> Int -- ^ first line indent (relative to block) (in twips) -> Alignment -- ^ alignment -> String -- ^ string with content- -> String -rtfPar = rtfParSpaced 180 + -> String+rtfPar = rtfParSpaced 180 -- | Compact paragraph (e.g. for compact list items). rtfCompact :: Int -- ^ block indent (in twips) -> Int -- ^ first line indent (relative to block) (in twips) -> Alignment -- ^ alignment -> String -- ^ string with content- -> String -rtfCompact = rtfParSpaced 0 + -> String+rtfCompact = rtfParSpaced 0 -- number of twips to indent indentIncrement :: Int@@ -174,7 +184,7 @@ -- | Returns appropriate (list of) ordered list markers for indent level. orderedMarkers :: Int -> ListAttributes -> [String]-orderedMarkers indent (start, style, delim) = +orderedMarkers indent (start, style, delim) = if style == DefaultStyle && delim == DefaultDelim then case indent `mod` 720 of 0 -> orderedListMarkers (start, Decimal, Period)@@ -187,30 +197,30 @@ -> Block -- ^ block to convert -> String blockToRTF _ _ Null = ""-blockToRTF indent alignment (Plain lst) = +blockToRTF indent alignment (Plain lst) = rtfCompact indent 0 alignment $ inlineListToRTF lst-blockToRTF indent alignment (Para lst) = +blockToRTF indent alignment (Para lst) = rtfPar indent 0 alignment $ inlineListToRTF lst-blockToRTF indent alignment (BlockQuote lst) = - concatMap (blockToRTF (indent + indentIncrement) alignment) lst +blockToRTF indent alignment (BlockQuote lst) =+ concatMap (blockToRTF (indent + indentIncrement) alignment) lst blockToRTF indent _ (CodeBlock _ str) = rtfPar indent 0 AlignLeft ("\\f1 " ++ (codeStringToRTF str)) blockToRTF _ _ (RawBlock "rtf" str) = str blockToRTF _ _ (RawBlock _ _) = ""-blockToRTF indent alignment (BulletList lst) = spaceAtEnd $ +blockToRTF indent alignment (BulletList lst) = spaceAtEnd $ concatMap (listItemToRTF alignment indent (bulletMarker indent)) lst-blockToRTF indent alignment (OrderedList attribs lst) = spaceAtEnd $ concat $ +blockToRTF indent alignment (OrderedList attribs lst) = spaceAtEnd $ concat $ zipWith (listItemToRTF alignment indent) (orderedMarkers indent attribs) lst-blockToRTF indent alignment (DefinitionList lst) = spaceAtEnd $ +blockToRTF indent alignment (DefinitionList lst) = spaceAtEnd $ concatMap (definitionListItemToRTF alignment indent) lst-blockToRTF indent _ HorizontalRule = +blockToRTF indent _ HorizontalRule = rtfPar indent 0 AlignCenter "\\emdash\\emdash\\emdash\\emdash\\emdash"-blockToRTF indent alignment (Header level lst) = rtfPar indent 0 alignment $+blockToRTF indent alignment (Header level _ lst) = rtfPar indent 0 alignment $ "\\b \\fs" ++ (show (40 - (level * 4))) ++ " " ++ inlineListToRTF lst-blockToRTF indent alignment (Table caption aligns sizes headers rows) = +blockToRTF indent alignment (Table caption aligns sizes headers rows) = (if all null headers then ""- else tableRowToRTF True indent aligns sizes headers) ++ + else tableRowToRTF True indent aligns sizes headers) ++ concatMap (tableRowToRTF False indent aligns sizes) rows ++ rtfPar indent 0 alignment (inlineListToRTF caption) @@ -232,7 +242,7 @@ end = "}\n\\intbl\\row}\n" in start ++ columns ++ end -tableItemToRTF :: Int -> Alignment -> [Block] -> String +tableItemToRTF :: Int -> Alignment -> [Block] -> String tableItemToRTF indent alignment item = let contents = concatMap (blockToRTF indent alignment) item in "{\\intbl " ++ contents ++ "\\cell}\n"@@ -240,7 +250,7 @@ -- | Ensure that there's the same amount of space after compact -- lists as after regular lists. spaceAtEnd :: String -> String-spaceAtEnd str = +spaceAtEnd str = if isSuffixOf "\\par}\n" str then (take ((length str) - 6) str) ++ "\\sa180\\par}\n" else str@@ -251,10 +261,10 @@ -> String -- ^ list start marker -> [Block] -- ^ list item (list of blocks) -> [Char]-listItemToRTF alignment indent marker [] = - rtfCompact (indent + listIncrement) (0 - listIncrement) alignment - (marker ++ "\\tx" ++ (show listIncrement) ++ "\\tab ") -listItemToRTF alignment indent marker list = +listItemToRTF alignment indent marker [] =+ rtfCompact (indent + listIncrement) (0 - listIncrement) alignment+ (marker ++ "\\tx" ++ (show listIncrement) ++ "\\tab ")+listItemToRTF alignment indent marker list = let (first:rest) = map (blockToRTF (indent + listIncrement) alignment) list listMarker = "\\fi" ++ show (0 - listIncrement) ++ " " ++ marker ++ "\\tx" ++ show listIncrement ++ "\\tab"@@ -277,7 +287,7 @@ let labelText = blockToRTF indent alignment (Plain label) itemsText = concatMap (blockToRTF (indent + listIncrement) alignment) $ concat defs- in labelText ++ itemsText + in labelText ++ itemsText -- | Convert list of inline items to RTF. inlineListToRTF :: [Inline] -- ^ list of inlines to convert@@ -293,9 +303,9 @@ inlineToRTF (Superscript lst) = "{\\super " ++ (inlineListToRTF lst) ++ "}" inlineToRTF (Subscript lst) = "{\\sub " ++ (inlineListToRTF lst) ++ "}" inlineToRTF (SmallCaps lst) = "{\\scaps " ++ (inlineListToRTF lst) ++ "}"-inlineToRTF (Quoted SingleQuote lst) = +inlineToRTF (Quoted SingleQuote lst) = "\\u8216'" ++ (inlineListToRTF lst) ++ "\\u8217'"-inlineToRTF (Quoted DoubleQuote lst) = +inlineToRTF (Quoted DoubleQuote lst) = "\\u8220\"" ++ (inlineListToRTF lst) ++ "\\u8221\"" inlineToRTF (Code _ str) = "{\\f1 " ++ (codeStringToRTF str) ++ "}" inlineToRTF (Str str) = stringToRTF str@@ -305,11 +315,11 @@ inlineToRTF (RawInline _ _) = "" inlineToRTF (LineBreak) = "\\line " inlineToRTF Space = " "-inlineToRTF (Link text (src, _)) = - "{\\field{\\*\\fldinst{HYPERLINK \"" ++ (codeStringToRTF src) ++ +inlineToRTF (Link text (src, _)) =+ "{\\field{\\*\\fldinst{HYPERLINK \"" ++ (codeStringToRTF src) ++ "\"}}{\\fldrslt{\\ul\n" ++ (inlineListToRTF text) ++ "\n}}}\n"-inlineToRTF (Image _ (source, _)) = - "{\\cf1 [image: " ++ source ++ "]\\cf0}" +inlineToRTF (Image _ (source, _)) =+ "{\\cf1 [image: " ++ source ++ "]\\cf0}" inlineToRTF (Note contents) =- "{\\super\\chftn}{\\*\\footnote\\chftn\\~\\plain\\pard " ++ + "{\\super\\chftn}{\\*\\footnote\\chftn\\~\\plain\\pard " ++ (concatMap (blockToRTF 0 AlignDefault) contents) ++ "}"
@@ -19,16 +19,17 @@ {- | Module : Text.Pandoc.Writers.Texinfo Copyright : Copyright (C) 2008-2010 John MacFarlane and Peter Wang- License : GNU GPL, version 2 or above + License : GNU GPL, version 2 or above Maintainer : John MacFarlane <jgm@berkeley.edu>- Stability : alpha + Stability : alpha Portability : portable Conversion of 'Pandoc' format into Texinfo. -} module Text.Pandoc.Writers.Texinfo ( writeTexinfo ) where import Text.Pandoc.Definition+import Text.Pandoc.Options import Text.Pandoc.Shared import Text.Pandoc.Templates (renderTemplate) import Text.Printf ( printf )@@ -40,10 +41,12 @@ import Network.URI ( isAbsoluteURI, unEscapeString ) import System.FilePath -data WriterState = +data WriterState = WriterState { stStrikeout :: Bool -- document contains strikeout , stSuperscript :: Bool -- document contains superscript , stSubscript :: Bool -- document contains subscript+ , stEscapeComma :: Bool -- in a context where we need @comma+ , stIdentifiers :: [String] -- header ids used already } {- TODO:@@ -53,14 +56,15 @@ -- | Convert Pandoc to Texinfo. writeTexinfo :: WriterOptions -> Pandoc -> String-writeTexinfo options document = - evalState (pandocToTexinfo options $ wrapTop document) $ - WriterState { stStrikeout = False, stSuperscript = False, stSubscript = False }+writeTexinfo options document =+ evalState (pandocToTexinfo options $ wrapTop document) $+ WriterState { stStrikeout = False, stSuperscript = False,+ stEscapeComma = False, stSubscript = False, stIdentifiers = [] } -- | Add a "Top" node around the document, needed by Texinfo. wrapTop :: Pandoc -> Pandoc wrapTop (Pandoc (Meta title authors date) blocks) =- Pandoc (Meta title authors date) (Header 0 title : blocks)+ Pandoc (Meta title authors date) (Header 0 nullAttr title : blocks) pandocToTexinfo :: WriterOptions -> Pandoc -> State WriterState String pandocToTexinfo options (Pandoc (Meta title authors date) blocks) = do@@ -94,7 +98,6 @@ where texinfoEscapes = [ ('{', "@{") , ('}', "@}") , ('@', "@@")- , (',', "@comma{}") -- only needed in argument lists , ('\160', "@ ") , ('\x2014', "---") , ('\x2013', "--")@@ -102,6 +105,14 @@ , ('\x2019', "'") ] +escapeCommas :: State WriterState Doc -> State WriterState Doc+escapeCommas parser = do+ oldEscapeComma <- gets stEscapeComma+ modify $ \st -> st{ stEscapeComma = True }+ res <- parser+ modify $ \st -> st{ stEscapeComma = oldEscapeComma }+ return res+ -- | Puts contents into Texinfo command. inCmd :: String -> Doc -> Doc inCmd cmd contents = char '@' <> text cmd <> braces contents@@ -115,11 +126,14 @@ blockToTexinfo (Plain lst) = inlineListToTexinfo lst -blockToTexinfo (Para [Image txt (src,tit)]) = do- capt <- inlineListToTexinfo txt+-- title beginning with fig: indicates that the image is a figure+blockToTexinfo (Para [Image txt (src,'f':'i':'g':':':tit)]) = do+ capt <- if null txt+ then return empty+ else (\c -> text "@caption" <> braces c) `fmap`+ inlineListToTexinfo txt img <- inlineToTexinfo (Image txt (src,tit))- return $ text "@float" $$ img $$ (text "@caption{" <> capt <> char '}') $$- text "@end float"+ return $ text "@float" $$ img $$ capt $$ text "@end float" blockToTexinfo (Para lst) = inlineListToTexinfo lst -- this is handled differently from Plain in blockListToTexinfo@@ -131,7 +145,8 @@ text "@end quotation" blockToTexinfo (CodeBlock _ str) = do- return $ text "@verbatim" $$+ return $ blankline $$+ text "@verbatim" $$ flush (text str) $$ text "@end verbatim" <> blankline @@ -181,19 +196,23 @@ text (take 72 $ repeat '-') $$ text "@end ifnottex" -blockToTexinfo (Header 0 lst) = do+blockToTexinfo (Header 0 _ lst) = do txt <- if null lst then return $ text "Top" else inlineListToTexinfo lst return $ text "@node Top" $$ text "@top " <> txt <> blankline -blockToTexinfo (Header level lst) = do+blockToTexinfo (Header level _ lst) = do node <- inlineListForNode lst txt <- inlineListToTexinfo lst+ idsUsed <- gets stIdentifiers+ let id' = uniqueIdent lst idsUsed+ modify $ \st -> st{ stIdentifiers = id' : idsUsed } return $ if (level > 0) && (level <= 4)- then blankline <> text "@node " <> node <> cr <>- text (seccmd level) <> txt+ then blankline <> text "@node " <> node $$+ text (seccmd level) <> txt $$+ text "@anchor" <> braces (text $ '#':id') else txt where seccmd 1 = "@chapter "@@ -217,7 +236,7 @@ else return $ "@columnfractions " ++ concatMap (printf "%.2f ") widths let tableBody = text ("@multitable " ++ colDescriptors) $$ headers $$- vcat rowsText $$ + vcat rowsText $$ text "@end multitable" return $ if isEmpty captionText then tableBody <> blankline@@ -241,7 +260,7 @@ -> [[Block]] -> State WriterState Doc tableAnyRowToTexinfo itemtype aligns cols =- zipWithM alignedBlock aligns cols >>= + zipWithM alignedBlock aligns cols >>= return . (text itemtype $$) . foldl (\row item -> row $$ (if isEmpty row then empty else text " @tab ") <> item) empty @@ -268,7 +287,7 @@ blockListToTexinfo (x:xs) = do x' <- blockToTexinfo x case x of- Header level _ -> do+ Header level _ _ -> do -- We need need to insert a menu for this node. let (before, after) = break isHeader xs before' <- blockListToTexinfo before@@ -293,14 +312,14 @@ return $ x' $$ xs' isHeader :: Block -> Bool-isHeader (Header _ _) = True-isHeader _ = False+isHeader (Header _ _ _) = True+isHeader _ = False collectNodes :: Int -> [Block] -> [Block] collectNodes _ [] = [] collectNodes level (x:xs) = case x of- (Header hl _) ->+ (Header hl _ _) -> if hl < level then [] else if hl == level@@ -311,7 +330,7 @@ makeMenuLine :: Block -> State WriterState Doc-makeMenuLine (Header _ lst) = do+makeMenuLine (Header _ _ lst) = do txt <- inlineListForNode lst return $ text "* " <> txt <> text "::" makeMenuLine _ = error "makeMenuLine called with non-Header block"@@ -358,8 +377,8 @@ inlineToTexinfo (Emph lst) = inlineListToTexinfo lst >>= return . inCmd "emph" -inlineToTexinfo (Strong lst) = - inlineListToTexinfo lst >>= return . inCmd "strong" +inlineToTexinfo (Strong lst) =+ inlineListToTexinfo lst >>= return . inCmd "strong" inlineToTexinfo (Strikeout lst) = do modify $ \st -> st{ stStrikeout = True }@@ -401,17 +420,21 @@ inlineToTexinfo (LineBreak) = return $ text "@*" inlineToTexinfo Space = return $ char ' ' +inlineToTexinfo (Link txt (src@('#':_), _)) = do+ contents <- escapeCommas $ inlineListToTexinfo txt+ return $ text "@ref" <>+ braces (text (stringToTexinfo src) <> text "," <> contents) inlineToTexinfo (Link txt (src, _)) = do case txt of- [Code _ x] | x == src -> -- autolink+ [Str x] | escapeURI x == src -> -- autolink do return $ text $ "@url{" ++ x ++ "}"- _ -> do contents <- inlineListToTexinfo txt+ _ -> do contents <- escapeCommas $ inlineListToTexinfo txt let src1 = stringToTexinfo src return $ text ("@uref{" ++ src1 ++ ",") <> contents <> char '}' inlineToTexinfo (Image alternate (source, _)) = do- content <- inlineListToTexinfo alternate+ content <- escapeCommas $ inlineListToTexinfo alternate return $ text ("@image{" ++ base ++ ",,,") <> content <> text "," <> text (ext ++ "}") where
@@ -19,7 +19,7 @@ {- | Module : Text.Pandoc.Writers.Textile Copyright : Copyright (C) 2010 John MacFarlane- License : GNU GPL, version 2 or above + License : GNU GPL, version 2 or above Maintainer : John MacFarlane <jgm@berkeley.edu> Stability : alpha@@ -31,7 +31,8 @@ -} module Text.Pandoc.Writers.Textile ( writeTextile ) where import Text.Pandoc.Definition-import Text.Pandoc.Shared +import Text.Pandoc.Options+import Text.Pandoc.Shared import Text.Pandoc.Templates (renderTemplate) import Text.Pandoc.XML ( escapeStringForXML ) import Data.List ( intercalate )@@ -46,9 +47,9 @@ -- | Convert Pandoc to Textile. writeTextile :: WriterOptions -> Pandoc -> String-writeTextile opts document = - evalState (pandocToTextile opts document) - (WriterState { stNotes = [], stListLevel = [], stUseTags = False }) +writeTextile opts document =+ evalState (pandocToTextile opts document)+ (WriterState { stNotes = [], stListLevel = [], stUseTags = False }) -- | Return Textile representation of document. pandocToTextile :: WriterOptions -> Pandoc -> State WriterState String@@ -90,17 +91,18 @@ escapeStringForTextile :: String -> String escapeStringForTextile = concatMap escapeCharForTextile --- | Convert Pandoc block element to Textile. +-- | Convert Pandoc block element to Textile. blockToTextile :: WriterOptions -- ^ Options -> Block -- ^ Block element- -> State WriterState String + -> State WriterState String blockToTextile _ Null = return "" -blockToTextile opts (Plain inlines) = +blockToTextile opts (Plain inlines) = inlineListToTextile opts inlines -blockToTextile opts (Para [Image txt (src,tit)]) = do+-- title beginning with fig: indicates that the image is a figure+blockToTextile opts (Para [Image txt (src,'f':'i':'g':':':tit)]) = do capt <- blockToTextile opts (Para txt) im <- inlineToTextile opts (Image txt (src,tit)) return $ im ++ "\n" ++ capt@@ -120,9 +122,10 @@ blockToTextile _ HorizontalRule = return "<hr />\n" -blockToTextile opts (Header level inlines) = do+blockToTextile opts (Header level (ident,_,_) inlines) = do contents <- inlineListToTextile opts inlines- let prefix = 'h' : (show level ++ ". ")+ let attribs = if null ident then "" else "(#" ++ ident ++ ")"+ let prefix = 'h' : show level ++ attribs ++ ". " return $ prefix ++ contents ++ "\n" blockToTextile _ (CodeBlock (_,classes,_) str) | any (all isSpace) (lines str) =@@ -236,7 +239,7 @@ -- | Convert definition list item (label, list of blocks) to Textile. definitionListItemToTextile :: WriterOptions- -> ([Inline],[[Block]]) + -> ([Inline],[[Block]]) -> State WriterState String definitionListItemToTextile opts (label, items) = do labelText <- inlineListToTextile opts label@@ -294,8 +297,8 @@ 0 -> "header" x | x `rem` 2 == 1 -> "odd" _ -> "even"- cols'' <- sequence $ zipWith - (\alignment item -> tableItemToTextile opts celltype alignment item) + cols'' <- sequence $ zipWith+ (\alignment item -> tableItemToTextile opts celltype alignment item) alignStrings cols' return $ "<tr class=\"" ++ rowclass ++ "\">\n" ++ unlines cols'' ++ "</tr>" @@ -320,7 +323,7 @@ -- | Convert list of Pandoc block elements to Textile. blockListToTextile :: WriterOptions -- ^ Options -> [Block] -- ^ List of block elements- -> State WriterState String + -> State WriterState String blockListToTextile opts blocks = mapM (blockToTextile opts) blocks >>= return . vcat @@ -332,11 +335,11 @@ -- | Convert Pandoc inline element to Textile. inlineToTextile :: WriterOptions -> Inline -> State WriterState String -inlineToTextile opts (Emph lst) = do +inlineToTextile opts (Emph lst) = do contents <- inlineListToTextile opts lst return $ if '_' `elem` contents then "<em>" ++ contents ++ "</em>"- else "_" ++ contents ++ "_" + else "_" ++ contents ++ "_" inlineToTextile opts (Strong lst) = do contents <- inlineListToTextile opts lst@@ -377,7 +380,7 @@ inlineToTextile _ (Code _ str) = return $ if '@' `elem` str then "<tt>" ++ escapeStringForXML str ++ "</tt>"- else "@" ++ str ++ "@" + else "@" ++ str ++ "@" inlineToTextile _ (Str str) = return $ escapeStringForTextile str @@ -395,7 +398,10 @@ inlineToTextile opts (Link txt (src, _)) = do label <- case txt of- [Code _ s] -> return s+ [Code _ s]+ | s == src -> return "$"+ [Str s]+ | s == src -> return "$" _ -> inlineListToTextile opts txt return $ "\"" ++ label ++ "\":" ++ src
@@ -1,1075 +0,0 @@-{-# LANGUAGE CPP #-}-{--Copyright (C) 2006-2012 John MacFarlane <jgm@berkeley.edu>--This program is free software; you can redistribute it and/or modify-it under the terms of the GNU General Public License as published by-the Free Software Foundation; either version 2 of the License, or-(at your option) any later version.--This program is distributed in the hope that it will be useful,-but WITHOUT ANY WARRANTY; without even the implied warranty of-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-GNU General Public License for more details.--You should have received a copy of the GNU General Public License-along with this program; if not, write to the Free Software-Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA--}--{- |- Module : Main- Copyright : Copyright (C) 2006-2012 John MacFarlane- License : GNU GPL, version 2 or above-- Maintainer : John MacFarlane <jgm@berkeley@edu>- Stability : alpha- Portability : portable--Parses command-line options and calls the appropriate readers and-writers.--}-{-# LANGUAGE ScopedTypeVariables #-}-module Main where-import Text.Pandoc-import Text.Pandoc.PDF (tex2pdf)-import Text.Pandoc.Readers.LaTeX (handleIncludes)-import Text.Pandoc.Shared ( tabFilter, ObfuscationMethod (..), readDataFile,- headerShift, findDataFile, normalize, err, warn )-import Text.Pandoc.XML ( toEntities, fromEntities )-import Text.Pandoc.SelfContained ( makeSelfContained )-import Text.Pandoc.Highlighting ( languages, Style, tango, pygments,- espresso, zenburn, kate, haddock, monochrome )-import System.Environment ( getArgs, getProgName )-import System.Exit ( exitWith, ExitCode (..) )-import System.FilePath-import System.Console.GetOpt-import Data.Char ( toLower )-import Data.List ( intercalate, isSuffixOf, isPrefixOf )-import System.Directory ( getAppUserDataDirectory, doesFileExist, findExecutable )-import System.IO ( stdout )-import System.IO.Error ( isDoesNotExistError )-import Control.Exception.Extensible ( throwIO )-import qualified Text.Pandoc.UTF8 as UTF8-import qualified Text.CSL as CSL-import Text.Pandoc.Biblio-import Control.Monad (when, unless, liftM)-import Network.HTTP (simpleHTTP, mkRequest, getResponseBody, RequestMethod(..))-import Network.URI (parseURI, isURI, URI(..))-import qualified Data.ByteString.Lazy as B-import Data.ByteString.Lazy.UTF8 (toString )-import Text.CSL.Reference (Reference(..))-#if MIN_VERSION_base(4,4,0)-#else-import Codec.Binary.UTF8.String (decodeString, encodeString)-#endif-import qualified Control.Exception as E (catch, IOException)--encodePath, decodeArg :: FilePath -> FilePath-#if MIN_VERSION_base(4,4,0)-encodePath = id-decodeArg = id-#else-encodePath = encodeString-decodeArg = decodeString-#endif---copyrightMessage :: String-copyrightMessage = "\nCopyright (C) 2006-2012 John MacFarlane\n" ++- "Web: http://johnmacfarlane.net/pandoc\n" ++- "This is free software; see the source for copying conditions. There is no\n" ++- "warranty, not even for merchantability or fitness for a particular purpose."--compileInfo :: String-compileInfo =- "\nCompiled with citeproc-hs " ++ VERSION_citeproc_hs ++ ", texmath " ++- VERSION_texmath ++ ", highlighting-kate " ++ VERSION_highlighting_kate ++- ".\nSyntax highlighting is supported for the following languages:\n " ++- wrapWords 4 78 languages---- | Converts a list of strings into a single string with the items printed as--- comma separated words in lines with a maximum line length.-wrapWords :: Int -> Int -> [String] -> String-wrapWords indent c = wrap' (c - indent) (c - indent)- where wrap' _ _ [] = ""- wrap' cols remaining (x:xs) = if remaining == cols- then x ++ wrap' cols (remaining - length x) xs- else if (length x + 1) > remaining- then ",\n" ++ replicate indent ' ' ++ x ++ wrap' cols (cols - length x) xs- else ", " ++ x ++ wrap' cols (remaining - (length x + 2)) xs--nonTextFormats :: [String]-nonTextFormats = ["odt","docx","epub"]---- | Data structure for command line options.-data Opt = Opt- { optTabStop :: Int -- ^ Number of spaces per tab- , optPreserveTabs :: Bool -- ^ Preserve tabs instead of converting to spaces- , optStandalone :: Bool -- ^ Include header, footer- , optReader :: String -- ^ Reader format- , optWriter :: String -- ^ Writer format- , optParseRaw :: Bool -- ^ Parse unconvertable HTML and TeX- , optTableOfContents :: Bool -- ^ Include table of contents- , optTransforms :: [Pandoc -> Pandoc] -- ^ Doc transforms to apply- , optTemplate :: Maybe FilePath -- ^ Custom template- , optVariables :: [(String,String)] -- ^ Template variables to set- , optOutputFile :: String -- ^ Name of output file- , optNumberSections :: Bool -- ^ Number sections in LaTeX- , optSectionDivs :: Bool -- ^ Put sections in div tags in HTML- , optIncremental :: Bool -- ^ Use incremental lists in Slidy/Slideous/S5- , optSelfContained :: Bool -- ^ Make HTML accessible offline- , optSmart :: Bool -- ^ Use smart typography- , optOldDashes :: Bool -- ^ Parse dashes like pandoc <=1.8.2.1- , optHtml5 :: Bool -- ^ Produce HTML5 in HTML- , optHighlight :: Bool -- ^ Highlight source code- , optHighlightStyle :: Style -- ^ Style to use for highlighted code- , optChapters :: Bool -- ^ Use chapter for top-level sects- , optHTMLMathMethod :: HTMLMathMethod -- ^ Method to print HTML math- , optReferenceODT :: Maybe FilePath -- ^ Path of reference.odt- , optReferenceDocx :: Maybe FilePath -- ^ Path of reference.docx- , optEPUBStylesheet :: Maybe String -- ^ EPUB stylesheet- , optEPUBMetadata :: String -- ^ EPUB metadata- , optEPUBFonts :: [FilePath] -- ^ EPUB fonts to embed- , optDumpArgs :: Bool -- ^ Output command-line arguments- , optIgnoreArgs :: Bool -- ^ Ignore command-line arguments- , optStrict :: Bool -- ^ Use strict markdown syntax- , optReferenceLinks :: Bool -- ^ Use reference links in writing markdown, rst- , optWrapText :: Bool -- ^ Wrap text- , optColumns :: Int -- ^ Line length in characters- , optPlugins :: [Pandoc -> IO Pandoc] -- ^ Plugins to apply- , optEmailObfuscation :: ObfuscationMethod- , optIdentifierPrefix :: String- , optIndentedCodeClasses :: [String] -- ^ Default classes for indented code blocks- , optDataDir :: Maybe FilePath- , optCiteMethod :: CiteMethod -- ^ Method to output cites- , optBibliography :: [String]- , optCslFile :: FilePath- , optAbbrevsFile :: Maybe FilePath- , optListings :: Bool -- ^ Use listings package for code blocks- , optLaTeXEngine :: String -- ^ Program to use for latex -> pdf- , optSlideLevel :: Maybe Int -- ^ Header level that creates slides- , optSetextHeaders :: Bool -- ^ Use atx headers for markdown level 1-2- , optAscii :: Bool -- ^ Use ascii characters only in html- , optTeXLigatures :: Bool -- ^ Use TeX ligatures for quotes/dashes- }---- | Defaults for command-line options.-defaultOpts :: Opt-defaultOpts = Opt- { optTabStop = 4- , optPreserveTabs = False- , optStandalone = False- , optReader = "" -- null for default reader- , optWriter = "" -- null for default writer- , optParseRaw = False- , optTableOfContents = False- , optTransforms = []- , optTemplate = Nothing- , optVariables = []- , optOutputFile = "-" -- "-" means stdout- , optNumberSections = False- , optSectionDivs = False- , optIncremental = False- , optSelfContained = False- , optSmart = False- , optOldDashes = False- , optHtml5 = False- , optHighlight = True- , optHighlightStyle = pygments- , optChapters = False- , optHTMLMathMethod = PlainMath- , optReferenceODT = Nothing- , optReferenceDocx = Nothing- , optEPUBStylesheet = Nothing- , optEPUBMetadata = ""- , optEPUBFonts = []- , optDumpArgs = False- , optIgnoreArgs = False- , optStrict = False- , optReferenceLinks = False- , optWrapText = True- , optColumns = 72- , optPlugins = []- , optEmailObfuscation = JavascriptObfuscation- , optIdentifierPrefix = ""- , optIndentedCodeClasses = []- , optDataDir = Nothing- , optCiteMethod = Citeproc- , optBibliography = []- , optCslFile = ""- , optAbbrevsFile = Nothing- , optListings = False- , optLaTeXEngine = "pdflatex"- , optSlideLevel = Nothing- , optSetextHeaders = True- , optAscii = False- , optTeXLigatures = True- }---- | A list of functions, each transforming the options data structure--- in response to a command-line option.-options :: [OptDescr (Opt -> IO Opt)]-options =- [ Option "fr" ["from","read"]- (ReqArg- (\arg opt -> return opt { optReader = map toLower arg })- "FORMAT")- ""-- , Option "tw" ["to","write"]- (ReqArg- (\arg opt -> return opt { optWriter = map toLower arg })- "FORMAT")- ""-- , Option "o" ["output"]- (ReqArg- (\arg opt -> return opt { optOutputFile = arg })- "FILENAME")- "" -- "Name of output file"-- , Option "" ["data-dir"]- (ReqArg- (\arg opt -> return opt { optDataDir = Just arg })- "DIRECTORY") -- "Directory containing pandoc data files."- ""-- , Option "" ["strict"]- (NoArg- (\opt -> return opt { optStrict = True } ))- "" -- "Disable markdown syntax extensions"-- , Option "R" ["parse-raw"]- (NoArg- (\opt -> return opt { optParseRaw = True }))- "" -- "Parse untranslatable HTML codes and LaTeX environments as raw"-- , Option "S" ["smart"]- (NoArg- (\opt -> return opt { optSmart = True }))- "" -- "Use smart quotes, dashes, and ellipses"-- , Option "" ["old-dashes"]- (NoArg- (\opt -> return opt { optSmart = True- , optOldDashes = True }))- "" -- "Use smart quotes, dashes, and ellipses"-- , Option "" ["base-header-level"]- (ReqArg- (\arg opt ->- case reads arg of- [(t,"")] | t > 0 -> do- let oldTransforms = optTransforms opt- let shift = t - 1- return opt{ optTransforms =- headerShift shift : oldTransforms }- _ -> err 19- "base-header-level must be a number > 0")- "NUMBER")- "" -- "Headers base level"-- , Option "" ["indented-code-classes"]- (ReqArg- (\arg opt -> return opt { optIndentedCodeClasses = words $- map (\c -> if c == ',' then ' ' else c) arg })- "STRING")- "" -- "Classes (whitespace- or comma-separated) to use for indented code-blocks"-- , Option "" ["normalize"]- (NoArg- (\opt -> return opt { optTransforms =- normalize : optTransforms opt } ))- "" -- "Normalize the Pandoc AST"-- , Option "p" ["preserve-tabs"]- (NoArg- (\opt -> return opt { optPreserveTabs = True }))- "" -- "Preserve tabs instead of converting to spaces"-- , Option "" ["tab-stop"]- (ReqArg- (\arg opt ->- case reads arg of- [(t,"")] | t > 0 -> return opt { optTabStop = t }- _ -> err 31- "tab-stop must be a number greater than 0")- "NUMBER")- "" -- "Tab stop (default 4)"-- , Option "s" ["standalone"]- (NoArg- (\opt -> return opt { optStandalone = True }))- "" -- "Include needed header and footer on output"-- , Option "" ["template"]- (ReqArg- (\arg opt -> do- return opt{ optTemplate = Just arg,- optStandalone = True })- "FILENAME")- "" -- "Use custom template"-- , Option "V" ["variable"]- (ReqArg- (\arg opt -> do- let (key,val) = case break (`elem` ":=") arg of- (k,_:v) -> (k,v)- (k,_) -> (k,"true")- let newvars = optVariables opt ++ [(key,val)]- return opt{ optVariables = newvars })- "KEY[:VALUE]")- "" -- "Use custom template"-- , Option "D" ["print-default-template"]- (ReqArg- (\arg _ -> do- templ <- getDefaultTemplate Nothing arg- case templ of- Right t -> UTF8.hPutStr stdout t- Left e -> error $ show e- exitWith ExitSuccess)- "FORMAT")- "" -- "Print default template for FORMAT"-- , Option "" ["no-wrap"]- (NoArg- (\opt -> return opt { optWrapText = False }))- "" -- "Do not wrap text in output"-- , Option "" ["columns"]- (ReqArg- (\arg opt ->- case reads arg of- [(t,"")] | t > 0 -> return opt { optColumns = t }- _ -> err 33 $- "columns must be a number greater than 0")- "NUMBER")- "" -- "Length of line in characters"-- , Option "" ["toc", "table-of-contents"]- (NoArg- (\opt -> return opt { optTableOfContents = True }))- "" -- "Include table of contents"-- , Option "" ["no-highlight"]- (NoArg- (\opt -> return opt { optHighlight = False }))- "" -- "Don't highlight source code"-- , Option "" ["highlight-style"]- (ReqArg- (\arg opt -> do- newStyle <- case map toLower arg of- "pygments" -> return pygments- "tango" -> return tango- "espresso" -> return espresso- "zenburn" -> return zenburn- "kate" -> return kate- "monochrome" -> return monochrome- "haddock" -> return haddock- _ -> err 39 $- "Unknown style :" ++ arg- return opt{ optHighlightStyle = newStyle })- "STYLE")- "" -- "Style for highlighted code"-- , Option "H" ["include-in-header"]- (ReqArg- (\arg opt -> do- text <- UTF8.readFile arg- -- add new ones to end, so they're included in order specified- let newvars = optVariables opt ++ [("header-includes",text)]- return opt { optVariables = newvars,- optStandalone = True })- "FILENAME")- "" -- "File to include at end of header (implies -s)"-- , Option "B" ["include-before-body"]- (ReqArg- (\arg opt -> do- text <- UTF8.readFile arg- -- add new ones to end, so they're included in order specified- let newvars = optVariables opt ++ [("include-before",text)]- return opt { optVariables = newvars,- optStandalone = True })- "FILENAME")- "" -- "File to include before document body"-- , Option "A" ["include-after-body"]- (ReqArg- (\arg opt -> do- text <- UTF8.readFile arg- -- add new ones to end, so they're included in order specified- let newvars = optVariables opt ++ [("include-after",text)]- return opt { optVariables = newvars,- optStandalone = True })- "FILENAME")- "" -- "File to include after document body"-- , Option "" ["self-contained"]- (NoArg- (\opt -> return opt { optSelfContained = True,- optVariables = ("slidy-url","slidy") :- optVariables opt,- optStandalone = True }))- "" -- "Make slide shows include all the needed js and css"-- , Option "" ["offline"]- (NoArg- (\opt -> do warn $ "--offline is deprecated. Use --self-contained instead."- return opt { optSelfContained = True,- optStandalone = True }))- "" -- "Make slide shows include all the needed js and css"- -- deprecated synonym for --self-contained-- , Option "5" ["html5"]- (NoArg- (\opt -> do- warn $ "--html5 is deprecated. "- ++ "Use the html5 output format instead."- return opt { optHtml5 = True }))- "" -- "Produce HTML5 in HTML output"-- , Option "" ["ascii"]- (NoArg- (\opt -> return opt { optAscii = True }))- "" -- "Use ascii characters only in HTML output"-- , Option "" ["reference-links"]- (NoArg- (\opt -> return opt { optReferenceLinks = True } ))- "" -- "Use reference links in parsing HTML"-- , Option "" ["atx-headers"]- (NoArg- (\opt -> return opt { optSetextHeaders = False } ))- "" -- "Use atx-style headers for markdown"-- , Option "" ["chapters"]- (NoArg- (\opt -> return opt { optChapters = True }))- "" -- "Use chapter for top-level sections in LaTeX, DocBook"-- , Option "N" ["number-sections"]- (NoArg- (\opt -> return opt { optNumberSections = True }))- "" -- "Number sections in LaTeX"-- , Option "" ["no-tex-ligatures"]- (NoArg- (\opt -> return opt { optTeXLigatures = False }))- "" -- "Don't use tex ligatures for quotes, dashes"-- , Option "" ["listings"]- (NoArg- (\opt -> return opt { optListings = True }))- "" -- "Use listings package for LaTeX code blocks"-- , Option "i" ["incremental"]- (NoArg- (\opt -> return opt { optIncremental = True }))- "" -- "Make list items display incrementally in Slidy/Slideous/S5"-- , Option "" ["slide-level"]- (ReqArg- (\arg opt -> do- case reads arg of- [(t,"")] | t >= 1 && t <= 6 ->- return opt { optSlideLevel = Just t }- _ -> err 39 $- "slide level must be a number between 1 and 6")- "NUMBER")- "" -- "Force header level for slides"-- , Option "" ["section-divs"]- (NoArg- (\opt -> return opt { optSectionDivs = True }))- "" -- "Put sections in div tags in HTML"-- , Option "" ["email-obfuscation"]- (ReqArg- (\arg opt -> do- method <- case arg of- "references" -> return ReferenceObfuscation- "javascript" -> return JavascriptObfuscation- "none" -> return NoObfuscation- _ -> err 6- ("Unknown obfuscation method: " ++ arg)- return opt { optEmailObfuscation = method })- "none|javascript|references")- "" -- "Method for obfuscating email in HTML"-- , Option "" ["id-prefix"]- (ReqArg- (\arg opt -> return opt { optIdentifierPrefix = arg })- "STRING")- "" -- "Prefix to add to automatically generated HTML identifiers"-- , Option "T" ["title-prefix"]- (ReqArg- (\arg opt -> do- let newvars = ("title-prefix", arg) : optVariables opt- return opt { optVariables = newvars,- optStandalone = True })- "STRING")- "" -- "String to prefix to HTML window title"-- , Option "c" ["css"]- (ReqArg- (\arg opt -> do- -- add new link to end, so it is included in proper order- let newvars = optVariables opt ++ [("css",arg)]- return opt { optVariables = newvars,- optStandalone = True })- "URL")- "" -- "Link to CSS style sheet"-- , Option "" ["reference-odt"]- (ReqArg- (\arg opt -> do- return opt { optReferenceODT = Just arg })- "FILENAME")- "" -- "Path of custom reference.odt"-- , Option "" ["reference-docx"]- (ReqArg- (\arg opt -> do- return opt { optReferenceDocx = Just arg })- "FILENAME")- "" -- "Path of custom reference.docx"-- , Option "" ["epub-stylesheet"]- (ReqArg- (\arg opt -> do- text <- UTF8.readFile arg- return opt { optEPUBStylesheet = Just text })- "FILENAME")- "" -- "Path of epub.css"-- , Option "" ["epub-cover-image"]- (ReqArg- (\arg opt ->- return opt { optVariables =- ("epub-cover-image", arg) : optVariables opt })- "FILENAME")- "" -- "Path of epub cover image"-- , Option "" ["epub-metadata"]- (ReqArg- (\arg opt -> do- text <- UTF8.readFile arg- return opt { optEPUBMetadata = text })- "FILENAME")- "" -- "Path of epub metadata file"-- , Option "" ["epub-embed-font"]- (ReqArg- (\arg opt -> do- return opt{ optEPUBFonts = arg : optEPUBFonts opt })- "FILE")- "" -- "Directory of fonts to embed"-- , Option "" ["latex-engine"]- (ReqArg- (\arg opt -> do- let b = takeBaseName arg- if (b == "pdflatex" || b == "lualatex" || b == "xelatex")- then return opt { optLaTeXEngine = arg }- else err 45 "latex-engine must be pdflatex, lualatex, or xelatex.")- "PROGRAM")- "" -- "Name of latex program to use in generating PDF"-- , Option "" ["bibliography"]- (ReqArg- (\arg opt -> return opt { optBibliography = (optBibliography opt) ++ [arg] })- "FILENAME")- ""-- , Option "" ["csl"]- (ReqArg- (\arg opt -> return opt { optCslFile = arg })- "FILENAME")- ""-- , Option "" ["citation-abbreviations"]- (ReqArg- (\arg opt -> return opt { optAbbrevsFile = Just arg })- "FILENAME")- ""-- , Option "" ["natbib"]- (NoArg- (\opt -> return opt { optCiteMethod = Natbib }))- "" -- "Use natbib cite commands in LaTeX output"-- , Option "" ["biblatex"]- (NoArg- (\opt -> return opt { optCiteMethod = Biblatex }))- "" -- "Use biblatex cite commands in LaTeX output"-- , Option "m" ["latexmathml", "asciimathml"]- (OptArg- (\arg opt ->- return opt { optHTMLMathMethod = LaTeXMathML arg })- "URL")- "" -- "Use LaTeXMathML script in html output"-- , Option "" ["mathml"]- (OptArg- (\arg opt ->- return opt { optHTMLMathMethod = MathML arg })- "URL")- "" -- "Use mathml for HTML math"-- , Option "" ["mimetex"]- (OptArg- (\arg opt -> do- let url' = case arg of- Just u -> u ++ "?"- Nothing -> "/cgi-bin/mimetex.cgi?"- return opt { optHTMLMathMethod = WebTeX url' })- "URL")- "" -- "Use mimetex for HTML math"-- , Option "" ["webtex"]- (OptArg- (\arg opt -> do- let url' = case arg of- Just u -> u- Nothing -> "http://chart.apis.google.com/chart?cht=tx&chl="- return opt { optHTMLMathMethod = WebTeX url' })- "URL")- "" -- "Use web service for HTML math"-- , Option "" ["jsmath"]- (OptArg- (\arg opt -> return opt { optHTMLMathMethod = JsMath arg})- "URL")- "" -- "Use jsMath for HTML math"-- , Option "" ["mathjax"]- (OptArg- (\arg opt -> do- let url' = case arg of- Just u -> u- Nothing -> "https://d3eoax9i5htok0.cloudfront.net/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"- return opt { optHTMLMathMethod = MathJax url'})- "URL")- "" -- "Use MathJax for HTML math"-- , Option "" ["gladtex"]- (NoArg- (\opt -> return opt { optHTMLMathMethod = GladTeX }))- "" -- "Use gladtex for HTML math"-- , Option "" ["dump-args"]- (NoArg- (\opt -> return opt { optDumpArgs = True }))- "" -- "Print output filename and arguments to stdout."-- , Option "" ["ignore-args"]- (NoArg- (\opt -> return opt { optIgnoreArgs = True }))- "" -- "Ignore command-line arguments."-- , Option "v" ["version"]- (NoArg- (\_ -> do- prg <- getProgName- UTF8.hPutStrLn stdout (prg ++ " " ++ pandocVersion ++ compileInfo ++- copyrightMessage)- exitWith ExitSuccess ))- "" -- "Print version"-- , Option "h" ["help"]- (NoArg- (\_ -> do- prg <- getProgName- UTF8.hPutStr stdout (usageMessage prg options)- exitWith ExitSuccess ))- "" -- "Show help"-- ]---- Returns usage message-usageMessage :: String -> [OptDescr (Opt -> IO Opt)] -> String-usageMessage programName = usageInfo- (programName ++ " [OPTIONS] [FILES]" ++ "\nInput formats: " ++- (wrapWords 16 78 $ map fst readers) ++ "\nOutput formats: " ++- (wrapWords 16 78 $ map fst writers ++ nonTextFormats) ++ "\nOptions:")---- Determine default reader based on source file extensions-defaultReaderName :: String -> [FilePath] -> String-defaultReaderName fallback [] = fallback-defaultReaderName fallback (x:xs) =- case takeExtension (map toLower x) of- ".xhtml" -> "html"- ".html" -> "html"- ".htm" -> "html"- ".tex" -> "latex"- ".latex" -> "latex"- ".ltx" -> "latex"- ".rst" -> "rst"- ".lhs" -> "markdown+lhs"- ".db" -> "docbook"- ".textile" -> "textile"- ".native" -> "native"- ".json" -> "json"- _ -> defaultReaderName fallback xs---- Returns True if extension of first source is .lhs-lhsExtension :: [FilePath] -> Bool-lhsExtension (x:_) = takeExtension x == ".lhs"-lhsExtension _ = False---- Determine default writer based on output file extension-defaultWriterName :: FilePath -> String-defaultWriterName "-" = "html" -- no output file-defaultWriterName x =- case takeExtension (map toLower x) of- "" -> "markdown" -- empty extension- ".tex" -> "latex"- ".latex" -> "latex"- ".ltx" -> "latex"- ".context" -> "context"- ".ctx" -> "context"- ".rtf" -> "rtf"- ".rst" -> "rst"- ".s5" -> "s5"- ".native" -> "native"- ".json" -> "json"- ".txt" -> "markdown"- ".text" -> "markdown"- ".md" -> "markdown"- ".markdown" -> "markdown"- ".textile" -> "textile"- ".lhs" -> "markdown+lhs"- ".texi" -> "texinfo"- ".texinfo" -> "texinfo"- ".db" -> "docbook"- ".odt" -> "odt"- ".docx" -> "docx"- ".epub" -> "epub"- ".org" -> "org"- ".asciidoc" -> "asciidoc"- ".pdf" -> "latex"- ['.',y] | y `elem` ['1'..'9'] -> "man"- _ -> "html"--main :: IO ()-main = do-- rawArgs <- liftM (map decodeArg) getArgs- prg <- getProgName- let compatMode = (prg == "hsmarkdown")-- let (actions, args, errors) = if compatMode- then ([], rawArgs, [])- else getOpt Permute options rawArgs-- unless (null errors) $- err 2 $ concat $ errors ++- ["Try " ++ prg ++ " --help for more information."]-- let defaultOpts' = if compatMode- then defaultOpts { optReader = "markdown"- , optWriter = "html"- , optStrict = True }- else defaultOpts-- -- thread option data structure through all supplied option actions- opts <- foldl (>>=) (return defaultOpts') actions-- let Opt { optTabStop = tabStop- , optPreserveTabs = preserveTabs- , optStandalone = standalone- , optReader = readerName- , optWriter = writerName- , optParseRaw = parseRaw- , optVariables = variables- , optTableOfContents = toc- , optTransforms = transforms- , optTemplate = templatePath- , optOutputFile = outputFile- , optNumberSections = numberSections- , optSectionDivs = sectionDivs- , optIncremental = incremental- , optSelfContained = selfContained- , optSmart = smart- , optOldDashes = oldDashes- , optHtml5 = html5- , optHighlight = highlight- , optHighlightStyle = highlightStyle- , optChapters = chapters- , optHTMLMathMethod = mathMethod- , optReferenceODT = referenceODT- , optReferenceDocx = referenceDocx- , optEPUBStylesheet = epubStylesheet- , optEPUBMetadata = epubMetadata- , optEPUBFonts = epubFonts- , optDumpArgs = dumpArgs- , optIgnoreArgs = ignoreArgs- , optStrict = strict- , optReferenceLinks = referenceLinks- , optWrapText = wrap- , optColumns = columns- , optEmailObfuscation = obfuscationMethod- , optIdentifierPrefix = idPrefix- , optIndentedCodeClasses = codeBlockClasses- , optDataDir = mbDataDir- , optBibliography = reffiles- , optCslFile = cslfile- , optAbbrevsFile = cslabbrevs- , optCiteMethod = citeMethod- , optListings = listings- , optLaTeXEngine = latexEngine- , optSlideLevel = slideLevel- , optSetextHeaders = setextHeaders- , optAscii = ascii- , optTeXLigatures = texLigatures- } = opts-- when dumpArgs $- do UTF8.hPutStrLn stdout outputFile- mapM_ (\arg -> UTF8.hPutStrLn stdout arg) args- exitWith ExitSuccess-- let sources = if ignoreArgs then [] else args-- datadir <- case mbDataDir of- Nothing -> E.catch- (liftM Just $ getAppUserDataDirectory "pandoc")- (\(_::E.IOException) -> return Nothing)- Just _ -> return mbDataDir-- -- assign reader and writer based on options and filenames- let readerName' = if null readerName- then let fallback = if any isURI sources- then "html"- else "markdown"- in defaultReaderName fallback sources- else readerName-- let writerName' = if null writerName- then defaultWriterName outputFile- else writerName-- let pdfOutput = map toLower (takeExtension outputFile) == ".pdf"-- let laTeXOutput = writerName' == "latex" || writerName' == "beamer" ||- writerName' == "latex+lhs" || writerName' == "beamer+lhs"-- when pdfOutput $ do- -- make sure writer is latex or beamer- unless laTeXOutput $- err 47 $ "cannot produce pdf output with " ++ writerName' ++ " writer"- -- check for latex program- mbLatex <- findExecutable latexEngine- case mbLatex of- Nothing -> err 41 $- latexEngine ++ " not found. " ++- latexEngine ++ " is needed for pdf output."- Just _ -> return ()-- reader <- case (lookup readerName' readers) of- Just r -> return r- Nothing -> err 7 ("Unknown reader: " ++ readerName')-- let standalone' = standalone || writerName' `elem` nonTextFormats || pdfOutput-- templ <- case templatePath of- _ | not standalone' -> return ""- Nothing -> do- deftemp <- getDefaultTemplate datadir writerName'- case deftemp of- Left e -> throwIO e- Right t -> return t- Just tp -> do- -- strip off "+lhs" if present- let format = takeWhile (/='+') writerName'- let tp' = case takeExtension tp of- "" -> tp <.> format- _ -> tp- E.catch (UTF8.readFile tp')- (\(e::E.IOException) -> if isDoesNotExistError e- then E.catch- (readDataFile datadir $- "templates" </> tp')- (\(_::E.IOException) -> throwIO e)- else throwIO e)-- let slideVariant = case writerName' of- "s5" -> S5Slides- "slidy" -> SlidySlides- "slideous" -> SlideousSlides- "dzslides" -> DZSlides- _ -> NoSlides-- variables' <- case mathMethod of- LaTeXMathML Nothing -> do- s <- readDataFile datadir $ "data" </> "LaTeXMathML.js"- return $ ("mathml-script", s) : variables- MathML Nothing -> do- s <- readDataFile datadir $ "data"</>"MathMLinHTML.js"- return $ ("mathml-script", s) : variables- _ -> return variables-- variables'' <- case slideVariant of- DZSlides -> do- dztempl <- readDataFile datadir $ "dzslides" </> "template.html"- let dzcore = unlines $ dropWhile (not . isPrefixOf "<!-- {{{{ dzslides core")- $ lines dztempl- return $ ("dzslides-core", dzcore) : variables'- _ -> return variables'-- -- unescape reference ids, which may contain XML entities, so- -- that we can do lookups with regular string equality- let unescapeRefId ref = ref{ refId = fromEntities (refId ref) }-- refs <- mapM (\f -> E.catch (CSL.readBiblioFile f) $ \(e::E.IOException) ->- err 23 $ "Error reading bibliography `" ++ f ++ "'" ++ "\n" ++ show e)- reffiles >>=- return . map unescapeRefId . concat-- let sourceDir = if null sources- then "."- else takeDirectory (head sources)-- let startParserState =- defaultParserState { stateParseRaw = parseRaw,- stateTabStop = tabStop,- stateLiterateHaskell = "+lhs" `isSuffixOf` readerName' ||- lhsExtension sources,- stateStandalone = standalone',- stateCitations = map CSL.refId refs,- stateSmart = smart || (texLigatures &&- (laTeXOutput || writerName' == "context")),- stateOldDashes = oldDashes,- stateColumns = columns,- stateStrict = strict,- stateIndentedCodeClasses = codeBlockClasses,- stateApplyMacros = not laTeXOutput- }-- let writerOptions = defaultWriterOptions- { writerStandalone = standalone',- writerTemplate = templ,- writerVariables = variables'',- writerEPUBMetadata = epubMetadata,- writerTabStop = tabStop,- writerTableOfContents = toc &&- writerName' /= "s5",- writerHTMLMathMethod = mathMethod,- writerSlideVariant = slideVariant,- writerIncremental = incremental,- writerCiteMethod = citeMethod,- writerBiblioFiles = reffiles,- writerIgnoreNotes = False,- writerNumberSections = numberSections,- writerSectionDivs = sectionDivs,- writerStrictMarkdown = strict,- writerReferenceLinks = referenceLinks,- writerWrapText = wrap,- writerColumns = columns,- writerLiterateHaskell = False,- writerEmailObfuscation = if strict- then ReferenceObfuscation- else obfuscationMethod,- writerIdentifierPrefix = idPrefix,- writerSourceDirectory = sourceDir,- writerUserDataDir = datadir,- writerHtml5 = html5 ||- slideVariant == DZSlides,- writerChapters = chapters,- writerListings = listings,- writerBeamer = False,- writerSlideLevel = slideLevel,- writerHighlight = highlight,- writerHighlightStyle = highlightStyle,- writerSetextHeaders = setextHeaders,- writerTeXLigatures = texLigatures- }-- when (writerName' `elem` nonTextFormats&& outputFile == "-") $- err 5 $ "Cannot write " ++ writerName' ++ " output to stdout.\n" ++- "Specify an output file using the -o option."-- let readSources [] = mapM readSource ["-"]- readSources srcs = mapM readSource srcs- readSource "-" = UTF8.getContents- readSource src = case parseURI src of- Just u | uriScheme u `elem` ["http:","https:"] ->- readURI u- _ -> UTF8.readFile src- readURI uri = simpleHTTP (mkRequest GET uri) >>= getResponseBody >>=- return . toString -- treat all as UTF8-- let convertTabs = tabFilter (if preserveTabs then 0 else tabStop)-- let handleIncludes' = if readerName' == "latex" || readerName' == "latex+lhs"- then handleIncludes- else return-- doc <- (reader startParserState) `fmap` (readSources sources >>=- handleIncludes' . convertTabs . intercalate "\n")-- let doc0 = foldr ($) doc transforms-- doc1 <- if writerName' == "rtf"- then bottomUpM rtfEmbedImage doc0- else return doc0-- doc2 <- do- if citeMethod == Citeproc && not (null refs)- then do- csldir <- getAppUserDataDirectory "csl"- cslfile' <- if null cslfile- then findDataFile datadir "default.csl"- else do- ex <- doesFileExist cslfile- if ex- then return cslfile- else findDataFile datadir $- replaceDirectory- (replaceExtension cslfile "csl")- csldir- processBiblio cslfile' cslabbrevs refs doc1- else return doc1-- let writeBinary :: B.ByteString -> IO ()- writeBinary = B.writeFile (encodePath outputFile)-- let writerFn :: FilePath -> String -> IO ()- writerFn "-" = UTF8.putStr- writerFn f = UTF8.writeFile f-- case lookup writerName' writers of- Nothing- | writerName' == "epub" ->- writeEPUB epubStylesheet epubFonts writerOptions doc2- >>= writeBinary- | writerName' == "odt" ->- writeODT referenceODT writerOptions doc2 >>= writeBinary- | writerName' == "docx" ->- writeDocx referenceDocx writerOptions doc2 >>= writeBinary- | otherwise -> err 9 ("Unknown writer: " ++ writerName')- Just w- | pdfOutput -> do- res <- tex2pdf latexEngine $ w writerOptions doc2- case res of- Right pdf -> writeBinary pdf- Left err' -> err 43 $ toString err'- Just w- | htmlFormat && ascii ->- writerFn outputFile =<< selfcontain (toEntities result)- | otherwise ->- writerFn outputFile =<< selfcontain result- where result = w writerOptions doc2 ++ ['\n' | not standalone']- htmlFormat = writerName' `elem`- ["html","html+lhs","html5","html5+lhs",- "s5","slidy","slideous","dzslides"]- selfcontain = if selfContained && htmlFormat- then makeSelfContained datadir- else return
@@ -1,26 +0,0 @@-$if(titleblock)$-$title$-$for(author)$-:author: $author$-$endfor$-$if(date)$-:date: $date$-$endif$-$if(toc)$-:toc:-$endif$--$endif$-$for(header-includes)$-$header-includes$--$endfor$-$for(include-before)$-$include-before$--$endfor$-$body$-$for(include-after)$--$include-after$-$endfor$
@@ -1,133 +0,0 @@-\documentclass[$if(fontsize)$$fontsize$,$endif$$if(handout)$handout,$endif$$if(beamer)$ignorenonframetext,$endif$]{$documentclass$}-$if(theme)$-\usetheme{$theme$}-$endif$-$if(colortheme)$-\usecolortheme{$colortheme$}-$endif$-\usepackage{amssymb,amsmath}-\usepackage{ifxetex,ifluatex}-\usepackage{fixltx2e} % provides \textsubscript-\ifxetex- \usepackage{fontspec,xltxtra,xunicode}- \defaultfontfeatures{Mapping=tex-text,Scale=MatchLowercase}-\else- \ifluatex- \usepackage{fontspec}- \defaultfontfeatures{Mapping=tex-text,Scale=MatchLowercase}- \else- \usepackage[utf8]{inputenc}- \fi-\fi-$if(natbib)$-\usepackage{natbib}-\bibliographystyle{plainnat}-$endif$-$if(biblatex)$-\usepackage{biblatex}-$if(biblio-files)$-\bibliography{$biblio-files$}-$endif$-$endif$-$if(listings)$-\usepackage{listings}-$endif$-$if(lhs)$-\lstnewenvironment{code}{\lstset{language=Haskell,basicstyle=\small\ttfamily}}{}-$endif$-$if(highlighting-macros)$-$highlighting-macros$-$endif$-$if(verbatim-in-note)$-\usepackage{fancyvrb}-$endif$-$if(fancy-enums)$-\usepackage{enumerate}-$endif$-$if(tables)$-\usepackage{ctable}-\usepackage{float} % provides the H option for float placement-$endif$-$if(url)$-\usepackage{url}-$endif$-$if(graphics)$-\usepackage{graphicx}-$endif$-% Comment these out if you don't want a slide with just the-% part/section/subsection/subsubsection title:-\AtBeginPart{\frame{\partpage}}-\AtBeginSection{\frame{\sectionpage}}-\AtBeginSubsection{\frame{\subsectionpage}}-\AtBeginSubsubsection{\frame{\subsubsectionpage}}-$if(strikeout)$-\usepackage[normalem]{ulem}-% avoid problems with \sout in headers with hyperref:-\pdfstringdefDisableCommands{\renewcommand{\sout}{}}-$endif$-\setlength{\parindent}{0pt}-\setlength{\parskip}{6pt plus 2pt minus 1pt}-\setlength{\emergencystretch}{3em} % prevent overfull lines-$if(numbersections)$-$else$-\setcounter{secnumdepth}{0}-$endif$-$if(verbatim-in-note)$-\VerbatimFootnotes % allows verbatim text in footnotes-$endif$-$if(lang)$-\usepackage[$lang$]{babel}-$endif$-$for(header-includes)$-$header-includes$-$endfor$--$if(title)$-\title{$title$}-$endif$-$if(author)$-\author{$for(author)$$author$$sep$ \and $endfor$}-$endif$-$if(date)$-\date{$date$}-$endif$--\begin{document}-$if(title)$-\frame{\titlepage}-$endif$--$for(include-before)$-$include-before$--$endfor$-$if(toc)$-\begin{frame}-\tableofcontents[hideallsubsections]-\end{frame}--$endif$-$body$--$if(natbib)$-$if(biblio-files)$-$if(biblio-title)$-$if(book-class)$-\renewcommand\bibname{$biblio-title$}-$else$-\renewcommand\refname{$biblio-title$}-$endif$-$endif$-\bibliography{$biblio-files$}--$endif$-$endif$-$if(biblatex)$-\printbibliography$if(biblio-title)$[title=$biblio-title$]$endif$--$endif$-$for(include-after)$-$include-after$--$endfor$-\end{document}
@@ -1,80 +0,0 @@-\startmode[*mkii]- \enableregime[utf-8] - \setupcolors[state=start]-\stopmode-$if(mainlang)$-\mainlanguage[$mainlang$]-$endif$--% Enable hyperlinks-\setupinteraction[state=start, color=middleblue]--\setuppapersize [letter][letter] -\setuplayout [width=middle, backspace=1.5in, cutspace=1.5in,- height=middle, topspace=0.75in, bottomspace=0.75in]--\setuppagenumbering[location={footer,center}]--\setupbodyfont[11pt]--\setupwhitespace[medium]--\setuphead[chapter] [style=\tfd]-\setuphead[section] [style=\tfc]-\setuphead[subsection] [style=\tfb]-\setuphead[subsubsection][style=\bf]--$if(number-sections)$-$else$-\setuphead[chapter, section, subsection, subsubsection][number=no]-$endif$--\definedescription- [description]- [headstyle=bold, style=normal, location=hanging, width=broad, margin=1cm]--\setupitemize[autointro] % prevent orphan list intro-\setupitemize[indentnext=no]--\setupthinrules[width=15em] % width of horizontal rules--\setupdelimitedtext- [blockquote]- [before={\blank[medium]},- after={\blank[medium]},- indentnext=no,- ]--$for(header-includes)$-$header-includes$-$endfor$--\starttext-$if(title)$-\startalignment[center]- \blank[2*big]- {\tfd $title$}-$if(author)$- \blank[3*medium]- {\tfa $for(author)$$author$$sep$\crlf $endfor$}-$endif$-$if(date)$- \blank[2*medium]- {\tfa $date$}-$endif$- \blank[3*medium]-\stopalignment-$endif$-$for(include-before)$-$include-before$-$endfor$-$if(toc)$-\placecontent-$endif$--$body$--$for(include-after)$-$include-after$-$endfor$-\stoptext
@@ -1,28 +0,0 @@-<?xml version="1.0" encoding="utf-8" ?>-$if(mathml)$-<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook EBNF Module V1.1CR1//EN"- "http://www.oasis-open.org/docbook/xml/mathml/1.1CR1/dbmathml.dtd">-$else$-<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"- "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd">-$endif$-<article>- <articleinfo>- <title>$title$</title>-$for(author)$- <author>- $author$- </author>-$endfor$-$if(date)$- <date>$date$</date>-$endif$- </articleinfo>-$for(include-before)$-$include-before$-$endfor$-$body$-$for(include-after)$-$include-after$-$endfor$-</article>
@@ -1,119 +0,0 @@-<!DOCTYPE html>-<head>-<meta charset="utf-8">-$for(author-meta)$- <meta name="author" content="$author-meta$" />-$endfor$-$if(date-meta)$- <meta name="dcterms.date" content="$date-meta$" />-$endif$- <title>$if(title-prefix)$$title-prefix$ - $endif$$if(pagetitle)$$pagetitle$$endif$</title>-$if(highlighting-css)$- <style type="text/css">-$highlighting-css$- </style>-$endif$-$if(css)$-$for(css)$- <link rel="stylesheet" href="$css$" $if(html5)$$else$type="text/css" $endif$/>-$endfor$-$else$-<style>- html { background-color: black; }- body { background-color: white; border-radius: 12px}- /* A section is a slide. It's size is 800x600, and this will never change */- section {- font-family: Arial, serif;- font-size: 20pt;- }- address, blockquote, dl, fieldset, form, h1, h2, h3, h4, h5, h6, hr, ol, p, pre, table, ul, dl { padding: 10px 20px 10px 20px; }- h1, h2, h3 {- text-align: center;- margin: 10pt 10pt 20pt 10pt;- }- ul, ol {- margin: 10px 10px 10px 50px;- }- section.titleslide h1 { margin-top: 200px; }- h1.title { margin-top: 150px; }- h1 { font-size: 180%; }- h2 { font-size: 120%; }- h3 { font-size: 100%; }- q { quotes: "“" "”" "‘" "’"; }- blockquote { font-style: italic }- /* Figures are displayed full-page, with the caption on- top of the image/video */- figure {- background-color: black;- }- figcaption {- margin: 70px;- }- footer {- position: absolute;- bottom: 0;- width: 100%;- padding: 40px;- text-align: right;- background-color: #F3F4F8;- border-top: 1px solid #CCC;- }-- /* Transition effect */- /* Feel free to change the transition effect for original- animations. See here:- https://developer.mozilla.org/en/CSS/CSS_transitions- How to use CSS3 Transitions: */- section {- -moz-transition: left 400ms linear 0s;- -webkit-transition: left 400ms linear 0s;- -ms-transition: left 400ms linear 0s;- transition: left 400ms linear 0s;- }-- /* Before */- section { left: -150%; }- /* Now */- section[aria-selected] { left: 0; }- /* After */- section[aria-selected] ~ section { left: +150%; }-- /* Incremental elements */-- /* By default, visible */- .incremental > * { opacity: 1; }-- /* The current item */- .incremental > *[aria-selected] { color: red; opacity: 1; }-- /* The items to-be-selected */- .incremental > *[aria-selected] ~ * { opacity: 0.2; }-</style>-$endif$-$if(math)$- $math$-$endif$-$for(header-includes)$- $header-includes$-$endfor$-</head>-<body>-$if(title)$-<section>- <h1 class="title">$title$</h1>-$for(author)$- <h2 class="author">$author$</h2>-$endfor$- <h3 class="date">$date$</h3>-</section>-$endif$-$for(include-before)$-$include-before$-$endfor$-$body$-$for(include-after)$-$include-after$-$endfor$-$dzslides-core$-</body>-</html>
@@ -1,54 +0,0 @@-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">-<html xmlns="http://www.w3.org/1999/xhtml"$if(lang)$ lang="$lang$" xml:lang="$lang$"$endif$>-<head>- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />- <meta http-equiv="Content-Style-Type" content="text/css" />- <meta name="generator" content="pandoc" />-$for(author-meta)$- <meta name="author" content="$author-meta$" />-$endfor$-$if(date-meta)$- <meta name="date" content="$date-meta$" />-$endif$- <title>$if(title-prefix)$$title-prefix$ - $endif$$if(pagetitle)$$pagetitle$$endif$</title>-$if(highlighting-css)$- <style type="text/css">-$highlighting-css$- </style>-$endif$-$for(css)$- <link rel="stylesheet" href="$css$" $if(html5)$$else$type="text/css" $endif$/>-$endfor$-$if(math)$- $math$-$endif$-$for(header-includes)$- $header-includes$-$endfor$-</head>-<body>-$for(include-before)$-$include-before$-$endfor$-$if(title)$-<div id="$idprefix$header">-<h1 class="title">$title$</h1>-$for(author)$-<h2 class="author">$author$</h2>-$endfor$-$if(date)$-<h3 class="date">$date$</h3>-$endif$-</div>-$endif$-$if(toc)$-<div id="$idprefix$TOC">-$toc$-</div>-$endif$-$body$-$for(include-after)$-$include-after$-$endfor$-</body>-</html>
@@ -1,61 +0,0 @@-<!DOCTYPE html>-<html$if(lang)$ lang="$lang$"$endif$>-<head>- <meta charset="utf-8">- <meta name="generator" content="pandoc">-$for(author-meta)$- <meta name="author" content="$author-meta$">-$endfor$-$if(date-meta)$- <meta name="dcterms.date" content="$date-meta$">-$endif$- <title>$if(title-prefix)$$title-prefix$ - $endif$$if(pagetitle)$$pagetitle$$endif$</title>- <!--[if lt IE 9]>- <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>- <![endif]-->-$if(quotes)$- <style type="text/css">- q { quotes: "“" "”" "‘" "’"; }- </style>-$endif$-$if(highlighting-css)$- <style type="text/css">-$highlighting-css$- </style>-$endif$-$for(css)$- <link rel="stylesheet" href="$css$">-$endfor$-$if(math)$- $math$-$endif$-$for(header-includes)$- $header-includes$-$endfor$-</head>-<body>-$for(include-before)$-$include-before$-$endfor$-$if(title)$-<header>-<h1 class="title">$title$</h1>-$for(author)$-<h2 class="author">$author$</h2>-$endfor$-$if(date)$-<h3 class="date">$date$</h3>-$endif$-</header>-$endif$-$if(toc)$-<nav id="$idprefix$TOC">-$toc$-</nav>-$endif$-$body$-$for(include-after)$-$include-after$-$endfor$-</body>-</html>
@@ -1,174 +0,0 @@-\documentclass[$if(fontsize)$$fontsize$,$endif$$if(lang)$$lang$,$endif$]{$documentclass$}-\usepackage[T1]{fontenc}-\usepackage{lmodern}-\usepackage{amssymb,amsmath}-\usepackage{ifxetex,ifluatex}-\usepackage{fixltx2e} % provides \textsubscript-% use microtype if available-\IfFileExists{microtype.sty}{\usepackage{microtype}}{}-\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex- \usepackage[utf8]{inputenc}-$if(euro)$- \usepackage{eurosym}-$endif$-\else % if luatex or xelatex- \usepackage{fontspec}- \ifxetex- \usepackage{xltxtra,xunicode}- \fi- \defaultfontfeatures{Mapping=tex-text,Scale=MatchLowercase}- \newcommand{\euro}{€}-$if(mainfont)$- \setmainfont{$mainfont$}-$endif$-$if(sansfont)$- \setsansfont{$sansfont$}-$endif$-$if(monofont)$- \setmonofont{$monofont$}-$endif$-$if(mathfont)$- \setmathfont{$mathfont$}-$endif$-\fi-$if(geometry)$-\usepackage[$for(geometry)$$geometry$$sep$,$endfor$]{geometry}-$endif$-$if(natbib)$-\usepackage{natbib}-\bibliographystyle{plainnat}-$endif$-$if(biblatex)$-\usepackage{biblatex}-$if(biblio-files)$-\bibliography{$biblio-files$}-$endif$-$endif$-$if(listings)$-\usepackage{listings}-$endif$-$if(lhs)$-\lstnewenvironment{code}{\lstset{language=Haskell,basicstyle=\small\ttfamily}}{}-$endif$-$if(highlighting-macros)$-$highlighting-macros$-$endif$-$if(verbatim-in-note)$-\usepackage{fancyvrb}-$endif$-$if(fancy-enums)$-% Redefine labelwidth for lists; otherwise, the enumerate package will cause-% markers to extend beyond the left margin.-\makeatletter\AtBeginDocument{%- \renewcommand{\@listi}- {\setlength{\labelwidth}{4em}}-}\makeatother-\usepackage{enumerate}-$endif$-$if(tables)$-\usepackage{ctable}-\usepackage{float} % provides the H option for float placement-$endif$-$if(graphics)$-\usepackage{graphicx}-% We will generate all images so they have a width \maxwidth. This means-% that they will get their normal width if they fit onto the page, but-% are scaled down if they would overflow the margins.-\makeatletter-\def\maxwidth{\ifdim\Gin@nat@width>\linewidth\linewidth-\else\Gin@nat@width\fi}-\makeatother-\let\Oldincludegraphics\includegraphics-\renewcommand{\includegraphics}[1]{\Oldincludegraphics[width=\maxwidth]{#1}}-$endif$-\ifxetex- \usepackage[setpagesize=false, % page size defined by xetex- unicode=false, % unicode breaks when used with xetex- xetex]{hyperref}-\else- \usepackage[unicode=true]{hyperref}-\fi-\hypersetup{breaklinks=true,- bookmarks=true,- pdfauthor={$author-meta$},- pdftitle={$title-meta$},- colorlinks=true,- urlcolor=$if(urlcolor)$$urlcolor$$else$blue$endif$,- linkcolor=$if(linkcolor)$$linkcolor$$else$magenta$endif$,- pdfborder={0 0 0}}-$if(links-as-notes)$-% Make links footnotes instead of hotlinks:-\renewcommand{\href}[2]{#2\footnote{\url{#1}}}-$endif$-$if(strikeout)$-\usepackage[normalem]{ulem}-% avoid problems with \sout in headers with hyperref:-\pdfstringdefDisableCommands{\renewcommand{\sout}{}}-$endif$-\setlength{\parindent}{0pt}-\setlength{\parskip}{6pt plus 2pt minus 1pt}-\setlength{\emergencystretch}{3em} % prevent overfull lines-$if(numbersections)$-$else$-\setcounter{secnumdepth}{0}-$endif$-$if(verbatim-in-note)$-\VerbatimFootnotes % allows verbatim text in footnotes-$endif$-$if(lang)$-\ifxetex- \usepackage{polyglossia}- \setmainlanguage{$mainlang$}-\else- \usepackage[$lang$]{babel}-\fi-$endif$-$for(header-includes)$-$header-includes$-$endfor$--$if(title)$-\title{$title$}-$endif$-\author{$for(author)$$author$$sep$ \and $endfor$}-\date{$date$}--\begin{document}-$if(title)$-\maketitle-$endif$--$for(include-before)$-$include-before$--$endfor$-$if(toc)$-{-\hypersetup{linkcolor=black}-\tableofcontents-}-$endif$-$body$--$if(natbib)$-$if(biblio-files)$-$if(biblio-title)$-$if(book-class)$-\renewcommand\bibname{$biblio-title$}-$else$-\renewcommand\refname{$biblio-title$}-$endif$-$endif$-\bibliography{$biblio-files$}--$endif$-$endif$-$if(biblatex)$-\printbibliography$if(biblio-title)$[title=$biblio-title$]$endif$--$endif$-$for(include-after)$-$include-after$--$endfor$-\end{document}
@@ -1,18 +0,0 @@-$if(has-tables)$-.\"t-$endif$-.TH $title$ $section$ "$date$" $description$-$for(header-includes)$-$header-includes$-$endfor$-$for(include-before)$-$include-before$-$endfor$-$body$-$for(include-after)$-$include-after$-$endfor$-$if(author)$-.SH AUTHORS-$for(author)$$author$$sep$; $endfor$.-$endif$
@@ -1,23 +0,0 @@-$if(titleblock)$-% $title$-% $for(author)$$author$$sep$; $endfor$-% $date$--$endif$-$for(header-includes)$-$header-includes$--$endfor$-$for(include-before)$-$include-before$--$endfor$-$if(toc)$-$toc$--$endif$-$body$-$for(include-after)$--$include-after$-$endfor$
@@ -1,13 +0,0 @@-$for(include-before)$-$include-before$--$endfor$-$if(toc)$-__TOC__--$endif$-$body$-$for(include-after)$--$include-after$-$endfor$
@@ -1,27 +0,0 @@-<?xml version="1.0" encoding="utf-8" ?>-<office:document-content xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" office:version="1.0">- $automatic-styles$-$for(header-includes)$- $header-includes$-$endfor$ -<office:body>-<office:text>-$if(title)$-<text:h text:style-name="Title">$title$</text:h>-$endif$-$for(author)$-<text:p text:style-name="Author">$author$</text:p>-$endfor$-$if(date)$-<text:p text:style-name="Date">$date$</text:p>-$endif$-$for(include-before)$-$include-before$-$endfor$-$body$-$for(include-after)$-$include-after$-$endfor$-</office:text>-</office:body>-</office:document-content>
@@ -1,24 +0,0 @@-$if(title)$-$title$--$endif$-$if(author)$-#+AUTHOR: $for(author)$$author$$sep$; $endfor$-$endif$-$if(date)$-#+DATE: $date$--$endif$-$for(header-includes)$-$header-includes$--$endfor$-$for(include-before)$-$include-before$--$endfor$-$body$-$for(include-after)$--$include-after$-$endfor$
@@ -1,23 +0,0 @@-$if(titleblock)$-$title$-$for(author)$$author$$sep$; $endfor$-$date$--$endif$-$for(header-includes)$-$header-includes$--$endfor$-$for(include-before)$-$include-before$--$endfor$-$if(toc)$-$toc$--$endif$-$body$-$for(include-after)$--$include-after$-$endfor$
@@ -1,41 +0,0 @@-$if(title)$-$title$--$endif$-$for(author)$-:Author: $author$-$endfor$-$if(date)$-:Date: $date$-$endif$-$if(author)$--$else$-$if(date)$--$endif$-$endif$-$if(math)$-.. role:: math(raw)- :format: html latex-..--$endif$-$for(include-before)$-$include-before$--$endfor$-$if(toc)$-.. contents::-..--$endif$-$for(header-includes)$-$header-includes$--$endfor$-$body$-$for(include-after)$--$include-after$-$endfor$
@@ -1,27 +0,0 @@-{\rtf1\ansi\deff0{\fonttbl{\f0 \fswiss Helvetica;}{\f1 Courier;}}-{\colortbl;\red255\green0\blue0;\red0\green0\blue255;}-\widowctrl\hyphauto-$for(header-includes)$-$header-includes$-$endfor$--$if(title)$-{\pard \qc \f0 \sa180 \li0 \fi0 \b \fs36 $title$\par}-$endif$-$for(author)$-{\pard \qc \f0 \sa180 \li0 \fi0 $author$\par}-$endfor$-$if(date)$-{\pard \qc \f0 \sa180 \li0 \fi0 $date$\par}-$endif$-$if(spacer)$-{\pard \ql \f0 \sa180 \li0 \fi0 \par}-$endif$-$for(include-before)$-$include-before$-$endfor$-$body$-$for(include-after)$-$include-after$-$endfor$-}
@@ -1,66 +0,0 @@-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">-<html xmlns="http://www.w3.org/1999/xhtml">-<head>- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />- <meta http-equiv="Content-Style-Type" content="text/css" />- <meta name="generator" content="pandoc" />-$for(author-meta)$- <meta name="author" content="$author-meta$" />-$endfor$-$if(date-meta)$- <meta name="date" content="$date-meta$" />-$endif$- <title>$if(title-prefix)$$title-prefix$ - $endif$$if(pagetitle)$$pagetitle$$endif$</title>- <!-- configuration parameters -->- <meta name="defaultView" content="slideshow" />- <meta name="controlVis" content="hidden" />-$if(highlighting-css)$- <style type="text/css">-$highlighting-css$- </style>-$endif$-$for(css)$- <link rel="stylesheet" href="$css$" type="text/css" />-$endfor$- <!-- style sheet links -->- <link rel="stylesheet" href="$s5-url$/slides.css" type="text/css" media="projection" id="slideProj" />- <link rel="stylesheet" href="$s5-url$/outline.css" type="text/css" media="screen" id="outlineStyle" />- <link rel="stylesheet" href="$s5-url$/print.css" type="text/css" media="print" id="slidePrint" />- <link rel="stylesheet" href="$s5-url$/opera.css" type="text/css" media="projection" id="operaFix" />- <!-- S5 JS -->- <script src="$s5-url$/slides.js" type="text/javascript"></script>-$if(math)$- $math$-$endif$-$for(header-includes)$- $header-includes$-$endfor$-</head>-<body>-$for(include-before)$-$include-before$-$endfor$-<div class="layout">-<div id="controls"></div>-<div id="currentSlide"></div>-<div id="header"></div>-<div id="footer">- <h1>$date$</h1>- <h2>$title$</h2>-</div>-</div>-<div class="presentation">-$if(title)$-<div class="titleslide slide">- <h1>$title$</h1>- <h2>$for(author)$$author$$sep$<br/>$endfor$</h2>- <h3>$date$</h3>-</div>-$endif$-$body$-$for(include-after)$-$include-after$-$endfor$-</div>-</body>-</html>
@@ -1,75 +0,0 @@-<?xml version="1.0" encoding="utf-8"?>-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">-<html xmlns="http://www.w3.org/1999/xhtml"$if(lang)$ lang="$lang$" xml:lang="$lang$"$endif$>-<head>- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />- <meta http-equiv="Content-Style-Type" content="text/css" />- <meta name="generator" content="pandoc" />-$for(author-meta)$- <meta name="author" content="$author-meta$" />-$endfor$-$if(date-meta)$- <meta name="date" content="$date-meta$" />-$endif$- <title>$if(title-prefix)$$title-prefix$ - $endif$$if(pagetitle)$$pagetitle$$endif$</title>-$if(highlighting-css)$- <style type="text/css">-$highlighting-css$- </style>-$endif$- <link rel="stylesheet" type="text/css" media="screen, projection, print"- href="$slideous-url$/slideous.css" />-$for(css)$- <link rel="stylesheet" type="text/css" media="screen, projection, print"- href="$css$" />-$endfor$-$if(math)$- $math$-$endif$-$for(header-includes)$- $header-includes$-$endfor$- <script src="$slideous-url$/slideous.js"- charset="utf-8" type="text/javascript"></script>-$if(duration)$- <meta name="duration" content="$duration$" />-$endif$-</head>-<body>-$for(include-before)$-$include-before$-$endfor$-<div id="statusbar">-<span style="float:right;">-<span style="margin-right:4em;font-weight:bold;"><span id="slideidx"></span> of {$$slidecount}</span>-<button id="homebutton" title="first slide">1</button>-<button id="prevslidebutton" title="previous slide">«</button>-<button id="previtembutton" title="previous item">‹</button>-<button id="nextitembutton" title="next item">›</button>-<button id="nextslidebutton" title="next slide">»</button>-<button id="endbutton" title="last slide">{$$slidecount}</button>-<button id="incfontbutton" title="content">A+</button>-<button id="decfontbutton" title="first slide">A-</button>-<select id="tocbox" size="1"><option></option></select>-</span>-<span id="eos">½</span>-<span title="{$$location}, {$$date}">{$$title}, {$$author}</span>-</div>-$if(title)$-<div class="slide titlepage">- <h1 class="title">$title$</h1>- <p class="author">-$for(author)$$author$$sep$<br/>$endfor$- </p>-$if(date)$- <p class="date">$date$</p>-$endif$-</div>-$endif$-$body$-$for(include-after)$-$include-after$-$endfor$-</body>-</html>
@@ -1,59 +0,0 @@-<?xml version="1.0" encoding="utf-8"?>-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">-<html xmlns="http://www.w3.org/1999/xhtml"$if(lang)$ lang="$lang$" xml:lang="$lang$"$endif$>-<head>- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />- <meta http-equiv="Content-Style-Type" content="text/css" />- <meta name="generator" content="pandoc" />-$for(author-meta)$- <meta name="author" content="$author-meta$" />-$endfor$-$if(date-meta)$- <meta name="date" content="$date-meta$" />-$endif$- <title>$if(title-prefix)$$title-prefix$ - $endif$$if(pagetitle)$$pagetitle$$endif$</title>-$if(highlighting-css)$- <style type="text/css">-$highlighting-css$- </style>-$endif$- <link rel="stylesheet" type="text/css" media="screen, projection, print"- href="$slidy-url$/styles/slidy.css" />-$for(css)$- <link rel="stylesheet" type="text/css" media="screen, projection, print"- href="$css$" />-$endfor$-$if(math)$- $math$-$endif$-$for(header-includes)$- $header-includes$-$endfor$- <script src="$slidy-url$/scripts/slidy.js.gz"- charset="utf-8" type="text/javascript"></script>-$if(duration)$- <meta name="duration" content="$duration$" />-$endif$-</head>-<body>-$for(include-before)$-$include-before$-$endfor$-$if(title)$-<div class="slide titlepage">- <h1 class="title">$title$</h1>- <p class="author">-$for(author)$$author$$sep$<br/>$endfor$- </p>-$if(date)$- <p class="date">$date$</p>-$endif$-</div>-$endif$-$body$-$for(include-after)$-$include-after$-$endfor$-</body>-</html>
@@ -1,64 +0,0 @@-\input texinfo-@documentencoding UTF-8-$for(header-includes)$-$header-includes$-$endfor$--$if(strikeout)$-@macro textstrikeout{text}-~~\text\~~-@end macro--$endif$-$if(subscript)$-@macro textsubscript{text}-@iftex-@textsubscript{\text\}-@end iftex-@ifnottex-_@{\text\@}-@end ifnottex-@end macro--$endif$-$if(superscript)$-@macro textsuperscript{text}-@iftex-@textsuperscript{\text\}-@end iftex-@ifnottex-^@{\text\@}-@end ifnottex-@end macro--$endif$-@ifnottex-@paragraphindent 0-@end ifnottex-$if(titlepage)$-@titlepage-@title $title$-$for(author)$-@author $author$-$endfor$-$if(date)$-$date$-$endif$-@end titlepage--$endif$-$for(include-before)$-$include-before$--$endfor$-$if(toc)$-@contents--$endif$-$body$-$for(include-after)$--$include-after$-$endfor$--@bye
@@ -1,9 +0,0 @@-$for(include-before)$-$include-before$--$endfor$-$body$-$for(include-after)$--$include-after$-$endfor$
@@ -1,14 +0,0 @@-<?xml version="1.0" encoding="UTF-8"?>-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">-<html xmlns="http://www.w3.org/1999/xhtml">-<head>-<title>$title$</title>-<style type="text/css">img{ max-width: 100%; }</style>-<link href="stylesheet.css" type="text/css" rel="stylesheet" />-</head>-<body>-<div id="cover-image">-<img src="$coverimage$" alt="$title$" />-</div>-</body>-</html>
@@ -1,18 +0,0 @@-<?xml version="1.0" encoding="UTF-8"?>-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">-<html xmlns="http://www.w3.org/1999/xhtml">-<head>-<title>$title$</title>-<link href="stylesheet.css" type="text/css" rel="stylesheet" />-</head>-<body>-<h1>$title$</h1>-$if(toc)$-<div id="$idprefix$TOC">-$toc$-</div>-$endif$-$body$-</body>-</html>-
@@ -1,22 +0,0 @@-<?xml version="1.0" encoding="UTF-8"?>-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">-<html xmlns="http://www.w3.org/1999/xhtml">-<head>-<title>$title$</title>-<link href="stylesheet.css" type="text/css" rel="stylesheet" />-</head>-<body>-<h1 class="title">$title$</h1>-$for(author)$-<h2 class="author">$author$</h2>-$endfor$-$if(date)$-<h3 class="date">$date$</h3>-$endif$-$if(toc)$-<div id="$idprefix$TOC">-$toc$-</div>-$endif$-</body>-</html>
@@ -81,7 +81,7 @@ ]) , (5, do x1 <- choose (1 :: Int, 6) x2 <- arbInlines (n-1)- return (Header x1 x2))+ return (Header x1 nullAttr x2)) , (2, return HorizontalRule) ] ++ [x | x <- nesters, n > 0] where nesters = [ (5, liftM BlockQuote $ listOf1 $ arbBlock (n-1))
@@ -17,19 +17,20 @@ import Test.Framework.Providers.HUnit import Test.Framework.Providers.QuickCheck2 import Test.HUnit (assertBool)-import Text.Pandoc.Shared (normalize, defaultWriterOptions,- WriterOptions(..), removeTrailingSpace)+import Text.Pandoc.Shared (normalize, trimr)+import Text.Pandoc.Options import Text.Pandoc.Writers.Native (writeNative) import Language.Haskell.TH.Quote (QuasiQuoter(..)) import Language.Haskell.TH.Syntax (Q, runIO) import qualified Test.QuickCheck.Property as QP-import System.Console.ANSI import Data.Algorithm.Diff lit :: QuasiQuoter lit = QuasiQuoter { quoteExp = (\a -> let b = rnl a in [|b|]) . filter (/= '\r')- , quotePat = error "Cannot use lit as a pattern"+ , quotePat = error "Unimplemented"+ , quoteType = error "Unimplemented"+ , quoteDec = error "Unimplemented" } where rnl ('\n':xs) = xs rnl xs = xs@@ -40,7 +41,8 @@ -- adapted from TH 2.5 code quoteFile :: QuasiQuoter -> QuasiQuoter quoteFile (QuasiQuoter { quoteExp = qe, quotePat = qp }) =- QuasiQuoter { quoteExp = get qe, quotePat = get qp }+ QuasiQuoter { quoteExp = get qe, quotePat = get qp,+ quoteType = error "Unimplemented", quoteDec = error "Unimplemented" } where get :: (String -> Q a) -> String -> Q a get old_quoter file_name = do { file_cts <- runIO (readFile file_name)@@ -54,25 +56,21 @@ test fn name (input, expected) = testCase name $ assertBool msg (actual' == expected') where msg = nl ++ dashes "input" ++ nl ++ input' ++ nl ++- dashes "expected" ++ nl ++ expected'' ++- dashes "got" ++ nl ++ actual'' +++ dashes "result" ++ nl +++ unlines (map vividize diff) ++ dashes "" nl = "\n" input' = toString input- actual' = toString $ fn input- expected' = toString expected- diff = getDiff (lines expected') (lines actual')- expected'' = unlines $ map vividize $ filter (\(d,_) -> d /= S) diff- actual'' = unlines $ map vividize $ filter (\(d,_) -> d /= F) diff+ actual' = lines $ toString $ fn input+ expected' = lines $ toString expected+ diff = getDiff expected' actual' dashes "" = replicate 72 '-' dashes x = replicate (72 - length x - 5) '-' ++ " " ++ x ++ " ---" -vividize :: (DI,String) -> String-vividize (B,s) = s-vividize (F,s) = s-vividize (S,s) = setSGRCode [SetColor Background Dull Red- , SetColor Foreground Vivid White] ++ s- ++ setSGRCode [Reset]+vividize :: Diff String -> String+vividize (Both s _) = " " ++ s+vividize (First s) = "- " ++ s+vividize (Second s) = "+ " ++ s property :: QP.Testable a => TestName -> a -> Test property = testProperty@@ -85,18 +83,16 @@ toString :: a -> String instance ToString Pandoc where- toString d = writeNative defaultWriterOptions{ writerStandalone = s }- $ toPandoc d+ toString d = writeNative def{ writerStandalone = s } $ toPandoc d where s = case d of (Pandoc (Meta [] [] []) _) -> False _ -> True instance ToString Blocks where- toString = writeNative defaultWriterOptions . toPandoc+ toString = writeNative def . toPandoc instance ToString Inlines where- toString = removeTrailingSpace . writeNative defaultWriterOptions .- toPandoc+ toString = trimr . writeNative def . toPandoc instance ToString String where toString = id
@@ -10,23 +10,24 @@ import System.Directory import System.Exit import Data.Algorithm.Diff-import Text.Pandoc.Shared ( normalize, defaultWriterOptions )+import Text.Pandoc.Shared ( normalize )+import Text.Pandoc.Options import Text.Pandoc.Writers.Native ( writeNative ) import Text.Pandoc.Readers.Native ( readNative ) import Prelude hiding ( readFile ) import qualified Data.ByteString.Lazy as B-import Data.ByteString.Lazy.UTF8 (toString)+import Text.Pandoc.UTF8 (toStringLazy) import Text.Printf readFileUTF8 :: FilePath -> IO String-readFileUTF8 f = B.readFile f >>= return . toString+readFileUTF8 f = B.readFile f >>= return . toStringLazy pandocPath :: FilePath pandocPath = ".." </> "dist" </> "build" </> "pandoc" </> "pandoc" data TestResult = TestPassed | TestError ExitCode- | TestFailed String FilePath [(DI, String)]+ | TestFailed String FilePath [Diff String] deriving (Eq) instance Show TestResult where@@ -38,13 +39,13 @@ dash where dash = replicate 72 '-' -showDiff :: (Int,Int) -> [(DI, String)] -> String+showDiff :: (Int,Int) -> [Diff String] -> String showDiff _ [] = ""-showDiff (l,r) ((F, ln) : ds) =+showDiff (l,r) (First ln : ds) = printf "+%4d " l ++ ln ++ "\n" ++ showDiff (l+1,r) ds-showDiff (l,r) ((S, ln) : ds) =+showDiff (l,r) (Second ln : ds) = printf "-%4d " r ++ ln ++ "\n" ++ showDiff (l,r+1) ds-showDiff (l,r) ((B, _ ) : ds) =+showDiff (l,r) (Both _ _ : ds) = showDiff (l+1,r+1) ds tests :: [Test]@@ -56,6 +57,8 @@ "testsuite.txt" "testsuite.native" , test "tables" ["-r", "markdown", "-w", "native", "--columns=80"] "tables.txt" "tables.native"+ , test "pipe tables" ["-r", "markdown", "-w", "native", "--columns=80"]+ "pipe-tables.txt" "pipe-tables.native" , test "more" ["-r", "markdown", "-w", "native", "-S"] "markdown-reader-more.txt" "markdown-reader-more.native" , lhsReaderTest "markdown+lhs"@@ -107,9 +110,23 @@ , test "reader" ["-r", "native", "-w", "native", "-s"] "testsuite.native" "testsuite.native" ]+ , testGroup "fb2"+ [ fb2WriterTest "basic" [] "fb2.basic.markdown" "fb2.basic.fb2"+ , fb2WriterTest "titles" [] "fb2.titles.markdown" "fb2.titles.fb2"+ , fb2WriterTest "images" [] "fb2.images.markdown" "fb2.images.fb2"+ , fb2WriterTest "images-embedded" [] "fb2.images-embedded.html" "fb2.images-embedded.fb2"+ , fb2WriterTest "tables" [] "tables.native" "tables.fb2"+ , fb2WriterTest "math" [] "fb2.math.markdown" "fb2.math.fb2"+ , fb2WriterTest "testsuite" [] "testsuite.native" "writer.fb2"+ ]+ , testGroup "mediawiki"+ [ testGroup "writer" $ writerTests "mediawiki"+ , test "reader" ["-r", "mediawiki", "-w", "native", "-s"]+ "mediawiki-reader.wiki" "mediawiki-reader.native"+ ] , testGroup "other writers" $ map (\f -> testGroup f $ writerTests f) [ "opendocument" , "context" , "texinfo"- , "man" , "plain" , "mediawiki", "rtf", "org", "asciidoc"+ , "man" , "plain" , "rtf", "org", "asciidoc" ] ] @@ -130,8 +147,11 @@ lhsReaderTest :: String -> Test lhsReaderTest format = testWithNormalize normalizer "lhs" ["-r", format, "-w", "native"]- ("lhs-test" <.> format) "lhs-test.native"- where normalizer = writeNative defaultWriterOptions . normalize . readNative+ ("lhs-test" <.> format) norm+ where normalizer = writeNative def . normalize . readNative+ norm = if format == "markdown+lhs"+ then "lhs-test-markdown.native"+ else "lhs-test.native" writerTests :: String -> [Test] writerTests format@@ -142,14 +162,27 @@ opts = ["-r", "native", "-w", format, "--columns=78"] s5WriterTest :: String -> [String] -> String -> Test-s5WriterTest modifier opts format +s5WriterTest modifier opts format = test (format ++ " writer (" ++ modifier ++ ")")- (["-r", "native", "-w", format] ++ opts) + (["-r", "native", "-w", format] ++ opts) "s5.native" ("s5." ++ modifier <.> "html") +fb2WriterTest :: String -> [String] -> String -> String -> Test+fb2WriterTest title opts inputfile normfile =+ testWithNormalize (ignoreBinary . formatXML)+ title (["-t", "fb2"]++opts) inputfile normfile+ where+ formatXML xml = splitTags $ zip xml (drop 1 xml)+ splitTags [] = []+ splitTags [end] = fst end : snd end : []+ splitTags (('>','<'):rest) = ">\n" ++ splitTags rest+ splitTags ((c,_):rest) = c : splitTags rest+ ignoreBinary = unlines . filter (not . startsWith "<binary ") . lines+ startsWith tag str = all (uncurry (==)) $ zip tag str+ markdownCitationTests :: [Test] markdownCitationTests- = map styleToTest ["chicago-author-date","ieee","mhra"] + = map styleToTest ["chicago-author-date","ieee","mhra"] ++ [test "natbib" wopts "markdown-citations.txt" "markdown-citations.txt"] where@@ -179,10 +212,10 @@ (outputPath, hOut) <- openTempFile "" "pandoc-test" let inpPath = inp let normPath = norm- let options = ["--data-dir", ".."] ++ [inpPath] ++ opts+ let options = ["--data-dir", ".." </> "data"] ++ [inpPath] ++ opts let cmd = pandocPath ++ " " ++ unwords options ph <- runProcess pandocPath options Nothing- (Just [("LANG","en_US.UTF-8"),("HOME", "./")]) Nothing (Just hOut)+ (Just [("TMP","."),("LANG","en_US.UTF-8"),("HOME", "./")]) Nothing (Just hOut) (Just stderr) ec <- waitForProcess ph result <- if ec == ExitSuccess
@@ -9,7 +9,7 @@ import Text.Pandoc latex :: String -> Pandoc-latex = readLaTeX defaultParserState+latex = readLaTeX def infix 4 =: (=:) :: ToString c@@ -67,7 +67,8 @@ , citationSuffix = [] , citationMode = AuthorInText , citationNoteNum = 0- , citationHash = 0 }+ , citationHash = 0+ } rt :: String -> Inlines rt = rawInline "latex"
@@ -6,27 +6,117 @@ import Tests.Helpers import Tests.Arbitrary() import Text.Pandoc.Builder+import qualified Data.Set as Set -- import Text.Pandoc.Shared ( normalize ) import Text.Pandoc markdown :: String -> Pandoc-markdown = readMarkdown defaultParserState{ stateStandalone = True }+markdown = readMarkdown def markdownSmart :: String -> Pandoc-markdownSmart = readMarkdown defaultParserState{ stateSmart = True }+markdownSmart = readMarkdown def { readerSmart = True } infix 4 =: (=:) :: ToString c => String -> (String, c) -> Test (=:) = test markdown +testBareLink :: (String, Inlines) -> Test+testBareLink (inp, ils) =+ test (readMarkdown def{ readerExtensions =+ Set.fromList [Ext_autolink_bare_uris] })+ inp (inp, doc $ para ils)++autolink :: String -> Inlines+autolink s = link s "" (str s)++bareLinkTests :: [(String, Inlines)]+bareLinkTests =+ [ ("http://google.com is a search engine.",+ autolink "http://google.com" <> " is a search engine.")+ , ("Try this query: http://google.com?search=fish&time=hour.",+ "Try this query: " <> autolink "http://google.com?search=fish&time=hour" <> ".")+ , ("HTTPS://GOOGLE.COM,",+ autolink "HTTPS://GOOGLE.COM" <> ",")+ , ("http://el.wikipedia.org/wiki/Τεχνολογία,",+ autolink "http://el.wikipedia.org/wiki/Τεχνολογία" <> ",")+ , ("doi:10.1000/182,",+ autolink "doi:10.1000/182" <> ",")+ , ("git://github.com/foo/bar.git,",+ autolink "git://github.com/foo/bar.git" <> ",")+ , ("file:///Users/joe/joe.txt, and",+ autolink "file:///Users/joe/joe.txt" <> ", and")+ , ("mailto:someone@somedomain.com.",+ autolink "mailto:someone@somedomain.com" <> ".")+ , ("Use http: this is not a link!",+ "Use http: this is not a link!")+ , ("(http://google.com).",+ "(" <> autolink "http://google.com" <> ").")+ , ("http://en.wikipedia.org/wiki/Sprite_(computer_graphics)",+ autolink "http://en.wikipedia.org/wiki/Sprite_(computer_graphics)")+ , ("http://en.wikipedia.org/wiki/Sprite_[computer_graphics]",+ autolink "http://en.wikipedia.org/wiki/Sprite_[computer_graphics]")+ , ("http://en.wikipedia.org/wiki/Sprite_{computer_graphics}",+ autolink "http://en.wikipedia.org/wiki/Sprite_{computer_graphics}")+ , ("http://example.com/Notification_Center-GitHub-20101108-140050.jpg",+ autolink "http://example.com/Notification_Center-GitHub-20101108-140050.jpg")+ , ("https://github.com/github/hubot/blob/master/scripts/cream.js#L20-20",+ autolink "https://github.com/github/hubot/blob/master/scripts/cream.js#L20-20")+ , ("http://www.rubyonrails.com",+ autolink "http://www.rubyonrails.com")+ , ("http://www.rubyonrails.com:80",+ autolink "http://www.rubyonrails.com:80")+ , ("http://www.rubyonrails.com/~minam",+ autolink "http://www.rubyonrails.com/~minam")+ , ("https://www.rubyonrails.com/~minam",+ autolink "https://www.rubyonrails.com/~minam")+ , ("http://www.rubyonrails.com/~minam/url%20with%20spaces",+ autolink "http://www.rubyonrails.com/~minam/url%20with%20spaces")+ , ("http://www.rubyonrails.com/foo.cgi?something=here",+ autolink "http://www.rubyonrails.com/foo.cgi?something=here")+ , ("http://www.rubyonrails.com/foo.cgi?something=here&and=here",+ autolink "http://www.rubyonrails.com/foo.cgi?something=here&and=here")+ , ("http://www.rubyonrails.com/contact;new",+ autolink "http://www.rubyonrails.com/contact;new")+ , ("http://www.rubyonrails.com/contact;new%20with%20spaces",+ autolink "http://www.rubyonrails.com/contact;new%20with%20spaces")+ , ("http://www.rubyonrails.com/contact;new?with=query&string=params",+ autolink "http://www.rubyonrails.com/contact;new?with=query&string=params")+ , ("http://www.rubyonrails.com/~minam/contact;new?with=query&string=params",+ autolink "http://www.rubyonrails.com/~minam/contact;new?with=query&string=params")+ , ("http://en.wikipedia.org/wiki/Wikipedia:Today%27s_featured_picture_%28animation%29/January_20%2C_2007",+ autolink "http://en.wikipedia.org/wiki/Wikipedia:Today%27s_featured_picture_%28animation%29/January_20%2C_2007")+ , ("http://www.mail-archive.com/rails@lists.rubyonrails.org/",+ autolink "http://www.mail-archive.com/rails@lists.rubyonrails.org/")+ , ("http://www.amazon.com/Testing-Equal-Sign-In-Path/ref=pd_bbs_sr_1?ie=UTF8&s=books&qid=1198861734&sr=8-1",+ autolink "http://www.amazon.com/Testing-Equal-Sign-In-Path/ref=pd_bbs_sr_1?ie=UTF8&s=books&qid=1198861734&sr=8-1")+ , ("http://en.wikipedia.org/wiki/Texas_hold%27em",+ autolink "http://en.wikipedia.org/wiki/Texas_hold%27em")+ , ("https://www.google.com/doku.php?id=gps:resource:scs:start",+ autolink "https://www.google.com/doku.php?id=gps:resource:scs:start")+ , ("http://www.rubyonrails.com",+ autolink "http://www.rubyonrails.com")+ , ("http://manuals.ruby-on-rails.com/read/chapter.need_a-period/103#page281",+ autolink "http://manuals.ruby-on-rails.com/read/chapter.need_a-period/103#page281")+ , ("http://foo.example.com/controller/action?parm=value&p2=v2#anchor123",+ autolink "http://foo.example.com/controller/action?parm=value&p2=v2#anchor123")+ , ("http://foo.example.com:3000/controller/action",+ autolink "http://foo.example.com:3000/controller/action")+ , ("http://foo.example.com:3000/controller/action+pack",+ autolink "http://foo.example.com:3000/controller/action+pack")+ , ("http://business.timesonline.co.uk/article/0,,9065-2473189,00.html",+ autolink "http://business.timesonline.co.uk/article/0,,9065-2473189,00.html")+ , ("http://www.mail-archive.com/ruby-talk@ruby-lang.org/",+ autolink "http://www.mail-archive.com/ruby-talk@ruby-lang.org/")+ ]+ {- p_markdown_round_trip :: Block -> Bool p_markdown_round_trip b = matches d' d'' where d' = normalize $ Pandoc (Meta [] [] []) [b] d'' = normalize- $ readMarkdown defaultParserState{ stateSmart = True }- $ writeMarkdown defaultWriterOptions d'+ $ readMarkdown def { readerSmart = True }+ $ writeMarkdown def d' matches (Pandoc _ [Plain []]) (Pandoc _ []) = True matches (Pandoc _ [Para []]) (Pandoc _ []) = True matches (Pandoc _ [Plain xs]) (Pandoc _ [Para xs']) = xs == xs'@@ -43,6 +133,12 @@ "`*` {.haskell .special x=\"7\"}" =?> para (codeWith ("",["haskell","special"],[("x","7")]) "*") ]+ , testGroup "raw LaTeX"+ [ "in URL" =:+ "\\begin\n" =?> para (text "\\begin")+ ]+ , "unbalanced brackets" =:+ "[[[[[[[[[[[[[[[hi" =?> para (text "[[[[[[[[[[[[[[[hi") , testGroup "backslash escapes" [ "in URL" =: "[hi](/there\\))"@@ -57,6 +153,8 @@ "[hi]\n\n[hi]: /there\\.0" =?> para (link "/there.0" "" "hi") ]+ , testGroup "bare URIs"+ (map testBareLink bareLinkTests) , testGroup "smart punctuation" [ test markdownSmart "quote before ellipses" ("'...hi'"@@ -91,7 +189,8 @@ =?> para (note (para "See [^1]")) ] , testGroup "lhs"- [ test (readMarkdown defaultParserState{stateLiterateHaskell = True})+ [ test (readMarkdown def{ readerExtensions = Set.insert+ Ext_literate_haskell $ readerExtensions def }) "inverse bird tracks and html" $ "> a\n\n< b\n\n<div>\n" =?> codeBlockWith ("",["sourceCode","literate","haskell"],[]) "a"
@@ -9,7 +9,7 @@ import Text.Pandoc rst :: String -> Pandoc-rst = readRST defaultParserState{ stateStandalone = True }+rst = readRST def infix 4 =: (=:) :: ToString c@@ -18,8 +18,8 @@ tests :: [Test] tests = [ "line block with blank line" =:- "| a\n|\n| b" =?> para (str "a" <> linebreak <>- linebreak <> str " " <> str "b")+ "| a\n|\n| b" =?> para (str "a") <>+ para (str "\160b") , "field list" =: [_LIT| :Hostname: media08
@@ -8,11 +8,10 @@ import Tests.Arbitrary() context :: (ToString a, ToPandoc a) => a -> String-context = writeConTeXt defaultWriterOptions . toPandoc+context = writeConTeXt def . toPandoc context' :: (ToString a, ToPandoc a) => a -> String-context' = writeConTeXt defaultWriterOptions{ writerWrapText = False }- . toPandoc+context' = writeConTeXt def{ writerWrapText = False } . toPandoc {- "my test" =: X =?> Y@@ -43,23 +42,24 @@ ] , testGroup "headers" [ "level 1" =:- header 1 "My header" =?> "\\section[my-header]{My header}"+ headerWith ("my-header",[],[]) 1 "My header" =?> "\\section[my-header]{My header}" ] , testGroup "bullet lists" [ "nested" =:- bulletList [plain (text "top")- ,bulletList [plain (text "next")- ,bulletList [plain (text "bot")]]]- =?> [_LIT|-\startitemize+ bulletList [+ plain (text "top")+ <> bulletList [+ plain (text "next")+ <> bulletList [plain (text "bot")]+ ]+ ] =?> [_LIT|+\startitemize[packed] \item top-\item- \startitemize+ \startitemize[packed] \item next- \item- \startitemize+ \startitemize[packed] \item bot \stopitemize
@@ -9,7 +9,7 @@ import Text.Pandoc.Highlighting (languages) -- null if no hl support html :: (ToString a, ToPandoc a) => a -> String-html = writeHtmlString defaultWriterOptions{ writerWrapText = False } . toPandoc+html = writeHtmlString def{ writerWrapText = False } . toPandoc {- "my test" =: X =?> Y
@@ -8,7 +8,7 @@ import Tests.Arbitrary() latex :: (ToString a, ToPandoc a) => a -> String-latex = writeLaTeX defaultWriterOptions . toPandoc+latex = writeLaTeX def . toPandoc {- "my test" =: X =?> Y@@ -31,5 +31,9 @@ tests = [ testGroup "code blocks" [ "in footnotes" =: note (para "hi" <> codeBlock "hi") =?> "\\footnote{hi\n\n\\begin{Verbatim}\nhi\n\\end{Verbatim}\n}"+ ]+ , testGroup "math"+ [ "escape |" =: para (math "\\sigma|_{\\{x\\}}") =?>+ "$\\sigma\\vert _{\\{x\\}}$" ] ]
@@ -8,7 +8,7 @@ import Tests.Arbitrary() markdown :: (ToString a, ToPandoc a) => a -> String-markdown = writeMarkdown defaultWriterOptions . toPandoc+markdown = writeMarkdown def . toPandoc {- "my test" =: X =?> Y
@@ -8,11 +8,11 @@ p_write_rt :: Pandoc -> Bool p_write_rt d =- read (writeNative defaultWriterOptions{ writerStandalone = True } d) == d+ read (writeNative def{ writerStandalone = True } d) == d p_write_blocks_rt :: [Block] -> Bool p_write_blocks_rt bs = length bs > 20 ||- read (writeNative defaultWriterOptions (Pandoc (Meta [] [] []) bs)) ==+ read (writeNative def (Pandoc (Meta [] [] []) bs)) == bs tests :: [Test]
@@ -915,7 +915,7 @@ <title>Autolinks</title> <para> With an ampersand:- <ulink url="http://example.com/?foo=1&bar=2"><literal>http://example.com/?foo=1&bar=2</literal></ulink>+ <ulink url="http://example.com/?foo=1&bar=2">http://example.com/?foo=1&bar=2</ulink> </para> <itemizedlist> <listitem>@@ -925,7 +925,7 @@ </listitem> <listitem> <para>- <ulink url="http://example.com/"><literal>http://example.com/</literal></ulink>+ <ulink url="http://example.com/">http://example.com/</ulink> </para> </listitem> <listitem>@@ -940,7 +940,7 @@ <blockquote> <para> Blockquoted:- <ulink url="http://example.com/"><literal>http://example.com/</literal></ulink>+ <ulink url="http://example.com/">http://example.com/</ulink> </para> </blockquote> <para>
@@ -1,22 +1,22 @@ Pandoc (Meta {docTitle = [Str "Pandoc",Space,Str "Test",Space,Str "Suite"], docAuthors = [[Str "John",Space,Str "MacFarlane"],[Str "Anonymous"]], docDate = [Str "July",Space,Str "17,",Space,Str "2006"]}) [Para [Str "This",Space,Str "is",Space,Str "a",Space,Str "set",Space,Str "of",Space,Str "tests",Space,Str "for",Space,Str "pandoc.",Space,Str "Most",Space,Str "of",Space,Str "them",Space,Str "are",Space,Str "adapted",Space,Str "from",Space,Str "John",Space,Str "Gruber\8217s",Space,Str "markdown",Space,Str "test",Space,Str "suite."]-,Header 1 [Str "Headers"]-,Header 2 [Str "Level",Space,Str "2",Space,Str "with",Space,Str "an",Space,Link [Str "embedded",Space,Str "link"] ("/url","")]-,Header 3 [Str "Level",Space,Str "3",Space,Str "with",Space,Emph [Str "emphasis"]]-,Header 4 [Str "Level",Space,Str "4"]-,Header 5 [Str "Level",Space,Str "5"]+,Header 1 ("",[],[]) [Str "Headers"]+,Header 2 ("",[],[]) [Str "Level",Space,Str "2",Space,Str "with",Space,Str "an",Space,Link [Str "embedded",Space,Str "link"] ("/url","")]+,Header 3 ("",[],[]) [Str "Level",Space,Str "3",Space,Str "with",Space,Emph [Str "emphasis"]]+,Header 4 ("",[],[]) [Str "Level",Space,Str "4"]+,Header 5 ("",[],[]) [Str "Level",Space,Str "5"] ,Para [Str "Hi."]-,Header 1 [Str "Level",Space,Str "1"]-,Header 2 [Str "Level",Space,Str "2",Space,Str "with",Space,Emph [Str "emphasis"]]-,Header 3 [Str "Level",Space,Str "3"]+,Header 1 ("",[],[]) [Str "Level",Space,Str "1"]+,Header 2 ("",[],[]) [Str "Level",Space,Str "2",Space,Str "with",Space,Emph [Str "emphasis"]]+,Header 3 ("",[],[]) [Str "Level",Space,Str "3"] ,Para [Str "with",Space,Str "no",Space,Str "blank",Space,Str "line"]-,Header 2 [Str "Level",Space,Str "2"]+,Header 2 ("",[],[]) [Str "Level",Space,Str "2"] ,Para [Str "with",Space,Str "no",Space,Str "blank",Space,Str "line"]-,Header 1 [Str "Paragraphs"]+,Header 1 ("",[],[]) [Str "Paragraphs"] ,Para [Str "Here\8217s",Space,Str "a",Space,Str "regular",Space,Str "paragraph."] ,Para [Str "In",Space,Str "Markdown",Space,Str "1.0.0",Space,Str "and",Space,Str "earlier.",Space,Str "Version",Space,Str "8.",Space,Str "This",Space,Str "line",Space,Str "turns",Space,Str "into",Space,Str "a",Space,Str "list",Space,Str "item.",Space,Str "Because",Space,Str "a",Space,Str "hard-wrapped",Space,Str "line",Space,Str "in",Space,Str "the",Space,Str "middle",Space,Str "of",Space,Str "a",Space,Str "paragraph",Space,Str "looked",Space,Str "like",Space,Str "a",Space,Str "list",Space,Str "item."] ,Para [Str "Here\8217s",Space,Str "one",Space,Str "with",Space,Str "a",Space,Str "bullet.",Space,Str "*",Space,Str "criminey."]-,Header 1 [Str "Block",Space,Str "Quotes"]+,Header 1 ("",[],[]) [Str "Block",Space,Str "Quotes"] ,Para [Str "E-mail",Space,Str "style:"] ,BlockQuote [Para [Str "This",Space,Str "is",Space,Str "a",Space,Str "block",Space,Str "quote.",Space,Str "It",Space,Str "is",Space,Str "pretty",Space,Str "short."]]@@ -34,13 +34,13 @@ [Para [Str "nested"]]] ,Para [Str "This",Space,Str "should",Space,Str "not",Space,Str "be",Space,Str "a",Space,Str "block",Space,Str "quote:",Space,Str "2",Space,Str ">",Space,Str "1."] ,Para [Str "And",Space,Str "a",Space,Str "following",Space,Str "paragraph."]-,Header 1 [Str "Code",Space,Str "Blocks"]+,Header 1 ("",[],[]) [Str "Code",Space,Str "Blocks"] ,Para [Str "Code:"] ,CodeBlock ("",[],[]) "---- (should be four hyphens)\n\nsub status {\n print \"working\";\n}\n\nthis code block is indented by one tab" ,Para [Str "And:"] ,CodeBlock ("",[],[]) " this code block is indented by two tabs\n\nThese should not be escaped: \\$ \\\\ \\> \\[ \\{"-,Header 1 [Str "Lists"]-,Header 2 [Str "Unordered"]+,Header 1 ("",[],[]) [Str "Lists"]+,Header 2 ("",[],[]) [Str "Unordered"] ,Para [Str "Asterisks",Space,Str "loose:"] ,BulletList [[Para [Str "asterisk",Space,Str "1"]]@@ -56,7 +56,7 @@ [[Para [Str "Minus",Space,Str "1"]] ,[Para [Str "Minus",Space,Str "2"]] ,[Para [Str "Minus",Space,Str "3"]]]-,Header 2 [Str "Ordered"]+,Header 2 ("",[],[]) [Str "Ordered"] ,OrderedList (1,Decimal,DefaultDelim) [[Para [Str "First"]] ,[Para [Str "Second"]]@@ -72,7 +72,7 @@ ,Para [Str "Item",Space,Str "1.",Space,Str "graf",Space,Str "two.",Space,Str "The",Space,Str "quick",Space,Str "brown",Space,Str "fox",Space,Str "jumped",Space,Str "over",Space,Str "the",Space,Str "lazy",Space,Str "dog\8217s",Space,Str "back."]] ,[Para [Str "Item",Space,Str "2."]] ,[Para [Str "Item",Space,Str "3."]]]-,Header 2 [Str "Nested"]+,Header 2 ("",[],[]) [Str "Nested"] ,BulletList [[Para [Str "Tab"] ,BulletList@@ -97,14 +97,14 @@ ,[Para [Str "Fie"]] ,[Para [Str "Foe"]]]] ,[Para [Str "Third"]]]-,Header 2 [Str "Tabs",Space,Str "and",Space,Str "spaces"]+,Header 2 ("",[],[]) [Str "Tabs",Space,Str "and",Space,Str "spaces"] ,BulletList [[Para [Str "this",Space,Str "is",Space,Str "a",Space,Str "list",Space,Str "item",Space,Str "indented",Space,Str "with",Space,Str "tabs"]] ,[Para [Str "this",Space,Str "is",Space,Str "a",Space,Str "list",Space,Str "item",Space,Str "indented",Space,Str "with",Space,Str "spaces"] ,BulletList [[Para [Str "this",Space,Str "is",Space,Str "an",Space,Str "example",Space,Str "list",Space,Str "item",Space,Str "indented",Space,Str "with",Space,Str "tabs"]] ,[Para [Str "this",Space,Str "is",Space,Str "an",Space,Str "example",Space,Str "list",Space,Str "item",Space,Str "indented",Space,Str "with",Space,Str "spaces"]]]]]-,Header 2 [Str "Fancy",Space,Str "list",Space,Str "markers"]+,Header 2 ("",[],[]) [Str "Fancy",Space,Str "list",Space,Str "markers"] ,OrderedList (2,Decimal,DefaultDelim) [[Para [Str "begins",Space,Str "with",Space,Str "2"]] ,[Para [Str "and",Space,Str "now",Space,Str "3"]@@ -133,7 +133,7 @@ ,Para [Str "Should",Space,Str "not",Space,Str "be",Space,Str "a",Space,Str "list",Space,Str "item:"] ,Para [Str "M.A.\160\&2007"] ,Para [Str "B.",Space,Str "Williams"]-,Header 1 [Str "Definition",Space,Str "Lists"]+,Header 1 ("",[],[]) [Str "Definition",Space,Str "Lists"] ,DefinitionList [([Str "apple"], [[Para [Str "red",Space,Str "fruit"]]])@@ -169,7 +169,7 @@ ,OrderedList (1,Decimal,DefaultDelim) [[Para [Str "sublist"]] ,[Para [Str "sublist"]]]]])]-,Header 1 [Str "Inline",Space,Str "Markup"]+,Header 1 ("",[],[]) [Str "Inline",Space,Str "Markup"] ,Para [Str "This",Space,Str "is",Space,Emph [Str "emphasized"],Str ",",Space,Str "and",Space,Str "so",Space,Emph [Str "is",Space,Str "this"],Str "."] ,Para [Str "This",Space,Str "is",Space,Strong [Str "strong"],Str ",",Space,Str "and",Space,Str "so",Space,Strong [Str "is",Space,Str "this"],Str "."] ,Para [Str "An",Space,Emph [Link [Str "emphasized",Space,Str "link"] ("/url","")],Str "."]@@ -182,14 +182,14 @@ ,Para [Str "Superscripts:",Space,Str "a",Superscript [Str "bc"],Str "d",Space,Str "a",Superscript [Emph [Str "hello"]],Space,Str "a",Superscript [Str "hello\160there"],Str "."] ,Para [Str "Subscripts:",Space,Str "H",Subscript [Str "2"],Str "O,",Space,Str "H",Subscript [Str "23"],Str "O,",Space,Str "H",Subscript [Str "many\160of\160them"],Str "O."] ,Para [Str "These",Space,Str "should",Space,Str "not",Space,Str "be",Space,Str "superscripts",Space,Str "or",Space,Str "subscripts,",Space,Str "because",Space,Str "of",Space,Str "the",Space,Str "unescaped",Space,Str "spaces:",Space,Str "a^b",Space,Str "c^d,",Space,Str "a~b",Space,Str "c~d."]-,Header 1 [Str "Smart",Space,Str "quotes,",Space,Str "ellipses,",Space,Str "dashes"]+,Header 1 ("",[],[]) [Str "Smart",Space,Str "quotes,",Space,Str "ellipses,",Space,Str "dashes"] ,Para [Quoted DoubleQuote [Str "Hello,"],Space,Str "said",Space,Str "the",Space,Str "spider.",Space,Quoted DoubleQuote [Quoted SingleQuote [Str "Shelob"],Space,Str "is",Space,Str "my",Space,Str "name."]] ,Para [Quoted DoubleQuote [Str "A"],Str ",",Space,Quoted DoubleQuote [Str "B"],Str ",",Space,Str "and",Space,Quoted DoubleQuote [Str "C"],Space,Str "are",Space,Str "letters."] ,Para [Quoted DoubleQuote [Str "He",Space,Str "said,",Space,Quoted SingleQuote [Str "I",Space,Str "want",Space,Str "to",Space,Str "go."]],Space,Str "Were",Space,Str "you",Space,Str "alive",Space,Str "in",Space,Str "the",Space,Str "70\8217s?"] ,Para [Str "Some",Space,Str "dashes:",Space,Str "one\8212two",Space,Str "\8212",Space,Str "three\8212four",Space,Str "\8212",Space,Str "five."] ,Para [Str "Dashes",Space,Str "between",Space,Str "numbers:",Space,Str "5\8211\&7,",Space,Str "255\8211\&66,",Space,Str "1987\8211\&1999."] ,Para [Str "Ellipses\8230and\8230and\8230."]-,Header 1 [Str "Special",Space,Str "Characters"]+,Header 1 ("",[],[]) [Str "Special",Space,Str "Characters"] ,Para [Str "Here",Space,Str "is",Space,Str "some",Space,Str "unicode:"] ,BulletList [[Para [Str "I",Space,Str "hat:",Space,Str "\206"]]@@ -218,8 +218,8 @@ ,Para [Str "Bang:",Space,Str "!"] ,Para [Str "Plus:",Space,Str "+"] ,Para [Str "Minus:",Space,Str "-"]-,Header 1 [Str "Links"]-,Header 2 [Str "Explicit"]+,Header 1 ("",[],[]) [Str "Links"]+,Header 2 ("",[],[]) [Str "Explicit"] ,Para [Str "Just",Space,Str "a",Space,Link [Str "URL"] ("/url/",""),Str "."] ,Para [Link [Str "URL",Space,Str "and",Space,Str "title"] ("/url/",""),Str "."] ,Para [Link [Str "URL",Space,Str "and",Space,Str "title"] ("/url/",""),Str "."]@@ -227,9 +227,9 @@ ,Para [Link [Str "URL",Space,Str "and",Space,Str "title"] ("/url/","")] ,Para [Link [Str "URL",Space,Str "and",Space,Str "title"] ("/url/","")] ,Para [Link [Str "with_underscore"] ("/url/with_underscore","")]-,Para [Link [Code ("",[],[]) "nobody@nowhere.net"] ("mailto:nobody@nowhere.net","")]+,Para [Link [Str "nobody@nowhere.net"] ("mailto:nobody@nowhere.net","")] ,Para [Link [Str "Empty"] ("",""),Str "."]-,Header 2 [Str "Reference"]+,Header 2 ("",[],[]) [Str "Reference"] ,Para [Str "Foo",Space,Link [Str "bar"] ("/url/",""),Str "."] ,Para [Str "Foo",Space,Link [Str "bar"] ("/url/",""),Str "."] ,Para [Str "Foo",Space,Link [Str "bar"] ("/url/",""),Str "."]@@ -242,34 +242,34 @@ ,CodeBlock ("",[],[]) "[not]: /url" ,Para [Str "Foo",Space,Link [Str "bar"] ("/url/",""),Str "."] ,Para [Str "Foo",Space,Link [Str "biz"] ("/url/",""),Str "."]-,Header 2 [Str "With",Space,Str "ampersands"]+,Header 2 ("",[],[]) [Str "With",Space,Str "ampersands"] ,Para [Str "Here\8217s",Space,Str "a",Space,Link [Str "link",Space,Str "with",Space,Str "an",Space,Str "ampersand",Space,Str "in",Space,Str "the",Space,Str "URL"] ("http://example.com/?foo=1&bar=2",""),Str "."] ,Para [Str "Here\8217s",Space,Str "a",Space,Str "link",Space,Str "with",Space,Str "an",Space,Str "amersand",Space,Str "in",Space,Str "the",Space,Str "link",Space,Str "text:",Space,Link [Str "AT&T"] ("http://att.com/",""),Str "."] ,Para [Str "Here\8217s",Space,Str "an",Space,Link [Str "inline",Space,Str "link"] ("/script?foo=1&bar=2",""),Str "."] ,Para [Str "Here\8217s",Space,Str "an",Space,Link [Str "inline",Space,Str "link",Space,Str "in",Space,Str "pointy",Space,Str "braces"] ("/script?foo=1&bar=2",""),Str "."]-,Header 2 [Str "Autolinks"]-,Para [Str "With",Space,Str "an",Space,Str "ampersand:",Space,Link [Code ("",[],[]) "http://example.com/?foo=1&bar=2"] ("http://example.com/?foo=1&bar=2","")]+,Header 2 ("",[],[]) [Str "Autolinks"]+,Para [Str "With",Space,Str "an",Space,Str "ampersand:",Space,Link [Str "http://example.com/?foo=1&bar=2"] ("http://example.com/?foo=1&bar=2","")] ,BulletList [[Para [Str "In",Space,Str "a",Space,Str "list?"]]- ,[Para [Link [Code ("",[],[]) "http://example.com/"] ("http://example.com/","")]]+ ,[Para [Link [Str "http://example.com/"] ("http://example.com/","")]] ,[Para [Str "It",Space,Str "should."]]]-,Para [Str "An",Space,Str "e-mail",Space,Str "address:",Space,Link [Code ("",[],[]) "nobody@nowhere.net"] ("mailto:nobody@nowhere.net","")]+,Para [Str "An",Space,Str "e-mail",Space,Str "address:",Space,Link [Str "nobody@nowhere.net"] ("mailto:nobody@nowhere.net","")] ,BlockQuote- [Para [Str "Blockquoted:",Space,Link [Code ("",[],[]) "http://example.com/"] ("http://example.com/","")]]+ [Para [Str "Blockquoted:",Space,Link [Str "http://example.com/"] ("http://example.com/","")]] ,Para [Str "Auto-links",Space,Str "should",Space,Str "not",Space,Str "occur",Space,Str "here:",Space,Code ("",[],[]) "<http://example.com/>"] ,CodeBlock ("",[],[]) "or here: <http://example.com/>"-,Header 1 [Str "Images"]+,Header 1 ("",[],[]) [Str "Images"] ,Para [Str "From",Space,Quoted DoubleQuote [Str "Voyage",Space,Str "dans",Space,Str "la",Space,Str "Lune"],Space,Str "by",Space,Str "Georges",Space,Str "Melies",Space,Str "(1902):"] ,Para [Image [Str "lalune"] ("lalune.jpg","")] ,Para [Str "Here",Space,Str "is",Space,Str "a",Space,Str "movie",Space,Image [] ("movie.jpg",""),Space,Str "icon."]-,Header 1 [Str "Footnotes"]+,Header 1 ("",[],[]) [Str "Footnotes"] ,Para [Str "Here",Space,Str "is",Space,Str "a",Space,Str "footnote",Space,Str "reference,",Note [Para [Str "Here",Space,Str "is",Space,Str "the",Space,Str "footnote.",Space,Str "It",Space,Str "can",Space,Str "go",Space,Str "anywhere",Space,Str "after",Space,Str "the",Space,Str "footnote",Space,Str "reference.",Space,Str "It",Space,Str "need",Space,Str "not",Space,Str "be",Space,Str "placed",Space,Str "at",Space,Str "the",Space,Str "end",Space,Str "of",Space,Str "the",Space,Str "document."]],Space,Str "and",Space,Str "another.",Note [Para [Str "Here\8217s",Space,Str "the",Space,Str "long",Space,Str "note.",Space,Str "This",Space,Str "one",Space,Str "contains",Space,Str "multiple",Space,Str "blocks."],Para [Str "Subsequent",Space,Str "blocks",Space,Str "are",Space,Str "indented",Space,Str "to",Space,Str "show",Space,Str "that",Space,Str "they",Space,Str "belong",Space,Str "to",Space,Str "the",Space,Str "footnote",Space,Str "(as",Space,Str "with",Space,Str "list",Space,Str "items)."],CodeBlock ("",[],[]) " { <code> }",Para [Str "If",Space,Str "you",Space,Str "want,",Space,Str "you",Space,Str "can",Space,Str "indent",Space,Str "every",Space,Str "line,",Space,Str "but",Space,Str "you",Space,Str "can",Space,Str "also",Space,Str "be",Space,Str "lazy",Space,Str "and",Space,Str "just",Space,Str "indent",Space,Str "the",Space,Str "first",Space,Str "line",Space,Str "of",Space,Str "each",Space,Str "block."]],Space,Str "This",Space,Str "should",Space,Emph [Str "not"],Space,Str "be",Space,Str "a",Space,Str "footnote",Space,Str "reference,",Space,Str "because",Space,Str "it",Space,Str "contains",Space,Str "a",Space,Str "space.[^my",Space,Str "note]",Space,Str "Here",Space,Str "is",Space,Str "an",Space,Str "inline",Space,Str "note.",Note [Para [Str "This",Space,Str "is",Space,Emph [Str "easier"],Space,Str "to",Space,Str "type.",Space,Str "Inline",Space,Str "notes",Space,Str "may",Space,Str "contain",Space,Link [Str "links"] ("http://google.com",""),Space,Str "and",Space,Code ("",[],[]) "]",Space,Str "verbatim",Space,Str "characters,",Space,Str "as",Space,Str "well",Space,Str "as",Space,Str "[bracketed",Space,Str "text]."]]] ,BlockQuote [Para [Str "Notes",Space,Str "can",Space,Str "go",Space,Str "in",Space,Str "quotes.",Note [Para [Str "In",Space,Str "quote."]]]] ,OrderedList (1,Decimal,DefaultDelim) [[Para [Str "And",Space,Str "in",Space,Str "list",Space,Str "items.",Note [Para [Str "In",Space,Str "list."]]]]] ,Para [Str "This",Space,Str "paragraph",Space,Str "should",Space,Str "not",Space,Str "be",Space,Str "part",Space,Str "of",Space,Str "the",Space,Str "note,",Space,Str "as",Space,Str "it",Space,Str "is",Space,Str "not",Space,Str "indented."]-,Header 1 [Str "Tables"]+,Header 1 ("",[],[]) [Str "Tables"] ,Para [Str "Simple",Space,Str "table",Space,Str "with",Space,Str "caption:"] ,Table [Str "Demonstration",Space,Str "of",Space,Str "simple",Space,Str "table",Space,Str "syntax."] [AlignRight,AlignLeft,AlignCenter,AlignLeft] [0.0,0.0,0.0,0.0] [[Plain [Str "Right"]]
@@ -1,25 +1,25 @@ Pandoc (Meta {docTitle = [Str "Pandoc",Space,Str "Test",Space,Str "Suite"], docAuthors = [], docDate = []}) [Para [Str "This",Space,Str "is",Space,Str "a",Space,Str "set",Space,Str "of",Space,Str "tests",Space,Str "for",Space,Str "pandoc",Str ".",Space,Str "Most",Space,Str "of",Space,Str "them",Space,Str "are",Space,Str "adapted",Space,Str "from",Space,Str "John",Space,Str "Gruber",Str "'",Str "s",Space,Str "markdown",Space,Str "test",Space,Str "suite",Str "."] ,HorizontalRule-,Header 1 [Str "Headers"]-,Header 2 [Str "Level",Space,Str "2",Space,Str "with",Space,Str "an",Space,Link [Str "embedded",Space,Str "link"] ("/url","")]-,Header 3 [Str "Level",Space,Str "3",Space,Str "with",Space,Emph [Str "emphasis"]]-,Header 4 [Str "Level",Space,Str "4"]-,Header 5 [Str "Level",Space,Str "5"]-,Header 1 [Str "Level",Space,Str "1"]-,Header 2 [Str "Level",Space,Str "2",Space,Str "with",Space,Emph [Str "emphasis"]]-,Header 3 [Str "Level",Space,Str "3"]+,Header 1 ("",[],[]) [Str "Headers"]+,Header 2 ("",[],[]) [Str "Level",Space,Str "2",Space,Str "with",Space,Str "an",Space,Link [Str "embedded",Space,Str "link"] ("/url","")]+,Header 3 ("",[],[]) [Str "Level",Space,Str "3",Space,Str "with",Space,Emph [Str "emphasis"]]+,Header 4 ("",[],[]) [Str "Level",Space,Str "4"]+,Header 5 ("",[],[]) [Str "Level",Space,Str "5"]+,Header 1 ("",[],[]) [Str "Level",Space,Str "1"]+,Header 2 ("",[],[]) [Str "Level",Space,Str "2",Space,Str "with",Space,Emph [Str "emphasis"]]+,Header 3 ("",[],[]) [Str "Level",Space,Str "3"] ,Para [Str "with",Space,Str "no",Space,Str "blank",Space,Str "line"]-,Header 2 [Str "Level",Space,Str "2"]+,Header 2 ("",[],[]) [Str "Level",Space,Str "2"] ,Para [Str "with",Space,Str "no",Space,Str "blank",Space,Str "line"] ,HorizontalRule-,Header 1 [Str "Paragraphs"]+,Header 1 ("",[],[]) [Str "Paragraphs"] ,Para [Str "Here",Str "'",Str "s",Space,Str "a",Space,Str "regular",Space,Str "paragraph",Str "."] ,Para [Str "In",Space,Str "Markdown",Space,Str "1",Str ".",Str "0",Str ".",Str "0",Space,Str "and",Space,Str "earlier",Str ".",Space,Str "Version",Space,Str "8",Str ".",Space,Str "This",Space,Str "line",Space,Str "turns",Space,Str "into",Space,Str "a",Space,Str "list",Space,Str "item",Str ".",Space,Str "Because",Space,Str "a",Space,Str "hard",Str "-",Str "wrapped",Space,Str "line",Space,Str "in",Space,Str "the",Space,Str "middle",Space,Str "of",Space,Str "a",Space,Str "paragraph",Space,Str "looked",Space,Str "like",Space,Str "a",Space,Str "list",Space,Str "item",Str "."] ,Para [Str "Here",Str "'",Str "s",Space,Str "one",Space,Str "with",Space,Str "a",Space,Str "bullet",Str ".",Space,Str "*",Space,Str "criminey",Str "."] ,Para [Str "There",Space,Str "should",Space,Str "be",Space,Str "a",Space,Str "hard",Space,Str "line",Space,Str "break",LineBreak,Space,Str "here",Str "."] ,HorizontalRule-,Header 1 [Str "Block",Space,Str "Quotes"]+,Header 1 ("",[],[]) [Str "Block",Space,Str "Quotes"] ,Para [Str "E",Str "-",Str "mail",Space,Str "style:"] ,BlockQuote [Para [Str "This",Space,Str "is",Space,Str "a",Space,Str "block",Space,Str "quote",Str ".",Space,Str "It",Space,Str "is",Space,Str "pretty",Space,Str "short",Str "."]]@@ -51,14 +51,14 @@ [Para [Str "Don",Str "'",Str "t",Space,Str "quote",Space,Str "me",Str "."]]] ,Para [Str "And",Space,Str "a",Space,Str "following",Space,Str "paragraph",Str "."] ,HorizontalRule-,Header 1 [Str "Code",Space,Str "Blocks"]+,Header 1 ("",[],[]) [Str "Code",Space,Str "Blocks"] ,Para [Str "Code:"] ,CodeBlock ("",[],[]) "---- (should be four hyphens)\n\nsub status {\n print \"working\";\n}\n\nthis code block is indented by one tab" ,Para [Str "And:"] ,CodeBlock ("",[],[]) " this code block is indented by two tabs\n\nThese should not be escaped: \\$ \\\\ \\> \\[ \\{" ,HorizontalRule-,Header 1 [Str "Lists"]-,Header 2 [Str "Unordered"]+,Header 1 ("",[],[]) [Str "Lists"]+,Header 2 ("",[],[]) [Str "Unordered"] ,Para [Str "Asterisks",Space,Str "tight:"] ,BulletList [[Plain [Str "asterisk",Space,Str "1"]]@@ -89,7 +89,7 @@ [[Para [Str "Minus",Space,Str "1"]] ,[Para [Str "Minus",Space,Str "2"]] ,[Para [Str "Minus",Space,Str "3"]]]-,Header 2 [Str "Ordered"]+,Header 2 ("",[],[]) [Str "Ordered"] ,Para [Str "Tight:"] ,OrderedList (1,DefaultStyle,DefaultDelim) [[Plain [Str "First"]]@@ -116,7 +116,7 @@ ,Para [Str "Item",Space,Str "1",Str ".",Space,Str "graf",Space,Str "two",Str ".",Space,Str "The",Space,Str "quick",Space,Str "brown",Space,Str "fox",Space,Str "jumped",Space,Str "over",Space,Str "the",Space,Str "lazy",Space,Str "dog",Str "'",Str "s",Space,Str "back",Str "."]] ,[Para [Str "Item",Space,Str "2",Str "."]] ,[Para [Str "Item",Space,Str "3",Str "."]]]-,Header 2 [Str "Nested"]+,Header 2 ("",[],[]) [Str "Nested"] ,BulletList [[Plain [Str "Tab"] ,BulletList@@ -141,14 +141,14 @@ ,[Plain [Str "Fie"]] ,[Plain [Str "Foe"]]]] ,[Para [Str "Third"]]]-,Header 2 [Str "Tabs",Space,Str "and",Space,Str "spaces"]+,Header 2 ("",[],[]) [Str "Tabs",Space,Str "and",Space,Str "spaces"] ,BulletList [[Para [Str "this",Space,Str "is",Space,Str "a",Space,Str "list",Space,Str "item",Space,Str "indented",Space,Str "with",Space,Str "tabs"]] ,[Para [Str "this",Space,Str "is",Space,Str "a",Space,Str "list",Space,Str "item",Space,Str "indented",Space,Str "with",Space,Str "spaces"] ,BulletList [[Para [Str "this",Space,Str "is",Space,Str "an",Space,Str "example",Space,Str "list",Space,Str "item",Space,Str "indented",Space,Str "with",Space,Str "tabs"]] ,[Para [Str "this",Space,Str "is",Space,Str "an",Space,Str "example",Space,Str "list",Space,Str "item",Space,Str "indented",Space,Str "with",Space,Str "spaces"]]]]]-,Header 2 [Str "Fancy",Space,Str "list",Space,Str "markers"]+,Header 2 ("fancy-list-markers",[],[]) [Str "Fancy",Space,Str "list",Space,Str "markers"] ,OrderedList (2,Decimal,DefaultDelim) [[Plain [Str "begins",Space,Str "with",Space,Str "2"]] ,[Para [Str "and",Space,Str "now",Space,Str "3"]@@ -175,7 +175,7 @@ ,OrderedList (1,DefaultStyle,DefaultDelim) [[Plain [Str "Nested",Str "."]]]]] ,HorizontalRule-,Header 2 [Str "Definition"]+,Header 2 ("",[],[]) [Str "Definition"] ,DefinitionList [([Str "Violin"], [[Plain [Str "Stringed",Space,Str "musical",Space,Str "instrument",Str "."]]@@ -183,7 +183,7 @@ ,([Str "Cello",LineBreak,Str "Violoncello"], [[Plain [Str "Low",Str "-",Str "voiced",Space,Str "stringed",Space,Str "instrument",Str "."]]])] ,HorizontalRule-,Header 1 [Str "Inline",Space,Str "Markup"]+,Header 1 ("",[],[]) [Str "Inline",Space,Str "Markup"] ,Para [Str "This",Space,Str "is",Space,Emph [Str "emphasized"],Str ",",Space,Str "and",Space,Str "so",Space,Emph [Str "is",Space,Str "this"],Str "."] ,Para [Str "This",Space,Str "is",Space,Strong [Str "strong"],Str ",",Space,Str "and",Space,Str "so",Space,Strong [Str "is",Space,Str "this"],Str "."] ,Para [Str "An",Space,Emph [Link [Str "emphasized",Space,Str "link"] ("/url","")],Str "."]@@ -193,7 +193,7 @@ ,Para [Str "So",Space,Str "is",Space,Strong [Emph [Str "this"]],Space,Str "word",Str "."] ,Para [Str "This",Space,Str "is",Space,Str "code:",Space,Code ("",[],[]) ">",Str ",",Space,Code ("",[],[]) "$",Str ",",Space,Code ("",[],[]) "\\",Str ",",Space,Code ("",[],[]) "\\$",Str ",",Space,Code ("",[],[]) "<html>",Str "."] ,HorizontalRule-,Header 1 [Str "Smart",Space,Str "quotes,",Space,Str "ellipses,",Space,Str "dashes"]+,Header 1 ("",[],[]) [Str "Smart",Space,Str "quotes,",Space,Str "ellipses,",Space,Str "dashes"] ,Para [Str "\"",Str "Hello,",Str "\"",Space,Str "said",Space,Str "the",Space,Str "spider",Str ".",Space,Str "\"",Str "'",Str "Shelob",Str "'",Space,Str "is",Space,Str "my",Space,Str "name",Str ".",Str "\""] ,Para [Str "'",Str "A",Str "'",Str ",",Space,Str "'",Str "B",Str "'",Str ",",Space,Str "and",Space,Str "'",Str "C",Str "'",Space,Str "are",Space,Str "letters",Str "."] ,Para [Str "'",Str "Oak,",Str "'",Space,Str "'",Str "elm,",Str "'",Space,Str "and",Space,Str "'",Str "beech",Str "'",Space,Str "are",Space,Str "names",Space,Str "of",Space,Str "trees",Str ".",Space,Str "So",Space,Str "is",Space,Str "'",Str "pine",Str ".",Str "'"]@@ -203,7 +203,7 @@ ,Para [Str "Dashes",Space,Str "between",Space,Str "numbers:",Space,Str "5",Str "-",Str "7,",Space,Str "255",Str "-",Str "66,",Space,Str "1987",Str "-",Str "1999",Str "."] ,Para [Str "Ellipses",Str ".",Str ".",Str ".",Str "and",Str ".",Space,Str ".",Space,Str ".",Str "and",Space,Str ".",Space,Str ".",Space,Str ".",Space,Str "."] ,HorizontalRule-,Header 1 [Str "LaTeX"]+,Header 1 ("",[],[]) [Str "LaTeX"] ,BulletList [[Plain [Str "\\cite[22",Str "-",Str "23]{smith",Str ".",Str "1899}"]] ,[Plain [Str "\\doublespacing"]]@@ -222,7 +222,7 @@ ,Para [Str "Here",Str "'",Str "s",Space,Str "a",Space,Str "LaTeX",Space,Str "table:"] ,Para [Str "\\begin{tabular}{|l|l|}\\hline",Space,Str "Animal",Space,Str "&",Space,Str "Number",Space,Str "\\\\",Space,Str "\\hline",Space,Str "Dog",Space,Str "&",Space,Str "2",Space,Str "\\\\",Space,Str "Cat",Space,Str "&",Space,Str "1",Space,Str "\\\\",Space,Str "\\hline",Space,Str "\\end{tabular}"] ,HorizontalRule-,Header 1 [Str "Special",Space,Str "Characters"]+,Header 1 ("",[],[]) [Str "Special",Space,Str "Characters"] ,Para [Str "Here",Space,Str "is",Space,Str "some",Space,Str "unicode:"] ,BulletList [[Plain [Str "I",Space,Str "hat:",Space,Str "\206"]]@@ -252,8 +252,8 @@ ,Para [Str "Plus:",Space,Str "+"] ,Para [Str "Minus:",Space,Str "-"] ,HorizontalRule-,Header 1 [Str "Links"]-,Header 2 [Str "Explicit"]+,Header 1 ("",[],[]) [Str "Links"]+,Header 2 ("",[],[]) [Str "Explicit"] ,Para [Str "Just",Space,Str "a",Space,Link [Str "URL"] ("/url/",""),Str "."] ,Para [Link [Str "URL",Space,Str "and",Space,Str "title"] ("/url/","title"),Str "."] ,Para [Link [Str "URL",Space,Str "and",Space,Str "title"] ("/url/","title preceded by two spaces"),Str "."]@@ -262,7 +262,7 @@ ,Para [Link [Str "URL",Space,Str "and",Space,Str "title"] ("/url/","title with single quotes")] ,Para [Str "Email",Space,Str "link",Space,Str "(nobody",Space,Str "[at]",Space,Str "nowhere",Str ".",Str "net)"] ,Para [Link [Str "Empty"] ("",""),Str "."]-,Header 2 [Str "Reference"]+,Header 2 ("",[],[]) [Str "Reference"] ,Para [Str "Foo",Space,Link [Str "bar"] ("/url/",""),Str "."] ,Para [Str "Foo",Space,Link [Str "bar"] ("/url/",""),Str "."] ,Para [Str "Foo",Space,Link [Str "bar"] ("/url/",""),Str "."]@@ -275,12 +275,12 @@ ,CodeBlock ("",[],[]) "[not]: /url" ,Para [Str "Foo",Space,Link [Str "bar"] ("/url/","Title with \"quotes\" inside"),Str "."] ,Para [Str "Foo",Space,Link [Str "biz"] ("/url/","Title with \"quote\" inside"),Str "."]-,Header 2 [Str "With",Space,Str "ampersands"]+,Header 2 ("",[],[]) [Str "With",Space,Str "ampersands"] ,Para [Str "Here",Str "'",Str "s",Space,Str "a",Space,Link [Str "link",Space,Str "with",Space,Str "an",Space,Str "ampersand",Space,Str "in",Space,Str "the",Space,Str "URL"] ("http://example.com/?foo=1&bar=2",""),Str "."] ,Para [Str "Here",Str "'",Str "s",Space,Str "a",Space,Str "link",Space,Str "with",Space,Str "an",Space,Str "amersand",Space,Str "in",Space,Str "the",Space,Str "link",Space,Str "text:",Space,Link [Str "AT&T"] ("http://att.com/","AT&T"),Str "."] ,Para [Str "Here",Str "'",Str "s",Space,Str "an",Space,Link [Str "inline",Space,Str "link"] ("/script?foo=1&bar=2",""),Str "."] ,Para [Str "Here",Str "'",Str "s",Space,Str "an",Space,Link [Str "inline",Space,Str "link",Space,Str "in",Space,Str "pointy",Space,Str "braces"] ("/script?foo=1&bar=2",""),Str "."]-,Header 2 [Str "Autolinks"]+,Header 2 ("",[],[]) [Str "Autolinks"] ,Para [Str "With",Space,Str "an",Space,Str "ampersand:",Space,Link [Str "http://example",Str ".",Str "com/?foo=1&bar=2"] ("http://example.com/?foo=1&bar=2","")] ,BulletList [[Plain [Str "In",Space,Str "a",Space,Str "list?"]]@@ -292,12 +292,12 @@ ,Para [Str "Auto",Str "-",Str "links",Space,Str "should",Space,Str "not",Space,Str "occur",Space,Str "here:",Space,Code ("",[],[]) "<http://example.com/>"] ,CodeBlock ("",[],[]) "or here: <http://example.com/>" ,HorizontalRule-,Header 1 [Str "Images"]+,Header 1 ("",[],[]) [Str "Images"] ,Para [Str "From",Space,Str "\"",Str "Voyage",Space,Str "dans",Space,Str "la",Space,Str "Lune",Str "\"",Space,Str "by",Space,Str "Georges",Space,Str "Melies",Space,Str "(1902):"] ,Para [Image [Str "lalune"] ("lalune.jpg","Voyage dans la Lune")] ,Para [Str "Here",Space,Str "is",Space,Str "a",Space,Str "movie",Space,Image [Str "movie"] ("movie.jpg",""),Space,Str "icon",Str "."] ,HorizontalRule-,Header 1 [Str "Footnotes"]+,Header 1 ("",[],[]) [Str "Footnotes"] ,Para [Str "Here",Space,Str "is",Space,Str "a",Space,Str "footnote",Space,Str "reference",Link [Str "(1)"] ("#note_1",""),Str ",",Space,Str "and",Space,Str "another",Link [Str "(longnote)"] ("#note_longnote",""),Str ".",Space,Str "This",Space,Str "should",Space,Emph [Str "not"],Space,Str "be",Space,Str "a",Space,Str "footnote",Space,Str "reference,",Space,Str "because",Space,Str "it",Space,Str "contains",Space,Str "a",Space,Str "space^(my",Space,Str "note)",Str "."] ,Para [Link [Str "(1)"] ("#ref_1",""),Space,Str "Here",Space,Str "is",Space,Str "the",Space,Str "footnote",Str ".",Space,Str "It",Space,Str "can",Space,Str "go",Space,Str "anywhere",Space,Str "in",Space,Str "the",Space,Str "document,",Space,Str "not",Space,Str "just",Space,Str "at",Space,Str "the",Space,Str "end",Str "."] ,Para [Link [Str "(longnote)"] ("#ref_longnote",""),Space,Str "Here",Str "'",Str "s",Space,Str "the",Space,Str "other",Space,Str "note",Str ".",Space,Str "This",Space,Str "one",Space,Str "contains",Space,Str "multiple",Space,Str "blocks",Str "."]
@@ -155,6 +155,11 @@ These should not be escaped: \$ \\ \> \[ \{ \end{verbatim}++\begin{obeylines}+this has \emph{two+lines}+\end{obeylines} \begin{center}\rule{3in}{0.4pt}\end{center} \section{Lists}@@ -775,7 +780,7 @@ It should. \end{itemize} An e-mail address:-\href{mailto:nobody@nowhere.net}{\texttt{nobody@nowhere.net}}+\href{mailto:nobody@nowhere.net}{nobody@nowhere.net} \begin{quote} Blockquoted: \url{http://example.com/}
@@ -2,25 +2,25 @@ [RawBlock "latex" "\\maketitle" ,Para [Str "This",Space,Str "is",Space,Str "a",Space,Str "set",Space,Str "of",Space,Str "tests",Space,Str "for",Space,Str "pandoc.",Space,Str "Most",Space,Str "of",Space,Str "them",Space,Str "are",Space,Str "adapted",Space,Str "from",Space,Str "John",Space,Str "Gruber\8217s",Space,Str "markdown",Space,Str "test",Space,Str "suite."] ,HorizontalRule-,Header 1 [Str "Headers"]-,Header 2 [Str "Level",Space,Str "2",Space,Str "with",Space,Str "an",Space,Link [Str "embedded",Space,Str "link"] ("/url","")]-,Header 3 [Str "Level",Space,Str "3",Space,Str "with",Space,Emph [Str "emphasis"]]+,Header 1 ("",[],[]) [Str "Headers"]+,Header 2 ("",[],[]) [Str "Level",Space,Str "2",Space,Str "with",Space,Str "an",Space,Link [Str "embedded",Space,Str "link"] ("/url","")]+,Header 3 ("",[],[]) [Str "Level",Space,Str "3",Space,Str "with",Space,Emph [Str "emphasis"]] ,Para [Str "Level",Space,Str "4"] ,Para [Str "Level",Space,Str "5"]-,Header 1 [Str "Level",Space,Str "1"]-,Header 2 [Str "Level",Space,Str "2",Space,Str "with",Space,Emph [Str "emphasis"]]-,Header 3 [Str "Level",Space,Str "3"]+,Header 1 ("",[],[]) [Str "Level",Space,Str "1"]+,Header 2 ("",[],[]) [Str "Level",Space,Str "2",Space,Str "with",Space,Emph [Str "emphasis"]]+,Header 3 ("",[],[]) [Str "Level",Space,Str "3"] ,Para [Str "with",Space,Str "no",Space,Str "blank",Space,Str "line"]-,Header 2 [Str "Level",Space,Str "2"]+,Header 2 ("",[],[]) [Str "Level",Space,Str "2"] ,Para [Str "with",Space,Str "no",Space,Str "blank",Space,Str "line"] ,HorizontalRule-,Header 1 [Str "Paragraphs"]+,Header 1 ("",[],[]) [Str "Paragraphs"] ,Para [Str "Here\8217s",Space,Str "a",Space,Str "regular",Space,Str "paragraph."] ,Para [Str "In",Space,Str "Markdown",Space,Str "1.0.0",Space,Str "and",Space,Str "earlier.",Space,Str "Version",Space,Str "8.",Space,Str "This",Space,Str "line",Space,Str "turns",Space,Str "into",Space,Str "a",Space,Str "list",Space,Str "item.",Space,Str "Because",Space,Str "a",Space,Str "hard-wrapped",Space,Str "line",Space,Str "in",Space,Str "the",Space,Str "middle",Space,Str "of",Space,Str "a",Space,Str "paragraph",Space,Str "looked",Space,Str "like",Space,Str "a",Space,Str "list",Space,Str "item."] ,Para [Str "Here\8217s",Space,Str "one",Space,Str "with",Space,Str "a",Space,Str "bullet.",Space,Str "*",Space,Str "criminey."] ,Para [Str "There",Space,Str "should",Space,Str "be",Space,Str "a",Space,Str "hard",Space,Str "line",Space,Str "break",LineBreak,Str "here."] ,HorizontalRule-,Header 1 [Str "Block",Space,Str "Quotes"]+,Header 1 ("",[],[]) [Str "Block",Space,Str "Quotes"] ,Para [Str "E-mail",Space,Str "style:"] ,BlockQuote [Para [Str "This",Space,Str "is",Space,Str "a",Space,Str "block",Space,Str "quote.",Space,Str "It",Space,Str "is",Space,Str "pretty",Space,Str "short."]]@@ -52,14 +52,15 @@ [Para [Str "Don\8217t",Space,Str "quote",Space,Str "me."]]] ,Para [Str "And",Space,Str "a",Space,Str "following",Space,Str "paragraph."] ,HorizontalRule-,Header 1 [Str "Code",Space,Str "Blocks"]+,Header 1 ("",[],[]) [Str "Code",Space,Str "Blocks"] ,Para [Str "Code:"] ,CodeBlock ("",[],[]) "---- (should be four hyphens)\n\nsub status {\n print \"working\";\n}\n\nthis code block is indented by one tab" ,Para [Str "And:"] ,CodeBlock ("",[],[]) " this code block is indented by two tabs\n\nThese should not be escaped: \\$ \\\\ \\> \\[ \\{"+,Para [Str "this",Space,Str "has",Space,Emph [Str "two",LineBreak,Str "lines"]] ,HorizontalRule-,Header 1 [Str "Lists"]-,Header 2 [Str "Unordered"]+,Header 1 ("",[],[]) [Str "Lists"]+,Header 2 ("",[],[]) [Str "Unordered"] ,Para [Str "Asterisks",Space,Str "tight:"] ,BulletList [[Para [Str "asterisk",Space,Str "1"]]@@ -90,7 +91,7 @@ [[Para [Str "Minus",Space,Str "1"]] ,[Para [Str "Minus",Space,Str "2"]] ,[Para [Str "Minus",Space,Str "3"]]]-,Header 2 [Str "Ordered"]+,Header 2 ("",[],[]) [Str "Ordered"] ,Para [Str "Tight:"] ,OrderedList (1,Decimal,Period) [[Para [Str "First"]]@@ -117,7 +118,7 @@ ,Para [Str "Item",Space,Str "1.",Space,Str "graf",Space,Str "two.",Space,Str "The",Space,Str "quick",Space,Str "brown",Space,Str "fox",Space,Str "jumped",Space,Str "over",Space,Str "the",Space,Str "lazy",Space,Str "dog\8217s",Space,Str "back."]] ,[Para [Str "Item",Space,Str "2."]] ,[Para [Str "Item",Space,Str "3."]]]-,Header 2 [Str "Nested"]+,Header 2 ("",[],[]) [Str "Nested"] ,BulletList [[Para [Str "Tab"] ,BulletList@@ -142,14 +143,14 @@ ,[Para [Str "Fie"]] ,[Para [Str "Foe"]]]] ,[Para [Str "Third"]]]-,Header 2 [Str "Tabs",Space,Str "and",Space,Str "spaces"]+,Header 2 ("",[],[]) [Str "Tabs",Space,Str "and",Space,Str "spaces"] ,BulletList [[Para [Str "this",Space,Str "is",Space,Str "a",Space,Str "list",Space,Str "item",Space,Str "indented",Space,Str "with",Space,Str "tabs"]] ,[Para [Str "this",Space,Str "is",Space,Str "a",Space,Str "list",Space,Str "item",Space,Str "indented",Space,Str "with",Space,Str "spaces"] ,BulletList [[Para [Str "this",Space,Str "is",Space,Str "an",Space,Str "example",Space,Str "list",Space,Str "item",Space,Str "indented",Space,Str "with",Space,Str "tabs"]] ,[Para [Str "this",Space,Str "is",Space,Str "an",Space,Str "example",Space,Str "list",Space,Str "item",Space,Str "indented",Space,Str "with",Space,Str "spaces"]]]]]-,Header 2 [Str "Fancy",Space,Str "list",Space,Str "markers"]+,Header 2 ("",[],[]) [Str "Fancy",Space,Str "list",Space,Str "markers"] ,OrderedList (2,Decimal,TwoParens) [[Para [Str "begins",Space,Str "with",Space,Str "2"]] ,[Para [Str "and",Space,Str "now",Space,Str "3"]@@ -179,7 +180,7 @@ ,Para [Str "M.A.",Space,Str "2007"] ,Para [Str "B.",Space,Str "Williams"] ,HorizontalRule-,Header 1 [Str "Definition",Space,Str "Lists"]+,Header 1 ("",[],[]) [Str "Definition",Space,Str "Lists"] ,Para [Str "Tight",Space,Str "using",Space,Str "spaces:"] ,DefinitionList [([Str "apple"],@@ -214,7 +215,7 @@ ,CodeBlock ("",[],[]) "{ orange code block }" ,BlockQuote [Para [Str "orange",Space,Str "block",Space,Str "quote"]]]])]-,Header 1 [Str "HTML",Space,Str "Blocks"]+,Header 1 ("",[],[]) [Str "HTML",Space,Str "Blocks"] ,Para [Str "Simple",Space,Str "block",Space,Str "on",Space,Str "one",Space,Str "line:"] ,Para [Str "foo",Space,Str "And",Space,Str "nested",Space,Str "without",Space,Str "indentation:"] ,Para [Str "foo",Space,Str "bar",Space,Str "Interpreted",Space,Str "markdown",Space,Str "in",Space,Str "a",Space,Str "table:"]@@ -233,7 +234,7 @@ ,CodeBlock ("",[],[]) "<hr />" ,Para [Str "Hr\8217s:"] ,HorizontalRule-,Header 1 [Str "Inline",Space,Str "Markup"]+,Header 1 ("",[],[]) [Str "Inline",Space,Str "Markup"] ,Para [Str "This",Space,Str "is",Space,Emph [Str "emphasized"],Str ",",Space,Str "and",Space,Str "so",Space,Emph [Str "is",Space,Str "this"],Str "."] ,Para [Str "This",Space,Str "is",Space,Strong [Str "strong"],Str ",",Space,Str "and",Space,Str "so",Space,Strong [Str "is",Space,Str "this"],Str "."] ,Para [Str "An",Space,Emph [Link [Str "emphasized",Space,Str "link"] ("/url","")],Str "."]@@ -247,7 +248,7 @@ ,Para [Str "Subscripts:",Space,Str "H",Subscript [Str "2"],Str "O,",Space,Str "H",Subscript [Str "23"],Str "O,",Space,Str "H",Subscript [Str "many",Space,Str "of",Space,Str "them"],Str "O."] ,Para [Str "These",Space,Str "should",Space,Str "not",Space,Str "be",Space,Str "superscripts",Space,Str "or",Space,Str "subscripts,",Space,Str "because",Space,Str "of",Space,Str "the",Space,Str "unescaped",Space,Str "spaces:",Space,Str "a^b",Space,Str "c^d,",Space,Str "a",Math InlineMath "\\sim",Str "b",Space,Str "c",Math InlineMath "\\sim",Str "d."] ,HorizontalRule-,Header 1 [Str "Smart",Space,Str "quotes,",Space,Str "ellipses,",Space,Str "dashes"]+,Header 1 ("",[],[]) [Str "Smart",Space,Str "quotes,",Space,Str "ellipses,",Space,Str "dashes"] ,Para [Quoted DoubleQuote [Str "Hello,"],Space,Str "said",Space,Str "the",Space,Str "spider.",Space,Quoted DoubleQuote [Quoted SingleQuote [Str "Shelob"],Space,Str "is",Space,Str "my",Space,Str "name."]] ,Para [Quoted SingleQuote [Str "A"],Str ",",Space,Quoted SingleQuote [Str "B"],Str ",",Space,Str "and",Space,Quoted SingleQuote [Str "C"],Space,Str "are",Space,Str "letters."] ,Para [Quoted SingleQuote [Str "Oak,"],Space,Quoted SingleQuote [Str "elm,"],Space,Str "and",Space,Quoted SingleQuote [Str "beech"],Space,Str "are",Space,Str "names",Space,Str "of",Space,Str "trees.",Space,Str "So",Space,Str "is",Space,Quoted SingleQuote [Str "pine."]]@@ -257,9 +258,9 @@ ,Para [Str "Dashes",Space,Str "between",Space,Str "numbers:",Space,Str "5\8211\&7,",Space,Str "255\8211\&66,",Space,Str "1987\8211\&1999."] ,Para [Str "Ellipses\8230and\8230and\8230."] ,HorizontalRule-,Header 1 [Str "LaTeX"]+,Header 1 ("",[],[]) [Str "LaTeX"] ,BulletList- [[Para [Cite [Citation {citationId = "smith.1899", citationPrefix = [], citationSuffix = [Str ",",Space,Str "22-23"], citationMode = NormalCitation, citationNoteNum = 0, citationHash = 0}] [RawInline "latex" "\\cite[22-23]{smith.1899}"]]]+ [[Para [Cite [Citation {citationId = "smith.1899", citationPrefix = [], citationSuffix = [Str ",",Space,Str "22-23"], citationMode = AuthorInText, citationNoteNum = 0, citationHash = 0}] [RawInline "latex" "\\cite[22-23]{smith.1899}"]]] ,[Para [RawInline "latex" "\\doublespacing"]] ,[Para [Math InlineMath "2+2=4"]] ,[Para [Math InlineMath "x \\in y"]]@@ -287,7 +288,7 @@ [[[Plain [Str "Animal"]]] ,[[Plain [Str "Vegetable"]]]] ,HorizontalRule-,Header 1 [Str "Special",Space,Str "Characters"]+,Header 1 ("",[],[]) [Str "Special",Space,Str "Characters"] ,Para [Str "Here",Space,Str "is",Space,Str "some",Space,Str "unicode:"] ,BulletList [[Para [Str "I",Space,Str "hat:",Space,Str "\206"]]@@ -301,7 +302,7 @@ ,Para [Str "4",Space,Str "<",Space,Str "5."] ,Para [Str "6",Space,Str ">",Space,Str "5."] ,Para [Str "Backslash:",Space,Str "\\"]-,Para [Str "Backtick:",Space,Str "`"]+,Para [Str "Backtick:",Space,Str "\8216"] ,Para [Str "Asterisk:",Space,Str "*"] ,Para [Str "Underscore:",Space,Str "_"] ,Para [Str "Left",Space,Str "brace:",Space,Str "{"]@@ -317,8 +318,8 @@ ,Para [Str "Plus:",Space,Str "+"] ,Para [Str "Minus:",Space,Str "-"] ,HorizontalRule-,Header 1 [Str "Links"]-,Header 2 [Str "Explicit"]+,Header 1 ("",[],[]) [Str "Links"]+,Header 2 ("",[],[]) [Str "Explicit"] ,Para [Str "Just",Space,Str "a",Space,Link [Str "URL"] ("/url/",""),Str "."] ,Para [Link [Str "URL",Space,Str "and",Space,Str "title"] ("/url/",""),Str "."] ,Para [Link [Str "URL",Space,Str "and",Space,Str "title"] ("/url/",""),Str "."]@@ -328,7 +329,7 @@ ,Para [Link [Str "with_underscore"] ("/url/with_underscore","")] ,Para [Link [Str "Email",Space,Str "link"] ("mailto:nobody@nowhere.net","")] ,Para [Link [Str "Empty"] ("",""),Str "."]-,Header 2 [Str "Reference"]+,Header 2 ("",[],[]) [Str "Reference"] ,Para [Str "Foo",Space,Link [Str "bar"] ("/url/",""),Str "."] ,Para [Str "Foo",Space,Link [Str "bar"] ("/url/",""),Str "."] ,Para [Str "Foo",Space,Link [Str "bar"] ("/url/",""),Str "."]@@ -341,29 +342,29 @@ ,CodeBlock ("",[],[]) "[not]: /url" ,Para [Str "Foo",Space,Link [Str "bar"] ("/url/",""),Str "."] ,Para [Str "Foo",Space,Link [Str "biz"] ("/url/",""),Str "."]-,Header 2 [Str "With",Space,Str "ampersands"]+,Header 2 ("",[],[]) [Str "With",Space,Str "ampersands"] ,Para [Str "Here\8217s",Space,Str "a",Space,Link [Str "link",Space,Str "with",Space,Str "an",Space,Str "ampersand",Space,Str "in",Space,Str "the",Space,Str "URL"] ("http://example.com/?foo=1&bar=2",""),Str "."] ,Para [Str "Here\8217s",Space,Str "a",Space,Str "link",Space,Str "with",Space,Str "an",Space,Str "amersand",Space,Str "in",Space,Str "the",Space,Str "link",Space,Str "text:",Space,Link [Str "AT&T"] ("http://att.com/",""),Str "."] ,Para [Str "Here\8217s",Space,Str "an",Space,Link [Str "inline",Space,Str "link"] ("/script?foo=1&bar=2",""),Str "."] ,Para [Str "Here\8217s",Space,Str "an",Space,Link [Str "inline",Space,Str "link",Space,Str "in",Space,Str "pointy",Space,Str "braces"] ("/script?foo=1&bar=2",""),Str "."]-,Header 2 [Str "Autolinks"]-,Para [Str "With",Space,Str "an",Space,Str "ampersand:",Space,Link [Code ("",["url"],[]) "http://example.com/?foo=1&bar=2"] ("http://example.com/?foo=1&bar=2","")]+,Header 2 ("",[],[]) [Str "Autolinks"]+,Para [Str "With",Space,Str "an",Space,Str "ampersand:",Space,Link [Str "http://example.com/?foo=1&bar=2"] ("http://example.com/?foo=1&bar=2","")] ,BulletList [[Para [Str "In",Space,Str "a",Space,Str "list?"]]- ,[Para [Link [Code ("",["url"],[]) "http://example.com/"] ("http://example.com/","")]]+ ,[Para [Link [Str "http://example.com/"] ("http://example.com/","")]] ,[Para [Str "It",Space,Str "should."]]]-,Para [Str "An",Space,Str "e-mail",Space,Str "address:",Space,Link [Code ("",[],[]) "nobody@nowhere.net"] ("mailto:nobody@nowhere.net","")]+,Para [Str "An",Space,Str "e-mail",Space,Str "address:",Space,Link [Str "nobody@nowhere.net"] ("mailto:nobody@nowhere.net","")] ,BlockQuote- [Para [Str "Blockquoted:",Space,Link [Code ("",["url"],[]) "http://example.com/"] ("http://example.com/","")]]+ [Para [Str "Blockquoted:",Space,Link [Str "http://example.com/"] ("http://example.com/","")]] ,Para [Str "Auto-links",Space,Str "should",Space,Str "not",Space,Str "occur",Space,Str "here:",Space,Code ("",[],[]) "<http://example.com/>"] ,CodeBlock ("",[],[]) "or here: <http://example.com/>" ,HorizontalRule-,Header 1 [Str "Images"]+,Header 1 ("",[],[]) [Str "Images"] ,Para [Str "From",Space,Quoted DoubleQuote [Str "Voyage",Space,Str "dans",Space,Str "la",Space,Str "Lune"],Space,Str "by",Space,Str "Georges",Space,Str "Melies",Space,Str "(1902):"] ,Para [Image [Str "image"] ("lalune.jpg","")] ,Para [Str "Here",Space,Str "is",Space,Str "a",Space,Str "movie",Space,Image [Str "image"] ("movie.jpg",""),Space,Str "icon."] ,HorizontalRule-,Header 1 [Str "Footnotes"]+,Header 1 ("",[],[]) [Str "Footnotes"] ,Para [Str "Here",Space,Str "is",Space,Str "a",Space,Str "footnote",Space,Str "reference,",Note [Para [Str "Here",Space,Str "is",Space,Str "the",Space,Str "footnote.",Space,Str "It",Space,Str "can",Space,Str "go",Space,Str "anywhere",Space,Str "after",Space,Str "the",Space,Str "footnote",Space,Str "reference.",Space,Str "It",Space,Str "need",Space,Str "not",Space,Str "be",Space,Str "placed",Space,Str "at",Space,Str "the",Space,Str "end",Space,Str "of",Space,Str "the",Space,Str "document."]],Space,Str "and",Space,Str "another.",Note [Para [Str "Here\8217s",Space,Str "the",Space,Str "long",Space,Str "note.",Space,Str "This",Space,Str "one",Space,Str "contains",Space,Str "multiple",Space,Str "blocks."],Para [Str "Subsequent",Space,Str "blocks",Space,Str "are",Space,Str "indented",Space,Str "to",Space,Str "show",Space,Str "that",Space,Str "they",Space,Str "belong",Space,Str "to",Space,Str "the",Space,Str "footnote",Space,Str "(as",Space,Str "with",Space,Str "list",Space,Str "items)."],CodeBlock ("",[],[]) " { <code> }",Para [Str "If",Space,Str "you",Space,Str "want,",Space,Str "you",Space,Str "can",Space,Str "indent",Space,Str "every",Space,Str "line,",Space,Str "but",Space,Str "you",Space,Str "can",Space,Str "also",Space,Str "be",Space,Str "lazy",Space,Str "and",Space,Str "just",Space,Str "indent",Space,Str "the",Space,Str "first",Space,Str "line",Space,Str "of",Space,Str "each",Space,Str "block."]],Space,Str "This",Space,Str "should",Space,Emph [Str "not"],Space,Str "be",Space,Str "a",Space,Str "footnote",Space,Str "reference,",Space,Str "because",Space,Str "it",Space,Str "contains",Space,Str "a",Space,Str "space.[^my",Space,Str "note]",Space,Str "Here",Space,Str "is",Space,Str "an",Space,Str "inline",Space,Str "note.",Note [Para [Str "This",Space,Str "is",Space,Emph [Str "easier"],Space,Str "to",Space,Str "type.",Space,Str "Inline",Space,Str "notes",Space,Str "may",Space,Str "contain",Space,Link [Str "links"] ("http://google.com",""),Space,Str "and",Space,Code ("",[],[]) "]",Space,Str "verbatim",Space,Str "characters,",Space,Str "as",Space,Str "well",Space,Str "as",Space,Str "[bracketed",Space,Str "text]."]]] ,BlockQuote [Para [Str "Notes",Space,Str "can",Space,Str "go",Space,Str "in",Space,Str "quotes.",Note [Para [Str "In",Space,Str "quote."]]]]
@@ -0,0 +1,8 @@+[Header 1 ("lhs-test",[],[]) [Str "lhs",Space,Str "test"]+,Para [Code ("",[],[]) "unsplit",Space,Str "is",Space,Str "an",Space,Str "arrow",Space,Str "that",Space,Str "takes",Space,Str "a",Space,Str "pair",Space,Str "of",Space,Str "values",Space,Str "and",Space,Str "combines",Space,Str "them",Space,Str "to",Space,Str "return",Space,Str "a",Space,Str "single",Space,Str "value:"]+,CodeBlock ("",["sourceCode","literate","haskell"],[]) "unsplit :: (Arrow a) => (b -> c -> d) -> a (b, c) d\nunsplit = arr . uncurry \n -- arr (\\op (x,y) -> x `op` y) "+,Para [Code ("",[],[]) "(***)",Space,Str "combines",Space,Str "two",Space,Str "arrows",Space,Str "into",Space,Str "a",Space,Str "new",Space,Str "arrow",Space,Str "by",Space,Str "running",Space,Str "the",Space,Str "two",Space,Str "arrows",Space,Str "on",Space,Str "a",Space,Str "pair",Space,Str "of",Space,Str "values",Space,Str "(one",Space,Str "arrow",Space,Str "on",Space,Str "the",Space,Str "first",Space,Str "item",Space,Str "of",Space,Str "the",Space,Str "pair",Space,Str "and",Space,Str "one",Space,Str "arrow",Space,Str "on",Space,Str "the",Space,Str "second",Space,Str "item",Space,Str "of",Space,Str "the",Space,Str "pair)."]+,CodeBlock ("",[],[]) "f *** g = first f >>> second g"+,Para [Str "Block",Space,Str "quote:"]+,BlockQuote+ [Para [Str "foo",Space,Str "bar"]]]
@@ -5,10 +5,11 @@ <meta http-equiv="Content-Style-Type" content="text/css" /> <meta name="generator" content="pandoc" /> <title></title>+ <style type="text/css">code{white-space: pre;}</style> <style type="text/css"> table.sourceCode, tr.sourceCode, td.lineNumbers, td.sourceCode { margin: 0; padding: 0; vertical-align: baseline; border: none; }-table.sourceCode { width: 100%; }+table.sourceCode { width: 100%; line-height: 100%; } td.lineNumbers { text-align: right; padding-right: 4px; padding-left: 4px; color: #aaaaaa; border-right: 1px solid #aaaaaa; } td.sourceCode { padding-left: 5px; } code > span.kw { color: #007020; font-weight: bold; }@@ -26,7 +27,7 @@ </style> </head> <body>-<h1 id="lhs-test">lhs test</h1>+<h1>lhs test</h1> <p><code>unsplit</code> is an arrow that takes a pair of values and combines them to return a single value:</p> <pre class="sourceCode literate haskell"><code class="sourceCode haskell"><span class="ot">unsplit ::</span> (<span class="dt">Arrow</span> a) <span class="ot">=></span> (b <span class="ot">-></span> c <span class="ot">-></span> d) <span class="ot">-></span> a (b, c) d unsplit <span class="fu">=</span> arr <span class="fu">.</span> <span class="fu">uncurry</span>
@@ -5,10 +5,11 @@ <meta http-equiv="Content-Style-Type" content="text/css" /> <meta name="generator" content="pandoc" /> <title></title>+ <style type="text/css">code{white-space: pre;}</style> <style type="text/css"> table.sourceCode, tr.sourceCode, td.lineNumbers, td.sourceCode { margin: 0; padding: 0; vertical-align: baseline; border: none; }-table.sourceCode { width: 100%; }+table.sourceCode { width: 100%; line-height: 100%; } td.lineNumbers { text-align: right; padding-right: 4px; padding-left: 4px; color: #aaaaaa; border-right: 1px solid #aaaaaa; } td.sourceCode { padding-left: 5px; } code > span.kw { color: #007020; font-weight: bold; }@@ -26,7 +27,7 @@ </style> </head> <body>-<h1 id="lhs-test">lhs test</h1>+<h1>lhs test</h1> <p><code>unsplit</code> is an arrow that takes a pair of values and combines them to return a single value:</p> <pre class="sourceCode literate haskell"><code class="sourceCode haskell"><span class="fu">></span><span class="ot"> unsplit ::</span> (<span class="dt">Arrow</span> a) <span class="ot">=></span> (b <span class="ot">-></span> c <span class="ot">-></span> d) <span class="ot">-></span> a (b, c) d <span class="fu">></span> unsplit <span class="fu">=</span> arr <span class="fu">.</span> <span class="fu">uncurry</span>
@@ -6,6 +6,8 @@ \usepackage{fixltx2e} % provides \textsubscript % use microtype if available \IfFileExists{microtype.sty}{\usepackage{microtype}}{}+% use upquote if available, for straight quotes in verbatim environments+\IfFileExists{upquote.sty}{\usepackage{upquote}}{} \ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex \usepackage[utf8]{inputenc} \else % if luatex or xelatex@@ -70,7 +72,7 @@ \begin{Highlighting}[] \OtherTok{unsplit ::} \NormalTok{(}\DataTypeTok{Arrow} \NormalTok{a) }\OtherTok{=>} \NormalTok{(b }\OtherTok{->} \NormalTok{c }\OtherTok{->} \NormalTok{d) }\OtherTok{->} \NormalTok{a (b, c) d} \NormalTok{unsplit }\FunctionTok{=} \NormalTok{arr }\FunctionTok{.} \FunctionTok{uncurry} - \CommentTok{-- arr (\textbackslash{}op (x,y) -> x {\char18}op{\char18} y) }+ \CommentTok{-- arr (\textbackslash{}op (x,y) -> x `op` y) } \end{Highlighting} \end{Shaded}
@@ -6,6 +6,8 @@ \usepackage{fixltx2e} % provides \textsubscript % use microtype if available \IfFileExists{microtype.sty}{\usepackage{microtype}}{}+% use upquote if available, for straight quotes in verbatim environments+\IfFileExists{upquote.sty}{\usepackage{upquote}}{} \ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex \usepackage[utf8]{inputenc} \else % if luatex or xelatex
@@ -1,8 +1,8 @@-[Header 1 [Str "lhs",Space,Str "test"]-,Para [Code ("",[],[]) "unsplit",Space,Str "is",Space,Str "an",Space,Str "arrow",Space,Str "that",Space,Str "takes",Space,Str "a",Space,Str "pair",Space,Str "of",Space,Str "values",Space,Str "and",Space,Str "combines",Space,Str "them",Space,Str "to",Space,Str "return",Space,Str "a",Space,Str "single",Space,Str "value",Str ":"]+[Header 1 ("",[],[]) [Str "lhs",Space,Str "test"]+,Para [Code ("",[],[]) "unsplit",Space,Str "is",Space,Str "an",Space,Str "arrow",Space,Str "that",Space,Str "takes",Space,Str "a",Space,Str "pair",Space,Str "of",Space,Str "values",Space,Str "and",Space,Str "combines",Space,Str "them",Space,Str "to",Space,Str "return",Space,Str "a",Space,Str "single",Space,Str "value:"] ,CodeBlock ("",["sourceCode","literate","haskell"],[]) "unsplit :: (Arrow a) => (b -> c -> d) -> a (b, c) d\nunsplit = arr . uncurry \n -- arr (\\op (x,y) -> x `op` y) "-,Para [Code ("",[],[]) "(***)",Space,Str "combines",Space,Str "two",Space,Str "arrows",Space,Str "into",Space,Str "a",Space,Str "new",Space,Str "arrow",Space,Str "by",Space,Str "running",Space,Str "the",Space,Str "two",Space,Str "arrows",Space,Str "on",Space,Str "a",Space,Str "pair",Space,Str "of",Space,Str "values",Space,Str "(one",Space,Str "arrow",Space,Str "on",Space,Str "the",Space,Str "first",Space,Str "item",Space,Str "of",Space,Str "the",Space,Str "pair",Space,Str "and",Space,Str "one",Space,Str "arrow",Space,Str "on",Space,Str "the",Space,Str "second",Space,Str "item",Space,Str "of",Space,Str "the",Space,Str "pair)",Str "."]+,Para [Code ("",[],[]) "(***)",Space,Str "combines",Space,Str "two",Space,Str "arrows",Space,Str "into",Space,Str "a",Space,Str "new",Space,Str "arrow",Space,Str "by",Space,Str "running",Space,Str "the",Space,Str "two",Space,Str "arrows",Space,Str "on",Space,Str "a",Space,Str "pair",Space,Str "of",Space,Str "values",Space,Str "(one",Space,Str "arrow",Space,Str "on",Space,Str "the",Space,Str "first",Space,Str "item",Space,Str "of",Space,Str "the",Space,Str "pair",Space,Str "and",Space,Str "one",Space,Str "arrow",Space,Str "on",Space,Str "the",Space,Str "second",Space,Str "item",Space,Str "of",Space,Str "the",Space,Str "pair)."] ,CodeBlock ("",[],[]) "f *** g = first f >>> second g"-,Para [Str "Block",Space,Str "quote",Str ":"]+,Para [Str "Block",Space,Str "quote:"] ,BlockQuote [Para [Str "foo",Space,Str "bar"]]]
@@ -1,54 +1,54 @@-[Header 1 [Str "Additional",Space,Str "markdown",Space,Str "reader",Space,Str "tests"]-,Header 2 [Str "Blank",Space,Str "line",Space,Str "before",Space,Str "URL",Space,Str "in",Space,Str "link",Space,Str "reference"]+[Header 1 ("additional-markdown-reader-tests",[],[]) [Str "Additional",Space,Str "markdown",Space,Str "reader",Space,Str "tests"]+,Header 2 ("blank-line-before-url-in-link-reference",[],[]) [Str "Blank",Space,Str "line",Space,Str "before",Space,Str "URL",Space,Str "in",Space,Str "link",Space,Str "reference"] ,Para [Link [Str "foo"] ("/url",""),Space,Str "and",Space,Link [Str "bar"] ("/url","title")]-,Header 2 [Str "Raw",Space,Str "ConTeXt",Space,Str "environments"]+,Header 2 ("raw-context-environments",[],[]) [Str "Raw",Space,Str "ConTeXt",Space,Str "environments"] ,Plain [RawInline "tex" "\\placeformula "] ,RawBlock "context" "\\startformula\n L_{1} = L_{2}\n \\stopformula" ,RawBlock "context" "\\start[a2]\n\\start[a2]\n\\stop[a2]\n\\stop[a2]"-,Header 2 [Str "URLs",Space,Str "with",Space,Str "spaces"]+,Header 2 ("urls-with-spaces",[],[]) [Str "URLs",Space,Str "with",Space,Str "spaces"] ,Para [Link [Str "foo"] ("/bar%20and%20baz",""),Space,Link [Str "foo"] ("/bar%20and%20baz",""),Space,Link [Str "foo"] ("/bar%20and%20baz",""),Space,Link [Str "foo"] ("bar%20baz","title")] ,Para [Link [Str "baz"] ("/foo%20foo",""),Space,Link [Str "bam"] ("/foo%20fee",""),Space,Link [Str "bork"] ("/foo/zee%20zob","title")]-,Header 2 [Str "Horizontal",Space,Str "rules",Space,Str "with",Space,Str "spaces",Space,Str "at",Space,Str "end"]+,Header 2 ("horizontal-rules-with-spaces-at-end",[],[]) [Str "Horizontal",Space,Str "rules",Space,Str "with",Space,Str "spaces",Space,Str "at",Space,Str "end"] ,HorizontalRule ,HorizontalRule-,Header 2 [Str "Raw",Space,Str "HTML",Space,Str "before",Space,Str "header"]-,Plain [RawInline "html" "<a>",RawInline "html" "</a>"]-,Header 3 [Str "my",Space,Str "header"]-,Header 2 [Str "$",Space,Str "in",Space,Str "math"]+,Header 2 ("raw-html-before-header",[],[]) [Str "Raw",Space,Str "HTML",Space,Str "before",Space,Str "header"]+,Para [RawInline "html" "<a>",RawInline "html" "</a>"]+,Header 3 ("my-header",[],[]) [Str "my",Space,Str "header"]+,Header 2 ("in-math",[],[]) [Str "$",Space,Str "in",Space,Str "math"] ,Para [Math InlineMath "\\$2 + \\$3"]-,Header 2 [Str "Commented",Str "-",Str "out",Space,Str "list",Space,Str "item"]+,Header 2 ("commented-out-list-item",[],[]) [Str "Commented-out",Space,Str "list",Space,Str "item"] ,BulletList [[Plain [Str "one",Space,RawInline "html" "<!--\n- two\n-->"]] ,[Plain [Str "three"]]]-,Header 2 [Str "Backslash",Space,Str "newline"]+,Header 2 ("backslash-newline",[],[]) [Str "Backslash",Space,Str "newline"] ,Para [Str "hi",LineBreak,Str "there"]-,Header 2 [Str "Code",Space,Str "spans"]+,Header 2 ("code-spans",[],[]) [Str "Code",Space,Str "spans"] ,Para [Code ("",[],[]) "hi\\"] ,Para [Code ("",[],[]) "hi there"] ,Para [Code ("",[],[]) "hi````there"]-,Para [Str "`",Str "hi"]-,Para [Str "there",Str "`"]-,Header 2 [Str "Multilingual",Space,Str "URLs"]-,Plain [RawInline "html" "<http://\27979.com?\27979=\27979>"]+,Para [Str "`hi"]+,Para [Str "there`"]+,Header 2 ("multilingual-urls",[],[]) [Str "Multilingual",Space,Str "URLs"]+,Para [Link [Str "http://\27979.com?\27979=\27979"] ("http://\27979.com?\27979=\27979","")] ,Para [Link [Str "foo"] ("/bar/\27979?x=\27979","title")]-,Para [Link [Code ("",["url"],[]) "\27979@foo.\27979.baz"] ("mailto:\27979@foo.\27979.baz","")]-,Header 2 [Str "Numbered",Space,Str "examples"]+,Para [Link [Str "\27979@foo.\27979.baz"] ("mailto:\27979@foo.\27979.baz","")]+,Header 2 ("numbered-examples",[],[]) [Str "Numbered",Space,Str "examples"] ,OrderedList (1,Example,TwoParens)- [[Plain [Str "First",Space,Str "example",Str "."]]- ,[Plain [Str "Second",Space,Str "example",Str "."]]]-,Para [Str "Explanation",Space,Str "of",Space,Str "examples",Space,Str "(",Str "2",Str ")",Space,Str "and",Space,Str "(",Str "3",Str ")",Str "."]+ [[Plain [Str "First",Space,Str "example."]]+ ,[Plain [Str "Second",Space,Str "example."]]]+,Para [Str "Explanation",Space,Str "of",Space,Str "examples",Space,Str "(2)",Space,Str "and",Space,Str "(3)."] ,OrderedList (3,Example,TwoParens)- [[Plain [Str "Third",Space,Str "example",Str "."]]]-,Header 2 [Str "Macros"]+ [[Plain [Str "Third",Space,Str "example."]]]+,Header 2 ("macros",[],[]) [Str "Macros"] ,Para [Math InlineMath "\\langle x,y \\rangle"]-,Header 2 [Str "Case",Str "-",Str "insensitive",Space,Str "references"]+,Header 2 ("case-insensitive-references",[],[]) [Str "Case-insensitive",Space,Str "references"] ,Para [Link [Str "Fum"] ("/fum","")] ,Para [Link [Str "FUM"] ("/fum","")] ,Para [Link [Str "bat"] ("/bat","")]-,Header 2 [Str "Curly",Space,Str "smart",Space,Str "quotes"]+,Header 2 ("curly-smart-quotes",[],[]) [Str "Curly",Space,Str "smart",Space,Str "quotes"] ,Para [Quoted DoubleQuote [Str "Hi"]] ,Para [Quoted SingleQuote [Str "Hi"]]-,Header 2 [Str "Consecutive",Space,Str "lists"]+,Header 2 ("consecutive-lists",[],[]) [Str "Consecutive",Space,Str "lists"] ,BulletList [[Plain [Str "one"]] ,[Plain [Str "two"]]]@@ -57,4 +57,14 @@ ,[Plain [Str "two"]]] ,OrderedList (1,LowerAlpha,Period) [[Plain [Str "one"]]- ,[Plain [Str "two"]]]]+ ,[Plain [Str "two"]]]+,Header 2 ("implicit-header-references",[],[]) [Str "Implicit",Space,Str "header",Space,Str "references"]+,Header 3 ("my-header-1",[],[]) [Str "My",Space,Str "header"]+,Header 3 ("my-other-header",[],[]) [Str "My",Space,Str "other",Space,Str "header"]+,Para [Str "A",Space,Str "link",Space,Str "to",Space,Link [Str "My",Space,Str "header"] ("#my-header",""),Str "."]+,Para [Str "Another",Space,Str "link",Space,Str "to",Space,Link [Str "it"] ("#my-header",""),Str "."]+,Para [Str "But",Space,Str "this",Space,Str "is",Space,Str "not",Space,Str "a",Space,Str "link",Space,Str "to",Space,Link [Str "My",Space,Str "other",Space,Str "header"] ("/foo",""),Str ",",Space,Str "since",Space,Str "the",Space,Str "reference",Space,Str "is",Space,Str "defined."]+,Header 2 ("foobar",["baz"],[("key","val")]) [Str "Explicit",Space,Str "header",Space,Str "attributes"]+,Header 2 ("line-blocks",[],[]) [Str "Line",Space,Str "blocks"]+,Para [Str "But",Space,Str "can",Space,Str "a",Space,Str "bee",Space,Str "be",Space,Str "said",Space,Str "to",Space,Str "be",LineBreak,Str "\160\160\160\160or",Space,Str "not",Space,Str "to",Space,Str "be",Space,Str "an",Space,Str "entire",Space,Str "bee,",LineBreak,Str "\160\160\160\160\160\160\160\160when",Space,Str "half",Space,Str "the",Space,Str "bee",Space,Str "is",Space,Str "not",Space,Str "a",Space,Str "bee,",LineBreak,Str "\160\160\160\160\160\160\160\160\160\160\160\160due",Space,Str "to",Space,Str "some",Space,Str "ancient",Space,Str "injury?"]+,Para [Str "Continuation",Space,Str "line",LineBreak,Str "\160\160and",Space,Str "another"]]
@@ -133,3 +133,32 @@ a. one b. two++## Implicit header references++### My header++### My other header++A link to [My header].++Another link to [it][My header].++[my other header]: /foo++But this is not a link to [My other header], since the reference is defined.++## Explicit header attributes {#foobar .baz key="val"}++## Line blocks++| But can a bee be said to be+| or not to be an entire bee,+| when half the bee is not a bee,+| due to some ancient injury?+|+| Continuation+ line+| and+ another+
@@ -0,0 +1,241 @@+Pandoc (Meta {docTitle = [], docAuthors = [], docDate = []})+[Header 1 ("",[],[]) [Str "header"]+,Header 2 ("",[],[]) [Str "header",Space,Str "level",Space,Str "two"]+,Header 3 ("",[],[]) [Str "header",Space,Str "level",Space,Str "3"]+,Header 4 ("",[],[]) [Str "header",Space,Emph [Str "level"],Space,Str "four"]+,Header 5 ("",[],[]) [Str "header",Space,Str "level",Space,Str "5"]+,Header 6 ("",[],[]) [Str "header",Space,Str "level",Space,Str "6"]+,Para [Str "=======",Space,Str "not",Space,Str "a",Space,Str "header",Space,Str "========"]+,Para [Code ("",[],[]) "==\160not\160a\160header\160=="]+,Header 2 ("",[],[]) [Str "emph",Space,Str "and",Space,Str "strong"]+,Para [Emph [Str "emph"],Space,Strong [Str "strong"]]+,Para [Strong [Emph [Str "strong",Space,Str "and",Space,Str "emph"]]]+,Para [Strong [Emph [Str "emph",Space,Str "inside"],Space,Str "strong"]]+,Para [Strong [Str "strong",Space,Str "with",Space,Emph [Str "emph"]]]+,Para [Emph [Strong [Str "strong",Space,Str "inside"],Space,Str "emph"]]+,Header 2 ("",[],[]) [Str "horizontal",Space,Str "rule"]+,Para [Str "top"]+,HorizontalRule+,Para [Str "bottom"]+,HorizontalRule+,Header 2 ("",[],[]) [Str "nowiki"]+,Para [Str "''not",Space,Str "emph''"]+,Header 2 ("",[],[]) [Str "strikeout"]+,Para [Strikeout [Str "This",Space,Str "is",Space,Emph [Str "struck",Space,Str "out"]]]+,Header 2 ("",[],[]) [Str "entities"]+,Para [Str "hi",Space,Str "&",Space,Str "low"]+,Para [Str "hi",Space,Str "&",Space,Str "low"]+,Para [Str "G\246del"]+,Para [Str "\777\2730"]+,Header 2 ("",[],[]) [Str "comments"]+,Para [Str "inline",Space,Str "comment"]+,Para [Str "between",Space,Str "blocks"]+,Header 2 ("",[],[]) [Str "linebreaks"]+,Para [Str "hi",LineBreak,Str "there"]+,Para [Str "hi",LineBreak,Str "there"]+,Header 2 ("",[],[]) [Str ":",Space,Str "indents"]+,Para [Str "hi"]+,DefinitionList+ [([],+ [[Plain [Str "there"]]])]+,Para [Str "bud"]+,Para [Str "hi"]+,DefinitionList+ [([],+ [[DefinitionList+ [([],+ [[Plain [Str "there"]]])]]])]+,Para [Str "bud"]+,Header 2 ("",[],[]) [Str "p",Space,Str "tags"]+,Para [Str "hi",Space,Str "there"]+,Para [Str "bud"]+,Para [Str "another"]+,Header 2 ("",[],[]) [Str "raw",Space,Str "html"]+,Para [Str "hi",Space,RawInline "html" "<span style=\"color:red\">",Emph [Str "there"],RawInline "html" "</span>",Str "."]+,Para [RawInline "html" "<ins>",Str "inserted",RawInline "html" "</ins>"]+,RawBlock "html" "<div class=\"special\">"+,Para [Str "hi",Space,Emph [Str "there"]]+,RawBlock "html" "</div>"+,Header 2 ("",[],[]) [Str "sup,",Space,Str "sub,",Space,Str "del"]+,Para [Str "H",Subscript [Str "2"],Str "O",Space,Str "base",Superscript [Emph [Str "exponent"]],Space,Strikeout [Str "hello"]]+,Header 2 ("",[],[]) [Str "inline",Space,Str "code"]+,Para [Code ("",[],[]) "*\8594*",Space,Code ("",[],[]) "typed",Space,Code ("",["haskell"],[]) ">>="]+,Header 2 ("",[],[]) [Str "code",Space,Str "blocks"]+,CodeBlock ("",[],[]) "case xs of\n (_:_) -> reverse xs\n [] -> ['*']"+,CodeBlock ("",["haskell"],[]) "case xs of\n (_:_) -> reverse xs\n [] -> ['*']"+,CodeBlock ("",["ruby","numberLines"],[("startFrom","100")]) "widgets.each do |w|\n print w.price\nend"+,Header 2 ("",[],[]) [Str "block",Space,Str "quotes"]+,Para [Str "Regular",Space,Str "paragraph"]+,BlockQuote+ [Para [Str "This",Space,Str "is",Space,Str "a",Space,Str "block",Space,Str "quote."]+ ,Para [Str "With",Space,Str "two",Space,Str "paragraphs."]]+,Para [Str "Nother",Space,Str "paragraph."]+,Header 2 ("",[],[]) [Str "external",Space,Str "links"]+,Para [Link [Emph [Str "Google"],Space,Str "search",Space,Str "engine"] ("http://google.com","")]+,Para [Link [Str "http://johnmacfarlane.net/pandoc/"] ("http://johnmacfarlane.net/pandoc/","")]+,Para [Link [Str "1"] ("http://google.com",""),Space,Link [Str "2"] ("http://yahoo.com","")]+,Para [Link [Str "email",Space,Str "me"] ("mailto:info@example.org","")]+,Header 2 ("",[],[]) [Str "internal",Space,Str "links"]+,Para [Link [Str "Help"] ("Help","wikilink")]+,Para [Link [Str "the",Space,Str "help",Space,Str "page"] ("Help","wikilink")]+,Para [Link [Str "Helpers"] ("Help","wikilink")]+,Para [Link [Str "Help"] ("Help","wikilink"),Str "ers"]+,Para [Link [Str "Contents"] ("Help:Contents","wikilink")]+,Para [Link [Str "#My",Space,Str "anchor"] ("#My_anchor","wikilink")]+,Para [Link [Str "and",Space,Str "text"] ("Page#with_anchor","wikilink")]+,Header 2 ("",[],[]) [Str "images"]+,Para [Image [Str "caption"] ("example.jpg","image")]+,Para [Image [Str "the",Space,Emph [Str "caption"],Space,Str "with",Space,Link [Str "external",Space,Str "link"] ("http://google.com","")] ("example.jpg","image")]+,Para [Image [Str "caption"] ("example.jpg","image")]+,Para [Image [Str "example.jpg"] ("example.jpg","image")]+,Header 2 ("",[],[]) [Str "lists"]+,BulletList+ [[Plain [Str "Start",Space,Str "each",Space,Str "line"]]+ ,[Plain [Str "with",Space,Str "an",Space,Str "asterisk",Space,Str "(*)."]+ ,BulletList+ [[Plain [Str "More",Space,Str "asterisks",Space,Str "gives",Space,Str "deeper"]+ ,BulletList+ [[Plain [Str "and",Space,Str "deeper",Space,Str "levels."]]]]]]+ ,[Plain [Str "Line",Space,Str "breaks",LineBreak,Str "don't",Space,Str "break",Space,Str "levels."]+ ,BulletList+ [[BulletList+ [[Plain [Str "But",Space,Str "jumping",Space,Str "levels",Space,Str "creates",Space,Str "empty",Space,Str "space."]]]]]]]+,Para [Str "Any",Space,Str "other",Space,Str "start",Space,Str "ends",Space,Str "the",Space,Str "list."]+,OrderedList (1,DefaultStyle,DefaultDelim)+ [[Plain [Str "Start",Space,Str "each",Space,Str "line"]]+ ,[Plain [Str "with",Space,Str "a",Space,Str "number",Space,Str "sign",Space,Str "(#)."]+ ,OrderedList (1,DefaultStyle,DefaultDelim)+ [[Plain [Str "More",Space,Str "number",Space,Str "signs",Space,Str "gives",Space,Str "deeper"]+ ,OrderedList (1,DefaultStyle,DefaultDelim)+ [[Plain [Str "and",Space,Str "deeper"]]+ ,[Plain [Str "levels."]]]]]]+ ,[Plain [Str "Line",Space,Str "breaks",LineBreak,Str "don't",Space,Str "break",Space,Str "levels."]+ ,OrderedList (1,DefaultStyle,DefaultDelim)+ [[OrderedList (1,DefaultStyle,DefaultDelim)+ [[Plain [Str "But",Space,Str "jumping",Space,Str "levels",Space,Str "creates",Space,Str "empty",Space,Str "space."]]]]]]+ ,[Plain [Str "Blank",Space,Str "lines"]]]+,OrderedList (1,DefaultStyle,DefaultDelim)+ [[Plain [Str "end",Space,Str "the",Space,Str "list",Space,Str "and",Space,Str "start",Space,Str "another."]]]+,Para [Str "Any",Space,Str "other",Space,Str "start",Space,Str "also",Space,Str "ends",Space,Str "the",Space,Str "list."]+,DefinitionList+ [([Str "item",Space,Str "1"],+ [[Plain [Str "definition",Space,Str "1"]]])+ ,([Str "item",Space,Str "2"],+ [[Plain [Str "definition",Space,Str "2-1"]]+ ,[Plain [Str "definition",Space,Str "2-2"]]])]+,OrderedList (1,DefaultStyle,DefaultDelim)+ [[Plain [Str "one"]]+ ,[Plain [Str "two"]+ ,BulletList+ [[Plain [Str "two",Space,Str "point",Space,Str "one"]]+ ,[Plain [Str "two",Space,Str "point",Space,Str "two"]]]]+ ,[Plain [Str "three"]+ ,DefinitionList+ [([Str "three",Space,Str "item",Space,Str "one"],+ [[Plain [Str "three",Space,Str "def",Space,Str "one"]]])]]+ ,[Plain [Str "four"]+ ,DefinitionList+ [([],+ [[Plain [Str "four",Space,Str "def",Space,Str "one"]]+ ,[Plain [Str "this",Space,Str "looks",Space,Str "like",Space,Str "a",Space,Str "continuation"]]+ ,[Plain [Str "and",Space,Str "is",Space,Str "often",Space,Str "used"]]+ ,[Plain [Str "instead",LineBreak,Str "of",Space,Str "<br/>"]]])]]+ ,[Plain [RawInline "mediawiki" "{{{template\n|author=John\n|title=My Book\n}}}"]+ ,OrderedList (1,DefaultStyle,DefaultDelim)+ [[Plain [Str "five",Space,Str "sub",Space,Str "1"]+ ,OrderedList (1,DefaultStyle,DefaultDelim)+ [[Plain [Str "five",Space,Str "sub",Space,Str "1",Space,Str "sub",Space,Str "1"]]]]+ ,[Plain [Str "five",Space,Str "sub",Space,Str "2"]]]]]+,OrderedList (1,DefaultStyle,DefaultDelim)+ [[Plain [Str "list",Space,Str "item",Space,Emph [Str "emph"]]+ ,OrderedList (1,DefaultStyle,DefaultDelim)+ [[Plain [Str "list",Space,Str "item",Space,Str "B1"]]+ ,[Plain [Str "list",Space,Str "item",Space,Str "B2"]]]+ ,Para [Str "continuing",Space,Str "list",Space,Str "item",Space,Str "A1"]]+ ,[Plain [Str "list",Space,Str "item",Space,Str "A2"]]]+,OrderedList (1,DefaultStyle,DefaultDelim)+ [[Plain [Str "abc"]]+ ,[Plain [Str "def"]]+ ,[Plain [Str "ghi"]]]+,OrderedList (9,DefaultStyle,DefaultDelim)+ [[Plain [Str "Amsterdam"]]+ ,[Plain [Str "Rotterdam"]]+ ,[Plain [Str "The",Space,Str "Hague"]]]+,Header 2 ("",[],[]) [Str "math"]+,Para [Str "Here",Space,Str "is",Space,Str "some",Space,Math InlineMath "x=\\frac{y^\\pi}{z}",Str "."]+,Header 2 ("",[],[]) [Str "preformatted",Space,Str "blocks"]+,Para [Code ("",[],[]) "Start\160each\160line\160with\160a\160space.",LineBreak,Code ("",[],[]) "Text\160is\160",Strong [Code ("",[],[]) "preformatted"],Code ("",[],[]) "\160and",LineBreak,Emph [Code ("",[],[]) "markups"],Code ("",[],[]) "\160",Strong [Emph [Code ("",[],[]) "can"]],Code ("",[],[]) "\160be\160done."]+,Para [Code ("",[],[]) "\160hell\160\160\160\160\160\160yeah"]+,Para [Code ("",[],[]) "Start\160with\160a\160space\160in\160the\160first\160column,",LineBreak,Code ("",[],[]) "(before\160the\160<nowiki>).",LineBreak,Code ("",[],[]) "",LineBreak,Code ("",[],[]) "Then\160your\160block\160format\160will\160be",LineBreak,Code ("",[],[]) "\160\160\160\160maintained.",LineBreak,Code ("",[],[]) "",LineBreak,Code ("",[],[]) "This\160is\160good\160for\160copying\160in\160code\160blocks:",LineBreak,Code ("",[],[]) "",LineBreak,Code ("",[],[]) "def\160function():",LineBreak,Code ("",[],[]) "\160\160\160\160\"\"\"documentation\160string\"\"\"",LineBreak,Code ("",[],[]) "",LineBreak,Code ("",[],[]) "\160\160\160\160if\160True:",LineBreak,Code ("",[],[]) "\160\160\160\160\160\160\160\160print\160True",LineBreak,Code ("",[],[]) "\160\160\160\160else:",LineBreak,Code ("",[],[]) "\160\160\160\160\160\160\160\160print\160False"]+,Para [Str "Not"]+,RawBlock "html" "<hr/>"+,Para [Str "preformatted"]+,Header 2 ("",[],[]) [Str "templates"]+,RawBlock "mediawiki" "{{Welcome}}"+,RawBlock "mediawiki" "{{Foo:Bar}}"+,RawBlock "mediawiki" "{{Thankyou|all your effort|Me}}"+,Para [Str "Written",Space,RawInline "mediawiki" "{{{date}}}",Space,Str "by",Space,RawInline "mediawiki" "{{{name}}}",Str "."]+,Header 2 ("",[],[]) [Str "tables"]+,Table [] [AlignDefault,AlignDefault] [0.0,0.0]+ [[]+ ,[]]+ [[[Para [Str "Orange"]]+ ,[Para [Str "Apple"]]]+ ,[[Para [Str "Bread"]]+ ,[Para [Str "Pie"]]]+ ,[[Para [Str "Butter"]]+ ,[Para [Str "Ice",Space,Str "cream"]]]]+,Table [Str "Food",Space,Str "complements"] [AlignDefault,AlignDefault] [0.0,0.0]+ [[Para [Str "Orange"]]+ ,[Para [Str "Apple"]]]+ [[[Para [Str "Bread"]]+ ,[Para [Str "Pie"]]]+ ,[[Para [Str "Butter"]]+ ,[Para [Str "Ice",Space,Str "cream"]]]]+,Table [Str "Food",Space,Str "complements"] [AlignDefault,AlignDefault] [0.0,0.0]+ [[Para [Str "Orange"]]+ ,[Para [Str "Apple"]]]+ [[[Para [Str "Bread"]+ ,Para [Str "and",Space,Str "cheese"]]+ ,[Para [Str "Pie"]+ ,OrderedList (1,DefaultStyle,DefaultDelim)+ [[Plain [Str "apple"]]+ ,[Plain [Str "carrot"]]]]]]+,Table [] [AlignDefault,AlignDefault,AlignDefault] [0.0,0.0,0.0]+ [[]+ ,[]+ ,[]]+ [[[Para [Str "Orange"]]+ ,[Para [Str "Apple"]]+ ,[Para [Str "more"]]]+ ,[[Para [Str "Bread"]]+ ,[Para [Str "Pie"]]+ ,[Para [Str "more"]]]+ ,[[Para [Str "Butter"]]+ ,[Para [Str "Ice",Space,Str "cream"]]+ ,[Para [Str "and",Space,Str "more"]]]]+,Table [] [AlignLeft,AlignRight,AlignCenter] [0.25,0.125,0.125]+ [[Para [Str "Left"]]+ ,[Para [Str "Right"]]+ ,[Para [Str "Center"]]]+ [[[Para [Str "left"]]+ ,[Para [Str "15.00"]]+ ,[Para [Str "centered"]]]+ ,[[Para [Str "more"]]+ ,[Para [Str "2.0"]]+ ,[Para [Str "more"]]]]+,Table [] [AlignDefault,AlignDefault] [0.0,0.0]+ [[]+ ,[]]+ [[[Para [Str "Orange"]]+ ,[Para [Str "Apple"]]]+ ,[[Para [Str "Bread"]]+ ,[Table [] [AlignDefault,AlignDefault] [0.0,0.0]+ [[Para [Str "fruit"]]+ ,[Para [Str "topping"]]]+ [[[Para [Str "apple"]]+ ,[Para [Str "ice",Space,Str "cream"]]]]]]+ ,[[Para [Str "Butter"]]+ ,[Para [Str "Ice",Space,Str "cream"]]]]+,Header 2 ("",[],[]) [Str "notes"]+,Para [Str "My",Space,Str "note!",Note [Plain [Str "This."]]]]
@@ -0,0 +1,369 @@+= header =++== header level two ==++===header level 3===++====header ''level'' four====++===== header level 5 =====++====== header level 6 ======++======= not a header ========++ == not a header ==++== emph and strong ==++''emph'' '''strong'''++'''''strong and emph'''''++'''''emph inside'' strong'''++'''strong with ''emph'''''++'''''strong inside''' emph''++== horizontal rule ==++top+----+bottom++----++== nowiki ==++<nowiki>''not emph''</nowiki>++== strikeout ==++<strike> This is ''struck out''</strike>++== entities ==++hi & low++hi & low++Gödel++̉પ++== comments ==++inline<!-- secret --> comment++<!-- secret -->++between blocks++ <!-- secret -->++== linebreaks ==++hi<br/>there++hi<br>+there++== : indents ==++hi+: there+bud++hi+:: there+bud++== p tags ==++hi there+<p>+bud+<p>+another+</p>++== raw html ==++hi <span style="color:red">''there''</span>.++<ins>inserted</ins>++<div class="special">+hi ''there''+</div>++== sup, sub, del ==++H<sub>2</sub>O base<sup>''exponent''</sup>+<del>hello</del>++== inline code ==++<code>*→*</code> <tt>typed</tt> <hask>>>=</hask>++== code blocks ==++<pre>+case xs of+ (_:_) -> reverse xs+ [] -> ['*']+</pre>++<haskell>+case xs of+ (_:_) -> reverse xs+ [] -> ['*']+</haskell>++<syntaxhighlight lang="ruby" line start=100>+widgets.each do |w|+ print w.price+end+</syntaxhighlight>++== block quotes ==++Regular paragraph+<blockquote>+This is a block quote.++With two paragraphs.+</blockquote>+Nother paragraph.++== external links ==++[http://google.com ''Google'' search engine]++http://johnmacfarlane.net/pandoc/++[http://google.com] [http://yahoo.com]++[mailto:info@example.org email me]++== internal links ==++[[Help]]++[[Help|the help page]]++[[Help]]ers++[[Help]]<nowiki/>ers++[[Help:Contents|]]++[[#My anchor]]++[[Page#with anchor|and text]]++== images ==++[[File:example.jpg|caption]]++[[File:example.jpg|border|the ''caption'' with [http://google.com external link]]]++[[File:example.jpg|frameless|border|30x40px|caption]]++[[File:example.jpg]]++== lists ==++* Start each line+* with an asterisk (*).+** More asterisks gives deeper+*** and deeper levels.+* Line breaks<br/>don't break levels.+*** But jumping levels creates empty space.+Any other start ends the list.++# Start each line+# with a number sign (#).+## More number signs gives deeper+### and deeper+### levels.+# Line breaks<br/>don't break levels.+### But jumping levels creates empty space.+# Blank lines++# end the list and start another.+Any other start also+ends the list.++;item 1+: definition 1+;item 2+: definition 2-1+: definition 2-2++# one+# two+#* two point one+#* two point two+# three+#; three item one+#: three def one+# four+#: four def one+#: this looks like a continuation+#: and is often used+#: instead<br/>of <nowiki><br/></nowiki>+# {{{template+|author=John+|title=My Book+}}}+## five sub 1+### five sub 1 sub 1+## five sub 2++<ol>+ <li>list item ''emph''+ <ol>+ <li>list item B1</li>+ <li>list item B2</li>+ </ol>continuing list item A1+ </li>+ <li>list item A2</li>+</ol>++<ul>+#abc+#def+#ghi+</ul>++<ol start="9">+<li>Amsterdam</li>+<li>Rotterdam</li>+<li>The Hague</li>+</ol>++== math ==++Here is some <math>x=\frac{y^\pi}{z}</math>.++== preformatted blocks ==++ Start each line with a space.+ Text is '''preformatted''' and+ ''markups'' '''''can''''' be done.++ hell yeah++ <nowiki>Start with a space in the first column,+(before the <nowiki>).++Then your block format will be+ maintained.++This is good for copying in code blocks:++def function():+ """documentation string"""++ if True:+ print True+ else:+ print False</nowiki>++Not<hr/> preformatted++== templates ==++{{Welcome}}++{{Foo:Bar}}++{{Thankyou|all your effort|Me}}++Written {{{date}}} by {{{name}}}.++== tables ==++{|+|-+|Orange+|Apple+|-+|Bread+|Pie+|-+|Butter+|Ice cream+|}++{|+|+Food complements+!Orange+!Apple+|-+|Bread+|Pie+|-+!Butter+|Ice cream+|}++{|+|+Food complements+!Orange+!Apple+|-+|Bread++and cheese+|Pie++# apple+# carrot++|}++{|+| Orange || Apple || more+|-+| Bread || Pie || more+|-+| Butter || Ice cream || and more+|}++{|width="50%"+! align="left" width="50%"| Left+! align="right"|Right+! align="center"|Center+|-+| left || 15.00 || centered+|-+| more || 2.0 || more+|}++{|+|-+|Orange+|Apple+|-+|Bread+|+{|+!fruit+!topping+|-+|apple+|ice cream+|}+|-+|Butter+|Ice cream+|}+++== notes ==++My note!<ref>This.</ref>+
@@ -0,0 +1,70 @@+[Para [Str "Simplest",Space,Str "table",Space,Str "without",Space,Str "caption:"]+,Table [] [AlignDefault,AlignDefault,AlignDefault] [0.0,0.0,0.0]+ [[Plain [Str "Default1"]]+ ,[Plain [Str "Default2"]]+ ,[Plain [Str "Default3"]]]+ [[[Plain [Str "12"]]+ ,[Plain [Str "12"]]+ ,[Plain [Str "12"]]]+ ,[[Plain [Str "123"]]+ ,[Plain [Str "123"]]+ ,[Plain [Str "123"]]]+ ,[[Plain [Str "1"]]+ ,[Plain [Str "1"]]+ ,[Plain [Str "1"]]]]+,Para [Str "Simple",Space,Str "table",Space,Str "with",Space,Str "caption:"]+,Table [Str "Demonstration",Space,Str "of",Space,Str "simple",Space,Str "table",Space,Str "syntax."] [AlignRight,AlignLeft,AlignDefault,AlignCenter] [0.0,0.0,0.0,0.0]+ [[Plain [Str "Right"]]+ ,[Plain [Str "Left"]]+ ,[Plain [Str "Default"]]+ ,[Plain [Str "Center"]]]+ [[[Plain [Str "12"]]+ ,[Plain [Str "12"]]+ ,[Plain [Str "12"]]+ ,[Plain [Str "12"]]]+ ,[[Plain [Str "123"]]+ ,[Plain [Str "123"]]+ ,[Plain [Str "123"]]+ ,[Plain [Str "123"]]]+ ,[[Plain [Str "1"]]+ ,[Plain [Str "1"]]+ ,[Plain [Str "1"]]+ ,[Plain [Str "1"]]]]+,Para [Str "Simple",Space,Str "table",Space,Str "without",Space,Str "caption:"]+,Table [] [AlignRight,AlignLeft,AlignCenter] [0.0,0.0,0.0]+ [[Plain [Str "Right"]]+ ,[Plain [Str "Left"]]+ ,[Plain [Str "Center"]]]+ [[[Plain [Str "12"]]+ ,[Plain [Str "12"]]+ ,[Plain [Str "12"]]]+ ,[[Plain [Str "123"]]+ ,[Plain [Str "123"]]+ ,[Plain [Str "123"]]]+ ,[[Plain [Str "1"]]+ ,[Plain [Str "1"]]+ ,[Plain [Str "1"]]]]+,Para [Str "Headerless",Space,Str "table",Space,Str "without",Space,Str "caption:"]+,Table [] [AlignRight,AlignLeft,AlignCenter] [0.0,0.0,0.0]+ [[]+ ,[]+ ,[]]+ [[[Plain [Str "12"]]+ ,[Plain [Str "12"]]+ ,[Plain [Str "12"]]]+ ,[[Plain [Str "123"]]+ ,[Plain [Str "123"]]+ ,[Plain [Str "123"]]]+ ,[[Plain [Str "1"]]+ ,[Plain [Str "1"]]+ ,[Plain [Str "1"]]]]+,Para [Str "Table",Space,Str "without",Space,Str "sides:"]+,Table [] [AlignDefault,AlignRight] [0.0,0.0]+ [[Plain [Str "Fruit"]]+ ,[Plain [Str "Quantity"]]]+ [[[Plain [Str "apple"]]+ ,[Plain [Str "5"]]]+ ,[[Plain [Str "orange"]]+ ,[Plain [Str "17"]]]+ ,[[Plain [Str "pear"]]+ ,[Plain [Str "302"]]]]]
@@ -0,0 +1,42 @@+Simplest table without caption:++| Default1 | Default2 | Default3 | +|----------|----------|----------|+|12|12|12|+|123|123|123|+|1|1|1|++Simple table with caption:++| Right | Left | Default | Center |+|------:|:-----|---------|:------:|+| 12 | 12 | 12 | 12 |+| 123 | 123 | 123 | 123 |+| 1 | 1 | 1 | 1 |++ : Demonstration of simple table syntax.++Simple table without caption:++| Right | Left | Center | +|------:|:-----|:------:|+|12|12|12|+|123|123|123|+|1|1|1|+++Headerless table without caption:++|------:|:-----|:------:|+|12|12|12|+|123|123|123|+|1|1|1|++Table without sides:++Fruit |Quantity+------|-------:+apple | 5+orange| 17+pear | 302+
@@ -2,123 +2,123 @@ [DefinitionList [([Str "Revision"], [[Para [Str "3"]]])]-,Header 1 [Str "Level",Space,Str "one",Space,Str "header"]-,Para [Str "This",Space,Str "is",Space,Str "a",Space,Str "set",Space,Str "of",Space,Str "tests",Space,Str "for",Space,Str "pandoc",Str ".",Space,Str "Most",Space,Str "of",Space,Str "them",Space,Str "are",Space,Str "adapted",Space,Str "from",Space,Str "John",Space,Str "Gruber",Str "\8217",Str "s",Space,Str "markdown",Space,Str "test",Space,Str "suite",Str "."]-,Header 2 [Str "Level",Space,Str "two",Space,Str "header"]-,Header 3 [Str "Level",Space,Str "three"]-,Header 4 [Str "Level",Space,Str "four",Space,Str "with",Space,Emph [Str "emphasis"]]-,Header 5 [Str "Level",Space,Str "five"]-,Header 1 [Str "Paragraphs"]-,Para [Str "Here",Str "\8217",Str "s",Space,Str "a",Space,Str "regular",Space,Str "paragraph",Str "."]-,Para [Str "In",Space,Str "Markdown",Space,Str "1",Str ".",Str "0",Str ".",Str "0",Space,Str "and",Space,Str "earlier",Str ".",Space,Str "Version",Space,Str "8",Str ".",Space,Str "This",Space,Str "line",Space,Str "turns",Space,Str "into",Space,Str "a",Space,Str "list",Space,Str "item",Str ".",Space,Str "Because",Space,Str "a",Space,Str "hard",Str "-",Str "wrapped",Space,Str "line",Space,Str "in",Space,Str "the",Space,Str "middle",Space,Str "of",Space,Str "a",Space,Str "paragraph",Space,Str "looked",Space,Str "like",Space,Str "a",Space,Str "list",Space,Str "item",Str "."]-,Para [Str "Here",Str "\8217",Str "s",Space,Str "one",Space,Str "with",Space,Str "a",Space,Str "bullet",Str ".",Space,Str "*",Space,Str "criminey",Str "."]-,Para [Str "Horizontal",Space,Str "rule",Str ":"]+,Header 1 ("",[],[]) [Str "Level",Space,Str "one",Space,Str "header"]+,Para [Str "This",Space,Str "is",Space,Str "a",Space,Str "set",Space,Str "of",Space,Str "tests",Space,Str "for",Space,Str "pandoc.",Space,Str "Most",Space,Str "of",Space,Str "them",Space,Str "are",Space,Str "adapted",Space,Str "from",Space,Str "John",Space,Str "Gruber\8217s",Space,Str "markdown",Space,Str "test",Space,Str "suite."]+,Header 2 ("",[],[]) [Str "Level",Space,Str "two",Space,Str "header"]+,Header 3 ("",[],[]) [Str "Level",Space,Str "three"]+,Header 4 ("",[],[]) [Str "Level",Space,Str "four",Space,Str "with",Space,Emph [Str "emphasis"]]+,Header 5 ("",[],[]) [Str "Level",Space,Str "five"]+,Header 1 ("",[],[]) [Str "Paragraphs"]+,Para [Str "Here\8217s",Space,Str "a",Space,Str "regular",Space,Str "paragraph."]+,Para [Str "In",Space,Str "Markdown",Space,Str "1.0.0",Space,Str "and",Space,Str "earlier.",Space,Str "Version",Space,Str "8.",Space,Str "This",Space,Str "line",Space,Str "turns",Space,Str "into",Space,Str "a",Space,Str "list",Space,Str "item.",Space,Str "Because",Space,Str "a",Space,Str "hard-wrapped",Space,Str "line",Space,Str "in",Space,Str "the",Space,Str "middle",Space,Str "of",Space,Str "a",Space,Str "paragraph",Space,Str "looked",Space,Str "like",Space,Str "a",Space,Str "list",Space,Str "item."]+,Para [Str "Here\8217s",Space,Str "one",Space,Str "with",Space,Str "a",Space,Str "bullet.",Space,Str "*",Space,Str "criminey."]+,Para [Str "Horizontal",Space,Str "rule:"] ,HorizontalRule-,Para [Str "Another",Str ":"]+,Para [Str "Another:"] ,HorizontalRule-,Header 1 [Str "Block",Space,Str "Quotes"]-,Para [Str "Here",Str "\8217",Str "s",Space,Str "a",Space,Str "block",Space,Str "quote",Str ":"]+,Header 1 ("",[],[]) [Str "Block",Space,Str "Quotes"]+,Para [Str "Here\8217s",Space,Str "a",Space,Str "block",Space,Str "quote:"] ,BlockQuote- [Para [Str "This",Space,Str "is",Space,Str "a",Space,Str "block",Space,Str "quote",Str ".",Space,Str "It",Space,Str "is",Space,Str "pretty",Space,Str "short",Str "."]]-,Para [Str "Here",Str "\8217",Str "s",Space,Str "another,",Space,Str "differently",Space,Str "indented",Str ":"]+ [Para [Str "This",Space,Str "is",Space,Str "a",Space,Str "block",Space,Str "quote.",Space,Str "It",Space,Str "is",Space,Str "pretty",Space,Str "short."]]+,Para [Str "Here\8217s",Space,Str "another,",Space,Str "differently",Space,Str "indented:"] ,BlockQuote- [Para [Str "This",Space,Str "is",Space,Str "a",Space,Str "block",Space,Str "quote",Str ".",Space,Str "It",Str "\8217",Str "s",Space,Str "indented",Space,Str "with",Space,Str "a",Space,Str "tab",Str "."]- ,Para [Str "Code",Space,Str "in",Space,Str "a",Space,Str "block",Space,Str "quote",Str ":"]+ [Para [Str "This",Space,Str "is",Space,Str "a",Space,Str "block",Space,Str "quote.",Space,Str "It\8217s",Space,Str "indented",Space,Str "with",Space,Str "a",Space,Str "tab."]+ ,Para [Str "Code",Space,Str "in",Space,Str "a",Space,Str "block",Space,Str "quote:"] ,CodeBlock ("",[],[]) "sub status {\n print \"working\";\n}"- ,Para [Str "List",Space,Str "in",Space,Str "a",Space,Str "block",Space,Str "quote",Str ":"]+ ,Para [Str "List",Space,Str "in",Space,Str "a",Space,Str "block",Space,Str "quote:"] ,OrderedList (1,Decimal,Period) [[Plain [Str "item",Space,Str "one"]] ,[Plain [Str "item",Space,Str "two"]]]- ,Para [Str "Nested",Space,Str "block",Space,Str "quotes",Str ":"]+ ,Para [Str "Nested",Space,Str "block",Space,Str "quotes:"] ,BlockQuote [Para [Str "nested"] ,BlockQuote [Para [Str "nested"]]]]-,Header 1 [Str "Code",Space,Str "Blocks"]-,Para [Str "Code",Str ":"]+,Header 1 ("",[],[]) [Str "Code",Space,Str "Blocks"]+,Para [Str "Code:"] ,CodeBlock ("",[],[]) "---- (should be four hyphens)\n\nsub status {\n print \"working\";\n}" ,CodeBlock ("",[],[]) "this code block is indented by one tab"-,Para [Str "And",Str ":"]+,Para [Str "And:"] ,CodeBlock ("",[],[]) "this block is indented by two tabs\n\nThese should not be escaped: \\$ \\\\ \\> \\[ \\{"-,Para [Str "And",Str ":"]+,Para [Str "And:"] ,CodeBlock ("",["sourceCode","python"],[]) "def my_function(x):\n return x + 1"-,Header 1 [Str "Lists"]-,Header 2 [Str "Unordered"]-,Para [Str "Asterisks",Space,Str "tight",Str ":"]+,Header 1 ("",[],[]) [Str "Lists"]+,Header 2 ("",[],[]) [Str "Unordered"]+,Para [Str "Asterisks",Space,Str "tight:"] ,BulletList [[Plain [Str "asterisk",Space,Str "1"]] ,[Plain [Str "asterisk",Space,Str "2"]] ,[Plain [Str "asterisk",Space,Str "3"]]]-,Para [Str "Asterisks",Space,Str "loose",Str ":"]+,Para [Str "Asterisks",Space,Str "loose:"] ,BulletList [[Para [Str "asterisk",Space,Str "1"]] ,[Para [Str "asterisk",Space,Str "2"]] ,[Para [Str "asterisk",Space,Str "3"]]]-,Para [Str "Pluses",Space,Str "tight",Str ":"]+,Para [Str "Pluses",Space,Str "tight:"] ,BulletList [[Plain [Str "Plus",Space,Str "1"]] ,[Plain [Str "Plus",Space,Str "2"]] ,[Plain [Str "Plus",Space,Str "3"]]]-,Para [Str "Pluses",Space,Str "loose",Str ":"]+,Para [Str "Pluses",Space,Str "loose:"] ,BulletList [[Para [Str "Plus",Space,Str "1"]] ,[Para [Str "Plus",Space,Str "2"]] ,[Para [Str "Plus",Space,Str "3"]]]-,Para [Str "Minuses",Space,Str "tight",Str ":"]+,Para [Str "Minuses",Space,Str "tight:"] ,BulletList [[Plain [Str "Minus",Space,Str "1"]] ,[Plain [Str "Minus",Space,Str "2"]] ,[Plain [Str "Minus",Space,Str "3"]]]-,Para [Str "Minuses",Space,Str "loose",Str ":"]+,Para [Str "Minuses",Space,Str "loose:"] ,BulletList [[Para [Str "Minus",Space,Str "1"]] ,[Para [Str "Minus",Space,Str "2"]] ,[Para [Str "Minus",Space,Str "3"]]]-,Header 2 [Str "Ordered"]-,Para [Str "Tight",Str ":"]+,Header 2 ("",[],[]) [Str "Ordered"]+,Para [Str "Tight:"] ,OrderedList (1,Decimal,Period) [[Plain [Str "First"]] ,[Plain [Str "Second"]] ,[Plain [Str "Third"]]]-,Para [Str "and",Str ":"]+,Para [Str "and:"] ,OrderedList (1,Decimal,Period) [[Plain [Str "One"]] ,[Plain [Str "Two"]] ,[Plain [Str "Three"]]]-,Para [Str "Loose",Space,Str "using",Space,Str "tabs",Str ":"]+,Para [Str "Loose",Space,Str "using",Space,Str "tabs:"] ,OrderedList (1,Decimal,Period) [[Para [Str "First"]] ,[Para [Str "Second"]] ,[Para [Str "Third"]]]-,Para [Str "and",Space,Str "using",Space,Str "spaces",Str ":"]+,Para [Str "and",Space,Str "using",Space,Str "spaces:"] ,OrderedList (1,Decimal,Period) [[Para [Str "One"]] ,[Para [Str "Two"]] ,[Para [Str "Three"]]]-,Para [Str "Multiple",Space,Str "paragraphs",Str ":"]+,Para [Str "Multiple",Space,Str "paragraphs:"] ,OrderedList (1,Decimal,Period)- [[Para [Str "Item",Space,Str "1,",Space,Str "graf",Space,Str "one",Str "."]- ,Para [Str "Item",Space,Str "1",Str ".",Space,Str "graf",Space,Str "two",Str ".",Space,Str "The",Space,Str "quick",Space,Str "brown",Space,Str "fox",Space,Str "jumped",Space,Str "over",Space,Str "the",Space,Str "lazy",Space,Str "dog",Str "\8217",Str "s",Space,Str "back",Str "."]]- ,[Para [Str "Item",Space,Str "2",Str "."]]- ,[Para [Str "Item",Space,Str "3",Str "."]]]-,Para [Str "Nested",Str ":"]+ [[Para [Str "Item",Space,Str "1,",Space,Str "graf",Space,Str "one."]+ ,Para [Str "Item",Space,Str "1.",Space,Str "graf",Space,Str "two.",Space,Str "The",Space,Str "quick",Space,Str "brown",Space,Str "fox",Space,Str "jumped",Space,Str "over",Space,Str "the",Space,Str "lazy",Space,Str "dog\8217s",Space,Str "back."]]+ ,[Para [Str "Item",Space,Str "2."]]+ ,[Para [Str "Item",Space,Str "3."]]]+,Para [Str "Nested:"] ,BulletList [[Para [Str "Tab"] ,BulletList [[Para [Str "Tab"] ,BulletList [[Plain [Str "Tab"]]]]]]]-,Para [Str "Here",Str "\8217",Str "s",Space,Str "another",Str ":"]+,Para [Str "Here\8217s",Space,Str "another:"] ,OrderedList (1,Decimal,Period) [[Para [Str "First"]]- ,[Para [Str "Second",Str ":"]+ ,[Para [Str "Second:"] ,BlockQuote [BulletList [[Plain [Str "Fee"]] ,[Plain [Str "Fie"]] ,[Plain [Str "Foe"]]]]] ,[Para [Str "Third"]]]-,Header 2 [Str "Fancy",Space,Str "list",Space,Str "markers"]+,Header 2 ("",[],[]) [Str "Fancy",Space,Str "list",Space,Str "markers"] ,OrderedList (2,Decimal,TwoParens) [[Plain [Str "begins",Space,Str "with",Space,Str "2"]] ,[Para [Str "and",Space,Str "now",Space,Str "3"]@@ -129,111 +129,112 @@ ,OrderedList (1,UpperAlpha,TwoParens) [[Plain [Str "a",Space,Str "subsublist"]] ,[Plain [Str "a",Space,Str "subsublist"]]]]]]]-,Para [Str "Nesting",Str ":"]+,Para [Str "Nesting:"] ,OrderedList (1,UpperAlpha,Period) [[Para [Str "Upper",Space,Str "Alpha"] ,OrderedList (1,UpperRoman,Period)- [[Para [Str "Upper",Space,Str "Roman",Str "."]+ [[Para [Str "Upper",Space,Str "Roman."] ,OrderedList (6,Decimal,TwoParens) [[Para [Str "Decimal",Space,Str "start",Space,Str "with",Space,Str "6"] ,OrderedList (3,LowerAlpha,OneParen) [[Plain [Str "Lower",Space,Str "alpha",Space,Str "with",Space,Str "paren"]]]]]]]]]-,Para [Str "Autonumbering",Str ":"]+,Para [Str "Autonumbering:"] ,OrderedList (1,DefaultStyle,DefaultDelim)- [[Plain [Str "Autonumber",Str "."]]- ,[Para [Str "More",Str "."]+ [[Plain [Str "Autonumber."]]+ ,[Para [Str "More."] ,OrderedList (1,DefaultStyle,DefaultDelim)- [[Plain [Str "Nested",Str "."]]]]]-,Para [Str "Autonumbering",Space,Str "with",Space,Str "explicit",Space,Str "start",Str ":"]+ [[Plain [Str "Nested."]]]]]+,Para [Str "Autonumbering",Space,Str "with",Space,Str "explicit",Space,Str "start:"] ,OrderedList (4,LowerAlpha,TwoParens) [[Plain [Str "item",Space,Str "1"]] ,[Plain [Str "item",Space,Str "2"]]]-,Header 2 [Str "Definition"]+,Header 2 ("",[],[]) [Str "Definition"] ,DefinitionList [([Str "term",Space,Str "1"],- [[Para [Str "Definition",Space,Str "1",Str "."]]])+ [[Para [Str "Definition",Space,Str "1."]]]) ,([Str "term",Space,Str "2"],- [[Para [Str "Definition",Space,Str "2,",Space,Str "paragraph",Space,Str "1",Str "."]- ,Para [Str "Definition",Space,Str "2,",Space,Str "paragraph",Space,Str "2",Str "."]]])+ [[Para [Str "Definition",Space,Str "2,",Space,Str "paragraph",Space,Str "1."]+ ,Para [Str "Definition",Space,Str "2,",Space,Str "paragraph",Space,Str "2."]]]) ,([Str "term",Space,Str "with",Space,Emph [Str "emphasis"]],- [[Para [Str "Definition",Space,Str "3",Str "."]]])]-,Header 1 [Str "Field",Space,Str "Lists"]+ [[Para [Str "Definition",Space,Str "3."]]])]+,Header 1 ("",[],[]) [Str "Field",Space,Str "Lists"] ,BlockQuote [DefinitionList [([Str "address"],- [[Para [Str "61",Space,Str "Main",Space,Str "St",Str "."]]])+ [[Para [Str "61",Space,Str "Main",Space,Str "St."]]]) ,([Str "city"], [[Para [Emph [Str "Nowhere"],Str ",",Space,Str "MA,",Space,Str "USA"]]]) ,([Str "phone"],- [[Para [Str "123",Str "-",Str "4567"]]])]]+ [[Para [Str "123-4567"]]])]] ,DefinitionList [([Str "address"],- [[Para [Str "61",Space,Str "Main",Space,Str "St",Str "."]]])+ [[Para [Str "61",Space,Str "Main",Space,Str "St."]]]) ,([Str "city"], [[Para [Emph [Str "Nowhere"],Str ",",Space,Str "MA,",Space,Str "USA"]]]) ,([Str "phone"],- [[Para [Str "123",Str "-",Str "4567"]]])]-,Header 1 [Str "HTML",Space,Str "Blocks"]-,Para [Str "Simple",Space,Str "block",Space,Str "on",Space,Str "one",Space,Str "line",Str ":"]-,RawBlock "html" "<div>foo</div>\n"-,Para [Str "Now,",Space,Str "nested",Str ":"]-,RawBlock "html" "<div>\n <div>\n <div>\n foo\n </div>\n </div>\n</div>\n"-,Header 1 [Str "LaTeX",Space,Str "Block"]-,RawBlock "latex" "\\begin{tabular}{|l|l|}\\hline\nAnimal & Number \\\\ \\hline\nDog & 2 \\\\\nCat & 1 \\\\ \\hline\n\\end{tabular}\n"-,Header 1 [Str "Inline",Space,Str "Markup"]+ [[Para [Str "123-4567"]]])]+,Header 1 ("",[],[]) [Str "HTML",Space,Str "Blocks"]+,Para [Str "Simple",Space,Str "block",Space,Str "on",Space,Str "one",Space,Str "line:"]+,RawBlock "html" "<div>foo</div>"+,Para [Str "Now,",Space,Str "nested:"]+,RawBlock "html" "<div>\n <div>\n <div>\n foo\n </div>\n </div>\n</div>"+,Header 1 ("",[],[]) [Str "LaTeX",Space,Str "Block"]+,RawBlock "latex" "\\begin{tabular}{|l|l|}\\hline\nAnimal & Number \\\\ \\hline\nDog & 2 \\\\\nCat & 1 \\\\ \\hline\n\\end{tabular}"+,Header 1 ("",[],[]) [Str "Inline",Space,Str "Markup"] ,Para [Str "This",Space,Str "is",Space,Emph [Str "emphasized"],Str ".",Space,Str "This",Space,Str "is",Space,Strong [Str "strong"],Str "."]-,Para [Str "This",Space,Str "is",Space,Str "code",Str ":",Space,Code ("",[],[]) ">",Str ",",Space,Code ("",[],[]) "$",Str ",",Space,Code ("",[],[]) "\\",Str ",",Space,Code ("",[],[]) "\\$",Str ",",Space,Code ("",[],[]) "<html>",Str "."]+,Para [Str "This",Space,Str "is",Space,Str "code:",Space,Code ("",[],[]) ">",Str ",",Space,Code ("",[],[]) "$",Str ",",Space,Code ("",[],[]) "\\",Str ",",Space,Code ("",[],[]) "\\$",Str ",",Space,Code ("",[],[]) "<html>",Str "."] ,Para [Str "This",Space,Str "is",Subscript [Str "subscripted"],Space,Str "and",Space,Str "this",Space,Str "is",Space,Superscript [Str "superscripted"],Str "."]-,Header 1 [Str "Special",Space,Str "Characters"]-,Para [Str "Here",Space,Str "is",Space,Str "some",Space,Str "unicode",Str ":"]+,Header 1 ("",[],[]) [Str "Special",Space,Str "Characters"]+,Para [Str "Here",Space,Str "is",Space,Str "some",Space,Str "unicode:"] ,BulletList- [[Plain [Str "I",Space,Str "hat",Str ":",Space,Str "\206"]]- ,[Plain [Str "o",Space,Str "umlaut",Str ":",Space,Str "\246"]]- ,[Plain [Str "section",Str ":",Space,Str "\167"]]- ,[Plain [Str "set",Space,Str "membership",Str ":",Space,Str "\8712"]]- ,[Plain [Str "copyright",Str ":",Space,Str "\169"]]]-,Para [Str "AT&T",Space,Str "has",Space,Str "an",Space,Str "ampersand",Space,Str "in",Space,Str "their",Space,Str "name",Str "."]-,Para [Str "This",Space,Str "&",Space,Str "that",Str "."]-,Para [Str "4",Space,Str "<",Space,Str "5",Str "."]-,Para [Str "6",Space,Str ">",Space,Str "5",Str "."]-,Para [Str "Backslash",Str ":",Space,Str "\\"]-,Para [Str "Backtick",Str ":",Space,Str "`"]-,Para [Str "Asterisk",Str ":",Space,Str "*"]-,Para [Str "Underscore",Str ":",Space,Str "_"]-,Para [Str "Left",Space,Str "brace",Str ":",Space,Str "{"]-,Para [Str "Right",Space,Str "brace",Str ":",Space,Str "}"]-,Para [Str "Left",Space,Str "bracket",Str ":",Space,Str "["]-,Para [Str "Right",Space,Str "bracket",Str ":",Space,Str "]"]-,Para [Str "Left",Space,Str "paren",Str ":",Space,Str "("]-,Para [Str "Right",Space,Str "paren",Str ":",Space,Str ")"]-,Para [Str "Greater",Str "-",Str "than",Str ":",Space,Str ">"]-,Para [Str "Hash",Str ":",Space,Str "#"]-,Para [Str "Period",Str ":",Space,Str "."]-,Para [Str "Bang",Str ":",Space,Str "!"]-,Para [Str "Plus",Str ":",Space,Str "+"]-,Para [Str "Minus",Str ":",Space,Str "-"]-,Header 1 [Str "Links"]-,Para [Str "Explicit",Str ":",Space,Str "a",Space,Link [Str "URL"] ("/url/",""),Str "."]-,Para [Str "Two",Space,Str "anonymous",Space,Str "links",Str ":",Space,Link [Str "the",Space,Str "first"] ("/url1/",""),Space,Str "and",Space,Link [Str "the",Space,Str "second"] ("/url2/","")]-,Para [Str "Reference",Space,Str "links",Str ":",Space,Link [Str "link1"] ("/url1/",""),Space,Str "and",Space,Link [Str "link2"] ("/url2/",""),Space,Str "and",Space,Link [Str "link1"] ("/url1/",""),Space,Str "again",Str "."]-,Para [Str "Here",Str "\8217",Str "s",Space,Str "a",Space,Link [Str "link",Space,Str "with",Space,Str "an",Space,Str "ampersand",Space,Str "in",Space,Str "the",Space,Str "URL"] ("http://example.com/?foo=1&bar=2",""),Str "."]-,Para [Str "Here",Str "\8217",Str "s",Space,Str "a",Space,Str "link",Space,Str "with",Space,Str "an",Space,Str "amersand",Space,Str "in",Space,Str "the",Space,Str "link",Space,Str "text",Str ":",Space,Link [Str "AT&T"] ("/url/",""),Str "."]-,Para [Str "Autolinks",Str ":",Space,Link [Str "http://example.com/?foo=1&bar=2"] ("http://example.com/?foo=1&bar=2",""),Space,Str "and",Space,Link [Str "nobody@nowhere.net"] ("mailto:nobody@nowhere.net",""),Str "."]-,Para [Str "But",Space,Str "not",Space,Str "here",Str ":"]+ [[Plain [Str "I",Space,Str "hat:",Space,Str "\206"]]+ ,[Plain [Str "o",Space,Str "umlaut:",Space,Str "\246"]]+ ,[Plain [Str "section:",Space,Str "\167"]]+ ,[Plain [Str "set",Space,Str "membership:",Space,Str "\8712"]]+ ,[Plain [Str "copyright:",Space,Str "\169"]]]+,Para [Str "AT&T",Space,Str "has",Space,Str "an",Space,Str "ampersand",Space,Str "in",Space,Str "their",Space,Str "name."]+,Para [Str "This",Space,Str "&",Space,Str "that."]+,Para [Str "4",Space,Str "<",Space,Str "5."]+,Para [Str "6",Space,Str ">",Space,Str "5."]+,Para [Str "Backslash:",Space,Str "\\"]+,Para [Str "Backtick:",Space,Str "`"]+,Para [Str "Asterisk:",Space,Str "*"]+,Para [Str "Underscore:",Space,Str "_"]+,Para [Str "Left",Space,Str "brace:",Space,Str "{"]+,Para [Str "Right",Space,Str "brace:",Space,Str "}"]+,Para [Str "Left",Space,Str "bracket:",Space,Str "["]+,Para [Str "Right",Space,Str "bracket:",Space,Str "]"]+,Para [Str "Left",Space,Str "paren:",Space,Str "("]+,Para [Str "Right",Space,Str "paren:",Space,Str ")"]+,Para [Str "Greater-than:",Space,Str ">"]+,Para [Str "Hash:",Space,Str "#"]+,Para [Str "Period:",Space,Str "."]+,Para [Str "Bang:",Space,Str "!"]+,Para [Str "Plus:",Space,Str "+"]+,Para [Str "Minus:",Space,Str "-"]+,Header 1 ("",[],[]) [Str "Links"]+,Para [Str "Explicit:",Space,Str "a",Space,Link [Str "URL"] ("/url/",""),Str "."]+,Para [Str "Two",Space,Str "anonymous",Space,Str "links:",Space,Link [Str "the",Space,Str "first"] ("/url1/",""),Space,Str "and",Space,Link [Str "the",Space,Str "second"] ("/url2/","")]+,Para [Str "Reference",Space,Str "links:",Space,Link [Str "link1"] ("/url1/",""),Space,Str "and",Space,Link [Str "link2"] ("/url2/",""),Space,Str "and",Space,Link [Str "link1"] ("/url1/",""),Space,Str "again."]+,Para [Str "Here\8217s",Space,Str "a",Space,Link [Str "link",Space,Str "with",Space,Str "an",Space,Str "ampersand",Space,Str "in",Space,Str "the",Space,Str "URL"] ("http://example.com/?foo=1&bar=2",""),Str "."]+,Para [Str "Here\8217s",Space,Str "a",Space,Str "link",Space,Str "with",Space,Str "an",Space,Str "amersand",Space,Str "in",Space,Str "the",Space,Str "link",Space,Str "text:",Space,Link [Str "AT&T"] ("/url/",""),Str "."]+,Para [Str "Autolinks:",Space,Link [Str "http://example.com/?foo=1&bar=2"] ("http://example.com/?foo=1&bar=2",""),Space,Str "and",Space,Link [Str "nobody@nowhere.net"] ("mailto:nobody@nowhere.net",""),Str "."]+,Para [Str "But",Space,Str "not",Space,Str "here:"] ,CodeBlock ("",[],[]) "http://example.com/"-,Header 1 [Str "Images"]-,Para [Str "From",Space,Quoted DoubleQuote [Str "Voyage",Space,Str "dans",Space,Str "la",Space,Str "Lune"],Space,Str "by",Space,Str "Georges",Space,Str "Melies",Space,Str "(",Str "1902",Str ")",Str ":"]-,Plain [Image [Str "image"] ("lalune.jpg","")]-,Plain [Image [Str "Voyage dans la Lune"] ("lalune.jpg","")]-,Para [Str "Here",Space,Str "is",Space,Str "a",Space,Str "movie",Space,Image [Str "movie"] ("movie.jpg",""),Space,Str "icon",Str "."]-,Header 1 [Str "Comments"]+,Header 1 ("",[],[]) [Str "Images"]+,Para [Str "From",Space,Quoted DoubleQuote [Str "Voyage",Space,Str "dans",Space,Str "la",Space,Str "Lune"],Space,Str "by",Space,Str "Georges",Space,Str "Melies",Space,Str "(1902):"]+,Para [Image [Str "image"] ("lalune.jpg","")]+,Para [Image [Str "Voyage dans la Lune"] ("lalune.jpg","")]+,Para [Str "Here",Space,Str "is",Space,Str "a",Space,Str "movie",Space,Image [Str "movie"] ("movie.jpg",""),Space,Str "icon."]+,Para [Str "And",Space,Str "an",Space,Link [Image [Str "A movie"] ("movie.jpg","")] ("/url",""),Str "."]+,Header 1 ("",[],[]) [Str "Comments"] ,Para [Str "First",Space,Str "paragraph"] ,Para [Str "Another",Space,Str "paragraph"] ,Para [Str "A",Space,Str "third",Space,Str "paragraph"]-,Header 1 [Str "Line",Space,Str "blocks"]-,Para [Str "But",Space,Str "can",Space,Str "a",Space,Str "bee",Space,Str "be",Space,Str "said",Space,Str "to",Space,Str "be",LineBreak,Str " ",Str "or",Space,Str "not",Space,Str "to",Space,Str "be",Space,Str "an",Space,Str "entire",Space,Str "bee,",LineBreak,Str " ",Str "when",Space,Str "half",Space,Str "the",Space,Str "bee",Space,Str "is",Space,Str "not",Space,Str "a",Space,Str "bee,",LineBreak,Str " ",Str "due",Space,Str "to",Space,Str "some",Space,Str "ancient",Space,Str "injury?"]-,Para [Str "Continuation",Space,Str "line",LineBreak,Str " ",Str "and",Space,Str "another"]-,Header 1 [Str "Simple",Space,Str "Tables"]+,Header 1 ("",[],[]) [Str "Line",Space,Str "blocks"]+,Para [Str "But",Space,Str "can",Space,Str "a",Space,Str "bee",Space,Str "be",Space,Str "said",Space,Str "to",Space,Str "be",LineBreak,Str "\160\160\160\160or",Space,Str "not",Space,Str "to",Space,Str "be",Space,Str "an",Space,Str "entire",Space,Str "bee,",LineBreak,Str "\160\160\160\160\160\160\160\160when",Space,Str "half",Space,Str "the",Space,Str "bee",Space,Str "is",Space,Str "not",Space,Str "a",Space,Str "bee,",LineBreak,Str "\160\160\160\160\160\160\160\160\160\160\160\160due",Space,Str "to",Space,Str "some",Space,Str "ancient",Space,Str "injury?"]+,Para [Str "Continuation",Space,Str "line",LineBreak,Str "\160\160and",Space,Str "another"]+,Header 1 ("",[],[]) [Str "Simple",Space,Str "Tables"] ,Table [] [AlignDefault,AlignDefault,AlignDefault] [0.0,0.0,0.0] [[Plain [Str "col",Space,Str "1"]] ,[Plain [Str "col",Space,Str "2"]]@@ -255,7 +256,7 @@ ,[[Plain [Str "r2",Space,Str "d"]] ,[Plain [Str "e"]] ,[Plain [Str "f"]]]]-,Header 1 [Str "Grid",Space,Str "Tables"]+,Header 1 ("",[],[]) [Str "Grid",Space,Str "Tables"] ,Table [] [AlignDefault,AlignDefault,AlignDefault] [0.2375,0.15,0.1625] [[Plain [Str "col",Space,Str "1"]] ,[Plain [Str "col",Space,Str "2"]]@@ -300,24 +301,26 @@ ,[Plain [Str "b",Space,Str "2"]] ,[Plain [Str "b",Space,Str "2"]]]] ,[Plain [Str "c",Space,Str "c",Space,Str "2",Space,Str "c",Space,Str "2"]]]]-,Header 1 [Str "Footnotes"]-,Para [Note [Para [Str "Note",Space,Str "with",Space,Str "one",Space,Str "line",Str "."]]]-,Para [Note [Para [Str "Note",Space,Str "with",Space,Str "continuation",Space,Str "line",Str "."]]]-,Para [Note [Para [Str "Note",Space,Str "with"],Para [Str "continuation",Space,Str "block",Str "."]]]-,Para [Note [Para [Str "Note",Space,Str "with",Space,Str "continuation",Space,Str "line"],Para [Str "and",Space,Str "a",Space,Str "second",Space,Str "para",Str "."]]]-,Para [Str "Not",Space,Str "in",Space,Str "note",Str "."]-,Header 1 [Str "Math"]-,Para [Str "Some",Space,Str "inline",Space,Str "math",Space,Math InlineMath "E=mc^2",Str ".",Space,Str "Now",Space,Str "some",Space,Str "display",Space,Str "math",Str ":"]+,Header 1 ("",[],[]) [Str "Footnotes"]+,Para [Note [Para [Str "Note",Space,Str "with",Space,Str "one",Space,Str "line."]]]+,Para [Note [Para [Str "Note",Space,Str "with",Space,Str "continuation",Space,Str "line."]]]+,Para [Note [Para [Str "Note",Space,Str "with"],Para [Str "continuation",Space,Str "block."]]]+,Para [Note [Para [Str "Note",Space,Str "with",Space,Str "continuation",Space,Str "line"],Para [Str "and",Space,Str "a",Space,Str "second",Space,Str "para."]]]+,Para [Str "Not",Space,Str "in",Space,Str "note."]+,Header 1 ("",[],[]) [Str "Math"]+,Para [Str "Some",Space,Str "inline",Space,Str "math",Space,Math InlineMath "E=mc^2",Str ".",Space,Str "Now",Space,Str "some",Space,Str "display",Space,Str "math:"] ,Para [Math DisplayMath "E=mc^2"] ,Para [Math DisplayMath "E = mc^2"] ,Para [Math DisplayMath "E = mc^2",Math DisplayMath "\\alpha = \\beta"] ,Para [Math DisplayMath "E &= mc^2\\\\\nF &= \\pi E",Math DisplayMath "F &= \\gamma \\alpha^2"]-,Para [Str "All",Space,Str "done",Str "."]-,Header 1 [Str "Default",Str "-",Str "Role"]-,Para [Str "Try",Space,Str "changing",Space,Str "the",Space,Str "default",Space,Str "role",Space,Str "to",Space,Str "a",Space,Str "few",Space,Str "different",Space,Str "things",Str "."]-,Header 2 [Str "Doesn",Str "\8217",Str "t",Space,Str "Break",Space,Str "Title",Space,Str "Parsing"]-,Para [Str "Inline",Space,Str "math",Str ":",Space,Math InlineMath "E=mc^2",Space,Str "or",Space,Math InlineMath "E=mc^2",Space,Str "or",Space,Math InlineMath "E=mc^2",Str ".",Space,Str "Other",Space,Str "roles",Str ":",Space,Superscript [Str "super"],Str ",",Space,Subscript [Str "sub"],Str "."]+,Para [Str "All",Space,Str "done."]+,Header 1 ("",[],[]) [Str "Default-Role"]+,Para [Str "Try",Space,Str "changing",Space,Str "the",Space,Str "default",Space,Str "role",Space,Str "to",Space,Str "a",Space,Str "few",Space,Str "different",Space,Str "things."]+,Header 2 ("",[],[]) [Str "Doesn\8217t",Space,Str "Break",Space,Str "Title",Space,Str "Parsing"]+,Para [Str "Inline",Space,Str "math:",Space,Math InlineMath "E=mc^2",Space,Str "or",Space,Math InlineMath "E=mc^2",Space,Str "or",Space,Math InlineMath "E=mc^2",Str ".",Space,Str "Other",Space,Str "roles:",Space,Superscript [Str "super"],Str ",",Space,Subscript [Str "sub"],Str "."] ,Para [Math DisplayMath "\\alpha = beta",Math DisplayMath "E = mc^2"] ,Para [Str "Some",Space,Superscript [Str "of"],Space,Str "these",Space,Superscript [Str "words"],Space,Str "are",Space,Str "in",Space,Superscript [Str "superscript"],Str "."]-,Para [Str "Reset",Space,Str "default",Str "-",Str "role",Space,Str "to",Space,Str "the",Space,Str "default",Space,Str "default",Str "."]-,Para [Str "And",Space,Str "now",Space,Str "`",Str "some",Str "-",Str "invalid",Str "-",Str "string",Str "-",Str "3231231",Str "`",Space,Str "is",Space,Str "nonsense",Str "."]]+,Para [Str "Reset",Space,Str "default-role",Space,Str "to",Space,Str "the",Space,Str "default",Space,Str "default."]+,Para [Str "And",Space,Str "now",Space,Str "some-invalid-string-3231231",Space,Str "is",Space,Str "nonsense."]+,Header 2 ("",[],[]) [Str "Literal",Space,Str "symbols"]+,Para [Str "2*2",Space,Str "=",Space,Str "4*1"]]
@@ -279,7 +279,8 @@ :address: 61 Main St. :city: *Nowhere*, MA, USA-:phone: 123-4567+:phone:+ 123-4567 HTML Blocks ===========@@ -415,6 +416,12 @@ .. |movie| image:: movie.jpg +And an |image with a link|.++.. |image with a link| image:: movie.jpg+ :alt: A movie+ :target: /url+ Comments ======== @@ -447,7 +454,7 @@ | or not to be an entire bee, | when half the bee is not a bee, | due to some ancient injury?-+| | Continuation line | and@@ -555,8 +562,8 @@ \alpha = \beta .. math::- :label hithere- :nowrap+ :label: hithere+ :nowrap: E &= mc^2\\ F &= \pi E@@ -593,3 +600,7 @@ And now `some-invalid-string-3231231` is nonsense. +Literal symbols+---------------++2*2 = 4*1
@@ -8,6 +8,7 @@ <meta name="author" content="Jen Jones" /> <meta name="date" content="2006-07-15" /> <title>My S5 Document</title>+ <style type="text/css">code{white-space: pre;}</style> <!-- configuration parameters --> <meta name="defaultView" content="slideshow" /> <meta name="controlVis" content="hidden" />
@@ -8,6 +8,7 @@ <meta name="author" content="Jen Jones" /> <meta name="date" content="2006-07-15" /> <title>My S5 Document</title>+ <style type="text/css">code{white-space: pre;}</style> <!-- configuration parameters --> <meta name="defaultView" content="slideshow" /> <meta name="controlVis" content="hidden" />
@@ -8,6 +8,7 @@ <meta name="author" content="Jen Jones" /> <meta name="date" content="2006-07-15" /> <title>My S5 Document</title>+ <style type="text/css">code{white-space: pre;}</style> <link rel="stylesheet" href="main.css" type="text/css" /> STUFF INSERTED </head>
@@ -1,8 +1,8 @@ Pandoc (Meta {docTitle = [Str "My",Space,Str "S5",Space,Str "Document"], docAuthors = [[Str "Sam",Space,Str "Smith"],[Str "Jen",Space,Str "Jones"]], docDate = [Str "July",Space,Str "15,",Space,Str "2006"]})-[Header 1 [Str "First",Space,Str "slide"]+[Header 1 ("first-slide",[],[]) [Str "First",Space,Str "slide"] ,BulletList [[Plain [Str "first",Space,Str "bullet"]] ,[Plain [Str "second",Space,Str "bullet"]]]-,Header 1 [Str "Math"]+,Header 1 ("math",[],[]) [Str "Math"] ,BulletList [[Plain [Math InlineMath "\\frac{d}{dx}f(x)=\\lim_{h\\to 0}\\frac{f(x+h)-f(x)}{h}"]]]]
@@ -1,4 +1,4 @@-[Para [Str "Simple",Space,Str "table",Space,Str "with",Space,Str "caption",Str ":"]+[Para [Str "Simple",Space,Str "table",Space,Str "with",Space,Str "caption:"] ,Table [] [AlignDefault,AlignDefault,AlignDefault,AlignDefault] [0.125,0.1125,0.1375,0.15] [[Plain [Str "Right"]] ,[Plain [Str "Left"]]@@ -16,8 +16,8 @@ ,[Plain [Str "1"]] ,[Plain [Str "1"]] ,[Plain [Str "1"]]]]-,Para [Str "Table",Str ":",Space,Str "Demonstration",Space,Str "of",Space,Str "simple",Space,Str "table",Space,Str "syntax",Str "."]-,Para [Str "Simple",Space,Str "table",Space,Str "without",Space,Str "caption",Str ":"]+,Para [Str "Table:",Space,Str "Demonstration",Space,Str "of",Space,Str "simple",Space,Str "table",Space,Str "syntax."]+,Para [Str "Simple",Space,Str "table",Space,Str "without",Space,Str "caption:"] ,Table [] [AlignDefault,AlignDefault,AlignDefault,AlignDefault] [0.125,0.1125,0.1375,0.15] [[Plain [Str "Right"]] ,[Plain [Str "Left"]]@@ -35,7 +35,7 @@ ,[Plain [Str "1"]] ,[Plain [Str "1"]] ,[Plain [Str "1"]]]]-,Para [Str "Simple",Space,Str "table",Space,Str "indented",Space,Str "two",Space,Str "spaces",Str ":"]+,Para [Str "Simple",Space,Str "table",Space,Str "indented",Space,Str "two",Space,Str "spaces:"] ,Table [] [AlignDefault,AlignDefault,AlignDefault,AlignDefault] [0.125,0.1125,0.1375,0.15] [[Plain [Str "Right"]] ,[Plain [Str "Left"]]@@ -53,8 +53,8 @@ ,[Plain [Str "1"]] ,[Plain [Str "1"]] ,[Plain [Str "1"]]]]-,Para [Str "Table",Str ":",Space,Str "Demonstration",Space,Str "of",Space,Str "simple",Space,Str "table",Space,Str "syntax",Str "."]-,Para [Str "Multiline",Space,Str "table",Space,Str "with",Space,Str "caption",Str ":"]+,Para [Str "Table:",Space,Str "Demonstration",Space,Str "of",Space,Str "simple",Space,Str "table",Space,Str "syntax."]+,Para [Str "Multiline",Space,Str "table",Space,Str "with",Space,Str "caption:"] ,Table [] [AlignDefault,AlignDefault,AlignDefault,AlignDefault] [0.175,0.1625,0.1875,0.3625] [[Plain [Str "Centered",Space,Str "Header"]] ,[Plain [Str "Left",Space,Str "Aligned"]]@@ -62,14 +62,14 @@ ,[Plain [Str "Default",Space,Str "aligned"]]] [[[Plain [Str "First"]] ,[Plain [Str "row"]]- ,[Plain [Str "12",Str ".",Str "0"]]- ,[Plain [Str "Example",Space,Str "of",Space,Str "a",Space,Str "row",Space,Str "that",Space,Str "spans",Space,Str "multiple",Space,Str "lines",Str "."]]]+ ,[Plain [Str "12.0"]]+ ,[Plain [Str "Example",Space,Str "of",Space,Str "a",Space,Str "row",Space,Str "that",Space,Str "spans",Space,Str "multiple",Space,Str "lines."]]] ,[[Plain [Str "Second"]] ,[Plain [Str "row"]]- ,[Plain [Str "5",Str ".",Str "0"]]- ,[Plain [Str "Here",Str "'",Str "s",Space,Str "another",Space,Str "one",Str ".",Space,Str "Note",Space,Str "the",Space,Str "blank",Space,Str "line",Space,Str "between",Space,Str "rows",Str "."]]]]-,Para [Str "Table",Str ":",Space,Str "Here",Str "'",Str "s",Space,Str "the",Space,Str "caption",Str ".",Space,Str "It",Space,Str "may",Space,Str "span",Space,Str "multiple",Space,Str "lines",Str "."]-,Para [Str "Multiline",Space,Str "table",Space,Str "without",Space,Str "caption",Str ":"]+ ,[Plain [Str "5.0"]]+ ,[Plain [Str "Here's",Space,Str "another",Space,Str "one.",Space,Str "Note",Space,Str "the",Space,Str "blank",Space,Str "line",Space,Str "between",Space,Str "rows."]]]]+,Para [Str "Table:",Space,Str "Here's",Space,Str "the",Space,Str "caption.",Space,Str "It",Space,Str "may",Space,Str "span",Space,Str "multiple",Space,Str "lines."]+,Para [Str "Multiline",Space,Str "table",Space,Str "without",Space,Str "caption:"] ,Table [] [AlignDefault,AlignDefault,AlignDefault,AlignDefault] [0.175,0.1625,0.1875,0.3625] [[Plain [Str "Centered",Space,Str "Header"]] ,[Plain [Str "Left",Space,Str "Aligned"]]@@ -77,13 +77,13 @@ ,[Plain [Str "Default",Space,Str "aligned"]]] [[[Plain [Str "First"]] ,[Plain [Str "row"]]- ,[Plain [Str "12",Str ".",Str "0"]]- ,[Plain [Str "Example",Space,Str "of",Space,Str "a",Space,Str "row",Space,Str "that",Space,Str "spans",Space,Str "multiple",Space,Str "lines",Str "."]]]+ ,[Plain [Str "12.0"]]+ ,[Plain [Str "Example",Space,Str "of",Space,Str "a",Space,Str "row",Space,Str "that",Space,Str "spans",Space,Str "multiple",Space,Str "lines."]]] ,[[Plain [Str "Second"]] ,[Plain [Str "row"]]- ,[Plain [Str "5",Str ".",Str "0"]]- ,[Plain [Str "Here",Str "'",Str "s",Space,Str "another",Space,Str "one",Str ".",Space,Str "Note",Space,Str "the",Space,Str "blank",Space,Str "line",Space,Str "between",Space,Str "rows",Str "."]]]]-,Para [Str "Table",Space,Str "without",Space,Str "column",Space,Str "headers",Str ":"]+ ,[Plain [Str "5.0"]]+ ,[Plain [Str "Here's",Space,Str "another",Space,Str "one.",Space,Str "Note",Space,Str "the",Space,Str "blank",Space,Str "line",Space,Str "between",Space,Str "rows."]]]]+,Para [Str "Table",Space,Str "without",Space,Str "column",Space,Str "headers:"] ,Table [] [AlignDefault,AlignDefault,AlignDefault,AlignDefault] [0.1,0.1,0.1,0.1] [[] ,[]@@ -101,7 +101,7 @@ ,[Plain [Str "1"]] ,[Plain [Str "1"]] ,[Plain [Str "1"]]]]-,Para [Str "Multiline",Space,Str "table",Space,Str "without",Space,Str "column",Space,Str "headers",Str ":"]+,Para [Str "Multiline",Space,Str "table",Space,Str "without",Space,Str "column",Space,Str "headers:"] ,Table [] [AlignDefault,AlignDefault,AlignDefault,AlignDefault] [0.175,0.1625,0.1875,0.3625] [[] ,[]@@ -109,9 +109,9 @@ ,[]] [[[Plain [Str "First"]] ,[Plain [Str "row"]]- ,[Plain [Str "12",Str ".",Str "0"]]- ,[Plain [Str "Example",Space,Str "of",Space,Str "a",Space,Str "row",Space,Str "that",Space,Str "spans",Space,Str "multiple",Space,Str "lines",Str "."]]]+ ,[Plain [Str "12.0"]]+ ,[Plain [Str "Example",Space,Str "of",Space,Str "a",Space,Str "row",Space,Str "that",Space,Str "spans",Space,Str "multiple",Space,Str "lines."]]] ,[[Plain [Str "Second"]] ,[Plain [Str "row"]]- ,[Plain [Str "5",Str ".",Str "0"]]- ,[Plain [Str "Here",Str "'",Str "s",Space,Str "another",Space,Str "one",Str ".",Space,Str "Note",Space,Str "the",Space,Str "blank",Space,Str "line",Space,Str "between",Space,Str "rows",Str "."]]]]]+ ,[Plain [Str "5.0"]]+ ,[Plain [Str "Here's",Space,Str "another",Space,Str "one.",Space,Str "Note",Space,Str "the",Space,Str "blank",Space,Str "line",Space,Str "between",Space,Str "rows."]]]]]
@@ -1,175 +1,169 @@ Simple table with caption: -\ctable[caption = {Demonstration of simple table syntax.},-pos = H, center, botcap]{rlcl}-{% notes-}-{% rows-\FL+\begin{longtable}[c]{rlcl}+\hline\noalign{\medskip} Right & Left & Center & Default-\ML+\\\noalign{\medskip}+\hline\noalign{\medskip} 12 & 12 & 12 & 12 \\\noalign{\medskip} 123 & 123 & 123 & 123 \\\noalign{\medskip} 1 & 1 & 1 & 1-\LL-}+\\\noalign{\medskip}+\hline+\noalign{\medskip}+\caption{Demonstration of simple table syntax.}+\end{longtable} Simple table without caption: -\ctable[pos = H, center, botcap]{rlcl}-{% notes-}-{% rows-\FL+\begin{longtable}[c]{rlcl}+\hline\noalign{\medskip} Right & Left & Center & Default-\ML+\\\noalign{\medskip}+\hline\noalign{\medskip} 12 & 12 & 12 & 12 \\\noalign{\medskip} 123 & 123 & 123 & 123 \\\noalign{\medskip} 1 & 1 & 1 & 1-\LL-}+\\\noalign{\medskip}+\hline+\end{longtable} Simple table indented two spaces: -\ctable[caption = {Demonstration of simple table syntax.},-pos = H, center, botcap]{rlcl}-{% notes-}-{% rows-\FL+\begin{longtable}[c]{rlcl}+\hline\noalign{\medskip} Right & Left & Center & Default-\ML+\\\noalign{\medskip}+\hline\noalign{\medskip} 12 & 12 & 12 & 12 \\\noalign{\medskip} 123 & 123 & 123 & 123 \\\noalign{\medskip} 1 & 1 & 1 & 1-\LL-}+\\\noalign{\medskip}+\hline+\noalign{\medskip}+\caption{Demonstration of simple table syntax.}+\end{longtable} Multiline table with caption: -\ctable[caption = {Here's the caption. It may span multiple lines.},-pos = H, center, botcap]{clrl}-{% notes-}-{% rows-\FL-\parbox[b]{0.15\columnwidth}{\centering+\begin{longtable}[c]{clrl}+\hline\noalign{\medskip}+\begin{minipage}[b]{0.15\columnwidth}\centering Centered Header-} & \parbox[b]{0.14\columnwidth}{\raggedright+\end{minipage} & \begin{minipage}[b]{0.14\columnwidth}\raggedright Left Aligned-} & \parbox[b]{0.16\columnwidth}{\raggedleft+\end{minipage} & \begin{minipage}[b]{0.16\columnwidth}\raggedleft Right Aligned-} & \parbox[b]{0.34\columnwidth}{\raggedright+\end{minipage} & \begin{minipage}[b]{0.34\columnwidth}\raggedright Default aligned-}-\ML-\parbox[t]{0.15\columnwidth}{\centering+\end{minipage}+\\\noalign{\medskip}+\hline\noalign{\medskip}+\begin{minipage}[t]{0.15\columnwidth}\centering First-} & \parbox[t]{0.14\columnwidth}{\raggedright+\end{minipage} & \begin{minipage}[t]{0.14\columnwidth}\raggedright row-} & \parbox[t]{0.16\columnwidth}{\raggedleft+\end{minipage} & \begin{minipage}[t]{0.16\columnwidth}\raggedleft 12.0-} & \parbox[t]{0.34\columnwidth}{\raggedright+\end{minipage} & \begin{minipage}[t]{0.34\columnwidth}\raggedright Example of a row that spans multiple lines.-}+\end{minipage} \\\noalign{\medskip}-\parbox[t]{0.15\columnwidth}{\centering+\begin{minipage}[t]{0.15\columnwidth}\centering Second-} & \parbox[t]{0.14\columnwidth}{\raggedright+\end{minipage} & \begin{minipage}[t]{0.14\columnwidth}\raggedright row-} & \parbox[t]{0.16\columnwidth}{\raggedleft+\end{minipage} & \begin{minipage}[t]{0.16\columnwidth}\raggedleft 5.0-} & \parbox[t]{0.34\columnwidth}{\raggedright+\end{minipage} & \begin{minipage}[t]{0.34\columnwidth}\raggedright Here's another one. Note the blank line between rows.-}-\LL-}+\end{minipage}+\\\noalign{\medskip}+\hline+\noalign{\medskip}+\caption{Here's the caption. It may span multiple lines.}+\end{longtable} Multiline table without caption: -\ctable[pos = H, center, botcap]{clrl}-{% notes-}-{% rows-\FL-\parbox[b]{0.15\columnwidth}{\centering+\begin{longtable}[c]{clrl}+\hline\noalign{\medskip}+\begin{minipage}[b]{0.15\columnwidth}\centering Centered Header-} & \parbox[b]{0.14\columnwidth}{\raggedright+\end{minipage} & \begin{minipage}[b]{0.14\columnwidth}\raggedright Left Aligned-} & \parbox[b]{0.16\columnwidth}{\raggedleft+\end{minipage} & \begin{minipage}[b]{0.16\columnwidth}\raggedleft Right Aligned-} & \parbox[b]{0.34\columnwidth}{\raggedright+\end{minipage} & \begin{minipage}[b]{0.34\columnwidth}\raggedright Default aligned-}-\ML-\parbox[t]{0.15\columnwidth}{\centering+\end{minipage}+\\\noalign{\medskip}+\hline\noalign{\medskip}+\begin{minipage}[t]{0.15\columnwidth}\centering First-} & \parbox[t]{0.14\columnwidth}{\raggedright+\end{minipage} & \begin{minipage}[t]{0.14\columnwidth}\raggedright row-} & \parbox[t]{0.16\columnwidth}{\raggedleft+\end{minipage} & \begin{minipage}[t]{0.16\columnwidth}\raggedleft 12.0-} & \parbox[t]{0.34\columnwidth}{\raggedright+\end{minipage} & \begin{minipage}[t]{0.34\columnwidth}\raggedright Example of a row that spans multiple lines.-}+\end{minipage} \\\noalign{\medskip}-\parbox[t]{0.15\columnwidth}{\centering+\begin{minipage}[t]{0.15\columnwidth}\centering Second-} & \parbox[t]{0.14\columnwidth}{\raggedright+\end{minipage} & \begin{minipage}[t]{0.14\columnwidth}\raggedright row-} & \parbox[t]{0.16\columnwidth}{\raggedleft+\end{minipage} & \begin{minipage}[t]{0.16\columnwidth}\raggedleft 5.0-} & \parbox[t]{0.34\columnwidth}{\raggedright+\end{minipage} & \begin{minipage}[t]{0.34\columnwidth}\raggedright Here's another one. Note the blank line between rows.-}-\LL-}+\end{minipage}+\\\noalign{\medskip}+\hline+\end{longtable} Table without column headers: -\ctable[pos = H, center, botcap]{rlcr}-{% notes-}-{% rows-\FL+\begin{longtable}[c]{rlcr}+\hline\noalign{\medskip} 12 & 12 & 12 & 12 \\\noalign{\medskip} 123 & 123 & 123 & 123 \\\noalign{\medskip} 1 & 1 & 1 & 1-\LL-}+\\\noalign{\medskip}+\hline+\end{longtable} Multiline table without column headers: -\ctable[pos = H, center, botcap]{clrl}-{% notes-}-{% rows-\FL-\parbox[t]{0.15\columnwidth}{\centering+\begin{longtable}[c]{clrl}+\hline\noalign{\medskip}+\begin{minipage}[t]{0.15\columnwidth}\centering First-} & \parbox[t]{0.14\columnwidth}{\raggedright+\end{minipage} & \begin{minipage}[t]{0.14\columnwidth}\raggedright row-} & \parbox[t]{0.16\columnwidth}{\raggedleft+\end{minipage} & \begin{minipage}[t]{0.16\columnwidth}\raggedleft 12.0-} & \parbox[t]{0.34\columnwidth}{\raggedright+\end{minipage} & \begin{minipage}[t]{0.34\columnwidth}\raggedright Example of a row that spans multiple lines.-}+\end{minipage} \\\noalign{\medskip}-\parbox[t]{0.15\columnwidth}{\centering+\begin{minipage}[t]{0.15\columnwidth}\centering Second-} & \parbox[t]{0.14\columnwidth}{\raggedright+\end{minipage} & \begin{minipage}[t]{0.14\columnwidth}\raggedright row-} & \parbox[t]{0.16\columnwidth}{\raggedleft+\end{minipage} & \begin{minipage}[t]{0.16\columnwidth}\raggedleft 5.0-} & \parbox[t]{0.34\columnwidth}{\raggedright+\end{minipage} & \begin{minipage}[t]{0.34\columnwidth}\raggedright Here's another one. Note the blank line between rows.-}-\LL-}+\end{minipage}+\\\noalign{\medskip}+\hline+\end{longtable}
@@ -1,5 +1,5 @@-[Para [Str "Simple",Space,Str "table",Space,Str "with",Space,Str "caption",Str ":"]-,Table [Str "Demonstration",Space,Str "of",Space,Str "simple",Space,Str "table",Space,Str "syntax",Str "."] [AlignRight,AlignLeft,AlignCenter,AlignDefault] [0.0,0.0,0.0,0.0]+[Para [Str "Simple",Space,Str "table",Space,Str "with",Space,Str "caption:"]+,Table [Str "Demonstration",Space,Str "of",Space,Str "simple",Space,Str "table",Space,Str "syntax."] [AlignRight,AlignLeft,AlignCenter,AlignDefault] [0.0,0.0,0.0,0.0] [[Plain [Str "Right"]] ,[Plain [Str "Left"]] ,[Plain [Str "Center"]]@@ -16,7 +16,7 @@ ,[Plain [Str "1"]] ,[Plain [Str "1"]] ,[Plain [Str "1"]]]]-,Para [Str "Simple",Space,Str "table",Space,Str "without",Space,Str "caption",Str ":"]+,Para [Str "Simple",Space,Str "table",Space,Str "without",Space,Str "caption:"] ,Table [] [AlignRight,AlignLeft,AlignCenter,AlignDefault] [0.0,0.0,0.0,0.0] [[Plain [Str "Right"]] ,[Plain [Str "Left"]]@@ -34,8 +34,8 @@ ,[Plain [Str "1"]] ,[Plain [Str "1"]] ,[Plain [Str "1"]]]]-,Para [Str "Simple",Space,Str "table",Space,Str "indented",Space,Str "two",Space,Str "spaces",Str ":"]-,Table [Str "Demonstration",Space,Str "of",Space,Str "simple",Space,Str "table",Space,Str "syntax",Str "."] [AlignRight,AlignLeft,AlignCenter,AlignDefault] [0.0,0.0,0.0,0.0]+,Para [Str "Simple",Space,Str "table",Space,Str "indented",Space,Str "two",Space,Str "spaces:"]+,Table [Str "Demonstration",Space,Str "of",Space,Str "simple",Space,Str "table",Space,Str "syntax."] [AlignRight,AlignLeft,AlignCenter,AlignDefault] [0.0,0.0,0.0,0.0] [[Plain [Str "Right"]] ,[Plain [Str "Left"]] ,[Plain [Str "Center"]]@@ -52,21 +52,21 @@ ,[Plain [Str "1"]] ,[Plain [Str "1"]] ,[Plain [Str "1"]]]]-,Para [Str "Multiline",Space,Str "table",Space,Str "with",Space,Str "caption",Str ":"]-,Table [Str "Here",Str "'",Str "s",Space,Str "the",Space,Str "caption",Str ".",Space,Str "It",Space,Str "may",Space,Str "span",Space,Str "multiple",Space,Str "lines",Str "."] [AlignCenter,AlignLeft,AlignRight,AlignLeft] [0.15,0.1375,0.1625,0.3375]+,Para [Str "Multiline",Space,Str "table",Space,Str "with",Space,Str "caption:"]+,Table [Str "Here's",Space,Str "the",Space,Str "caption.",Space,Str "It",Space,Str "may",Space,Str "span",Space,Str "multiple",Space,Str "lines."] [AlignCenter,AlignLeft,AlignRight,AlignLeft] [0.15,0.1375,0.1625,0.3375] [[Plain [Str "Centered",Space,Str "Header"]] ,[Plain [Str "Left",Space,Str "Aligned"]] ,[Plain [Str "Right",Space,Str "Aligned"]] ,[Plain [Str "Default",Space,Str "aligned"]]] [[[Plain [Str "First"]] ,[Plain [Str "row"]]- ,[Plain [Str "12",Str ".",Str "0"]]- ,[Plain [Str "Example",Space,Str "of",Space,Str "a",Space,Str "row",Space,Str "that",Space,Str "spans",Space,Str "multiple",Space,Str "lines",Str "."]]]+ ,[Plain [Str "12.0"]]+ ,[Plain [Str "Example",Space,Str "of",Space,Str "a",Space,Str "row",Space,Str "that",Space,Str "spans",Space,Str "multiple",Space,Str "lines."]]] ,[[Plain [Str "Second"]] ,[Plain [Str "row"]]- ,[Plain [Str "5",Str ".",Str "0"]]- ,[Plain [Str "Here",Str "'",Str "s",Space,Str "another",Space,Str "one",Str ".",Space,Str "Note",Space,Str "the",Space,Str "blank",Space,Str "line",Space,Str "between",Space,Str "rows",Str "."]]]]-,Para [Str "Multiline",Space,Str "table",Space,Str "without",Space,Str "caption",Str ":"]+ ,[Plain [Str "5.0"]]+ ,[Plain [Str "Here's",Space,Str "another",Space,Str "one.",Space,Str "Note",Space,Str "the",Space,Str "blank",Space,Str "line",Space,Str "between",Space,Str "rows."]]]]+,Para [Str "Multiline",Space,Str "table",Space,Str "without",Space,Str "caption:"] ,Table [] [AlignCenter,AlignLeft,AlignRight,AlignLeft] [0.15,0.1375,0.1625,0.3375] [[Plain [Str "Centered",Space,Str "Header"]] ,[Plain [Str "Left",Space,Str "Aligned"]]@@ -74,13 +74,13 @@ ,[Plain [Str "Default",Space,Str "aligned"]]] [[[Plain [Str "First"]] ,[Plain [Str "row"]]- ,[Plain [Str "12",Str ".",Str "0"]]- ,[Plain [Str "Example",Space,Str "of",Space,Str "a",Space,Str "row",Space,Str "that",Space,Str "spans",Space,Str "multiple",Space,Str "lines",Str "."]]]+ ,[Plain [Str "12.0"]]+ ,[Plain [Str "Example",Space,Str "of",Space,Str "a",Space,Str "row",Space,Str "that",Space,Str "spans",Space,Str "multiple",Space,Str "lines."]]] ,[[Plain [Str "Second"]] ,[Plain [Str "row"]]- ,[Plain [Str "5",Str ".",Str "0"]]- ,[Plain [Str "Here",Str "'",Str "s",Space,Str "another",Space,Str "one",Str ".",Space,Str "Note",Space,Str "the",Space,Str "blank",Space,Str "line",Space,Str "between",Space,Str "rows",Str "."]]]]-,Para [Str "Table",Space,Str "without",Space,Str "column",Space,Str "headers",Str ":"]+ ,[Plain [Str "5.0"]]+ ,[Plain [Str "Here's",Space,Str "another",Space,Str "one.",Space,Str "Note",Space,Str "the",Space,Str "blank",Space,Str "line",Space,Str "between",Space,Str "rows."]]]]+,Para [Str "Table",Space,Str "without",Space,Str "column",Space,Str "headers:"] ,Table [] [AlignRight,AlignLeft,AlignCenter,AlignRight] [0.0,0.0,0.0,0.0] [[] ,[]@@ -98,7 +98,7 @@ ,[Plain [Str "1"]] ,[Plain [Str "1"]] ,[Plain [Str "1"]]]]-,Para [Str "Multiline",Space,Str "table",Space,Str "without",Space,Str "column",Space,Str "headers",Str ":"]+,Para [Str "Multiline",Space,Str "table",Space,Str "without",Space,Str "column",Space,Str "headers:"] ,Table [] [AlignCenter,AlignLeft,AlignRight,AlignDefault] [0.15,0.1375,0.1625,0.3375] [[] ,[]@@ -106,9 +106,9 @@ ,[]] [[[Plain [Str "First"]] ,[Plain [Str "row"]]- ,[Plain [Str "12",Str ".",Str "0"]]- ,[Plain [Str "Example",Space,Str "of",Space,Str "a",Space,Str "row",Space,Str "that",Space,Str "spans",Space,Str "multiple",Space,Str "lines",Str "."]]]+ ,[Plain [Str "12.0"]]+ ,[Plain [Str "Example",Space,Str "of",Space,Str "a",Space,Str "row",Space,Str "that",Space,Str "spans",Space,Str "multiple",Space,Str "lines."]]] ,[[Plain [Str "Second"]] ,[Plain [Str "row"]]- ,[Plain [Str "5",Str ".",Str "0"]]- ,[Plain [Str "Here",Str "'",Str "s",Space,Str "another",Space,Str "one",Str ".",Space,Str "Note",Space,Str "the",Space,Str "blank",Space,Str "line",Space,Str "between",Space,Str "rows",Str "."]]]]]+ ,[Plain [Str "5.0"]]+ ,[Plain [Str "Here's",Space,Str "another",Space,Str "one.",Space,Str "Note",Space,Str "the",Space,Str "blank",Space,Str "line",Space,Str "between",Space,Str "rows."]]]]]
@@ -357,4 +357,3 @@ } \intbl\row} {\pard \ql \f0 \sa180 \li0 \fi0 \par}-
@@ -3,7 +3,7 @@ module Main where import Test.Framework-+import GHC.IO.Encoding import qualified Tests.Old import qualified Tests.Readers.LaTeX import qualified Tests.Readers.Markdown@@ -34,4 +34,6 @@ ] main :: IO ()-main = inDirectory "tests" $ defaultMain tests+main = do+ setLocaleEncoding utf8+ inDirectory "tests" $ defaultMain tests
@@ -1,172 +1,172 @@-Pandoc (Meta {docTitle = [Str "Pandoc",Space,Str "Test",Space,Str "Suite"], docAuthors = [[Str "John",Space,Str "MacFarlane"],[Str "Anonymous"]], docDate = [Str "July",Space,Str "17",Str ",",Space,Str "2006"]})-[Para [Str "This",Space,Str "is",Space,Str "a",Space,Str "set",Space,Str "of",Space,Str "tests",Space,Str "for",Space,Str "pandoc",Str ".",Space,Str "Most",Space,Str "of",Space,Str "them",Space,Str "are",Space,Str "adapted",Space,Str "from",Space,Str "John",Space,Str "Gruber\8217s",Space,Str "markdown",Space,Str "test",Space,Str "suite",Str "."]+Pandoc (Meta {docTitle = [Str "Pandoc",Space,Str "Test",Space,Str "Suite"], docAuthors = [[Str "John",Space,Str "MacFarlane"],[Str "Anonymous"]], docDate = [Str "July",Space,Str "17,",Space,Str "2006"]})+[Para [Str "This",Space,Str "is",Space,Str "a",Space,Str "set",Space,Str "of",Space,Str "tests",Space,Str "for",Space,Str "pandoc.",Space,Str "Most",Space,Str "of",Space,Str "them",Space,Str "are",Space,Str "adapted",Space,Str "from",Space,Str "John",Space,Str "Gruber\8217s",Space,Str "markdown",Space,Str "test",Space,Str "suite."] ,HorizontalRule-,Header 1 [Str "Headers"]-,Header 2 [Str "Level",Space,Str "2",Space,Str "with",Space,Str "an",Space,Link [Str "embedded",Space,Str "link"] ("/url","")]-,Header 3 [Str "Level",Space,Str "3",Space,Str "with",Space,Emph [Str "emphasis"]]-,Header 4 [Str "Level",Space,Str "4"]-,Header 5 [Str "Level",Space,Str "5"]-,Header 1 [Str "Level",Space,Str "1"]-,Header 2 [Str "Level",Space,Str "2",Space,Str "with",Space,Emph [Str "emphasis"]]-,Header 3 [Str "Level",Space,Str "3"]+,Header 1 ("headers",[],[]) [Str "Headers"]+,Header 2 ("level-2-with-an-embedded-link",[],[]) [Str "Level",Space,Str "2",Space,Str "with",Space,Str "an",Space,Link [Str "embedded",Space,Str "link"] ("/url","")]+,Header 3 ("level-3-with-emphasis",[],[]) [Str "Level",Space,Str "3",Space,Str "with",Space,Emph [Str "emphasis"]]+,Header 4 ("level-4",[],[]) [Str "Level",Space,Str "4"]+,Header 5 ("level-5",[],[]) [Str "Level",Space,Str "5"]+,Header 1 ("level-1",[],[]) [Str "Level",Space,Str "1"]+,Header 2 ("level-2-with-emphasis",[],[]) [Str "Level",Space,Str "2",Space,Str "with",Space,Emph [Str "emphasis"]]+,Header 3 ("level-3",[],[]) [Str "Level",Space,Str "3"] ,Para [Str "with",Space,Str "no",Space,Str "blank",Space,Str "line"]-,Header 2 [Str "Level",Space,Str "2"]+,Header 2 ("level-2",[],[]) [Str "Level",Space,Str "2"] ,Para [Str "with",Space,Str "no",Space,Str "blank",Space,Str "line"] ,HorizontalRule-,Header 1 [Str "Paragraphs"]-,Para [Str "Here\8217s",Space,Str "a",Space,Str "regular",Space,Str "paragraph",Str "."]-,Para [Str "In",Space,Str "Markdown",Space,Str "1",Str ".",Str "0",Str ".",Str "0",Space,Str "and",Space,Str "earlier",Str ".",Space,Str "Version",Space,Str "8",Str ".",Space,Str "This",Space,Str "line",Space,Str "turns",Space,Str "into",Space,Str "a",Space,Str "list",Space,Str "item",Str ".",Space,Str "Because",Space,Str "a",Space,Str "hard",Str "-",Str "wrapped",Space,Str "line",Space,Str "in",Space,Str "the",Space,Str "middle",Space,Str "of",Space,Str "a",Space,Str "paragraph",Space,Str "looked",Space,Str "like",Space,Str "a",Space,Str "list",Space,Str "item",Str "."]-,Para [Str "Here\8217s",Space,Str "one",Space,Str "with",Space,Str "a",Space,Str "bullet",Str ".",Space,Str "*",Space,Str "criminey",Str "."]-,Para [Str "There",Space,Str "should",Space,Str "be",Space,Str "a",Space,Str "hard",Space,Str "line",Space,Str "break",LineBreak,Str "here",Str "."]+,Header 1 ("paragraphs",[],[]) [Str "Paragraphs"]+,Para [Str "Here\8217s",Space,Str "a",Space,Str "regular",Space,Str "paragraph."]+,Para [Str "In",Space,Str "Markdown",Space,Str "1.0.0",Space,Str "and",Space,Str "earlier.",Space,Str "Version",Space,Str "8.",Space,Str "This",Space,Str "line",Space,Str "turns",Space,Str "into",Space,Str "a",Space,Str "list",Space,Str "item.",Space,Str "Because",Space,Str "a",Space,Str "hard-wrapped",Space,Str "line",Space,Str "in",Space,Str "the",Space,Str "middle",Space,Str "of",Space,Str "a",Space,Str "paragraph",Space,Str "looked",Space,Str "like",Space,Str "a",Space,Str "list",Space,Str "item."]+,Para [Str "Here\8217s",Space,Str "one",Space,Str "with",Space,Str "a",Space,Str "bullet.",Space,Str "*",Space,Str "criminey."]+,Para [Str "There",Space,Str "should",Space,Str "be",Space,Str "a",Space,Str "hard",Space,Str "line",Space,Str "break",LineBreak,Str "here."] ,HorizontalRule-,Header 1 [Str "Block",Space,Str "Quotes"]-,Para [Str "E",Str "-",Str "mail",Space,Str "style",Str ":"]+,Header 1 ("block-quotes",[],[]) [Str "Block",Space,Str "Quotes"]+,Para [Str "E-mail",Space,Str "style:"] ,BlockQuote- [Para [Str "This",Space,Str "is",Space,Str "a",Space,Str "block",Space,Str "quote",Str ".",Space,Str "It",Space,Str "is",Space,Str "pretty",Space,Str "short",Str "."]]+ [Para [Str "This",Space,Str "is",Space,Str "a",Space,Str "block",Space,Str "quote.",Space,Str "It",Space,Str "is",Space,Str "pretty",Space,Str "short."]] ,BlockQuote- [Para [Str "Code",Space,Str "in",Space,Str "a",Space,Str "block",Space,Str "quote",Str ":"]+ [Para [Str "Code",Space,Str "in",Space,Str "a",Space,Str "block",Space,Str "quote:"] ,CodeBlock ("",[],[]) "sub status {\n print \"working\";\n}"- ,Para [Str "A",Space,Str "list",Str ":"]+ ,Para [Str "A",Space,Str "list:"] ,OrderedList (1,Decimal,Period) [[Plain [Str "item",Space,Str "one"]] ,[Plain [Str "item",Space,Str "two"]]]- ,Para [Str "Nested",Space,Str "block",Space,Str "quotes",Str ":"]+ ,Para [Str "Nested",Space,Str "block",Space,Str "quotes:"] ,BlockQuote [Para [Str "nested"]] ,BlockQuote [Para [Str "nested"]]]-,Para [Str "This",Space,Str "should",Space,Str "not",Space,Str "be",Space,Str "a",Space,Str "block",Space,Str "quote",Str ":",Space,Str "2",Space,Str ">",Space,Str "1",Str "."]-,Para [Str "And",Space,Str "a",Space,Str "following",Space,Str "paragraph",Str "."]+,Para [Str "This",Space,Str "should",Space,Str "not",Space,Str "be",Space,Str "a",Space,Str "block",Space,Str "quote:",Space,Str "2",Space,Str ">",Space,Str "1."]+,Para [Str "And",Space,Str "a",Space,Str "following",Space,Str "paragraph."] ,HorizontalRule-,Header 1 [Str "Code",Space,Str "Blocks"]-,Para [Str "Code",Str ":"]+,Header 1 ("code-blocks",[],[]) [Str "Code",Space,Str "Blocks"]+,Para [Str "Code:"] ,CodeBlock ("",[],[]) "---- (should be four hyphens)\n\nsub status {\n print \"working\";\n}\n\nthis code block is indented by one tab"-,Para [Str "And",Str ":"]+,Para [Str "And:"] ,CodeBlock ("",[],[]) " this code block is indented by two tabs\n\nThese should not be escaped: \\$ \\\\ \\> \\[ \\{" ,HorizontalRule-,Header 1 [Str "Lists"]-,Header 2 [Str "Unordered"]-,Para [Str "Asterisks",Space,Str "tight",Str ":"]+,Header 1 ("lists",[],[]) [Str "Lists"]+,Header 2 ("unordered",[],[]) [Str "Unordered"]+,Para [Str "Asterisks",Space,Str "tight:"] ,BulletList [[Plain [Str "asterisk",Space,Str "1"]] ,[Plain [Str "asterisk",Space,Str "2"]] ,[Plain [Str "asterisk",Space,Str "3"]]]-,Para [Str "Asterisks",Space,Str "loose",Str ":"]+,Para [Str "Asterisks",Space,Str "loose:"] ,BulletList [[Para [Str "asterisk",Space,Str "1"]] ,[Para [Str "asterisk",Space,Str "2"]] ,[Para [Str "asterisk",Space,Str "3"]]]-,Para [Str "Pluses",Space,Str "tight",Str ":"]+,Para [Str "Pluses",Space,Str "tight:"] ,BulletList [[Plain [Str "Plus",Space,Str "1"]] ,[Plain [Str "Plus",Space,Str "2"]] ,[Plain [Str "Plus",Space,Str "3"]]]-,Para [Str "Pluses",Space,Str "loose",Str ":"]+,Para [Str "Pluses",Space,Str "loose:"] ,BulletList [[Para [Str "Plus",Space,Str "1"]] ,[Para [Str "Plus",Space,Str "2"]] ,[Para [Str "Plus",Space,Str "3"]]]-,Para [Str "Minuses",Space,Str "tight",Str ":"]+,Para [Str "Minuses",Space,Str "tight:"] ,BulletList [[Plain [Str "Minus",Space,Str "1"]] ,[Plain [Str "Minus",Space,Str "2"]] ,[Plain [Str "Minus",Space,Str "3"]]]-,Para [Str "Minuses",Space,Str "loose",Str ":"]+,Para [Str "Minuses",Space,Str "loose:"] ,BulletList [[Para [Str "Minus",Space,Str "1"]] ,[Para [Str "Minus",Space,Str "2"]] ,[Para [Str "Minus",Space,Str "3"]]]-,Header 2 [Str "Ordered"]-,Para [Str "Tight",Str ":"]+,Header 2 ("ordered",[],[]) [Str "Ordered"]+,Para [Str "Tight:"] ,OrderedList (1,Decimal,Period) [[Plain [Str "First"]] ,[Plain [Str "Second"]] ,[Plain [Str "Third"]]]-,Para [Str "and",Str ":"]+,Para [Str "and:"] ,OrderedList (1,Decimal,Period) [[Plain [Str "One"]] ,[Plain [Str "Two"]] ,[Plain [Str "Three"]]]-,Para [Str "Loose",Space,Str "using",Space,Str "tabs",Str ":"]+,Para [Str "Loose",Space,Str "using",Space,Str "tabs:"] ,OrderedList (1,Decimal,Period) [[Para [Str "First"]] ,[Para [Str "Second"]] ,[Para [Str "Third"]]]-,Para [Str "and",Space,Str "using",Space,Str "spaces",Str ":"]+,Para [Str "and",Space,Str "using",Space,Str "spaces:"] ,OrderedList (1,Decimal,Period) [[Para [Str "One"]] ,[Para [Str "Two"]] ,[Para [Str "Three"]]]-,Para [Str "Multiple",Space,Str "paragraphs",Str ":"]+,Para [Str "Multiple",Space,Str "paragraphs:"] ,OrderedList (1,Decimal,Period)- [[Para [Str "Item",Space,Str "1",Str ",",Space,Str "graf",Space,Str "one",Str "."]- ,Para [Str "Item",Space,Str "1",Str ".",Space,Str "graf",Space,Str "two",Str ".",Space,Str "The",Space,Str "quick",Space,Str "brown",Space,Str "fox",Space,Str "jumped",Space,Str "over",Space,Str "the",Space,Str "lazy",Space,Str "dog\8217s",Space,Str "back",Str "."]]- ,[Para [Str "Item",Space,Str "2",Str "."]]- ,[Para [Str "Item",Space,Str "3",Str "."]]]-,Header 2 [Str "Nested"]+ [[Para [Str "Item",Space,Str "1,",Space,Str "graf",Space,Str "one."]+ ,Para [Str "Item",Space,Str "1.",Space,Str "graf",Space,Str "two.",Space,Str "The",Space,Str "quick",Space,Str "brown",Space,Str "fox",Space,Str "jumped",Space,Str "over",Space,Str "the",Space,Str "lazy",Space,Str "dog\8217s",Space,Str "back."]]+ ,[Para [Str "Item",Space,Str "2."]]+ ,[Para [Str "Item",Space,Str "3."]]]+,Header 2 ("nested",[],[]) [Str "Nested"] ,BulletList [[Plain [Str "Tab"] ,BulletList [[Plain [Str "Tab"] ,BulletList [[Plain [Str "Tab"]]]]]]]-,Para [Str "Here\8217s",Space,Str "another",Str ":"]+,Para [Str "Here\8217s",Space,Str "another:"] ,OrderedList (1,Decimal,Period) [[Plain [Str "First"]]- ,[Plain [Str "Second",Str ":"]+ ,[Plain [Str "Second:"] ,BulletList [[Plain [Str "Fee"]] ,[Plain [Str "Fie"]] ,[Plain [Str "Foe"]]]] ,[Plain [Str "Third"]]]-,Para [Str "Same",Space,Str "thing",Space,Str "but",Space,Str "with",Space,Str "paragraphs",Str ":"]+,Para [Str "Same",Space,Str "thing",Space,Str "but",Space,Str "with",Space,Str "paragraphs:"] ,OrderedList (1,Decimal,Period) [[Para [Str "First"]]- ,[Para [Str "Second",Str ":"]+ ,[Para [Str "Second:"] ,BulletList [[Plain [Str "Fee"]] ,[Plain [Str "Fie"]] ,[Plain [Str "Foe"]]]] ,[Para [Str "Third"]]]-,Header 2 [Str "Tabs",Space,Str "and",Space,Str "spaces"]+,Header 2 ("tabs-and-spaces",[],[]) [Str "Tabs",Space,Str "and",Space,Str "spaces"] ,BulletList [[Para [Str "this",Space,Str "is",Space,Str "a",Space,Str "list",Space,Str "item",Space,Str "indented",Space,Str "with",Space,Str "tabs"]] ,[Para [Str "this",Space,Str "is",Space,Str "a",Space,Str "list",Space,Str "item",Space,Str "indented",Space,Str "with",Space,Str "spaces"] ,BulletList [[Para [Str "this",Space,Str "is",Space,Str "an",Space,Str "example",Space,Str "list",Space,Str "item",Space,Str "indented",Space,Str "with",Space,Str "tabs"]] ,[Para [Str "this",Space,Str "is",Space,Str "an",Space,Str "example",Space,Str "list",Space,Str "item",Space,Str "indented",Space,Str "with",Space,Str "spaces"]]]]]-,Header 2 [Str "Fancy",Space,Str "list",Space,Str "markers"]+,Header 2 ("fancy-list-markers",[],[]) [Str "Fancy",Space,Str "list",Space,Str "markers"] ,OrderedList (2,Decimal,TwoParens) [[Plain [Str "begins",Space,Str "with",Space,Str "2"]] ,[Para [Str "and",Space,Str "now",Space,Str "3"] ,Para [Str "with",Space,Str "a",Space,Str "continuation"] ,OrderedList (4,LowerRoman,Period)- [[Plain [Str "sublist",Space,Str "with",Space,Str "roman",Space,Str "numerals",Str ",",Space,Str "starting",Space,Str "with",Space,Str "4"]]+ [[Plain [Str "sublist",Space,Str "with",Space,Str "roman",Space,Str "numerals,",Space,Str "starting",Space,Str "with",Space,Str "4"]] ,[Plain [Str "more",Space,Str "items"] ,OrderedList (1,UpperAlpha,TwoParens) [[Plain [Str "a",Space,Str "subsublist"]] ,[Plain [Str "a",Space,Str "subsublist"]]]]]]]-,Para [Str "Nesting",Str ":"]+,Para [Str "Nesting:"] ,OrderedList (1,UpperAlpha,Period) [[Plain [Str "Upper",Space,Str "Alpha"] ,OrderedList (1,UpperRoman,Period)- [[Plain [Str "Upper",Space,Str "Roman",Str "."]+ [[Plain [Str "Upper",Space,Str "Roman."] ,OrderedList (6,Decimal,TwoParens) [[Plain [Str "Decimal",Space,Str "start",Space,Str "with",Space,Str "6"] ,OrderedList (3,LowerAlpha,OneParen) [[Plain [Str "Lower",Space,Str "alpha",Space,Str "with",Space,Str "paren"]]]]]]]]]-,Para [Str "Autonumbering",Str ":"]+,Para [Str "Autonumbering:"] ,OrderedList (1,DefaultStyle,DefaultDelim)- [[Plain [Str "Autonumber",Str "."]]- ,[Plain [Str "More",Str "."]+ [[Plain [Str "Autonumber."]]+ ,[Plain [Str "More."] ,OrderedList (1,DefaultStyle,DefaultDelim)- [[Plain [Str "Nested",Str "."]]]]]-,Para [Str "Should",Space,Str "not",Space,Str "be",Space,Str "a",Space,Str "list",Space,Str "item",Str ":"]-,Para [Str "M.A.\160",Str "2007"]-,Para [Str "B",Str ".",Space,Str "Williams"]+ [[Plain [Str "Nested."]]]]]+,Para [Str "Should",Space,Str "not",Space,Str "be",Space,Str "a",Space,Str "list",Space,Str "item:"]+,Para [Str "M.A.\160\&2007"]+,Para [Str "B.",Space,Str "Williams"] ,HorizontalRule-,Header 1 [Str "Definition",Space,Str "Lists"]-,Para [Str "Tight",Space,Str "using",Space,Str "spaces",Str ":"]+,Header 1 ("definition-lists",[],[]) [Str "Definition",Space,Str "Lists"]+,Para [Str "Tight",Space,Str "using",Space,Str "spaces:"] ,DefinitionList [([Str "apple"], [[Plain [Str "red",Space,Str "fruit"]]])@@ -174,7 +174,7 @@ [[Plain [Str "orange",Space,Str "fruit"]]]) ,([Str "banana"], [[Plain [Str "yellow",Space,Str "fruit"]]])]-,Para [Str "Tight",Space,Str "using",Space,Str "tabs",Str ":"]+,Para [Str "Tight",Space,Str "using",Space,Str "tabs:"] ,DefinitionList [([Str "apple"], [[Plain [Str "red",Space,Str "fruit"]]])@@ -182,7 +182,7 @@ [[Plain [Str "orange",Space,Str "fruit"]]]) ,([Str "banana"], [[Plain [Str "yellow",Space,Str "fruit"]]])]-,Para [Str "Loose",Str ":"]+,Para [Str "Loose:"] ,DefinitionList [([Str "apple"], [[Para [Str "red",Space,Str "fruit"]]])@@ -190,17 +190,17 @@ [[Para [Str "orange",Space,Str "fruit"]]]) ,([Str "banana"], [[Para [Str "yellow",Space,Str "fruit"]]])]-,Para [Str "Multiple",Space,Str "blocks",Space,Str "with",Space,Str "italics",Str ":"]+,Para [Str "Multiple",Space,Str "blocks",Space,Str "with",Space,Str "italics:"] ,DefinitionList [([Emph [Str "apple"]], [[Para [Str "red",Space,Str "fruit"]- ,Para [Str "contains",Space,Str "seeds",Str ",",Space,Str "crisp",Str ",",Space,Str "pleasant",Space,Str "to",Space,Str "taste"]]])+ ,Para [Str "contains",Space,Str "seeds,",Space,Str "crisp,",Space,Str "pleasant",Space,Str "to",Space,Str "taste"]]]) ,([Emph [Str "orange"]], [[Para [Str "orange",Space,Str "fruit"] ,CodeBlock ("",[],[]) "{ orange code block }" ,BlockQuote [Para [Str "orange",Space,Str "block",Space,Str "quote"]]]])]-,Para [Str "Multiple",Space,Str "definitions",Str ",",Space,Str "tight",Str ":"]+,Para [Str "Multiple",Space,Str "definitions,",Space,Str "tight:"] ,DefinitionList [([Str "apple"], [[Plain [Str "red",Space,Str "fruit"]]@@ -208,7 +208,7 @@ ,([Str "orange"], [[Plain [Str "orange",Space,Str "fruit"]] ,[Plain [Str "bank"]]])]-,Para [Str "Multiple",Space,Str "definitions",Str ",",Space,Str "loose",Str ":"]+,Para [Str "Multiple",Space,Str "definitions,",Space,Str "loose:"] ,DefinitionList [([Str "apple"], [[Para [Str "red",Space,Str "fruit"]]@@ -216,7 +216,7 @@ ,([Str "orange"], [[Para [Str "orange",Space,Str "fruit"]] ,[Para [Str "bank"]]])]-,Para [Str "Blank",Space,Str "line",Space,Str "after",Space,Str "term",Str ",",Space,Str "indented",Space,Str "marker",Str ",",Space,Str "alternate",Space,Str "markers",Str ":"]+,Para [Str "Blank",Space,Str "line",Space,Str "after",Space,Str "term,",Space,Str "indented",Space,Str "marker,",Space,Str "alternate",Space,Str "markers:"] ,DefinitionList [([Str "apple"], [[Para [Str "red",Space,Str "fruit"]]@@ -226,171 +226,171 @@ ,OrderedList (1,Decimal,Period) [[Plain [Str "sublist"]] ,[Plain [Str "sublist"]]]]])]-,Header 1 [Str "HTML",Space,Str "Blocks"]-,Para [Str "Simple",Space,Str "block",Space,Str "on",Space,Str "one",Space,Str "line",Str ":"]+,Header 1 ("html-blocks",[],[]) [Str "HTML",Space,Str "Blocks"]+,Para [Str "Simple",Space,Str "block",Space,Str "on",Space,Str "one",Space,Str "line:"] ,RawBlock "html" "<div>" ,Plain [Str "foo"] ,RawBlock "html" "</div>\n"-,Para [Str "And",Space,Str "nested",Space,Str "without",Space,Str "indentation",Str ":"]+,Para [Str "And",Space,Str "nested",Space,Str "without",Space,Str "indentation:"] ,RawBlock "html" "<div>\n<div>\n<div>" ,Plain [Str "foo"] ,RawBlock "html" "</div>\n</div>\n<div>" ,Plain [Str "bar"] ,RawBlock "html" "</div>\n</div>\n"-,Para [Str "Interpreted",Space,Str "markdown",Space,Str "in",Space,Str "a",Space,Str "table",Str ":"]+,Para [Str "Interpreted",Space,Str "markdown",Space,Str "in",Space,Str "a",Space,Str "table:"] ,RawBlock "html" "<table>\n<tr>\n<td>" ,Plain [Str "This",Space,Str "is",Space,Emph [Str "emphasized"]] ,RawBlock "html" "</td>\n<td>" ,Plain [Str "And",Space,Str "this",Space,Str "is",Space,Strong [Str "strong"]] ,RawBlock "html" "</td>\n</tr>\n</table>\n\n<script type=\"text/javascript\">document.write('This *should not* be interpreted as markdown');</script>\n"-,Para [Str "Here\8217s",Space,Str "a",Space,Str "simple",Space,Str "block",Str ":"]+,Para [Str "Here\8217s",Space,Str "a",Space,Str "simple",Space,Str "block:"] ,RawBlock "html" "<div>\n " ,Plain [Str "foo"] ,RawBlock "html" "</div>\n"-,Para [Str "This",Space,Str "should",Space,Str "be",Space,Str "a",Space,Str "code",Space,Str "block",Str ",",Space,Str "though",Str ":"]+,Para [Str "This",Space,Str "should",Space,Str "be",Space,Str "a",Space,Str "code",Space,Str "block,",Space,Str "though:"] ,CodeBlock ("",[],[]) "<div>\n foo\n</div>"-,Para [Str "As",Space,Str "should",Space,Str "this",Str ":"]+,Para [Str "As",Space,Str "should",Space,Str "this:"] ,CodeBlock ("",[],[]) "<div>foo</div>"-,Para [Str "Now",Str ",",Space,Str "nested",Str ":"]+,Para [Str "Now,",Space,Str "nested:"] ,RawBlock "html" "<div>\n <div>\n <div>\n " ,Plain [Str "foo"] ,RawBlock "html" "</div>\n </div>\n</div>\n"-,Para [Str "This",Space,Str "should",Space,Str "just",Space,Str "be",Space,Str "an",Space,Str "HTML",Space,Str "comment",Str ":"]+,Para [Str "This",Space,Str "should",Space,Str "just",Space,Str "be",Space,Str "an",Space,Str "HTML",Space,Str "comment:"] ,RawBlock "html" "<!-- Comment -->\n"-,Para [Str "Multiline",Str ":"]+,Para [Str "Multiline:"] ,RawBlock "html" "<!--\nBlah\nBlah\n-->\n\n<!--\n This is another comment.\n-->\n"-,Para [Str "Code",Space,Str "block",Str ":"]+,Para [Str "Code",Space,Str "block:"] ,CodeBlock ("",[],[]) "<!-- Comment -->"-,Para [Str "Just",Space,Str "plain",Space,Str "comment",Str ",",Space,Str "with",Space,Str "trailing",Space,Str "spaces",Space,Str "on",Space,Str "the",Space,Str "line",Str ":"]+,Para [Str "Just",Space,Str "plain",Space,Str "comment,",Space,Str "with",Space,Str "trailing",Space,Str "spaces",Space,Str "on",Space,Str "the",Space,Str "line:"] ,RawBlock "html" "<!-- foo --> \n"-,Para [Str "Code",Str ":"]+,Para [Str "Code:"] ,CodeBlock ("",[],[]) "<hr />"-,Para [Str "Hr\8217s",Str ":"]+,Para [Str "Hr\8217s:"] ,RawBlock "html" "<hr>\n\n<hr />\n\n<hr />\n\n<hr> \n\n<hr /> \n\n<hr /> \n\n<hr class=\"foo\" id=\"bar\" />\n\n<hr class=\"foo\" id=\"bar\" />\n\n<hr class=\"foo\" id=\"bar\">\n" ,HorizontalRule-,Header 1 [Str "Inline",Space,Str "Markup"]+,Header 1 ("inline-markup",[],[]) [Str "Inline",Space,Str "Markup"] ,Para [Str "This",Space,Str "is",Space,Emph [Str "emphasized"],Str ",",Space,Str "and",Space,Str "so",Space,Emph [Str "is",Space,Str "this"],Str "."] ,Para [Str "This",Space,Str "is",Space,Strong [Str "strong"],Str ",",Space,Str "and",Space,Str "so",Space,Strong [Str "is",Space,Str "this"],Str "."] ,Para [Str "An",Space,Emph [Link [Str "emphasized",Space,Str "link"] ("/url","")],Str "."]-,Para [Strong [Emph [Str "This",Space,Str "is",Space,Str "strong",Space,Str "and",Space,Str "em",Str "."]]]-,Para [Str "So",Space,Str "is",Space,Strong [Emph [Str "this"]],Space,Str "word",Str "."]-,Para [Strong [Emph [Str "This",Space,Str "is",Space,Str "strong",Space,Str "and",Space,Str "em",Str "."]]]-,Para [Str "So",Space,Str "is",Space,Strong [Emph [Str "this"]],Space,Str "word",Str "."]-,Para [Str "This",Space,Str "is",Space,Str "code",Str ":",Space,Code ("",[],[]) ">",Str ",",Space,Code ("",[],[]) "$",Str ",",Space,Code ("",[],[]) "\\",Str ",",Space,Code ("",[],[]) "\\$",Str ",",Space,Code ("",[],[]) "<html>",Str "."]+,Para [Strong [Emph [Str "This",Space,Str "is",Space,Str "strong",Space,Str "and",Space,Str "em."]]]+,Para [Str "So",Space,Str "is",Space,Strong [Emph [Str "this"]],Space,Str "word."]+,Para [Strong [Emph [Str "This",Space,Str "is",Space,Str "strong",Space,Str "and",Space,Str "em."]]]+,Para [Str "So",Space,Str "is",Space,Strong [Emph [Str "this"]],Space,Str "word."]+,Para [Str "This",Space,Str "is",Space,Str "code:",Space,Code ("",[],[]) ">",Str ",",Space,Code ("",[],[]) "$",Str ",",Space,Code ("",[],[]) "\\",Str ",",Space,Code ("",[],[]) "\\$",Str ",",Space,Code ("",[],[]) "<html>",Str "."] ,Para [Strikeout [Str "This",Space,Str "is",Space,Emph [Str "strikeout"],Str "."]]-,Para [Str "Superscripts",Str ":",Space,Str "a",Superscript [Str "bc"],Str "d",Space,Str "a",Superscript [Emph [Str "hello"]],Space,Str "a",Superscript [Str "hello",Str "\160",Str "there"],Str "."]-,Para [Str "Subscripts",Str ":",Space,Str "H",Subscript [Str "2"],Str "O",Str ",",Space,Str "H",Subscript [Str "23"],Str "O",Str ",",Space,Str "H",Subscript [Str "many",Str "\160",Str "of",Str "\160",Str "them"],Str "O",Str "."]-,Para [Str "These",Space,Str "should",Space,Str "not",Space,Str "be",Space,Str "superscripts",Space,Str "or",Space,Str "subscripts",Str ",",Space,Str "because",Space,Str "of",Space,Str "the",Space,Str "unescaped",Space,Str "spaces",Str ":",Space,Str "a",Str "^",Str "b",Space,Str "c",Str "^",Str "d",Str ",",Space,Str "a",Str "~",Str "b",Space,Str "c",Str "~",Str "d",Str "."]+,Para [Str "Superscripts:",Space,Str "a",Superscript [Str "bc"],Str "d",Space,Str "a",Superscript [Emph [Str "hello"]],Space,Str "a",Superscript [Str "hello\160there"],Str "."]+,Para [Str "Subscripts:",Space,Str "H",Subscript [Str "2"],Str "O,",Space,Str "H",Subscript [Str "23"],Str "O,",Space,Str "H",Subscript [Str "many\160of\160them"],Str "O."]+,Para [Str "These",Space,Str "should",Space,Str "not",Space,Str "be",Space,Str "superscripts",Space,Str "or",Space,Str "subscripts,",Space,Str "because",Space,Str "of",Space,Str "the",Space,Str "unescaped",Space,Str "spaces:",Space,Str "a^b",Space,Str "c^d,",Space,Str "a~b",Space,Str "c~d."] ,HorizontalRule-,Header 1 [Str "Smart",Space,Str "quotes",Str ",",Space,Str "ellipses",Str ",",Space,Str "dashes"]-,Para [Quoted DoubleQuote [Str "Hello",Str ","],Space,Str "said",Space,Str "the",Space,Str "spider",Str ".",Space,Quoted DoubleQuote [Quoted SingleQuote [Str "Shelob"],Space,Str "is",Space,Str "my",Space,Str "name",Str "."]]-,Para [Quoted SingleQuote [Str "A"],Str ",",Space,Quoted SingleQuote [Str "B"],Str ",",Space,Str "and",Space,Quoted SingleQuote [Str "C"],Space,Str "are",Space,Str "letters",Str "."]-,Para [Quoted SingleQuote [Str "Oak",Str ","],Space,Quoted SingleQuote [Str "elm",Str ","],Space,Str "and",Space,Quoted SingleQuote [Str "beech"],Space,Str "are",Space,Str "names",Space,Str "of",Space,Str "trees",Str ".",Space,Str "So",Space,Str "is",Space,Quoted SingleQuote [Str "pine",Str "."]]-,Para [Quoted SingleQuote [Str "He",Space,Str "said",Str ",",Space,Quoted DoubleQuote [Str "I",Space,Str "want",Space,Str "to",Space,Str "go",Str "."]],Space,Str "Were",Space,Str "you",Space,Str "alive",Space,Str "in",Space,Str "the",Space,Str "70\8217s",Str "?"]+,Header 1 ("smart-quotes-ellipses-dashes",[],[]) [Str "Smart",Space,Str "quotes,",Space,Str "ellipses,",Space,Str "dashes"]+,Para [Quoted DoubleQuote [Str "Hello,"],Space,Str "said",Space,Str "the",Space,Str "spider.",Space,Quoted DoubleQuote [Quoted SingleQuote [Str "Shelob"],Space,Str "is",Space,Str "my",Space,Str "name."]]+,Para [Quoted SingleQuote [Str "A"],Str ",",Space,Quoted SingleQuote [Str "B"],Str ",",Space,Str "and",Space,Quoted SingleQuote [Str "C"],Space,Str "are",Space,Str "letters."]+,Para [Quoted SingleQuote [Str "Oak,"],Space,Quoted SingleQuote [Str "elm,"],Space,Str "and",Space,Quoted SingleQuote [Str "beech"],Space,Str "are",Space,Str "names",Space,Str "of",Space,Str "trees.",Space,Str "So",Space,Str "is",Space,Quoted SingleQuote [Str "pine."]]+,Para [Quoted SingleQuote [Str "He",Space,Str "said,",Space,Quoted DoubleQuote [Str "I",Space,Str "want",Space,Str "to",Space,Str "go."]],Space,Str "Were",Space,Str "you",Space,Str "alive",Space,Str "in",Space,Str "the",Space,Str "70\8217s?"] ,Para [Str "Here",Space,Str "is",Space,Str "some",Space,Str "quoted",Space,Quoted SingleQuote [Code ("",[],[]) "code"],Space,Str "and",Space,Str "a",Space,Quoted DoubleQuote [Link [Str "quoted",Space,Str "link"] ("http://example.com/?foo=1&bar=2","")],Str "."]-,Para [Str "Some",Space,Str "dashes",Str ":",Space,Str "one",Str "\8212",Str "two",Space,Str "\8212",Space,Str "three",Str "\8212",Str "four",Space,Str "\8212",Space,Str "five",Str "."]-,Para [Str "Dashes",Space,Str "between",Space,Str "numbers",Str ":",Space,Str "5",Str "\8211",Str "7",Str ",",Space,Str "255",Str "\8211",Str "66",Str ",",Space,Str "1987",Str "\8211",Str "1999",Str "."]-,Para [Str "Ellipses",Str "\8230",Str "and",Str "\8230",Str "and",Str "\8230",Str "."]+,Para [Str "Some",Space,Str "dashes:",Space,Str "one\8212two",Space,Str "\8212",Space,Str "three\8212four",Space,Str "\8212",Space,Str "five."]+,Para [Str "Dashes",Space,Str "between",Space,Str "numbers:",Space,Str "5\8211\&7,",Space,Str "255\8211\&66,",Space,Str "1987\8211\&1999."]+,Para [Str "Ellipses\8230and\8230and\8230."] ,HorizontalRule-,Header 1 [Str "LaTeX"]+,Header 1 ("latex",[],[]) [Str "LaTeX"] ,BulletList [[Plain [RawInline "tex" "\\cite[22-23]{smith.1899}"]] ,[Plain [Math InlineMath "2+2=4"]] ,[Plain [Math InlineMath "x \\in y"]] ,[Plain [Math InlineMath "\\alpha \\wedge \\omega"]] ,[Plain [Math InlineMath "223"]]- ,[Plain [Math InlineMath "p",Str "-",Str "Tree"]]- ,[Plain [Str "Here\8217s",Space,Str "some",Space,Str "display",Space,Str "math",Str ":",Space,Math DisplayMath "\\frac{d}{dx}f(x)=\\lim_{h\\to 0}\\frac{f(x+h)-f(x)}{h}"]]- ,[Plain [Str "Here\8217s",Space,Str "one",Space,Str "that",Space,Str "has",Space,Str "a",Space,Str "line",Space,Str "break",Space,Str "in",Space,Str "it",Str ":",Space,Math InlineMath "\\alpha + \\omega \\times x^2",Str "."]]]-,Para [Str "These",Space,Str "shouldn\8217t",Space,Str "be",Space,Str "math",Str ":"]+ ,[Plain [Math InlineMath "p",Str "-Tree"]]+ ,[Plain [Str "Here\8217s",Space,Str "some",Space,Str "display",Space,Str "math:",Space,Math DisplayMath "\\frac{d}{dx}f(x)=\\lim_{h\\to 0}\\frac{f(x+h)-f(x)}{h}"]]+ ,[Plain [Str "Here\8217s",Space,Str "one",Space,Str "that",Space,Str "has",Space,Str "a",Space,Str "line",Space,Str "break",Space,Str "in",Space,Str "it:",Space,Math InlineMath "\\alpha + \\omega \\times x^2",Str "."]]]+,Para [Str "These",Space,Str "shouldn\8217t",Space,Str "be",Space,Str "math:"] ,BulletList- [[Plain [Str "To",Space,Str "get",Space,Str "the",Space,Str "famous",Space,Str "equation",Str ",",Space,Str "write",Space,Code ("",[],[]) "$e = mc^2$",Str "."]]- ,[Plain [Str "$",Str "22",Str ",",Str "000",Space,Str "is",Space,Str "a",Space,Emph [Str "lot"],Space,Str "of",Space,Str "money",Str ".",Space,Str "So",Space,Str "is",Space,Str "$",Str "34",Str ",",Str "000",Str ".",Space,Str "(",Str "It",Space,Str "worked",Space,Str "if",Space,Quoted DoubleQuote [Str "lot"],Space,Str "is",Space,Str "emphasized",Str ".",Str ")"]]- ,[Plain [Str "Shoes",Space,Str "(",Str "$",Str "20",Str ")",Space,Str "and",Space,Str "socks",Space,Str "(",Str "$",Str "5",Str ")",Str "."]]- ,[Plain [Str "Escaped",Space,Code ("",[],[]) "$",Str ":",Space,Str "$",Str "73",Space,Emph [Str "this",Space,Str "should",Space,Str "be",Space,Str "emphasized"],Space,Str "23",Str "$",Str "."]]]-,Para [Str "Here\8217s",Space,Str "a",Space,Str "LaTeX",Space,Str "table",Str ":"]+ [[Plain [Str "To",Space,Str "get",Space,Str "the",Space,Str "famous",Space,Str "equation,",Space,Str "write",Space,Code ("",[],[]) "$e = mc^2$",Str "."]]+ ,[Plain [Str "$22,000",Space,Str "is",Space,Str "a",Space,Emph [Str "lot"],Space,Str "of",Space,Str "money.",Space,Str "So",Space,Str "is",Space,Str "$34,000.",Space,Str "(It",Space,Str "worked",Space,Str "if",Space,Quoted DoubleQuote [Str "lot"],Space,Str "is",Space,Str "emphasized.)"]]+ ,[Plain [Str "Shoes",Space,Str "($20)",Space,Str "and",Space,Str "socks",Space,Str "($5)."]]+ ,[Plain [Str "Escaped",Space,Code ("",[],[]) "$",Str ":",Space,Str "$73",Space,Emph [Str "this",Space,Str "should",Space,Str "be",Space,Str "emphasized"],Space,Str "23$."]]]+,Para [Str "Here\8217s",Space,Str "a",Space,Str "LaTeX",Space,Str "table:"] ,RawBlock "latex" "\\begin{tabular}{|l|l|}\\hline\nAnimal & Number \\\\ \\hline\nDog & 2 \\\\\nCat & 1 \\\\ \\hline\n\\end{tabular}" ,HorizontalRule-,Header 1 [Str "Special",Space,Str "Characters"]-,Para [Str "Here",Space,Str "is",Space,Str "some",Space,Str "unicode",Str ":"]+,Header 1 ("special-characters",[],[]) [Str "Special",Space,Str "Characters"]+,Para [Str "Here",Space,Str "is",Space,Str "some",Space,Str "unicode:"] ,BulletList- [[Plain [Str "I",Space,Str "hat",Str ":",Space,Str "\206"]]- ,[Plain [Str "o",Space,Str "umlaut",Str ":",Space,Str "\246"]]- ,[Plain [Str "section",Str ":",Space,Str "\167"]]- ,[Plain [Str "set",Space,Str "membership",Str ":",Space,Str "\8712"]]- ,[Plain [Str "copyright",Str ":",Space,Str "\169"]]]-,Para [Str "AT",Str "&",Str "T",Space,Str "has",Space,Str "an",Space,Str "ampersand",Space,Str "in",Space,Str "their",Space,Str "name",Str "."]-,Para [Str "AT",Str "&",Str "T",Space,Str "is",Space,Str "another",Space,Str "way",Space,Str "to",Space,Str "write",Space,Str "it",Str "."]-,Para [Str "This",Space,Str "&",Space,Str "that",Str "."]-,Para [Str "4",Space,Str "<",Space,Str "5",Str "."]-,Para [Str "6",Space,Str ">",Space,Str "5",Str "."]-,Para [Str "Backslash",Str ":",Space,Str "\\"]-,Para [Str "Backtick",Str ":",Space,Str "`"]-,Para [Str "Asterisk",Str ":",Space,Str "*"]-,Para [Str "Underscore",Str ":",Space,Str "_"]-,Para [Str "Left",Space,Str "brace",Str ":",Space,Str "{"]-,Para [Str "Right",Space,Str "brace",Str ":",Space,Str "}"]-,Para [Str "Left",Space,Str "bracket",Str ":",Space,Str "["]-,Para [Str "Right",Space,Str "bracket",Str ":",Space,Str "]"]-,Para [Str "Left",Space,Str "paren",Str ":",Space,Str "("]-,Para [Str "Right",Space,Str "paren",Str ":",Space,Str ")"]-,Para [Str "Greater",Str "-",Str "than",Str ":",Space,Str ">"]-,Para [Str "Hash",Str ":",Space,Str "#"]-,Para [Str "Period",Str ":",Space,Str "."]-,Para [Str "Bang",Str ":",Space,Str "!"]-,Para [Str "Plus",Str ":",Space,Str "+"]-,Para [Str "Minus",Str ":",Space,Str "-"]+ [[Plain [Str "I",Space,Str "hat:",Space,Str "\206"]]+ ,[Plain [Str "o",Space,Str "umlaut:",Space,Str "\246"]]+ ,[Plain [Str "section:",Space,Str "\167"]]+ ,[Plain [Str "set",Space,Str "membership:",Space,Str "\8712"]]+ ,[Plain [Str "copyright:",Space,Str "\169"]]]+,Para [Str "AT&T",Space,Str "has",Space,Str "an",Space,Str "ampersand",Space,Str "in",Space,Str "their",Space,Str "name."]+,Para [Str "AT&T",Space,Str "is",Space,Str "another",Space,Str "way",Space,Str "to",Space,Str "write",Space,Str "it."]+,Para [Str "This",Space,Str "&",Space,Str "that."]+,Para [Str "4",Space,Str "<",Space,Str "5."]+,Para [Str "6",Space,Str ">",Space,Str "5."]+,Para [Str "Backslash:",Space,Str "\\"]+,Para [Str "Backtick:",Space,Str "`"]+,Para [Str "Asterisk:",Space,Str "*"]+,Para [Str "Underscore:",Space,Str "_"]+,Para [Str "Left",Space,Str "brace:",Space,Str "{"]+,Para [Str "Right",Space,Str "brace:",Space,Str "}"]+,Para [Str "Left",Space,Str "bracket:",Space,Str "["]+,Para [Str "Right",Space,Str "bracket:",Space,Str "]"]+,Para [Str "Left",Space,Str "paren:",Space,Str "("]+,Para [Str "Right",Space,Str "paren:",Space,Str ")"]+,Para [Str "Greater-than:",Space,Str ">"]+,Para [Str "Hash:",Space,Str "#"]+,Para [Str "Period:",Space,Str "."]+,Para [Str "Bang:",Space,Str "!"]+,Para [Str "Plus:",Space,Str "+"]+,Para [Str "Minus:",Space,Str "-"] ,HorizontalRule-,Header 1 [Str "Links"]-,Header 2 [Str "Explicit"]+,Header 1 ("links",[],[]) [Str "Links"]+,Header 2 ("explicit",[],[]) [Str "Explicit"] ,Para [Str "Just",Space,Str "a",Space,Link [Str "URL"] ("/url/",""),Str "."] ,Para [Link [Str "URL",Space,Str "and",Space,Str "title"] ("/url/","title"),Str "."] ,Para [Link [Str "URL",Space,Str "and",Space,Str "title"] ("/url/","title preceded by two spaces"),Str "."] ,Para [Link [Str "URL",Space,Str "and",Space,Str "title"] ("/url/","title preceded by a tab"),Str "."] ,Para [Link [Str "URL",Space,Str "and",Space,Str "title"] ("/url/","title with \"quotes\" in it")] ,Para [Link [Str "URL",Space,Str "and",Space,Str "title"] ("/url/","title with single quotes")]-,Para [Link [Str "with",Str "_",Str "underscore"] ("/url/with_underscore","")]+,Para [Link [Str "with_underscore"] ("/url/with_underscore","")] ,Para [Link [Str "Email",Space,Str "link"] ("mailto:nobody@nowhere.net","")] ,Para [Link [Str "Empty"] ("",""),Str "."]-,Header 2 [Str "Reference"]+,Header 2 ("reference",[],[]) [Str "Reference"] ,Para [Str "Foo",Space,Link [Str "bar"] ("/url/",""),Str "."] ,Para [Str "Foo",Space,Link [Str "bar"] ("/url/",""),Str "."] ,Para [Str "Foo",Space,Link [Str "bar"] ("/url/",""),Str "."]-,Para [Str "With",Space,Link [Str "embedded",Space,Str "[",Str "brackets",Str "]"] ("/url/",""),Str "."]-,Para [Link [Str "b"] ("/url/",""),Space,Str "by",Space,Str "itself",Space,Str "should",Space,Str "be",Space,Str "a",Space,Str "link",Str "."]+,Para [Str "With",Space,Link [Str "embedded",Space,Str "[brackets]"] ("/url/",""),Str "."]+,Para [Link [Str "b"] ("/url/",""),Space,Str "by",Space,Str "itself",Space,Str "should",Space,Str "be",Space,Str "a",Space,Str "link."] ,Para [Str "Indented",Space,Link [Str "once"] ("/url",""),Str "."] ,Para [Str "Indented",Space,Link [Str "twice"] ("/url",""),Str "."] ,Para [Str "Indented",Space,Link [Str "thrice"] ("/url",""),Str "."]-,Para [Str "This",Space,Str "should",Space,Str "[",Str "not",Str "]",Str "[",Str "]",Space,Str "be",Space,Str "a",Space,Str "link",Str "."]+,Para [Str "This",Space,Str "should",Space,Str "[not][]",Space,Str "be",Space,Str "a",Space,Str "link."] ,CodeBlock ("",[],[]) "[not]: /url" ,Para [Str "Foo",Space,Link [Str "bar"] ("/url/","Title with \"quotes\" inside"),Str "."] ,Para [Str "Foo",Space,Link [Str "biz"] ("/url/","Title with \"quote\" inside"),Str "."]-,Header 2 [Str "With",Space,Str "ampersands"]+,Header 2 ("with-ampersands",[],[]) [Str "With",Space,Str "ampersands"] ,Para [Str "Here\8217s",Space,Str "a",Space,Link [Str "link",Space,Str "with",Space,Str "an",Space,Str "ampersand",Space,Str "in",Space,Str "the",Space,Str "URL"] ("http://example.com/?foo=1&bar=2",""),Str "."]-,Para [Str "Here\8217s",Space,Str "a",Space,Str "link",Space,Str "with",Space,Str "an",Space,Str "amersand",Space,Str "in",Space,Str "the",Space,Str "link",Space,Str "text",Str ":",Space,Link [Str "AT",Str "&",Str "T"] ("http://att.com/","AT&T"),Str "."]+,Para [Str "Here\8217s",Space,Str "a",Space,Str "link",Space,Str "with",Space,Str "an",Space,Str "amersand",Space,Str "in",Space,Str "the",Space,Str "link",Space,Str "text:",Space,Link [Str "AT&T"] ("http://att.com/","AT&T"),Str "."] ,Para [Str "Here\8217s",Space,Str "an",Space,Link [Str "inline",Space,Str "link"] ("/script?foo=1&bar=2",""),Str "."] ,Para [Str "Here\8217s",Space,Str "an",Space,Link [Str "inline",Space,Str "link",Space,Str "in",Space,Str "pointy",Space,Str "braces"] ("/script?foo=1&bar=2",""),Str "."]-,Header 2 [Str "Autolinks"]-,Para [Str "With",Space,Str "an",Space,Str "ampersand",Str ":",Space,Link [Code ("",["url"],[]) "http://example.com/?foo=1&bar=2"] ("http://example.com/?foo=1&bar=2","")]+,Header 2 ("autolinks",[],[]) [Str "Autolinks"]+,Para [Str "With",Space,Str "an",Space,Str "ampersand:",Space,Link [Str "http://example.com/?foo=1&bar=2"] ("http://example.com/?foo=1&bar=2","")] ,BulletList- [[Plain [Str "In",Space,Str "a",Space,Str "list",Str "?"]]- ,[Plain [Link [Code ("",["url"],[]) "http://example.com/"] ("http://example.com/","")]]- ,[Plain [Str "It",Space,Str "should",Str "."]]]-,Para [Str "An",Space,Str "e",Str "-",Str "mail",Space,Str "address",Str ":",Space,Link [Code ("",["url"],[]) "nobody@nowhere.net"] ("mailto:nobody@nowhere.net","")]+ [[Plain [Str "In",Space,Str "a",Space,Str "list?"]]+ ,[Plain [Link [Str "http://example.com/"] ("http://example.com/","")]]+ ,[Plain [Str "It",Space,Str "should."]]]+,Para [Str "An",Space,Str "e-mail",Space,Str "address:",Space,Link [Str "nobody@nowhere.net"] ("mailto:nobody@nowhere.net","")] ,BlockQuote- [Para [Str "Blockquoted",Str ":",Space,Link [Code ("",["url"],[]) "http://example.com/"] ("http://example.com/","")]]-,Para [Str "Auto",Str "-",Str "links",Space,Str "should",Space,Str "not",Space,Str "occur",Space,Str "here",Str ":",Space,Code ("",[],[]) "<http://example.com/>"]+ [Para [Str "Blockquoted:",Space,Link [Str "http://example.com/"] ("http://example.com/","")]]+,Para [Str "Auto-links",Space,Str "should",Space,Str "not",Space,Str "occur",Space,Str "here:",Space,Code ("",[],[]) "<http://example.com/>"] ,CodeBlock ("",[],[]) "or here: <http://example.com/>" ,HorizontalRule-,Header 1 [Str "Images"]-,Para [Str "From",Space,Quoted DoubleQuote [Str "Voyage",Space,Str "dans",Space,Str "la",Space,Str "Lune"],Space,Str "by",Space,Str "Georges",Space,Str "Melies",Space,Str "(",Str "1902",Str ")",Str ":"]-,Para [Image [Str "lalune"] ("lalune.jpg","Voyage dans la Lune")]-,Para [Str "Here",Space,Str "is",Space,Str "a",Space,Str "movie",Space,Image [Str "movie"] ("movie.jpg",""),Space,Str "icon",Str "."]+,Header 1 ("images",[],[]) [Str "Images"]+,Para [Str "From",Space,Quoted DoubleQuote [Str "Voyage",Space,Str "dans",Space,Str "la",Space,Str "Lune"],Space,Str "by",Space,Str "Georges",Space,Str "Melies",Space,Str "(1902):"]+,Para [Image [Str "lalune"] ("lalune.jpg","fig:Voyage dans la Lune")]+,Para [Str "Here",Space,Str "is",Space,Str "a",Space,Str "movie",Space,Image [Str "movie"] ("movie.jpg",""),Space,Str "icon."] ,HorizontalRule-,Header 1 [Str "Footnotes"]-,Para [Str "Here",Space,Str "is",Space,Str "a",Space,Str "footnote",Space,Str "reference",Str ",",Note [Para [Str "Here",Space,Str "is",Space,Str "the",Space,Str "footnote",Str ".",Space,Str "It",Space,Str "can",Space,Str "go",Space,Str "anywhere",Space,Str "after",Space,Str "the",Space,Str "footnote",Space,Str "reference",Str ".",Space,Str "It",Space,Str "need",Space,Str "not",Space,Str "be",Space,Str "placed",Space,Str "at",Space,Str "the",Space,Str "end",Space,Str "of",Space,Str "the",Space,Str "document",Str "."]],Space,Str "and",Space,Str "another",Str ".",Note [Para [Str "Here\8217s",Space,Str "the",Space,Str "long",Space,Str "note",Str ".",Space,Str "This",Space,Str "one",Space,Str "contains",Space,Str "multiple",Space,Str "blocks",Str "."],Para [Str "Subsequent",Space,Str "blocks",Space,Str "are",Space,Str "indented",Space,Str "to",Space,Str "show",Space,Str "that",Space,Str "they",Space,Str "belong",Space,Str "to",Space,Str "the",Space,Str "footnote",Space,Str "(",Str "as",Space,Str "with",Space,Str "list",Space,Str "items",Str ")",Str "."],CodeBlock ("",[],[]) " { <code> }",Para [Str "If",Space,Str "you",Space,Str "want",Str ",",Space,Str "you",Space,Str "can",Space,Str "indent",Space,Str "every",Space,Str "line",Str ",",Space,Str "but",Space,Str "you",Space,Str "can",Space,Str "also",Space,Str "be",Space,Str "lazy",Space,Str "and",Space,Str "just",Space,Str "indent",Space,Str "the",Space,Str "first",Space,Str "line",Space,Str "of",Space,Str "each",Space,Str "block",Str "."]],Space,Str "This",Space,Str "should",Space,Emph [Str "not"],Space,Str "be",Space,Str "a",Space,Str "footnote",Space,Str "reference",Str ",",Space,Str "because",Space,Str "it",Space,Str "contains",Space,Str "a",Space,Str "space",Str ".",Str "[",Str "^",Str "my",Space,Str "note",Str "]",Space,Str "Here",Space,Str "is",Space,Str "an",Space,Str "inline",Space,Str "note",Str ".",Note [Para [Str "This",Space,Str "is",Space,Emph [Str "easier"],Space,Str "to",Space,Str "type",Str ".",Space,Str "Inline",Space,Str "notes",Space,Str "may",Space,Str "contain",Space,Link [Str "links"] ("http://google.com",""),Space,Str "and",Space,Code ("",[],[]) "]",Space,Str "verbatim",Space,Str "characters",Str ",",Space,Str "as",Space,Str "well",Space,Str "as",Space,Str "[",Str "bracketed",Space,Str "text",Str "]",Str "."]]]+,Header 1 ("footnotes",[],[]) [Str "Footnotes"]+,Para [Str "Here",Space,Str "is",Space,Str "a",Space,Str "footnote",Space,Str "reference,",Note [Para [Str "Here",Space,Str "is",Space,Str "the",Space,Str "footnote.",Space,Str "It",Space,Str "can",Space,Str "go",Space,Str "anywhere",Space,Str "after",Space,Str "the",Space,Str "footnote",Space,Str "reference.",Space,Str "It",Space,Str "need",Space,Str "not",Space,Str "be",Space,Str "placed",Space,Str "at",Space,Str "the",Space,Str "end",Space,Str "of",Space,Str "the",Space,Str "document."]],Space,Str "and",Space,Str "another.",Note [Para [Str "Here\8217s",Space,Str "the",Space,Str "long",Space,Str "note.",Space,Str "This",Space,Str "one",Space,Str "contains",Space,Str "multiple",Space,Str "blocks."],Para [Str "Subsequent",Space,Str "blocks",Space,Str "are",Space,Str "indented",Space,Str "to",Space,Str "show",Space,Str "that",Space,Str "they",Space,Str "belong",Space,Str "to",Space,Str "the",Space,Str "footnote",Space,Str "(as",Space,Str "with",Space,Str "list",Space,Str "items)."],CodeBlock ("",[],[]) " { <code> }",Para [Str "If",Space,Str "you",Space,Str "want,",Space,Str "you",Space,Str "can",Space,Str "indent",Space,Str "every",Space,Str "line,",Space,Str "but",Space,Str "you",Space,Str "can",Space,Str "also",Space,Str "be",Space,Str "lazy",Space,Str "and",Space,Str "just",Space,Str "indent",Space,Str "the",Space,Str "first",Space,Str "line",Space,Str "of",Space,Str "each",Space,Str "block."]],Space,Str "This",Space,Str "should",Space,Emph [Str "not"],Space,Str "be",Space,Str "a",Space,Str "footnote",Space,Str "reference,",Space,Str "because",Space,Str "it",Space,Str "contains",Space,Str "a",Space,Str "space.[^my",Space,Str "note]",Space,Str "Here",Space,Str "is",Space,Str "an",Space,Str "inline",Space,Str "note.",Note [Para [Str "This",Space,Str "is",Space,Emph [Str "easier"],Space,Str "to",Space,Str "type.",Space,Str "Inline",Space,Str "notes",Space,Str "may",Space,Str "contain",Space,Link [Str "links"] ("http://google.com",""),Space,Str "and",Space,Code ("",[],[]) "]",Space,Str "verbatim",Space,Str "characters,",Space,Str "as",Space,Str "well",Space,Str "as",Space,Str "[bracketed",Space,Str "text]."]]] ,BlockQuote- [Para [Str "Notes",Space,Str "can",Space,Str "go",Space,Str "in",Space,Str "quotes",Str ".",Note [Para [Str "In",Space,Str "quote",Str "."]]]]+ [Para [Str "Notes",Space,Str "can",Space,Str "go",Space,Str "in",Space,Str "quotes.",Note [Para [Str "In",Space,Str "quote."]]]] ,OrderedList (1,Decimal,Period)- [[Plain [Str "And",Space,Str "in",Space,Str "list",Space,Str "items",Str ".",Note [Para [Str "In",Space,Str "list",Str "."]]]]]-,Para [Str "This",Space,Str "paragraph",Space,Str "should",Space,Str "not",Space,Str "be",Space,Str "part",Space,Str "of",Space,Str "the",Space,Str "note",Str ",",Space,Str "as",Space,Str "it",Space,Str "is",Space,Str "not",Space,Str "indented",Str "."]]+ [[Plain [Str "And",Space,Str "in",Space,Str "list",Space,Str "items.",Note [Para [Str "In",Space,Str "list."]]]]]+,Para [Str "This",Space,Str "paragraph",Space,Str "should",Space,Str "not",Space,Str "be",Space,Str "part",Space,Str "of",Space,Str "the",Space,Str "note,",Space,Str "as",Space,Str "it",Space,Str "is",Space,Str "not",Space,Str "indented."]]
@@ -1,13 +1,13 @@ Pandoc (Meta {docTitle = [], docAuthors = [], docDate = []}) [Para [Str "This",Space,Str "is",Space,Str "a",Space,Str "set",Space,Str "of",Space,Str "tests",Space,Str "for",Space,Str "pandoc",Space,Str "Textile",Space,Str "Reader",Str ".",Space,Str "Part",Space,Str "of",Space,Str "it",Space,Str "comes",LineBreak,Str "from",Space,Str "John",Space,Str "Gruber",Str "\8217",Str "s",Space,Str "markdown",Space,Str "test",Space,Str "suite",Str "."] ,HorizontalRule-,Header 1 [Str "Headers"]-,Header 2 [Str "Level",Space,Str "2",Space,Str "with",Space,Str "an",Space,Link [Str "embeded",Space,Str "link"] ("http://www.example.com","")]-,Header 3 [Str "Level",Space,Str "3",Space,Str "with",Space,Strong [Str "emphasis"]]-,Header 4 [Str "Level",Space,Str "4"]-,Header 5 [Str "Level",Space,Str "5"]-,Header 6 [Str "Level",Space,Str "6"]-,Header 1 [Str "Paragraphs"]+,Header 1 ("",[],[]) [Str "Headers"]+,Header 2 ("",[],[]) [Str "Level",Space,Str "2",Space,Str "with",Space,Str "an",Space,Link [Str "embeded",Space,Str "link"] ("http://www.example.com","")]+,Header 3 ("",[],[]) [Str "Level",Space,Str "3",Space,Str "with",Space,Strong [Str "emphasis"]]+,Header 4 ("",[],[]) [Str "Level",Space,Str "4"]+,Header 5 ("",[],[]) [Str "Level",Space,Str "5"]+,Header 6 ("",[],[]) [Str "Level",Space,Str "6"]+,Header 1 ("",[],[]) [Str "Paragraphs"] ,Para [Str "Here",Str "\8217",Str "s",Space,Str "a",Space,Str "regular",Space,Str "paragraph",Str "."] ,Para [Str "Line",Space,Str "breaks",Space,Str "are",Space,Str "preserved",Space,Str "in",Space,Str "textile",Str ",",Space,Str "so",Space,Str "you",Space,Str "can",Space,Str "not",Space,Str "wrap",Space,Str "your",Space,Str "very",LineBreak,Str "long",Space,Str "paragraph",Space,Str "with",Space,Str "your",Space,Str "favourite",Space,Str "text",Space,Str "editor",Space,Str "and",Space,Str "have",Space,Str "it",Space,Str "rendered",LineBreak,Str "with",Space,Str "no",Space,Str "break",Str "."] ,Para [Str "Here",Str "\8217",Str "s",Space,Str "one",Space,Str "with",Space,Str "a",Space,Str "bullet",Str "."]@@ -16,35 +16,39 @@ ,Para [Str "There",Space,Str "should",Space,Str "be",Space,Str "a",Space,Str "paragraph",Space,Str "break",Space,Str "between",Space,Str "here"] ,Para [Str "and",Space,Str "here",Str "."] ,Para [Str "pandoc",Space,Str "converts",Space,Str "textile",Str "."]-,Header 1 [Str "Block",Space,Str "Quotes"]+,Header 1 ("",[],[]) [Str "Block",Space,Str "Quotes"] ,BlockQuote [Para [Str "This",Space,Str "is",Space,Str "a",Space,Str "famous",Space,Str "quote",Space,Str "from",Space,Str "somebody",Str ".",Space,Str "He",Space,Str "had",Space,Str "a",Space,Str "lot",Space,Str "of",Space,Str "things",Space,Str "to",LineBreak,Str "say",Str ",",Space,Str "so",Space,Str "the",Space,Str "text",Space,Str "is",Space,Str "really",Space,Str "really",Space,Str "long",Space,Str "and",Space,Str "spans",Space,Str "on",Space,Str "multiple",Space,Str "lines",Str "."]] ,Para [Str "And",Space,Str "a",Space,Str "following",Space,Str "paragraph",Str "."]-,Header 1 [Str "Code",Space,Str "Blocks"]+,Header 1 ("",[],[]) [Str "Code",Space,Str "Blocks"] ,Para [Str "Code",Str ":"] ,CodeBlock ("",[],[]) " ---- (should be four hyphens)\n\n sub status {\n print \"working\";\n }\n\n this code block is indented by one tab" ,Para [Str "And",Str ":"] ,CodeBlock ("",[],[]) " this code block is indented by two tabs\n\n These should not be escaped: \\$ \\\\ \\> \\[ \\{" ,CodeBlock ("",[],[]) "Code block with .bc\n continued\n @</\\\n" ,Para [Str "Inline",Space,Str "code",Str ":",Space,Code ("",[],[]) "<tt>",Str ",",Space,Code ("",[],[]) "@",Str "."]-,Header 1 [Str "Notextile"]+,Header 1 ("",[],[]) [Str "Notextile"] ,Para [Str "A",Space,Str "block",Space,Str "of",Space,Str "text",Space,Str "can",Space,Str "be",Space,Str "protected",Space,Str "with",Space,Str "notextile",Space,Str ":"] ,Para [Str "\nNo *bold* and\n* no bullet\n"] ,Para [Str "and",Space,Str "inlines",Space,Str "can",Space,Str "be",Space,Str "protected",Space,Str "with",Space,Str "double *equals (=)* markup",Str "."]-,Header 1 [Str "Lists"]-,Header 2 [Str "Unordered"]+,Header 1 ("",[],[]) [Str "Lists"]+,Header 2 ("",[],[]) [Str "Unordered"] ,Para [Str "Asterisks",Space,Str "tight",Str ":"] ,BulletList [[Plain [Str "asterisk",Space,Str "1"]] ,[Plain [Str "asterisk",Space,Str "2"]] ,[Plain [Str "asterisk",Space,Str "3"]]]-,Header 2 [Str "Ordered"]+,Para [Str "With",Space,Str "line",Space,Str "breaks",Str ":"]+,BulletList+ [[Plain [Str "asterisk",Space,Str "1",LineBreak,Str "newline"]]+ ,[Plain [Str "asterisk",Space,Str "2"]]]+,Header 2 ("",[],[]) [Str "Ordered"] ,Para [Str "Tight",Str ":"] ,OrderedList (1,DefaultStyle,DefaultDelim) [[Plain [Str "First"]] ,[Plain [Str "Second"]] ,[Plain [Str "Third"]]]-,Header 2 [Str "Nested"]+,Header 2 ("",[],[]) [Str "Nested"] ,BulletList [[Plain [Str "ui",Space,Str "1"] ,BulletList@@ -59,7 +63,7 @@ ,BulletList [[Plain [Str "ui",Space,Str "2",Str ".",Str "1",Str ".",Str "1"]] ,[Plain [Str "ui",Space,Str "2",Str ".",Str "1",Str ".",Str "2"]]]]]]]-,Header 2 [Str "Definition",Space,Str "List"]+,Header 2 ("",[],[]) [Str "Definition",Space,Str "List"] ,DefinitionList [([Str "coffee"], [[Plain [Str "Hot",Space,Str "and",Space,Str "black"]]])@@ -70,22 +74,23 @@ ,Para [Str "Cold",Space,Str "drink",Space,Str "that",Space,Str "goes",Space,Str "great",Space,Str "with",Space,Str "cookies",Str "."]]]) ,([Str "beer"], [[Plain [Str "fresh",Space,Str "and",Space,Str "bitter"]]])]-,Header 1 [Str "Inline",Space,Str "Markup"]+,Header 1 ("",[],[]) [Str "Inline",Space,Str "Markup"] ,Para [Str "This",Space,Str "is",Space,Emph [Str "emphasized"],Str ",",Space,Str "and",Space,Str "so",Space,Emph [Str "is",Space,Str "this"],Str ".",LineBreak,Str "This",Space,Str "is",Space,Strong [Str "strong"],Str ",",Space,Str "and",Space,Str "so",Space,Strong [Str "is",Space,Str "this"],Str ".",LineBreak,Str "Hyphenated-words-are-ok",Str ",",Space,Str "as",Space,Str "well",Space,Str "as",Space,Str "strange_underscore_notation",Str ".",LineBreak,Str "A",Space,Link [Strong [Str "strong",Space,Str "link"]] ("http://www.foobar.com",""),Str "."] ,Para [Emph [Strong [Str "This",Space,Str "is",Space,Str "strong",Space,Str "and",Space,Str "em",Str "."]],LineBreak,Str "So",Space,Str "is",Space,Strong [Emph [Str "this"]],Space,Str "word",Space,Str "and",Space,Emph [Strong [Str "that",Space,Str "one"]],Str ".",LineBreak,Strikeout [Str "This",Space,Str "is",Space,Str "strikeout",Space,Str "and",Space,Strong [Str "strong"]]] ,Para [Str "Superscripts",Str ":",Space,Str "a",Superscript [Str "bc"],Str "d",Space,Str "a",Superscript [Strong [Str "hello"]],Space,Str "a",Superscript [Str "hello",Space,Str "there"],Str ".",LineBreak,Str "Subscripts",Str ":",Space,Subscript [Str "here"],Space,Str "H",Subscript [Str "2"],Str "O",Str ",",Space,Str "H",Subscript [Str "23"],Str "O",Str ",",Space,Str "H",Subscript [Str "many",Space,Str "of",Space,Str "them"],Str "O",Str "."] ,Para [Str "Dashes",Space,Str ":",Space,Str "How",Space,Str "cool",Space,Str "\8212",Space,Str "automatic",Space,Str "dashes",Str "."] ,Para [Str "Elipses",Space,Str ":",Space,Str "He",Space,Str "thought",Space,Str "and",Space,Str "thought",Space,Str "\8230",Space,Str "and",Space,Str "then",Space,Str "thought",Space,Str "some",Space,Str "more",Str "."] ,Para [Str "Quotes",Space,Str "and",Space,Str "apostrophes",Space,Str ":",Space,Quoted DoubleQuote [Str "I",Str "\8217",Str "d",Space,Str "like",Space,Str "to",Space,Str "thank",Space,Str "you"],Space,Str "for",Space,Str "example",Str "."]-,Header 1 [Str "Links"]-,Header 2 [Str "Explicit"]+,Header 1 ("",[],[]) [Str "Links"]+,Header 2 ("",[],[]) [Str "Explicit"] ,Para [Str "Just",Space,Str "a",Space,Link [Str "url"] ("http://www.url.com","")] ,Para [Link [Str "Email",Space,Str "link"] ("mailto:nobody@nowhere.net","")]-,Para [Str "Automatic",Space,Str "linking",Space,Str "to",Space,Link [Str "http://www.example.com"] ("http://www.example.com",""),Space,Str "and",Space,Link [Str "foobar@example.com"] ("mailto:foobar@example.com",""),Str "."]+,Para [Str "Automatic",Space,Str "linking",Space,Str "to",Space,Link [Str "http://www.example.com"] ("http://www.example.com",""),Str "."] ,Para [Link [Str "Example"] ("http://www.example.com/",""),Str ":",Space,Str "Example",Space,Str "of",Space,Str "a",Space,Str "link",Space,Str "followed",Space,Str "by",Space,Str "a",Space,Str "colon",Str "."]-,Header 1 [Str "Tables"]+,Para [Str "A",Space,Str "link",Link [Str "with",Space,Str "brackets"] ("http://www.example.com",""),Str "and",Space,Str "no",Space,Str "spaces",Str "."]+,Header 1 ("",[],[]) [Str "Tables"] ,Para [Str "Textile",Space,Str "allows",Space,Str "tables",Space,Str "with",Space,Str "and",Space,Str "without",Space,Str "headers",Space,Str ":"]-,Header 2 [Str "Without",Space,Str "headers"]+,Header 2 ("",[],[]) [Str "Without",Space,Str "headers"] ,Table [] [AlignDefault,AlignDefault,AlignDefault] [0.0,0.0,0.0] [] [[[Plain [Str "name"]]@@ -101,7 +106,7 @@ ,[Plain [Str "45"]] ,[Plain [Str "f"]]]] ,Para [Str "and",Space,Str "some",Space,Str "text",Space,Str "following",Space,Str "\8230"]-,Header 2 [Str "With",Space,Str "headers"]+,Header 2 ("",[],[]) [Str "With",Space,Str "headers"] ,Table [] [AlignDefault,AlignDefault,AlignDefault] [0.0,0.0,0.0] [[Plain [Str "name"]] ,[Plain [Str "age"]]@@ -115,10 +120,10 @@ ,[[Plain [Str "bella"]] ,[Plain [Str "45"]] ,[Plain [Str "f"]]]]-,Header 1 [Str "Images"]+,Header 1 ("",[],[]) [Str "Images"] ,Para [Str "Textile",Space,Str "inline",Space,Str "image",Space,Str "syntax",Str ",",Space,Str "like",Space,LineBreak,Str "here",Space,Image [Str "this is the alt text"] ("this_is_an_image.png","this is the alt text"),LineBreak,Str "and",Space,Str "here",Space,Image [Str ""] ("this_is_an_image.png",""),Str "."]-,Header 1 [Str "Attributes"]-,Header 2 [Str "HTML",Space,Str "and",Space,Str "CSS",Space,Str "attributes",Space,Str "are",Space,Str "ignored"]+,Header 1 ("",[],[]) [Str "Attributes"]+,Header 2 ("",[],[]) [Str "HTML",Space,Str "and",Space,Str "CSS",Space,Str "attributes",Space,Str "are",Space,Str "ignored"] ,Para [Str "as",Space,Str "well",Space,Str "as",Space,Strong [Str "inline",Space,Str "attributes"],Space,Str "of",Space,Str " all kind"] ,Para [Str "and",Space,Str "paragraph",Space,Str "attributes",Str ",",Space,Str "and",Space,Str "table",Space,Str "attributes",Str "."] ,Table [] [AlignDefault,AlignDefault,AlignDefault] [0.0,0.0,0.0]@@ -129,7 +134,7 @@ ,[[Plain [Str "joan"]] ,[Plain [Str "24"]] ,[Plain [Str "f"]]]]-,Header 1 [Str "Raw",Space,Str "HTML"]+,Header 1 ("",[],[]) [Str "Raw",Space,Str "HTML"] ,Para [Str "However",Str ",",Space,RawInline "html" "<strong>",Space,Str "raw",Space,Str "HTML",Space,Str "inlines",Space,RawInline "html" "</strong>",Space,Str "are",Space,Str "accepted",Str ",",Space,Str "as",Space,Str "well",Space,Str "as",Space,Str ":"] ,RawBlock "html" "<div class=\"foobar\">" ,Para [Str "any",Space,Strong [Str "Raw",Space,Str "HTML",Space,Str "Block"],Space,Str "with",Space,Str "bold",LineBreak]@@ -143,15 +148,18 @@ [[Plain [Str "this",Space,Str "<",Str "div",Str ">",Space,Str "won",Str "\8217",Str "t",Space,Str "produce",Space,Str "raw",Space,Str "html",Space,Str "blocks",Space,Str "<",Str "/div",Str ">"]] ,[Plain [Str "but",Space,Str "this",Space,RawInline "html" "<strong>",Space,Str "will",Space,Str "produce",Space,Str "inline",Space,Str "html",Space,RawInline "html" "</strong>"]]] ,Para [Str "Can",Space,Str "you",Space,Str "prove",Space,Str "that",Space,Str "2",Space,Str "<",Space,Str "3",Space,Str "?"]-,Header 1 [Str "Raw",Space,Str "LaTeX"]+,Header 1 ("",[],[]) [Str "Raw",Space,Str "LaTeX"] ,Para [Str "This",Space,Str "Textile",Space,Str "reader",Space,Str "also",Space,Str "accepts",Space,Str "raw",Space,Str "LaTeX",Space,Str "for",Space,Str "blocks",Space,Str ":"] ,RawBlock "latex" "\\begin{itemize}\n \\item one\n \\item two\n\\end{itemize}" ,Para [Str "and",Space,Str "for",Space,RawInline "latex" "\\emph{inlines}",Str "."]-,Header 1 [Str "Acronyms",Space,Str "and",Space,Str "marks"]+,Header 1 ("",[],[]) [Str "Acronyms",Space,Str "and",Space,Str "marks"] ,Para [Str "PBS (Public Broadcasting System)"] ,Para [Str "Hi",Str "\8482"] ,Para [Str "Hi",Space,Str "\8482"] ,Para [Str "\174",Space,Str "Hi",Str "\174"] ,Para [Str "Hi",Str "\169",Str "2008",Space,Str "\169",Space,Str "2008"]-,Header 1 [Str "Footnotes"]-,Para [Str "A",Space,Str "note",Str ".",Note [Para [Str "The",Space,Str "note",LineBreak,Str "is",Space,Str "here",Str "!"]]]]+,Header 1 ("",[],[]) [Str "Footnotes"]+,Para [Str "A",Space,Str "note",Str ".",Note [Para [Str "The",Space,Str "note",LineBreak,Str "is",Space,Str "here",Str "!"]],Space,Str "Another",Space,Str "note",Note [Para [Str "Other",Space,Str "note",Str "."]],Str "."]+,Header 1 ("",[],[]) [Str "Comment",Space,Str "blocks"]+,Null+,Para [Str "not",Space,Str "a",Space,Str "comment",Str "."]]
@@ -91,6 +91,12 @@ * asterisk 2 * asterisk 3 +With line breaks:++* asterisk 1+newline+* asterisk 2+ h2. Ordered Tight:@@ -151,10 +157,12 @@ "Email link":mailto:nobody@nowhere.net -Automatic linking to http://www.example.com and foobar@example.com.+Automatic linking to "$":http://www.example.com. "Example":http://www.example.com/: Example of a link followed by a colon. +A link["with brackets":http://www.example.com]and no spaces.+ h1. Tables Textile allows tables with and without headers :@@ -235,7 +243,16 @@ h1. Footnotes -A note.[1]+A note.[1] Another note[2]. fn1. The note is here!++fn2. Other note.++h1. Comment blocks++###. my comment+is here.++not a comment.
@@ -9,31 +9,40 @@ ''''' +[[headers]] Headers ------- +[[level-2-with-an-embedded-link]] Level 2 with an link:/url[embedded link] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +[[level-3-with-emphasis]] Level 3 with _emphasis_ ^^^^^^^^^^^^^^^^^^^^^^^ +[[level-4]] Level 4 +++++++ +[[level-5]] Level 5 +[[level-1]] Level 1 ------- +[[level-2-with-emphasis]] Level 2 with _emphasis_ ~~~~~~~~~~~~~~~~~~~~~~~ +[[level-3]] Level 3 ^^^^^^^ with no blank line +[[level-2]] Level 2 ~~~~~~~ @@ -41,6 +50,7 @@ ''''' +[[paragraphs]] Paragraphs ---------- @@ -57,6 +67,7 @@ ''''' +[[block-quotes]] Block Quotes ------------ @@ -100,6 +111,7 @@ ''''' +[[code-blocks]] Code Blocks ----------- @@ -125,9 +137,11 @@ ''''' +[[lists]] Lists ----- +[[unordered]] Unordered ~~~~~~~~~ @@ -167,6 +181,7 @@ * Minus 2 * Minus 3 +[[ordered]] Ordered ~~~~~~~ @@ -202,6 +217,7 @@ 2. Item 2. 3. Item 3. +[[nested]] Nested ~~~~~~ @@ -227,6 +243,7 @@ * Foe 3. Third +[[tabs-and-spaces]] Tabs and spaces ~~~~~~~~~~~~~~~ @@ -235,6 +252,7 @@ ** this is an example list item indented with tabs ** this is an example list item indented with spaces +[[fancy-list-markers]] Fancy list markers ~~~~~~~~~~~~~~~~~~ @@ -268,6 +286,7 @@ ''''' +[[definition-lists]] Definition Lists ---------------- @@ -349,6 +368,7 @@ 1. sublist 2. sublist +[[html-blocks]] HTML Blocks ----------- @@ -405,6 +425,7 @@ ''''' +[[inline-markup]] Inline Markup ------------- @@ -435,6 +456,7 @@ ''''' +[[smart-quotes-ellipses-dashes]] Smart quotes, ellipses, dashes ------------------------------ @@ -457,6 +479,7 @@ ''''' +[[latex]] LaTeX ----- @@ -483,6 +506,7 @@ ''''' +[[special-characters]] Special Characters ------------------ @@ -538,9 +562,11 @@ ''''' +[[links]] Links ----- +[[explicit]] Explicit ~~~~~~~~ @@ -562,6 +588,7 @@ link:[Empty]. +[[reference]] Reference ~~~~~~~~~ @@ -591,6 +618,7 @@ Foo link:/url/[biz]. +[[with-ampersands]] With ampersands ~~~~~~~~~~~~~~~ @@ -602,6 +630,7 @@ Here’s an link:/script?foo=1&bar=2[inline link in pointy braces]. +[[autolinks]] Autolinks ~~~~~~~~~ @@ -625,6 +654,7 @@ ''''' +[[images]] Images ------ @@ -636,6 +666,7 @@ ''''' +[[footnotes]] Footnotes ---------
@@ -6,7 +6,7 @@ % Enable hyperlinks \setupinteraction[state=start, color=middleblue] -\setuppapersize [letter][letter] +\setuppapersize [letter][letter] \setuplayout [width=middle, backspace=1.5in, cutspace=1.5in, height=middle, topspace=0.75in, bottomspace=0.75in] @@ -115,7 +115,7 @@ A list: -\startitemize[n][stopper=.]+\startitemize[n,packed][stopper=.] \item item one \item@@ -169,7 +169,7 @@ Asterisks tight: -\startitemize+\startitemize[packed] \item asterisk 1 \item@@ -191,7 +191,7 @@ Pluses tight: -\startitemize+\startitemize[packed] \item Plus 1 \item@@ -213,7 +213,7 @@ Minuses tight: -\startitemize+\startitemize[packed] \item Minus 1 \item@@ -237,7 +237,7 @@ Tight: -\startitemize[n][stopper=.]+\startitemize[n,packed][stopper=.] \item First \item@@ -248,7 +248,7 @@ and: -\startitemize[n][stopper=.]+\startitemize[n,packed][stopper=.] \item One \item@@ -294,13 +294,13 @@ \subsection[nested]{Nested} -\startitemize+\startitemize[packed] \item Tab- \startitemize+ \startitemize[packed] \item Tab- \startitemize+ \startitemize[packed] \item Tab \stopitemize@@ -309,12 +309,12 @@ Here's another: -\startitemize[n][stopper=.]+\startitemize[n,packed][stopper=.] \item First \item Second:- \startitemize+ \startitemize[packed] \item Fee \item@@ -334,7 +334,7 @@ \item Second: - \startitemize+ \startitemize[packed] \item Fee \item@@ -372,12 +372,12 @@ with a continuation - \startitemize[r][start=4,stopper=.,width=2.0em]+ \startitemize[r,packed][start=4,stopper=.,width=2.0em] \item sublist with roman numerals, starting with 4 \item more items- \startitemize[A][left=(,stopper=),width=2.0em]+ \startitemize[A,packed][left=(,stopper=),width=2.0em] \item a subsublist \item@@ -388,16 +388,16 @@ Nesting: -\startitemize[A][stopper=.]+\startitemize[A,packed][stopper=.] \item Upper Alpha- \startitemize[R][stopper=.]+ \startitemize[R,packed][stopper=.] \item Upper Roman.- \startitemize[n][start=6,left=(,stopper=),width=2.0em]+ \startitemize[n,packed][start=6,left=(,stopper=),width=2.0em] \item Decimal start with 6- \startitemize[a][start=3,stopper=)]+ \startitemize[a,packed][start=3,stopper=)] \item Lower alpha with paren \stopitemize@@ -407,12 +407,12 @@ Autonumbering: -\startitemize[n]+\startitemize[n,packed] \item Autonumber. \item More.- \startitemize[a]+ \startitemize[a,packed] \item Nested. \stopitemize@@ -529,7 +529,7 @@ \startdescription{orange} orange fruit - \startitemize[n][stopper=.]+ \startitemize[n,packed][stopper=.] \item sublist \item@@ -646,7 +646,7 @@ \section[latex]{LaTeX} -\startitemize+\startitemize[packed] \item \cite[22-23]{smith.1899} \item@@ -668,7 +668,7 @@ These shouldn't be math: -\startitemize+\startitemize[packed] \item To get the famous equation, write \type{$e = mc^2$}. \item@@ -688,7 +688,7 @@ Here is some unicode: -\startitemize+\startitemize[packed] \item I hat: Î \item@@ -813,7 +813,7 @@ With an ampersand: \useURL[url27][http://example.com/?foo=1&bar=2][][\hyphenatedurl{http://example.com/?foo=1&bar=2}]\from[url27] -\startitemize+\startitemize[packed] \item In a list? \item@@ -873,7 +873,7 @@ Notes can go in quotes.\footnote{In quote.} \stopblockquote -\startitemize[n][stopper=.]+\startitemize[n,packed][stopper=.] \item And in list items.\footnote{In list.} \stopitemize
@@ -1323,7 +1323,7 @@ <title>Autolinks</title> <para> With an ampersand:- <ulink url="http://example.com/?foo=1&bar=2"><literal>http://example.com/?foo=1&bar=2</literal></ulink>+ <ulink url="http://example.com/?foo=1&bar=2">http://example.com/?foo=1&bar=2</ulink> </para> <itemizedlist> <listitem>@@ -1333,7 +1333,7 @@ </listitem> <listitem> <para>- <ulink url="http://example.com/"><literal>http://example.com/</literal></ulink>+ <ulink url="http://example.com/">http://example.com/</ulink> </para> </listitem> <listitem>@@ -1348,7 +1348,7 @@ <blockquote> <para> Blockquoted:- <ulink url="http://example.com/"><literal>http://example.com/</literal></ulink>+ <ulink url="http://example.com/">http://example.com/</ulink> </para> </blockquote> <para>
@@ -8,6 +8,7 @@ <meta name="author" content="Anonymous" /> <meta name="date" content="2006-07-17" /> <title>Pandoc Test Suite</title>+ <style type="text/css">code{white-space: pre;}</style> </head> <body> <div id="header">@@ -281,30 +282,35 @@ <dl> <dt>apple</dt> <dd>red fruit-</dd><dd>computer </dd>+<dd>computer+</dd> <dt>orange</dt> <dd>orange fruit-</dd><dd>bank </dd>+<dd>bank+</dd> </dl> <p>Multiple definitions, loose:</p> <dl> <dt>apple</dt> <dd><p>red fruit</p>-</dd><dd><p>computer</p> </dd>+<dd><p>computer</p>+</dd> <dt>orange</dt> <dd><p>orange fruit</p>-</dd><dd><p>bank</p> </dd>+<dd><p>bank</p>+</dd> </dl> <p>Blank line after term, indented marker, alternate markers:</p> <dl> <dt>apple</dt> <dd><p>red fruit</p>-</dd><dd><p>computer</p> </dd>+<dd><p>computer</p>+</dd> <dt>orange</dt> <dd><p>orange fruit</p> <ol style="list-style-type: decimal">@@ -518,10 +524,10 @@ <p>Here’s an <a href="/script?foo=1&bar=2">inline link</a>.</p> <p>Here’s an <a href="/script?foo=1&bar=2">inline link in pointy braces</a>.</p> <h2 id="autolinks">Autolinks</h2>-<p>With an ampersand: <a href="http://example.com/?foo=1&bar=2"><code class="url">http://example.com/?foo=1&bar=2</code></a></p>+<p>With an ampersand: <a href="http://example.com/?foo=1&bar=2">http://example.com/?foo=1&bar=2</a></p> <ul> <li>In a list?</li>-<li><a href="http://example.com/"><code class="url">http://example.com/</code></a></li>+<li><a href="http://example.com/">http://example.com/</a></li> <li>It should.</li> </ul> <p>An e-mail address: <script type="text/javascript">@@ -531,7 +537,7 @@ // --> </script><noscript>nobody at nowhere dot net</noscript></p> <blockquote>-<p>Blockquoted: <a href="http://example.com/"><code class="url">http://example.com/</code></a></p>+<p>Blockquoted: <a href="http://example.com/">http://example.com/</a></p> </blockquote> <p>Auto-links should not occur here: <code><http://example.com/></code></p> <pre><code>or here: <http://example.com/></code></pre>
@@ -6,6 +6,8 @@ \usepackage{fixltx2e} % provides \textsubscript % use microtype if available \IfFileExists{microtype.sty}{\usepackage{microtype}}{}+% use upquote if available, for straight quotes in verbatim environments+\IfFileExists{upquote.sty}{\usepackage{upquote}}{} \ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex \usepackage[utf8]{inputenc} \else % if luatex or xelatex@@ -17,13 +19,6 @@ \newcommand{\euro}{€} \fi \usepackage{fancyvrb}-% Redefine labelwidth for lists; otherwise, the enumerate package will cause-% markers to extend beyond the left margin.-\makeatletter\AtBeginDocument{%- \renewcommand{\@listi}- {\setlength{\labelwidth}{4em}}-}\makeatother-\usepackage{enumerate} \usepackage{graphicx} % We will generate all images so they have a width \maxwidth. This means % that they will get their normal width if they fit onto the page, but@@ -127,7 +122,9 @@ A list: -\begin{enumerate}[1.]+\begin{enumerate}+\def\labelenumi{\arabic{enumi}.}+\itemsep1pt\parskip0pt\parsep0pt \item item one \item@@ -182,6 +179,7 @@ Asterisks tight: \begin{itemize}+\itemsep1pt\parskip0pt\parsep0pt \item asterisk 1 \item@@ -204,6 +202,7 @@ Pluses tight: \begin{itemize}+\itemsep1pt\parskip0pt\parsep0pt \item Plus 1 \item@@ -226,6 +225,7 @@ Minuses tight: \begin{itemize}+\itemsep1pt\parskip0pt\parsep0pt \item Minus 1 \item@@ -249,7 +249,9 @@ Tight: -\begin{enumerate}[1.]+\begin{enumerate}+\def\labelenumi{\arabic{enumi}.}+\itemsep1pt\parskip0pt\parsep0pt \item First \item@@ -260,7 +262,9 @@ and: -\begin{enumerate}[1.]+\begin{enumerate}+\def\labelenumi{\arabic{enumi}.}+\itemsep1pt\parskip0pt\parsep0pt \item One \item@@ -271,7 +275,8 @@ Loose using tabs: -\begin{enumerate}[1.]+\begin{enumerate}+\def\labelenumi{\arabic{enumi}.} \item First \item@@ -282,7 +287,8 @@ and using spaces: -\begin{enumerate}[1.]+\begin{enumerate}+\def\labelenumi{\arabic{enumi}.} \item One \item@@ -293,7 +299,8 @@ Multiple paragraphs: -\begin{enumerate}[1.]+\begin{enumerate}+\def\labelenumi{\arabic{enumi}.} \item Item 1, graf one. @@ -307,14 +314,17 @@ \subsection{Nested} \begin{itemize}+\itemsep1pt\parskip0pt\parsep0pt \item Tab \begin{itemize}+ \itemsep1pt\parskip0pt\parsep0pt \item Tab \begin{itemize}+ \itemsep1pt\parskip0pt\parsep0pt \item Tab \end{itemize}@@ -323,13 +333,16 @@ Here's another: -\begin{enumerate}[1.]+\begin{enumerate}+\def\labelenumi{\arabic{enumi}.}+\itemsep1pt\parskip0pt\parsep0pt \item First \item Second: \begin{itemize}+ \itemsep1pt\parskip0pt\parsep0pt \item Fee \item@@ -343,13 +356,15 @@ Same thing but with paragraphs: -\begin{enumerate}[1.]+\begin{enumerate}+\def\labelenumi{\arabic{enumi}.} \item First \item Second: \begin{itemize}+ \itemsep1pt\parskip0pt\parsep0pt \item Fee \item@@ -379,7 +394,8 @@ \subsection{Fancy list markers} -\begin{enumerate}[(1)]+\begin{enumerate}+\def\labelenumi{(\arabic{enumi})} \setcounter{enumi}{1} \item begins with 2@@ -388,14 +404,18 @@ with a continuation - \begin{enumerate}[i.]+ \begin{enumerate}+ \def\labelenumii{\roman{enumii}.} \setcounter{enumii}{3}+ \itemsep1pt\parskip0pt\parsep0pt \item sublist with roman numerals, starting with 4 \item more items - \begin{enumerate}[(A)]+ \begin{enumerate}+ \def\labelenumiii{(\Alph{enumiii})}+ \itemsep1pt\parskip0pt\parsep0pt \item a subsublist \item@@ -406,21 +426,29 @@ Nesting: -\begin{enumerate}[A.]+\begin{enumerate}+\def\labelenumi{\Alph{enumi}.}+\itemsep1pt\parskip0pt\parsep0pt \item Upper Alpha - \begin{enumerate}[I.]+ \begin{enumerate}+ \def\labelenumii{\Roman{enumii}.}+ \itemsep1pt\parskip0pt\parsep0pt \item Upper Roman. - \begin{enumerate}[(1)]+ \begin{enumerate}+ \def\labelenumiii{(\arabic{enumiii})} \setcounter{enumiii}{5}+ \itemsep1pt\parskip0pt\parsep0pt \item Decimal start with 6 - \begin{enumerate}[a)]+ \begin{enumerate}+ \def\labelenumiv{\alph{enumiv})} \setcounter{enumiv}{2}+ \itemsep1pt\parskip0pt\parsep0pt \item Lower alpha with paren \end{enumerate}@@ -431,12 +459,14 @@ Autonumbering: \begin{enumerate}+\itemsep1pt\parskip0pt\parsep0pt \item Autonumber. \item More. \begin{enumerate}+ \itemsep1pt\parskip0pt\parsep0pt \item Nested. \end{enumerate}@@ -455,6 +485,7 @@ Tight using spaces: \begin{description}+\itemsep1pt\parskip0pt\parsep0pt \item[apple] red fruit \item[orange]@@ -466,6 +497,7 @@ Tight using tabs: \begin{description}+\itemsep1pt\parskip0pt\parsep0pt \item[apple] red fruit \item[orange]@@ -507,6 +539,7 @@ Multiple definitions, tight: \begin{description}+\itemsep1pt\parskip0pt\parsep0pt \item[apple] red fruit @@ -540,7 +573,9 @@ \item[orange] orange fruit -\begin{enumerate}[1.]+\begin{enumerate}+\def\labelenumi{\arabic{enumi}.}+\itemsep1pt\parskip0pt\parsep0pt \item sublist \item@@ -666,6 +701,7 @@ \section{LaTeX} \begin{itemize}+\itemsep1pt\parskip0pt\parsep0pt \item \cite[22-23]{smith.1899} \item@@ -688,6 +724,7 @@ These shouldn't be math: \begin{itemize}+\itemsep1pt\parskip0pt\parsep0pt \item To get the famous equation, write \texttt{\$e = mc\^{}2\$}. \item@@ -714,6 +751,7 @@ Here is some unicode: \begin{itemize}+\itemsep1pt\parskip0pt\parsep0pt \item I hat: Î \item@@ -786,7 +824,7 @@ \href{/url/}{URL and title} -\href{/url/with\_underscore}{with\_underscore}+\href{/url/with_underscore}{with\_underscore} \href{mailto:nobody@nowhere.net}{Email link} @@ -834,9 +872,10 @@ \subsection{Autolinks} -With an ampersand: \url{http://example.com/?foo=1&bar=2}+With an ampersand: \url{http://example.com/?foo=1\&bar=2} \begin{itemize}+\itemsep1pt\parskip0pt\parsep0pt \item In a list? \item@@ -845,8 +884,7 @@ It should. \end{itemize} -An e-mail address:-\href{mailto:nobody@nowhere.net}{\texttt{nobody@nowhere.net}}+An e-mail address: \href{mailto:nobody@nowhere.net}{nobody@nowhere.net} \begin{quote} Blockquoted: \url{http://example.com/}@@ -900,7 +938,9 @@ Notes can go in quotes.\footnote{In quote.} \end{quote} -\begin{enumerate}[1.]+\begin{enumerate}+\def\labelenumi{\arabic{enumi}.}+\itemsep1pt\parskip0pt\parsep0pt \item And in list items.\footnote{In list.} \end{enumerate}
@@ -26,7 +26,7 @@ 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+Because a hard\-wrapped line in the middle of a paragraph looked like a list item. .PP Here's one with a bullet.@@ -41,7 +41,7 @@ * * * * * .SH Block Quotes .PP-E-mail style:+E\-mail style: .RS .PP This is a block quote.@@ -87,7 +87,7 @@ .IP .nf \f[C]-----\ (should\ be\ four\ hyphens)+\-\-\-\-\ (should\ be\ four\ hyphens) sub\ status\ { \ \ \ \ print\ "working";@@ -489,7 +489,7 @@ .IP .nf \f[C]-<!--\ Comment\ -->+<!\-\-\ Comment\ \-\-> \f[] .fi .PP@@ -568,11 +568,11 @@ .IP \[bu] 2 223 .IP \[bu] 2-\f[I]p\f[]-Tree+\f[I]p\f[]\-Tree .IP \[bu] 2 Here's some display math: .RS-$\\frac{d}{dx}f(x)=\\lim_{h\\to 0}\\frac{f(x+h)-f(x)}{h}$+$\\frac{d}{dx}f(x)=\\lim_{h\\to 0}\\frac{f(x+h)\-f(x)}{h}$ .RE .IP \[bu] 2 Here's one that has a line break in it:@@ -637,7 +637,7 @@ .PP Right paren: ) .PP-Greater-than: >+Greater\-than: > .PP Hash: # .PP@@ -647,7 +647,7 @@ .PP Plus: + .PP-Minus: -+Minus: \- .PP * * * * * .SH Links@@ -718,13 +718,13 @@ .IP \[bu] 2 It should. .PP-An e-mail address: <nobody@nowhere.net>+An e\-mail address: <nobody@nowhere.net> .RS .PP Blockquoted: <http://example.com/> .RE .PP-Auto-links should not occur here: \f[C]<http://example.com/>\f[]+Auto\-links should not occur here: \f[C]<http://example.com/>\f[] .IP .nf \f[C]
@@ -36,8 +36,7 @@ Here’s one with a bullet. * criminey. -There should be a hard line break<br />-here.+There should be a hard line break<br />here. -----@@ -433,7 +432,7 @@ So is '''''this''''' word. -This is code: <tt>></tt>, <tt>$</tt>, <tt>\</tt>, <tt>\$</tt>, <tt><html></tt>.+This is code: <code>></code>, <code>$</code>, <code>\</code>, <code>\$</code>, <code><html></code>. <s>This is ''strikeout''.</s> @@ -456,7 +455,7 @@ ‘He said, “I want to go.”’ Were you alive in the 70’s? -Here is some quoted ‘<tt>code</tt>’ and a “[http://example.com/?foo=1&bar=2 quoted link]”.+Here is some quoted ‘<code>code</code>’ and a “[http://example.com/?foo=1&bar=2 quoted link]”. Some dashes: one—two — three—four — five. @@ -480,10 +479,10 @@ These shouldn’t be math: -* To get the famous equation, write <tt>$e = mc^2$</tt>.+* To get the famous equation, write <code>$e = mc^2$</code>. * $22,000 is a ''lot'' of money. So is $34,000. (It worked if “lot” is emphasized.) * Shoes ($20) and socks ($5).-* Escaped <tt>$</tt>: $73 ''this should be emphasized'' 23$.+* Escaped <code>$</code>: $73 ''this should be emphasized'' 23$. Here’s a LaTeX table: @@ -611,11 +610,11 @@ * http://example.com/ * It should. -An e-mail address: [mailto:nobody@nowhere.net <tt>nobody@nowhere.net</tt>]+An e-mail address: [mailto:nobody@nowhere.net nobody@nowhere.net] <blockquote>Blockquoted: http://example.com/ </blockquote>-Auto-links should not occur here: <tt><http://example.com/></tt>+Auto-links should not occur here: <code><http://example.com/></code> <pre>or here: <http://example.com/></pre> @@ -641,7 +640,7 @@ <pre> { <code> }</pre> If you want, you can indent every line, but you can also be lazy and just indent the first line of each block.-</ref> This should ''not'' be a footnote reference, because it contains a space.[^my note] Here is an inline note.<ref>This is ''easier'' to type. Inline notes may contain [http://google.com links] and <tt>]</tt> verbatim characters, as well as [bracketed text].+</ref> This should ''not'' be a footnote reference, because it contains a space.[^my note] Here is an inline note.<ref>This is ''easier'' to type. Inline notes may contain [http://google.com links] and <code>]</code> verbatim characters, as well as [bracketed text]. </ref> <blockquote>Notes can go in quotes.<ref>In quote.
@@ -1,172 +1,172 @@-Pandoc (Meta {docTitle = [Str "Pandoc",Space,Str "Test",Space,Str "Suite"], docAuthors = [[Str "John",Space,Str "MacFarlane"],[Str "Anonymous"]], docDate = [Str "July",Space,Str "17",Str ",",Space,Str "2006"]})-[Para [Str "This",Space,Str "is",Space,Str "a",Space,Str "set",Space,Str "of",Space,Str "tests",Space,Str "for",Space,Str "pandoc",Str ".",Space,Str "Most",Space,Str "of",Space,Str "them",Space,Str "are",Space,Str "adapted",Space,Str "from",Space,Str "John",Space,Str "Gruber\8217s",Space,Str "markdown",Space,Str "test",Space,Str "suite",Str "."]+Pandoc (Meta {docTitle = [Str "Pandoc",Space,Str "Test",Space,Str "Suite"], docAuthors = [[Str "John",Space,Str "MacFarlane"],[Str "Anonymous"]], docDate = [Str "July",Space,Str "17,",Space,Str "2006"]})+[Para [Str "This",Space,Str "is",Space,Str "a",Space,Str "set",Space,Str "of",Space,Str "tests",Space,Str "for",Space,Str "pandoc.",Space,Str "Most",Space,Str "of",Space,Str "them",Space,Str "are",Space,Str "adapted",Space,Str "from",Space,Str "John",Space,Str "Gruber\8217s",Space,Str "markdown",Space,Str "test",Space,Str "suite."] ,HorizontalRule-,Header 1 [Str "Headers"]-,Header 2 [Str "Level",Space,Str "2",Space,Str "with",Space,Str "an",Space,Link [Str "embedded",Space,Str "link"] ("/url","")]-,Header 3 [Str "Level",Space,Str "3",Space,Str "with",Space,Emph [Str "emphasis"]]-,Header 4 [Str "Level",Space,Str "4"]-,Header 5 [Str "Level",Space,Str "5"]-,Header 1 [Str "Level",Space,Str "1"]-,Header 2 [Str "Level",Space,Str "2",Space,Str "with",Space,Emph [Str "emphasis"]]-,Header 3 [Str "Level",Space,Str "3"]+,Header 1 ("headers",[],[]) [Str "Headers"]+,Header 2 ("level-2-with-an-embedded-link",[],[]) [Str "Level",Space,Str "2",Space,Str "with",Space,Str "an",Space,Link [Str "embedded",Space,Str "link"] ("/url","")]+,Header 3 ("level-3-with-emphasis",[],[]) [Str "Level",Space,Str "3",Space,Str "with",Space,Emph [Str "emphasis"]]+,Header 4 ("level-4",[],[]) [Str "Level",Space,Str "4"]+,Header 5 ("level-5",[],[]) [Str "Level",Space,Str "5"]+,Header 1 ("level-1",[],[]) [Str "Level",Space,Str "1"]+,Header 2 ("level-2-with-emphasis",[],[]) [Str "Level",Space,Str "2",Space,Str "with",Space,Emph [Str "emphasis"]]+,Header 3 ("level-3",[],[]) [Str "Level",Space,Str "3"] ,Para [Str "with",Space,Str "no",Space,Str "blank",Space,Str "line"]-,Header 2 [Str "Level",Space,Str "2"]+,Header 2 ("level-2",[],[]) [Str "Level",Space,Str "2"] ,Para [Str "with",Space,Str "no",Space,Str "blank",Space,Str "line"] ,HorizontalRule-,Header 1 [Str "Paragraphs"]-,Para [Str "Here\8217s",Space,Str "a",Space,Str "regular",Space,Str "paragraph",Str "."]-,Para [Str "In",Space,Str "Markdown",Space,Str "1",Str ".",Str "0",Str ".",Str "0",Space,Str "and",Space,Str "earlier",Str ".",Space,Str "Version",Space,Str "8",Str ".",Space,Str "This",Space,Str "line",Space,Str "turns",Space,Str "into",Space,Str "a",Space,Str "list",Space,Str "item",Str ".",Space,Str "Because",Space,Str "a",Space,Str "hard",Str "-",Str "wrapped",Space,Str "line",Space,Str "in",Space,Str "the",Space,Str "middle",Space,Str "of",Space,Str "a",Space,Str "paragraph",Space,Str "looked",Space,Str "like",Space,Str "a",Space,Str "list",Space,Str "item",Str "."]-,Para [Str "Here\8217s",Space,Str "one",Space,Str "with",Space,Str "a",Space,Str "bullet",Str ".",Space,Str "*",Space,Str "criminey",Str "."]-,Para [Str "There",Space,Str "should",Space,Str "be",Space,Str "a",Space,Str "hard",Space,Str "line",Space,Str "break",LineBreak,Str "here",Str "."]+,Header 1 ("paragraphs",[],[]) [Str "Paragraphs"]+,Para [Str "Here\8217s",Space,Str "a",Space,Str "regular",Space,Str "paragraph."]+,Para [Str "In",Space,Str "Markdown",Space,Str "1.0.0",Space,Str "and",Space,Str "earlier.",Space,Str "Version",Space,Str "8.",Space,Str "This",Space,Str "line",Space,Str "turns",Space,Str "into",Space,Str "a",Space,Str "list",Space,Str "item.",Space,Str "Because",Space,Str "a",Space,Str "hard-wrapped",Space,Str "line",Space,Str "in",Space,Str "the",Space,Str "middle",Space,Str "of",Space,Str "a",Space,Str "paragraph",Space,Str "looked",Space,Str "like",Space,Str "a",Space,Str "list",Space,Str "item."]+,Para [Str "Here\8217s",Space,Str "one",Space,Str "with",Space,Str "a",Space,Str "bullet.",Space,Str "*",Space,Str "criminey."]+,Para [Str "There",Space,Str "should",Space,Str "be",Space,Str "a",Space,Str "hard",Space,Str "line",Space,Str "break",LineBreak,Str "here."] ,HorizontalRule-,Header 1 [Str "Block",Space,Str "Quotes"]-,Para [Str "E",Str "-",Str "mail",Space,Str "style",Str ":"]+,Header 1 ("block-quotes",[],[]) [Str "Block",Space,Str "Quotes"]+,Para [Str "E-mail",Space,Str "style:"] ,BlockQuote- [Para [Str "This",Space,Str "is",Space,Str "a",Space,Str "block",Space,Str "quote",Str ".",Space,Str "It",Space,Str "is",Space,Str "pretty",Space,Str "short",Str "."]]+ [Para [Str "This",Space,Str "is",Space,Str "a",Space,Str "block",Space,Str "quote.",Space,Str "It",Space,Str "is",Space,Str "pretty",Space,Str "short."]] ,BlockQuote- [Para [Str "Code",Space,Str "in",Space,Str "a",Space,Str "block",Space,Str "quote",Str ":"]+ [Para [Str "Code",Space,Str "in",Space,Str "a",Space,Str "block",Space,Str "quote:"] ,CodeBlock ("",[],[]) "sub status {\n print \"working\";\n}"- ,Para [Str "A",Space,Str "list",Str ":"]+ ,Para [Str "A",Space,Str "list:"] ,OrderedList (1,Decimal,Period) [[Plain [Str "item",Space,Str "one"]] ,[Plain [Str "item",Space,Str "two"]]]- ,Para [Str "Nested",Space,Str "block",Space,Str "quotes",Str ":"]+ ,Para [Str "Nested",Space,Str "block",Space,Str "quotes:"] ,BlockQuote [Para [Str "nested"]] ,BlockQuote [Para [Str "nested"]]]-,Para [Str "This",Space,Str "should",Space,Str "not",Space,Str "be",Space,Str "a",Space,Str "block",Space,Str "quote",Str ":",Space,Str "2",Space,Str ">",Space,Str "1",Str "."]-,Para [Str "And",Space,Str "a",Space,Str "following",Space,Str "paragraph",Str "."]+,Para [Str "This",Space,Str "should",Space,Str "not",Space,Str "be",Space,Str "a",Space,Str "block",Space,Str "quote:",Space,Str "2",Space,Str ">",Space,Str "1."]+,Para [Str "And",Space,Str "a",Space,Str "following",Space,Str "paragraph."] ,HorizontalRule-,Header 1 [Str "Code",Space,Str "Blocks"]-,Para [Str "Code",Str ":"]+,Header 1 ("code-blocks",[],[]) [Str "Code",Space,Str "Blocks"]+,Para [Str "Code:"] ,CodeBlock ("",[],[]) "---- (should be four hyphens)\n\nsub status {\n print \"working\";\n}\n\nthis code block is indented by one tab"-,Para [Str "And",Str ":"]+,Para [Str "And:"] ,CodeBlock ("",[],[]) " this code block is indented by two tabs\n\nThese should not be escaped: \\$ \\\\ \\> \\[ \\{" ,HorizontalRule-,Header 1 [Str "Lists"]-,Header 2 [Str "Unordered"]-,Para [Str "Asterisks",Space,Str "tight",Str ":"]+,Header 1 ("lists",[],[]) [Str "Lists"]+,Header 2 ("unordered",[],[]) [Str "Unordered"]+,Para [Str "Asterisks",Space,Str "tight:"] ,BulletList [[Plain [Str "asterisk",Space,Str "1"]] ,[Plain [Str "asterisk",Space,Str "2"]] ,[Plain [Str "asterisk",Space,Str "3"]]]-,Para [Str "Asterisks",Space,Str "loose",Str ":"]+,Para [Str "Asterisks",Space,Str "loose:"] ,BulletList [[Para [Str "asterisk",Space,Str "1"]] ,[Para [Str "asterisk",Space,Str "2"]] ,[Para [Str "asterisk",Space,Str "3"]]]-,Para [Str "Pluses",Space,Str "tight",Str ":"]+,Para [Str "Pluses",Space,Str "tight:"] ,BulletList [[Plain [Str "Plus",Space,Str "1"]] ,[Plain [Str "Plus",Space,Str "2"]] ,[Plain [Str "Plus",Space,Str "3"]]]-,Para [Str "Pluses",Space,Str "loose",Str ":"]+,Para [Str "Pluses",Space,Str "loose:"] ,BulletList [[Para [Str "Plus",Space,Str "1"]] ,[Para [Str "Plus",Space,Str "2"]] ,[Para [Str "Plus",Space,Str "3"]]]-,Para [Str "Minuses",Space,Str "tight",Str ":"]+,Para [Str "Minuses",Space,Str "tight:"] ,BulletList [[Plain [Str "Minus",Space,Str "1"]] ,[Plain [Str "Minus",Space,Str "2"]] ,[Plain [Str "Minus",Space,Str "3"]]]-,Para [Str "Minuses",Space,Str "loose",Str ":"]+,Para [Str "Minuses",Space,Str "loose:"] ,BulletList [[Para [Str "Minus",Space,Str "1"]] ,[Para [Str "Minus",Space,Str "2"]] ,[Para [Str "Minus",Space,Str "3"]]]-,Header 2 [Str "Ordered"]-,Para [Str "Tight",Str ":"]+,Header 2 ("ordered",[],[]) [Str "Ordered"]+,Para [Str "Tight:"] ,OrderedList (1,Decimal,Period) [[Plain [Str "First"]] ,[Plain [Str "Second"]] ,[Plain [Str "Third"]]]-,Para [Str "and",Str ":"]+,Para [Str "and:"] ,OrderedList (1,Decimal,Period) [[Plain [Str "One"]] ,[Plain [Str "Two"]] ,[Plain [Str "Three"]]]-,Para [Str "Loose",Space,Str "using",Space,Str "tabs",Str ":"]+,Para [Str "Loose",Space,Str "using",Space,Str "tabs:"] ,OrderedList (1,Decimal,Period) [[Para [Str "First"]] ,[Para [Str "Second"]] ,[Para [Str "Third"]]]-,Para [Str "and",Space,Str "using",Space,Str "spaces",Str ":"]+,Para [Str "and",Space,Str "using",Space,Str "spaces:"] ,OrderedList (1,Decimal,Period) [[Para [Str "One"]] ,[Para [Str "Two"]] ,[Para [Str "Three"]]]-,Para [Str "Multiple",Space,Str "paragraphs",Str ":"]+,Para [Str "Multiple",Space,Str "paragraphs:"] ,OrderedList (1,Decimal,Period)- [[Para [Str "Item",Space,Str "1",Str ",",Space,Str "graf",Space,Str "one",Str "."]- ,Para [Str "Item",Space,Str "1",Str ".",Space,Str "graf",Space,Str "two",Str ".",Space,Str "The",Space,Str "quick",Space,Str "brown",Space,Str "fox",Space,Str "jumped",Space,Str "over",Space,Str "the",Space,Str "lazy",Space,Str "dog\8217s",Space,Str "back",Str "."]]- ,[Para [Str "Item",Space,Str "2",Str "."]]- ,[Para [Str "Item",Space,Str "3",Str "."]]]-,Header 2 [Str "Nested"]+ [[Para [Str "Item",Space,Str "1,",Space,Str "graf",Space,Str "one."]+ ,Para [Str "Item",Space,Str "1.",Space,Str "graf",Space,Str "two.",Space,Str "The",Space,Str "quick",Space,Str "brown",Space,Str "fox",Space,Str "jumped",Space,Str "over",Space,Str "the",Space,Str "lazy",Space,Str "dog\8217s",Space,Str "back."]]+ ,[Para [Str "Item",Space,Str "2."]]+ ,[Para [Str "Item",Space,Str "3."]]]+,Header 2 ("nested",[],[]) [Str "Nested"] ,BulletList [[Plain [Str "Tab"] ,BulletList [[Plain [Str "Tab"] ,BulletList [[Plain [Str "Tab"]]]]]]]-,Para [Str "Here\8217s",Space,Str "another",Str ":"]+,Para [Str "Here\8217s",Space,Str "another:"] ,OrderedList (1,Decimal,Period) [[Plain [Str "First"]]- ,[Plain [Str "Second",Str ":"]+ ,[Plain [Str "Second:"] ,BulletList [[Plain [Str "Fee"]] ,[Plain [Str "Fie"]] ,[Plain [Str "Foe"]]]] ,[Plain [Str "Third"]]]-,Para [Str "Same",Space,Str "thing",Space,Str "but",Space,Str "with",Space,Str "paragraphs",Str ":"]+,Para [Str "Same",Space,Str "thing",Space,Str "but",Space,Str "with",Space,Str "paragraphs:"] ,OrderedList (1,Decimal,Period) [[Para [Str "First"]]- ,[Para [Str "Second",Str ":"]+ ,[Para [Str "Second:"] ,BulletList [[Plain [Str "Fee"]] ,[Plain [Str "Fie"]] ,[Plain [Str "Foe"]]]] ,[Para [Str "Third"]]]-,Header 2 [Str "Tabs",Space,Str "and",Space,Str "spaces"]+,Header 2 ("tabs-and-spaces",[],[]) [Str "Tabs",Space,Str "and",Space,Str "spaces"] ,BulletList [[Para [Str "this",Space,Str "is",Space,Str "a",Space,Str "list",Space,Str "item",Space,Str "indented",Space,Str "with",Space,Str "tabs"]] ,[Para [Str "this",Space,Str "is",Space,Str "a",Space,Str "list",Space,Str "item",Space,Str "indented",Space,Str "with",Space,Str "spaces"] ,BulletList [[Para [Str "this",Space,Str "is",Space,Str "an",Space,Str "example",Space,Str "list",Space,Str "item",Space,Str "indented",Space,Str "with",Space,Str "tabs"]] ,[Para [Str "this",Space,Str "is",Space,Str "an",Space,Str "example",Space,Str "list",Space,Str "item",Space,Str "indented",Space,Str "with",Space,Str "spaces"]]]]]-,Header 2 [Str "Fancy",Space,Str "list",Space,Str "markers"]+,Header 2 ("fancy-list-markers",[],[]) [Str "Fancy",Space,Str "list",Space,Str "markers"] ,OrderedList (2,Decimal,TwoParens) [[Plain [Str "begins",Space,Str "with",Space,Str "2"]] ,[Para [Str "and",Space,Str "now",Space,Str "3"] ,Para [Str "with",Space,Str "a",Space,Str "continuation"] ,OrderedList (4,LowerRoman,Period)- [[Plain [Str "sublist",Space,Str "with",Space,Str "roman",Space,Str "numerals",Str ",",Space,Str "starting",Space,Str "with",Space,Str "4"]]+ [[Plain [Str "sublist",Space,Str "with",Space,Str "roman",Space,Str "numerals,",Space,Str "starting",Space,Str "with",Space,Str "4"]] ,[Plain [Str "more",Space,Str "items"] ,OrderedList (1,UpperAlpha,TwoParens) [[Plain [Str "a",Space,Str "subsublist"]] ,[Plain [Str "a",Space,Str "subsublist"]]]]]]]-,Para [Str "Nesting",Str ":"]+,Para [Str "Nesting:"] ,OrderedList (1,UpperAlpha,Period) [[Plain [Str "Upper",Space,Str "Alpha"] ,OrderedList (1,UpperRoman,Period)- [[Plain [Str "Upper",Space,Str "Roman",Str "."]+ [[Plain [Str "Upper",Space,Str "Roman."] ,OrderedList (6,Decimal,TwoParens) [[Plain [Str "Decimal",Space,Str "start",Space,Str "with",Space,Str "6"] ,OrderedList (3,LowerAlpha,OneParen) [[Plain [Str "Lower",Space,Str "alpha",Space,Str "with",Space,Str "paren"]]]]]]]]]-,Para [Str "Autonumbering",Str ":"]+,Para [Str "Autonumbering:"] ,OrderedList (1,DefaultStyle,DefaultDelim)- [[Plain [Str "Autonumber",Str "."]]- ,[Plain [Str "More",Str "."]+ [[Plain [Str "Autonumber."]]+ ,[Plain [Str "More."] ,OrderedList (1,DefaultStyle,DefaultDelim)- [[Plain [Str "Nested",Str "."]]]]]-,Para [Str "Should",Space,Str "not",Space,Str "be",Space,Str "a",Space,Str "list",Space,Str "item",Str ":"]-,Para [Str "M.A.\160",Str "2007"]-,Para [Str "B",Str ".",Space,Str "Williams"]+ [[Plain [Str "Nested."]]]]]+,Para [Str "Should",Space,Str "not",Space,Str "be",Space,Str "a",Space,Str "list",Space,Str "item:"]+,Para [Str "M.A.\160\&2007"]+,Para [Str "B.",Space,Str "Williams"] ,HorizontalRule-,Header 1 [Str "Definition",Space,Str "Lists"]-,Para [Str "Tight",Space,Str "using",Space,Str "spaces",Str ":"]+,Header 1 ("definition-lists",[],[]) [Str "Definition",Space,Str "Lists"]+,Para [Str "Tight",Space,Str "using",Space,Str "spaces:"] ,DefinitionList [([Str "apple"], [[Plain [Str "red",Space,Str "fruit"]]])@@ -174,7 +174,7 @@ [[Plain [Str "orange",Space,Str "fruit"]]]) ,([Str "banana"], [[Plain [Str "yellow",Space,Str "fruit"]]])]-,Para [Str "Tight",Space,Str "using",Space,Str "tabs",Str ":"]+,Para [Str "Tight",Space,Str "using",Space,Str "tabs:"] ,DefinitionList [([Str "apple"], [[Plain [Str "red",Space,Str "fruit"]]])@@ -182,7 +182,7 @@ [[Plain [Str "orange",Space,Str "fruit"]]]) ,([Str "banana"], [[Plain [Str "yellow",Space,Str "fruit"]]])]-,Para [Str "Loose",Str ":"]+,Para [Str "Loose:"] ,DefinitionList [([Str "apple"], [[Para [Str "red",Space,Str "fruit"]]])@@ -190,17 +190,17 @@ [[Para [Str "orange",Space,Str "fruit"]]]) ,([Str "banana"], [[Para [Str "yellow",Space,Str "fruit"]]])]-,Para [Str "Multiple",Space,Str "blocks",Space,Str "with",Space,Str "italics",Str ":"]+,Para [Str "Multiple",Space,Str "blocks",Space,Str "with",Space,Str "italics:"] ,DefinitionList [([Emph [Str "apple"]], [[Para [Str "red",Space,Str "fruit"]- ,Para [Str "contains",Space,Str "seeds",Str ",",Space,Str "crisp",Str ",",Space,Str "pleasant",Space,Str "to",Space,Str "taste"]]])+ ,Para [Str "contains",Space,Str "seeds,",Space,Str "crisp,",Space,Str "pleasant",Space,Str "to",Space,Str "taste"]]]) ,([Emph [Str "orange"]], [[Para [Str "orange",Space,Str "fruit"] ,CodeBlock ("",[],[]) "{ orange code block }" ,BlockQuote [Para [Str "orange",Space,Str "block",Space,Str "quote"]]]])]-,Para [Str "Multiple",Space,Str "definitions",Str ",",Space,Str "tight",Str ":"]+,Para [Str "Multiple",Space,Str "definitions,",Space,Str "tight:"] ,DefinitionList [([Str "apple"], [[Plain [Str "red",Space,Str "fruit"]]@@ -208,7 +208,7 @@ ,([Str "orange"], [[Plain [Str "orange",Space,Str "fruit"]] ,[Plain [Str "bank"]]])]-,Para [Str "Multiple",Space,Str "definitions",Str ",",Space,Str "loose",Str ":"]+,Para [Str "Multiple",Space,Str "definitions,",Space,Str "loose:"] ,DefinitionList [([Str "apple"], [[Para [Str "red",Space,Str "fruit"]]@@ -216,7 +216,7 @@ ,([Str "orange"], [[Para [Str "orange",Space,Str "fruit"]] ,[Para [Str "bank"]]])]-,Para [Str "Blank",Space,Str "line",Space,Str "after",Space,Str "term",Str ",",Space,Str "indented",Space,Str "marker",Str ",",Space,Str "alternate",Space,Str "markers",Str ":"]+,Para [Str "Blank",Space,Str "line",Space,Str "after",Space,Str "term,",Space,Str "indented",Space,Str "marker,",Space,Str "alternate",Space,Str "markers:"] ,DefinitionList [([Str "apple"], [[Para [Str "red",Space,Str "fruit"]]@@ -226,171 +226,171 @@ ,OrderedList (1,Decimal,Period) [[Plain [Str "sublist"]] ,[Plain [Str "sublist"]]]]])]-,Header 1 [Str "HTML",Space,Str "Blocks"]-,Para [Str "Simple",Space,Str "block",Space,Str "on",Space,Str "one",Space,Str "line",Str ":"]+,Header 1 ("html-blocks",[],[]) [Str "HTML",Space,Str "Blocks"]+,Para [Str "Simple",Space,Str "block",Space,Str "on",Space,Str "one",Space,Str "line:"] ,RawBlock "html" "<div>" ,Plain [Str "foo"] ,RawBlock "html" "</div>\n"-,Para [Str "And",Space,Str "nested",Space,Str "without",Space,Str "indentation",Str ":"]+,Para [Str "And",Space,Str "nested",Space,Str "without",Space,Str "indentation:"] ,RawBlock "html" "<div>\n<div>\n<div>" ,Plain [Str "foo"] ,RawBlock "html" "</div>\n</div>\n<div>" ,Plain [Str "bar"] ,RawBlock "html" "</div>\n</div>\n"-,Para [Str "Interpreted",Space,Str "markdown",Space,Str "in",Space,Str "a",Space,Str "table",Str ":"]+,Para [Str "Interpreted",Space,Str "markdown",Space,Str "in",Space,Str "a",Space,Str "table:"] ,RawBlock "html" "<table>\n<tr>\n<td>" ,Plain [Str "This",Space,Str "is",Space,Emph [Str "emphasized"]] ,RawBlock "html" "</td>\n<td>" ,Plain [Str "And",Space,Str "this",Space,Str "is",Space,Strong [Str "strong"]] ,RawBlock "html" "</td>\n</tr>\n</table>\n\n<script type=\"text/javascript\">document.write('This *should not* be interpreted as markdown');</script>\n"-,Para [Str "Here\8217s",Space,Str "a",Space,Str "simple",Space,Str "block",Str ":"]+,Para [Str "Here\8217s",Space,Str "a",Space,Str "simple",Space,Str "block:"] ,RawBlock "html" "<div>\n " ,Plain [Str "foo"] ,RawBlock "html" "</div>\n"-,Para [Str "This",Space,Str "should",Space,Str "be",Space,Str "a",Space,Str "code",Space,Str "block",Str ",",Space,Str "though",Str ":"]+,Para [Str "This",Space,Str "should",Space,Str "be",Space,Str "a",Space,Str "code",Space,Str "block,",Space,Str "though:"] ,CodeBlock ("",[],[]) "<div>\n foo\n</div>"-,Para [Str "As",Space,Str "should",Space,Str "this",Str ":"]+,Para [Str "As",Space,Str "should",Space,Str "this:"] ,CodeBlock ("",[],[]) "<div>foo</div>"-,Para [Str "Now",Str ",",Space,Str "nested",Str ":"]+,Para [Str "Now,",Space,Str "nested:"] ,RawBlock "html" "<div>\n <div>\n <div>\n " ,Plain [Str "foo"] ,RawBlock "html" "</div>\n </div>\n</div>\n"-,Para [Str "This",Space,Str "should",Space,Str "just",Space,Str "be",Space,Str "an",Space,Str "HTML",Space,Str "comment",Str ":"]+,Para [Str "This",Space,Str "should",Space,Str "just",Space,Str "be",Space,Str "an",Space,Str "HTML",Space,Str "comment:"] ,RawBlock "html" "<!-- Comment -->\n"-,Para [Str "Multiline",Str ":"]+,Para [Str "Multiline:"] ,RawBlock "html" "<!--\nBlah\nBlah\n-->\n\n<!--\n This is another comment.\n-->\n"-,Para [Str "Code",Space,Str "block",Str ":"]+,Para [Str "Code",Space,Str "block:"] ,CodeBlock ("",[],[]) "<!-- Comment -->"-,Para [Str "Just",Space,Str "plain",Space,Str "comment",Str ",",Space,Str "with",Space,Str "trailing",Space,Str "spaces",Space,Str "on",Space,Str "the",Space,Str "line",Str ":"]+,Para [Str "Just",Space,Str "plain",Space,Str "comment,",Space,Str "with",Space,Str "trailing",Space,Str "spaces",Space,Str "on",Space,Str "the",Space,Str "line:"] ,RawBlock "html" "<!-- foo --> \n"-,Para [Str "Code",Str ":"]+,Para [Str "Code:"] ,CodeBlock ("",[],[]) "<hr />"-,Para [Str "Hr\8217s",Str ":"]+,Para [Str "Hr\8217s:"] ,RawBlock "html" "<hr>\n\n<hr />\n\n<hr />\n\n<hr> \n\n<hr /> \n\n<hr /> \n\n<hr class=\"foo\" id=\"bar\" />\n\n<hr class=\"foo\" id=\"bar\" />\n\n<hr class=\"foo\" id=\"bar\">\n" ,HorizontalRule-,Header 1 [Str "Inline",Space,Str "Markup"]+,Header 1 ("inline-markup",[],[]) [Str "Inline",Space,Str "Markup"] ,Para [Str "This",Space,Str "is",Space,Emph [Str "emphasized"],Str ",",Space,Str "and",Space,Str "so",Space,Emph [Str "is",Space,Str "this"],Str "."] ,Para [Str "This",Space,Str "is",Space,Strong [Str "strong"],Str ",",Space,Str "and",Space,Str "so",Space,Strong [Str "is",Space,Str "this"],Str "."] ,Para [Str "An",Space,Emph [Link [Str "emphasized",Space,Str "link"] ("/url","")],Str "."]-,Para [Strong [Emph [Str "This",Space,Str "is",Space,Str "strong",Space,Str "and",Space,Str "em",Str "."]]]-,Para [Str "So",Space,Str "is",Space,Strong [Emph [Str "this"]],Space,Str "word",Str "."]-,Para [Strong [Emph [Str "This",Space,Str "is",Space,Str "strong",Space,Str "and",Space,Str "em",Str "."]]]-,Para [Str "So",Space,Str "is",Space,Strong [Emph [Str "this"]],Space,Str "word",Str "."]-,Para [Str "This",Space,Str "is",Space,Str "code",Str ":",Space,Code ("",[],[]) ">",Str ",",Space,Code ("",[],[]) "$",Str ",",Space,Code ("",[],[]) "\\",Str ",",Space,Code ("",[],[]) "\\$",Str ",",Space,Code ("",[],[]) "<html>",Str "."]+,Para [Strong [Emph [Str "This",Space,Str "is",Space,Str "strong",Space,Str "and",Space,Str "em."]]]+,Para [Str "So",Space,Str "is",Space,Strong [Emph [Str "this"]],Space,Str "word."]+,Para [Strong [Emph [Str "This",Space,Str "is",Space,Str "strong",Space,Str "and",Space,Str "em."]]]+,Para [Str "So",Space,Str "is",Space,Strong [Emph [Str "this"]],Space,Str "word."]+,Para [Str "This",Space,Str "is",Space,Str "code:",Space,Code ("",[],[]) ">",Str ",",Space,Code ("",[],[]) "$",Str ",",Space,Code ("",[],[]) "\\",Str ",",Space,Code ("",[],[]) "\\$",Str ",",Space,Code ("",[],[]) "<html>",Str "."] ,Para [Strikeout [Str "This",Space,Str "is",Space,Emph [Str "strikeout"],Str "."]]-,Para [Str "Superscripts",Str ":",Space,Str "a",Superscript [Str "bc"],Str "d",Space,Str "a",Superscript [Emph [Str "hello"]],Space,Str "a",Superscript [Str "hello",Str "\160",Str "there"],Str "."]-,Para [Str "Subscripts",Str ":",Space,Str "H",Subscript [Str "2"],Str "O",Str ",",Space,Str "H",Subscript [Str "23"],Str "O",Str ",",Space,Str "H",Subscript [Str "many",Str "\160",Str "of",Str "\160",Str "them"],Str "O",Str "."]-,Para [Str "These",Space,Str "should",Space,Str "not",Space,Str "be",Space,Str "superscripts",Space,Str "or",Space,Str "subscripts",Str ",",Space,Str "because",Space,Str "of",Space,Str "the",Space,Str "unescaped",Space,Str "spaces",Str ":",Space,Str "a",Str "^",Str "b",Space,Str "c",Str "^",Str "d",Str ",",Space,Str "a",Str "~",Str "b",Space,Str "c",Str "~",Str "d",Str "."]+,Para [Str "Superscripts:",Space,Str "a",Superscript [Str "bc"],Str "d",Space,Str "a",Superscript [Emph [Str "hello"]],Space,Str "a",Superscript [Str "hello\160there"],Str "."]+,Para [Str "Subscripts:",Space,Str "H",Subscript [Str "2"],Str "O,",Space,Str "H",Subscript [Str "23"],Str "O,",Space,Str "H",Subscript [Str "many\160of\160them"],Str "O."]+,Para [Str "These",Space,Str "should",Space,Str "not",Space,Str "be",Space,Str "superscripts",Space,Str "or",Space,Str "subscripts,",Space,Str "because",Space,Str "of",Space,Str "the",Space,Str "unescaped",Space,Str "spaces:",Space,Str "a^b",Space,Str "c^d,",Space,Str "a~b",Space,Str "c~d."] ,HorizontalRule-,Header 1 [Str "Smart",Space,Str "quotes",Str ",",Space,Str "ellipses",Str ",",Space,Str "dashes"]-,Para [Quoted DoubleQuote [Str "Hello",Str ","],Space,Str "said",Space,Str "the",Space,Str "spider",Str ".",Space,Quoted DoubleQuote [Quoted SingleQuote [Str "Shelob"],Space,Str "is",Space,Str "my",Space,Str "name",Str "."]]-,Para [Quoted SingleQuote [Str "A"],Str ",",Space,Quoted SingleQuote [Str "B"],Str ",",Space,Str "and",Space,Quoted SingleQuote [Str "C"],Space,Str "are",Space,Str "letters",Str "."]-,Para [Quoted SingleQuote [Str "Oak",Str ","],Space,Quoted SingleQuote [Str "elm",Str ","],Space,Str "and",Space,Quoted SingleQuote [Str "beech"],Space,Str "are",Space,Str "names",Space,Str "of",Space,Str "trees",Str ".",Space,Str "So",Space,Str "is",Space,Quoted SingleQuote [Str "pine",Str "."]]-,Para [Quoted SingleQuote [Str "He",Space,Str "said",Str ",",Space,Quoted DoubleQuote [Str "I",Space,Str "want",Space,Str "to",Space,Str "go",Str "."]],Space,Str "Were",Space,Str "you",Space,Str "alive",Space,Str "in",Space,Str "the",Space,Str "70\8217s",Str "?"]+,Header 1 ("smart-quotes-ellipses-dashes",[],[]) [Str "Smart",Space,Str "quotes,",Space,Str "ellipses,",Space,Str "dashes"]+,Para [Quoted DoubleQuote [Str "Hello,"],Space,Str "said",Space,Str "the",Space,Str "spider.",Space,Quoted DoubleQuote [Quoted SingleQuote [Str "Shelob"],Space,Str "is",Space,Str "my",Space,Str "name."]]+,Para [Quoted SingleQuote [Str "A"],Str ",",Space,Quoted SingleQuote [Str "B"],Str ",",Space,Str "and",Space,Quoted SingleQuote [Str "C"],Space,Str "are",Space,Str "letters."]+,Para [Quoted SingleQuote [Str "Oak,"],Space,Quoted SingleQuote [Str "elm,"],Space,Str "and",Space,Quoted SingleQuote [Str "beech"],Space,Str "are",Space,Str "names",Space,Str "of",Space,Str "trees.",Space,Str "So",Space,Str "is",Space,Quoted SingleQuote [Str "pine."]]+,Para [Quoted SingleQuote [Str "He",Space,Str "said,",Space,Quoted DoubleQuote [Str "I",Space,Str "want",Space,Str "to",Space,Str "go."]],Space,Str "Were",Space,Str "you",Space,Str "alive",Space,Str "in",Space,Str "the",Space,Str "70\8217s?"] ,Para [Str "Here",Space,Str "is",Space,Str "some",Space,Str "quoted",Space,Quoted SingleQuote [Code ("",[],[]) "code"],Space,Str "and",Space,Str "a",Space,Quoted DoubleQuote [Link [Str "quoted",Space,Str "link"] ("http://example.com/?foo=1&bar=2","")],Str "."]-,Para [Str "Some",Space,Str "dashes",Str ":",Space,Str "one",Str "\8212",Str "two",Space,Str "\8212",Space,Str "three",Str "\8212",Str "four",Space,Str "\8212",Space,Str "five",Str "."]-,Para [Str "Dashes",Space,Str "between",Space,Str "numbers",Str ":",Space,Str "5",Str "\8211",Str "7",Str ",",Space,Str "255",Str "\8211",Str "66",Str ",",Space,Str "1987",Str "\8211",Str "1999",Str "."]-,Para [Str "Ellipses",Str "\8230",Str "and",Str "\8230",Str "and",Str "\8230",Str "."]+,Para [Str "Some",Space,Str "dashes:",Space,Str "one\8212two",Space,Str "\8212",Space,Str "three\8212four",Space,Str "\8212",Space,Str "five."]+,Para [Str "Dashes",Space,Str "between",Space,Str "numbers:",Space,Str "5\8211\&7,",Space,Str "255\8211\&66,",Space,Str "1987\8211\&1999."]+,Para [Str "Ellipses\8230and\8230and\8230."] ,HorizontalRule-,Header 1 [Str "LaTeX"]+,Header 1 ("latex",[],[]) [Str "LaTeX"] ,BulletList [[Plain [RawInline "tex" "\\cite[22-23]{smith.1899}"]] ,[Plain [Math InlineMath "2+2=4"]] ,[Plain [Math InlineMath "x \\in y"]] ,[Plain [Math InlineMath "\\alpha \\wedge \\omega"]] ,[Plain [Math InlineMath "223"]]- ,[Plain [Math InlineMath "p",Str "-",Str "Tree"]]- ,[Plain [Str "Here\8217s",Space,Str "some",Space,Str "display",Space,Str "math",Str ":",Space,Math DisplayMath "\\frac{d}{dx}f(x)=\\lim_{h\\to 0}\\frac{f(x+h)-f(x)}{h}"]]- ,[Plain [Str "Here\8217s",Space,Str "one",Space,Str "that",Space,Str "has",Space,Str "a",Space,Str "line",Space,Str "break",Space,Str "in",Space,Str "it",Str ":",Space,Math InlineMath "\\alpha + \\omega \\times x^2",Str "."]]]-,Para [Str "These",Space,Str "shouldn\8217t",Space,Str "be",Space,Str "math",Str ":"]+ ,[Plain [Math InlineMath "p",Str "-Tree"]]+ ,[Plain [Str "Here\8217s",Space,Str "some",Space,Str "display",Space,Str "math:",Space,Math DisplayMath "\\frac{d}{dx}f(x)=\\lim_{h\\to 0}\\frac{f(x+h)-f(x)}{h}"]]+ ,[Plain [Str "Here\8217s",Space,Str "one",Space,Str "that",Space,Str "has",Space,Str "a",Space,Str "line",Space,Str "break",Space,Str "in",Space,Str "it:",Space,Math InlineMath "\\alpha + \\omega \\times x^2",Str "."]]]+,Para [Str "These",Space,Str "shouldn\8217t",Space,Str "be",Space,Str "math:"] ,BulletList- [[Plain [Str "To",Space,Str "get",Space,Str "the",Space,Str "famous",Space,Str "equation",Str ",",Space,Str "write",Space,Code ("",[],[]) "$e = mc^2$",Str "."]]- ,[Plain [Str "$",Str "22",Str ",",Str "000",Space,Str "is",Space,Str "a",Space,Emph [Str "lot"],Space,Str "of",Space,Str "money",Str ".",Space,Str "So",Space,Str "is",Space,Str "$",Str "34",Str ",",Str "000",Str ".",Space,Str "(",Str "It",Space,Str "worked",Space,Str "if",Space,Quoted DoubleQuote [Str "lot"],Space,Str "is",Space,Str "emphasized",Str ".",Str ")"]]- ,[Plain [Str "Shoes",Space,Str "(",Str "$",Str "20",Str ")",Space,Str "and",Space,Str "socks",Space,Str "(",Str "$",Str "5",Str ")",Str "."]]- ,[Plain [Str "Escaped",Space,Code ("",[],[]) "$",Str ":",Space,Str "$",Str "73",Space,Emph [Str "this",Space,Str "should",Space,Str "be",Space,Str "emphasized"],Space,Str "23",Str "$",Str "."]]]-,Para [Str "Here\8217s",Space,Str "a",Space,Str "LaTeX",Space,Str "table",Str ":"]+ [[Plain [Str "To",Space,Str "get",Space,Str "the",Space,Str "famous",Space,Str "equation,",Space,Str "write",Space,Code ("",[],[]) "$e = mc^2$",Str "."]]+ ,[Plain [Str "$22,000",Space,Str "is",Space,Str "a",Space,Emph [Str "lot"],Space,Str "of",Space,Str "money.",Space,Str "So",Space,Str "is",Space,Str "$34,000.",Space,Str "(It",Space,Str "worked",Space,Str "if",Space,Quoted DoubleQuote [Str "lot"],Space,Str "is",Space,Str "emphasized.)"]]+ ,[Plain [Str "Shoes",Space,Str "($20)",Space,Str "and",Space,Str "socks",Space,Str "($5)."]]+ ,[Plain [Str "Escaped",Space,Code ("",[],[]) "$",Str ":",Space,Str "$73",Space,Emph [Str "this",Space,Str "should",Space,Str "be",Space,Str "emphasized"],Space,Str "23$."]]]+,Para [Str "Here\8217s",Space,Str "a",Space,Str "LaTeX",Space,Str "table:"] ,RawBlock "latex" "\\begin{tabular}{|l|l|}\\hline\nAnimal & Number \\\\ \\hline\nDog & 2 \\\\\nCat & 1 \\\\ \\hline\n\\end{tabular}" ,HorizontalRule-,Header 1 [Str "Special",Space,Str "Characters"]-,Para [Str "Here",Space,Str "is",Space,Str "some",Space,Str "unicode",Str ":"]+,Header 1 ("special-characters",[],[]) [Str "Special",Space,Str "Characters"]+,Para [Str "Here",Space,Str "is",Space,Str "some",Space,Str "unicode:"] ,BulletList- [[Plain [Str "I",Space,Str "hat",Str ":",Space,Str "\206"]]- ,[Plain [Str "o",Space,Str "umlaut",Str ":",Space,Str "\246"]]- ,[Plain [Str "section",Str ":",Space,Str "\167"]]- ,[Plain [Str "set",Space,Str "membership",Str ":",Space,Str "\8712"]]- ,[Plain [Str "copyright",Str ":",Space,Str "\169"]]]-,Para [Str "AT",Str "&",Str "T",Space,Str "has",Space,Str "an",Space,Str "ampersand",Space,Str "in",Space,Str "their",Space,Str "name",Str "."]-,Para [Str "AT",Str "&",Str "T",Space,Str "is",Space,Str "another",Space,Str "way",Space,Str "to",Space,Str "write",Space,Str "it",Str "."]-,Para [Str "This",Space,Str "&",Space,Str "that",Str "."]-,Para [Str "4",Space,Str "<",Space,Str "5",Str "."]-,Para [Str "6",Space,Str ">",Space,Str "5",Str "."]-,Para [Str "Backslash",Str ":",Space,Str "\\"]-,Para [Str "Backtick",Str ":",Space,Str "`"]-,Para [Str "Asterisk",Str ":",Space,Str "*"]-,Para [Str "Underscore",Str ":",Space,Str "_"]-,Para [Str "Left",Space,Str "brace",Str ":",Space,Str "{"]-,Para [Str "Right",Space,Str "brace",Str ":",Space,Str "}"]-,Para [Str "Left",Space,Str "bracket",Str ":",Space,Str "["]-,Para [Str "Right",Space,Str "bracket",Str ":",Space,Str "]"]-,Para [Str "Left",Space,Str "paren",Str ":",Space,Str "("]-,Para [Str "Right",Space,Str "paren",Str ":",Space,Str ")"]-,Para [Str "Greater",Str "-",Str "than",Str ":",Space,Str ">"]-,Para [Str "Hash",Str ":",Space,Str "#"]-,Para [Str "Period",Str ":",Space,Str "."]-,Para [Str "Bang",Str ":",Space,Str "!"]-,Para [Str "Plus",Str ":",Space,Str "+"]-,Para [Str "Minus",Str ":",Space,Str "-"]+ [[Plain [Str "I",Space,Str "hat:",Space,Str "\206"]]+ ,[Plain [Str "o",Space,Str "umlaut:",Space,Str "\246"]]+ ,[Plain [Str "section:",Space,Str "\167"]]+ ,[Plain [Str "set",Space,Str "membership:",Space,Str "\8712"]]+ ,[Plain [Str "copyright:",Space,Str "\169"]]]+,Para [Str "AT&T",Space,Str "has",Space,Str "an",Space,Str "ampersand",Space,Str "in",Space,Str "their",Space,Str "name."]+,Para [Str "AT&T",Space,Str "is",Space,Str "another",Space,Str "way",Space,Str "to",Space,Str "write",Space,Str "it."]+,Para [Str "This",Space,Str "&",Space,Str "that."]+,Para [Str "4",Space,Str "<",Space,Str "5."]+,Para [Str "6",Space,Str ">",Space,Str "5."]+,Para [Str "Backslash:",Space,Str "\\"]+,Para [Str "Backtick:",Space,Str "`"]+,Para [Str "Asterisk:",Space,Str "*"]+,Para [Str "Underscore:",Space,Str "_"]+,Para [Str "Left",Space,Str "brace:",Space,Str "{"]+,Para [Str "Right",Space,Str "brace:",Space,Str "}"]+,Para [Str "Left",Space,Str "bracket:",Space,Str "["]+,Para [Str "Right",Space,Str "bracket:",Space,Str "]"]+,Para [Str "Left",Space,Str "paren:",Space,Str "("]+,Para [Str "Right",Space,Str "paren:",Space,Str ")"]+,Para [Str "Greater-than:",Space,Str ">"]+,Para [Str "Hash:",Space,Str "#"]+,Para [Str "Period:",Space,Str "."]+,Para [Str "Bang:",Space,Str "!"]+,Para [Str "Plus:",Space,Str "+"]+,Para [Str "Minus:",Space,Str "-"] ,HorizontalRule-,Header 1 [Str "Links"]-,Header 2 [Str "Explicit"]+,Header 1 ("links",[],[]) [Str "Links"]+,Header 2 ("explicit",[],[]) [Str "Explicit"] ,Para [Str "Just",Space,Str "a",Space,Link [Str "URL"] ("/url/",""),Str "."] ,Para [Link [Str "URL",Space,Str "and",Space,Str "title"] ("/url/","title"),Str "."] ,Para [Link [Str "URL",Space,Str "and",Space,Str "title"] ("/url/","title preceded by two spaces"),Str "."] ,Para [Link [Str "URL",Space,Str "and",Space,Str "title"] ("/url/","title preceded by a tab"),Str "."] ,Para [Link [Str "URL",Space,Str "and",Space,Str "title"] ("/url/","title with \"quotes\" in it")] ,Para [Link [Str "URL",Space,Str "and",Space,Str "title"] ("/url/","title with single quotes")]-,Para [Link [Str "with",Str "_",Str "underscore"] ("/url/with_underscore","")]+,Para [Link [Str "with_underscore"] ("/url/with_underscore","")] ,Para [Link [Str "Email",Space,Str "link"] ("mailto:nobody@nowhere.net","")] ,Para [Link [Str "Empty"] ("",""),Str "."]-,Header 2 [Str "Reference"]+,Header 2 ("reference",[],[]) [Str "Reference"] ,Para [Str "Foo",Space,Link [Str "bar"] ("/url/",""),Str "."] ,Para [Str "Foo",Space,Link [Str "bar"] ("/url/",""),Str "."] ,Para [Str "Foo",Space,Link [Str "bar"] ("/url/",""),Str "."]-,Para [Str "With",Space,Link [Str "embedded",Space,Str "[",Str "brackets",Str "]"] ("/url/",""),Str "."]-,Para [Link [Str "b"] ("/url/",""),Space,Str "by",Space,Str "itself",Space,Str "should",Space,Str "be",Space,Str "a",Space,Str "link",Str "."]+,Para [Str "With",Space,Link [Str "embedded",Space,Str "[brackets]"] ("/url/",""),Str "."]+,Para [Link [Str "b"] ("/url/",""),Space,Str "by",Space,Str "itself",Space,Str "should",Space,Str "be",Space,Str "a",Space,Str "link."] ,Para [Str "Indented",Space,Link [Str "once"] ("/url",""),Str "."] ,Para [Str "Indented",Space,Link [Str "twice"] ("/url",""),Str "."] ,Para [Str "Indented",Space,Link [Str "thrice"] ("/url",""),Str "."]-,Para [Str "This",Space,Str "should",Space,Str "[",Str "not",Str "]",Str "[",Str "]",Space,Str "be",Space,Str "a",Space,Str "link",Str "."]+,Para [Str "This",Space,Str "should",Space,Str "[not][]",Space,Str "be",Space,Str "a",Space,Str "link."] ,CodeBlock ("",[],[]) "[not]: /url" ,Para [Str "Foo",Space,Link [Str "bar"] ("/url/","Title with \"quotes\" inside"),Str "."] ,Para [Str "Foo",Space,Link [Str "biz"] ("/url/","Title with \"quote\" inside"),Str "."]-,Header 2 [Str "With",Space,Str "ampersands"]+,Header 2 ("with-ampersands",[],[]) [Str "With",Space,Str "ampersands"] ,Para [Str "Here\8217s",Space,Str "a",Space,Link [Str "link",Space,Str "with",Space,Str "an",Space,Str "ampersand",Space,Str "in",Space,Str "the",Space,Str "URL"] ("http://example.com/?foo=1&bar=2",""),Str "."]-,Para [Str "Here\8217s",Space,Str "a",Space,Str "link",Space,Str "with",Space,Str "an",Space,Str "amersand",Space,Str "in",Space,Str "the",Space,Str "link",Space,Str "text",Str ":",Space,Link [Str "AT",Str "&",Str "T"] ("http://att.com/","AT&T"),Str "."]+,Para [Str "Here\8217s",Space,Str "a",Space,Str "link",Space,Str "with",Space,Str "an",Space,Str "amersand",Space,Str "in",Space,Str "the",Space,Str "link",Space,Str "text:",Space,Link [Str "AT&T"] ("http://att.com/","AT&T"),Str "."] ,Para [Str "Here\8217s",Space,Str "an",Space,Link [Str "inline",Space,Str "link"] ("/script?foo=1&bar=2",""),Str "."] ,Para [Str "Here\8217s",Space,Str "an",Space,Link [Str "inline",Space,Str "link",Space,Str "in",Space,Str "pointy",Space,Str "braces"] ("/script?foo=1&bar=2",""),Str "."]-,Header 2 [Str "Autolinks"]-,Para [Str "With",Space,Str "an",Space,Str "ampersand",Str ":",Space,Link [Code ("",["url"],[]) "http://example.com/?foo=1&bar=2"] ("http://example.com/?foo=1&bar=2","")]+,Header 2 ("autolinks",[],[]) [Str "Autolinks"]+,Para [Str "With",Space,Str "an",Space,Str "ampersand:",Space,Link [Str "http://example.com/?foo=1&bar=2"] ("http://example.com/?foo=1&bar=2","")] ,BulletList- [[Plain [Str "In",Space,Str "a",Space,Str "list",Str "?"]]- ,[Plain [Link [Code ("",["url"],[]) "http://example.com/"] ("http://example.com/","")]]- ,[Plain [Str "It",Space,Str "should",Str "."]]]-,Para [Str "An",Space,Str "e",Str "-",Str "mail",Space,Str "address",Str ":",Space,Link [Code ("",["url"],[]) "nobody@nowhere.net"] ("mailto:nobody@nowhere.net","")]+ [[Plain [Str "In",Space,Str "a",Space,Str "list?"]]+ ,[Plain [Link [Str "http://example.com/"] ("http://example.com/","")]]+ ,[Plain [Str "It",Space,Str "should."]]]+,Para [Str "An",Space,Str "e-mail",Space,Str "address:",Space,Link [Str "nobody@nowhere.net"] ("mailto:nobody@nowhere.net","")] ,BlockQuote- [Para [Str "Blockquoted",Str ":",Space,Link [Code ("",["url"],[]) "http://example.com/"] ("http://example.com/","")]]-,Para [Str "Auto",Str "-",Str "links",Space,Str "should",Space,Str "not",Space,Str "occur",Space,Str "here",Str ":",Space,Code ("",[],[]) "<http://example.com/>"]+ [Para [Str "Blockquoted:",Space,Link [Str "http://example.com/"] ("http://example.com/","")]]+,Para [Str "Auto-links",Space,Str "should",Space,Str "not",Space,Str "occur",Space,Str "here:",Space,Code ("",[],[]) "<http://example.com/>"] ,CodeBlock ("",[],[]) "or here: <http://example.com/>" ,HorizontalRule-,Header 1 [Str "Images"]-,Para [Str "From",Space,Quoted DoubleQuote [Str "Voyage",Space,Str "dans",Space,Str "la",Space,Str "Lune"],Space,Str "by",Space,Str "Georges",Space,Str "Melies",Space,Str "(",Str "1902",Str ")",Str ":"]-,Para [Image [Str "lalune"] ("lalune.jpg","Voyage dans la Lune")]-,Para [Str "Here",Space,Str "is",Space,Str "a",Space,Str "movie",Space,Image [Str "movie"] ("movie.jpg",""),Space,Str "icon",Str "."]+,Header 1 ("images",[],[]) [Str "Images"]+,Para [Str "From",Space,Quoted DoubleQuote [Str "Voyage",Space,Str "dans",Space,Str "la",Space,Str "Lune"],Space,Str "by",Space,Str "Georges",Space,Str "Melies",Space,Str "(1902):"]+,Para [Image [Str "lalune"] ("lalune.jpg","fig:Voyage dans la Lune")]+,Para [Str "Here",Space,Str "is",Space,Str "a",Space,Str "movie",Space,Image [Str "movie"] ("movie.jpg",""),Space,Str "icon."] ,HorizontalRule-,Header 1 [Str "Footnotes"]-,Para [Str "Here",Space,Str "is",Space,Str "a",Space,Str "footnote",Space,Str "reference",Str ",",Note [Para [Str "Here",Space,Str "is",Space,Str "the",Space,Str "footnote",Str ".",Space,Str "It",Space,Str "can",Space,Str "go",Space,Str "anywhere",Space,Str "after",Space,Str "the",Space,Str "footnote",Space,Str "reference",Str ".",Space,Str "It",Space,Str "need",Space,Str "not",Space,Str "be",Space,Str "placed",Space,Str "at",Space,Str "the",Space,Str "end",Space,Str "of",Space,Str "the",Space,Str "document",Str "."]],Space,Str "and",Space,Str "another",Str ".",Note [Para [Str "Here\8217s",Space,Str "the",Space,Str "long",Space,Str "note",Str ".",Space,Str "This",Space,Str "one",Space,Str "contains",Space,Str "multiple",Space,Str "blocks",Str "."],Para [Str "Subsequent",Space,Str "blocks",Space,Str "are",Space,Str "indented",Space,Str "to",Space,Str "show",Space,Str "that",Space,Str "they",Space,Str "belong",Space,Str "to",Space,Str "the",Space,Str "footnote",Space,Str "(",Str "as",Space,Str "with",Space,Str "list",Space,Str "items",Str ")",Str "."],CodeBlock ("",[],[]) " { <code> }",Para [Str "If",Space,Str "you",Space,Str "want",Str ",",Space,Str "you",Space,Str "can",Space,Str "indent",Space,Str "every",Space,Str "line",Str ",",Space,Str "but",Space,Str "you",Space,Str "can",Space,Str "also",Space,Str "be",Space,Str "lazy",Space,Str "and",Space,Str "just",Space,Str "indent",Space,Str "the",Space,Str "first",Space,Str "line",Space,Str "of",Space,Str "each",Space,Str "block",Str "."]],Space,Str "This",Space,Str "should",Space,Emph [Str "not"],Space,Str "be",Space,Str "a",Space,Str "footnote",Space,Str "reference",Str ",",Space,Str "because",Space,Str "it",Space,Str "contains",Space,Str "a",Space,Str "space",Str ".",Str "[",Str "^",Str "my",Space,Str "note",Str "]",Space,Str "Here",Space,Str "is",Space,Str "an",Space,Str "inline",Space,Str "note",Str ".",Note [Para [Str "This",Space,Str "is",Space,Emph [Str "easier"],Space,Str "to",Space,Str "type",Str ".",Space,Str "Inline",Space,Str "notes",Space,Str "may",Space,Str "contain",Space,Link [Str "links"] ("http://google.com",""),Space,Str "and",Space,Code ("",[],[]) "]",Space,Str "verbatim",Space,Str "characters",Str ",",Space,Str "as",Space,Str "well",Space,Str "as",Space,Str "[",Str "bracketed",Space,Str "text",Str "]",Str "."]]]+,Header 1 ("footnotes",[],[]) [Str "Footnotes"]+,Para [Str "Here",Space,Str "is",Space,Str "a",Space,Str "footnote",Space,Str "reference,",Note [Para [Str "Here",Space,Str "is",Space,Str "the",Space,Str "footnote.",Space,Str "It",Space,Str "can",Space,Str "go",Space,Str "anywhere",Space,Str "after",Space,Str "the",Space,Str "footnote",Space,Str "reference.",Space,Str "It",Space,Str "need",Space,Str "not",Space,Str "be",Space,Str "placed",Space,Str "at",Space,Str "the",Space,Str "end",Space,Str "of",Space,Str "the",Space,Str "document."]],Space,Str "and",Space,Str "another.",Note [Para [Str "Here\8217s",Space,Str "the",Space,Str "long",Space,Str "note.",Space,Str "This",Space,Str "one",Space,Str "contains",Space,Str "multiple",Space,Str "blocks."],Para [Str "Subsequent",Space,Str "blocks",Space,Str "are",Space,Str "indented",Space,Str "to",Space,Str "show",Space,Str "that",Space,Str "they",Space,Str "belong",Space,Str "to",Space,Str "the",Space,Str "footnote",Space,Str "(as",Space,Str "with",Space,Str "list",Space,Str "items)."],CodeBlock ("",[],[]) " { <code> }",Para [Str "If",Space,Str "you",Space,Str "want,",Space,Str "you",Space,Str "can",Space,Str "indent",Space,Str "every",Space,Str "line,",Space,Str "but",Space,Str "you",Space,Str "can",Space,Str "also",Space,Str "be",Space,Str "lazy",Space,Str "and",Space,Str "just",Space,Str "indent",Space,Str "the",Space,Str "first",Space,Str "line",Space,Str "of",Space,Str "each",Space,Str "block."]],Space,Str "This",Space,Str "should",Space,Emph [Str "not"],Space,Str "be",Space,Str "a",Space,Str "footnote",Space,Str "reference,",Space,Str "because",Space,Str "it",Space,Str "contains",Space,Str "a",Space,Str "space.[^my",Space,Str "note]",Space,Str "Here",Space,Str "is",Space,Str "an",Space,Str "inline",Space,Str "note.",Note [Para [Str "This",Space,Str "is",Space,Emph [Str "easier"],Space,Str "to",Space,Str "type.",Space,Str "Inline",Space,Str "notes",Space,Str "may",Space,Str "contain",Space,Link [Str "links"] ("http://google.com",""),Space,Str "and",Space,Code ("",[],[]) "]",Space,Str "verbatim",Space,Str "characters,",Space,Str "as",Space,Str "well",Space,Str "as",Space,Str "[bracketed",Space,Str "text]."]]] ,BlockQuote- [Para [Str "Notes",Space,Str "can",Space,Str "go",Space,Str "in",Space,Str "quotes",Str ".",Note [Para [Str "In",Space,Str "quote",Str "."]]]]+ [Para [Str "Notes",Space,Str "can",Space,Str "go",Space,Str "in",Space,Str "quotes.",Note [Para [Str "In",Space,Str "quote."]]]] ,OrderedList (1,Decimal,Period)- [[Plain [Str "And",Space,Str "in",Space,Str "list",Space,Str "items",Str ".",Note [Para [Str "In",Space,Str "list",Str "."]]]]]-,Para [Str "This",Space,Str "paragraph",Space,Str "should",Space,Str "not",Space,Str "be",Space,Str "part",Space,Str "of",Space,Str "the",Space,Str "note",Str ",",Space,Str "as",Space,Str "it",Space,Str "is",Space,Str "not",Space,Str "indented",Str "."]]+ [[Plain [Str "And",Space,Str "in",Space,Str "list",Space,Str "items.",Note [Para [Str "In",Space,Str "list."]]]]]+,Para [Str "This",Space,Str "paragraph",Space,Str "should",Space,Str "not",Space,Str "be",Space,Str "part",Space,Str "of",Space,Str "the",Space,Str "note,",Space,Str "as",Space,Str "it",Space,Str "is",Space,Str "not",Space,Str "indented."]]
@@ -665,27 +665,27 @@ <style:style style:name="T35" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic" fo:font-weight="bold" style:font-weight-asian="bold" style:font-weight-complex="bold" /></style:style> <style:style style:name="T36" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic" fo:font-weight="bold" style:font-weight-asian="bold" style:font-weight-complex="bold" /></style:style> <style:style style:name="T37" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic" fo:font-weight="bold" style:font-weight-asian="bold" style:font-weight-complex="bold" /></style:style>- <style:style style:name="T38" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic" fo:font-weight="bold" style:font-weight-asian="bold" style:font-weight-complex="bold" /></style:style>- <style:style style:name="T39" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic" fo:font-weight="bold" style:font-weight-asian="bold" style:font-weight-complex="bold" /></style:style>+ <style:style style:name="T38" style:family="text"><style:text-properties style:text-line-through-style="solid" /></style:style>+ <style:style style:name="T39" style:family="text"><style:text-properties style:text-line-through-style="solid" /></style:style> <style:style style:name="T40" style:family="text"><style:text-properties style:text-line-through-style="solid" /></style:style> <style:style style:name="T41" style:family="text"><style:text-properties style:text-line-through-style="solid" /></style:style>- <style:style style:name="T42" style:family="text"><style:text-properties style:text-line-through-style="solid" /></style:style>+ <style:style style:name="T42" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic" style:text-line-through-style="solid" /></style:style> <style:style style:name="T43" style:family="text"><style:text-properties style:text-line-through-style="solid" /></style:style>- <style:style style:name="T44" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic" style:text-line-through-style="solid" /></style:style>- <style:style style:name="T45" style:family="text"><style:text-properties style:text-line-through-style="solid" /></style:style>+ <style:style style:name="T44" style:family="text"><style:text-properties style:text-position="super 58%" /></style:style>+ <style:style style:name="T45" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic" style:text-position="super 58%" /></style:style> <style:style style:name="T46" style:family="text"><style:text-properties style:text-position="super 58%" /></style:style>- <style:style style:name="T47" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic" style:text-position="super 58%" /></style:style>- <style:style style:name="T48" style:family="text"><style:text-properties style:text-position="super 58%" /></style:style>- <style:style style:name="T49" style:family="text"><style:text-properties style:text-position="super 58%" /></style:style>- <style:style style:name="T50" style:family="text"><style:text-properties style:text-position="super 58%" /></style:style>- <style:style style:name="T51" style:family="text"><style:text-properties style:text-position="sub 58%" /></style:style>- <style:style style:name="T52" style:family="text"><style:text-properties style:text-position="sub 58%" /></style:style>- <style:style style:name="T53" style:family="text"><style:text-properties style:text-position="sub 58%" /></style:style>- <style:style style:name="T54" style:family="text"><style:text-properties style:text-position="sub 58%" /></style:style>- <style:style style:name="T55" style:family="text"><style:text-properties style:text-position="sub 58%" /></style:style>- <style:style style:name="T56" style:family="text"><style:text-properties style:text-position="sub 58%" /></style:style>- <style:style style:name="T57" style:family="text"><style:text-properties style:text-position="sub 58%" /></style:style>- <style:style style:name="T58" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic" /></style:style>+ <style:style style:name="T47" style:family="text"><style:text-properties style:text-position="sub 58%" /></style:style>+ <style:style style:name="T48" style:family="text"><style:text-properties style:text-position="sub 58%" /></style:style>+ <style:style style:name="T49" style:family="text"><style:text-properties style:text-position="sub 58%" /></style:style>+ <style:style style:name="T50" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic" /></style:style>+ <style:style style:name="T51" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic" /></style:style>+ <style:style style:name="T52" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic" /></style:style>+ <style:style style:name="T53" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic" /></style:style>+ <style:style style:name="T54" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic" /></style:style>+ <style:style style:name="T55" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic" /></style:style>+ <style:style style:name="T56" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic" /></style:style>+ <style:style style:name="T57" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic" /></style:style>+ <style:style style:name="T58" style:family="text"><style:text-properties style:text-position="super 58%" /></style:style> <style:style style:name="T59" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic" /></style:style> <style:style style:name="T60" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic" /></style:style> <style:style style:name="T61" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic" /></style:style>@@ -693,17 +693,9 @@ <style:style style:name="T63" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic" /></style:style> <style:style style:name="T64" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic" /></style:style> <style:style style:name="T65" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic" /></style:style>- <style:style style:name="T66" style:family="text"><style:text-properties style:text-position="super 58%" /></style:style>+ <style:style style:name="T66" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic" /></style:style> <style:style style:name="T67" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic" /></style:style> <style:style style:name="T68" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic" /></style:style>- <style:style style:name="T69" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic" /></style:style>- <style:style style:name="T70" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic" /></style:style>- <style:style style:name="T71" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic" /></style:style>- <style:style style:name="T72" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic" /></style:style>- <style:style style:name="T73" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic" /></style:style>- <style:style style:name="T74" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic" /></style:style>- <style:style style:name="T75" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic" /></style:style>- <style:style style:name="T76" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic" /></style:style> <style:style style:name="P1" style:family="paragraph" style:parent-style-name="Quotations"> <style:paragraph-properties fo:margin-left="0.5in" fo:margin-right="0in" fo:text-indent="0in" style:auto-text-indent="false" /> </style:style>@@ -1342,33 +1334,33 @@ </text:span><text:span text:style-name="T20">is</text:span><text:span text:style-name="T21"> </text:span><text:span text:style-name="T22">strong</text:span><text:span text:style-name="T23"> </text:span><text:span text:style-name="T24">and</text:span><text:span text:style-name="T25">-</text:span><text:span text:style-name="T26">em</text:span><text:span text:style-name="T27">.</text:span></text:p>+</text:span><text:span text:style-name="T26">em.</text:span></text:p> <text:p text:style-name="Text_20_body">So is-<text:span text:style-name="T28">this</text:span> word.</text:p>-<text:p text:style-name="Text_20_body"><text:span text:style-name="T29">This</text:span><text:span text:style-name="T30">-</text:span><text:span text:style-name="T31">is</text:span><text:span text:style-name="T32">-</text:span><text:span text:style-name="T33">strong</text:span><text:span text:style-name="T34">-</text:span><text:span text:style-name="T35">and</text:span><text:span text:style-name="T36">-</text:span><text:span text:style-name="T37">em</text:span><text:span text:style-name="T38">.</text:span></text:p>+<text:span text:style-name="T27">this</text:span> word.</text:p>+<text:p text:style-name="Text_20_body"><text:span text:style-name="T28">This</text:span><text:span text:style-name="T29">+</text:span><text:span text:style-name="T30">is</text:span><text:span text:style-name="T31">+</text:span><text:span text:style-name="T32">strong</text:span><text:span text:style-name="T33">+</text:span><text:span text:style-name="T34">and</text:span><text:span text:style-name="T35">+</text:span><text:span text:style-name="T36">em.</text:span></text:p> <text:p text:style-name="Text_20_body">So is-<text:span text:style-name="T39">this</text:span> word.</text:p>+<text:span text:style-name="T37">this</text:span> word.</text:p> <text:p text:style-name="Text_20_body">This is code: <text:span text:style-name="Teletype">></text:span>, <text:span text:style-name="Teletype">$</text:span>, <text:span text:style-name="Teletype">\</text:span>, <text:span text:style-name="Teletype">\$</text:span>, <text:span text:style-name="Teletype"><html></text:span>.</text:p>-<text:p text:style-name="Text_20_body"><text:span text:style-name="T40">This</text:span><text:span text:style-name="T41">-</text:span><text:span text:style-name="T42">is</text:span><text:span text:style-name="T43">-</text:span><text:span text:style-name="T44">strikeout</text:span><text:span text:style-name="T45">.</text:span></text:p>+<text:p text:style-name="Text_20_body"><text:span text:style-name="T38">This</text:span><text:span text:style-name="T39">+</text:span><text:span text:style-name="T40">is</text:span><text:span text:style-name="T41">+</text:span><text:span text:style-name="T42">strikeout</text:span><text:span text:style-name="T43">.</text:span></text:p> <text:p text:style-name="Text_20_body">Superscripts:-a<text:span text:style-name="T46">bc</text:span>d-a<text:span text:style-name="T47">hello</text:span>-a<text:span text:style-name="T48">hello</text:span><text:span text:style-name="T49"> </text:span><text:span text:style-name="T50">there</text:span>.</text:p>+a<text:span text:style-name="T44">bc</text:span>d+a<text:span text:style-name="T45">hello</text:span>+a<text:span text:style-name="T46">hello there</text:span>.</text:p> <text:p text:style-name="Text_20_body">Subscripts:-H<text:span text:style-name="T51">2</text:span>O,-H<text:span text:style-name="T52">23</text:span>O,-H<text:span text:style-name="T53">many</text:span><text:span text:style-name="T54"> </text:span><text:span text:style-name="T55">of</text:span><text:span text:style-name="T56"> </text:span><text:span text:style-name="T57">them</text:span>O.</text:p>+H<text:span text:style-name="T47">2</text:span>O,+H<text:span text:style-name="T48">23</text:span>O,+H<text:span text:style-name="T49">many of them</text:span>O.</text:p> <text:p text:style-name="Text_20_body">These should not be superscripts or subscripts, because of the unescaped spaces: a^b c^d, a~b c~d.</text:p> <text:p text:style-name="Horizontal_20_Line" />@@ -1400,16 +1392,16 @@ <text:p text:style-name="P51">2 + 2 = 4</text:p> </text:list-item> <text:list-item>- <text:p text:style-name="P51"><text:span text:style-name="T58">x</text:span> ∈ <text:span text:style-name="T59">y</text:span></text:p>+ <text:p text:style-name="P51"><text:span text:style-name="T50">x</text:span> ∈ <text:span text:style-name="T51">y</text:span></text:p> </text:list-item> <text:list-item>- <text:p text:style-name="P51"><text:span text:style-name="T60">α</text:span> ∧ <text:span text:style-name="T61">ω</text:span></text:p>+ <text:p text:style-name="P51"><text:span text:style-name="T52">α</text:span> ∧ <text:span text:style-name="T53">ω</text:span></text:p> </text:list-item> <text:list-item> <text:p text:style-name="P51">223</text:p> </text:list-item> <text:list-item>- <text:p text:style-name="P51"><text:span text:style-name="T62">p</text:span>-Tree</text:p>+ <text:p text:style-name="P51"><text:span text:style-name="T54">p</text:span>-Tree</text:p> </text:list-item> <text:list-item> <text:p text:style-name="P51">Here’s some display math:@@ -1417,7 +1409,7 @@ </text:list-item> <text:list-item> <text:p text:style-name="P51">Here’s one that has a line break in it:- <text:span text:style-name="T63">α</text:span> + <text:span text:style-name="T64">ω</text:span> × <text:span text:style-name="T65">x</text:span><text:span text:style-name="T66">2</text:span>.</text:p>+ <text:span text:style-name="T55">α</text:span> + <text:span text:style-name="T56">ω</text:span> × <text:span text:style-name="T57">x</text:span><text:span text:style-name="T58">2</text:span>.</text:p> </text:list-item> </text:list> <text:p text:style-name="First_20_paragraph">These shouldn’t be math:</text:p>@@ -1428,7 +1420,7 @@ </text:list-item> <text:list-item> <text:p text:style-name="P52">$22,000 is a- <text:span text:style-name="T67">lot</text:span> of money. So is $34,000.+ <text:span text:style-name="T59">lot</text:span> of money. So is $34,000. (It worked if “lot” is emphasized.)</text:p> </text:list-item> <text:list-item>@@ -1437,10 +1429,10 @@ <text:list-item> <text:p text:style-name="P52">Escaped <text:span text:style-name="Teletype">$</text:span>: $73- <text:span text:style-name="T68">this</text:span><text:span text:style-name="T69">- </text:span><text:span text:style-name="T70">should</text:span><text:span text:style-name="T71">- </text:span><text:span text:style-name="T72">be</text:span><text:span text:style-name="T73">- </text:span><text:span text:style-name="T74">emphasized</text:span>+ <text:span text:style-name="T60">this</text:span><text:span text:style-name="T61">+ </text:span><text:span text:style-name="T62">should</text:span><text:span text:style-name="T63">+ </text:span><text:span text:style-name="T64">be</text:span><text:span text:style-name="T65">+ </text:span><text:span text:style-name="T66">emphasized</text:span> 23$.</text:p> </text:list-item> </text:list>@@ -1548,22 +1540,22 @@ link in pointy braces</text:span></text:a>.</text:p> <text:h text:style-name="Heading_20_2" text:outline-level="2">Autolinks</text:h> <text:p text:style-name="First_20_paragraph">With an ampersand:-<text:a xlink:type="simple" xlink:href="http://example.com/?foo=1&bar=2" office:name=""><text:span text:style-name="Definition"><text:span text:style-name="Teletype">http://example.com/?foo=1&bar=2</text:span></text:span></text:a></text:p>+<text:a xlink:type="simple" xlink:href="http://example.com/?foo=1&bar=2" office:name=""><text:span text:style-name="Definition">http://example.com/?foo=1&bar=2</text:span></text:a></text:p> <text:list text:style-name="L29"> <text:list-item> <text:p text:style-name="P55">In a list?</text:p> </text:list-item> <text:list-item>- <text:p text:style-name="P55"><text:a xlink:type="simple" xlink:href="http://example.com/" office:name=""><text:span text:style-name="Definition"><text:span text:style-name="Teletype">http://example.com/</text:span></text:span></text:a></text:p>+ <text:p text:style-name="P55"><text:a xlink:type="simple" xlink:href="http://example.com/" office:name=""><text:span text:style-name="Definition">http://example.com/</text:span></text:a></text:p> </text:list-item> <text:list-item> <text:p text:style-name="P55">It should.</text:p> </text:list-item> </text:list> <text:p text:style-name="First_20_paragraph">An e-mail address:-<text:a xlink:type="simple" xlink:href="mailto:nobody@nowhere.net" office:name=""><text:span text:style-name="Definition"><text:span text:style-name="Teletype">nobody@nowhere.net</text:span></text:span></text:a></text:p>+<text:a xlink:type="simple" xlink:href="mailto:nobody@nowhere.net" office:name=""><text:span text:style-name="Definition">nobody@nowhere.net</text:span></text:a></text:p> <text:p text:style-name="P56">Blockquoted:-<text:a xlink:type="simple" xlink:href="http://example.com/" office:name=""><text:span text:style-name="Definition"><text:span text:style-name="Teletype">http://example.com/</text:span></text:span></text:a></text:p>+<text:a xlink:type="simple" xlink:href="http://example.com/" office:name=""><text:span text:style-name="Definition">http://example.com/</text:span></text:a></text:p> <text:p text:style-name="First_20_paragraph">Auto-links should not occur here: <text:span text:style-name="Teletype"><http://example.com/></text:span></text:p> <text:p text:style-name="P57">or here: <http://example.com/></text:p>@@ -1589,10 +1581,10 @@ items).</text:p><text:p text:style-name="P58"><text:s text:c="2" />{ <code> }</text:p><text:p text:style-name="Footnote">If you want, you can indent every line, but you can also be lazy and just indent the first line of each block.</text:p></text:note-body></text:note> This-should <text:span text:style-name="T75">not</text:span> be a footnote+should <text:span text:style-name="T67">not</text:span> be a footnote reference, because it contains a space.[^my note] Here is an inline note.<text:note text:id="ftn2" text:note-class="footnote"><text:note-citation>3</text:note-citation><text:note-body><text:p text:style-name="Footnote">This-is <text:span text:style-name="T76">easier</text:span> to type. Inline notes+is <text:span text:style-name="T68">easier</text:span> to type. Inline notes may contain <text:a xlink:type="simple" xlink:href="http://google.com" office:name=""><text:span text:style-name="Definition">links</text:span></text:a> and <text:span text:style-name="Teletype">]</text:span> verbatim characters,
@@ -711,7 +711,7 @@ - [[http://example.com/]] - It should. -An e-mail address: [[mailto:nobody@nowhere.net][=nobody@nowhere.net=]]+An e-mail address: [[mailto:nobody@nowhere.net][nobody@nowhere.net]] #+BEGIN_QUOTE Blockquoted: [[http://example.com/]]
@@ -18,8 +18,8 @@ Headers ======= -Level 2 with an `embedded link </url>`_----------------------------------------+Level 2 with an `embedded link </url>`__+---------------------------------------- Level 3 with *emphasis* ~~~~~~~~~~~~~~~~~~~~~~~@@ -59,8 +59,8 @@ Here’s one with a bullet. \* criminey. -There should be a hard line break-here.+| There should be a hard line break+| here. -------------- @@ -549,7 +549,7 @@ This is **strong**, and so **is this**. -An *`emphasized link </url>`_*.+An *`emphasized link </url>`__*. ***This is strong and em.*** @@ -584,7 +584,7 @@ ‘He said, “I want to go.”’ Were you alive in the 70’s? Here is some quoted ‘``code``’ and a “`quoted-link <http://example.com/?foo=1&bar=2>`_”.+link <http://example.com/?foo=1&bar=2>`__”. Some dashes: one—two — three—four — five. @@ -690,42 +690,42 @@ Explicit -------- -Just a `URL </url/>`_.+Just a `URL </url/>`__. -`URL and title </url/>`_.+`URL and title </url/>`__. -`URL and title </url/>`_.+`URL and title </url/>`__. -`URL and title </url/>`_.+`URL and title </url/>`__. -`URL and title </url/>`_+`URL and title </url/>`__ -`URL and title </url/>`_+`URL and title </url/>`__ -`with\_underscore </url/with_underscore>`_+`with\_underscore </url/with_underscore>`__ -`Email link <mailto:nobody@nowhere.net>`_+`Email link <mailto:nobody@nowhere.net>`__ -`Empty <>`_.+`Empty <>`__. Reference --------- -Foo `bar </url/>`_.+Foo `bar </url/>`__. -Foo `bar </url/>`_.+Foo `bar </url/>`__. -Foo `bar </url/>`_.+Foo `bar </url/>`__. -With `embedded [brackets] </url/>`_.+With `embedded [brackets] </url/>`__. -`b </url/>`_ by itself should be a link.+`b </url/>`__ by itself should be a link. -Indented `once </url>`_.+Indented `once </url>`__. -Indented `twice </url>`_.+Indented `twice </url>`__. -Indented `thrice </url>`_.+Indented `thrice </url>`__. This should [not][] be a link. @@ -733,21 +733,21 @@ [not]: /url -Foo `bar </url/>`_.+Foo `bar </url/>`__. -Foo `biz </url/>`_.+Foo `biz </url/>`__. With ampersands --------------- Here’s a `link with an ampersand in the-URL <http://example.com/?foo=1&bar=2>`_.+URL <http://example.com/?foo=1&bar=2>`__. -Here’s a link with an amersand in the link text: `AT&T <http://att.com/>`_.+Here’s a link with an amersand in the link text: `AT&T <http://att.com/>`__. -Here’s an `inline link </script?foo=1&bar=2>`_.+Here’s an `inline link </script?foo=1&bar=2>`__. -Here’s an `inline link in pointy braces </script?foo=1&bar=2>`_.+Here’s an `inline link in pointy braces </script?foo=1&bar=2>`__. Autolinks ---------@@ -776,7 +776,6 @@ From “Voyage dans la Lune” by Georges Melies (1902): .. figure:: lalune.jpg- :align: center :alt: Voyage dans la Lune lalune@@ -816,7 +815,7 @@ .. [3] This is *easier* to type. Inline notes may contain- `links <http://google.com>`_ and ``]`` verbatim characters, as well as+ `links <http://google.com>`__ and ``]`` verbatim characters, as well as [bracketed text]. .. [4]
@@ -407,21 +407,21 @@ .\par} {\pard \ql \f0 \sa180 \li0 \fi0 \b \fs32 Autolinks\par} {\pard \ql \f0 \sa180 \li0 \fi0 With an ampersand: {\field{\*\fldinst{HYPERLINK "http://example.com/?foo=1&bar=2"}}{\fldrslt{\ul-{\f1 http://example.com/?foo=1&bar=2}+http://example.com/?foo=1&bar=2 }}} \par} {\pard \ql \f0 \sa0 \li360 \fi-360 \bullet \tx360\tab In a list?\par} {\pard \ql \f0 \sa0 \li360 \fi-360 \bullet \tx360\tab {\field{\*\fldinst{HYPERLINK "http://example.com/"}}{\fldrslt{\ul-{\f1 http://example.com/}+http://example.com/ }}} \par} {\pard \ql \f0 \sa0 \li360 \fi-360 \bullet \tx360\tab It should.\sa180\par} {\pard \ql \f0 \sa180 \li0 \fi0 An e-mail address: {\field{\*\fldinst{HYPERLINK "mailto:nobody@nowhere.net"}}{\fldrslt{\ul-{\f1 nobody@nowhere.net}+nobody@nowhere.net }}} \par} {\pard \ql \f0 \sa180 \li720 \fi0 Blockquoted: {\field{\*\fldinst{HYPERLINK "http://example.com/"}}{\fldrslt{\ul-{\f1 http://example.com/}+http://example.com/ }}} \par} {\pard \ql \f0 \sa180 \li0 \fi0 Auto-links should not occur here: {\f1 <http://example.com/>}\par}
@@ -30,7 +30,7 @@ @title Pandoc Test Suite @author John MacFarlane @author Anonymous-July 17@comma{} 2006+July 17, 2006 @end titlepage @node Top@@ -64,28 +64,33 @@ @node Headers @chapter Headers+@anchor{#headers} @menu * Level 2 with an embedded link:: @end menu @node Level 2 with an embedded link @section Level 2 with an @uref{/url,embedded link}+@anchor{#level-2-with-an-embedded-link} @menu * Level 3 with emphasis:: @end menu @node Level 3 with emphasis @subsection Level 3 with @emph{emphasis}+@anchor{#level-3-with-emphasis} @menu * Level 4:: @end menu @node Level 4 @subsubsection Level 4+@anchor{#level-4} Level 5 @node Level 1 @chapter Level 1+@anchor{#level-1} @menu * Level 2 with emphasis:: * Level 2::@@ -93,16 +98,19 @@ @node Level 2 with emphasis @section Level 2 with @emph{emphasis}+@anchor{#level-2-with-emphasis} @menu * Level 3:: @end menu @node Level 3 @subsection Level 3+@anchor{#level-3} with no blank line @node Level 2 @section Level 2+@anchor{#level-2} with no blank line @iftex@@ -114,6 +122,7 @@ @node Paragraphs @chapter Paragraphs+@anchor{#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.@@ -131,6 +140,7 @@ @node Block Quotes @chapter Block Quotes+@anchor{#block-quotes} E-mail style: @quotation@@ -138,6 +148,7 @@ @end quotation @quotation Code in a block quote:+ @verbatim sub status { print "working";@@ -175,7 +186,9 @@ @node Code Blocks @chapter Code Blocks+@anchor{#code-blocks} Code:+ @verbatim ---- (should be four hyphens) @@ -187,6 +200,7 @@ @end verbatim And:+ @verbatim this code block is indented by two tabs @@ -202,6 +216,7 @@ @node Lists @chapter Lists+@anchor{#lists} @menu * Unordered:: * Ordered::@@ -212,6 +227,7 @@ @node Unordered @section Unordered+@anchor{#unordered} Asterisks tight: @itemize@@ -289,6 +305,7 @@ @node Ordered @section Ordered+@anchor{#ordered} Tight: @enumerate @@ -343,7 +360,7 @@ @enumerate @item-Item 1@comma{} graf one.+Item 1, graf one. Item 1. graf two. The quick brown fox jumped over the lazy dog's back. @@ -357,6 +374,7 @@ @node Nested @section Nested+@anchor{#nested} @itemize @item Tab@@ -417,6 +435,7 @@ @node Tabs and spaces @section Tabs and spaces+@anchor{#tabs-and-spaces} @itemize @item this is a list item indented with tabs@@ -437,6 +456,7 @@ @node Fancy list markers @section Fancy list markers+@anchor{#fancy-list-markers} @enumerate 2 @item begins with 2@@ -447,7 +467,7 @@ @enumerate 4 @item-sublist with roman numerals@comma{} starting with 4+sublist with roman numerals, starting with 4 @item more items @enumerate A@@ -512,6 +532,7 @@ @node Definition Lists @chapter Definition Lists+@anchor{#definition-lists} Tight using spaces: @table @asis@@ -564,11 +585,12 @@ red fruit -contains seeds@comma{} crisp@comma{} pleasant to taste+contains seeds, crisp, pleasant to taste @item @emph{orange} orange fruit+ @verbatim { orange code block } @end verbatim@@ -578,7 +600,7 @@ @end quotation @end table -Multiple definitions@comma{} tight:+Multiple definitions, tight: @table @asis @item apple@@ -591,7 +613,7 @@ bank @end table -Multiple definitions@comma{} loose:+Multiple definitions, loose: @table @asis @item apple@@ -608,7 +630,7 @@ @end table -Blank line after term@comma{} indented marker@comma{} alternate markers:+Blank line after term, indented marker, alternate markers: @table @asis @item apple@@ -632,6 +654,7 @@ @node HTML Blocks @chapter HTML Blocks+@anchor{#html-blocks} Simple block on one line: foo@@ -646,7 +669,8 @@ Here's a simple block: foo-This should be a code block@comma{} though:+This should be a code block, though:+ @verbatim <div> foo@@ -654,11 +678,12 @@ @end verbatim As should this:+ @verbatim <div>foo</div> @end verbatim -Now@comma{} nested:+Now, nested: foo This should just be an HTML comment:@@ -666,13 +691,15 @@ Multiline: Code block:+ @verbatim <!-- Comment --> @end verbatim -Just plain comment@comma{} with trailing spaces on the line:+Just plain comment, with trailing spaces on the line: Code:+ @verbatim <hr /> @end verbatim@@ -688,9 +715,10 @@ @node Inline Markup @chapter Inline Markup-This is @emph{emphasized}@comma{} and so @emph{is this}.+@anchor{#inline-markup}+This is @emph{emphasized}, and so @emph{is this}. -This is @strong{strong}@comma{} and so @strong{is this}.+This is @strong{strong}, and so @strong{is this}. An @emph{@uref{/url,emphasized link}}. @@ -702,15 +730,15 @@ So is @strong{@emph{this}} word. -This is code: @code{>}@comma{} @code{$}@comma{} @code{\}@comma{} @code{\$}@comma{} @code{<html>}.+This is code: @code{>}, @code{$}, @code{\}, @code{\$}, @code{<html>}. @textstrikeout{This is @emph{strikeout}.} Superscripts: a@textsuperscript{bc}d a@textsuperscript{@emph{hello}} a@textsuperscript{hello@ there}. -Subscripts: H@textsubscript{2}O@comma{} H@textsubscript{23}O@comma{} H@textsubscript{many@ of@ them}O.+Subscripts: H@textsubscript{2}O, H@textsubscript{23}O, H@textsubscript{many@ of@ them}O. -These should not be superscripts or subscripts@comma{} because of the unescaped spaces: a^b c^d@comma{} a~b c~d.+These should not be superscripts or subscripts, because of the unescaped spaces: a^b c^d, a~b c~d. @iftex @bigskip@hrule@bigskip@@ -720,20 +748,21 @@ @end ifnottex @node Smart quotes ellipses dashes-@chapter Smart quotes@comma{} ellipses@comma{} dashes-``Hello@comma{}'' said the spider. ```Shelob' is my name.''+@chapter Smart quotes, ellipses, dashes+@anchor{#smart-quotes-ellipses-dashes}+``Hello,'' said the spider. ```Shelob' is my name.'' -`A'@comma{} `B'@comma{} and `C' are letters.+`A', `B', and `C' are letters. -`Oak@comma{}' `elm@comma{}' and `beech' are names of trees. So is `pine.'+`Oak,' `elm,' and `beech' are names of trees. So is `pine.' -`He said@comma{} ``I want to go.''' Were you alive in the 70's?+`He said, ``I want to go.''' Were you alive in the 70's? Here is some quoted `@code{code}' and a ``@uref{http://example.com/?foo=1&bar=2,quoted link}''. Some dashes: one---two --- three---four --- five. -Dashes between numbers: 5--7@comma{} 255--66@comma{} 1987--1999.+Dashes between numbers: 5--7, 255--66, 1987--1999. Ellipses@dots{}and@dots{}and@dots{}. @@ -746,6 +775,7 @@ @node LaTeX @chapter LaTeX+@anchor{#latex} @itemize @item @tex@@ -771,9 +801,9 @@ @itemize @item-To get the famous equation@comma{} write @code{$e = mc^2$}.+To get the famous equation, write @code{$e = mc^2$}. @item-$22@comma{}000 is a @emph{lot} of money. So is $34@comma{}000. (It worked if ``lot'' is emphasized.)+$22,000 is a @emph{lot} of money. So is $34,000. (It worked if ``lot'' is emphasized.) @item Shoes ($20) and socks ($5). @item@@ -798,6 +828,7 @@ @node Special Characters @chapter Special Characters+@anchor{#special-characters} Here is some unicode: @itemize@@ -864,6 +895,7 @@ @node Links @chapter Links+@anchor{#links} @menu * Explicit:: * Reference::@@ -873,6 +905,7 @@ @node Explicit @section Explicit+@anchor{#explicit} Just a @uref{/url/,URL}. @uref{/url/,URL and title}.@@ -893,6 +926,7 @@ @node Reference @section Reference+@anchor{#reference} Foo @uref{/url/,bar}. Foo @uref{/url/,bar}.@@ -910,6 +944,7 @@ Indented @uref{/url,thrice}. This should [not][] be a link.+ @verbatim [not]: /url @end verbatim@@ -920,6 +955,7 @@ @node With ampersands @section With ampersands+@anchor{#with-ampersands} Here's a @uref{http://example.com/?foo=1&bar=2,link with an ampersand in the URL}. Here's a link with an amersand in the link text: @uref{http://att.com/,AT&T}.@@ -930,6 +966,7 @@ @node Autolinks @section Autolinks+@anchor{#autolinks} With an ampersand: @url{http://example.com/?foo=1&bar=2} @itemize@@ -941,12 +978,13 @@ It should. @end itemize -An e-mail address: @uref{mailto:nobody@@nowhere.net,@code{nobody@@nowhere.net}}+An e-mail address: @uref{mailto:nobody@@nowhere.net,nobody@@nowhere.net} @quotation Blockquoted: @url{http://example.com/} @end quotation Auto-links should not occur here: @code{<http://example.com/>}+ @verbatim or here: <http://example.com/> @end verbatim@@ -960,6 +998,7 @@ @node Images @chapter Images+@anchor{#images} From ``Voyage dans la Lune'' by Georges Melies (1902): @float@@ -978,14 +1017,16 @@ @node Footnotes @chapter Footnotes-Here is a footnote reference@comma{}@footnote{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.@footnote{Here's the long note. This one contains multiple blocks.+@anchor{#footnotes}+Here is a footnote reference,@footnote{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.@footnote{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).+ @verbatim { <code> } @end verbatim -If you want@comma{} you can indent every line@comma{} but you can also be lazy and just indent the first line of each block.} This should @emph{not} be a footnote reference@comma{} because it contains a space.[^my note] Here is an inline note.@footnote{This is @emph{easier} to type. Inline notes may contain @uref{http://google.com,links} and @code{]} verbatim characters@comma{} as well as [bracketed text].}+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 @emph{not} be a footnote reference, because it contains a space.[^my note] Here is an inline note.@footnote{This is @emph{easier} to type. Inline notes may contain @uref{http://google.com,links} and @code{]} verbatim characters, as well as [bracketed text].} @quotation Notes can go in quotes.@footnote{In quote.}@@ -995,6 +1036,6 @@ And in list items.@footnote{In list.} @end enumerate -This paragraph should not be part of the note@comma{} as it is not indented.+This paragraph should not be part of the note, as it is not indented. @bye
@@ -2,31 +2,31 @@ <hr /> -h1. Headers+h1(#headers). Headers -h2. Level 2 with an "embedded link":/url+h2(#level-2-with-an-embedded-link). Level 2 with an "embedded link":/url -h3. Level 3 with _emphasis_+h3(#level-3-with-emphasis). Level 3 with _emphasis_ -h4. Level 4+h4(#level-4). Level 4 -h5. Level 5+h5(#level-5). Level 5 -h1. Level 1+h1(#level-1). Level 1 -h2. Level 2 with _emphasis_+h2(#level-2-with-emphasis). Level 2 with _emphasis_ -h3. Level 3+h3(#level-3). Level 3 with no blank line -h2. Level 2+h2(#level-2). Level 2 with no blank line <hr /> -h1. Paragraphs+h1(#paragraphs). Paragraphs Here's a regular paragraph. @@ -39,7 +39,7 @@ <hr /> -h1. Block Quotes+h1(#block-quotes). Block Quotes E-mail style: @@ -79,7 +79,7 @@ <hr /> -h1. Code Blocks+h1(#code-blocks). Code Blocks Code: @@ -103,9 +103,9 @@ <hr /> -h1. Lists+h1(#lists). Lists -h2. Unordered+h2(#unordered). Unordered Asterisks tight: @@ -143,7 +143,7 @@ * Minus 2 * Minus 3 -h2. Ordered+h2(#ordered). Ordered Tight: @@ -178,7 +178,7 @@ <li><p>Item 3.</p></li> </ol> -h2. Nested+h2(#nested). Nested * Tab ** Tab@@ -202,14 +202,14 @@ #* Foe # Third -h2. Tabs and spaces+h2(#tabs-and-spaces). 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 -h2. Fancy list markers+h2(#fancy-list-markers). Fancy list markers <ol start="2" style="list-style-type: decimal;"> <li>begins with 2</li>@@ -259,7 +259,7 @@ <hr /> -h1. Definition Lists+h1(#definition-lists). Definition Lists Tight using spaces: @@ -347,7 +347,7 @@ </dd> </dl> -h1. HTML Blocks+h1(#html-blocks). HTML Blocks Simple block on one line: @@ -464,7 +464,7 @@ <hr /> -h1. Inline Markup+h1(#inline-markup). Inline Markup This is _emphasized_, and so _is this_. @@ -492,7 +492,7 @@ <hr /> -h1. Smart quotes, ellipses, dashes+h1(#smart-quotes-ellipses-dashes). Smart quotes, ellipses, dashes "Hello," said the spider. "'Shelob' is my name." @@ -512,7 +512,7 @@ <hr /> -h1. LaTeX+h1(#latex). LaTeX * * <span class="math">2+2=4</math>@@ -535,7 +535,7 @@ <hr /> -h1. Special Characters+h1(#special-characters). Special Characters Here is some unicode: @@ -589,9 +589,9 @@ <hr /> -h1. Links+h1(#links). Links -h2. Explicit+h2(#explicit). Explicit Just a "URL":/url/. @@ -611,7 +611,7 @@ "Empty":. -h2. Reference+h2(#reference). Reference Foo "bar":/url/. @@ -638,7 +638,7 @@ Foo "biz":/url/. -h2. With ampersands+h2(#with-ampersands). With ampersands Here's a "link with an ampersand in the URL":http://example.com/?foo=1&bar=2. @@ -648,17 +648,17 @@ Here's an "inline link in pointy braces":/script?foo=1&bar=2. -h2. Autolinks+h2(#autolinks). Autolinks -With an ampersand: "http://example.com/?foo=1&bar=2":http://example.com/?foo=1&bar=2+With an ampersand: "$":http://example.com/?foo=1&bar=2 * In a list?-* "http://example.com/":http://example.com/+* "$":http://example.com/ * It should. -An e-mail address: "nobody@nowhere.net":mailto:nobody@nowhere.net+An e-mail address: "nobody@nowhere.net":mailto:nobody@nowhere.net -bq. Blockquoted: "http://example.com/":http://example.com/+bq. Blockquoted: "$":http://example.com/ @@ -669,7 +669,7 @@ <hr /> -h1. Images+h1(#images). Images From "Voyage dans la Lune" by Georges Melies (1902): @@ -680,7 +680,7 @@ <hr /> -h1. Footnotes+h1(#footnotes). Footnotes Here is a footnote reference,[1] and another.[2] This should _not_ be a footnote reference, because it contains a space.[^my note] Here is an inline note.[3]