diff -Nru pandoc-1.5.1.1/Benchmark.hs pandoc-1.8.0.3/Benchmark.hs --- pandoc-1.5.1.1/Benchmark.hs 1970-01-01 00:00:00.000000000 +0000 +++ pandoc-1.8.0.3/Benchmark.hs 2011-02-05 18:48:07.000000000 +0000 @@ -0,0 +1,45 @@ +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 + diff -Nru pandoc-1.5.1.1/changelog pandoc-1.8.0.3/changelog --- pandoc-1.5.1.1/changelog 2010-03-29 14:24:56.000000000 +0000 +++ pandoc-1.8.0.3/changelog 2011-02-05 18:48:07.000000000 +0000 @@ -1,3 +1,603 @@ +pandoc (1.8.0.3) + + * Fixed Source-repository stanza in cabal file. + +pandoc (1.8.0.2) + + * HTML writer: + + + Stringify alt text instead of converting to HTML. + + Break lines after block elements, not inside tags. + HTML output now closely resembles that of tidy. Resolves Issue #134. + + * Markdown reader: Fixed bug in footnote block parser (pointed out + by Jesse Rosenthal). The problem arose when the blank line + at the end of a footnote block contained indenting spaces. + + * Shared: Improved 'normalize' function so it normalizes Spaces too. + In normal form, Space elements only occur to separate two non-Space + elements. So, we never have [Space], or [, ..., Space]. + + * Tests: + + + Improved Arbitrary instance. + + Added timeout for test instances. + + * README: + + + Added section on four-space rule for lists. Resolves Issue #283. + + Clarified optional arguments on math options. + + * markdown2pdf: Fixed bug with output file extensions. + Previously `markdown2pdf test.txt -o test.en.pdf` would produce + `test.pdf`, not `test.en.pdf`. Thanks to Paolo Tanimoto for the fix. + +pandoc (1.8.0.1) + + * Revised Interact.hs so that it works with the CPP macros + in the UTF8 module. + + * Revised Setup.hs so that we don't call MakeManPage.hs unless + the man pages are out of date. + +pandoc (1.8) + + [new features] + + * Support for citations using Andrea Rossato's `citeproc-hs` 0.3. + You can now write, for example, + + Water is wet [see @doe99, pp. 33-35; also @smith04, ch. 1]. + + and, when you process your document using `pandoc`, specifying + a citation style using `--csl` and a bibliography using `--bibliography`, + the citation will be replaced by an appropriately formatted + citation, and a list of works cited will be added to the end + of the document. + + This means that you can switch effortlessly between different citation + and bibliography styles, including footnote, numerical, and author-date + formats. The bibliography can be in any of the following formats: MODS, + BibTeX, BibLaTeX, RIS, EndNote, EndNote XML, ISI, MEDLINE, Copac, or JSON. + See the README for further details. + + Citations are supported in the markdown reader, using a special + syntax, and in the LaTeX reader, using natbib or biblatex syntax. + (Thanks to Nathan Gass for the natbib and biblatex support.) + + * New `textile` reader and writer. Thanks to Paul Rivier for contributing + the `textile` reader, an almost complete implementation of the textile + syntax used by the ruby [RedCloth library](http://redcloth.org/textile). + Resolves Issue #51. + + * New `org` writer, for Emacs Org-mode, contributed by Puneeth Chaganti. + + * New `json` reader and writer, for reading and writing a JSON + representation of the native Pandoc AST. These are much faster + than the `native` reader and writer, and should be used for + serializing Pandoc to text. To convert between the JSON representation + and native Pandoc, use `encodeJSON` and `decodeJSON` from + `Text.JSON.Generic`. + + * A new `jsonFilter` function in `Text.Pandoc` makes it easy + to write scripts that transform a JSON-encoded pandoc document. + For example: + + -- removelinks.hs - removes links from document + import Text.Pandoc + main = interact $ jsonFilter $ bottomUp removeLink + where removeLink (Link xs _) = Emph xs + removeLink x = x + + To use this to remove links while translating markdown to LaTeX: + + pandoc -t json | runghc removelinks.hs | pandoc -f json -t latex + + * Attributes are now allowed in inline `Code` elements, for example: + + In this code, `ulist ! [theclass "special"] << elts`{.haskell} is... + + The attribute syntax is the same as for delimited code blocks. + `Code` inline has an extra argument place for attributes, just like + `CodeBlock`. Inline code will be highlighted in HTML output, if pandoc + is compiled with highlighting support. Resolves Issue #119. + + * New `RawBlock` and `RawInline` elements (replacing `RawHtml`, + `HtmlInline`, and `TeX`) provide lots of flexibility in writing + scripts to transform Pandoc documents. Scripts can now change + how each element is rendered in each output format. + + * You can now define LaTeX macros in markdown documents, and pandoc + will apply them to TeX math. For example, + + \newcommand{\plus}[2]{#1 + #2} + $\plus{3}{4}$ + + yields `3+4`. Since the macros are applied in the reader, they + will work in every output format, not just LaTeX. + + * LaTeX macros can also be used in LaTeX documents (both in math + and in non-math contexts). + + * A new `--mathjax` option has been added for displaying + math in HTML using MathJax. Resolves issue #259. + + * Footnotes are now supported in the RST reader. (Note, however, + that unlike docutils, pandoc ignores the numeral or symbol used in + the note; footnotes are put in an auto-numbered ordered list.) + Resolves Issue #258. + + * A new `--normalize` option causes pandoc to normalize the AST + before writing the document. This means that, for example, + `*hi**there*` will be rendered as `hithere` + instead of `hithere`. This is not the default, + because there is a significant performance penalty. + + * A new `--chapters` command-line option causes headers + in DocBook, LaTeX, and ConTeXt to start with "chapter" (level one). + Resolves Issue #265. + + * In DocBook output, `` is now used for top-level + headers if the template contains ``. Resolves Issue #265. + + * A new `--listings` option in `pandoc` and `markdown2pdf` causes + the LaTeX writer to use the listings package for code blocks. + (Thanks to Josef Svennigsson for the pandoc patch, and Etienne + Millon for the markdown2pdf patch.) + + * `markdown2pdf` now supports `--data-dir`. + + * URLs in autolinks now have class "url" so they can be styled. + + * Improved prettyprinting in most formats. Lines will be wrapped + more evenly and duplicate blank lines avoided. + + * New `--columns` command-line option sets the column width for + line wrapping and relative width calculations for tables. + + * Made `--smart` work in HTML, RST, and Textile readers, as well + as markdown. + + * Added `--html5` option for HTML5 output. + + * Added support for listings package in LaTeX reader + (Puneeth Chaganti). + + * Added support for simple tables in the LaTeX reader. + + * Added support for simple tables in the HTML reader. + + * Significant performance improvements in many readers and writers. + + [API and program changes] + + * Moved `Text.Pandoc.Definition` from the `pandoc` package to a new + auxiliary package, `pandoc-types`. This will make it possible for other + programs to supply output in Pandoc format, without depending on the whole + pandoc package. + + * Added `Attr` field to `Code`. + + * Removed `RawHtml`, `HtmlInline`, and `TeX` elements; added generic + `RawBlock` and `RawInline`. + + * Moved generic functions to `Text.Pandoc.Generic`. Deprecated + `processWith`, replacing it with two functions, `bottomUp` and `topDown`. + Removed previously deprecated functions `processPandoc` and `queryPandoc`. + + * Added `Text.Pandoc.Builder`, for building `Pandoc` structures. + + * `Text.Pandoc` now exports association lists `readers` and `writers`. + + * Added `Text.Pandoc.Readers.Native`, which exports `readNative`. + `readNative` can now read full pandoc documents, block lists, blocks, + inline lists, or inlines. It will interpret `Str "hi"` + as if it were `Pandoc (Meta [] [] []) [Plain [Str "hi"]]`. + This should make testing easier. + + * Removed deprecated `-C/--custom-header` option. + Use `--template` instead. + + * `--biblio-file` has been replaced by `--bibliography`. + `--biblio-format` has been removed; pandoc now guesses the format + from the file extension (see README). + + * pandoc will treat an argument as a URI only if it has an + `http(s)` scheme. Previously pandoc would treat some + Windows pathnames beginning with `C:/` as URIs. + + * The `--sanitize-html` option and the `stateSanitize` field in + `ParserState` have been removed. Sanitization is better done in the + resulting HTML using `xss-sanitize`, which is based on pandoc's + sanitization, but improved. + + * pandoc now adds a newline to the end of its output in fragment + mode (= not `--standalone`). + + * Added support for `lang` in `html` tag in the HTML template, + so you can do `pandoc -s -V lang=es`, for example. + + * `highlightHtml` in `Text.Pandoc.Highlighting` now takes + a boolean argument that selects between "inline" and + "block" HTML. + + * `Text.Pandoc.Writers.RTF` now exports `rtfEmbedImage`. + Images are embedded in RTF output when possible (png, jpeg). + Resolves Issue #275. + + * Added `Text.Pandoc.Pretty`. This is better suited for pandoc than the + `pretty` package. Changed all writers that used + `Text.PrettyPrint.HughesPJ` to use `Text.Pandoc.Pretty` instead. + + * Rewrote `writeNative` using the new prettyprinting module. It is + now much faster. The output has been made more consistent and compressed. + `writeNative` is also now sensitive to writerStandalone`, and will simply + `print a block list if writerStandalone` is False. + + * Removed `Text.Pandoc.Blocks`. `Text.Pandoc.Pretty` allows you to define + blocks and concatenate them, so a separate module is no longer needed. + + * `Text.Pandoc.Shared`: + + + Added `writerColumns`, `writerChapters`, and `writerHtml5` to + `WriterOptions`. + + Added `normalize`. + + Removed unneeded prettyprinting functions: + `wrapped`, `wrapIfNeeded`, `wrappedTeX`, `wrapTeXIfNeeded`, `hang'`, + `BlockWrapper`, `wrappedBlocksToDoc`. + + Made `splitBy` take a test instead of an element. + + Added `findDataFile`, refactored `readDataFile`. + + Added `stringify`. Rewrote `inlineListToIdentifier` using `stringify`. + + Fixed `inlineListToIdentifier` to treat '\160' as ' '. + + * `Text.Pandoc.Readers.HTML`: + + + Removed `rawHtmlBlock`, `anyHtmlBlockTag`, `anyHtmlInlineTag`, + `anyHtmlTag`, `anyHtmlEndTag`, `htmlEndTag`, `extractTagType`, + `htmlBlockElement`, `htmlComment` + + Added `htmlTag`, `htmlInBalanced`, `isInlineTag`, `isBlockTag`, + `isTextTag` + + * Moved `smartPunctuation` from `Text.Pandoc.Readers.Markdown` + to `Text.Pandoc.Readers.Parsing`, and parameterized it with + an inline parser. + + * Ellipses are no longer allowed to contain spaces. + Previously we allowed '. . .', ' . . . ', etc. This caused + too many complications, and removed author's flexibility in + combining ellipses with spaces and periods. + + * Allow linebreaks in URLs (treat as spaces). Also, a string of + consecutive spaces or tabs is now parsed as a single space. If you have + multiple spaces in your URL, use `%20%20`. + + * `Text.Pandoc.Parsing`: + + + Removed `refsMatch`. + + Hid `Key` constructor. + + Removed custom `Ord` and `Eq` instances for `Key`. + + Added `toKey` and `fromKey` to convert between `Key` and `[Inline]`. + + Generalized type on `readWith`. + + * Small change in calculation of relative widths of table columns. + If the size of the header > the specified column width, use + the header size as 100% for purposes of calculating + relative widths of columns. + + * Markdown writer now uses some pandoc-specific features when `--strict` + is not specified: `\` newline is used for a hard linebreak instead of + two spaces then a newline. And delimited code blocks are used when + there are attributes. + + * HTML writer: improved gladTeX output by setting ENV appropriately + for display or inline math (Jonathan Daugherty). + + * LaTeX writer: Use `\paragraph`, `\subparagraph` for level 4,5 headers. + + * LaTeX reader: + + + `\label{foo}` and `\ref{foo}` now become `{foo}` instead of `(foo)`. + + `\index{}` commands are skipped. + + * Added `fontsize` variable to default LaTeX template. + This makes it easy to set the font size using `markdown2pdf`: + `markdown2pdf -V fontsize=12pt input.txt`. + + * Fixed problem with strikeout in LaTeX headers when using + hyperref, by adding a command to the default LaTeX template + that disables `\sout` inside pdf strings. Thanks to Joost Kremers + for the fix. + + * The `COLUMNS` environment variable no longer has any effect. + + [under-the-hood improvements] + + * Pandoc now compiles with GHC 7. (This alone leads to a + significant performance improvement, 15-20%.) + + * Completely rewrote HTML reader using tagsoup as a lexer. The + new reader is faster and more accurate. Unlike the + old reader, it does not get bogged down on some input + (Issues #277, 255). And it handles namespaces in tags + (Issue #274). + + * Replaced `escapeStringAsXML` with a faster version. + + * Rewrote `spaceChar` and some other parsers in Text.Pandoc.Parsing + for a significant performance boost. + + * Improved performance of all readers by rewriting parsers. + + * Simplified Text.Pandoc.CharacterReferences by using + entity lookup functions from TagSoup. + + * `Text.Pandoc.UTF8` now uses the unicode-aware IO functions + from `System.IO` if base >= 4.2. This gives support for + windows line endings on windows. + + * Remove duplications in documentation by generating the + pandoc man page from README, using `MakeManPage.hs`. + + * README now includes a full description of markdown syntax, + including non-pandoc-specific parts. A new `pandoc_markdown` + man page is extracted from this, so you can look up markdown + syntax by doing `man pandoc_markdown`. + + * Completely revised test framework (with help from Nathan Gass). + The new test framework is built when the `tests` Cabal flag is set. It + includes the old integration tests, but also some new unit and quickcheck + tests. Test output has been much improved, and you can now specify a glob + pattern after `cabal test` to indicate which tests should be run; + for example `cabal test citations` will run all the citation tests. + + * Added a shell script, `stripansi.sh`, for filtering ANSI control + sequences from test output: `cabal test | ./stripansi.sh > test.log`. + + * Added `Interact.hs` to make it easier to use ghci while developing. + `Interact.hs` loads `ghci` from the `src` directory, specifying + all the options needed to load pandoc modules (including + specific package dependencies, which it gets by parsing + dist/setup-config). + + * Added `Benchmark.hs`, testing all readers + writers using criterion. + + * Added `stats.sh`, to make it easier to collect and archive + benchmark and lines-of-code stats. + + * Added upper bounds to all cabal dependencies. + + * Include man pages in extra-source-files. This allows users to + install pandoc from the tarball without needing to build the man + pages. + + [bug fixes] + + * Filenames are encoded as UTF8. Resolves Issue #252. + + * Handle curly quotes better in `--smart` mode. Previously, curly quotes + were just parsed literally, leading to problems in some output formats. + Now they are parsed as `Quoted` inlines, if `--smart` is specified. + Resolves Issue #270. + + * Text.Pandoc.Parsing: Fixed bug in grid table parser. + Spaces at end of line were not being stripped properly, + resulting in unintended LineBreaks. + + * Markdown reader: + + + Allow HTML comments as inline elements in markdown. + So, `aaa bbb` can be a single paragraph. + + Fixed superscripts with links: `^[link](/foo)^` gets + recognized as a superscripted link, not an inline note followed by + garbage. + + Fixed regression, making markdown reference keys case-insensitive again. + Resolves Issue #272. + + Properly handle abbreviations (like `Mr.`) at the end of a line. + + Better handling of intraword underscores, avoiding exponential + slowdowns in some cases. Resolves Issue #182. + + Fixed bug in alignments in tables with blank rows in the header. + + * RST reader: + + + Field lists now allow spaces in field names, and + block content in field values. (Thanks to Lachlan Musicman + for pointing out the bug.) + + Definition list items are now always `Para` instead of + `Plain`, matching behavior of `rst2xml.py`. + + In image blocks, the description is parsed properly and + used for the alt attribute, not also the title. + + Skip blank lines at beginning of file. Resolves + Debian #611328. + + * LaTeX reader: + + + Improved parsing of preamble. + Previously you'd get unexpected behavior on a document that + contained `\begin{document}` in, say, a verbatim block. + + Allow spaces between `\begin` or `\end` and `{`. + + Support `\L` and `\l`. + + Skip comments inside paragraphs. + + * LaTeX writer: + + + Escape strings in `\href{..}`. + + In nonsimple tables, put cells in `\parbox`. + + * OpenDocument writer: don't print raw TeX. + + * Markdown writer: + + + Fixed bug in `Image`. URI was getting unescaped twice! + + Avoid printing extra blank lines at the end if there are + no notes or references. + + * LaTeX and ConTeXt: Escape `[` and `]` as `{[}` and `{]}`. + This avoids unwanted interpretation as an optional argument. + + * ConTeXt writer: Fixed problem with inline code. Previously + `}` would be rendered `\type{}}`. Now we check the string for '}' and '{'. + If it contains neither, use `\type{}`; otherwise use `\mono{}` + with an escaped version of the string. + + * `:` now allowed in HTML tags. Resolves Issue #274. + +pandoc (1.6) + + [ John MacFarlane ] + + * New EPUB and HTML Slidy writers. (Issue #122) + + - EPUB is a standard ebook format, used in Apple's iBooks for + the iPad and iPhone, Barnes and Noble's nook reader, the Sony + reader, and many other devices. + - Slidy, like S5, is a system for producing HTML+javascript slide + shows. + + * All input is assumed to be UTF-8, no matter what the locale and ghc + version, and all output is UTF-8. This reverts to pre-1.5 behavior. + Also, a BOM, if present, is stripped from the input. + + * Markdown now supports grid tables, whose cells can contain + arbitrary block elements. (Issue #43) + + * Sequentially numbered example lists in markdown with `@` marker. + + * Markdown table captions can begin with a bare colon and no longer need + to include the English word "table." Also, a caption can now occur + either before or after the table. (Issue #227) + + * New command-line options: + + - `--epub-stylesheet` allows you to specify a CSS file that will + be used to style your ebook. + - `--epub-metadata` allows you to specify metadata for the ebook. + - `--offline` causes the generated HTML slideshow to include all + needed scripts and stylesheets. + - `--webtex` causes TeX math to be converted to images using the + Google Charts API (unless a different URL is specified). + - `--section-divs` causes div tags to be added around each section + in an HTML document. (Issue #230, 239) + + * Default behavior of S5 writer in standalone mode has changed: + previously, it would include all needed scripts and stylesheets + in the generated HTML; now, only links are included unless + the `--offline` option is used. + + * Default behavior of HTML writer has changed. Between 1.2 and 1.5, + pandoc would enclose sections in div tags with identifiers on the + div tags, so that the sections can be manipulated in javascript. + This caused undesirable interactions with raw HTML div tags. So, + starting with 1.6, the default is to put the identifiers directly + on the header tags, and not to include the divs. The `--section-divs` + option selects the 1.2-1.5 behavior. + + * API changes: + + - `HTMLMathMethod`: Added `WebTeX`, removed `MimeTeX`. + - `WriterOptions`: Added `writerUserDataDir`, `writerSourceDirectory`, + `writerEPUBMetadata` fields. Removed `writerIncludeBefore`, + `writerIncludeAfter`. + - Added `headerShift` to `Text.Pandoc.Shared`. + - Moved parsing code and `ParserState` from `Text.Pandoc.Shared` + to a new module, `Text.Pandoc.Parsing`. + - Added `stateHasChapters` to `ParserState`. + - Added `HTMLSlideVariant`. + - Made `KeyTable` a map instead of an association list. + - Added accessors for `Meta` fields (`docTitle`, `docAuthors`, + `docDate`). + - `Pandoc`, `Meta`, `Inline`, and `Block` have been given `Ord` + instances. + - Reference keys now have a type of their own (`Key`), with its + own `Ord` instance for case-insensitive comparison. + - Added `Text.Pandoc.Writers.EPUB`. + - Added `Text.Pandoc.UUID`. + - Removed `Text.Pandoc.ODT`, added `Text.Pandoc.Writers.ODT`. + Removed `saveOpenDocumentAsODT`, added `writeODT`. + - Added `Text.Pandoc.Writers.Native` and `writeNative`. + Removed `prettyPandoc`. + - Added `Text.Pandoc.UTF8` for portable UTF8 string IO. + - Removed `Text.Pandoc.Writers.S5` and the `writeS5` function. + Moved `s5Includes` to a new module, `Text.Pandoc.S5`. + To write S5, you now use `writeHtml` with `writerSlideVariant` + set to `S5Slides` or `SlidySlides`. + + * Template changes. If you use custom templates, please update them, + particularly if you use syntax highlighting with pandoc. The old HTML + templates hardcoded highlighting CSS that will no longer work with + the most recent version of highlighting-kate. + + - HTML template: avoid empty meta tag if no date. + - HTML template: Use default highlighting CSS from highlighting-kate + instead of hard-coding the CSS into the template. + - HTML template: insert-before text goes before the title, and + immediately after the tag, as documented. (Issue #241) + - Added slidy and s5 templates. + - Added amssymb to preamble of latex template. (github Issue 1) + + * Removed excess newlines at the end of output. Note: because output + will not contain an extra newline, you may need to make adjustments + if you are inserting pandoc's output into a template. + + * In S5 and slidy, horizontal rules now cause a new slide, so you + are no longer limited to one slide per section. + + * Improved handling of code in man writer. Inline code is now monospace, + not bold, and code blocks now use .nf (no fill) and .IP (indented para). + + * HTML reader parses `` as Code. (Issue #247) + + * html+lhs output now contains bird tracks, even when compiled without + highlighting support. (Issue #242) + + * Colons are now no longer allowed in autogenerated XML/HTML identifiers, + since they have a special meaning in XML. + + * Code improvements in ODT writer. Remote images are now replaced with + their alt text rather than a broken link. + + * LaTeX reader improvements: + + - Made latex `\section`, `\chapter` parsers more forgiving of + whitespace. + - Parse `\chapter{}` in latex. + - Changed `rawLaTeXInline` to accept `\section`, `\begin`, etc. + - Use new `rawLaTeXInline'` in LaTeX reader, and export `rawLaTeXInline` + for use in markdown reader. + - Fixes bug wherein `\section{foo}` was not recognized as raw TeX + in markdown document. + + * LaTeX writer: images are automatically shrunk if they would extend + beyond the page margin. + + * Plain, markdown, RST writers now use unicode for smart punctuation. + + * Man writer converts math to unicode when possible, as in other writers. + + * `markdown2pdf` can now recognize citeproc options. + + * Command-line arguments are converted to UTF-8. (Issue #234) + + * `Text.Pandoc.TeXMath` has been rewritten to use texmath's parser. + This allows it to handle a wider range of formulas. Also, if a formula + cannot be converted, it is left in raw TeX; formulas are no longer + partially converted. + + * Unicode curly quotes are left alone when parsing smart quotes. (Issue + #143) + + * Cabal file changes: + + - Removed parsec < 3 restriction. + - Added 'threaded' flag for architectures where GHC lacks a threaded + runtime. + - Use 'threaded' only for markdown2pdf; it is not needed for pandoc. + - Require highlighting-kate 0.2.7. + + * Use explicit imports from `Data.Generics`. Otherwise we have a + conflict with the 'empty' symbol, introduced in syb >= 0.2. (Issue #237) + + * New data files: slidy/slidy.min.js, slidy/slidy.min.css, epub.css. + pandoc (1.5.1.1) [ John MacFarlane ] @@ -16,9 +616,9 @@ parsed text and the escaped URI (in the latter case, with the mailto: prefix). + HTML reader: unsanitaryURI has been modified to allow unicode - high characters in a URI. + high characters in a URI. + Readers: All link and image URIs are now escaped using - escapeURI. + escapeURI. + Markdown and RST writers: unescapeURI is used so that URIs in these formats are human-readable. @@ -245,13 +845,15 @@ Resolves Issue #199. * LaTeX writer: - + If book, report, or memoir documentclass, use \chapter{} + + + If book, report, or memoir documentclass, use \chapter{} for first-level headers. Otherwise use \section{}. + Removed stLink, link template variable. Reason: we now always include hyperref in the template. - * Latex template: - + Only show \author if there are some. + * LaTeX template: + + + Only show \author if there are some. + Always include hyperref package. It is used not just for links but for toc, section heading bookmarks, footnotes, etc. Also added unicode=true on hyperref options. diff -Nru pandoc-1.5.1.1/COPYRIGHT pandoc-1.8.0.3/COPYRIGHT --- pandoc-1.5.1.1/COPYRIGHT 2010-03-29 14:24:56.000000000 +0000 +++ pandoc-1.8.0.3/COPYRIGHT 2011-02-05 18:48:07.000000000 +0000 @@ -44,8 +44,20 @@ Released under the GPL. ---------------------------------------------------------------------- +src/Text/Pandoc/Writers/Org.hs +Copyright (C) 2010 Puneeth Chaganti + +Released under the GPL. + +---------------------------------------------------------------------- +src/Text/Pandoc/Readers/Textile.hs +Copyright (C) 2010 Paul Rivier + +Released under the GPL. + +---------------------------------------------------------------------- src/Text/Pandoc/Biblio.hs -Copyright (C) 2008 Andrea Rossato +Copyright (C) 2008-2010 Andrea Rossato Released under the GPL. diff -Nru pandoc-1.5.1.1/debian/changelog pandoc-1.8.0.3/debian/changelog --- pandoc-1.5.1.1/debian/changelog 2010-08-29 08:08:01.000000000 +0000 +++ pandoc-1.8.0.3/debian/changelog 2011-03-25 14:03:01.000000000 +0000 @@ -1,8 +1,38 @@ -pandoc (1.5.1.1-5build1) maverick; urgency=low +pandoc (1.8.0.3-1ubuntu1~ppa1) maverick; urgency=low - * No-change rebuild to pick up new library ABIs. + * PPA build. - -- Michael Bienia Sun, 29 Aug 2010 10:08:01 +0200 + -- Adam Buchbinder Fri, 25 Mar 2011 10:01:59 -0400 + +pandoc (1.8.0.3-1) UNRELEASED; urgency=low + + * New upstream release. + * Update copyright file format to DEP5 draft 166. + * Update long descriptions to mention newly supported formats and + features. + * Update copyright-check suppression hint to match recent CDBS + releases. + * Tighten and extend build-dependencies. + + -- Jonas Smedegaard Mon, 07 Feb 2011 03:26:55 +0100 + +pandoc (1.6-1) experimental; urgency=low + + * New upstream release. + * Drop patch 0001 now included upstream. + * Bump Policy compliance to Standards-Version 3.9.1. + * Tighten build-dependencies on libghc6-highlighting-kate-dev and + libghc6-texmath-dev. + * Sync long descriptions with upstream README: Mention new output + formats EPUB and Slidy. + * (Build-)depend on parsec3 packages (not parsec2). + * Ease building with git-buildpackage: + + Git-ignore (eventual) quilt .pc dir. + + Add dpkg-source local-options abort-on-upstream-changes and + unapply-patches. + * Rewrite copyright file using Bazaar rev. 137 draft of DEP5 format. + + -- Jonas Smedegaard Fri, 31 Dec 2010 17:12:44 +0100 pandoc (1.5.1.1-5) unstable; urgency=low diff -Nru pandoc-1.5.1.1/debian/control pandoc-1.8.0.3/debian/control --- pandoc-1.5.1.1/debian/control 2010-06-29 18:58:50.000000000 +0000 +++ pandoc-1.8.0.3/debian/control 2011-03-25 13:51:18.000000000 +0000 @@ -4,30 +4,58 @@ Maintainer: Jonas Smedegaard Build-Depends: cdbs (>= 0.4.70~), devscripts (>= 2.10.7~), - dh-buildinfo, debhelper (>= 6), + dh-buildinfo, ghc6 (>= 6.8.2), - libghc6-mtl-dev, - libghc6-parsec2-dev (>= 2.1), - libghc6-network-dev, + libghc6-syb-dev, + libghc6-parsec3-dev (>= 2.1), + libghc6-parsec3-dev (<< 3.2), + libghc6-xhtml-dev (>= 3000.0), + libghc6-xhtml-dev (<< 3000.3), + libghc6-mtl-dev (>= 1.1), + libghc6-mtl-dev (<< 1.2), + libghc6-network-dev (>= 2), + libghc6-network-dev (<< 2.4), + libghc6-filepath-dev, + libghc6-process-dev, + libghc6-directory-dev, + libghc6-bytestring-dev, + libghc6-zip-archive-dev (>= 0.1.1.7), + libghc6-zip-archive-dev (<< 0.2), libghc6-utf8-string-dev, - libghc6-xhtml-dev, - libghc6-zip-archive-dev (>= 0.1.1.4), + libghc6-old-time-dev, libghc6-http-dev (>= 40000005), - libghc6-texmath-dev, + libghc6-http-dev (<< 40000200), + libghc6-texmath-dev (>= 0.5), + libghc6-texmath-dev (<< 0.6), libghc6-xml-dev (>= 1.3.5), libghc6-xml-dev (<< 1.4), + libghc6-random-dev, libghc6-extensible-exceptions-dev, - libghc6-highlighting-kate-dev (>= 0.2.3), + libghc6-citeproc-hs-dev (>= 0.3.1), + libghc6-citeproc-hs-dev (<< 0.4), + libghc6-pandoc-types-dev (>= 1.8), + libghc6-pandoc-types-dev (<< 1.9), + libghc6-json-dev (>= 0.4), + libghc6-json-dev (<< 0.5), + libghc6-dlist-dev (>= 0.4), + libghc6-dlist-dev (<< 0.6), + libghc6-tagsoup-dev (>= 0.12), + libghc6-tagsoup-dev (<< 0.13), + libghc6-highlighting-kate-dev (>= 0.2.9), + libghc6-highlighting-kate-dev (<< 0.3), + libghc6-diff-dev, + libghc6-testpack-dev, + libghc6-template-haskell-dev, hscolour (>= 1.8), ghc6-doc (>= 6.8.2), - libghc6-highlighting-kate-doc (>= 0.2.3), + libghc6-highlighting-kate-doc (>= 0.2.9), libghc6-xhtml-doc, - libghc6-parsec2-doc (>= 2.1), + libghc6-parsec3-doc (>= 2.1), haskell-pcre-light-doc, haskell-devscripts (>=0.5.12) Build-Depends-Indep: haddock -Standards-Version: 3.9.0 +Standards-Version: 3.9.1 Homepage: http://johnmacfarlane.net/pandoc/ Vcs-Git: git://git.debian.org/git/collab-maint/pandoc.git Vcs-Browser: http://git.debian.org/?p=collab-maint/pandoc.git;a=summary @@ -43,14 +71,14 @@ markdown and (subsets of) reStructuredText, HTML, and LaTeX; and it can write plain text, markdown, reStructuredText, HTML, LaTeX, ConTeXt, RTF, DocBook XML, OpenDocument XML, ODT, GNU Texinfo, MediaWiki markup, - groff man pages, and S5 HTML slide shows. + EPUB, Textile, groff man pages, Emacs Org-mode, and Slidy or S5 HTML + slide shows. . Pandoc's enhanced version of markdown includes syntax for footnotes, tables, flexible ordered lists, definition lists, delimited code blocks, superscript, subscript, strikeout, title blocks, automatic - tables of contents, embedded LaTeX math, and markdown inside HTML block - elements. (These enhancements can be disabled if a drop-in replacement - for `Markdown.pl` is desired.) + tables of contents, embedded LaTeX math, citations, and markdown inside + HTML block elements. (These enhancements can optionally be disabled.) . In contrast to most existing tools for converting markdown to HTML, which use regex substitutions, Pandoc has a modular design: it consists @@ -75,14 +103,14 @@ markdown and (subsets of) reStructuredText, HTML, and LaTeX; and it can write plain text, markdown, reStructuredText, HTML, LaTeX, ConTeXt, RTF, DocBook XML, OpenDocument XML, ODT, GNU Texinfo, MediaWiki markup, - groff man pages, and S5 HTML slide shows. + EPUB, Textile, groff man pages, Emacs Org-mode, and Slidy or S5 HTML + slide shows. . Pandoc's enhanced version of markdown includes syntax for footnotes, tables, flexible ordered lists, definition lists, delimited code blocks, superscript, subscript, strikeout, title blocks, automatic - tables of contents, embedded LaTeX math, and markdown inside HTML block - elements. (These enhancements can be disabled if a drop-in replacement - for `Markdown.pl` is desired.) + tables of contents, embedded LaTeX math, citations, and markdown inside + HTML block elements. (These enhancements can optionally be disabled.) . In contrast to most existing tools for converting markdown to HTML, which use regex substitutions, Pandoc has a modular design: it consists @@ -104,14 +132,14 @@ markdown and (subsets of) reStructuredText, HTML, and LaTeX; and it can write plain text, markdown, reStructuredText, HTML, LaTeX, ConTeXt, RTF, DocBook XML, OpenDocument XML, ODT, GNU Texinfo, MediaWiki markup, - groff man pages, and S5 HTML slide shows. + EPUB, Textile, groff man pages, Emacs Org-mode, and Slidy or S5 HTML + slide shows. . Pandoc's enhanced version of markdown includes syntax for footnotes, tables, flexible ordered lists, definition lists, delimited code blocks, superscript, subscript, strikeout, title blocks, automatic - tables of contents, embedded LaTeX math, and markdown inside HTML block - elements. (These enhancements can be disabled if a drop-in replacement - for `Markdown.pl` is desired.) + tables of contents, embedded LaTeX math, citations, and markdown inside + HTML block elements. (These enhancements can optionally be disabled.) . In contrast to most existing tools for converting markdown to HTML, which use regex substitutions, Pandoc has a modular design: it consists diff -Nru pandoc-1.5.1.1/debian/control.in pandoc-1.8.0.3/debian/control.in --- pandoc-1.5.1.1/debian/control.in 2010-06-29 18:58:35.000000000 +0000 +++ pandoc-1.8.0.3/debian/control.in 2011-03-25 13:51:18.000000000 +0000 @@ -4,7 +4,7 @@ Maintainer: Jonas Smedegaard Build-Depends: @cdbs@ Build-Depends-Indep: haddock -Standards-Version: 3.9.0 +Standards-Version: 3.9.1 Homepage: http://johnmacfarlane.net/pandoc/ Vcs-Git: git://git.debian.org/git/collab-maint/pandoc.git Vcs-Browser: http://git.debian.org/?p=collab-maint/pandoc.git;a=summary @@ -20,14 +20,14 @@ markdown and (subsets of) reStructuredText, HTML, and LaTeX; and it can write plain text, markdown, reStructuredText, HTML, LaTeX, ConTeXt, RTF, DocBook XML, OpenDocument XML, ODT, GNU Texinfo, MediaWiki markup, - groff man pages, and S5 HTML slide shows. + EPUB, Textile, groff man pages, Emacs Org-mode, and Slidy or S5 HTML + slide shows. . Pandoc's enhanced version of markdown includes syntax for footnotes, tables, flexible ordered lists, definition lists, delimited code blocks, superscript, subscript, strikeout, title blocks, automatic - tables of contents, embedded LaTeX math, and markdown inside HTML block - elements. (These enhancements can be disabled if a drop-in replacement - for `Markdown.pl` is desired.) + tables of contents, embedded LaTeX math, citations, and markdown inside + HTML block elements. (These enhancements can optionally be disabled.) . In contrast to most existing tools for converting markdown to HTML, which use regex substitutions, Pandoc has a modular design: it consists @@ -52,14 +52,14 @@ markdown and (subsets of) reStructuredText, HTML, and LaTeX; and it can write plain text, markdown, reStructuredText, HTML, LaTeX, ConTeXt, RTF, DocBook XML, OpenDocument XML, ODT, GNU Texinfo, MediaWiki markup, - groff man pages, and S5 HTML slide shows. + EPUB, Textile, groff man pages, Emacs Org-mode, and Slidy or S5 HTML + slide shows. . Pandoc's enhanced version of markdown includes syntax for footnotes, tables, flexible ordered lists, definition lists, delimited code blocks, superscript, subscript, strikeout, title blocks, automatic - tables of contents, embedded LaTeX math, and markdown inside HTML block - elements. (These enhancements can be disabled if a drop-in replacement - for `Markdown.pl` is desired.) + tables of contents, embedded LaTeX math, citations, and markdown inside + HTML block elements. (These enhancements can optionally be disabled.) . In contrast to most existing tools for converting markdown to HTML, which use regex substitutions, Pandoc has a modular design: it consists @@ -81,14 +81,14 @@ markdown and (subsets of) reStructuredText, HTML, and LaTeX; and it can write plain text, markdown, reStructuredText, HTML, LaTeX, ConTeXt, RTF, DocBook XML, OpenDocument XML, ODT, GNU Texinfo, MediaWiki markup, - groff man pages, and S5 HTML slide shows. + EPUB, Textile, groff man pages, Emacs Org-mode, and Slidy or S5 HTML + slide shows. . Pandoc's enhanced version of markdown includes syntax for footnotes, tables, flexible ordered lists, definition lists, delimited code blocks, superscript, subscript, strikeout, title blocks, automatic - tables of contents, embedded LaTeX math, and markdown inside HTML block - elements. (These enhancements can be disabled if a drop-in replacement - for `Markdown.pl` is desired.) + tables of contents, embedded LaTeX math, citations, and markdown inside + HTML block elements. (These enhancements can optionally be disabled.) . In contrast to most existing tools for converting markdown to HTML, which use regex substitutions, Pandoc has a modular design: it consists diff -Nru pandoc-1.5.1.1/debian/copyright pandoc-1.8.0.3/debian/copyright --- pandoc-1.5.1.1/debian/copyright 2010-05-26 20:30:53.000000000 +0000 +++ pandoc-1.8.0.3/debian/copyright 2011-03-25 13:51:18.000000000 +0000 @@ -1,48 +1,59 @@ -Format-Specification: http://svn.debian.org/wsvn/dep/web/deps/dep5.mdwn?rev=135 -Name: pandoc -Maintainer: John MacFarlane +Format: http://svn.debian.org/wsvn/dep/web/deps/dep5.mdwn?rev=162 +Upstream-Name: pandoc +Upstream-Contact: John MacFarlane Source: http://code.google.com/p/pandoc/downloads/list -Copyright: 2006-2010, John MacFarlane +Files: * +Copyright: 2006-2011, John MacFarlane License: GPL-2+ -Files: ./data/LaTeXMathML.js, - ./data/MathMLinHTML.js, - ./tests/s5.fancy.html +Files: data/LaTeXMathML.js + data/MathMLinHTML.js + tests/s5.fancy.html Copyright: 2005, Peter Jipsen License: GPL-2+ -Files: ./src/Text/Pandoc/Biblio.hs +Files: src/Text/Pandoc/Biblio.hs Copyright: 2008, Andrea Rossato License: GPL-2+ -Files: ./src/Text/Pandoc/Writers/OpenDocument.hs +Files: src/Text/Pandoc/Writers/Org.hs +Copyright: 2006-2010, Puneeth Chaganti +License: GPL-2+ + +Files: src/Text/Pandoc/Readers/Textile.hs +Copyright: 2010-2011, Paul Rivier + 2010-2011, John MacFarlane +License: GPL-2+ + FIXME + +Files: src/Text/Pandoc/Writers/OpenDocument.hs Copyright: 2008-2010, Andrea Rossato - 2008-2010, John MacFarlane + 2008-2010, John MacFarlane License: GPL-2+ -Files: ./src/Text/Pandoc/Writers/Texinfo.hs +Files: src/Text/Pandoc/Writers/Texinfo.hs Copyright: 2008-2010, John MacFarlane - 2008-2010, Peter Wang + 2008-2010, Peter Wang License: GPL-2+ -Files: ./tests/movie.jpg +Files: tests/movie.jpg Copyright: none -License: other-PD +License: PD This art is in the public domai -Files: ./tests/Diff.hs +Files: tests/Diff.hs Copyright: 2008, Sterling Clover -License: BSD +License: BSD-3-clause BSD 3 Clause -Files: ./data/ui/default/s5-core.css, - ./data/ui/default/slides.js.* +Files: data/ui/default/s5-core.css + data/ui/default/slides.js.* Copyright: none -License: other-PD +License: PD released into the Public Domain -Files: ./debian/* +Files: debian/* Copyright: 2006-2010, John MacFarlane 2007-2008, Recai Oktaş 2008-2010, Jonas Smedegaard @@ -50,15 +61,15 @@ License: GPL-2+ This file 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. + 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. - . +Comment: On Debian systems, the complete text of the GNU General Public License (GPL) version 2 can be found an 2/usr/share/common-licenses/GPL-2". . diff -Nru pandoc-1.5.1.1/debian/copyright_hints pandoc-1.8.0.3/debian/copyright_hints --- pandoc-1.5.1.1/debian/copyright_hints 2010-05-26 20:30:53.000000000 +0000 +++ pandoc-1.8.0.3/debian/copyright_hints 2011-03-25 13:51:18.000000000 +0000 @@ -1,264 +1,336 @@ -Format-Specification: http://svn.debian.org/wsvn/dep/web/deps/dep5.mdwn?rev=135 -X-Draft: Autogenerated by CDBS snippet copyright-check.mk - -Files: ./BUGS, - ./INSTALL, - ./Setup.hs, - ./debian/NEWS, - ./debian/README.source, - ./debian/TODO, - ./debian/compat, - ./debian/control, - ./debian/control.in, - ./debian/gbp.conf, - ./debian/hsmarkdown.1, - ./debian/libghc6-pandoc-doc.doc-base, - ./debian/pandoc.README.Debian, - ./debian/pandoc.install.in, - ./debian/pandoc.links, - ./debian/patches/0001_threaded.patch, - ./debian/patches/README, - ./debian/patches/series, - ./debian/rules, - ./debian/source/format, - ./debian/watch, - ./man/man1/markdown2pdf.1.md, - ./man/man1/pandoc.1.md, - ./markdown2pdf, - ./s5/default/framing.css, - ./s5/default/opera.css, - ./s5/default/outline.css, - ./s5/default/pretty.css, - ./s5/default/print.css, - ./s5/default/s5-core.css, - ./s5/default/slides.js.comment, - ./s5/default/slides.js.packed, - ./src/markdown2pdf.hs, - ./templates/context.template, - ./templates/docbook.template, - ./templates/html.template, - ./templates/latex.template, - ./templates/man.template, - ./templates/markdown.template, - ./templates/mediawiki.template, - ./templates/opendocument.template, - ./templates/plain.template, - ./templates/rst.template, - ./templates/rtf.template, - ./templates/texinfo.template, - ./tests/RunTests.hs, - ./tests/insert, - ./tests/latex-reader.latex, - ./tests/lhs-test.fragment.html+lhs, - ./tests/lhs-test.html, - ./tests/lhs-test.html+lhs, - ./tests/lhs-test.latex, - ./tests/lhs-test.latex+lhs, - ./tests/lhs-test.markdown, - ./tests/lhs-test.markdown+lhs, - ./tests/lhs-test.native, - ./tests/lhs-test.rst, - ./tests/lhs-test.rst+lhs, - ./tests/markdown-reader-more.native, - ./tests/markdown-reader-more.txt, - ./tests/rst-reader.native, - ./tests/rst-reader.rst, - ./tests/s5.basic.html, - ./tests/s5.fragment.html, - ./tests/s5.inserts.html, - ./tests/s5.native, - ./tests/tables-rstsubset.native, - ./tests/tables.context, - ./tests/tables.docbook, - ./tests/tables.html, - ./tests/tables.latex, - ./tests/tables.man, - ./tests/tables.markdown, - ./tests/tables.mediawiki, - ./tests/tables.native, - ./tests/tables.opendocument, - ./tests/tables.plain, - ./tests/tables.rst, - ./tests/tables.rtf, - ./tests/tables.texinfo, - ./tests/tables.txt, - ./tests/testsuite.txt, - ./tests/writer.context, - ./tests/writer.docbook, - ./tests/writer.latex, - ./tests/writer.man, - ./tests/writer.markdown, - ./tests/writer.mediawiki, - ./tests/writer.plain, - ./tests/writer.rst, - ./tests/writer.texinfo +Format: http://svn.debian.org/wsvn/dep/web/deps/dep5.mdwn?rev=162 +Upstream-Name: FIXME +Upstream-Contact: FIXME +Source: FIXME +Copyright: FIXME +License: FIXME +Disclaimer: Autogenerated by CDBS + +Files: BUGS + Benchmark.hs + INSTALL + MakeManPage.hs + Setup.hs + debian/NEWS + debian/README.source + debian/TODO + debian/compat + debian/control + debian/control.in + debian/gbp.conf + debian/hsmarkdown.1 + debian/libghc6-pandoc-doc.doc-base + debian/pandoc.README.Debian + debian/pandoc.install.in + debian/pandoc.links + debian/rules + debian/source/format + debian/source/local-options + debian/watch + default.csl + epub.css + man/man1/markdown2pdf.1 + man/man1/markdown2pdf.1.md + man/man1/pandoc.1.template + man/man5/pandoc_markdown.5 + man/man5/pandoc_markdown.5.template + s5/default/framing.css + s5/default/opera.css + s5/default/outline.css + s5/default/pretty.css + s5/default/print.css + s5/default/s5-core.css + s5/default/slides.js.comment + s5/default/slides.js.packed + slidy/slidy.min.css + slidy/slidy.min.js + src/Tests/Arbitrary.hs + src/Tests/Helpers.hs + src/Tests/Old.hs + src/Tests/Readers/LaTeX.hs + src/Tests/Readers/Markdown.hs + src/Tests/Readers/RST.hs + src/Tests/Shared.hs + src/Tests/Writers/ConTeXt.hs + src/Tests/Writers/HTML.hs + src/Tests/Writers/Native.hs + src/markdown2pdf.hs + src/test-pandoc.hs + templates/context.template + templates/docbook.template + templates/html.template + templates/latex.template + templates/man.template + templates/markdown.template + templates/mediawiki.template + templates/opendocument.template + templates/org.template + templates/plain.template + templates/rst.template + templates/rtf.template + templates/s5.template + templates/slidy.template + templates/texinfo.template + templates/textile.template + tests/biblio.bib + tests/chicago-author-date.csl + tests/ieee.csl + tests/insert + tests/latex-reader.latex + tests/lhs-test.fragment.html+lhs + tests/lhs-test.html + tests/lhs-test.html+lhs + tests/lhs-test.latex + tests/lhs-test.latex+lhs + tests/lhs-test.markdown + tests/lhs-test.markdown+lhs + tests/lhs-test.native + tests/lhs-test.nohl.html + tests/lhs-test.nohl.html+lhs + tests/lhs-test.rst + tests/lhs-test.rst+lhs + tests/markdown-citations.chicago-author-date.txt + tests/markdown-citations.ieee.txt + tests/markdown-citations.mhra.txt + tests/markdown-citations.txt + tests/markdown-reader-more.native + tests/markdown-reader-more.txt + tests/mhra.csl + tests/rst-reader.native + tests/rst-reader.rst + tests/s5.basic.html + tests/s5.fragment.html + tests/s5.inserts.html + tests/s5.native + tests/tables-rstsubset.native + tests/tables.context + tests/tables.docbook + tests/tables.html + tests/tables.latex + tests/tables.man + tests/tables.markdown + tests/tables.mediawiki + tests/tables.native + tests/tables.opendocument + tests/tables.org + tests/tables.plain + tests/tables.rst + tests/tables.rtf + tests/tables.texinfo + tests/tables.textile + tests/tables.txt + tests/testsuite.native + tests/testsuite.txt + tests/textile-reader.native + tests/writer.context + tests/writer.docbook + tests/writer.latex + tests/writer.man + tests/writer.markdown + tests/writer.mediawiki + tests/writer.native + tests/writer.org + tests/writer.plain + tests/writer.rst + tests/writer.texinfo + tests/writer.textile Copyright: *No copyright* License: UNKNOWN FIXME -Files: ./src/Text/Pandoc.hs, - ./src/Text/Pandoc/CharacterReferences.hs, - ./src/Text/Pandoc/Definition.hs, - ./src/Text/Pandoc/Readers/HTML.hs, - ./src/Text/Pandoc/Readers/Markdown.hs, - ./src/Text/Pandoc/Readers/RST.hs, - ./src/Text/Pandoc/Shared.hs, - ./src/Text/Pandoc/Writers/Docbook.hs, - ./src/Text/Pandoc/Writers/HTML.hs, - ./src/Text/Pandoc/Writers/LaTeX.hs, - ./src/Text/Pandoc/Writers/Markdown.hs, - ./src/Text/Pandoc/Writers/RST.hs, - ./src/Text/Pandoc/Writers/RTF.hs, - ./src/Text/Pandoc/Writers/S5.hs, - ./src/Text/Pandoc/XML.hs +Files: src/Text/Pandoc.hs + src/Text/Pandoc/CharacterReferences.hs + src/Text/Pandoc/Parsing.hs + src/Text/Pandoc/Readers/HTML.hs + src/Text/Pandoc/Readers/Markdown.hs + src/Text/Pandoc/Readers/RST.hs + src/Text/Pandoc/S5.hs + src/Text/Pandoc/Shared.hs + src/Text/Pandoc/Writers/Docbook.hs + src/Text/Pandoc/Writers/HTML.hs + src/Text/Pandoc/Writers/LaTeX.hs + src/Text/Pandoc/Writers/Markdown.hs + src/Text/Pandoc/Writers/Native.hs + src/Text/Pandoc/Writers/RST.hs + src/Text/Pandoc/Writers/RTF.hs + src/Text/Pandoc/XML.hs Copyright: 2006-2010, John MacFarlane - : 2006-2010, John MacFarlane + : 2006-2010, John MacFarlane License: GPL-2+ FIXME -Files: ./tests/html-reader.native, - ./tests/latex-reader.native, - ./tests/testsuite.native, - ./tests/writer.native -Copyright: ",Space,Str "\169" -License: UNKNOWN +Files: src/Text/Pandoc/Pretty.hs + src/Text/Pandoc/UTF8.hs + src/Text/Pandoc/UUID.hs + src/Text/Pandoc/Writers/EPUB.hs + src/Text/Pandoc/Writers/Textile.hs +Copyright: 2010, John MacFarlane + : 2010, John MacFarlane +License: GPL-2+ FIXME -Files: ./src/Text/Pandoc/Readers/TeXMath.hs, - ./src/Text/Pandoc/Writers/ConTeXt.hs, - ./src/Text/Pandoc/Writers/Man.hs +Files: src/Text/Pandoc/Readers/TeXMath.hs + src/Text/Pandoc/Writers/ConTeXt.hs + src/Text/Pandoc/Writers/Man.hs Copyright: 2007-2010, John MacFarlane - : 2007-2010, John MacFarlane + : 2007-2010, John MacFarlane License: GPL-2+ FIXME -Files: ./data/LaTeXMathML.js, - ./data/MathMLinHTML.js, - ./tests/s5.fancy.html +Files: data/LaTeXMathML.js + data/MathMLinHTML.js + tests/s5.fancy.html Copyright: 2005, Peter Jipsen http://www.chapman.edu/~jipsen - Peter Jipsen http://www.chapman.edu/~jipsen + Peter Jipsen http://www.chapman.edu/~jipsen License: UNKNOWN FIXME -Files: ./src/Text/Pandoc/ODT.hs, - ./src/Text/Pandoc/Writers/MediaWiki.hs +Files: src/Text/Pandoc/Writers/MediaWiki.hs + src/Text/Pandoc/Writers/ODT.hs Copyright: 2008-2010, John MacFarlane - : 2008-2010, John MacFarlane + : 2008-2010, John MacFarlane License: GPL-2+ FIXME -Files: ./src/Text/Pandoc/Readers/LaTeX.hs +Files: tests/html-reader.native + tests/latex-reader.native +Copyright: ",Space,Str "\169" +License: UNKNOWN + FIXME + +Files: tests/html-reader.html + tests/writer.html +Copyright: +License: UNKNOWN + FIXME + +Files: src/Text/Pandoc/Readers/LaTeX.hs Copyright: : 2006-2010, John MacFarlane - = try (string "\\") >> return (Str [chr 169 + = try (string "\\") >> return (Str [chr 169 License: GPL-2+ FIXME -Files: ./src/pandoc.hs +Files: src/pandoc.hs Copyright: 2006-2010, John MacFarlane - 2006-2010, John MacFarlane\n" ++ - : 2006-2010, John MacFarlane + 2006-2010, John MacFarlane\n" ++ + : 2006-2010, John MacFarlane License: GPL-2+ FIXME -Files: ./src/Text/Pandoc/Blocks.hs -Copyright: 2007, John MacFarlane - : 2007, John MacFarlane +Files: src/Text/Pandoc/Highlighting.hs +Copyright: 2008, John MacFarlane + : 2008, John MacFarlane License: GPL-2+ FIXME -Files: ./src/Text/Pandoc/Biblio.hs +Files: src/Text/Pandoc/Biblio.hs Copyright: 2008, Andrea Rossato - : 2008, Andrea Rossato + : 2008-2010, Andrea Rossato License: GPL-2+ FIXME -Files: ./src/Text/Pandoc/Highlighting.hs -Copyright: 2008, John MacFarlane - : 2008, John MacFarlane -License: GPL-2+ - FIXME - -Files: ./src/Text/Pandoc/Writers/OpenDocument.hs +Files: src/Text/Pandoc/Writers/OpenDocument.hs Copyright: 2008-2010, Andrea Rossato - : 2008-2010, Andrea Rossato and John MacFarlane + : 2008-2010, Andrea Rossato and John MacFarlane License: GPL-2+ FIXME -Files: ./src/Text/Pandoc/Writers/Texinfo.hs +Files: src/Text/Pandoc/Writers/Texinfo.hs Copyright: 2008-2010, John MacFarlane and Peter Wang - : 2008-2010, John MacFarlane and Peter Wang + : 2008-2010, John MacFarlane and Peter Wang License: GPL-2+ FIXME -Files: ./src/Text/Pandoc/Templates.hs +Files: src/Text/Pandoc/Templates.hs Copyright: 2009-2010, John MacFarlane - : 2009-2010, John MacFarlane + : 2009-2010, John MacFarlane +License: GPL-2+ + FIXME + +Files: src/Text/Pandoc/Writers/Org.hs +Copyright: 2006-2010, Puneeth Chaganti + : 2010, Puneeth Chaganti +License: GPL-2+ + FIXME + +Files: src/Text/Pandoc/Readers/Textile.hs +Copyright: 2010, Paul Rivier | tr '*#' '.@' + : 2010-2011, Paul Rivier and John MacFarlane +License: GPL-2+ + FIXME + +Files: src/Text/Pandoc/Readers/Native.hs +Copyright: 2011, John MacFarlane + : 2011, John MacFarlane License: GPL-2+ FIXME -Files: ./COPYING +Files: COPYING Copyright: 1989, 1991 Free Software Foundation, Inc - - HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR - HOLDERS AND/OR OTHER PARTIES - disclaimer" for the program, if - holder saying it may be distributed - holder who places the Program under this License - interest in the program - law: - the software, and - year name of author + + HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR + HOLDERS AND/OR OTHER PARTIES + disclaimer" for the program, if + holder saying it may be distributed + holder who places the Program under this License + interest in the program + law: + the software, and + year name of author License: GPL-2+ FIXME -Files: ./COPYRIGHT +Files: COPYRIGHT Copyright: 2004, Peter Jipsen http://www.chapman.edu/~jipsen - 2005, Peter Jipsen - 2006-2010, John MacFarlane - 2007, Jared Breland - 2008, Andrea Rossato - 2008-2010, Andrea Rossato and John MacFarlane - 2008-2010, John MacFarlane and Peter Wang + 2005, Peter Jipsen + 2006-2010, John MacFarlane + 2007, Jared Breland + 2008-2010, Andrea Rossato + 2008-2010, Andrea Rossato and John MacFarlane + 2008-2010, John MacFarlane and Peter Wang + 2010, Paul Rivier + 2010, Puneeth Chaganti License: GPL-2+ FIXME -Files: ./tests/writer.html -Copyright: +Files: tests/writer.opendocument +Copyright: License: UNKNOWN FIXME -Files: ./tests/writer.opendocument -Copyright: +Files: README +Copyright: 2006-2011, John MacFarlane (jgm at berkeley dot edu). Released under the + 2007, Joe Smith + for full and warranty notices.) License: UNKNOWN FIXME -Files: ./README -Copyright: 2006-2010, John MacFarlane (jgm at berkeley dot edu). Released under the - 2007, Joe Smith - for full and warranty notices.) +Files: pandoc.cabal +Copyright: 2006-2011, John MacFarlane License: UNKNOWN FIXME -Files: ./pandoc.cabal -Copyright: 2006-2010, John MacFarlane +Files: man/man1/pandoc.1 +Copyright: 2006-2011, John MacFarlane (jgm at berkeley dot edu) + for full and warranty notices.) License: UNKNOWN FIXME -Files: ./tests/writer.rtf +Files: tests/writer.rtf Copyright: \u169?\sa180\par} License: UNKNOWN FIXME -Files: ./changelog +Files: changelog Copyright: file - in top level a symlink to debian/, to avoid - message in Main.hs - message to '-v' output, modeled after FSF messages + in top level a symlink to debian/, to avoid + message in Main.hs + message to '-v' output, modeled after FSF messages License: UNKNOWN FIXME diff -Nru pandoc-1.5.1.1/debian/patches/0001_threaded.patch pandoc-1.8.0.3/debian/patches/0001_threaded.patch --- pandoc-1.5.1.1/debian/patches/0001_threaded.patch 2010-05-26 20:30:53.000000000 +0000 +++ pandoc-1.8.0.3/debian/patches/0001_threaded.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,40 +0,0 @@ -Description: Implement configure option -threaded -Author: John MacFarlane -Forwarded: not-needed -Last-Update: 2010-04-21 ---- a/pandoc.cabal -+++ b/pandoc.cabal -@@ -124,6 +124,9 @@ - tests/RunTests.hs - Extra-Tmp-Files: man/man1/pandoc.1, man/man1/markdown2pdf.1 - -+Flag threaded -+ Description: Compile markdown2pdf with -threaded option. -+ Default: True - Flag highlighting - Description: Compile in support for syntax highlighting of code blocks. - Default: False -@@ -204,9 +207,9 @@ - Hs-Source-Dirs: src - Main-Is: pandoc.hs - if impl(ghc >= 6.12) -- Ghc-Options: -O2 -Wall -threaded -fno-warn-unused-do-bind -+ Ghc-Options: -O2 -Wall -fno-warn-unused-do-bind - else -- Ghc-Options: -O2 -Wall -threaded -+ Ghc-Options: -O2 -Wall - Ghc-Prof-Options: -auto-all -caf-all - Extensions: CPP - -@@ -223,7 +226,10 @@ - Executable markdown2pdf - Hs-Source-Dirs: src - Main-Is: markdown2pdf.hs -- Ghc-Options: -Wall -threaded -+ if flag(threaded) -+ Ghc-Options: -Wall -threaded -+ else -+ Ghc-Options: -Wall - Ghc-Prof-Options: -auto-all - Extensions: CPP - if flag(wrappers) diff -Nru pandoc-1.5.1.1/debian/patches/README pandoc-1.8.0.3/debian/patches/README --- pandoc-1.5.1.1/debian/patches/README 2010-05-26 20:30:53.000000000 +0000 +++ pandoc-1.8.0.3/debian/patches/README 1970-01-01 00:00:00.000000000 +0000 @@ -1,3 +0,0 @@ -0xxx: Grabbed from upstream development. -1xxx: Possibly relevant for upstream adoption. -2xxx: Only relevant for official Debian release. diff -Nru pandoc-1.5.1.1/debian/patches/series pandoc-1.8.0.3/debian/patches/series --- pandoc-1.5.1.1/debian/patches/series 2010-05-26 20:30:53.000000000 +0000 +++ pandoc-1.8.0.3/debian/patches/series 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -0001_threaded.patch diff -Nru pandoc-1.5.1.1/debian/rules pandoc-1.8.0.3/debian/rules --- pandoc-1.5.1.1/debian/rules 2010-06-29 18:57:02.000000000 +0000 +++ pandoc-1.8.0.3/debian/rules 2011-03-25 13:51:18.000000000 +0000 @@ -9,9 +9,9 @@ abi = $(DEB_UPSTREAM_TARBALL_VERSION) DEB_UPSTREAM_URL = http://pandoc.googlecode.com/files -DEB_UPSTREAM_TARBALL_MD5 = bfccc042ae0cf0901bbca1f87748f969 +DEB_UPSTREAM_TARBALL_MD5 = e9003100e54755c5deaca7334910fe8c -DEB_COPYRIGHT_CHECK_IGNORE_REGEX = ^.*\.(gif|jpg|odt)|\./debian/(changelog|copyright(|_hints|_newhints))$ +DEB_COPYRIGHT_CHECK_IGNORE_REGEX = ^.*\.(gif|jpg|odt)|debian/(changelog|copyright(|_hints|_newhints))$ DEB_INSTALL_MANPAGES_pandoc = man/man1/*.1 debian/hsmarkdown.1 @@ -40,12 +40,28 @@ [ ! -x "$(DEB_SETUP_BIN_NAME)" ] || $(DEB_SETUP_BIN_NAME) clean deps_doc = ghc6-doc (>= 6.8.2) -deps_doc += , libghc6-highlighting-kate-doc (>= 0.2.3), libghc6-xhtml-doc, libghc6-parsec2-doc (>= 2.1), haskell-pcre-light-doc +deps_doc += , libghc6-highlighting-kate-doc (>= 0.2.9), libghc6-xhtml-doc, libghc6-parsec3-doc (>= 2.1), haskell-pcre-light-doc # Needed by upstream build process -CDBS_BUILD_DEPENDS += , ghc6 (>= 6.8.2) -CDBS_BUILD_DEPENDS += , libghc6-mtl-dev, libghc6-network-dev, libghc6-parsec2-dev (>= 2.1), libghc6-network-dev, libghc6-utf8-string-dev, libghc6-xhtml-dev, libghc6-zip-archive-dev (>= 0.1.1.4), libghc6-http-dev (>= 40000005), libghc6-texmath-dev, libghc6-xml-dev (>= 1.3.5), libghc6-xml-dev (<< 1.4), libghc6-extensible-exceptions-dev -CDBS_BUILD_DEPENDS += , libghc6-highlighting-kate-dev (>= 0.2.3) +CDBS_BUILD_DEPENDS += , ghc6 (>= 6.8.2), libghc6-syb-dev +CDBS_BUILD_DEPENDS += , libghc6-parsec3-dev (>= 2.1), libghc6-parsec3-dev (<< 3.2) +CDBS_BUILD_DEPENDS += , libghc6-xhtml-dev (>= 3000.0), libghc6-xhtml-dev (<< 3000.3) +CDBS_BUILD_DEPENDS += , libghc6-mtl-dev (>= 1.1), libghc6-mtl-dev (<< 1.2) +CDBS_BUILD_DEPENDS += , libghc6-network-dev (>= 2), libghc6-network-dev (<< 2.4) +CDBS_BUILD_DEPENDS += , libghc6-filepath-dev, libghc6-process-dev, libghc6-directory-dev, libghc6-bytestring-dev +CDBS_BUILD_DEPENDS += , libghc6-zip-archive-dev (>= 0.1.1.7), libghc6-zip-archive-dev (<< 0.2) +CDBS_BUILD_DEPENDS += , libghc6-utf8-string-dev, libghc6-old-time-dev +CDBS_BUILD_DEPENDS += , libghc6-http-dev (>= 40000005), libghc6-http-dev (<< 40000200) +CDBS_BUILD_DEPENDS += , libghc6-texmath-dev (>= 0.5), libghc6-texmath-dev (<< 0.6) +CDBS_BUILD_DEPENDS += , libghc6-xml-dev (>= 1.3.5), libghc6-xml-dev (<< 1.4) +CDBS_BUILD_DEPENDS += , libghc6-random-dev, libghc6-extensible-exceptions-dev +CDBS_BUILD_DEPENDS += , libghc6-citeproc-hs-dev (>= 0.3.1), libghc6-citeproc-hs-dev (<< 0.4) +CDBS_BUILD_DEPENDS += , libghc6-pandoc-types-dev (>= 1.8), libghc6-pandoc-types-dev (<< 1.9) +CDBS_BUILD_DEPENDS += , libghc6-json-dev (>= 0.4), libghc6-json-dev (<< 0.5) +CDBS_BUILD_DEPENDS += , libghc6-dlist-dev (>= 0.4), libghc6-dlist-dev (<< 0.6) +CDBS_BUILD_DEPENDS += , libghc6-tagsoup-dev (>= 0.12), libghc6-tagsoup-dev (<< 0.13) +CDBS_BUILD_DEPENDS += , libghc6-highlighting-kate-dev (>= 0.2.9), libghc6-highlighting-kate-dev (<< 0.3) +CDBS_BUILD_DEPENDS += , libghc6-diff-dev, libghc6-testpack-dev, libghc6-template-haskell-dev CDBS_BUILD_DEPENDS += , hscolour (>= 1.8) CDBS_BUILD_DEPENDS += , $(deps_doc) diff -Nru pandoc-1.5.1.1/default.csl pandoc-1.8.0.3/default.csl --- pandoc-1.5.1.1/default.csl 1970-01-01 00:00:00.000000000 +0000 +++ pandoc-1.8.0.3/default.csl 2011-02-05 18:48:07.000000000 +0000 @@ -0,0 +1,369 @@ + + diff -Nru pandoc-1.5.1.1/epub.css pandoc-1.8.0.3/epub.css --- pandoc-1.5.1.1/epub.css 1970-01-01 00:00:00.000000000 +0000 +++ pandoc-1.8.0.3/epub.css 2011-02-05 18:48:07.000000000 +0000 @@ -0,0 +1,11 @@ +/* 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 { } diff -Nru pandoc-1.5.1.1/INSTALL pandoc-1.8.0.3/INSTALL --- pandoc-1.5.1.1/INSTALL 2010-03-29 14:24:56.000000000 +0000 +++ pandoc-1.8.0.3/INSTALL 2011-02-05 18:48:07.000000000 +0000 @@ -68,19 +68,18 @@ preceded by a `-` (to force the flag to `false`), and separated by spaces. Pandoc's flags include: - - `library`: build the library (default yes) - `executable`: build the pandoc executable (default yes) - - `wrappers`: build the wrappers `markdown2pdf` and `hsmarkdown` - (default yes) + - `library`: build the pandoc library (default yes) + - `wrappers`: build the wrapper `markdown2pdf` (default yes) - `highlighting`: compile with syntax highlighting support (increases the size of the executable) (default no) So, for example, - --flags="-library highlighting" + --flags="-executable -wrappers highlighting" - tells Cabal to build the executable but not the library, and to - compile with syntax highlighting support. + tells Cabal to build the library but not the executables, + and to compile with syntax highlighting support. 3. Build: @@ -108,22 +107,3 @@ [highlighting-kate]: http://hackage.haskell.org/package/highlighting-kate [Cabal User's Guide]: http://www.haskell.org/cabal/release/latest/doc/users-guide/builders.html#setup-configure-paths -Optional citeproc support -------------------------- - -Pandoc can optionally be compiled with support for bibliographic citations -using Andrea Rossato's [`citeproc-hs` library]. This allows you -to specify citations in markdown using an intuitive syntax (for example, -`[jones2005@p. 3; smith2006]`). These are automatically changed into -appropriately styled citations in the output, and a bibliography is -added. The bibliography data and style information are taken from XML -files that must be specified on the command line. (Note: `citeproc-hs` -support is experimental, and the interface may change in the future.) - -If you are using Cabal to compile pandoc, specify the `citeproc` flag in -the configure step: - - runhaskell Setup configure --flags="citeproc" - -[`citeproc-hs` library]: http://code.haskell.org/citeproc-hs/ - diff -Nru pandoc-1.5.1.1/MakeManPage.hs pandoc-1.8.0.3/MakeManPage.hs --- pandoc-1.5.1.1/MakeManPage.hs 1970-01-01 00:00:00.000000000 +0000 +++ pandoc-1.8.0.3/MakeManPage.hs 2011-02-05 18:48:07.000000000 +0000 @@ -0,0 +1,97 @@ +-- Create pandoc.1 man page from README +import Text.Pandoc +import Data.ByteString.UTF8 (toString, fromString) +import Data.Char (toUpper) +import qualified Data.ByteString as B +import Control.Monad +import System.FilePath +import System.Environment (getArgs) +import Text.Pandoc.Shared (normalize) +import System.Directory (getModificationTime) +import System.IO.Error (isDoesNotExistError) +import System.Time (ClockTime(..)) +import Data.Maybe (catMaybes) + +main = do + rmContents <- liftM toString $ B.readFile "README" + let (Pandoc meta blocks) = readMarkdown defaultParserState rmContents + let manBlocks = removeSect [Str "Wrappers"] + $ removeSect [Str "Pandoc's",Space,Str "markdown"] blocks + let syntaxBlocks = extractSect [Str "Pandoc's",Space,Str "markdown"] blocks + args <- getArgs + let verbose = "--verbose" `elem` args + makeManPage verbose ("man" "man1" "pandoc.1") + meta manBlocks + makeManPage verbose ("man" "man5" "pandoc_markdown.5") + meta syntaxBlocks + let markdown2pdfpage = "man" "man1" "markdown2pdf.1" + modDeps <- modifiedDependencies markdown2pdfpage [markdown2pdfpage <.> "md"] + unless (null modDeps) $ do + mpdfContents <- liftM toString $ B.readFile $ markdown2pdfpage <.> "md" + templ <- liftM toString $ B.readFile $ "templates" "man.template" + let doc = readMarkdown defaultParserState{ stateStandalone = True } + mpdfContents + writeManPage markdown2pdfpage templ doc + when verbose $ + putStrLn $ "Created " ++ markdown2pdfpage + +makeManPage :: Bool -> FilePath -> Meta -> [Block] -> IO () +makeManPage verbose page meta blocks = do + let templ = page <.> "template" + modDeps <- modifiedDependencies page ["README", templ] + unless (null modDeps) $ do + manTemplate <- liftM toString $ B.readFile templ + writeManPage page manTemplate (Pandoc meta blocks) + when verbose $ + putStrLn $ "Created " ++ page + +writeManPage :: FilePath -> String -> Pandoc -> IO () +writeManPage page templ doc = do + let opts = defaultWriterOptions{ writerStandalone = True + , writerTemplate = templ } + let manPage = writeMan opts $ + bottomUp (concatMap removeLinks) $ + bottomUp capitalizeHeaders doc + B.writeFile page $ fromString manPage + +-- | Returns a list of 'dependencies' that have been modified after 'file'. +modifiedDependencies :: FilePath -> [FilePath] -> IO [FilePath] +modifiedDependencies file dependencies = do + fileModTime <- catch (getModificationTime file) $ + \e -> if isDoesNotExistError e + then return (TOD 0 0) -- the minimum ClockTime + else ioError e + depModTimes <- mapM getModificationTime dependencies + let modified = zipWith (\dep time -> if time > fileModTime then Just dep else Nothing) dependencies depModTimes + return $ catMaybes modified + +removeLinks :: Inline -> [Inline] +removeLinks (Link l _) = l +removeLinks x = [x] + +capitalizeHeaders :: Block -> Block +capitalizeHeaders (Header 1 xs) = Header 1 $ bottomUp capitalize xs +capitalizeHeaders x = x + +capitalize :: Inline -> Inline +capitalize (Str xs) = Str $ map toUpper xs +capitalize x = x + +removeSect :: [Inline] -> [Block] -> [Block] +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 = + bottomUp promoteHeader $ takeWhile (not . isHeader1) xs + where promoteHeader (Header n x) = Header (n-1) x + promoteHeader x = x +extractSect ils (x:xs) = extractSect ils xs +extractSect _ [] = [] + +isHeader1 :: Block -> Bool +isHeader1 (Header 1 _) = True +isHeader1 _ = False + diff -Nru pandoc-1.5.1.1/man/man1/markdown2pdf.1 pandoc-1.8.0.3/man/man1/markdown2pdf.1 --- pandoc-1.5.1.1/man/man1/markdown2pdf.1 1970-01-01 00:00:00.000000000 +0000 +++ pandoc-1.8.0.3/man/man1/markdown2pdf.1 2011-02-05 18:48:07.000000000 +0000 @@ -0,0 +1,165 @@ +.TH MARKDOWN2PDF 1 "January 29, 2011" "Pandoc User Manuals" +.SH NAME +.PP +markdown2pdf - converts markdown-formatted text to PDF, using pdflatex +.SH SYNOPSIS +.PP +markdown2pdf [\f[I]options\f[]] [\f[I]input-file\f[]]... +.SH DESCRIPTION +.PP +\f[C]markdown2pdf\f[] converts \f[I]input-file\f[] (or text from +standard input) from markdown-formatted plain text to PDF, using +\f[C]pandoc\f[] and \f[C]pdflatex\f[]. +If no output filename is specified (using the \f[C]-o\f[] option), the +name of the output file is derived from the input file; thus, for +example, if the input file is \f[I]hello.txt\f[], the output file will +be \f[I]hello.pdf\f[]. +If the input is read from STDIN and no output filename is specified, the +output file will be named \f[I]stdin.pdf\f[]. +If multiple input files are specified, they will be concatenated before +conversion, and the name of the output file will be derived from the +first input file. +.PP +Input is assumed to be in the UTF-8 character encoding. +If your local character encoding is not UTF-8, you should pipe input +through \f[C]iconv\f[]: +.IP +.nf +\f[C] +iconv\ -t\ utf-8\ input.txt\ |\ markdown2pdf +\f[] +.fi +.PP +\f[C]markdown2pdf\f[] assumes that the \f[C]unicode\f[], \f[C]array\f[], +\f[C]fancyvrb\f[], \f[C]graphicx\f[], and \f[C]ulem\f[] packages are in +latex\[aq]s search path. +If these packages are not included in your latex setup, they can be +obtained from \f[C]http://ctan.org\f[]. +.SH OPTIONS +.TP +.B -o \f[I]FILE\f[], --output=\f[I]FILE\f[] +Write output to \f[I]FILE\f[]. +.RS +.RE +.TP +.B --strict +Use strict markdown syntax, with no extensions or variants. +.RS +.RE +.TP +.B --xetex +Use xelatex instead of pdflatex to create the PDF. +.RS +.RE +.TP +.B -N, --number-sections +Number section headings in LaTeX output. +(Default is not to number them.) +.RS +.RE +.TP +.B --listings +Use listings package for LaTeX code blocks +.RS +.RE +.TP +.B --template=\f[I]FILE\f[] +Use \f[I]FILE\f[] as a custom template for the generated document. +Implies \f[C]-s\f[]. +See the section TEMPLATES in \f[C]pandoc\f[](1) for information about +template syntax. +Use \f[C]pandoc\ -D\ latex\f[] to print the default LaTeX template. +.RS +.RE +.TP +.B -V KEY=VAL, --variable=\f[I]KEY:VAL\f[] +Set the template variable KEY to the value VAL when rendering the +document in standalone mode. +Use this to set the font size when using the default LaTeX template: +\f[C]-V\ fontsize=12pt\f[]. +.RS +.RE +.TP +.B -H \f[I]FILE\f[], --include-in-header=\f[I]FILE\f[] +Include (LaTeX) contents of \f[I]FILE\f[] at the end of the header. +Implies \f[C]-s\f[]. +.RS +.RE +.TP +.B -B \f[I]FILE\f[], --include-before-body=\f[I]FILE\f[] +Include (LaTeX) contents of \f[I]FILE\f[] at the beginning of the +document body. +.RS +.RE +.TP +.B -A \f[I]FILE\f[], --include-after-body=\f[I]FILE\f[] +Include (LaTeX) contents of \f[I]FILE\f[] at the end of the document +body. +.RS +.RE +.TP +.B --bibliography=\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].xml\f[] (MODS format), \f[C].bib\f[] +(BibTeX format), or \f[C].json\f[] (citeproc JSON). +.RS +.RE +.TP +.B --csl=\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 +.RS +.IP +.nf +\f[C] +$HOME/.csl +\f[] +.fi +.PP +in unix and +.IP +.nf +\f[C] +C:\\Documents\ And\ Settings\\USERNAME\\Application\ Data\\csl +\f[] +.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. +.RE +.TP +.B --data-dir\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: +.RS +.IP +.nf +\f[C] +$HOME/.pandoc +\f[] +.fi +.PP +in unix and +.IP +.nf +\f[C] +C:\\Documents\ And\ Settings\\USERNAME\\Application\ Data\\pandoc +\f[] +.fi +.PP +in Windows. +A \f[C]reference.odt\f[], \f[C]epub.css\f[], \f[C]templates\f[] +directory, or \f[C]s5\f[] directory placed in this directory will +override pandoc\[aq]s normal defaults. +.RE +.SH SEE ALSO +.PP +\f[C]pandoc\f[](1), \f[C]pdflatex\f[](1) +.SH AUTHORS +John MacFarlane, Paulo Tanimoto, and Recai Oktas. diff -Nru pandoc-1.5.1.1/man/man1/markdown2pdf.1.md pandoc-1.8.0.3/man/man1/markdown2pdf.1.md --- pandoc-1.5.1.1/man/man1/markdown2pdf.1.md 2010-03-29 14:24:56.000000000 +0000 +++ pandoc-1.8.0.3/man/man1/markdown2pdf.1.md 2011-02-05 18:48:07.000000000 +0000 @@ -1,6 +1,6 @@ % MARKDOWN2PDF(1) Pandoc User Manuals -% John MacFarlane and Recai Oktas -% January 8, 2008 +% John MacFarlane, Paulo Tanimoto, and Recai Oktas +% January 29, 2011 # NAME @@ -48,6 +48,9 @@ -N, \--number-sections : Number section headings in LaTeX output. (Default is not to number them.) +\--listings +: Use listings package for LaTeX code blocks + \--template=*FILE* : Use *FILE* as a custom template for the generated document. Implies `-s`. See the section TEMPLATES in `pandoc`(1) for information about @@ -56,10 +59,8 @@ -V KEY=VAL, \--variable=*KEY:VAL* : Set the template variable KEY to the value VAL when rendering the - document in standalone mode. This is only useful when the - `--template` option is used to specify a custom template, since - pandoc automatically sets the variables used in the default - templates. + document in standalone mode. Use this to set the font size when + using the default LaTeX template: `-V fontsize=12pt`. -H *FILE*, \--include-in-header=*FILE* : Include (LaTeX) contents of *FILE* at the end of the header. Implies @@ -71,10 +72,46 @@ -A *FILE*, \--include-after-body=*FILE* : Include (LaTeX) contents of *FILE* at the end of the document body. --C *FILE*, \--custom-header=*FILE* -: Use contents of *FILE* as the document header. *Note: This option is - deprecated. Users should transition to using `--template` instead.* +\--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 `.xml` (MODS format), + `.bib` (BibTeX format), or `.json` (citeproc JSON). + +\--csl=*FILE* +: Specify [CSL] style to be used in formatting citations and + the bibliography. If *FILE* is not found, pandoc will look + for it in + + $HOME/.csl + + in unix and + + C:\Documents And Settings\USERNAME\Application Data\csl + + in Windows. If the `--csl` option is not specified, pandoc + will use a default style: either `default.csl` in the + user data directory (see `--data-dir`), or, if that is + not present, the Chicago author-date style. + +\--data-dir*=DIRECTORY* +: 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: + + $HOME/.pandoc + + in unix and + + C:\Documents And Settings\USERNAME\Application Data\pandoc + + in Windows. A `reference.odt`, `epub.css`, `templates` directory, + or `s5` directory placed in this directory will override pandoc's + normal defaults. # SEE ALSO `pandoc`(1), `pdflatex`(1) + +[CSL]: CitationStyles.org + diff -Nru pandoc-1.5.1.1/man/man1/pandoc.1 pandoc-1.8.0.3/man/man1/pandoc.1 --- pandoc-1.5.1.1/man/man1/pandoc.1 1970-01-01 00:00:00.000000000 +0000 +++ pandoc-1.8.0.3/man/man1/pandoc.1 2011-02-05 18:48:07.000000000 +0000 @@ -0,0 +1,909 @@ +.TH PANDOC 1 "January 29, 2011" "Pandoc" +.SH NAME +pandoc - general markup converter +.SH SYNOPSIS +.PP +pandoc [\f[I]options\f[]] [\f[I]input-file\f[]]... +.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. +It can read markdown and (subsets of) Textile, reStructuredText, HTML, +and LaTeX; and it can write plain text, markdown, reStructuredText, +HTML, LaTeX, ConTeXt, RTF, DocBook XML, OpenDocument XML, ODT, GNU +Texinfo, MediaWiki markup, EPUB, Textile, groff man pages, Emacs +Org-Mode, and Slidy or S5 HTML slide shows. +.PP +Pandoc\[aq]s enhanced version of markdown includes syntax for footnotes, +tables, flexible ordered lists, definition lists, delimited 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.) +.PP +In contrast to most existing tools for converting markdown to HTML, +which use regex substitutions, Pandoc has a modular design: it consists +of a set of readers, which parse text in a given format and produce a +native representation of the document, and a set of writers, which +convert this native representation into a target format. +Thus, adding an input or output format requires only adding a reader or +writer. +.SS Using Pandoc +.PP +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 +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[] and \f[C]epub\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 +\f[] +.fi +.PP +Instead of a file, an absolute URI may be given. +In this case pandoc will fetch the content using HTTP: +.IP +.nf +\f[C] +pandoc\ -f\ html\ -t\ markdown\ http://www.fsf.org +\f[] +.fi +.PP +If multiple input files are given, \f[C]pandoc\f[] will concatenate them +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. +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 +\f[] +.fi +.PP +To convert \f[C]hello.html\f[] from html to markdown: +.IP +.nf +\f[C] +pandoc\ -f\ html\ -t\ markdown\ hello.html +\f[] +.fi +.PP +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[] +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 +they do not parse. +.PP +If the input or output format is not specified explicitly, +\f[C]pandoc\f[] will attempt to guess it from the extensions of the +input and output filenames. +Thus, for example, +.IP +.nf +\f[C] +pandoc\ -o\ hello.tex\ hello.txt +\f[] +.fi +.PP +will convert \f[C]hello.txt\f[] from markdown to LaTeX. +If no output file is specified (so that output goes to \f[I]stdout\f[]), +or if the output file\[aq]s extension is unknown, the output format will +default to HTML. +If no input file is specified (so that input comes from \f[I]stdin\f[]), +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[]: +.IP +.nf +\f[C] +iconv\ -t\ utf-8\ input.txt\ |\ pandoc\ |\ iconv\ -f\ utf-8 +\f[] +.fi +.SH 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[] +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), or \f[C]latex\f[] (LaTeX). +If \f[C]+lhs\f[] is appended to \f[C]markdown\f[], \f[C]rst\f[], or +\f[C]latex\f[], the input will be treated as literate Haskell source: +see Literate Haskell support, below. +.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[] +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[] (HTML), \f[C]latex\f[] (LaTeX), \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]epub\f[] (EPUB book), \f[C]slidy\f[] (Slidy HTML and +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. +If \f[C]+lhs\f[] is appended to \f[C]markdown\f[], \f[C]rst\f[], +\f[C]latex\f[], or \f[C]html\f[], the output will be rendered as +literate Haskell source: see Literate Haskell support, below. +.RS +.RE +.TP +.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). +.RS +.RE +.TP +.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[] or \f[C]epub\f[], +output to stdout is disabled.) +.RS +.RE +.TP +.B \f[C]-p\f[], \f[C]--preserve-tabs\f[] +Preserve tabs instead of converting them to spaces (the default). +.RS +.RE +.TP +.B \f[C]--tab-stop=\f[]\f[I]NUMBER\f[] +Specify the number of spaces per tab (default is 4). +.RS +.RE +.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]--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]--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]-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. +Raw HTML can be printed in markdown, reStructuredText, HTML, Slidy, and +S5 output; raw LaTeX can be printed in markdown, reStructuredText, +LaTeX, and ConTeXt output. +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.) +.RS +.RE +.TP +.B \f[C]-S\f[], \f[C]--smart\f[] +Produce typographically correct output, converting straight quotes to +curly quotes, \f[C]---\f[] and \f[C]--\f[] to dashes, ande \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[]. +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[].) +.RS +.RE +.TP +.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[]. +.RS +.RE +.TP +.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[]. +If no \f[I]URL\f[] is provided, the contents of the script will be +inserted directly into the HTML header, preserving portability at the +price of efficiency. +If you plan to use math on several pages, it is much better to link to a +copy of the script, so it can be cached. +.RS +.RE +.TP +.B \f[C]--mathml\f[][=\f[I]URL\f[]] +Convert TeX math to MathML. +In standalone mode, a small javascript (or a link to such a script if a +\f[I]URL\f[] is supplied) will be inserted that allows the MathML to be +viewed on some browsers. +.RS +.RE +.TP +.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 +header of standalone HTML documents. +If a \f[I]URL\f[] is not provided, no link to the jsMath load script +will be inserted; it is then up to the author to provide such a link in +the HTML template. +.RS +.RE +.TP +.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. +.RS +.RE +.TP +.B \f[C]--gladtex\f[] +Enclose TeX math in \f[C]\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[]] +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[]. +.RS +.RE +.TP +.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. +If \f[I]URL\f[] is not specified, the Google Chart API will be used. +.RS +.RE +.TP +.B \f[C]-i\f[], \f[C]--incremental\f[] +Make list items in Slidy or S5 display incrementally (one by one). +The default is for lists to be displayed all at once. +.RS +.RE +.TP +.B \f[C]--offline\f[] +Include all the CSS and javascript needed for a Slidy or S5 slide show +in the output, so that the slide show will work even when no internet +connection is available. +.RS +.RE +.TP +.B \f[C]--xetex\f[] +Create LaTeX outut suitable for processing by XeTeX. +.RS +.RE +.TP +.B \f[C]--chapters\f[] +Treat top-level headers as chapters in LaTeX, ConTeXt, and DocBook +output. +.RS +.RE +.TP +.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]--listings\f[] +Use listings package for LaTeX code blocks +.RS +.RE +.TP +.B \f[C]--section-divs\f[] +Wrap sections in \f[C]
\f[] tags (or \f[C]
\f[] tags in +HTML5), and attach identifiers to the enclosing \f[C]
\f[] (or +\f[C]
\f[]) rather than the header itself. +See Section identifiers, below. +.RS +.RE +.TP +.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[] +Specify length of lines in characters (for text wrapping). +.RS +.RE +.TP +.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[] +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. +.RS +.RE +.TP +.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]--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. +This option has no effect on \f[C]man\f[], \f[C]docbook\f[], +\f[C]slidy\f[], or \f[C]s5\f[] output. +.RS +.RE +.TP +.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]--template=\f[]\f[I]FILE\f[] +Use \f[I]FILE\f[] as a custom template for the generated document. +Implies \f[C]--standalone\f[]. +See Templates below for a description of template syntax. +If this option is not used, a default template appropriate for the +output format will be used. +See also \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[] +Set the template variable \f[I]KEY\f[] to the value \f[I]VAL\f[] when +rendering the document in standalone mode. +This is 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. +.RS +.RE +.TP +.B \f[C]-c\f[] \f[I]URL\f[], \f[C]--css=\f[]\f[I]URL\f[] +Link to a CSS style sheet. +.RS +.RE +.TP +.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[]. +.RS +.RE +.TP +.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]\f[] tag in HTML, or the \f[C]\\begin{document}\f[] +command in LaTeX). +This can be used to include navigation bars or banners in HTML +documents. +This option can be used repeatedly to include multiple files. +They will be included in the order specified. +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[] +Include contents of \f[I]FILE\f[], verbatim, at the end of the document +body (before the \f[C]\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[]. +.RS +.RE +.TP +.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. +The contents of the reference ODT are ignored, but its stylesheets are +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[]). +If this is not found either, sensible defaults will be used. +.RS +.RE +.TP +.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[], +below). +If it is not found there, sensible defaults will be used. +.RS +.RE +.TP +.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[]. +For example: +.RS +.IP +.nf +\f[C] +\ Creative\ Commons +\ es-AR +\f[] +.fi +.PP +By default, pandoc will include the following metadata elements: +\f[C]\f[] (from the document title), \f[C]\f[] +(from the document authors), \f[C]\f[] (from the locale), +and \f[C]\f[] (a randomly generated UUID). +Any of these may be overridden by elements in the metadata file. +.RE +.TP +.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.) +.RS +.RE +.TP +.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[]. +.RS +.RE +.TP +.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 format), \f[C].bbx\f[] (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). +If you want to use multiple bibliographies, just use this option +repeatedly. +.RS +.RE +.TP +.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 +.RS +.IP +.nf +\f[C] +$HOME/.csl +\f[] +.fi +.PP +in unix and +.IP +.nf +\f[C] +C:\\Documents\ And\ Settings\\USERNAME\\Application\ Data\\csl +\f[] +.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. +.RE +.TP +.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: +.RS +.IP +.nf +\f[C] +$HOME/.pandoc +\f[] +.fi +.PP +in unix and +.IP +.nf +\f[C] +C:\\Documents\ And\ Settings\\USERNAME\\Application\ Data\\pandoc +\f[] +.fi +.PP +in Windows. +A \f[C]reference.odt\f[], \f[C]epub.css\f[], \f[C]templates\f[] +directory, or \f[C]s5\f[] directory placed in this directory will +override pandoc\[aq]s normal defaults. +.RE +.TP +.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 +output file was specified. +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 +of the line. +.RS +.RE +.TP +.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 +\f[] +.fi +.PP +is equivalent to +.IP +.nf +\f[C] +pandoc\ -o\ foo.html\ -s +\f[] +.fi +.RE +.TP +.B \f[C]-v\f[], \f[C]--version\f[] +Print version. +.RS +.RE +.TP +.B \f[C]-h\f[], \f[C]--help\f[] +Show usage message. +.RS +.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. +To see the default template that is used, just type +.IP +.nf +\f[C] +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. +You can also override the system default templates for a given output +format \f[C]FORMAT\f[] by putting a file +\f[C]templates/FORMAT.template\f[] in the user data directory (see +\f[C]--data-dir\f[], above). +.PP +Templates may contain \f[I]variables\f[]. +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. +For example, the string \f[C]$title$\f[] in +.IP +.nf +\f[C] +$title$ +\f[] +.fi +.PP +will be replaced by the document title. +.PP +To write a literal \f[C]$\f[] in a template, use \f[C]$$\f[]. +.PP +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) +.RS +.RE +.TP +.B \f[C]toc\f[] +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 +multiple values) +.RS +.RE +.TP +.B \f[C]include-after\f[] +contents specified by \f[C]-A/--include-after-body\f[] (may have +multiple values) +.RS +.RE +.TP +.B \f[C]body\f[] +body of document +.RS +.RE +.TP +.B \f[C]title\f[] +title of document, as specified in title block +.RS +.RE +.TP +.B \f[C]author\f[] +author of document, as specified in title block (may have multiple +values) +.RS +.RE +.TP +.B \f[C]date\f[] +date of document, as specified in title block +.RS +.RE +.TP +.B \f[C]lang\f[] +language code for HTML documents +.RS +.RE +.PP +Variables may be set at the command line using the +\f[C]-V/--variable\f[] option. +This allows users to include custom variables in their templates. +.PP +Templates may contain conditionals. +The syntax is as follows: +.IP +.nf +\f[C] +$if(variable)$ +X +$else$ +Y +$endif$ +\f[] +.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[]. +\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: +.IP +.nf +\f[C] +$for(author)$ + +$endfor$ +\f[] +.fi +.PP +You can optionally specify a separator to be used between consecutive +items: +.IP +.nf +\f[C] +$for(author)$$author$$sep$,\ $endfor$ +\f[] +.fi +.SH PRODUCING HTML SLIDE SHOWS WITH PANDOC +.PP +You can use Pandoc to produce an HTML + javascript slide presentation +that can be viewed via a web browser. +There are two ways to do this, using S5 or Slidy. +.PP +Here\[aq]s the markdown source for a simple slide show, +\f[C]eating.txt\f[]: +.IP +.nf +\f[C] +%\ Eating\ Habits +%\ John\ Doe +%\ March\ 22,\ 2005 + +#\ In\ the\ morning + +-\ Eat\ eggs +-\ Drink\ coffee + +#\ In\ the\ evening + +-\ Eat\ spaghetti +-\ Drink\ wine + +-------------------------- + +![picture\ of\ spaghetti](images/spaghetti.jpg) +\f[] +.fi +.PP +To produce the slide show, simply type +.IP +.nf +\f[C] +pandoc\ -w\ s5\ -s\ eating.txt\ >\ eating.html +\f[] +.fi +.PP +for S5, or +.IP +.nf +\f[C] +pandoc\ -w\ slidy\ -s\ eating.txt\ >\ eating.html +\f[] +.fi +.PP +for Slidy. +.PP +A title page is constructed automatically from the document\[aq]s title +block. +Each level-one header and horizontal rule begins a new slide. +.PP +The file produced by pandoc with the \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]ui/default\f[] (for S5) or at the +Slidy website at \f[C]w3.org\f[] (for Slidy). +If the \f[C]--offline\f[] option is specified, the scripts and CSS will +be included directly in the generated file, so that it may be used +offline. +.PP +You can change the style of the slides by putting customized CSS files +in \f[C]$DATADIR/s5/default\f[] (for S5) or \f[C]$DATADIR/slidy\f[] (for +Slidy), where \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[]). +Pandoc will look there for any files it does not find in the user data +directory. +.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. +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: +.IP +.nf +\f[C] +>\ -\ Eat\ spaghetti +>\ -\ Drink\ wine +\f[] +.fi +.PP +In this way incremental and nonincremental lists can be mixed in a +single document. +.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]html\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 +rather than block quotations. +Text between \f[C]\\begin{code}\f[] and \f[C]\\end{code}\f[] will also +be treated as Haskell code. +.IP \[bu] 2 +In markdown output, code blocks with class \f[C]haskell\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). +(This is because ghc treats \[aq]#\[aq] characters in column 1 as +introducing line numbers.) +.IP \[bu] 2 +In restructured text input, "bird track" sections will be parsed as +Haskell code. +.IP \[bu] 2 +In restructured text output, code blocks with class \f[C]haskell\f[] +will be rendered using bird tracks. +.IP \[bu] 2 +In LaTeX input, text in \f[C]code\f[] environments will be parsed as +Haskell code. +.IP \[bu] 2 +In LaTeX output, code blocks with class \f[C]haskell\f[] will be +rendered inside \f[C]code\f[] environments. +.IP \[bu] 2 +In HTML output, code blocks with class \f[C]haskell\f[] will be rendered +with class \f[C]literatehaskell\f[] and bird tracks. +.PP +Examples: +.IP +.nf +\f[C] +pandoc\ -f\ markdown+lhs\ -t\ html +\f[] +.fi +.PP +reads literate Haskell source formatted with markdown conventions and +writes ordinary HTML (without bird tracks). +.IP +.nf +\f[C] +pandoc\ -f\ markdown+lhs\ -t\ html+lhs +\f[] +.fi +.PP +writes HTML with the Haskell code in bird tracks, so it can be copied +and pasted as literate Haskell source. +.SH AUTHORS +.PP +© 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. +.SH PANDOC'S MARKDOWN +For a complete description of pandoc's extensions to standard markdown, +see \f[C]pandoc_markdown\f[] (5). +.SH SEE ALSO +.PP +\f[C]markdown2pdf\f[] (1), \f[C]pandoc_markdown\f[] (5). +.PP +The Pandoc source code and all documentation may be downloaded +from . diff -Nru pandoc-1.5.1.1/man/man1/pandoc.1.md pandoc-1.8.0.3/man/man1/pandoc.1.md --- pandoc-1.5.1.1/man/man1/pandoc.1.md 2010-03-29 14:24:56.000000000 +0000 +++ pandoc-1.8.0.3/man/man1/pandoc.1.md 1970-01-01 00:00:00.000000000 +0000 @@ -1,359 +0,0 @@ -% PANDOC(1) Pandoc User Manuals -% John MacFarlane -% January 8, 2008 - -# NAME - -pandoc - general markup converter - -# SYNOPSIS - -pandoc [*options*] [*input-file*]... - -# DESCRIPTION - -Pandoc converts files from one markup format to another. It can -read markdown and (subsets of) reStructuredText, HTML, and LaTeX, and -it can write plain text, markdown, reStructuredText, HTML, LaTeX, -ConTeXt, Texinfo, groff man, MediaWiki markup, RTF, OpenDocument XML, -ODT, DocBook XML, and S5 HTML slide shows. - -If no *input-file* is specified, input is read from *stdin*. -Otherwise, the *input-files* are concatenated (with a blank -line between each) and used as input. Output goes to *stdout* by -default (though output to *stdout* is disabled for the `odt` output -format). For output to a file, use the `-o` option: - - pandoc -o output.html input.txt - -Instead of a file, an absolute URI may be given. In this case -pandoc will fetch the content using HTTP: - - pandoc -f html -t markdown http://www.fsf.org - -The input and output formats may be specified using command-line options -(see **OPTIONS**, below, for details). If these formats are not -specified explicitly, Pandoc will attempt to determine them -from the extensions of the input and output filenames. If input comes -from *stdin* or from a file with an unknown extension, the input is assumed -to be markdown. If no output filename is specified using the `-o` -option, or if a filename is specified but its extension is unknown, -the output will default to HTML. Thus, for example, - - pandoc -o chap1.tex chap1.txt - -converts *chap1.txt* from markdown to LaTeX. And - - pandoc README - -converts *README* from markdown to HTML. - -Pandoc's version of markdown is an extended variant of standard -markdown: the differences are described in the *README* file in -the user documentation. If standard markdown syntax is desired, the -`--strict` option may be used. - -Pandoc uses the UTF-8 character encoding for both input and output -(unless compiled with GHC 6.12 or higher, in which case it uses -the local encoding). If your local character encoding is not UTF-8, you -should pipe input and output through `iconv`: - - iconv -t utf-8 input.txt | pandoc | iconv -f utf-8 - -# OPTIONS - --f *FORMAT*, -r *FORMAT*, \--from=*FORMAT*, \--read=*FORMAT* -: Specify input format. *FORMAT* can be - `native` (native Haskell), `markdown` (markdown or plain text), - `rst` (reStructuredText), `html` (HTML), or `latex` (LaTeX). - If `+lhs` is appended to `markdown`, `rst`, or `latex`, the input - will be treated as literate Haskell source. - --t *FORMAT*, -w *FORMAT*, \--to=*FORMAT*, \--write=*FORMAT* -: Specify output format. *FORMAT* can be `native` (native Haskell), - `plain` (plain text), `markdown` (markdown), `rst` (reStructuredText), - `html` (HTML), `latex` (LaTeX), `context` (ConTeXt), `man` (groff man), - `mediawiki` (MediaWiki markup), `texinfo` (GNU Texinfo), - `docbook` (DocBook XML), `opendocument` (OpenDocument XML), - `odt` (OpenOffice text document), `s5` (S5 HTML and javascript slide - show), or `rtf` (rich text format). Note that `odt` 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`, or `html`, the output will be rendered as literate - Haskell source. - --s, \--standalone -: Produce output with an appropriate header and footer (e.g. a - standalone HTML, LaTeX, or RTF file, not a fragment). - --o *FILE*, \--output=*FILE* -: Write output to *FILE* instead of *stdout*. If *FILE* is - \``-`', output will go to *stdout*. - --p, \--preserve-tabs -: Preserve tabs instead of converting them to spaces. - -\--tab-stop=*TABSTOP* -: Specify tab stop (default is 4). - -\--strict -: Use strict markdown syntax, with no extensions or variants. - -\--reference-links -: Use reference-style links, rather than inline links, in writing markdown - or reStructuredText. - --R, \--parse-raw -: Parse untranslatable HTML codes and LaTeX environments as raw HTML - or LaTeX, instead of ignoring them. - --S, \--smart -: Use smart quotes, dashes, and ellipses. (This option is significant - only when the input format is `markdown`. It is selected automatically - when the output format is `latex` or `context`.) - --m*URL*, \--latexmathml=*URL* -: Use LaTeXMathML to display embedded TeX math in HTML output. - To insert a link to a local copy of the `LaTeXMathML.js` script, - provide a *URL*. If no *URL* is provided, the contents of the - script will be inserted directly into the HTML header. - -\--mathml -: Convert TeX math to MathML. In standalone mode, a small javascript - will be inserted that allows the MathML to be viewed on some browsers. - -\--jsmath=*URL* -: Use jsMath to display embedded TeX math in HTML output. - The *URL* should point to the jsMath load script; if provided, - it will be linked to in the header of standalone HTML documents. - -\--gladtex -: Enclose TeX math in `` tags in HTML output. These can then - be processed by gladTeX to produce links to images of the typeset - formulas. - -\--mimetex=*URL* -: Render TeX math using the mimeTeX CGI script. If *URL* is not specified, - it is assumed that the script is at `/cgi-bin/mimetex.cgi`. - --i, \--incremental -: Make list items in S5 display incrementally (one by one). - -\--xetex -: Create LaTeX outut suitable for processing by XeTeX. - --N, \--number-sections -: Number section headings in LaTeX, ConTeXt, or HTML output. - (Default is not to number them.) - -\--no-wrap -: Disable text wrapping in output. (Default is to wrap text.) - -\--sanitize-html -: Sanitizes HTML (in markdown or HTML input) using a whitelist. - Unsafe tags are replaced by HTML comments; unsafe attributes - are omitted. URIs in links and images are also checked against a - whitelist of URI schemes. - -\--email-obfuscation=*none|javascript|references* -: Specify a method for obfuscating `mailto:` links in HTML documents. - *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. - -\--indented-code-classes*=classes* -: Specify classes to use for indented code blocks--for example, - `perl,numberLines` or `haskell`. Multiple classes may be separated - by spaces or commas. - -\--toc, \--table-of-contents -: Include an automatically generated table of contents (HTML, markdown, - RTF) or an instruction to create one (LaTeX, reStructuredText). - This option has no effect on man, DocBook, or S5 output. - -\--base-header-level=*LEVEL* -: Specify the base level for headers (defaults to 1). - -\--template=*FILE* -: Use *FILE* as a custom template for the generated document. Implies - `-s`. See TEMPLATES below for a description of template syntax. If - this option is not used, a default template appropriate for the - output format will be used. See also `-D/--print-default-template`. - --V KEY=VAL, \--variable=*KEY:VAL* -: Set the template variable KEY to the value VAL when rendering the - document in standalone mode. This is only useful when the - `--template` option is used to specify a custom template, since - pandoc automatically sets the variables used in the default - templates. - --c *CSS*, \--css=*CSS* -: Link to a CSS style sheet. *CSS* is the pathname of the style sheet. - --H *FILE*, \--include-in-header=*FILE* -: Include contents of *FILE* at the end of the header. Implies `-s`. - --B *FILE*, \--include-before-body=*FILE* -: Include contents of *FILE* at the beginning of the document body. - Implies `-s`. - --A *FILE*, \--include-after-body=*FILE* -: Include contents of *FILE* at the end of the document body. - Implies `-s`. - --C *FILE*, \--custom-header=*FILE* -: Use contents of *FILE* as the document header. *Note: This option is - deprecated. Users should transition to using `--template` instead.* - -\--reference-odt=*filename* -: 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. The contents of the reference ODT - are ignored, but its stylesheets are used in the new ODT. If no - reference ODT is specified on the command line, pandoc will look - for a file `reference.odt` in the user data directory (see - `--data-dir`). If this is not found either, sensible defaults will be - used. - --D *FORMAT*, \--print-default-template=*FORMAT* -: Print the default template for an output *FORMAT*. (See `-t` - for a list of possible *FORMAT*s.) - --T *STRING*, \--title-prefix=*STRING* -: Specify *STRING* as a prefix to the HTML window title. - -\--data-dir*=DIRECTORY* -: 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: - - $HOME/.pandoc - - in unix and - - C:\Documents And Settings\USERNAME\Application Data\pandoc - - in Windows. A reference ODT, `templates` directory, `s5` directory - placed in this directory will override pandoc's normal defaults. - -\--dump-args -: Print information about command-line arguments to *stdout*, then exit. - The first line of output contains the name of the output file specified - with the `-o` option, or \``-`' (for *stdout*) if no output file was - specified. 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 \``--`' separator at the end of the line. - This option is intended primarily for use in wrapper scripts. - -\--ignore-args -: Ignore command-line arguments (for use in wrapper scripts). - Regular Pandoc options are not ignored. Thus, for example, - -: pandoc --ignore-args -o foo.html -s foo.txt -- -e latin1 - -: is equivalent to - -: pandoc -o foo.html -s - --v, \--version -: Print version. - --h, \--help -: Show usage message. - -# TEMPLATES - -When the `-s/--standalone` 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 - - pandoc --print-default-template=FORMAT - -where `FORMAT` is the name of the output format. A custom template -can be specified using the `--template` option. You can also override -the system default templates for a given output format `FORMAT` -by putting a file `templates/FORMAT.template` in the user data -directory (see `--data-dir`, below). - -Templates may contain *variables*. Variable names are sequences of -alphanumerics, `-`, and `_`, starting with a letter. A variable name -surrounded by `$` signs will be replaced by its value. For example, -the string `$title$` in - - $title$ - -will be replaced by the document title. - -To write a literal `$` in a template, use `$$`. - -Some variables are set automatically by pandoc. These vary somewhat -depending on the output format, but include: - -`legacy-header` -: contents specified by `-C/--custom-header` -`header-includes` -: contents specified by `-H/--include-in-header` (may have multiple - values) -`toc` -: non-null value if `--toc/--table-of-contents` was specified -`include-before` -: contents specified by `-B/--include-before-body` (may have - multiple values) -`include-after` -: contents specified by `-A/--include-after-body` (may have - multiple values) -`body` -: body of document -`title` -: title of document, as specified in title block -`author` -: author of document, as specified in title block (may have - multiple values) -`date` -: date of document, as specified in title block - -Variables may be set at the command line using the `-V/--variable` -option. This allows users to include custom variables in their -templates. - -Templates may contain conditionals. The syntax is as follows: - - $if(variable)$ - X - $else$ - Y - $endif$ - -This will include `X` in the template if `variable` has a non-null -value; otherwise it will include `Y`. `X` and `Y` are placeholders for -any valid template text, and may include interpolated variables or other -conditionals. The `$else$` section may be omitted. - -When variables can have multiple values (for example, `author` in -a multi-author document), you can use the `$for$` keyword: - - $for(author)$ - - $endfor$ - -You can optionally specify a separator to be used between -consecutive items: - - $for(author)$$author$$sep$, $endfor$ - -# SEE ALSO - -`markdown2pdf` (1). -The *README* file distributed with Pandoc contains full documentation. - -The Pandoc source code and all documentation may be downloaded from -. - diff -Nru pandoc-1.5.1.1/man/man1/pandoc.1.template pandoc-1.8.0.3/man/man1/pandoc.1.template --- pandoc-1.5.1.1/man/man1/pandoc.1.template 1970-01-01 00:00:00.000000000 +0000 +++ pandoc-1.8.0.3/man/man1/pandoc.1.template 2011-02-05 18:48:07.000000000 +0000 @@ -0,0 +1,16 @@ +$if(has-tables)$ +.\"t +$endif$ +.TH PANDOC 1 "$date$" "$title$" +.SH NAME +pandoc - general markup converter +$body$ +.SH PANDOC'S MARKDOWN +For a complete description of pandoc's extensions to standard markdown, +see \f[C]pandoc_markdown\f[] (5). +.SH SEE ALSO +.PP +\f[C]markdown2pdf\f[] (1), \f[C]pandoc_markdown\f[] (5). +.PP +The Pandoc source code and all documentation may be downloaded +from . diff -Nru pandoc-1.5.1.1/man/man5/pandoc_markdown.5 pandoc-1.8.0.3/man/man5/pandoc_markdown.5 --- pandoc-1.5.1.1/man/man5/pandoc_markdown.5 1970-01-01 00:00:00.000000000 +0000 +++ pandoc-1.8.0.3/man/man5/pandoc_markdown.5 2011-02-05 18:48:07.000000000 +0000 @@ -0,0 +1,1726 @@ +.\"t +.TH PANDOC_MARKDOWN 5 "January 29, 2011" "Pandoc" +.SH NAME +pandoc_markdown - markdown syntax for pandoc(1) +.SH DESCRIPTION +.PP +Pandoc understands an extended and slightly revised version of John +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. +.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 +text, without looking like it\[aq]s been marked up with tags or +formatting instructions. +-- John Gruber +.RE +.PP +This principle has guided pandoc\[aq]s decisions in finding syntax for +tables, footnotes, and other extensions. +.PP +There is, however, one respect in which pandoc\[aq]s aims are different +from the original aims of markdown. +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 +elements like definition lists, tables, mathematics, and footnotes. +.SH PARAGRAPHS +.PP +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 or type a backslash followed by a newline. +.SH HEADERS +.PP +There are two kinds of headers, Setext and atx. +.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 +level two header): +.IP +.nf +\f[C] +A\ level-one\ 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 +.PP +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-three\ header\ ### +\f[] +.fi +.PP +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* +\f[] +.fi +.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). +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). +Consider, for example: +.IP +.nf +\f[C] +I\ like\ several\ of\ their\ flavors\ of\ ice\ cream: +#22,\ for\ example,\ and\ #5. +\f[] +.fi +.SS Header identifiers in HTML +.PP +\f[I]Pandoc extension\f[]. +.PP +Each header element in pandoc\[aq]s HTML output is given a unique +identifier. +This identifier is based on the text of the header. +To derive the identifier from the header text, +.IP \[bu] 2 +Remove all formatting, links, etc. +.IP \[bu] 2 +Remove all punctuation, except underscores, hyphens, and periods. +.IP \[bu] 2 +Replace all spaces and newlines with hyphens. +.IP \[bu] 2 +Convert all alphabetic characters to lowercase. +.IP \[bu] 2 +Remove everything up to the first letter (identifiers may not begin with +a number or punctuation mark). +.IP \[bu] 2 +If nothing is left after this, use the identifier \f[C]section\f[]. +.PP +Thus, for example, +.PP +.TS +tab(@); +l l. +T{ +Header +T}@T{ +Identifier +T} +_ +T{ +Header identifiers in HTML +T}@T{ +\f[C]header-identifiers-in-html\f[] +T} +T{ +\f[I]Dogs\f[]?--in \f[I]my\f[] house? +T}@T{ +\f[C]dogs--in-my-house\f[] +T} +T{ +HTML, S5, or RTF? +T}@T{ +\f[C]html-s5-or-rtf\f[] +T} +T{ +3. +Applications +T}@T{ +\f[C]applications\f[] +T} +T{ +33 +T}@T{ +\f[C]section\f[] +T} +.TE +.PP +These rules should, in most cases, allow one to determine the identifier +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. +.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. +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: +.IP +.nf +\f[C] +See\ the\ section\ on +[header\ identifiers](#header-identifiers-in-html). +\f[] +.fi +.PP +Note, however, that this method of providing links to sections works +only in HTML. +.PP +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]
\f[] (or \f[C]
\f[]) tag rather than the +header itself. +This allows entire sections to be manipulated using javascript or +treated differently in CSS. +.SH BLOCK QUOTATIONS +.PP +Markdown uses email conventions for quoting blocks of text. +A block quotation is one or more paragraphs or other block elements +(such as lists or headers), with each line preceded by a \f[C]>\f[] +character and a space. +(The \f[C]>\f[] need not start at the left margin, but it should not be +indented more than three spaces.) +.IP +.nf +\f[C] +>\ This\ is\ a\ block\ quote.\ This +>\ paragraph\ has\ two\ lines. +> +>\ 1.\ This\ is\ a\ list\ inside\ a\ block\ quote. +>\ 2.\ Second\ item. +\f[] +.fi +.PP +A "lazy" form, which requires the \f[C]>\f[] character only on the first +line of each block, is also allowed: +.IP +.nf +\f[C] +>\ This\ is\ a\ block\ quote.\ This +paragraph\ has\ two\ lines. + +>\ 1.\ This\ is\ a\ list\ inside\ a\ block\ quote. +2.\ Second\ item. +\f[] +.fi +.PP +Among the block elements that can be contained in a block quote are +other block quotes. +That is, block quotes can be nested: +.IP +.nf +\f[C] +>\ This\ is\ a\ block\ quote. +> +>\ >\ A\ block\ quote\ within\ a\ block\ quote. +\f[] +.fi +.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 +document). +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: +.IP +.nf +\f[C] +>\ This\ is\ a\ block\ quote. +>>\ Nested. +\f[] +.fi +.SH VERBATIM (CODE) BLOCKS +.SS Indented code blocks +.PP +A block of text indented four spaces (or one tab) is treated as verbatim +text: that is, special characters do not trigger special formatting, and +all spaces and line breaks are preserved. +For example, +.IP +.nf +\f[C] +\ \ \ \ if\ (a\ >\ 3)\ { +\ \ \ \ \ \ moveShip(5\ *\ gravity,\ DOWN); +\ \ \ \ } +\f[] +.fi +.PP +The initial (four space or one tab) indentation is not considered part +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 +.PP +\f[I]Pandoc extension\f[]. +.PP +In addition to standard indented code blocks, Pandoc supports +\f[I]delimited\f[] code blocks. +These begin with a row of three or more tildes (\f[C]~\f[]) and end with +a row of tildes that must be at least as long as the starting row. +Everything between the tilde-lines is treated as code. +No indentation is necessary: +.IP +.nf +\f[C] +~~~~~~~ +if\ (a\ >\ 3)\ { +\ \ moveShip(5\ *\ gravity,\ DOWN); +} +~~~~~~~ +\f[] +.fi +.PP +Like regular code blocks, delimited code blocks must be separated from +surrounding text by blank lines. +.PP +If the code itself contains a row of tildes, just use a longer row of +tildes at the start and end: +.IP +.nf +\f[C] +~~~~~~~~~~~~~~~~ +~~~~~~~~~~ +code\ including\ tildes +~~~~~~~~~~ +~~~~~~~~~~~~~~~~ +\f[] +.fi +.PP +Optionally, you may specify the language of the code block using this +syntax: +.IP +.nf +\f[C] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\ {.haskell\ .numberLines} +qsort\ []\ \ \ \ \ =\ [] +qsort\ (x:xs)\ =\ qsort\ (filter\ (<\ x)\ xs)\ ++\ [x]\ ++ +\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ qsort\ (filter\ (>=\ x)\ xs)\ +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +\f[] +.fi +.PP +Some output formats can use this information to do syntax highlighting. +Currently, the only output format that uses this information is HTML. +.PP +If pandoc has been compiled with syntax highlighting support, then the +code block above will appear highlighted, with numbered lines. +(To see which languages are supported, do \f[C]pandoc\ --version\f[].) +.PP +If pandoc has not been compiled with syntax highlighting support, the +code block above will appear as follows: +.IP +.nf +\f[C] + +\ \ +\ \ ... +\ \ + +\f[] +.fi +.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[]). +Here is a simple example: +.IP +.nf +\f[C] +*\ one +*\ two +*\ three +\f[] +.fi +.PP +This will produce a "compact" list. +If you want a "loose" list, in which each item is formatted as a +paragraph, put spaces between the items: +.IP +.nf +\f[C] +*\ one + +*\ two + +*\ three +\f[] +.fi +.PP +The bullets need not be flush with the left margin; they may be indented +one, two, or three spaces. +The bullet must be followed by whitespace. +.PP +List items look best if subsequent lines are flush with the first line +(after the bullet): +.IP +.nf +\f[C] +*\ here\ is\ my\ first +\ \ list\ item. +*\ and\ my\ second. +\f[] +.fi +.PP +But markdown also allows a "lazy" format: +.IP +.nf +\f[C] +*\ here\ is\ my\ first +list\ item. +*\ and\ my\ second. +\f[] +.fi +.SS The four-space rule +.PP +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. +The list will look better if the first paragraph is aligned with the +rest: +.IP +.nf +\f[C] +\ \ *\ First\ paragraph. + +\ \ \ \ Continued. + +\ \ *\ Second\ paragraph.\ With\ a\ code\ block,\ which\ must\ be\ indented +\ \ \ \ eight\ spaces: + +\ \ \ \ \ \ \ \ {\ code\ } +\f[] +.fi +.PP +List items may include other lists. +In this case the preceding blank line is optional. +The nested list must be indented four spaces or one tab: +.IP +.nf +\f[C] +*\ fruits +\ \ \ \ +\ apples +\ \ \ \ \ \ \ \ -\ macintosh +\ \ \ \ \ \ \ \ -\ red\ delicious +\ \ \ \ +\ pears +\ \ \ \ +\ peaches +*\ vegetables +\ \ \ \ +\ brocolli +\ \ \ \ +\ chard +\f[] +.fi +.PP +As noted above, markdown allows you to write list items "lazily," +instead of indenting continuation lines. +However, if there are multiple paragraphs or other blocks in a list +item, the first line of each must be indented. +.IP +.nf +\f[C] ++\ A\ lazy,\ lazy,\ list +item. + ++\ Another\ one;\ this\ looks +bad\ but\ is\ legal. + +\ \ \ \ Second\ paragraph\ of\ second +list\ item. +\f[] +.fi +.PP +\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 +mentions paragraphs and code blocks. +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 +Ordered lists work just like bulleted lists, except that the items begin +with enumerators rather than bullets. +.PP +In standard markdown, enumerators are decimal numbers followed by a +period and a space. +The numbers themselves are ignored, so there is no difference between +this list: +.IP +.nf +\f[C] +1.\ \ one +2.\ \ two +3.\ \ three +\f[] +.fi +.PP +and this one: +.IP +.nf +\f[C] +5.\ \ one +7.\ \ two +1.\ \ three +\f[] +.fi +.PP +\f[I]Pandoc extension\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. +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 +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 by a single +parenthesis, starting with 9, and a sublist with lowercase roman +numerals: +.IP +.nf +\f[C] +\ 9)\ \ Ninth +10)\ \ Tenth +11)\ \ Eleventh +\ \ \ \ \ \ \ i.\ subone +\ \ \ \ \ \ ii.\ subtwo +\ \ \ \ \ iii.\ subthree +\f[] +.fi +.PP +Note that Pandoc pays attention only to the \f[I]starting\f[] marker in +a list. +So, the following yields a list numbered sequentially starting from 2: +.IP +.nf +\f[C] +(2)\ Two +(5)\ Three +1.\ \ Four +*\ \ \ Five +\f[] +.fi +.PP +If default list markers are desired, use \f[C]#.\f[]: +.IP +.nf +\f[C] +#.\ \ one +#.\ \ two +#.\ \ three +\f[] +.fi +.SS Definition lists +.PP +\f[I]Pandoc extension\f[]. +.PP +Pandoc supports definition lists, using a syntax inspired by PHP +Markdown Extra and reStructuredText:[2] +.IP +.nf +\f[C] +Term\ 1 + +:\ \ \ Definition\ 1 + +Term\ 2\ with\ *inline\ markup* + +:\ \ \ Definition\ 2 + +\ \ \ \ \ \ \ \ {\ some\ code,\ part\ of\ Definition\ 2\ } + +\ \ \ \ Third\ paragraph\ of\ definition\ 2. +\f[] +.fi +.PP +Each term must fit on one line, which may optionally be followed by a +blank line, and must be followed by one or more definitions. +A definition begins with a colon or tilde, which may be indented one or +two 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. +.PP +If you leave space after the definition (as in the example above), the +blocks of the definitions will be considered paragraphs. +In some output formats, this will mean greater spacing between +term/definition pairs. +For a compact definition list, do not leave space between the definition +and the next term: +.IP +.nf +\f[C] +Term\ 1 +\ \ ~\ Definition\ 1 +Term\ 2 +\ \ ~\ Definition\ 2a +\ \ ~\ Definition\ 2b +\f[] +.fi +.SS Numbered example lists +.PP +\f[I]Pandoc extension\f[]. +.PP +The special list marker \f[C]\@\f[] can be used for sequentially +numbered examples. +The first list item with a \f[C]\@\f[] marker will be numbered +\[aq]1\[aq], the next \[aq]2\[aq], and so on, throughout the document. +The numbered examples need not occur in a single list; each new list +using \f[C]\@\f[] will take up where the last stopped. +So, for example: +.IP +.nf +\f[C] +(\@)\ \ My\ first\ example\ will\ be\ numbered\ (1). +(\@)\ \ My\ second\ example\ will\ be\ numbered\ (2). + +Explanation\ of\ examples. + +(\@)\ \ My\ third\ example\ will\ be\ numbered\ (3). +\f[] +.fi +.PP +Numbered examples can be labeled and referred to elsewhere in the +document: +.IP +.nf +\f[C] +(\@good)\ \ This\ is\ a\ good\ example. + +As\ (\@good)\ illustrates,\ ... +\f[] +.fi +.PP +The label can be any string of alphanumeric characters, underscores, or +hyphens. +.SS Compact and loose lists +.PP +Pandoc behaves differently from \f[C]Markdown.pl\f[] on some "edge +cases" involving lists. +Consider this source: +.IP +.nf +\f[C] ++\ \ \ First ++\ \ \ Second: +\ -\ \ \ Fee +\ -\ \ \ Fie +\ -\ \ \ Foe + ++\ \ \ Third +\f[] +.fi +.PP +Pandoc transforms this into a "compact list" (with no \f[C]

\f[] tags +around "First", "Second", or "Third"), while markdown puts \f[C]

\f[] +tags around "Second" and "Third" (but not "First"), because of the blank +space around "Third". +Pandoc follows a simple rule: if the text is followed by a blank line, +it is treated as a paragraph. +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. +This behavior is consistent with the official markdown syntax +description, even though it is different from that of +\f[C]Markdown.pl\f[].) +.SS Ending a list +.PP +What if you want to put an indented code block after a list? +.IP +.nf +\f[C] +-\ \ \ item\ one +-\ \ \ item\ two + +\ \ \ \ {\ my\ code\ block\ } +\f[] +.fi +.PP +Trouble! Here pandoc (like other markdown implementations) will treat +\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 +content, like an HTML comment, which won\[aq]t produce visible output in +any format: +.IP +.nf +\f[C] +-\ \ \ item\ one +-\ \ \ item\ two + + + +\ \ \ \ {\ my\ code\ block\ } +\f[] +.fi +.PP +You can use the same trick if you want two consecutive lists instead of +one big list: +.IP +.nf +\f[C] +1.\ \ one +2.\ \ two +3.\ \ three + + + +a.\ \ uno +b.\ \ dos +c.\ \ tres +\f[] +.fi +.SH HORIZONTAL RULES +.PP +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 +.nf +\f[C] +*\ \ *\ \ *\ \ * + +--------------- +\f[] +.fi +.SH TABLES +.PP +\f[I]Pandoc extension\f[]. +.PP +Three kinds of tables may be used. +All three kinds presuppose the use of a fixed-width font, such as +Courier. +.PP +\f[B]Simple tables\f[] look like this: +.IP +.nf +\f[C] +\ \ Right\ \ \ \ \ Left\ \ \ \ \ Center\ \ \ \ \ Default +-------\ \ \ \ \ ------\ ----------\ \ \ ------- +\ \ \ \ \ 12\ \ \ \ \ 12\ \ \ \ \ \ \ \ 12\ \ \ \ \ \ \ \ \ \ \ \ 12 +\ \ \ \ 123\ \ \ \ \ 123\ \ \ \ \ \ \ 123\ \ \ \ \ \ \ \ \ \ 123 +\ \ \ \ \ \ 1\ \ \ \ \ 1\ \ \ \ \ \ \ \ \ \ 1\ \ \ \ \ \ \ \ \ \ \ \ \ 1 + +Table:\ \ Demonstration\ of\ simple\ table\ syntax. +\f[] +.fi +.PP +The headers and table rows must each fit on one line. +Column alignments are determined by the position of the header text +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. +.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. +.IP \[bu] 2 +If the dashed line extends beyond the header text on both sides, the +column is centered. +.IP \[bu] 2 +If the dashed line is flush with the header text on both sides, the +default alignment is used (in most cases, this will be left). +.PP +The table must end with a blank line, or a line of dashes followed by a +blank line. +A caption may optionally be provided (as illustrated in the example +above). +A caption is a paragraph beginning with the string \f[C]Table:\f[] (or +just \f[C]:\f[]), which will be stripped off. +It may appear either before or after the table. +.PP +The column headers may be omitted, provided a dashed line is used to end +the table. +For example: +.IP +.nf +\f[C] +-------\ \ \ \ \ ------\ ----------\ \ \ ------- +\ \ \ \ \ 12\ \ \ \ \ 12\ \ \ \ \ \ \ \ 12\ \ \ \ \ \ \ \ \ \ \ \ \ 12 +\ \ \ \ 123\ \ \ \ \ 123\ \ \ \ \ \ \ 123\ \ \ \ \ \ \ \ \ \ \ 123 +\ \ \ \ \ \ 1\ \ \ \ \ 1\ \ \ \ \ \ \ \ \ \ 1\ \ \ \ \ \ \ \ \ \ \ \ \ \ 1 +-------\ \ \ \ \ ------\ ----------\ \ \ ------- +\f[] +.fi +.PP +When headers are omitted, column alignments are determined on the basis +of the first line of the table body. +So, in the tables above, the columns would be right, left, center, and +right aligned, respectively. +.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). +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. +\f[] +.fi +.PP +These work like simple tables, but with the following differences: +.IP \[bu] 2 +They must begin with a row of dashes, before the header text (unless the +headers are omitted). +.IP \[bu] 2 +They must end with a row of dashes, then a blank line. +.IP \[bu] 2 +The rows must be separated by blank lines. +.PP +In multiline tables, the table parser pays attention to the widths of +the columns, and the writers try to reproduce these relative widths in +the output. +So, if you find that one of the columns is too narrow in the output, try +widening it in the markdown source. +.PP +Headers may be omitted in multiline tables as well as simple tables: +.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[] +.fi +.PP +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. +.PP +\f[B]Grid tables\f[] 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\ \ \ \ \ \ \ \ \ \ \ \ | ++---------------+---------------+--------------------+ +\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.) +\&. +Alignments are not supported, nor are cells that span multiple columns +or rows. +Grid tables can be created easily using Emacs table mode. +.SH TITLE BLOCK +.PP +\f[I]Pandoc extension\f[]. +.PP +If the file begins with a title block +.IP +.nf +\f[C] +%\ title +%\ author(s)\ (separated\ by\ semicolons) +%\ date +\f[] +.fi +.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. +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 +.nf +\f[C] +% +%\ Author + +%\ My\ title +% +%\ June\ 15,\ 2006 +\f[] +.fi +.PP +The title may occupy multiple lines, but continuation lines must begin +with leading space, thus: +.IP +.nf +\f[C] +%\ My\ title +\ \ on\ multiple\ lines +\f[] +.fi +.PP +If a document has multiple authors, the authors may be put on separate +lines with leading space, or separated by semicolons, or both. +So, all of the following are equivalent: +.IP +.nf +\f[C] +%\ Author\ One +\ \ Author\ Two + +%\ Author\ One;\ Author\ Two + +%\ Author\ One; +\ \ Author\ Two +\f[] +.fi +.PP +The date must fit on one line. +.PP +All three metadata fields may contain standard inline formatting +(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 -- +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. +The title in the document head can have an optional prefix attached +(\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 +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. +(There should be no space between the title and the parentheses.) + 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, +.IP +.nf +\f[C] +%\ PANDOC(1) +\f[] +.fi +.PP +will yield a man page with the title \f[C]PANDOC\f[] and section 1. +.IP +.nf +\f[C] +%\ PANDOC(1)\ Pandoc\ User\ Manuals +\f[] +.fi +.PP +will also have "Pandoc User Manuals" in the footer. +.IP +.nf +\f[C] +%\ PANDOC(1)\ Pandoc\ User\ Manuals\ |\ Version\ 4.0 +\f[] +.fi +.PP +will also have "Version 4.0" in the header. +.SH BACKSLASH ESCAPES +.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. +Thus, for example, if one writes +.IP +.nf +\f[C] +*\\*hello\\** +\f[] +.fi +.PP +one will get +.IP +.nf +\f[C] +*hello* +\f[] +.fi +.PP +instead of +.IP +.nf +\f[C] +hello +\f[] +.fi +.PP +This rule is easier to remember than standard markdown\[aq]s rule, which +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 +markdown rule will be used.) +.PP +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 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 +\f[C]\f[]. +This is a nice alternative to markdown\[aq]s "invisible" way of +indicating hard line breaks using two trailing spaces on a line. +.PP +Backslash escapes do not work in verbatim contexts. +.SH SMART PUNCTUATION +.PP +If the \f[C]--smart\f[] option is specified, pandoc will produce +typographically correct output, converting straight quotes to curly +quotes, \f[C]---\f[] and \f[C]--\f[] to Em-dashes, and \f[C]...\f[] to +ellipses. +Nonbreaking spaces are inserted after certain abbreviations, such as +"Mr." +.SH INLINE FORMATTING +.SS Emphasis +.PP +To \f[I]emphasize\f[] some text, surround it with \f[C]*\f[]s or +\f[C]_\f[], like this: +.IP +.nf +\f[C] +This\ text\ is\ _emphasized\ with\ underscores_,\ and\ this +is\ *emphasized\ with\ asterisks*. +\f[] +.fi +.PP +Double \f[C]*\f[] or \f[C]_\f[] produces \f[B]strong emphasis\f[]: +.IP +.nf +\f[C] +This\ is\ **strong\ emphasis**\ and\ __with\ underscores__. +\f[] +.fi +.PP +A \f[C]*\f[] or \f[C]_\f[] character surrounded by spaces, or +backslash-escaped, will not trigger emphasis: +.IP +.nf +\f[C] +This\ is\ *\ not\ emphasized\ *,\ and\ \\*neither\ is\ this\\*. +\f[] +.fi +.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. +If you want to emphasize just part of a word, use \f[C]*\f[]: +.IP +.nf +\f[C] +feas*ible*,\ not\ feas*able*. +\f[] +.fi +.SS Strikeout +.PP +\f[I]Pandoc extension\f[]. +.PP +To strikeout a section of text with a horizontal line, begin and end it +with \f[C]~~\f[]. +Thus, for example, +.IP +.nf +\f[C] +This\ ~~is\ deleted\ text.~~ +\f[] +.fi +.SS Superscripts and subscripts +.PP +\f[I]Pandoc extension\f[]. +.PP +Superscripts may be written by surrounding the superscripted text by +\f[C]^\f[] characters; subscripts may be written by surrounding the +subscripted text by \f[C]~\f[] characters. +Thus, for example, +.IP +.nf +\f[C] +H~2~O\ is\ a\ liquid.\ \ 2^10^\ is\ 1024. +\f[] +.fi +.PP +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[]. +.SS Verbatim +.PP +To make a short span of text verbatim, put it inside backticks: +.IP +.nf +\f[C] +What\ is\ the\ difference\ between\ `>>=`\ and\ `>>`? +\f[] +.fi +.PP +If the verbatim text includes a backtick, use double backticks: +.IP +.nf +\f[C] +Here\ is\ a\ literal\ backtick\ ``\ `\ ``. +\f[] +.fi +.PP +(The spaces after the opening backticks and before the closing backticks +will be ignored.) +.PP +The general rule is that a verbatim span starts with a string of +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 +in verbatim contexts: +.IP +.nf +\f[C] +This\ is\ a\ backslash\ followed\ by\ an\ asterisk:\ `\\*`. +\f[] +.fi +.SH MATH +.PP +\f[I]Pandoc extension\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, +while the closing \f[C]$\f[] must have a character immediately to its +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 +delimiters. +.PP +TeX math will be printed in all output formats. +How it is rendered depends on the output format: +.TP +.B Markdown, reStructuredText, LaTeX, Org-Mode, ConTeXt +It will appear verbatim between \f[C]$\f[] characters. +.RS +.RE +.TP +.B reStructuredText +It will be rendered using an interpreted text role \f[C]:math:\f[], as +described here. +.RS +.RE +.TP +.B Texinfo +It will be rendered inside a \f[C]\@math\f[] command. +.RS +.RE +.TP +.B groff man +It will be rendered verbatim without \f[C]$\f[]\[aq]s. +.RS +.RE +.TP +.B MediaWiki +It will be rendered inside \f[C]\f[] tags. +.RS +.RE +.TP +.B Textile +It will be rendered inside \f[C]\f[] tags. +.RS +.RE +.TP +.B RTF, Docbook, OpenDocument, ODT +It will be rendered, if possible, using unicode characters, and will +otherwise appear verbatim. +.RS +.RE +.TP +.B HTML, Slidy, 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]\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.) +.IP "3." 3 +If the \f[C]--jsmath\f[] option is used, TeX math will be put inside +\f[C]\f[] tags (for inline math) or \f[C]

\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. +This should work in all browsers. +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[]. +.IP "5." 3 +If the \f[C]--gladtex\f[] option is used, TeX formulas will be enclosed +in \f[C]\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. +So, the procedure is: +.RS 4 +.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 +\f[] +.fi +.RE +.IP "6." 3 +If the \f[C]--webtex\f[] option is used, TeX formulas will be converted +to \f[C]\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[]). +.RE +.SH RAW HTML +.PP +Markdown allows you to insert raw HTML anywhere in a document (except +verbatim contexts, where \f[C]<\f[], \f[C]>\f[], and \f[C]&\f[] are +interpreted literally). +.PP +The raw HTML is passed through unchanged in HTML, S5, Slidy, EPUB, +Markdown, and Textile output, and suppressed in other formats. +.PP +\f[I]Pandoc extension\f[]. +.PP +Standard markdown allows you to include HTML "blocks": blocks of HTML +between balanced tags that are separated from the surrounding text with +blank lines, and start and end at the left margin. +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. +Thus, for example, Pandoc will turn +.IP +.nf +\f[C] + +\ +\ \ +\ \ +\ +
*one*[a\ link](http://google.com)
+\f[] +.fi +.PP +into +.IP +.nf +\f[C] + +\ +\ \ +\ \ +\ +
onea\ link
+\f[] +.fi +.PP +whereas \f[C]Markdown.pl\f[] will preserve it as is. +.PP +There is one exception to this rule: text between \f[C]` tags is not interpreted as markdown. +`" - -htmlBlockElement :: GenParser Char ParserState [Char] -htmlBlockElement = choice [ htmlScript, htmlStyle, htmlComment, xmlDec, definition ] - -rawHtmlBlock :: GenParser Char ParserState Block -rawHtmlBlock = try $ do - body <- htmlBlockElement <|> rawVerbatimBlock <|> anyHtmlBlockTag - state <- getState - if stateParseRaw state then return (RawHtml body) else return Null - --- This is a block whose contents should be passed through verbatim, not interpreted. -rawVerbatimBlock :: GenParser Char ParserState [Char] -rawVerbatimBlock = try $ do - start <- anyHtmlBlockTag - let tagtype = extractTagType start - if tagtype `elem` ["pre"] - then do - contents <- many (notFollowedBy' (htmlEndTag tagtype) >> anyChar) - end <- htmlEndTag tagtype - return $ start ++ contents ++ end - else fail "Not a verbatim block" - --- We don't want to parse or as raw HTML, since these --- are handled in parseHtml. -rawHtmlBlock' :: GenParser Char ParserState Block -rawHtmlBlock' = do notFollowedBy' (htmlTag "/body" <|> htmlTag "/html") - rawHtmlBlock - --- | Parses an HTML comment. -htmlComment :: GenParser Char st [Char] -htmlComment = try $ do - string "" - return $ "" - --- --- parsing documents --- - -xmlDec :: GenParser Char st [Char] -xmlDec = try $ do - string "') - return $ "" - -definition :: GenParser Char st [Char] -definition = try $ do - string "') - return $ "" - -nonTitleNonHead :: GenParser Char ParserState Char -nonTitleNonHead = try $ do - notFollowedBy $ (htmlTag "title" >> return ' ') <|> - (htmlEndTag "head" >> return ' ') - (rawHtmlBlock >> return ' ') <|> anyChar - -parseTitle :: GenParser Char ParserState [Inline] -parseTitle = try $ do - (tag, _) <- htmlTag "title" - contents <- inlinesTilEnd tag - spaces - return contents - --- parse header and return meta-information (for now, just title) -parseHead :: GenParser Char ParserState Meta -parseHead = try $ do - htmlTag "head" - spaces - skipMany nonTitleNonHead - contents <- option [] parseTitle - skipMany nonTitleNonHead - htmlEndTag "head" - return $ Meta contents [] [] - -skipHtmlTag :: String -> GenParser Char ParserState () -skipHtmlTag tag = optional (htmlTag tag) - --- h1 class="title" representation of title in body -bodyTitle :: GenParser Char ParserState [Inline] -bodyTitle = try $ do - (_, attribs) <- htmlTag "h1" - case (extractAttribute "class" attribs) of - Just "title" -> return "" - _ -> fail "not title" - inlinesTilEnd "h1" - -endOfDoc :: GenParser Char ParserState () -endOfDoc = try $ do - spaces - optional (htmlEndTag "body") - spaces - optional (htmlEndTag "html" >> many anyChar) -- ignore stuff after - eof - -parseHtml :: GenParser Char ParserState Pandoc -parseHtml = do - sepEndBy (choice [xmlDec, definition, htmlComment]) spaces - spaces - skipHtmlTag "html" - spaces - meta <- option (Meta [] [] []) parseHead - spaces - skipHtmlTag "body" - spaces - optional bodyTitle -- skip title in body, because it's represented in meta - blocks <- parseBlocks - endOfDoc - return $ Pandoc meta blocks - --- --- parsing blocks --- - -parseBlocks :: GenParser Char ParserState [Block] -parseBlocks = spaces >> sepEndBy block spaces >>= (return . filter (/= Null)) - -block :: GenParser Char ParserState Block -block = choice [ codeBlock - , header - , hrule - , list - , blockQuote - , para - , plain - , rawHtmlBlock' - , notFollowedBy' endOfDoc >> char '<' >> return Null - ] "block" - --- --- header blocks --- - -header :: GenParser Char ParserState Block -header = choice (map headerLevel (enumFromTo 1 5)) "header" - -headerLevel :: Int -> GenParser Char ParserState Block -headerLevel n = try $ do - let level = "h" ++ show n - htmlTag level - contents <- inlinesTilEnd level - return $ Header n (normalizeSpaces contents) - --- --- hrule block --- - -hrule :: GenParser Char ParserState Block -hrule = try $ do - (_, attribs) <- htmlTag "hr" - state <- getState - if not (null attribs) && stateParseRaw state - then unexpected "attributes in hr" -- parse as raw in this case - else return HorizontalRule - --- --- code blocks --- - --- Note: HTML tags in code blocks (e.g. for syntax highlighting) are --- skipped, because they are not portable to output formats other than HTML. -codeBlock :: GenParser Char ParserState Block -codeBlock = try $ do - htmlTag "pre" - result <- manyTill - (many1 (satisfy (/= '<')) <|> - ((anyHtmlTag <|> anyHtmlEndTag) >> return "")) - (htmlEndTag "pre") - let result' = concat result - -- drop leading newline if any - let result'' = if "\n" `isPrefixOf` result' - then drop 1 result' - else result' - -- drop trailing newline if any - let result''' = if "\n" `isSuffixOf` result'' - then init result'' - else result'' - return $ CodeBlock ("",[],[]) $ decodeCharacterReferences result''' - --- --- block quotes --- - -blockQuote :: GenParser Char ParserState Block -blockQuote = try $ htmlTag "blockquote" >> spaces >> - blocksTilEnd "blockquote" >>= (return . BlockQuote) - --- --- list blocks --- - -list :: GenParser Char ParserState Block -list = choice [ bulletList, orderedList, definitionList ] "list" - -orderedList :: GenParser Char ParserState Block -orderedList = try $ do - (_, attribs) <- htmlTag "ol" - (start, style) <- option (1, DefaultStyle) $ - do failIfStrict - let sta = fromMaybe "1" $ - lookup "start" attribs - let sty = fromMaybe (fromMaybe "" $ - lookup "style" attribs) $ - lookup "class" attribs - let sty' = case sty of - "lower-roman" -> LowerRoman - "upper-roman" -> UpperRoman - "lower-alpha" -> LowerAlpha - "upper-alpha" -> UpperAlpha - "decimal" -> Decimal - _ -> DefaultStyle - return (read sta, sty') - spaces - -- note: if they have an
    or
      not in scope of a
    • , - -- treat it as a list item, though it's not valid xhtml... - items <- sepEndBy1 (blocksIn "li" <|> liftM (:[]) list) spaces - htmlEndTag "ol" - return $ OrderedList (start, style, DefaultDelim) items - -bulletList :: GenParser Char ParserState Block -bulletList = try $ do - htmlTag "ul" - spaces - -- note: if they have an
        or
          not in scope of a
        • , - -- treat it as a list item, though it's not valid xhtml... - items <- sepEndBy1 (blocksIn "li" <|> liftM (:[]) list) spaces - htmlEndTag "ul" - return $ BulletList items - -definitionList :: GenParser Char ParserState Block -definitionList = try $ do - failIfStrict -- def lists not part of standard markdown - htmlTag "dl" - spaces - items <- sepEndBy1 definitionListItem spaces - htmlEndTag "dl" - return $ DefinitionList items - -definitionListItem :: GenParser Char ParserState ([Inline], [[Block]]) -definitionListItem = try $ do - terms <- sepEndBy1 (inlinesIn "dt") spaces - defs <- sepEndBy1 (blocksIn "dd") spaces - let term = intercalate [LineBreak] terms - return (term, defs) - --- --- paragraph block --- - -para :: GenParser Char ParserState Block -para = try $ htmlTag "p" >> inlinesTilEnd "p" >>= - return . Para . normalizeSpaces - --- --- plain block --- - -plain :: GenParser Char ParserState Block -plain = many1 inline >>= return . Plain . normalizeSpaces - --- --- inline --- - -inline :: GenParser Char ParserState Inline -inline = choice [ charRef - , strong - , emph - , superscript - , subscript - , strikeout - , spanStrikeout - , code - , str - , linebreak - , whitespace - , link - , image - , rawHtmlInline - , char '&' >> return (Str "&") -- common HTML error - ] "inline" - -code :: GenParser Char ParserState Inline -code = try $ do - htmlTag "code" - result <- manyTill anyChar (htmlEndTag "code") - -- remove internal line breaks, leading and trailing space, - -- and decode character references - return $ Code $ decodeCharacterReferences $ removeLeadingTrailingSpace $ - intercalate " " $ lines result - -rawHtmlInline :: GenParser Char ParserState Inline -rawHtmlInline = do - result <- anyHtmlInlineTag <|> htmlComment - state <- getState - if stateParseRaw state then return (HtmlInline result) else return (Str "") - -betweenTags :: [Char] -> GenParser Char ParserState [Inline] -betweenTags tag = try $ htmlTag tag >> inlinesTilEnd tag >>= - return . normalizeSpaces - -emph :: GenParser Char ParserState Inline -emph = (betweenTags "em" <|> betweenTags "i") >>= return . Emph - -strong :: GenParser Char ParserState Inline -strong = (betweenTags "b" <|> betweenTags "strong") >>= return . Strong - -superscript :: GenParser Char ParserState Inline -superscript = failIfStrict >> betweenTags "sup" >>= return . Superscript - -subscript :: GenParser Char ParserState Inline -subscript = failIfStrict >> betweenTags "sub" >>= return . Subscript - -strikeout :: GenParser Char ParserState Inline -strikeout = failIfStrict >> (betweenTags "s" <|> betweenTags "strike") >>= - return . Strikeout - -spanStrikeout :: GenParser Char ParserState Inline -spanStrikeout = try $ do - failIfStrict -- strict markdown has no strikeout, so treat as raw HTML - (_, attributes) <- htmlTag "span" - result <- case (extractAttribute "class" attributes) of - Just "strikeout" -> inlinesTilEnd "span" - _ -> fail "not a strikeout" - return $ Strikeout result - -whitespace :: GenParser Char st Inline -whitespace = many1 space >> return Space - --- hard line break -linebreak :: GenParser Char ParserState Inline -linebreak = htmlTag "br" >> optional newline >> return LineBreak - -str :: GenParser Char st Inline -str = many1 (noneOf "< \t\n&") >>= return . Str - --- --- links and images --- - --- extract contents of attribute (attribute names are case-insensitive) -extractAttribute :: [Char] -> [([Char], String)] -> Maybe String -extractAttribute _ [] = Nothing -extractAttribute name ((attrName, contents):rest) = - let name' = map toLower name - attrName' = map toLower attrName - in if attrName' == name' - then Just (decodeCharacterReferences contents) - else extractAttribute name rest - -link :: GenParser Char ParserState Inline -link = try $ do - (_, attributes) <- htmlTag "a" - url <- case (extractAttribute "href" attributes) of - Just url -> return url - Nothing -> fail "no href" - let title = fromMaybe "" $ extractAttribute "title" attributes - lab <- inlinesTilEnd "a" - return $ Link (normalizeSpaces lab) (escapeURI url, title) - -image :: GenParser Char ParserState Inline -image = try $ do - (_, attributes) <- htmlTag "img" - url <- case (extractAttribute "src" attributes) of - Just url -> return url - Nothing -> fail "no src" - let title = fromMaybe "" $ extractAttribute "title" attributes - let alt = fromMaybe "" (extractAttribute "alt" attributes) - return $ Image [Str alt] (escapeURI url, title) +--- parsers for use in markdown, textile readers +-- | Matches a stretch of HTML in balanced tags. +htmlInBalanced :: (Tag String -> Bool) -> GenParser 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) + 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 f = try $ do + lookAhead (char '<') + (next : _) <- getInput >>= return . canonicalizeTags . parseTags + guard $ f next + -- advance the parser + case next of + TagComment s -> do + count (length s + 4) anyChar + skipMany (satisfy (/='>')) + char '>' + return (next, "") + _ -> do + rendered <- manyTill anyChar (char '>') + return (next, rendered ++ ">") diff -Nru pandoc-1.5.1.1/src/Text/Pandoc/Readers/LaTeX.hs pandoc-1.8.0.3/src/Text/Pandoc/Readers/LaTeX.hs --- pandoc-1.5.1.1/src/Text/Pandoc/Readers/LaTeX.hs 2010-03-29 14:24:56.000000000 +0000 +++ pandoc-1.8.0.3/src/Text/Pandoc/Readers/LaTeX.hs 2011-02-05 18:48:07.000000000 +0000 @@ -35,11 +35,12 @@ import Text.ParserCombinators.Parsec import Text.Pandoc.Definition -import Text.Pandoc.Shared +import Text.Pandoc.Shared +import Text.Pandoc.Parsing import Data.Maybe ( fromMaybe ) -import Data.Char ( chr ) -import Data.List ( isPrefixOf, isSuffixOf ) -import Control.Monad ( when ) +import Data.Char ( chr, toUpper ) +import Data.List ( intercalate, isPrefixOf, isSuffixOf ) +import Control.Monad -- | Parse LaTeX from string and return 'Pandoc' document. readLaTeX :: ParserState -- ^ Parser state, including options for parser @@ -49,7 +50,7 @@ -- characters with special meaning specialChars :: [Char] -specialChars = "\\`$%^&_~#{}\n \t|<>'\"-" +specialChars = "\\`$%^&_~#{}[]\n \t|<>'\"-" -- -- utility functions @@ -63,7 +64,7 @@ -- | Returns an option or argument of a LaTeX command. optOrArg :: GenParser Char st [Char] -optOrArg = bracketedText '{' '}' <|> bracketedText '[' ']' +optOrArg = try $ spaces >> (bracketedText '{' '}' <|> bracketedText '[' ']') -- | True if the string begins with '{'. isArg :: [Char] -> Bool @@ -85,14 +86,22 @@ begin :: [Char] -> GenParser Char st [Char] begin name = try $ do - string $ "\\begin{" ++ name ++ "}" + string "\\begin" + spaces + char '{' + string name + char '}' optional commandArgs spaces return name end :: [Char] -> GenParser Char st [Char] end name = try $ do - string $ "\\end{" ++ name ++ "}" + string "\\end" + spaces + char '{' + string name + char '}' return name -- | Returns a list of block elements containing the contents of an @@ -102,7 +111,9 @@ anyEnvironment :: GenParser Char ParserState Block anyEnvironment = try $ do - string "\\begin{" + string "\\begin" + spaces + char '{' name <- many letter star <- option "" (string "*") -- some environments have starred variants char '}' @@ -118,22 +129,17 @@ -- | Process LaTeX preamble, extracting metadata. processLaTeXPreamble :: GenParser Char ParserState () -processLaTeXPreamble = try $ manyTill - (choice [bibliographic, comment, unknownCommand, nullBlock]) - (try (string "\\begin{document}")) >> - spaces +processLaTeXPreamble = do + try $ string "\\documentclass" + skipMany $ bibliographic <|> macro <|> commentBlock <|> skipChar -- | Parse LaTeX and return 'Pandoc'. parseLaTeX :: GenParser Char ParserState Pandoc parseLaTeX = do - optional processLaTeXPreamble -- preamble might not be present (fragment) spaces - blocks <- parseBlocks - spaces - optional $ try (string "\\end{document}" >> many anyChar) - -- might not be present (fragment) - spaces - eof + skipMany $ comment >> spaces + blocks <- try (processLaTeXPreamble >> environment "document") + <|> (many block >>~ (spaces >> eof)) state <- getState let blocks' = filter (/= Null) blocks let title' = stateTitle state @@ -154,29 +160,53 @@ , header , list , blockQuote - , comment + , simpleTable + , commentBlock + , macro , bibliographic , para , itemBlock , unknownEnvironment , ignore - , unknownCommand ] "block" + , unknownCommand + ] "block" -- -- header blocks -- header :: GenParser Char ParserState Block -header = try $ do +header = section <|> chapter + +chapter :: GenParser Char ParserState Block +chapter = try $ do + string "\\chapter" + result <- headerWithLevel 1 + updateState $ \s -> s{ stateHasChapters = True } + return result + +section :: GenParser Char ParserState Block +section = try $ do char '\\' subs <- many (try (string "sub")) base <- try (string "section" >> return 1) <|> (string "paragraph" >> return 4) + st <- getState + let lev = if stateHasChapters st + then length subs + base + 1 + else length subs + base + headerWithLevel lev + +headerWithLevel :: Int -> GenParser Char ParserState Block +headerWithLevel lev = try $ do + spaces optional (char '*') + spaces optional $ bracketedText '[' ']' -- alt title + spaces char '{' title' <- manyTill inline (char '}') spaces - return $ Header (length subs + base) (normalizeSpaces title') + return $ Header lev (normalizeSpaces title') -- -- hrule block @@ -186,20 +216,77 @@ hrule = oneOfStrings [ "\\begin{center}\\rule{3in}{0.4pt}\\end{center}\n\n", "\\newpage" ] >> spaces >> return HorizontalRule +-- tables + +simpleTable :: GenParser Char ParserState Block +simpleTable = try $ do + string "\\begin" + spaces + string "{tabular}" + spaces + aligns <- parseAligns + let cols = length aligns + optional hline + header' <- option [] $ parseTableHeader cols + rows <- many (parseTableRow cols >>~ optional hline) + spaces + end "tabular" + spaces + let header'' = if null header' + then replicate cols [] + else header' + return $ Table [] aligns (replicate cols 0) header'' rows + +hline :: GenParser Char st () +hline = try $ spaces >> string "\\hline" >> return () + +parseAligns :: GenParser Char ParserState [Alignment] +parseAligns = try $ do + char '{' + optional $ char '|' + let cAlign = char 'c' >> return AlignCenter + let lAlign = char 'l' >> return AlignLeft + let rAlign = char 'r' >> return AlignRight + let alignChar = cAlign <|> lAlign <|> rAlign + aligns' <- sepEndBy alignChar (optional $ char '|') + char '}' + spaces + return aligns' + +parseTableHeader :: Int -- ^ number of columns + -> GenParser Char ParserState [TableCell] +parseTableHeader cols = try $ do + cells' <- parseTableRow cols + hline + return cells' + +parseTableRow :: Int -- ^ number of columns + -> GenParser Char ParserState [TableCell] +parseTableRow cols = try $ do + let tableCellInline = notFollowedBy (char '&' <|> + (try $ char '\\' >> char '\\')) >> inline + cells' <- sepBy (spaces >> liftM ((:[]) . Plain . normalizeSpaces) + (many tableCellInline)) (char '&') + guard $ length cells' == cols + spaces + (try $ string "\\\\" >> spaces) <|> + (lookAhead (end "tabular") >> return ()) + return cells' + -- -- code blocks -- codeBlock :: GenParser Char ParserState Block -codeBlock = codeBlockWith "verbatim" <|> codeBlockWith "Verbatim" <|> lhsCodeBlock +codeBlock = codeBlockWith "verbatim" <|> codeBlockWith "Verbatim" <|> codeBlockWith "lstlisting" <|> lhsCodeBlock -- Note: Verbatim is from fancyvrb. codeBlockWith :: String -> GenParser Char st Block codeBlockWith env = try $ do - string ("\\begin{" ++ env ++ "}") -- don't use begin function because it - -- gobbles whitespace - optional blanklines -- we want to gobble blank lines, but not - -- leading space + string "\\begin" + spaces -- don't use begin function because it + string $ "{" ++ env ++ "}" -- gobbles whitespace; we want to gobble + optional blanklines -- blank lines, but not leading space contents <- manyTill anyChar (try (string $ "\\end{" ++ env ++ "}")) spaces let classes = if env == "code" then ["haskell"] else [] @@ -243,7 +330,10 @@ orderedList :: GenParser Char ParserState Block orderedList = try $ do - string "\\begin{enumerate}" + string "\\begin" + spaces + string "{enumerate}" + spaces (_, style, delim) <- option (1, DefaultStyle, DefaultDelim) $ try $ do failIfStrict char '[' @@ -271,7 +361,6 @@ bulletList :: GenParser Char ParserState Block bulletList = try $ do begin "itemize" - spaces items <- many listItem end "itemize" spaces @@ -280,7 +369,6 @@ definitionList :: GenParser Char ParserState Block definitionList = try $ do begin "description" - spaces items <- many listItem end "description" spaces @@ -320,7 +408,7 @@ authors = try $ do string "\\author{" raw <- many1 (notFollowedBy (char '}') >> inline) - let authors' = map normalizeSpaces $ splitBy LineBreak raw + let authors' = map normalizeSpaces $ splitBy (== LineBreak) raw char '}' spaces updateState (\s -> s { stateAuthors = authors' }) @@ -360,13 +448,15 @@ rawLaTeXEnvironment = do contents <- rawLaTeXEnvironment' spaces - return $ Para [TeX contents] + return $ RawBlock "latex" contents -- | Parse any LaTeX environment and return a string containing -- the whole literal environment as raw TeX. rawLaTeXEnvironment' :: GenParser Char st String rawLaTeXEnvironment' = try $ do - string "\\begin{" + string "\\begin" + spaces + char '{' name <- many1 letter star <- option "" (string "*") -- for starred variants let name' = name ++ star @@ -396,31 +486,49 @@ spaces return Null +demacro :: (String, String, [String]) -> GenParser Char ParserState Inline +demacro (n,st,args) = try $ do + let raw = "\\" ++ n ++ st ++ concat args + s' <- applyMacros' raw + if raw == s' + then return $ RawInline "latex" raw + else do + inp <- getInput + setInput $ s' ++ inp + return $ Str "" + unknownCommand :: GenParser Char ParserState Block unknownCommand = try $ do - notFollowedBy' $ choice $ map end ["itemize", "enumerate", "description", - "document"] + spaces + notFollowedBy' $ oneOfStrings ["\\begin","\\end","\\item"] state <- getState when (stateParserContext state == ListItemState) $ notFollowedBy' (string "\\item") if stateParseRaw state - then do - (name, star, args) <- command - spaces - return $ Plain [TeX ("\\" ++ name ++ star ++ concat args)] + then command >>= demacro >>= return . Plain . (:[]) else do (name, _, args) <- command spaces - if name `elem` commandsToIgnore - then return Null - else return $ Plain [Str $ concat args] + unless (name `elem` commandsToIgnore) $ do + -- put arguments back in input to be parsed + inp <- getInput + setInput $ intercalate " " args ++ inp + return Null commandsToIgnore :: [String] -commandsToIgnore = ["special","pdfannot","pdfstringdef"] +commandsToIgnore = ["special","pdfannot","pdfstringdef", "index","bibliography"] --- latex comment -comment :: GenParser Char st Block -comment = try $ char '%' >> manyTill anyChar newline >> spaces >> return Null +skipChar :: GenParser Char ParserState Block +skipChar = do + satisfy (/='\\') <|> + (notFollowedBy' (try $ + string "\\begin" >> spaces >> string "{document}") >> + anyChar) + spaces + return Null + +commentBlock :: GenParser Char st Block +commentBlock = many1 (comment >> spaces) >> return Null -- -- inline @@ -442,8 +550,6 @@ , strikeout , superscript , subscript - , ref - , lab , code , url , link @@ -452,12 +558,20 @@ , linebreak , accentedChar , nonbreakingSpace + , cite , specialChar - , rawLaTeXInline + , ensureMath + , rawLaTeXInline' , escapedChar , unescapedChar + , comment ] "inline" + +-- latex comment +comment :: GenParser Char st Inline +comment = try $ char '%' >> manyTill anyChar newline >> spaces >> return (Str "") + accentedChar :: GenParser Char st Inline accentedChar = normalAccentedChar <|> specialAccentedChar @@ -490,7 +604,7 @@ ('u', [('`', 249), ('\'', 250), ('^', 251), ('"', 252)]) ] specialAccentedChar :: GenParser Char st Inline -specialAccentedChar = choice [ ccedil, aring, iuml, szlig, aelig, +specialAccentedChar = choice [ ccedil, aring, iuml, szlig, aelig, lslash, oslash, pound, euro, copyright, sect ] ccedil :: GenParser Char st Inline @@ -521,6 +635,13 @@ let num = if letter' == 'o' then 248 else 216 return $ Str [chr num] +lslash :: GenParser Char st Inline +lslash = try $ do + cmd <- oneOfStrings ["{\\L}","{\\l}","\\L ","\\l "] + return $ if 'l' `elem` cmd + then Str "\x142" + else Str "\x141" + aelig :: GenParser Char st Inline aelig = try $ do char '\\' @@ -547,7 +668,7 @@ -- nonescaped special characters unescapedChar :: GenParser Char st Inline -unescapedChar = oneOf "`$^&_#{}|<>" >>= return . (\c -> Str [c]) +unescapedChar = oneOf "`$^&_#{}[]|<>" >>= return . (\c -> Str [c]) specialChar :: GenParser Char st Inline specialChar = choice [ spacer, interwordSpace, @@ -582,27 +703,34 @@ doubleQuote = char '"' >> return (Str "\"") code :: GenParser Char ParserState Inline -code = code1 <|> code2 <|> lhsInlineCode +code = code1 <|> code2 <|> code3 <|> lhsInlineCode code1 :: GenParser Char st Inline code1 = try $ do string "\\verb" marker <- anyChar result <- manyTill anyChar (char marker) - return $ Code $ removeLeadingTrailingSpace result + return $ Code nullAttr $ removeLeadingTrailingSpace result code2 :: GenParser Char st Inline code2 = try $ do string "\\texttt{" result <- manyTill (noneOf "\\\n~$%^&{}") (char '}') - return $ Code result + return $ Code nullAttr result + +code3 :: GenParser Char st Inline +code3 = try $ do + string "\\lstinline" + marker <- anyChar + result <- manyTill anyChar (char marker) + return $ Code nullAttr $ removeLeadingTrailingSpace result lhsInlineCode :: GenParser Char ParserState Inline lhsInlineCode = try $ do failUnlessLHS char '|' result <- manyTill (noneOf "|\n") (char '|') - return $ Code result + return $ Code ("",["haskell"],[]) result emph :: GenParser Char ParserState Inline emph = try $ oneOfStrings [ "\\emph{", "\\textit{" ] >> @@ -661,15 +789,6 @@ hyphen :: GenParser Char st Inline hyphen = char '-' >> return (Str "-") -lab :: GenParser Char st Inline -lab = try $ do - string "\\label{" - result <- manyTill anyChar (char '}') - return $ Str $ "(" ++ result ++ ")" - -ref :: GenParser Char st Inline -ref = try (string "\\ref{") >> manyTill anyChar (char '}') >>= return . Str - strong :: GenParser Char ParserState Inline strong = try (string "\\textbf{") >> manyTill inline (char '}') >>= return . Strong @@ -692,13 +811,13 @@ endline = try $ newline >> notFollowedBy blankline >> return Space -- math -math :: GenParser Char st Inline -math = (math3 >>= return . Math DisplayMath) - <|> (math1 >>= return . Math InlineMath) - <|> (math2 >>= return . Math InlineMath) - <|> (math4 >>= return . Math DisplayMath) - <|> (math5 >>= return . Math DisplayMath) - <|> (math6 >>= return . Math DisplayMath) +math :: GenParser Char ParserState Inline +math = (math3 >>= applyMacros' >>= return . Math DisplayMath) + <|> (math1 >>= applyMacros' >>= return . Math InlineMath) + <|> (math2 >>= applyMacros' >>= return . Math InlineMath) + <|> (math4 >>= applyMacros' >>= return . Math DisplayMath) + <|> (math5 >>= applyMacros' >>= return . Math DisplayMath) + <|> (math6 >>= applyMacros' >>= return . Math DisplayMath) "math" math1 :: GenParser Char st String @@ -715,7 +834,6 @@ name <- begin "displaymath" <|> begin "equation" <|> begin "equation*" <|> begin "gather" <|> begin "gather*" <|> begin "gathered" <|> begin "multline" <|> begin "multline*" - spaces manyTill anyChar (end name) math5 :: GenParser Char st String @@ -726,10 +844,15 @@ name <- begin "eqnarray" <|> begin "eqnarray*" <|> begin "align" <|> begin "align*" <|> begin "alignat" <|> begin "alignat*" <|> begin "split" <|> begin "aligned" <|> begin "alignedat" - spaces res <- manyTill anyChar (end name) return $ filter (/= '&') res -- remove alignment codes +ensureMath :: GenParser Char st Inline +ensureMath = try $ do + (n, _, args) <- command + guard $ n == "ensuremath" && not (null args) + return $ Math InlineMath $ tail $ init $ head args + -- -- links and images -- @@ -738,7 +861,7 @@ url = try $ do string "\\url" url' <- charsInBalanced '{' '}' - return $ Link [Code url'] (escapeURI url', "") + return $ Link [Code ("",["url"],[]) url'] (escapeURI url', "") link :: GenParser Char ParserState Inline link = try $ do @@ -771,19 +894,120 @@ setInput rest return $ Note blocks +-- | citations +cite :: GenParser Char ParserState Inline +cite = simpleCite <|> complexNatbibCites + +simpleCiteArgs :: GenParser Char ParserState [Citation] +simpleCiteArgs = try $ do + first <- optionMaybe $ (char '[') >> manyTill inline (char ']') + second <- optionMaybe $ (char '[') >> manyTill inline (char ']') + char '{' + keys <- many1Till citationLabel (char '}') + let (pre, suf) = case (first , second ) of + (Just s , Nothing) -> ([], s ) + (Just s , Just t ) -> (s , t ) + _ -> ([], []) + conv k = Citation { citationId = k + , citationPrefix = [] + , citationSuffix = [] + , citationMode = NormalCitation + , citationHash = 0 + , citationNoteNum = 0 + } + return $ addPrefix pre $ addSuffix suf $ map conv keys + + +simpleCite :: GenParser Char ParserState Inline +simpleCite = try $ do + char '\\' + let biblatex = [a ++ "cite" | a <- ["auto", "foot", "paren", "super", ""]] + ++ ["footcitetext"] + normal = ["cite" ++ a ++ b | a <- ["al", ""], b <- ["p", "p*", ""]] + ++ biblatex + supress = ["citeyearpar", "citeyear", "autocite*", "cite*", "parencite*"] + intext = ["textcite"] ++ ["cite" ++ a ++ b | a <- ["al", ""], b <- ["t", "t*"]] + mintext = ["textcites"] + mnormal = map (++ "s") biblatex + cmdend = notFollowedBy (letter <|> char '*') + capit [] = [] + capit (x:xs) = toUpper x : xs + addUpper xs = xs ++ map capit xs + toparser l t = try $ oneOfStrings (addUpper l) >> cmdend >> return t + (mode, multi) <- toparser normal (NormalCitation, False) + <|> toparser supress (SuppressAuthor, False) + <|> toparser intext (AuthorInText , False) + <|> toparser mnormal (NormalCitation, True ) + <|> toparser mintext (AuthorInText , True ) + cits <- if multi then + many1 simpleCiteArgs + else + simpleCiteArgs >>= \c -> return [c] + let (c:cs) = concat cits + cits' = case mode of + AuthorInText -> c {citationMode = mode} : cs + _ -> map (\a -> a {citationMode = mode}) (c:cs) + return $ Cite cits' [] + +complexNatbibCites :: GenParser Char ParserState Inline +complexNatbibCites = complexNatbibTextual <|> complexNatbibParenthetical + +complexNatbibTextual :: GenParser Char ParserState Inline +complexNatbibTextual = try $ do + string "\\citeauthor{" + manyTill (noneOf "}") (char '}') + skipSpaces + Cite (c:cs) _ <- complexNatbibParenthetical + return $ Cite (c {citationMode = AuthorInText} : cs) [] + + +complexNatbibParenthetical :: GenParser Char ParserState Inline +complexNatbibParenthetical = try $ do + string "\\citetext{" + cits <- many1Till parseOne (char '}') + return $ Cite (concat cits) [] + where + parseOne = do + skipSpaces + pref <- many (notFollowedBy (oneOf "\\}") >> inline) + (Cite cites _) <- simpleCite + suff <- many (notFollowedBy (oneOf "\\};") >> inline) + skipSpaces + optional $ char ';' + return $ addPrefix pref $ addSuffix suff $ cites + +addPrefix :: [Inline] -> [Citation] -> [Citation] +addPrefix p (k:ks) = k {citationPrefix = p ++ citationPrefix k} : ks +addPrefix _ _ = [] + +addSuffix :: [Inline] -> [Citation] -> [Citation] +addSuffix s ks@(_:_) = let k = last ks + in init ks ++ [k {citationSuffix = citationSuffix k ++ s}] +addSuffix _ _ = [] + +citationLabel :: GenParser Char ParserState String +citationLabel = do + res <- many1 $ noneOf ",}" + optional $ char ',' + return $ removeLeadingTrailingSpace res + +-- | Parse any LaTeX inline command and return it in a raw TeX inline element. +rawLaTeXInline' :: GenParser Char ParserState Inline +rawLaTeXInline' = do + notFollowedBy' $ oneOfStrings ["\\begin", "\\end", "\\item", "\\ignore", + "\\section"] + rawLaTeXInline + -- | Parse any LaTeX command and return it in a raw TeX inline element. rawLaTeXInline :: GenParser Char ParserState Inline rawLaTeXInline = try $ do - notFollowedBy' $ oneOfStrings ["\\begin", "\\end", "\\item", "\\ignore", - "\\section"] state <- getState if stateParseRaw state - then do - (name, star, args) <- command - return $ TeX ("\\" ++ name ++ star ++ concat args) + then command >>= demacro else do - (name, _, args) <- command - spaces - if name `elem` commandsToIgnore - then return $ Str "" - else return $ Str (concat args) + (name,st,args) <- command + x <- demacro (name,st,args) + unless (x == Str "" || name `elem` commandsToIgnore) $ do + inp <- getInput + setInput $ intercalate " " args ++ inp + return $ Str "" diff -Nru pandoc-1.5.1.1/src/Text/Pandoc/Readers/Markdown.hs pandoc-1.8.0.3/src/Text/Pandoc/Readers/Markdown.hs --- pandoc-1.5.1.1/src/Text/Pandoc/Readers/Markdown.hs 2010-03-29 14:24:56.000000000 +0000 +++ pandoc-1.8.0.3/src/Text/Pandoc/Readers/Markdown.hs 2011-02-05 18:48:07.000000000 +0000 @@ -27,24 +27,25 @@ Conversion of markdown-formatted plain text to 'Pandoc' document. -} -module Text.Pandoc.Readers.Markdown ( - readMarkdown - ) where +module Text.Pandoc.Readers.Markdown ( readMarkdown ) where -import Data.List ( transpose, isSuffixOf, sortBy, findIndex, intercalate ) +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.Shared +import Text.Pandoc.Generic +import Text.Pandoc.Shared +import Text.Pandoc.Parsing import Text.Pandoc.Readers.LaTeX ( rawLaTeXInline, rawLaTeXEnvironment' ) -import Text.Pandoc.Readers.HTML ( rawHtmlBlock, anyHtmlBlockTag, - anyHtmlInlineTag, anyHtmlTag, - anyHtmlEndTag, htmlEndTag, extractTagType, - htmlBlockElement, htmlComment, unsanitaryURI ) +import Text.Pandoc.Readers.HTML ( htmlTag, htmlInBalanced, isInlineTag, isBlockTag, + isTextTag, isCommentTag ) import Text.Pandoc.CharacterReferences ( decodeCharacterReferences ) import Text.ParserCombinators.Parsec -import Control.Monad (when, liftM, unless) +import Control.Monad (when, liftM, guard) +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 @@ -56,18 +57,26 @@ -- Constants and data structure definitions -- -bulletListMarkers :: [Char] -bulletListMarkers = "*+-" - -hruleChars :: [Char] -hruleChars = "*-_" +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 = "=-" --- treat these as potentially non-text when parsing inline: -specialChars :: [Char] -specialChars = "\\[]*_~`<>$!^-.&'\"\8216\8217\8220\8221;" +isBlank :: Char -> Bool +isBlank ' ' = True +isBlank '\t' = True +isBlank '\n' = True +isBlank _ = False -- -- auxiliary functions @@ -104,12 +113,6 @@ pos <- getPosition if sourceColumn pos == 1 then return () else fail "not beginning of line" --- | Fail unless we're in "smart typography" mode. -failUnlessSmart :: GenParser tok ParserState () -failUnlessSmart = do - state <- getState - if stateSmart state then return () else pzero - -- | Parse a sequence of inline elements between square brackets, -- including inlines between balanced pairs of square brackets. inlinesInBalancedBrackets :: GenParser Char ParserState Inline @@ -117,7 +120,7 @@ inlinesInBalancedBrackets parser = try $ do char '[' result <- manyTill ( (do lookAhead $ try $ do (Str res) <- parser - unless (res == "[") pzero + guard (res == "[") bal <- inlinesInBalancedBrackets parser return $ [Str "["] ++ bal ++ [Str "]"]) <|> (count 1 parser)) @@ -141,7 +144,8 @@ authorsLine = try $ do char '%' skipSpaces - authors <- sepEndBy (many (notFollowedBy (oneOf ";\n") >> inline)) + authors <- sepEndBy (many (notFollowedBy (satisfy $ \c -> + c == ';' || c == '\n') >> inline)) (char ';' <|> try (newline >> notFollowedBy blankline >> spaceChar)) newline @@ -183,7 +187,18 @@ -- now parse it for real... (title, author, date) <- option ([],[],[]) titleBlock blocks <- parseBlocks - return $ Pandoc (Meta title author date) $ filter (/= Null) blocks + 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 @@ -196,16 +211,24 @@ lab <- reference char ':' skipSpaces >> optional newline >> skipSpaces >> notFollowedBy (char '[') - let sourceURL excludes = many $ - optional (char '\\') >> (noneOf (' ':excludes) <|> (notFollowedBy' referenceTitle >> char ' ')) - src <- try (char '<' >> sourceURL ">\t\n" >>~ char '>') <|> sourceURL "\t\n" + let nl = char '\n' >> notFollowedBy blankline >> return ' ' + let sourceURL = liftM unwords $ many $ try $ do + notFollowedBy' referenceTitle + skipMany spaceChar + optional nl + skipMany spaceChar + notFollowedBy' reference + many1 (satisfy $ not . isBlank) + let betweenAngles = try $ char '<' >> + manyTill (noneOf ">\n" <|> nl) (char '>') + src <- try betweenAngles <|> sourceURL tit <- option "" referenceTitle blanklines endPos <- getPosition - let newkey = (lab, (escapeURI $ removeTrailingSpace src, tit)) + let target = (escapeURI $ removeTrailingSpace src, tit) st <- getState let oldkeys = stateKeys st - updateState $ \s -> s { stateKeys = newkey : oldkeys } + 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' @@ -219,27 +242,32 @@ return $ decodeCharacterReferences tit noteMarker :: GenParser Char ParserState [Char] -noteMarker = skipNonindentSpaces >> string "[^" >> manyTill (noneOf " \t\n") (char ']') +noteMarker = string "[^" >> many1Till (satisfy $ not . isBlank) (char ']') rawLine :: GenParser Char ParserState [Char] -rawLine = do +rawLine = try $ do notFollowedBy blankline - notFollowedBy' noteMarker - contents <- many1 nonEndline - end <- option "" (newline >> optional indentSpaces >> return "\n") - return $ contents ++ end + notFollowedBy' $ try $ skipNonindentSpaces >> noteMarker + optional indentSpaces + anyLine rawLines :: GenParser Char ParserState [Char] -rawLines = many1 rawLine >>= return . concat +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)) + raw <- sepBy rawLines + (try (blankline >> indentSpaces >> + notFollowedBy blankline)) optional blanklines endPos <- getPosition let newnote = (ref, (intercalate "\n" raw) ++ "\n\n") @@ -271,6 +299,7 @@ , plain , nullBlock ] else [ codeBlockDelimited + , macro , header , table , codeBlockIndented @@ -280,6 +309,7 @@ , bulletList , orderedList , definitionList + , rawTeXBlock , para , rawHtmlBlocks , plain @@ -305,6 +335,9 @@ 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) @@ -319,7 +352,7 @@ hrule :: GenParser Char st Block hrule = try $ do skipSpaces - start <- oneOf hruleChars + start <- satisfy isHruleChar count 2 (skipSpaces >> char start) skipMany (spaceChar <|> char start) newline @@ -358,6 +391,7 @@ attribute :: GenParser Char st ([Char], [[Char]], [([Char], [Char])]) attribute = identifierAttr <|> classAttr <|> keyValAttr + identifier :: GenParser Char st [Char] identifier = do first <- letter @@ -381,7 +415,7 @@ key <- identifier char '=' char '"' - val <- manyTill (noneOf "\n") (char '"') + val <- manyTill (satisfy (/='\n')) (char '"') return ("",[],[(key,val)]) codeBlockDelimited :: GenParser Char st Block @@ -476,7 +510,7 @@ optional newline -- if preceded by a Plain block in a list context skipNonindentSpaces notFollowedBy' hrule -- because hrules start out just like lists - oneOf bulletListMarkers + satisfy isBulletListMarker spaceChar skipSpaces @@ -511,7 +545,7 @@ notFollowedBy' (do indentSpaces many (spaceChar) listStart) - chunks <- manyTill (htmlComment <|> count 1 anyChar) newline + 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 @@ -631,23 +665,21 @@ -- isHtmlOrBlank :: Inline -> Bool -isHtmlOrBlank (HtmlInline _) = True -isHtmlOrBlank (Space) = True -isHtmlOrBlank (LineBreak) = True -isHtmlOrBlank _ = False +isHtmlOrBlank (RawInline "html" _) = True +isHtmlOrBlank (Space) = True +isHtmlOrBlank (LineBreak) = True +isHtmlOrBlank _ = False para :: GenParser Char ParserState Block para = try $ do - result <- many1 inline - if all isHtmlOrBlank result - then fail "treat as raw HTML" - else return () - newline - blanklines <|> do st <- getState - if stateStrict st - then lookAhead (blockQuote <|> header) >> return "" - else pzero - return $ Para $ normalizeSpaces result + 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 @@ -657,7 +689,7 @@ -- htmlElement :: GenParser Char ParserState [Char] -htmlElement = strictHtmlBlock <|> htmlBlockElement "html element" +htmlElement = strictHtmlBlock <|> liftM snd (htmlTag isBlockTag) htmlBlock :: GenParser Char ParserState Block htmlBlock = try $ do @@ -665,27 +697,33 @@ first <- htmlElement finalSpace <- many spaceChar finalNewlines <- many newline - return $ RawHtml $ first ++ finalSpace ++ finalNewlines - --- True if tag is self-closing -isSelfClosing :: [Char] -> Bool -isSelfClosing tag = - isSuffixOf "/>" $ filter (not . (`elem` " \n\t")) tag + return $ RawBlock "html" $ first ++ finalSpace ++ finalNewlines strictHtmlBlock :: GenParser Char ParserState [Char] -strictHtmlBlock = try $ do - tag <- anyHtmlBlockTag - let tag' = extractTagType tag - if isSelfClosing tag || tag' == "hr" - then return tag - else do contents <- many (notFollowedBy' (htmlEndTag tag') >> - (htmlElement <|> (count 1 anyChar))) - end <- htmlEndTag tag' - return $ tag ++ concat contents ++ end +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") rawLaTeXEnvironment' + <|> liftM (RawBlock "context") rawConTeXtEnvironment' + spaces + return result rawHtmlBlocks :: GenParser Char ParserState Block rawHtmlBlocks = do - htmlBlocks <- many1 $ do (RawHtml blk) <- rawHtmlBlock + htmlBlocks <- many1 $ do blk <- rawVerbatimBlock <|> + liftM snd (htmlTag isBlockTag) sps <- do sp1 <- many spaceChar sp2 <- option "" (blankline >> return "\n") sp3 <- many spaceChar @@ -697,7 +735,7 @@ return $ blk ++ sps let combined = concat htmlBlocks let combined' = if last combined == '\n' then init combined else combined - return $ RawHtml combined' + return $ RawBlock "html" combined' -- -- Tables @@ -715,7 +753,7 @@ -- Parse a table header with dashed lines of '-' preceded by -- one (or zero) line of text. simpleTableHeader :: Bool -- ^ Headerless table - -> GenParser Char ParserState ([[Char]], [Alignment], [Int]) + -> GenParser Char ParserState ([[Block]], [Alignment], [Int]) simpleTableHeader headless = try $ do rawContent <- if headless then return "" @@ -734,7 +772,9 @@ let rawHeads' = if headless then replicate (length dashes) "" else rawHeads - return (rawHeads', aligns, indices) + 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] @@ -763,65 +803,27 @@ -> GenParser Char ParserState [[Block]] multilineRow indices = do colLines <- many1 (rawTableLine indices) - optional blanklines let cols = map unlines $ transpose colLines mapM (parseFromString (many plain)) cols --- 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 = - let lengths' = zipWith (-) indices (0:indices) - lengths = reverse $ - case reverse lengths' of - [] -> [] - [x] -> [x] - -- compensate for the fact that intercolumn - -- spaces are counted in widths of all columns - -- but the last... - (x:y:zs) -> if x < y && y - x <= 2 - then y:y:zs - else x:y:zs - totLength = sum lengths - quotient = if totLength > numColumns - then fromIntegral totLength - else fromIntegral numColumns - fracs = map (\l -> (fromIntegral l) / quotient) lengths in - tail fracs - -- Parses a table caption: inlines beginning with 'Table:' -- and followed by blank lines. tableCaption :: GenParser Char ParserState [Inline] tableCaption = try $ do skipNonindentSpaces - string "Table:" + string ":" <|> string "Table:" result <- many1 inline blanklines return $ normalizeSpaces result --- Parse a table using 'headerParser', 'lineParser', and 'footerParser'. -tableWith :: GenParser Char ParserState ([[Char]], [Alignment], [Int]) - -> ([Int] -> GenParser Char ParserState [[Block]]) - -> GenParser Char ParserState end - -> GenParser Char ParserState Block -tableWith headerParser lineParser footerParser = try $ do - (rawHeads, aligns, indices) <- headerParser - lines' <- many1Till (lineParser indices) footerParser - caption <- option [] tableCaption - heads <- mapM (parseFromString (many plain)) rawHeads - state <- getState - let numColumns = stateColumns state - let widths = widthsFromIndices numColumns indices - return $ Table caption aligns widths heads lines' - -- 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 - (if headless then tableFooter else tableFooter <|> blanklines) + (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 @@ -832,10 +834,10 @@ multilineTable :: Bool -- ^ Headerless table -> GenParser Char ParserState Block multilineTable headless = - tableWith (multilineTableHeader headless) multilineRow tableFooter + tableWith (multilineTableHeader headless) multilineRow blanklines tableFooter tableCaption multilineTableHeader :: Bool -- ^ Headerless table - -> GenParser Char ParserState ([String], [Alignment], [Int]) + -> GenParser Char ParserState ([[Block]], [Alignment], [Int]) multilineTableHeader headless = try $ do if headless then return '\n' @@ -859,7 +861,9 @@ let rawHeads = if headless then replicate (length dashes) "" else map (intercalate " ") rawHeadsList - return ((map removeLeadingTrailingSpace rawHeads), aligns, indices) + 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 @@ -869,19 +873,25 @@ -> Alignment alignType [] _ = AlignDefault alignType strLst len = - let s = head $ sortBy (comparing length) $ - map removeTrailingSpace strLst - leftSpace = if null s then False else (s !! 0) `elem` " \t" - rightSpace = length s < len || (s !! (len - 1)) `elem` " \t" + 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 "table" + simpleTable False <|> multilineTable True <|> + gridTable False <|> gridTable True "table" -- -- inline @@ -891,30 +901,29 @@ inline = choice inlineParsers "inline" inlineParsers :: [GenParser Char ParserState Inline] -inlineParsers = [ str - , smartPunctuation - , whitespace +inlineParsers = [ whitespace + , str , endline , code - , charRef , (fourOrMore '*' <|> fourOrMore '_') , strong , emph , note - , inlineNote , link -#ifdef _CITEPROC - , inlineCitation -#endif + , cite , image , math , strikeout , superscript , subscript + , inlineNote -- after superscript because of ^[link](/foo)^ , autoLink - , rawHtmlInline' + , rawHtmlInline , rawLaTeXInline' , escapedChar + , exampleRef + , smartPunctuation inline + , charRef , symbol , ltSign ] @@ -928,12 +937,12 @@ failIfLink elt = return elt escapedChar :: GenParser Char ParserState Inline -escapedChar = do +escapedChar = try $ do char '\\' state <- getState - result <- option '\\' $ if stateStrict state - then oneOf "\\`*_{}[]()>#+-.!~" - else satisfy (not . isAlphaNum) + result <- if stateStrict state + then oneOf "\\`*_{}[]()>#+-.!~" + else satisfy (not . isAlphaNum) return $ case result of ' ' -> Str "\160" -- "\ " is a nonbreaking space '\n' -> LineBreak -- "\[newline]" is a linebreak @@ -947,12 +956,21 @@ else notFollowedBy' rawHtmlBlocks >> char '<' -- unless it starts html return $ Str ['<'] -specialCharsMinusLt :: [Char] -specialCharsMinusLt = filter (/= '<') specialChars +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 <- oneOf specialCharsMinusLt + result <- noneOf "<\\\n\t " + <|> try (do lookAhead $ char '\\' + notFollowedBy' $ rawLaTeXEnvironment' + <|> rawConTeXtEnvironment' + char '\\') return $ Str [result] -- parses inline code, between n `s and n `s @@ -964,7 +982,8 @@ (char '\n' >> notFollowedBy' blankline >> return " ")) (try (skipSpaces >> count (length starts) (char '`') >> notFollowedBy (char '`'))) - return $ Code $ removeLeadingTrailingSpace $ concat result + attr <- option ([],[],[]) (try $ optional whitespace >> attributes) + return $ Code attr $ removeLeadingTrailingSpace $ concat result mathWord :: GenParser Char st [Char] mathWord = liftM concat $ many1 mathChunk @@ -973,11 +992,11 @@ mathChunk = do char '\\' c <- anyChar return ['\\',c] - <|> many1 (noneOf " \t\n\\$") + <|> many1 (satisfy $ \c -> not (isBlank c || c == '\\' || c == '$')) math :: GenParser Char ParserState Inline -math = (mathDisplay >>= return . Math DisplayMath) - <|> (mathInline >>= return . Math InlineMath) +math = (mathDisplay >>= applyMacros' >>= return . Math DisplayMath) + <|> (mathInline >>= applyMacros' >>= return . Math InlineMath) mathDisplay :: GenParser Char ParserState String mathDisplay = try $ do @@ -1026,87 +1045,6 @@ (notFollowedBy spaceChar >> inline) >>= -- may not contain Space return . Subscript -smartPunctuation :: GenParser Char ParserState Inline -smartPunctuation = failUnlessSmart >> - choice [ quoted, apostrophe, dash, ellipses ] - -apostrophe :: GenParser Char ParserState Inline -apostrophe = (char '\'' <|> char '\8217') >> return Apostrophe - -quoted :: GenParser Char ParserState Inline -quoted = doubleQuoted <|> singleQuoted - -withQuoteContext :: QuoteContext - -> (GenParser Char ParserState Inline) - -> GenParser Char ParserState Inline -withQuoteContext context parser = do - oldState <- getState - let oldQuoteContext = stateQuoteContext oldState - setState oldState { stateQuoteContext = context } - result <- parser - newState <- getState - setState newState { stateQuoteContext = oldQuoteContext } - return result - -singleQuoted :: GenParser Char ParserState Inline -singleQuoted = try $ do - singleQuoteStart - withQuoteContext InSingleQuote $ many1Till inline singleQuoteEnd >>= - return . Quoted SingleQuote . normalizeSpaces - -doubleQuoted :: GenParser Char ParserState Inline -doubleQuoted = try $ do - doubleQuoteStart - withQuoteContext InDoubleQuote $ many1Till inline doubleQuoteEnd >>= - return . Quoted DoubleQuote . normalizeSpaces - -failIfInQuoteContext :: QuoteContext -> GenParser tok ParserState () -failIfInQuoteContext context = do - st <- getState - if stateQuoteContext st == context - then fail "already inside quotes" - else return () - -singleQuoteStart :: GenParser Char ParserState Char -singleQuoteStart = do - failIfInQuoteContext InSingleQuote - char '\8216' <|> - (try $ do char '\'' - notFollowedBy (oneOf ")!],.;:-? \t\n") - notFollowedBy (try (oneOfStrings ["s","t","m","ve","ll","re"] >> - satisfy (not . isAlphaNum))) - -- possess/contraction - return '\'') - -singleQuoteEnd :: GenParser Char st Char -singleQuoteEnd = try $ do - char '\8217' <|> char '\'' - notFollowedBy alphaNum - return '\'' - -doubleQuoteStart :: GenParser Char ParserState Char -doubleQuoteStart = do - failIfInQuoteContext InDoubleQuote - char '\8220' <|> - (try $ do char '"' - notFollowedBy (oneOf " \t\n") - return '"') - -doubleQuoteEnd :: GenParser Char st Char -doubleQuoteEnd = char '\8221' <|> char '"' - -ellipses :: GenParser Char st Inline -ellipses = oneOfStrings ["...", " . . . ", ". . .", " . . ."] >> return Ellipses - -dash :: GenParser Char st Inline -dash = enDash <|> emDash - -enDash :: GenParser Char st Inline -enDash = try $ char '-' >> notFollowedBy (noneOf "0123456789") >> return EnDash - -emDash :: GenParser Char st Inline -emDash = oneOfStrings ["---", "--"] >> return EmDash - whitespace :: GenParser Char ParserState Inline whitespace = spaceChar >> ( (spaceChar >> skipMany spaceChar >> option Space (endline >> return LineBreak)) @@ -1115,20 +1053,19 @@ nonEndline :: GenParser Char st Char nonEndline = satisfy (/='\n') -strChar :: GenParser Char st Char -strChar = noneOf (specialChars ++ " \t\n") - str :: GenParser Char ParserState Inline str = do - result <- many1 strChar + a <- alphaNum + as <- many $ alphaNum <|> (try $ char '_' >>~ lookAhead alphaNum) + let result = a:as state <- getState let spacesToNbr = map (\c -> if c == ' ' then '\160' else c) if stateSmart state then case likelyAbbrev result of [] -> return $ Str result xs -> choice (map (\x -> - try (string x >> char ' ' >> - notFollowedBy spaceChar >> + try (string x >> oneOf " \n" >> + lookAhead alphaNum >> return (Str $ result ++ spacesToNbr x ++ "\160"))) xs) <|> (return $ Str result) else return $ Str result @@ -1151,15 +1088,13 @@ newline notFollowedBy blankline st <- getState - if stateStrict st - then do notFollowedBy emailBlockQuoteStart - notFollowedBy (char '#') -- atx header - else return () + when (stateStrict st) $ do + notFollowedBy emailBlockQuoteStart + notFollowedBy (char '#') -- atx header -- parse potential list-starts differently if in a list: - if stateParserContext st == ListItemState - then notFollowedBy' (bulletListStart <|> - (anyOrderedListStart >> return ())) - else return () + when (stateParserContext st == ListItemState) $ do + notFollowedBy' bulletListStart + notFollowedBy' anyOrderedListStart return Space -- @@ -1184,9 +1119,16 @@ source' :: GenParser Char st (String, [Char]) source' = do skipSpaces - let sourceURL excludes = many $ - optional (char '\\') >> (noneOf (' ':excludes) <|> (notFollowedBy' linkTitle >> char ' ')) - src <- try (char '<' >> sourceURL ">\t\n" >>~ char '>') <|> sourceURL "\t\n" + let nl = char '\n' >>~ notFollowedBy blankline + let sourceURL = liftM unwords $ many $ try $ do + notFollowedBy' linkTitle + skipMany spaceChar + optional nl + skipMany spaceChar + many1 (satisfy $ not . isBlank) + let betweenAngles = try $ char '<' >> + manyTill (noneOf ">\n" <|> nl) (char '>') + src <- try betweenAngles <|> sourceURL tit <- option "" linkTitle skipSpaces eof @@ -1205,10 +1147,7 @@ link = try $ do lab <- reference (src, tit) <- source <|> referenceLink lab - sanitize <- getState >>= return . stateSanitizeHTML - if sanitize && unsanitaryURI src - then fail "Unsanitary URI" - else return $ Link lab (src, tit) + return $ Link lab (src, tit) -- a link like [this][ref] or [this][] or [this] referenceLink :: [Inline] @@ -1218,7 +1157,7 @@ optional (newline >> skipSpaces) >> reference)) let ref' = if null ref then lab else ref state <- getState - case lookupKeySrc (stateKeys state) ref' of + case lookupKeySrc (stateKeys state) (toKey ref') of Nothing -> fail "no corresponding key" Just target -> return target @@ -1228,12 +1167,9 @@ (orig, src) <- uri <|> emailAddress char '>' st <- getState - let sanitize = stateSanitizeHTML st - if sanitize && unsanitaryURI src - then fail "Unsanitary URI" - else return $ if stateStrict st - then Link [Str orig] (src, "") - else Link [Code orig] (src, "") + return $ if stateStrict st + then Link [Str orig] (src, "") + else Link [Code ("",["url"],[]) orig] (src, "") image :: GenParser Char ParserState Inline image = try $ do @@ -1259,11 +1195,13 @@ return $ Note [Para contents] rawLaTeXInline' :: GenParser Char ParserState Inline -rawLaTeXInline' = do +rawLaTeXInline' = try $ do failIfStrict - (rawConTeXtEnvironment' >>= return . TeX) - <|> (rawLaTeXEnvironment' >>= return . TeX) - <|> rawLaTeXInline + lookAhead $ char '\\' + notFollowedBy' $ rawLaTeXEnvironment' + <|> rawConTeXtEnvironment' + RawInline _ s <- rawLaTeXInline + return $ RawInline "tex" s -- "tex" because it might be context or latex rawConTeXtEnvironment' :: GenParser Char st String rawConTeXtEnvironment' = try $ do @@ -1281,46 +1219,98 @@ char ']' return $ "[" ++ contents ++ "]" -rawHtmlInline' :: GenParser Char ParserState Inline -rawHtmlInline' = do +rawHtmlInline :: GenParser Char ParserState Inline +rawHtmlInline = do st <- getState - result <- if stateStrict st - then choice [htmlBlockElement, anyHtmlTag, anyHtmlEndTag] - else anyHtmlInlineTag - return $ HtmlInline result - -#ifdef _CITEPROC -inlineCitation :: GenParser Char ParserState Inline -inlineCitation = try $ do + (_,result) <- if stateStrict st + then htmlTag (not . isTextTag) + else htmlTag isInlineTag + return $ RawInline "html" result + +-- Citations + +cite :: GenParser Char ParserState Inline +cite = do failIfStrict - cit <- citeMarker - let citations = readWith parseCitation defaultParserState cit - mr <- mapM chkCit citations - if catMaybes mr /= [] - then return $ Cite citations [] - else fail "no citation found" + citations <- textualCite <|> normalCite + return $ Cite citations [] -chkCit :: Target -> GenParser Char ParserState (Maybe Target) -chkCit t = do +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 + rest <- many $ (noneOf ",;]@ \t\n") + let key = first:rest st <- getState - case lookupKeySrc (stateKeys st) [Str $ fst t] of - Just _ -> fail "This is a link" - Nothing -> if elem (fst t) $ stateCitations st - then return $ Just t - else return $ Nothing - -citeMarker :: GenParser Char ParserState String -citeMarker = char '[' >> manyTill ( noneOf "\n" <|> (newline >>~ notFollowedBy blankline) ) (char ']') - -parseCitation :: GenParser Char ParserState [(String,String)] -parseCitation = try $ sepBy (parseLabel) (oneOf ";") - -parseLabel :: GenParser Char ParserState (String,String) -parseLabel = try $ do - res <- sepBy (skipSpaces >> optional newline >> skipSpaces >> many1 (noneOf "@;")) (oneOf "@") - case res of - [lab,loc] -> return (lab, loc) - [lab] -> return (lab, "" ) - _ -> return ("" , "" ) + guard $ key `elem` stateCitations st + return (suppress_author, key) + +suffix :: GenParser Char ParserState [Inline] +suffix = try $ do + spnl + liftM normalizeSpaces $ many $ notFollowedBy (oneOf ";]") >> inline + +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 + } -#endif diff -Nru pandoc-1.5.1.1/src/Text/Pandoc/Readers/Native.hs pandoc-1.8.0.3/src/Text/Pandoc/Readers/Native.hs --- pandoc-1.5.1.1/src/Text/Pandoc/Readers/Native.hs 1970-01-01 00:00:00.000000000 +0000 +++ pandoc-1.8.0.3/src/Text/Pandoc/Readers/Native.hs 2011-02-05 18:48:07.000000000 +0000 @@ -0,0 +1,81 @@ +{- +Copyright (C) 2011 John MacFarlane + +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.Native + Copyright : Copyright (C) 2011 John MacFarlane + License : GNU GPL, version 2 or above + + Maintainer : John MacFarlane + Stability : alpha + Portability : portable + +Conversion of a string representation of a pandoc type (@Pandoc@, +@[Block]@, @Block@, @[Inline]@, or @Inline@) to a @Pandoc@ document. +-} +module Text.Pandoc.Readers.Native ( readNative ) where + +import Text.Pandoc.Definition + +nullMeta :: Meta +nullMeta = Meta{ docTitle = [] + , docAuthors = [] + , docDate = [] + } + +-- | Read native formatted text and return a Pandoc document. +-- The input may be a full pandoc document, a block list, a block, +-- an inline list, or an inline. Thus, for example, +-- +-- > Str "hi" +-- +-- will be treated as if it were +-- +-- > Pandoc (Meta [] [] []) [Plain [Str "hi"]] +-- +readNative :: String -- ^ String to parse (assuming @'\n'@ line endings) + -> Pandoc +readNative s = + case reads s of + (d,_):_ -> d + [] -> Pandoc nullMeta $ readBlocks s + +readBlocks :: String -> [Block] +readBlocks s = + case reads s of + (d,_):_ -> d + [] -> [readBlock s] + +readBlock :: String -> Block +readBlock s = + case reads s of + (d,_):_ -> d + [] -> Plain $ readInlines s + +readInlines :: String -> [Inline] +readInlines s = + case reads s of + (d,_):_ -> d + [] -> [readInline s] + +readInline :: String -> Inline +readInline s = + case reads s of + (d,_):_ -> d + [] -> error "Cannot parse document" + diff -Nru pandoc-1.5.1.1/src/Text/Pandoc/Readers/RST.hs pandoc-1.8.0.3/src/Text/Pandoc/Readers/RST.hs --- pandoc-1.5.1.1/src/Text/Pandoc/Readers/RST.hs 2010-03-29 14:24:56.000000000 +0000 +++ pandoc-1.8.0.3/src/Text/Pandoc/Readers/RST.hs 2011-02-05 18:48:07.000000000 +0000 @@ -31,10 +31,14 @@ readRST ) where import Text.Pandoc.Definition -import Text.Pandoc.Shared +import Text.Pandoc.Shared +import Text.Pandoc.Parsing import Text.ParserCombinators.Parsec -import Control.Monad ( when, unless, liftM ) -import Data.List ( findIndex, delete, intercalate, transpose ) +import Control.Monad ( when ) +import Data.List ( findIndex, intercalate, transpose, sort, deleteFirstsBy ) +import qualified Data.Map as M +import Text.Printf ( printf ) +import Data.Maybe ( catMaybes ) -- | Parse reStructuredText string and return Pandoc document. readRST :: ParserState -- ^ Parser state, including options for parser @@ -54,7 +58,7 @@ -- treat these as potentially non-text when parsing inline: specialChars :: [Char] -specialChars = "\\`|*_<>$:[-" +specialChars = "\\`|*_<>$:[-.\"'\8216\8217\8220\8221" -- -- parsing documents @@ -87,15 +91,17 @@ parseRST :: GenParser Char ParserState Pandoc parseRST = do + optional blanklines -- skip blank lines at beginning of file startPos <- getPosition - -- go through once just to get list of reference keys + -- 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 <|> lineClump) eof >>= return . concat + docMinusKeys <- manyTill (referenceKey <|> noteBlock <|> lineClump) eof >>= + return . concat setInput docMinusKeys setPosition startPos - st <- getState - let reversedKeys = stateKeys st - updateState $ \s -> s { stateKeys = reverse reversedKeys } + st' <- getState + let reversedNotes = stateNotes st' + updateState $ \s -> s { stateNotes = reverse reversedNotes } -- now parse it for real... blocks <- parseBlocks let blocks' = filter (/= Null) blocks @@ -117,10 +123,9 @@ block :: GenParser Char ParserState Block block = choice [ codeBlock - , rawHtmlBlock - , rawLaTeXBlock - , fieldList + , rawBlock , blockQuote + , fieldList , imageBlock , customCodeBlock , unknownDirective @@ -138,46 +143,54 @@ -- field list -- -fieldListItem :: String -> GenParser Char st ([Char], [Char]) -fieldListItem indent = try $ do +rawFieldListItem :: String -> GenParser Char ParserState (String, String) +rawFieldListItem indent = try $ do string indent char ':' - name <- many1 alphaNum + name <- many1 $ alphaNum <|> spaceChar string ": " skipSpaces first <- manyTill anyChar newline - rest <- option "" $ try $ lookAhead (string indent >> oneOf " \t") >> - indentedBlock - return (name, intercalate " " (first:(lines rest))) + rest <- option "" $ try $ do lookAhead (string indent >> spaceChar) + indentedBlock + let raw = first ++ "\n" ++ rest ++ "\n" + return (name, raw) + +fieldListItem :: String + -> GenParser Char ParserState (Maybe ([Inline], [[Block]])) +fieldListItem indent = try $ do + (name, raw) <- rawFieldListItem indent + let term = [Str name] + contents <- parseFromString (many block) raw + case (name, contents) of + ("Author", x) -> do + updateState $ \st -> + st{ stateAuthors = stateAuthors st ++ [extractContents x] } + return Nothing + ("Authors", [BulletList auths]) -> do + updateState $ \st -> st{ stateAuthors = map extractContents auths } + return Nothing + ("Date", x) -> do + updateState $ \st -> st{ stateDate = extractContents x } + return Nothing + ("Title", x) -> do + updateState $ \st -> st{ stateTitle = extractContents x } + return Nothing + _ -> return $ Just (term, [contents]) + +extractContents :: [Block] -> [Inline] +extractContents [Plain auth] = auth +extractContents [Para auth] = auth +extractContents _ = [] fieldList :: GenParser Char ParserState Block fieldList = try $ do - indent <- lookAhead $ many (oneOf " \t") + indent <- lookAhead $ many spaceChar items <- many1 $ fieldListItem indent blanklines - let authors = case lookup "Authors" items of - Just auth -> [auth] - Nothing -> map snd (filter (\(x,_) -> x == "Author") items) - unless (null authors) $ do - authors' <- mapM (parseFromString (many inline)) authors - updateState $ \st -> st {stateAuthors = map normalizeSpaces authors'} - case (lookup "Date" items) of - Just dat -> do - dat' <- parseFromString (many inline) dat - updateState $ \st -> st{ stateDate = normalizeSpaces dat' } - Nothing -> return () - case (lookup "Title" items) of - Just tit -> parseFromString (many inline) tit >>= - \t -> updateState $ \st -> st {stateTitle = t} - Nothing -> return () - let remaining = filter (\(x,_) -> (x /= "Authors") && (x /= "Author") && - (x /= "Date") && (x /= "Title")) items - if null remaining - then return Null - else do terms <- mapM (return . (:[]) . Str . fst) remaining - defs <- mapM (parseFromString (many block) . snd) - remaining - return $ DefinitionList $ zip terms $ map (:[]) defs + if null items + then return Null + else return $ DefinitionList $ catMaybes items -- -- line block @@ -186,7 +199,7 @@ lineBlockLine :: GenParser Char ParserState [Inline] lineBlockLine = try $ do string "| " - white <- many (oneOf " \t") + white <- many spaceChar line <- many $ (notFollowedBy newline >> inline) <|> (try $ endline >>~ char ' ') optional endline return $ normalizeSpaces $ (if null white then [] else [Str white]) ++ line @@ -231,15 +244,16 @@ -- image block -- -imageBlock :: GenParser Char st Block +imageBlock :: GenParser Char ParserState Block imageBlock = try $ do string ".. image:: " src <- manyTill anyChar newline - fields <- option [] $ do indent <- lookAhead $ many (oneOf " /t") - many1 $ fieldListItem indent + fields <- try $ do indent <- lookAhead $ many (oneOf " /t") + many $ rawFieldListItem indent optional blanklines case lookup "alt" fields of - Just alt -> return $ Plain [Image [Str alt] (src, alt)] + Just alt -> return $ Plain [Image [Str $ removeTrailingSpace alt] + (src, "")] Nothing -> return $ Plain [Image [Str "image"] (src, "")] -- -- header blocks @@ -314,20 +328,19 @@ indentedLine :: String -> GenParser Char st [Char] indentedLine indents = try $ do string indents - result <- manyTill anyChar newline - return $ result ++ "\n" + manyTill anyChar newline -- two or more indented lines, possibly separated by blank lines. -- any amount of indentation will work. indentedBlock :: GenParser Char st [Char] -indentedBlock = do - indents <- lookAhead $ many1 (oneOf " \t") +indentedBlock = try $ do + indents <- lookAhead $ many1 spaceChar lns <- many $ choice $ [ indentedLine indents, try $ do b <- blanklines l <- indentedLine indents return (b ++ l) ] - optional blanklines - return $ concat lns + optional blanklines + return $ unlines lns codeBlock :: GenParser Char st Block codeBlock = try $ do @@ -365,23 +378,16 @@ manyTill anyChar newline -- --- raw html --- - -rawHtmlBlock :: GenParser Char st Block -rawHtmlBlock = try $ string ".. raw:: html" >> blanklines >> - indentedBlock >>= return . RawHtml - --- --- raw latex +-- raw html/latex/etc -- -rawLaTeXBlock :: GenParser Char st Block -rawLaTeXBlock = try $ do - string ".. raw:: latex" +rawBlock :: GenParser Char st Block +rawBlock = try $ do + string ".. raw:: " + lang <- many1 (letter <|> digit) blanklines result <- indentedBlock - return $ Para [(TeX result)] + return $ RawBlock lang result -- -- block quotes @@ -408,7 +414,7 @@ term <- many1Till inline endline raw <- indentedBlock -- parse the extracted block, which may contain various block elements: - contents <- parseFromString parseBlocks $ raw ++ "\n\n" + contents <- parseFromString parseBlocks $ raw ++ "\n" return (normalizeSpaces term, [contents]) definitionList :: GenParser Char ParserState Block @@ -425,7 +431,7 @@ -- parses ordered list start and returns its length (inc following whitespace) orderedListStart :: ListNumberStyle -> ListNumberDelim - -> GenParser Char st Int + -> GenParser Char ParserState Int orderedListStart style delim = try $ do (_, markerLen) <- withHorizDisplacement (orderedListMarker style delim) white <- many1 spaceChar @@ -505,9 +511,35 @@ string ".." notFollowedBy (noneOf " \t\n") manyTill anyChar newline - many $ blanklines <|> (oneOf " \t" >> manyTill anyChar newline) + many $ blanklines <|> (spaceChar >> manyTill anyChar newline) return Null +--- +--- note block +--- + +noteBlock :: GenParser Char ParserState [Char] +noteBlock = try $ do + startPos <- getPosition + string ".." + spaceChar >> skipMany spaceChar + ref <- noteMarker + spaceChar >> skipMany spaceChar + first <- anyLine + blanks <- option "" blanklines + rest <- option "" indentedBlock + endPos <- getPosition + let raw = first ++ "\n" ++ blanks ++ rest ++ "\n" + let newnote = (ref, raw) + 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' + +noteMarker :: GenParser Char ParserState [Char] +noteMarker = char '[' >> (many1 digit <|> count 1 (oneOf "#*")) >>~ char ']' + -- -- reference key -- @@ -540,10 +572,10 @@ referenceKey :: GenParser Char ParserState [Char] referenceKey = do startPos <- getPosition - key <- choice [imageKey, anonymousKey, regularKey] + (key, target) <- choice [imageKey, anonymousKey, regularKey] st <- getState let oldkeys = stateKeys st - updateState $ \s -> s { stateKeys = key : oldkeys } + updateState $ \s -> s { stateKeys = M.insert key target oldkeys } optional blanklines endPos <- getPosition -- return enough blanks to replace key @@ -558,28 +590,29 @@ blanklines return $ escapeURI $ removeLeadingTrailingSpace $ contents -imageKey :: GenParser Char ParserState ([Inline], (String, [Char])) +imageKey :: GenParser Char ParserState (Key, Target) imageKey = try $ do string ".. |" ref <- manyTill inline (char '|') skipSpaces string "image::" src <- targetURI - return (normalizeSpaces ref, (src, "")) + return (toKey (normalizeSpaces ref), (src, "")) -anonymousKey :: GenParser Char st ([Inline], (String, [Char])) +anonymousKey :: GenParser Char st (Key, Target) anonymousKey = try $ do oneOfStrings [".. __:", "__"] src <- targetURI - return ([Str "_"], (src, "")) + pos <- getPosition + return (toKey [Str $ "_" ++ printf "%09d" (sourceLine pos)], (src, "")) -regularKey :: GenParser Char ParserState ([Inline], (String, [Char])) +regularKey :: GenParser Char ParserState (Key, Target) regularKey = try $ do string ".. _" ref <- referenceName char ':' src <- targetURI - return (normalizeSpaces ref, (src, "")) + return (toKey (normalizeSpaces ref), (src, "")) -- -- tables @@ -607,41 +640,20 @@ simpleDashedLines :: Char -> GenParser Char st [(Int,Int)] simpleDashedLines ch = try $ many1 (dashedLine ch) -gridPart :: Char -> GenParser 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 ch = try $ char '+' >> many1 (gridPart ch) >>~ blankline - -- Parse a table row separator simpleTableSep :: Char -> GenParser Char ParserState Char simpleTableSep ch = try $ simpleDashedLines ch >> newline -gridTableSep :: Char -> GenParser Char ParserState Char -gridTableSep ch = try $ gridDashedLines ch >> return '\n' - -- Parse a table footer simpleTableFooter :: GenParser Char ParserState [Char] simpleTableFooter = try $ simpleTableSep '=' >> blanklines -gridTableFooter :: GenParser Char ParserState [Char] -gridTableFooter = blanklines - -- Parse a raw line and split it into chunks by indices. simpleTableRawLine :: [Int] -> GenParser Char ParserState [String] simpleTableRawLine indices = do line <- many1Till anyChar newline return (simpleTableSplitLine indices line) -gridTableRawLine :: [Int] -> GenParser Char ParserState [String] -gridTableRawLine indices = do - char '|' - line <- many1Till anyChar newline - return (gridTableSplitLine indices $ removeTrailingSpace line) - -- Parse a table row and return a list of blocks (columns). simpleTableRow :: [Int] -> GenParser Char ParserState [[Block]] simpleTableRow indices = do @@ -651,64 +663,13 @@ let cols = map unlines . transpose $ firstLine : colLines mapM (parseFromString (many plain)) cols -gridTableRow :: [Int] - -> GenParser Char ParserState [[Block]] -gridTableRow indices = do - colLines <- many1 (gridTableRawLine indices) - let cols = map ((++ "\n") . unlines . removeOneLeadingSpace) $ - transpose colLines - mapM (liftM compactifyCell . parseFromString (many block)) cols - -compactifyCell :: [Block] -> [Block] -compactifyCell bs = head $ compactify [bs] - simpleTableSplitLine :: [Int] -> String -> [String] simpleTableSplitLine indices line = map removeLeadingTrailingSpace $ tail $ splitByIndices (init indices) line -gridTableSplitLine :: [Int] -> String -> [String] -gridTableSplitLine indices line = - map removeFinalBar $ tail $ splitByIndices (init indices) line - -removeFinalBar :: String -> String -removeFinalBar = reverse . dropWhile (=='|') . dropWhile (`elem` " \t") . - reverse - -removeOneLeadingSpace :: [String] -> [String] -removeOneLeadingSpace xs = - if all startsWithSpace xs - then map (drop 1) xs - else xs - where startsWithSpace "" = True - startsWithSpace (y:_) = y == ' ' - --- 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 = - let lengths' = zipWith (-) indices (0:indices) - lengths = reverse $ - case reverse lengths' of - [] -> [] - [x] -> [x] - -- compensate for the fact that intercolumn - -- spaces are counted in widths of all columns - -- but the last... - (x:y:zs) -> if x < y && y - x <= 2 - then y:y:zs - else x:y:zs - totLength = sum lengths - quotient = if totLength > numColumns - then fromIntegral totLength - else fromIntegral numColumns - fracs = map (\l -> (fromIntegral l) / quotient) lengths in - tail fracs - simpleTableHeader :: Bool -- ^ Headerless table - -> GenParser Char ParserState ([[Char]], [Alignment], [Int]) + -> GenParser Char ParserState ([[Block]], [Alignment], [Int]) simpleTableHeader headless = try $ do optional blanklines rawContent <- if headless @@ -722,64 +683,23 @@ let rawHeads = if headless then replicate (length dashes) "" else simpleTableSplitLine indices rawContent - return (rawHeads, aligns, indices) - -gridTableHeader :: Bool -- ^ Headerless table - -> GenParser Char ParserState ([String], [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 - return (rawHeads, aligns, indices) - --- Parse a table using 'headerParser', 'lineParser', and 'footerParser'. -tableWith :: GenParser Char ParserState ([[Char]], [Alignment], [Int]) - -> ([Int] -> GenParser Char ParserState [[Block]]) - -> GenParser Char ParserState sep - -> GenParser Char ParserState end - -> GenParser Char ParserState Block -tableWith headerParser rowParser lineParser footerParser = try $ do - (rawHeads, aligns, indices) <- headerParser - lines' <- rowParser indices `sepEndBy` lineParser - footerParser - heads <- mapM (parseFromString (many plain)) rawHeads - state <- getState - let captions = [] -- no notion of captions in RST - let numColumns = stateColumns state - let widths = widthsFromIndices numColumns indices - return $ Table captions aligns widths heads lines' + heads <- mapM (parseFromString (many plain)) $ + map removeLeadingTrailingSpace rawHeads + return (heads, aligns, indices) --- Parse a simple table with '---' header and one line per row. +-- Parse a simple table. simpleTable :: Bool -- ^ Headerless table -> GenParser Char ParserState Block simpleTable headless = do - Table c a _w h l <- tableWith (simpleTableHeader headless) simpleTableRow sep simpleTableFooter + Table c a _w h l <- tableWith (simpleTableHeader headless) simpleTableRow sep simpleTableFooter (return []) -- Simple tables get 0s for relative column widths (i.e., use default) return $ Table c a (replicate (length a) 0) h l where sep = return () -- optional (simpleTableSep '-') --- 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 - -> GenParser Char ParserState Block -gridTable headless = - tableWith (gridTableHeader headless) gridTableRow (gridTableSep '-') gridTableFooter + -> GenParser Char ParserState Block +gridTable = gridTableWith block (return []) table :: GenParser Char ParserState Block table = gridTable False <|> simpleTable False <|> @@ -791,17 +711,19 @@ -- inline :: GenParser Char ParserState Inline -inline = choice [ link +inline = choice [ whitespace + , link , str - , whitespace , endline , strong , emph , code , image - , hyphens , superscript , subscript + , note + , smartPunctuation inline + , hyphens , escapedChar , symbol ] "inline" @@ -825,7 +747,8 @@ code = try $ do string "``" result <- manyTill anyChar (try (string "``")) - return $ Code $ removeLeadingTrailingSpace $ intercalate " " $ lines result + return $ Code nullAttr + $ removeLeadingTrailingSpace $ intercalate " " $ lines result emph :: GenParser Char ParserState Inline emph = enclosed (char '*') (char '*') inline >>= @@ -889,17 +812,22 @@ referenceLink :: GenParser Char ParserState Inline referenceLink = try $ do label' <- (quotedReferenceName <|> simpleReferenceName) >>~ char '_' - key <- option label' (do{char '_'; return [Str "_"]}) -- anonymous link state <- getState let keyTable = stateKeys state + let isAnonKey x = case fromKey x of + [Str ('_':_)] -> True + _ -> False + key <- option (toKey label') $ + do char '_' + let anonKeys = sort $ filter isAnonKey $ M.keys keyTable + if null anonKeys + then pzero + else return (head anonKeys) (src,tit) <- case lookupKeySrc keyTable key of Nothing -> fail "no corresponding key" Just target -> return target - -- if anonymous link, remove first anon key so it won't be used again - let keyTable' = if (key == [Str "_"]) -- anonymous link? - then delete ([Str "_"], (src,tit)) keyTable -- remove first anon key - else keyTable - setState $ state { stateKeys = keyTable' } + -- 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) autoURI :: GenParser Char ParserState Inline @@ -922,7 +850,24 @@ ref <- manyTill inline (char '|') state <- getState let keyTable = stateKeys state - (src,tit) <- case lookupKeySrc keyTable ref of + (src,tit) <- case lookupKeySrc keyTable (toKey ref) of Nothing -> fail "no corresponding key" Just target -> return target return $ Image (normalizeSpaces ref) (src, tit) + +note :: GenParser Char ParserState Inline +note = try $ do + ref <- noteMarker + char '_' + state <- getState + let notes = stateNotes state + case lookup ref notes of + Nothing -> fail "note not found" + Just raw -> do + contents <- parseFromString parseBlocks raw + when (ref == "*" || ref == "#") $ do -- auto-numbered + -- delete the note so the next auto-numbered note + -- doesn't get the same contents: + let newnotes = deleteFirstsBy (==) notes [(ref,raw)] + updateState $ \st -> st{ stateNotes = newnotes } + return $ Note contents diff -Nru pandoc-1.5.1.1/src/Text/Pandoc/Readers/TeXMath.hs pandoc-1.8.0.3/src/Text/Pandoc/Readers/TeXMath.hs --- pandoc-1.5.1.1/src/Text/Pandoc/Readers/TeXMath.hs 2010-03-29 14:24:56.000000000 +0000 +++ pandoc-1.8.0.3/src/Text/Pandoc/Readers/TeXMath.hs 2011-02-05 18:48:07.000000000 +0000 @@ -27,209 +27,87 @@ Conversion of TeX math to a list of 'Pandoc' inline elements. -} -module Text.Pandoc.Readers.TeXMath ( - readTeXMath - ) where +module Text.Pandoc.Readers.TeXMath ( readTeXMath ) where -import Text.ParserCombinators.Parsec import Text.Pandoc.Definition +import Text.TeXMath.Types +import Text.TeXMath.Parser --- | Converts a string of raw TeX math to a list of 'Pandoc' inlines. +-- | Converts a raw TeX math formula to a list of 'Pandoc' inlines. +-- Defaults to raw formula between @$@ characters if entire formula +-- can't be converted. readTeXMath :: String -- ^ String to parse (assumes @'\n'@ line endings) -> [Inline] -readTeXMath inp = case parse teXMath ("formula: " ++ inp) inp of - Left _ -> [Str inp] -- if unparseable, just include original - Right res -> res - -teXMath :: GenParser Char st [Inline] -teXMath = manyTill mathPart eof >>= return . concat - -mathPart :: GenParser Char st [Inline] -mathPart = whitespace <|> superscript <|> subscript <|> symbol <|> - argument <|> digits <|> letters <|> misc - -whitespace :: GenParser Char st [Inline] -whitespace = many1 space >> return [] - -symbol :: GenParser Char st [Inline] -symbol = try $ do - char '\\' - res <- many1 letter - case lookup res teXsymbols of - Just m -> return [Str m] - Nothing -> return [Str $ "\\" ++ res] - -argument :: GenParser Char st [Inline] -argument = try $ do - char '{' - res <- many mathPart - char '}' - return $ if null res - then [Str " "] - else [Str "{"] ++ concat res ++ [Str "}"] - -digits :: GenParser Char st [Inline] -digits = do - res <- many1 digit - return [Str res] - -letters :: GenParser Char st [Inline] -letters = do - res <- many1 letter - return [Emph [Str res]] - -misc :: GenParser Char st [Inline] -misc = do - res <- noneOf "}" - return [Str [res]] - -scriptArg :: GenParser Char st [Inline] -scriptArg = try $ do - (try (do{char '{'; r <- many mathPart; char '}'; return $ concat r})) - <|> symbol - <|> (do{c <- (letter <|> digit); return [Str [c]]}) - -superscript :: GenParser Char st [Inline] -superscript = try $ do - char '^' - arg <- scriptArg - return [Superscript arg] - -subscript :: GenParser Char st [Inline] -subscript = try $ do - char '_' - arg <- scriptArg - return [Subscript arg] - -withThinSpace :: String -> String -withThinSpace str = "\x2009" ++ str ++ "\x2009" - -teXsymbols :: [(String, String)] -teXsymbols = - [("alpha","\x3B1") - ,("beta", "\x3B2") - ,("chi", "\x3C7") - ,("delta", "\x3B4") - ,("Delta", "\x394") - ,("epsilon", "\x3B5") - ,("varepsilon", "\x25B") - ,("eta", "\x3B7") - ,("gamma", "\x3B3") - ,("Gamma", "\x393") - ,("iota", "\x3B9") - ,("kappa", "\x3BA") - ,("lambda", "\x3BB") - ,("Lambda", "\x39B") - ,("mu", "\x3BC") - ,("nu", "\x3BD") - ,("omega", "\x3C9") - ,("Omega", "\x3A9") - ,("phi", "\x3C6") - ,("varphi", "\x3D5") - ,("Phi", "\x3A6") - ,("pi", "\x3C0") - ,("Pi", "\x3A0") - ,("psi", "\x3C8") - ,("Psi", "\x3A8") - ,("rho", "\x3C1") - ,("sigma", "\x3C3") - ,("Sigma", "\x3A3") - ,("tau", "\x3C4") - ,("theta", "\x3B8") - ,("vartheta", "\x3D1") - ,("Theta", "\x398") - ,("upsilon", "\x3C5") - ,("xi", "\x3BE") - ,("Xi", "\x39E") - ,("zeta", "\x3B6") - ,("ne", "\x2260") - ,("lt", withThinSpace "<") - ,("le", withThinSpace "\x2264") - ,("leq", withThinSpace "\x2264") - ,("ge", withThinSpace "\x2265") - ,("geq", withThinSpace "\x2265") - ,("prec", withThinSpace "\x227A") - ,("succ", withThinSpace "\x227B") - ,("preceq", withThinSpace "\x2AAF") - ,("succeq", withThinSpace "\x2AB0") - ,("in", withThinSpace "\x2208") - ,("notin", withThinSpace "\x2209") - ,("subset", withThinSpace "\x2282") - ,("supset", withThinSpace "\x2283") - ,("subseteq", withThinSpace "\x2286") - ,("supseteq", withThinSpace "\x2287") - ,("equiv", withThinSpace "\x2261") - ,("cong", withThinSpace "\x2245") - ,("approx", withThinSpace "\x2248") - ,("propto", withThinSpace "\x221D") - ,("cdot", withThinSpace "\x22C5") - ,("star", withThinSpace "\x22C6") - ,("backslash", "\\") - ,("times", withThinSpace "\x00D7") - ,("divide", withThinSpace "\x00F7") - ,("circ", withThinSpace "\x2218") - ,("oplus", withThinSpace "\x2295") - ,("otimes", withThinSpace "\x2297") - ,("odot", withThinSpace "\x2299") - ,("sum", "\x2211") - ,("prod", "\x220F") - ,("wedge", withThinSpace "\x2227") - ,("bigwedge", withThinSpace "\x22C0") - ,("vee", withThinSpace "\x2228") - ,("bigvee", withThinSpace "\x22C1") - ,("cap", withThinSpace "\x2229") - ,("bigcap", withThinSpace "\x22C2") - ,("cup", withThinSpace "\x222A") - ,("bigcup", withThinSpace "\x22C3") - ,("neg", "\x00AC") - ,("implies", withThinSpace "\x21D2") - ,("iff", withThinSpace "\x21D4") - ,("forall", "\x2200") - ,("exists", "\x2203") - ,("bot", "\x22A5") - ,("top", "\x22A4") - ,("vdash", "\x22A2") - ,("models", withThinSpace "\x22A8") - ,("uparrow", "\x2191") - ,("downarrow", "\x2193") - ,("rightarrow", withThinSpace "\x2192") - ,("to", withThinSpace "\x2192") - ,("rightarrowtail", "\x21A3") - ,("twoheadrightarrow", withThinSpace "\x21A0") - ,("twoheadrightarrowtail", withThinSpace "\x2916") - ,("mapsto", withThinSpace "\x21A6") - ,("leftarrow", withThinSpace "\x2190") - ,("leftrightarrow", withThinSpace "\x2194") - ,("Rightarrow", withThinSpace "\x21D2") - ,("Leftarrow", withThinSpace "\x21D0") - ,("Leftrightarrow", withThinSpace "\x21D4") - ,("partial", "\x2202") - ,("nabla", "\x2207") - ,("pm", "\x00B1") - ,("emptyset", "\x2205") - ,("infty", "\x221E") - ,("aleph", "\x2135") - ,("ldots", "...") - ,("therefore", "\x2234") - ,("angle", "\x2220") - ,("quad", "\x00A0\x00A0") - ,("cdots", "\x22EF") - ,("vdots", "\x22EE") - ,("ddots", "\x22F1") - ,("diamond", "\x22C4") - ,("Box", "\x25A1") - ,("lfloor", "\x230A") - ,("rfloor", "\x230B") - ,("lceiling", "\x2308") - ,("rceiling", "\x2309") - ,("langle", "\x2329") - ,("rangle", "\x232A") - ,("int", "\8747") - ,("{", "{") - ,("}", "}") - ,("[", "[") - ,("]", "]") - ,("|", "|") - ,("||", "||") - ] +readTeXMath inp = case texMathToPandoc inp of + Left _ -> [Str ("$" ++ inp ++ "$")] + Right res -> res + +texMathToPandoc :: String -> Either String [Inline] +texMathToPandoc inp = inp `seq` + case parseFormula inp of + Left err -> Left err + Right exps -> case expsToInlines exps of + Nothing -> Left "Formula too complex for [Inline]" + Just r -> Right r + +expsToInlines :: [Exp] -> Maybe [Inline] +expsToInlines xs = do + res <- mapM expToInlines xs + return (concat res) + +expToInlines :: Exp -> Maybe [Inline] +expToInlines (ENumber s) = Just [Str s] +expToInlines (EIdentifier s) = Just [Emph [Str s]] +expToInlines (EMathOperator s) = Just [Str s] +expToInlines (ESymbol t s) = Just $ addSpace t (Str s) + where addSpace Op x = [x, thinspace] + addSpace Bin x = [medspace, x, medspace] + addSpace Rel x = [widespace, x, widespace] + addSpace Pun x = [x, thinspace] + addSpace _ x = [x] + thinspace = Str "\x2006" + medspace = Str "\x2005" + widespace = Str "\x2004" +expToInlines (EStretchy x) = expToInlines x +expToInlines (EGrouped xs) = expsToInlines xs +expToInlines (ESpace _) = Just [Str " "] -- variable widths not supported +expToInlines (EBinary _ _ _) = Nothing +expToInlines (ESub x y) = do + x' <- expToInlines x + y' <- expToInlines y + return $ x' ++ [Subscript y'] +expToInlines (ESuper x y) = do + x' <- expToInlines x + y' <- expToInlines y + return $ x' ++ [Superscript y'] +expToInlines (ESubsup x y z) = do + x' <- expToInlines x + y' <- expToInlines y + z' <- expToInlines z + return $ x' ++ [Subscript y'] ++ [Superscript z'] +expToInlines (EDown x y) = expToInlines (ESub x y) +expToInlines (EUp x y) = expToInlines (ESuper x y) +expToInlines (EDownup x y z) = expToInlines (ESubsup x y z) +expToInlines (EText "normal" x) = Just [Str x] +expToInlines (EText "bold" x) = Just [Strong [Str x]] +expToInlines (EText "monospace" x) = Just [Code nullAttr x] +expToInlines (EText "italic" x) = Just [Emph [Str x]] +expToInlines (EText _ x) = Just [Str x] +expToInlines (EOver (EGrouped [EIdentifier [c]]) (ESymbol Accent [accent])) = + case accent of + '\x203E' -> Just [Emph [Str [c,'\x0304']]] -- bar + '\x00B4' -> Just [Emph [Str [c,'\x0301']]] -- acute + '\x0060' -> Just [Emph [Str [c,'\x0300']]] -- grave + '\x02D8' -> Just [Emph [Str [c,'\x0306']]] -- breve + '\x02C7' -> Just [Emph [Str [c,'\x030C']]] -- check + '.' -> Just [Emph [Str [c,'\x0307']]] -- dot + '\x00B0' -> Just [Emph [Str [c,'\x030A']]] -- ring + '\x20D7' -> Just [Emph [Str [c,'\x20D7']]] -- arrow right + '\x20D6' -> Just [Emph [Str [c,'\x20D6']]] -- arrow left + '\x005E' -> Just [Emph [Str [c,'\x0302']]] -- hat + '\x0302' -> Just [Emph [Str [c,'\x0302']]] -- hat + '~' -> Just [Emph [Str [c,'\x0303']]] -- tilde + _ -> Nothing +expToInlines _ = Nothing + diff -Nru pandoc-1.5.1.1/src/Text/Pandoc/Readers/Textile.hs pandoc-1.8.0.3/src/Text/Pandoc/Readers/Textile.hs --- pandoc-1.5.1.1/src/Text/Pandoc/Readers/Textile.hs 1970-01-01 00:00:00.000000000 +0000 +++ pandoc-1.8.0.3/src/Text/Pandoc/Readers/Textile.hs 2011-02-05 18:48:07.000000000 +0000 @@ -0,0 +1,523 @@ +{- +Copyright (C) 2010 Paul Rivier | tr '*#' '.@' + +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.Textile + Copyright : Copyright (C) 2010-2011 Paul Rivier and John MacFarlane + License : GNU GPL, version 2 or above + + Maintainer : Paul Rivier + Stability : alpha + Portability : portable + +Conversion from Textile to 'Pandoc' document, based on the spec +available at http://redcloth.org/textile. + +Implemented and parsed: + - Paragraphs + - Code blocks + - Lists + - blockquote + - Inlines : strong, emph, cite, code, deleted, superscript, + subscript, links + - footnotes + +Implemented but discarded: + - HTML-specific and CSS-specific attributes + +Left to be implemented: + - dimension sign + - all caps + - continued blocks (ex bq..) + +TODO : refactor common patterns across readers : + - autolink + - smartPunctuation + - more ... + +-} + + +module Text.Pandoc.Readers.Textile ( readTextile) where + +import Text.Pandoc.Definition +import Text.Pandoc.Shared +import Text.Pandoc.Parsing +import Text.Pandoc.Readers.HTML ( htmlTag, isInlineTag, isBlockTag ) +import Text.ParserCombinators.Parsec +import Text.HTML.TagSoup.Match +import Data.Char ( digitToInt, isLetter ) +import Control.Monad ( guard, liftM ) + +-- | 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 (s ++ "\n\n") + + +-- +-- Constants and data structure definitions +-- + +-- | Special chars border strings parsing +specialChars :: [Char] +specialChars = "\\[]<>*#_@~-+^&,.;:!?|\"'%()" + +-- | Generate a Pandoc ADT from a textile document +parseTextile :: GenParser Char ParserState Pandoc +parseTextile = do + -- textile allows raw HTML and does smart punctuation by default + updateState (\state -> state { stateParseRaw = True, stateSmart = True }) + many blankline + 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... + let firstPassParser = noteBlock <|> lineClump + manyTill firstPassParser eof >>= setInput . concat + setPosition startPos + st' <- getState + let reversedNotes = stateNotes st' + updateState $ \s -> s { stateNotes = reverse reversedNotes } + -- now parse it for real... + blocks <- parseBlocks + return $ Pandoc (Meta [] [] []) blocks -- FIXME + +noteMarker :: GenParser Char ParserState [Char] +noteMarker = skipMany spaceChar >> string "fn" >> manyTill digit (char '.') + +noteBlock :: GenParser Char ParserState [Char] +noteBlock = try $ do + startPos <- getPosition + ref <- noteMarker + optional blankline + contents <- liftM unlines $ many1Till anyLine (blanklines <|> noteBlock) + endPos <- getPosition + let newnote = (ref, contents ++ "\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' + +-- | Parse document blocks +parseBlocks :: GenParser Char ParserState [Block] +parseBlocks = manyTill block eof + +-- | Block parsers list tried in definition order +blockParsers :: [GenParser Char ParserState Block] +blockParsers = [ codeBlock + , header + , blockQuote + , hrule + , anyList + , rawHtmlBlock + , maybeExplicitBlock "table" table + , maybeExplicitBlock "p" para + , nullBlock ] + +-- | Any block in the order of definition of blockParsers +block :: GenParser Char ParserState Block +block = choice blockParsers "block" + +codeBlock :: GenParser Char ParserState Block +codeBlock = codeBlockBc <|> codeBlockPre + +codeBlockBc :: GenParser Char ParserState Block +codeBlockBc = try $ do + string "bc. " + contents <- manyTill anyLine blanklines + return $ CodeBlock ("",[],[]) $ unlines contents + +-- | Code Blocks in Textile are between
           and 
          +codeBlockPre :: GenParser Char ParserState Block +codeBlockPre = try $ do + htmlTag (tagOpen (=="pre") null) + result' <- manyTill anyChar (try $ htmlTag (tagClose (=="pre")) >> blockBreak) + -- drop leading newline if any + let result'' = case result' of + '\n':xs -> xs + _ -> result' + -- drop trailing newline if any + let result''' = case reverse result'' of + '\n':_ -> init result'' + _ -> result'' + return $ CodeBlock ("",[],[]) result''' + +-- | Header of the form "hN. content" with N in 1..6 +header :: GenParser Char ParserState Block +header = try $ do + char 'h' + level <- oneOf "123456" >>= return . digitToInt + optional attributes + char '.' + whitespace + name <- manyTill inline blockBreak + return $ Header level (normalizeSpaces name) + +-- | Blockquote of the form "bq. content" +blockQuote :: GenParser Char ParserState Block +blockQuote = try $ do + string "bq" + optional attributes + char '.' + whitespace + para >>= return . BlockQuote . (:[]) + +-- Horizontal rule + +hrule :: GenParser Char st Block +hrule = try $ do + skipSpaces + start <- oneOf "-*" + count 2 (skipSpaces >> char start) + skipMany (spaceChar <|> char start) + newline + optional blanklines + return HorizontalRule + +-- Lists handling + +-- | 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 $ do + l <- anyListAtDepth 1 + blanklines + return l + +-- | This allow one type of list to be nested into an other type, +-- provided correct nesting +anyListAtDepth :: Int -> GenParser 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 depth = try $ do + items <- many1 (bulletListItemAtDepth depth) + return (BulletList items) + +-- | Bullet List Item of given depth, depth being the number of +-- leading '*' +bulletListItemAtDepth :: Int -> GenParser Char ParserState [Block] +bulletListItemAtDepth depth = try $ do + count depth (char '*') + optional attributes + whitespace + p <- inlines >>= return . Plain + sublist <- option [] (anyListAtDepth (depth + 1) >>= return . (:[])) + return (p:sublist) + +-- | Ordered List of given depth, depth being the number of +-- leading '#' +orderedListAtDepth :: Int -> GenParser 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 depth = try $ do + count depth (char '#') + optional attributes + whitespace + p <- inlines >>= return . Plain + sublist <- option [] (anyListAtDepth (depth + 1) >>= return . (:[])) + return (p:sublist) + +-- | A definition list is a set of consecutive definition items +definitionList :: GenParser Char ParserState Block +definitionList = try $ do + items <- many1 definitionListItem + return $ DefinitionList items + +-- | 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 = 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]] + multilineDef = try $ do + optional whitespace >> newline + s <- many1Till anyChar (try (string "=:" >> newline)) + -- this ++ "\n\n" does not look very good + ds <- parseFromString parseBlocks (s ++ "\n\n") + return [ds] + +-- | 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 = try (newline >> blanklines >> return ()) <|> + (lookAhead rawHtmlBlock >> return ()) + +-- | A raw Html Block, optionally followed by blanklines +rawHtmlBlock :: GenParser Char ParserState Block +rawHtmlBlock = try $ do + (_,b) <- htmlTag isBlockTag + optional blanklines + return $ RawBlock "html" b + +-- | In textile, paragraphs are separated by blank lines. +para :: GenParser Char ParserState Block +para = try $ do + content <- manyTill inline blockBreak + return $ Para $ normalizeSpaces content + + +-- Tables + +-- | A table cell spans until a pipe | +tableCell :: GenParser 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 $ do + char '|' + cells <- endBy1 tableCell (char '|') + newline + return cells + +-- | Many table rows +tableRows :: GenParser Char ParserState [[TableCell]] +tableRows = many1 tableRow + +-- | Table headers are made of cells separated by a tag "|_." +tableHeaders :: GenParser Char ParserState [TableCell] +tableHeaders = try $ do + let separator = (try $ string "|_.") + separator + headers <- sepBy1 tableCell separator + char '|' + newline + return headers + +-- | 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 = try $ do + headers <- option [] tableHeaders + rows <- tableRows + blanklines + let nbOfCols = max (length headers) (length $ head rows) + 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 +maybeExplicitBlock name blk = try $ do + optional $ try $ string name >> optional attributes >> char '.' >> + ((try whitespace) <|> endline) + blk + + + +---------- +-- Inlines +---------- + + +-- | Any inline element +inline :: GenParser 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 + , whitespace + , endline + , code + , htmlSpan + , rawHtmlInline + , note + , simpleInline (string "??") (Cite []) + , simpleInline (string "**") Strong + , simpleInline (string "__") Emph + , simpleInline (char '*') Strong + , simpleInline (char '_') Emph + , simpleInline (char '-') Strikeout + , simpleInline (char '^') Superscript + , simpleInline (char '~') Subscript + , link + , image + , mark + , smartPunctuation inline + , symbol + ] + +-- | Trademark, registered, copyright +mark :: GenParser Char st Inline +mark = try $ char '(' >> (try tm <|> try reg <|> copy) + +reg :: GenParser Char st Inline +reg = do + oneOf "Rr" + char ')' + return $ Str "\174" + +tm :: GenParser Char st Inline +tm = do + oneOf "Tt" + oneOf "Mm" + char ')' + return $ Str "\8482" + +copy :: GenParser Char st Inline +copy = do + oneOf "Cc" + char ')' + return $ Str "\169" + +note :: GenParser Char ParserState Inline +note = try $ do + char '[' + ref <- many1 digit + char ']' + state <- getState + let notes = stateNotes state + case lookup ref notes of + Nothing -> fail "note not found" + Just raw -> liftM Note $ parseFromString parseBlocks raw + +-- | Any string +str :: GenParser Char ParserState Inline +str = do + xs <- many1 (noneOf (specialChars ++ "\t\n ")) + optional $ try $ do + lookAhead (char '(') + notFollowedBy' mark + getInput >>= setInput . (' ':) -- add space before acronym explanation + -- parse a following hyphen if followed by a letter + -- (this prevents unwanted interpretation as starting a strikeout section) + result <- option xs $ try $ do + char '-' + next <- lookAhead letter + guard $ isLetter (last xs) || isLetter next + return $ xs ++ "-" + return $ Str result + +-- | Textile allows HTML span infos, we discard them +htmlSpan :: GenParser Char ParserState Inline +htmlSpan = try $ do + char '%' + _ <- attributes + content <- manyTill anyChar (char '%') + return $ Str content + +-- | Some number of space chars +whitespace :: GenParser 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 = try $ do + newline >> notFollowedBy blankline + return LineBreak + +rawHtmlInline :: GenParser Char ParserState Inline +rawHtmlInline = liftM (RawInline "html" . snd) + $ htmlTag isInlineTag + +-- | Textile standard link syntax is "label":target +link :: GenParser Char ParserState Inline +link = try $ do + name <- surrounded (char '"') inline + char ':' + url <- manyTill (anyChar) (lookAhead $ (space <|> try (oneOf ".;," >> (space <|> newline)))) + 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, "") + +-- | image embedding +image :: GenParser Char ParserState Inline +image = try $ do + char '!' >> notFollowedBy space + src <- manyTill anyChar (lookAhead $ oneOf "!(") + alt <- option "" (try $ (char '(' >> manyTill anyChar (char ')'))) + char '!' + return $ Image [Str alt] (src, alt) + +-- | Any special symbol defined in specialChars +symbol :: GenParser Char ParserState Inline +symbol = do + result <- oneOf specialChars + return $ Str [result] + +-- | Inline code +code :: GenParser Char ParserState Inline +code = code1 <|> code2 + +code1 :: GenParser Char ParserState Inline +code1 = surrounded (char '@') anyChar >>= return . Code nullAttr + +code2 :: GenParser Char ParserState Inline +code2 = do + htmlTag (tagOpen (=="tt") null) + result' <- manyTill anyChar (try $ htmlTag $ tagClose (=="tt")) + return $ Code nullAttr result' + +-- | Html / CSS attributes +attributes :: GenParser 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 border + +-- | Inlines are most of the time of the same form +simpleInline :: GenParser Char ParserState t -- ^ surrounding parser + -> ([Inline] -> Inline) -- ^ Inline constructor + -> GenParser Char ParserState Inline -- ^ content parser (to be used repeatedly) +simpleInline border construct = surrounded border (inlineWithAttribute) >>= + return . construct . normalizeSpaces + where inlineWithAttribute = (try $ optional attributes) >> inline diff -Nru pandoc-1.5.1.1/src/Text/Pandoc/S5.hs pandoc-1.8.0.3/src/Text/Pandoc/S5.hs --- pandoc-1.5.1.1/src/Text/Pandoc/S5.hs 1970-01-01 00:00:00.000000000 +0000 +++ pandoc-1.8.0.3/src/Text/Pandoc/S5.hs 2011-02-05 18:48:07.000000000 +0000 @@ -0,0 +1,57 @@ +{- +Copyright (C) 2006-2010 John MacFarlane + +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.S5 + Copyright : Copyright (C) 2006-2010 John MacFarlane + License : GNU GPL, version 2 or above + + Maintainer : John MacFarlane + Stability : alpha + Portability : portable + +Definitions for creation of S5 powerpoint-like HTML. +(See .) +-} +module Text.Pandoc.S5 ( s5HeaderIncludes) where +import Text.Pandoc.Shared ( readDataFile ) +import System.FilePath ( () ) + +s5HeaderIncludes :: Maybe FilePath -> IO String +s5HeaderIncludes datadir = do + c <- s5CSS datadir + j <- s5Javascript datadir + return $ c ++ j + +s5Javascript :: Maybe FilePath -> IO String +s5Javascript datadir = do + jsCom <- readDataFile datadir $ "s5" "default" "slides.js.comment" + jsPacked <- readDataFile datadir $ "s5" "default" "slides.js.packed" + return $ "\n" + +s5CSS :: Maybe FilePath -> IO String +s5CSS datadir = do + s5CoreCSS <- readDataFile datadir $ "s5" "default" "s5-core.css" + s5FramingCSS <- readDataFile datadir $ "s5" "default" "framing.css" + s5PrettyCSS <- readDataFile datadir $ "s5" "default" "pretty.css" + s5OperaCSS <- readDataFile datadir $ "s5" "default" "opera.css" + s5OutlineCSS <- readDataFile datadir $ "s5" "default" "outline.css" + s5PrintCSS <- readDataFile datadir $ "s5" "default" "print.css" + return $ "\n\n\n\n" + diff -Nru pandoc-1.5.1.1/src/Text/Pandoc/Shared.hs pandoc-1.8.0.3/src/Text/Pandoc/Shared.hs --- pandoc-1.5.1.1/src/Text/Pandoc/Shared.hs 2010-03-29 14:24:56.000000000 +0000 +++ pandoc-1.8.0.3/src/Text/Pandoc/Shared.hs 2011-02-05 18:48:07.000000000 +0000 @@ -45,94 +45,43 @@ toRomanNumeral, escapeURI, unescapeURI, - wrapped, - wrapIfNeeded, - wrappedTeX, - wrapTeXIfNeeded, - BlockWrapper (..), - wrappedBlocksToDoc, tabFilter, - -- * Parsing - (>>~), - anyLine, - many1Till, - notFollowedBy', - oneOfStrings, - spaceChar, - skipSpaces, - blankline, - blanklines, - enclosed, - stringAnyCase, - parseFromString, - lineClump, - charsInBalanced, - charsInBalanced', - romanNumeral, - emailAddress, - uri, - withHorizDisplacement, - nullBlock, - failIfStrict, - failUnlessLHS, - escaped, - anyOrderedListMarker, - orderedListMarker, - charRef, - readWith, - testStringWith, - ParserState (..), - defaultParserState, - HeaderType (..), - ParserContext (..), - QuoteContext (..), - NoteTable, - KeyTable, - lookupKeySrc, - refsMatch, - -- * Prettyprinting - hang', - prettyPandoc, -- * Pandoc block and inline list processing orderedListMarkers, normalizeSpaces, + normalize, + stringify, compactify, Element (..), hierarchicalize, uniqueIdent, isHeaderBlock, + headerShift, -- * Writer options HTMLMathMethod (..), + CiteMethod (..), ObfuscationMethod (..), + HTMLSlideVariant (..), WriterOptions (..), defaultWriterOptions, -- * File handling inDirectory, + findDataFile, readDataFile ) where import Text.Pandoc.Definition -import Text.ParserCombinators.Parsec -import Text.PrettyPrint.HughesPJ ( Doc, fsep, ($$), (<>), empty, isEmpty, text, nest ) -import qualified Text.PrettyPrint.HughesPJ as PP -import Text.Pandoc.CharacterReferences ( characterReference ) -import Data.Char ( toLower, toUpper, ord, isLower, isUpper, isAlpha, isAscii, +import Text.Pandoc.Generic +import qualified Text.Pandoc.UTF8 as UTF8 (readFile) +import Data.Char ( toLower, isLower, isUpper, isAlpha, isAscii, isLetter, isDigit ) import Data.List ( find, isPrefixOf, intercalate ) -import Network.URI ( parseURI, URI (..), isAllowedInURI, escapeURIString, unEscapeString ) +import Network.URI ( isAllowedInURI, escapeURIString, unEscapeString ) import Codec.Binary.UTF8.String ( encodeString, decodeString ) import System.Directory import System.FilePath ( () ) --- Note: ghc >= 6.12 (base >=4.2) supports unicode through iconv --- So we use System.IO.UTF8 only if we have an earlier version -#if MIN_VERSION_base(4,2,0) -#else -import Prelude hiding ( putStr, putStrLn, writeFile, readFile, getContents ) -import System.IO.UTF8 -#endif -import Data.Generics +import Data.Generics (Typeable, Data) import qualified Control.Monad.State as S -import Control.Monad (join) import Paths_pandoc (getDataFileName) -- @@ -140,12 +89,12 @@ -- -- | Split list by groups of one or more sep. -splitBy :: (Eq a) => a -> [a] -> [[a]] +splitBy :: (a -> Bool) -> [a] -> [[a]] splitBy _ [] = [] -splitBy sep lst = - let (first, rest) = break (== sep) lst - rest' = dropWhile (== sep) rest - in first:(splitBy sep rest') +splitBy isSep lst = + let (first, rest) = break isSep lst + rest' = dropWhile isSep rest + in first:(splitBy isSep rest') -- | Split list into chunks divided at specified indices. splitByIndices :: [Int] -> [a] -> [[a]] @@ -157,11 +106,11 @@ -- | Replace each occurrence of one sublist in a list with another. substitute :: (Eq a) => [a] -> [a] -> [a] -> [a] substitute _ _ [] = [] -substitute [] _ lst = lst -substitute target replacement lst = +substitute [] _ xs = xs +substitute target replacement lst@(x:xs) = if target `isPrefixOf` lst - then replacement ++ (substitute target replacement $ drop (length target) lst) - else (head lst):(substitute target replacement $ tail lst) + then replacement ++ substitute target replacement (drop (length target) lst) + else x : substitute target replacement xs -- -- Text processing @@ -243,75 +192,6 @@ unescapeURI = escapeURIString (\c -> isAllowedInURI c || not (isAscii c)) . decodeString . unEscapeString --- | Wrap inlines to line length. -wrapped :: Monad m => ([Inline] -> m Doc) -> [Inline] -> m Doc -wrapped listWriter sect = (mapM listWriter $ splitBy Space sect) >>= - return . fsep - --- | Wrap inlines if the text wrap option is selected. -wrapIfNeeded :: Monad m => WriterOptions -> ([Inline] -> m Doc) -> - [Inline] -> m Doc -wrapIfNeeded opts = if writerWrapText opts - then wrapped - else ($) - --- auxiliary function for wrappedTeX -isNote :: Inline -> Bool -isNote (Note _) = True -isNote _ = False - --- | Wrap inlines to line length, treating footnotes in a way that --- makes sense in LaTeX and ConTeXt. -wrappedTeX :: Monad m - => Bool - -> ([Inline] -> m Doc) - -> [Inline] - -> m Doc -wrappedTeX includePercent listWriter sect = do - let (firstpart, rest) = break isNote sect - firstpartWrapped <- wrapped listWriter firstpart - if null rest - then return firstpartWrapped - else do let (note:rest') = rest - let (rest1, rest2) = break (== Space) rest' - -- rest1 is whatever comes between the note and a Space. - -- if the note is followed directly by a Space, rest1 is null. - -- rest1 is printed after the note but before the line break, - -- to avoid spurious blank space the note and immediately - -- following punctuation. - rest1Out <- if null rest1 - then return empty - else listWriter rest1 - rest2Wrapped <- if null rest2 - then return empty - else wrappedTeX includePercent listWriter (tail rest2) - noteText <- listWriter [note] - return $ (firstpartWrapped <> if includePercent then PP.char '%' else empty) $$ - (noteText <> rest1Out) $$ - rest2Wrapped - --- | Wrap inlines if the text wrap option is selected, specialized --- for LaTeX and ConTeXt. -wrapTeXIfNeeded :: Monad m - => WriterOptions - -> Bool - -> ([Inline] -> m Doc) - -> [Inline] - -> m Doc -wrapTeXIfNeeded opts includePercent = if writerWrapText opts - then wrappedTeX includePercent - else ($) - --- | Indicates whether block should be surrounded by blank lines (@Pad@) or not (@Reg@). -data BlockWrapper = Pad Doc | Reg Doc - --- | Converts a list of wrapped blocks to a Doc, with appropriate spaces around blocks. -wrappedBlocksToDoc :: [BlockWrapper] -> Doc -wrappedBlocksToDoc = foldr addBlock empty - where addBlock (Pad d) accum | isEmpty accum = d - addBlock (Pad d) accum = d $$ text "" $$ accum - addBlock (Reg d) accum = d $$ accum - -- | Convert tabs to spaces and filter out DOS line endings. -- Tabs will be preserved if tab stop is set to 0. tabFilter :: Int -- ^ Tab stop @@ -333,518 +213,6 @@ in go tabStop -- --- Parsing --- - --- | 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 = 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 p end = do - first <- p - rest <- manyTill p end - return (first:rest) - --- | 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' 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 - --- | Parses a space or tab. -spaceChar :: CharParser st Char -spaceChar = char ' ' <|> char '\t' - --- | Skips zero or more spaces or tabs. -skipSpaces :: GenParser Char st () -skipSpaces = skipMany spaceChar - --- | Skips zero or more spaces or tabs, then reads a newline. -blankline :: GenParser 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 = 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 $ - start >> notFollowedBy space >> many1Till parser end - --- | Parse string, case insensitive. -stringAnyCase :: [Char] -> CharParser st String -stringAnyCase [] = string "" -stringAnyCase (x:xs) = do - firstChar <- char (toUpper x) <|> char (toLower x) - rest <- stringAnyCase xs - return (firstChar:rest) - --- | Parse contents of 'str' using 'parser' and return result. -parseFromString :: GenParser tok st a -> [tok] -> GenParser tok st a -parseFromString parser str = do - oldPos <- getPosition - oldInput <- getInput - setInput str - result <- parser - setInput oldInput - setPosition oldPos - return result - --- | Parse raw line block up to and including blank lines. -lineClump :: GenParser Char st String -lineClump = blanklines - <|> (many1 (notFollowedBy blankline >> anyLine) >>= return . unlines) - --- | Parse a string of characters between an open character --- and a close character, including text between balanced --- pairs of open and close, which must be different. For example, --- @charsInBalanced '(' ')'@ will parse "(hello (there))" --- and return "hello (there)". Stop if a blank line is --- encountered. -charsInBalanced :: Char -> Char -> GenParser Char st String -charsInBalanced open close = try $ do - char open - raw <- many $ (many1 (noneOf [open, close, '\n'])) - <|> (do res <- charsInBalanced open close - return $ [open] ++ res ++ [close]) - <|> try (string "\n" >>~ notFollowedBy' blanklines) - char close - return $ concat raw - --- | Like @charsInBalanced@, but allow blank lines in the content. -charsInBalanced' :: Char -> Char -> GenParser Char st String -charsInBalanced' open close = try $ do - char open - raw <- many $ (many1 (noneOf [open, close])) - <|> (do res <- charsInBalanced' open close - return $ [open] ++ res ++ [close]) - char close - return $ concat raw - --- Auxiliary functions for romanNumeral: - -lowercaseRomanDigits :: [Char] -lowercaseRomanDigits = ['i','v','x','l','c','d','m'] - -uppercaseRomanDigits :: [Char] -uppercaseRomanDigits = map toUpper lowercaseRomanDigits - --- | Parses a roman numeral (uppercase or lowercase), returns number. -romanNumeral :: Bool -- ^ Uppercase if true - -> GenParser Char st Int -romanNumeral upperCase = do - let romanDigits = if upperCase - then uppercaseRomanDigits - else lowercaseRomanDigits - lookAhead $ oneOf romanDigits - 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 - fivehundreds <- many fivehundred >>= (return . (500 *) . length) - fourhundreds <- option 0 $ try $ hundred >> fivehundred >> return 400 - hundreds <- many hundred >>= (return . (100 *) . length) - nineties <- option 0 $ try $ ten >> hundred >> return 90 - fifties <- many fifty >>= (return . (50 *) . length) - forties <- option 0 $ try $ ten >> fifty >> return 40 - tens <- many ten >>= (return . (10 *) . length) - nines <- option 0 $ try $ one >> ten >> return 9 - fives <- many five >>= (return . (5 *) . length) - fours <- option 0 $ try $ one >> five >> return 4 - ones <- many one >>= (return . length) - let total = thousands + ninehundreds + fivehundreds + fourhundreds + - hundreds + nineties + fifties + forties + tens + nines + - fives + fours + ones - if total == 0 - then fail "not a roman numeral" - else return total - --- Parsers for email addresses and URIs - -emailChar :: GenParser Char st Char -emailChar = alphaNum <|> oneOf "-+_." - -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) - --- | 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) - --- | Parses a URI. Returns pair of original and URI-escaped version. -uri :: GenParser 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 - str <- many1 $ satisfy (\c -> not (isAscii c) || isAllowedInURI c) - -- 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" - --- | 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 = do - pos1 <- getPosition - result <- parser - pos2 <- getPosition - return (result, sourceColumn pos2 - sourceColumn pos1) - --- | 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 Char 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 = do - state <- getState - if stateLiterateHaskell state then return () else fail "Literate haskell feature" - --- | Parses backslash, then applies character parser. -escaped :: GenParser Char st Char -- ^ Parser for character to escape - -> GenParser Char st Inline -escaped parser = try $ do - char '\\' - result <- parser - return (Str [result]) - --- | Parses an uppercase roman numeral and returns (UpperRoman, number). -upperRoman :: GenParser 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 = do - num <- romanNumeral False - return (LowerRoman, num) - --- | Parses a decimal numeral and returns (Decimal, number). -decimal :: GenParser Char st (ListNumberStyle, Int) -decimal = do - num <- many1 digit - return (Decimal, read num) - --- | Parses a '#' returns (DefaultStyle, 1). -defaultNum :: GenParser 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 = 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 = 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 = (char 'i' >> return (LowerRoman, 1)) <|> - (char 'I' >> return (UpperRoman, 1)) - --- | Parses an ordered list marker and returns list attributes. -anyOrderedListMarker :: GenParser Char st ListAttributes -anyOrderedListMarker = choice $ - [delimParser numParser | delimParser <- [inPeriod, inOneParen, inTwoParens], - numParser <- [decimal, 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 num = try $ do - (style, start) <- num - char '.' - let delim = if style == DefaultStyle - 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 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 num = try $ do - char '(' - (style, start) <- num - char ')' - return (start, style, TwoParens) - --- | Parses an ordered list marker with a given style and delimiter, --- returns number. -orderedListMarker :: ListNumberStyle - -> ListNumberDelim - -> GenParser Char st Int -orderedListMarker style delim = do - let num = defaultNum <|> -- # can continue any kind of list - case style of - DefaultStyle -> decimal - Decimal -> decimal - UpperRoman -> upperRoman - LowerRoman -> lowerRoman - UpperAlpha -> upperAlpha - LowerAlpha -> lowerAlpha - let context = case delim of - DefaultDelim -> inPeriod - Period -> inPeriod - OneParen -> inOneParen - TwoParens -> inTwoParens - (start, _, _) <- context num - return start - --- | Parses a character reference and returns a Str element. -charRef :: GenParser Char st Inline -charRef = do - c <- characterReference - return $ Str [c] - --- | Parse a string with a given parser and state. -readWith :: GenParser Char ParserState a -- ^ parser - -> ParserState -- ^ initial state - -> String -- ^ input string - -> a -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 - -> String - -> IO () -testStringWith parser str = putStrLn $ show $ - readWith parser defaultParserState str - --- | Parsing options. -data ParserState = ParserState - { stateParseRaw :: Bool, -- ^ Parse raw HTML and LaTeX? - stateParserContext :: ParserContext, -- ^ Inside list? - stateQuoteContext :: QuoteContext, -- ^ Inside quoted environment? - stateSanitizeHTML :: Bool, -- ^ Sanitize HTML? - stateKeys :: KeyTable, -- ^ List of reference keys -#ifdef _CITEPROC - stateCitations :: [String], -- ^ List of available citations -#endif - stateNotes :: NoteTable, -- ^ List of notes - stateTabStop :: Int, -- ^ Tab stop - stateStandalone :: Bool, -- ^ Parse bibliographic info? - 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? - 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 - } - deriving Show - -defaultParserState :: ParserState -defaultParserState = - ParserState { stateParseRaw = False, - stateParserContext = NullState, - stateQuoteContext = NoQuote, - stateSanitizeHTML = False, - stateKeys = [], -#ifdef _CITEPROC - stateCitations = [], -#endif - stateNotes = [], - stateTabStop = 4, - stateStandalone = False, - stateTitle = [], - stateAuthors = [], - stateDate = [], - stateStrict = False, - stateSmart = False, - stateLiterateHaskell = False, - stateColumns = 80, - stateHeaderTable = [], - stateIndentedCodeClasses = [] } - -data HeaderType - = SingleHeader Char -- ^ Single line of characters underneath - | DoubleHeader Char -- ^ Lines of characters above and below - deriving (Eq, Show) - -data ParserContext - = ListItemState -- ^ Used when running parser on list item contents - | NullState -- ^ Default state - deriving (Eq, Show) - -data QuoteContext - = InSingleQuote -- ^ Used when parsing inside single quotes - | InDoubleQuote -- ^ Used when parsing inside double quotes - | NoQuote -- ^ Used when not parsing inside quotes - deriving (Eq, Show) - -type NoteTable = [(String, String)] - -type KeyTable = [([Inline], Target)] - --- | Look up key in key table and return target object. -lookupKeySrc :: KeyTable -- ^ Key table - -> [Inline] -- ^ Key - -> Maybe Target -lookupKeySrc table key = case find (refsMatch key . fst) table of - Nothing -> Nothing - Just (_, src) -> Just src - --- | Returns @True@ if keys match (case insensitive). -refsMatch :: [Inline] -> [Inline] -> Bool -refsMatch ((Str x):restx) ((Str y):resty) = - ((map toLower x) == (map toLower y)) && refsMatch restx resty -refsMatch ((Emph x):restx) ((Emph y):resty) = - refsMatch x y && refsMatch restx resty -refsMatch ((Strong x):restx) ((Strong y):resty) = - refsMatch x y && refsMatch restx resty -refsMatch ((Strikeout x):restx) ((Strikeout y):resty) = - refsMatch x y && refsMatch restx resty -refsMatch ((Superscript x):restx) ((Superscript y):resty) = - refsMatch x y && refsMatch restx resty -refsMatch ((Subscript x):restx) ((Subscript y):resty) = - refsMatch x y && refsMatch restx resty -refsMatch ((SmallCaps x):restx) ((SmallCaps y):resty) = - refsMatch x y && refsMatch restx resty -refsMatch ((Quoted t x):restx) ((Quoted u y):resty) = - t == u && refsMatch x y && refsMatch restx resty -refsMatch ((Code x):restx) ((Code y):resty) = - ((map toLower x) == (map toLower y)) && refsMatch restx resty -refsMatch ((Math t x):restx) ((Math u y):resty) = - ((map toLower x) == (map toLower y)) && t == u && refsMatch restx resty -refsMatch ((TeX x):restx) ((TeX y):resty) = - ((map toLower x) == (map toLower y)) && refsMatch restx resty -refsMatch ((HtmlInline x):restx) ((HtmlInline y):resty) = - ((map toLower x) == (map toLower y)) && refsMatch restx resty -refsMatch (x:restx) (y:resty) = (x == y) && refsMatch restx resty -refsMatch [] x = null x -refsMatch x [] = null x - --- --- Prettyprinting --- - --- | A version of hang that works like the version in pretty-1.0.0.0 -hang' :: Doc -> Int -> Doc -> Doc -hang' d1 n d2 = d1 $$ (nest n d2) - --- | Indent string as a block. -indentBy :: Int -- ^ Number of spaces to indent the block - -> Int -- ^ Number of spaces (rel to block) to indent first line - -> String -- ^ Contents of block to indent - -> String -indentBy _ _ [] = "" -indentBy num first str = - let (firstLine:restLines) = lines str - firstLineIndent = num + first - in (replicate firstLineIndent ' ') ++ firstLine ++ "\n" ++ - (intercalate "\n" $ map ((replicate num ' ') ++ ) restLines) - --- | Prettyprint list of Pandoc blocks elements. -prettyBlockList :: Int -- ^ Number of spaces to indent list of blocks - -> [Block] -- ^ List of blocks - -> String -prettyBlockList indent [] = indentBy indent 0 "[]" -prettyBlockList indent blocks = indentBy indent (-2) $ "[ " ++ - (intercalate "\n, " (map prettyBlock blocks)) ++ " ]" - --- | Prettyprint Pandoc block element. -prettyBlock :: Block -> String -prettyBlock (BlockQuote blocks) = "BlockQuote\n " ++ - (prettyBlockList 2 blocks) -prettyBlock (OrderedList attribs blockLists) = - "OrderedList " ++ show attribs ++ "\n" ++ indentBy 2 0 ("[ " ++ - (intercalate ", " $ map (\blocks -> prettyBlockList 2 blocks) - blockLists)) ++ " ]" -prettyBlock (BulletList blockLists) = "BulletList\n" ++ - indentBy 2 0 ("[ " ++ (intercalate ", " - (map (\blocks -> prettyBlockList 2 blocks) blockLists))) ++ " ]" -prettyBlock (DefinitionList items) = "DefinitionList\n" ++ - indentBy 2 0 ("[ " ++ (intercalate "\n, " - (map (\(term, defs) -> "(" ++ show term ++ ",\n" ++ - indentBy 3 0 ("[ " ++ (intercalate ", " - (map (\blocks -> prettyBlockList 2 blocks) defs)) ++ "]") ++ - ")") items))) ++ " ]" -prettyBlock (Table caption aligns widths header rows) = - "Table " ++ show caption ++ " " ++ show aligns ++ " " ++ - show widths ++ "\n" ++ prettyRow header ++ " [\n" ++ - (intercalate ",\n" (map prettyRow rows)) ++ " ]" - where prettyRow cols = indentBy 2 0 ("[ " ++ (intercalate ", " - (map (\blocks -> prettyBlockList 2 blocks) - cols))) ++ " ]" -prettyBlock block = show block - --- | Prettyprint Pandoc document. -prettyPandoc :: Pandoc -> String -prettyPandoc (Pandoc meta blocks) = "Pandoc " ++ "(" ++ show meta ++ - ")\n" ++ (prettyBlockList 0 blocks) ++ "\n" - --- -- Pandoc block and inline list processing -- @@ -855,6 +223,7 @@ 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 $ map singleton ['A'..'Z'] @@ -873,20 +242,104 @@ -- @Space@ elements, collapse double @Space@s into singles, and -- remove empty Str elements. normalizeSpaces :: [Inline] -> [Inline] -normalizeSpaces [] = [] -normalizeSpaces list = - let removeDoubles [] = [] - removeDoubles (Space:Space:rest) = removeDoubles (Space:rest) - removeDoubles (Space:(Str ""):Space:rest) = removeDoubles (Space:rest) - removeDoubles ((Str ""):rest) = removeDoubles rest - removeDoubles (x:rest) = x:(removeDoubles rest) - removeLeading (Space:xs) = removeLeading xs - removeLeading x = x - removeTrailing [] = [] - removeTrailing lst = if (last lst == Space) - then init lst - else lst - in removeLeading $ removeTrailing $ removeDoubles list +normalizeSpaces = cleanup . dropWhile isSpaceOrEmpty + where cleanup [] = [] + cleanup (Space:rest) = let rest' = dropWhile isSpaceOrEmpty rest + in case rest' of + [] -> [] + _ -> Space : cleanup rest' + cleanup ((Str ""):rest) = cleanup rest + cleanup (x:rest) = x : cleanup rest + +isSpaceOrEmpty :: Inline -> Bool +isSpaceOrEmpty Space = True +isSpaceOrEmpty (Str "") = True +isSpaceOrEmpty _ = False + +-- | Normalize @Pandoc@ document, consolidating doubled 'Space's, +-- combining adjacent 'Str's and 'Emph's, remove 'Null's and +-- empty elements, etc. +normalize :: (Eq a, Data a) => a -> a +normalize = topDown removeEmptyBlocks . + topDown consolidateInlines . + bottomUp (removeEmptyInlines . removeTrailingInlineSpaces) + +removeEmptyBlocks :: [Block] -> [Block] +removeEmptyBlocks (Null : xs) = removeEmptyBlocks xs +removeEmptyBlocks (BulletList [] : xs) = removeEmptyBlocks xs +removeEmptyBlocks (OrderedList _ [] : xs) = removeEmptyBlocks xs +removeEmptyBlocks (DefinitionList [] : xs) = removeEmptyBlocks xs +removeEmptyBlocks (RawBlock _ [] : xs) = removeEmptyBlocks xs +removeEmptyBlocks (x:xs) = x : removeEmptyBlocks xs +removeEmptyBlocks [] = [] + +removeEmptyInlines :: [Inline] -> [Inline] +removeEmptyInlines (Emph [] : zs) = removeEmptyInlines zs +removeEmptyInlines (Strong [] : zs) = removeEmptyInlines zs +removeEmptyInlines (Subscript [] : zs) = removeEmptyInlines zs +removeEmptyInlines (Superscript [] : zs) = removeEmptyInlines zs +removeEmptyInlines (SmallCaps [] : zs) = removeEmptyInlines zs +removeEmptyInlines (Strikeout [] : zs) = removeEmptyInlines zs +removeEmptyInlines (RawInline _ [] : zs) = removeEmptyInlines zs +removeEmptyInlines (Code _ [] : zs) = removeEmptyInlines zs +removeEmptyInlines (Str "" : zs) = removeEmptyInlines zs +removeEmptyInlines (x : xs) = x : removeEmptyInlines xs +removeEmptyInlines [] = [] + +removeTrailingInlineSpaces :: [Inline] -> [Inline] +removeTrailingInlineSpaces = reverse . removeLeadingInlineSpaces . reverse + +removeLeadingInlineSpaces :: [Inline] -> [Inline] +removeLeadingInlineSpaces = dropWhile isSpaceOrEmpty + +consolidateInlines :: [Inline] -> [Inline] +consolidateInlines (Str x : ys) = + case concat (x : map fromStr strs) of + "" -> consolidateInlines rest + n -> Str n : consolidateInlines rest + where + (strs, rest) = span isStr ys + isStr (Str _) = True + isStr _ = False + fromStr (Str z) = z + fromStr _ = error "consolidateInlines - fromStr - not a Str" +consolidateInlines (Space : ys) = Space : rest + where isSpace Space = True + isSpace _ = False + rest = consolidateInlines $ dropWhile isSpace ys +consolidateInlines (Emph xs : Emph ys : zs) = consolidateInlines $ + Emph (xs ++ ys) : zs +consolidateInlines (Strong xs : Strong ys : zs) = consolidateInlines $ + Strong (xs ++ ys) : zs +consolidateInlines (Subscript xs : Subscript ys : zs) = consolidateInlines $ + Subscript (xs ++ ys) : zs +consolidateInlines (Superscript xs : Superscript ys : zs) = consolidateInlines $ + Superscript (xs ++ ys) : zs +consolidateInlines (SmallCaps xs : SmallCaps ys : zs) = consolidateInlines $ + SmallCaps (xs ++ ys) : zs +consolidateInlines (Strikeout xs : Strikeout ys : zs) = consolidateInlines $ + Strikeout (xs ++ ys) : zs +consolidateInlines (RawInline f x : RawInline f' y : zs) | f == f' = + consolidateInlines $ RawInline f (x ++ y) : zs +consolidateInlines (Code a1 x : Code a2 y : zs) | a1 == a2 = + consolidateInlines $ Code a1 (x ++ y) : zs +consolidateInlines (x : xs) = x : consolidateInlines xs +consolidateInlines [] = [] + +-- | Convert list of inlines to a string with formatting removed. +stringify :: [Inline] -> String +stringify = queryWith go + where go :: Inline -> [Char] + go Space = " " + go (Str x) = x + go (Code _ x) = x + go (Math _ x) = x + go EmDash = "--" + go EnDash = "-" + go Apostrophe = "'" + go Ellipses = "..." + go LineBreak = " " + go _ = "" -- | Change final list item from @Para@ to @Plain@ if the list contains -- no other @Para@ blocks. @@ -916,35 +369,15 @@ -- | Convert Pandoc inline list to plain text identifier. HTML -- identifiers must start with a letter, and may contain only --- letters, digits, and the characters _-:. +-- letters, digits, and the characters _-. inlineListToIdentifier :: [Inline] -> String inlineListToIdentifier = - dropWhile (not . isAlpha) . intercalate "-" . words . map toLower . - filter (\c -> isLetter c || isDigit c || c `elem` "_-:. ") . - concatMap extractText - where extractText x = case x of - Str s -> s - Emph lst -> concatMap extractText lst - Strikeout lst -> concatMap extractText lst - Superscript lst -> concatMap extractText lst - SmallCaps lst -> concatMap extractText lst - Subscript lst -> concatMap extractText lst - Strong lst -> concatMap extractText lst - Quoted _ lst -> concatMap extractText lst - Cite _ lst -> concatMap extractText lst - Code s -> s - Space -> " " - EmDash -> "---" - EnDash -> "--" - Apostrophe -> "" - Ellipses -> "..." - LineBreak -> " " - Math _ s -> s - TeX _ -> "" - HtmlInline _ -> "" - Link lst _ -> concatMap extractText lst - Image lst _ -> concatMap extractText lst - Note _ -> "" + dropWhile (not . isAlpha) . intercalate "-" . words . + map (nbspToSp . toLower) . + filter (\c -> isLetter c || isDigit c || c `elem` "_-. ") . + stringify + where nbspToSp '\160' = ' ' + nbspToSp x = x -- | Convert list of Pandoc blocks into (hierarchical) list of Elements hierarchicalize :: [Block] -> [Element] @@ -991,6 +424,13 @@ 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 + -- -- Writer options -- @@ -999,37 +439,57 @@ | LaTeXMathML (Maybe String) -- url of LaTeXMathML.js | JsMath (Maybe String) -- url of jsMath load script | GladTeX - | MimeTeX String -- url of mimetex.cgi + | 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 + | 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 - , writerIncludeBefore :: String -- ^ Text to include before the body - , writerIncludeAfter :: String -- ^ Text to include after the body + , writerEPUBMetadata :: String -- ^ Metadata to include in EPUB , writerTabStop :: Int -- ^ Tabstop for conversion btw spaces and tabs , writerTableOfContents :: Bool -- ^ Include table of contents - , writerS5 :: Bool -- ^ We're writing S5 + , writerSlideVariant :: HTMLSlideVariant -- ^ Are we writing S5 or Slidy? + , 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) - , writerIncremental :: Bool -- ^ Incremental S5 lists , 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 + , writerChapters :: Bool -- ^ Use "chapter" for top-level sects + , writerListings :: Bool -- ^ Use listings package for code } deriving Show -- | Default writer options. @@ -1038,22 +498,30 @@ WriterOptions { writerStandalone = False , writerTemplate = "" , writerVariables = [] - , writerIncludeBefore = "" - , writerIncludeAfter = "" + , writerEPUBMetadata = "" , writerTabStop = 4 , writerTableOfContents = False - , writerS5 = False + , writerSlideVariant = NoSlides + , writerIncremental = False , writerXeTeX = False , writerHTMLMathMethod = PlainMath , writerIgnoreNotes = False - , writerIncremental = False , writerNumberSections = False + , writerSectionDivs = True , writerStrictMarkdown = False , writerReferenceLinks = False , writerWrapText = True + , writerColumns = 72 , writerLiterateHaskell = False , writerEmailObfuscation = JavascriptObfuscation , writerIdentifierPrefix = "" + , writerSourceDirectory = "." + , writerUserDataDir = Nothing + , writerCiteMethod = Citeproc + , writerBiblioFiles = [] + , writerHtml5 = False + , writerChapters = False + , writerListings = False } -- @@ -1069,11 +537,17 @@ 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 + -- | 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 = - case userDir of - Nothing -> getDataFileName fname >>= readFile - Just u -> catch (readFile $ u fname) - (\_ -> getDataFileName fname >>= readFile) +readDataFile userDir fname = findDataFile userDir fname >>= UTF8.readFile diff -Nru pandoc-1.5.1.1/src/Text/Pandoc/Templates.hs pandoc-1.8.0.3/src/Text/Pandoc/Templates.hs --- pandoc-1.5.1.1/src/Text/Pandoc/Templates.hs 2010-03-29 14:24:56.000000000 +0000 +++ pandoc-1.8.0.3/src/Text/Pandoc/Templates.hs 2011-02-05 18:48:07.000000000 +0000 @@ -72,7 +72,6 @@ import Control.Monad (liftM, when, forM) import System.FilePath import Data.List (intercalate, intersperse) -import Text.PrettyPrint (text, Doc) import Text.XHtml (primHtml, Html) import Data.ByteString.Lazy.UTF8 (ByteString, fromString) import Text.Pandoc.Shared (readDataFile) @@ -83,7 +82,6 @@ -> String -- ^ Name of writer -> IO (Either E.IOException String) getDefaultTemplate _ "native" = return $ Right "" -getDefaultTemplate user "s5" = getDefaultTemplate user "html" getDefaultTemplate user "odt" = getDefaultTemplate user "opendocument" getDefaultTemplate user writer = do let format = takeWhile (/='+') writer -- strip off "+lhs" if present @@ -113,9 +111,6 @@ instance TemplateTarget Html where toTarget = primHtml -instance TemplateTarget Doc where - toTarget = text - -- | Renders a template renderTemplate :: TemplateTarget a => [(String,String)] -- ^ Assoc. list of values for variables @@ -173,7 +168,7 @@ string "$for(" id' <- ident string ")$" - -- if newline after the "if", then a newline after "endif" will be swallowed + -- 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 indent = replicate pos ' ' diff -Nru pandoc-1.5.1.1/src/Text/Pandoc/UTF8.hs pandoc-1.8.0.3/src/Text/Pandoc/UTF8.hs --- pandoc-1.5.1.1/src/Text/Pandoc/UTF8.hs 1970-01-01 00:00:00.000000000 +0000 +++ pandoc-1.8.0.3/src/Text/Pandoc/UTF8.hs 2011-02-05 18:48:07.000000000 +0000 @@ -0,0 +1,116 @@ +{- +Copyright (C) 2010 John MacFarlane + +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.UTF8 + Copyright : Copyright (C) 2010 John MacFarlane + License : GNU GPL, version 2 or above + + Maintainer : John MacFarlane + Stability : alpha + Portability : portable + +UTF-8 aware string IO functions that will work with GHC 6.10, 6.12, or 7. +-} +module Text.Pandoc.UTF8 ( readFile + , writeFile + , getContents + , putStr + , putStrLn + , hPutStr + , hPutStrLn + , hGetContents + ) + +where + +#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 qualified System.IO as IO + +readFile :: FilePath -> IO String +readFile f = do + h <- openFile f ReadMode + hGetContents h + +writeFile :: FilePath -> String -> IO () +writeFile f s = withFile f WriteMode $ \h -> hPutStr h s + +getContents :: IO String +getContents = hGetContents stdin + +putStr :: String -> IO () +putStr s = hPutStr stdout s + +putStrLn :: String -> IO () +putStrLn s = hPutStrLn stdout s + +hPutStr :: Handle -> String -> IO () +hPutStr h s = hSetEncoding h utf8 >> IO.hPutStr h s + +hPutStrLn :: Handle -> String -> IO () +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 Codec.Binary.UTF8.String (encodeString) +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 . encodeString + +writeFile :: FilePath -> String -> IO () +writeFile f = B.writeFile (encodeString 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 + +putStrLn :: String -> IO () +putStrLn = B.putStrLn . fromString + +hPutStr :: Handle -> String -> IO () +hPutStr h = B.hPutStr h . fromString + +hPutStrLn :: Handle -> String -> IO () +hPutStrLn h s = hPutStr h (s ++ "\n") + +#endif diff -Nru pandoc-1.5.1.1/src/Text/Pandoc/UUID.hs pandoc-1.8.0.3/src/Text/Pandoc/UUID.hs --- pandoc-1.5.1.1/src/Text/Pandoc/UUID.hs 1970-01-01 00:00:00.000000000 +0000 +++ pandoc-1.8.0.3/src/Text/Pandoc/UUID.hs 2011-02-05 18:48:07.000000000 +0000 @@ -0,0 +1,77 @@ +{- +Copyright (C) 2010 John MacFarlane + +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.UUID + Copyright : Copyright (C) 2010 John MacFarlane + License : GNU GPL, version 2 or above + + Maintainer : John MacFarlane + Stability : alpha + Portability : portable + +UUID generation using Version 4 (random method) described +in RFC4122. See http://tools.ietf.org/html/rfc4122 +-} + +module Text.Pandoc.UUID ( UUID, getRandomUUID ) where + +import Text.Printf ( printf ) +import System.Random ( randomIO ) +import Data.Word +import Data.Bits ( setBit, clearBit ) +import Control.Monad ( liftM ) + +data UUID = UUID Word8 Word8 Word8 Word8 Word8 Word8 Word8 Word8 + Word8 Word8 Word8 Word8 Word8 Word8 Word8 Word8 + +instance Show UUID where + show (UUID a b c d e f g h i j k l m n o p) = + "urn:uuid:" ++ + printf "%02x" a ++ + printf "%02x" b ++ + printf "%02x" c ++ + printf "%02x" d ++ + "-" ++ + printf "%02x" e ++ + printf "%02x" f ++ + "-" ++ + printf "%02x" g ++ + printf "%02x" h ++ + "-" ++ + printf "%02x" i ++ + printf "%02x" j ++ + "-" ++ + printf "%02x" k ++ + printf "%02x" l ++ + printf "%02x" m ++ + printf "%02x" n ++ + printf "%02x" o ++ + printf "%02x" p + +getRandomUUID :: IO UUID +getRandomUUID = do + let getRN :: a -> IO Word8 + getRN _ = liftM fromIntegral (randomIO :: IO Int) + [a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p] <- mapM getRN ([1..16] :: [Int]) + -- set variant + let i' = i `setBit` 7 `clearBit` 6 + -- set version (0100 for random) + let g' = g `clearBit` 7 `setBit` 6 `clearBit` 5 `clearBit` 4 + return $ UUID a b c d e f g' h i' j k l m n o p + diff -Nru pandoc-1.5.1.1/src/Text/Pandoc/Writers/ConTeXt.hs pandoc-1.8.0.3/src/Text/Pandoc/Writers/ConTeXt.hs --- pandoc-1.5.1.1/src/Text/Pandoc/Writers/ConTeXt.hs 2010-03-29 14:24:56.000000000 +0000 +++ pandoc-1.8.0.3/src/Text/Pandoc/Writers/ConTeXt.hs 2011-02-05 18:48:07.000000000 +0000 @@ -1,3 +1,4 @@ +{-# LANGUAGE OverloadedStrings #-} {- Copyright (C) 2007-2010 John MacFarlane @@ -31,9 +32,9 @@ import Text.Pandoc.Definition import Text.Pandoc.Shared import Text.Printf ( printf ) -import Data.List ( isSuffixOf, intercalate, intersperse ) +import Data.List ( intercalate ) import Control.Monad.State -import Text.PrettyPrint.HughesPJ hiding ( Str ) +import Text.Pandoc.Pretty import Text.Pandoc.Templates ( renderTemplate ) data WriterState = @@ -56,15 +57,18 @@ pandocToConTeXt :: WriterOptions -> Pandoc -> State WriterState String pandocToConTeXt options (Pandoc (Meta title authors date) blocks) = do + let colwidth = if writerWrapText options + then Just $ writerColumns options + else Nothing titletext <- if null title then return "" - else liftM render $ inlineListToConTeXt title - authorstext <- mapM (liftM render . inlineListToConTeXt) authors + else liftM (render colwidth) $ inlineListToConTeXt title + authorstext <- mapM (liftM (render colwidth) . inlineListToConTeXt) authors datetext <- if null date then return "" - else liftM render $ inlineListToConTeXt date - body <- blockListToConTeXt blocks - let main = render body + else liftM (render colwidth) $ inlineListToConTeXt date + body <- blockListToConTeXt blocks + let main = render colwidth $ body let context = writerVariables options ++ [ ("toc", if writerTableOfContents options then "yes" else "") , ("body", main) @@ -92,6 +96,8 @@ '#' -> "\\#" '<' -> "\\letterless{}" '>' -> "\\lettermore{}" + '[' -> "{[}" + ']' -> "{]}" '_' -> "\\letterunderscore{}" '\160' -> "~" x -> [x] @@ -102,32 +108,27 @@ -- | Convert Pandoc block element to ConTeXt. blockToConTeXt :: Block - -> State WriterState BlockWrapper -blockToConTeXt Null = return $ Reg empty -blockToConTeXt (Plain lst) = do - st <- get - let options = stOptions st - contents <- wrapTeXIfNeeded options False inlineListToConTeXt lst - return $ Reg contents + -> State WriterState Doc +blockToConTeXt Null = return empty +blockToConTeXt (Plain lst) = inlineListToConTeXt lst blockToConTeXt (Para [Image txt (src,_)]) = do capt <- inlineListToConTeXt txt - return $ Pad $ text "\\placefigure[here,nonumber]{" <> capt <> - text "}{\\externalfigure[" <> text src <> text "]}" + return $ blankline $$ "\\placefigure[here,nonumber]" <> braces capt <> + braces ("\\externalfigure" <> brackets (text src)) <> blankline blockToConTeXt (Para lst) = do - st <- get - let options = stOptions st - contents <- wrapTeXIfNeeded options False inlineListToConTeXt lst - return $ Pad contents + contents <- inlineListToConTeXt lst + return $ contents <> blankline blockToConTeXt (BlockQuote lst) = do contents <- blockListToConTeXt lst - return $ Pad $ text "\\startblockquote" $$ contents $$ text "\\stopblockquote" -blockToConTeXt (CodeBlock _ str) = - return $ Reg $ text $ "\\starttyping\n" ++ str ++ "\n\\stoptyping\n" - -- \n because \stoptyping can't have anything after it, inc. } -blockToConTeXt (RawHtml _) = return $ Reg empty -blockToConTeXt (BulletList lst) = do + return $ "\\startblockquote" $$ nest 0 contents $$ "\\stopblockquote" <> blankline +blockToConTeXt (CodeBlock _ str) = + return $ "\\starttyping" <> cr <> flush (text str) <> cr <> "\\stoptyping" $$ blankline + -- blankline because \stoptyping can't have anything after it, inc. '}' +blockToConTeXt (RawBlock "context" str) = return $ text str <> blankline +blockToConTeXt (RawBlock _ _ ) = return empty +blockToConTeXt (BulletList lst) = do contents <- mapM listItemToConTeXt lst - return $ Pad $ text "\\startitemize" $$ vcat contents $$ text "\\stopitemize" + return $ "\\startitemize" $$ vcat contents $$ text "\\stopitemize" <> blankline blockToConTeXt (OrderedList (start, style', delim) lst) = do st <- get let level = stOrderedListLevel st @@ -153,25 +154,29 @@ let style'' = case style' of DefaultStyle -> orderedListStyles !! level Decimal -> "[n]" + Example -> "[n]" LowerRoman -> "[r]" UpperRoman -> "[R]" LowerAlpha -> "[a]" UpperAlpha -> "[A]" let specs = style'' ++ specs2 - return $ Pad $ text ("\\startitemize" ++ specs) $$ vcat contents $$ - text "\\stopitemize" + return $ "\\startitemize" <> text specs $$ vcat contents $$ + "\\stopitemize" <> blankline blockToConTeXt (DefinitionList lst) = - mapM defListItemToConTeXt lst >>= return . Pad . wrappedBlocksToDoc -blockToConTeXt HorizontalRule = return $ Pad $ text "\\thinrule" + liftM vcat $ mapM defListItemToConTeXt lst +blockToConTeXt HorizontalRule = return $ "\\thinrule" <> blankline blockToConTeXt (Header level lst) = do contents <- inlineListToConTeXt lst st <- get let opts = stOptions st let base = if writerNumberSections opts then "section" else "subject" - return $ Pad $ if level >= 1 && level <= 5 - then char '\\' <> text (concat (replicate (level - 1) "sub")) <> - text base <> char '{' <> contents <> char '}' - else contents + let level' = if writerChapters opts then level - 1 else level + return $ if level' >= 1 && level' <= 5 + then char '\\' <> text (concat (replicate (level' - 1) "sub")) <> + text base <> char '{' <> contents <> char '}' <> blankline + else if level' == 0 + then "\\chapter{" <> contents <> "}" + else contents <> blankline blockToConTeXt (Table caption aligns widths heads rows) = do let colDescriptor colWidth alignment = (case alignment of AlignLeft -> 'l' @@ -185,81 +190,87 @@ zipWith colDescriptor widths aligns) headers <- if all null heads then return empty - else liftM ($$ text "\\HL") $ tableRowToConTeXt heads + else liftM ($$ "\\HL") $ tableRowToConTeXt heads captionText <- inlineListToConTeXt caption let captionText' = if null caption then text "none" else captionText rows' <- mapM tableRowToConTeXt rows - return $ Pad $ text "\\placetable[here]{" <> captionText' <> char '}' $$ - text "\\starttable[" <> text colDescriptors <> char ']' $$ - text "\\HL" $$ headers $$ - vcat rows' $$ text "\\HL\n\\stoptable" + return $ "\\placetable[here]" <> braces captionText' $$ + "\\starttable" <> brackets (text colDescriptors) $$ + "\\HL" $$ headers $$ + vcat rows' $$ "\\HL" $$ "\\stoptable" <> blankline tableRowToConTeXt :: [[Block]] -> State WriterState Doc tableRowToConTeXt cols = do cols' <- mapM blockListToConTeXt cols - return $ (vcat (map (text "\\NC " <>) cols')) $$ - text "\\NC\\AR" + return $ (vcat (map ("\\NC " <>) cols')) $$ "\\NC\\AR" listItemToConTeXt :: [Block] -> State WriterState Doc listItemToConTeXt list = blockListToConTeXt list >>= - return . (text "\\item" $$) . (nest 2) + return . ("\\item" $$) . (nest 2) -defListItemToConTeXt :: ([Inline], [[Block]]) -> State WriterState BlockWrapper +defListItemToConTeXt :: ([Inline], [[Block]]) -> State WriterState Doc defListItemToConTeXt (term, defs) = do term' <- inlineListToConTeXt term - def' <- liftM (vcat . intersperse (text "")) $ mapM blockListToConTeXt defs - return $ Pad $ text "\\startdescr{" <> term' <> char '}' $$ def' $$ text "\\stopdescr" + def' <- liftM vsep $ mapM blockListToConTeXt defs + return $ "\\startdescr" <> braces term' $$ nest 2 def' $$ + "\\stopdescr" <> blankline -- | Convert list of block elements to ConTeXt. blockListToConTeXt :: [Block] -> State WriterState Doc -blockListToConTeXt lst = mapM blockToConTeXt lst >>= return . wrappedBlocksToDoc +blockListToConTeXt lst = liftM vcat $ mapM blockToConTeXt lst -- | Convert list of inline elements to ConTeXt. inlineListToConTeXt :: [Inline] -- ^ Inlines to convert -> State WriterState Doc -inlineListToConTeXt lst = mapM inlineToConTeXt lst >>= return . hcat +inlineListToConTeXt lst = liftM hcat $ mapM inlineToConTeXt lst -- | Convert inline element to ConTeXt inlineToConTeXt :: Inline -- ^ Inline to convert -> State WriterState Doc inlineToConTeXt (Emph lst) = do contents <- inlineListToConTeXt lst - return $ text "{\\em " <> contents <> char '}' + return $ braces $ "\\em " <> contents inlineToConTeXt (Strong lst) = do contents <- inlineListToConTeXt lst - return $ text "{\\bf " <> contents <> char '}' + return $ braces $ "\\bf " <> contents inlineToConTeXt (Strikeout lst) = do contents <- inlineListToConTeXt lst - return $ text "\\overstrikes{" <> contents <> char '}' + return $ "\\overstrikes" <> braces contents inlineToConTeXt (Superscript lst) = do contents <- inlineListToConTeXt lst - return $ text "\\high{" <> contents <> char '}' + return $ "\\high" <> braces contents inlineToConTeXt (Subscript lst) = do contents <- inlineListToConTeXt lst - return $ text "\\low{" <> contents <> char '}' + return $ "\\low" <> braces contents inlineToConTeXt (SmallCaps lst) = do contents <- inlineListToConTeXt lst - return $ text "{\\sc " <> contents <> char '}' -inlineToConTeXt (Code str) = return $ text $ "\\type{" ++ str ++ "}" + return $ braces $ "\\sc " <> contents +inlineToConTeXt (Code _ str) | not ('{' `elem` str || '}' `elem` str) = + return $ "\\type" <> braces (text str) +inlineToConTeXt (Code _ str) = + return $ "\\mono" <> braces (text $ stringToConTeXt str) inlineToConTeXt (Quoted SingleQuote lst) = do contents <- inlineListToConTeXt lst - return $ text "\\quote{" <> contents <> char '}' + return $ "\\quote" <> braces contents inlineToConTeXt (Quoted DoubleQuote lst) = do contents <- inlineListToConTeXt lst - return $ text "\\quotation{" <> contents <> char '}' + return $ "\\quotation" <> braces contents inlineToConTeXt (Cite _ lst) = inlineListToConTeXt lst inlineToConTeXt Apostrophe = return $ char '\'' -inlineToConTeXt EmDash = return $ text "---" -inlineToConTeXt EnDash = return $ text "--" -inlineToConTeXt Ellipses = return $ text "\\ldots{}" +inlineToConTeXt EmDash = return "---" +inlineToConTeXt EnDash = return "--" +inlineToConTeXt Ellipses = return "\\ldots{}" inlineToConTeXt (Str str) = return $ text $ stringToConTeXt str -inlineToConTeXt (Math InlineMath str) = return $ char '$' <> text str <> char '$' -inlineToConTeXt (Math DisplayMath str) = return $ text "\\startformula " <> text str <> text " \\stopformula" -inlineToConTeXt (TeX str) = return $ text str -inlineToConTeXt (HtmlInline _) = return empty -inlineToConTeXt (LineBreak) = return $ text "\\crlf\n" -inlineToConTeXt Space = return $ char ' ' -inlineToConTeXt (Link [Code str] (src, tit)) = -- since ConTeXt has its own +inlineToConTeXt (Math InlineMath str) = + return $ char '$' <> text str <> char '$' +inlineToConTeXt (Math DisplayMath str) = + return $ text "\\startformula " <> text str <> text " \\stopformula" +inlineToConTeXt (RawInline "context" str) = return $ text str +inlineToConTeXt (RawInline "tex" str) = return $ text str +inlineToConTeXt (RawInline _ _) = return empty +inlineToConTeXt (LineBreak) = return $ text "\\crlf" <> cr +inlineToConTeXt Space = return space +inlineToConTeXt (Link [Code _ str] (src, tit)) = -- since ConTeXt has its own inlineToConTeXt (Link [Str str] (src, tit)) -- way of printing links... inlineToConTeXt (Link txt (src, _)) = do st <- get @@ -267,15 +278,12 @@ put $ st {stNextRef = next + 1} let ref = show next label <- inlineListToConTeXt txt - return $ text "\\useURL[" <> text ref <> text "][" <> text src <> - text "][][" <> label <> text "]\\from[" <> text ref <> char ']' + return $ "\\useURL" <> brackets (text ref) <> brackets (text src) <> + brackets empty <> brackets label <> + "\\from" <> brackets (text ref) inlineToConTeXt (Image _ (src, _)) = do - return $ text "{\\externalfigure[" <> text src <> text "]}" + return $ braces $ "\\externalfigure" <> brackets (text src) inlineToConTeXt (Note contents) = do contents' <- blockListToConTeXt contents - let rawnote = stripTrailingNewlines $ render contents' - -- note: a \n before } is needed when note ends with a \stoptyping - let optNewline = "\\stoptyping" `isSuffixOf` rawnote - return $ text "\\footnote{" <> - text rawnote <> (if optNewline then char '\n' else empty) <> char '}' - + return $ text "\\footnote{" <> + nest 2 contents' <> char '}' diff -Nru pandoc-1.5.1.1/src/Text/Pandoc/Writers/Docbook.hs pandoc-1.8.0.3/src/Text/Pandoc/Writers/Docbook.hs --- pandoc-1.5.1.1/src/Text/Pandoc/Writers/Docbook.hs 2010-03-29 14:24:56.000000000 +0000 +++ pandoc-1.8.0.3/src/Text/Pandoc/Writers/Docbook.hs 2011-02-05 18:48:07.000000000 +0000 @@ -33,15 +33,15 @@ import Text.Pandoc.Shared import Text.Pandoc.Templates (renderTemplate) import Text.Pandoc.Readers.TeXMath -import Data.List ( isPrefixOf, intercalate ) +import Data.List ( isPrefixOf, intercalate, isSuffixOf ) import Data.Char ( toLower ) -import Text.PrettyPrint.HughesPJ hiding ( Str ) import Text.Pandoc.Highlighting (languages, languagesByExtension) +import Text.Pandoc.Pretty -- | Convert list of authors to a docbook section authorToDocbook :: WriterOptions -> [Inline] -> Doc authorToDocbook opts name' = - let name = render $ inlinesToDocbook opts name' + let name = render Nothing $ inlinesToDocbook opts name' in if ',' `elem` name then -- last name first let (lastname, rest) = break (==',') name @@ -61,16 +61,24 @@ -- | Convert Pandoc document to string in Docbook format. writeDocbook :: WriterOptions -> Pandoc -> String writeDocbook opts (Pandoc (Meta tit auths dat) blocks) = - let title = wrap opts tit + let title = inlinesToDocbook opts tit authors = map (authorToDocbook opts) auths date = inlinesToDocbook opts dat elements = hierarchicalize blocks - main = render $ vcat (map (elementToDocbook opts) elements) + colwidth = if writerWrapText opts + then Just $ writerColumns opts + else Nothing + render' = render colwidth + opts' = if "" `isSuffixOf` + (removeTrailingSpace $ writerTemplate opts) + then opts{ writerChapters = True } + else opts + main = render' $ vcat (map (elementToDocbook opts') elements) context = writerVariables opts ++ [ ("body", main) - , ("title", render title) - , ("date", render date) ] ++ - [ ("author", render a) | a <- authors ] + , ("title", render' title) + , ("date", render' date) ] ++ + [ ("author", render' a) | a <- authors ] in if writerStandalone opts then renderTemplate context $ writerTemplate opts else main @@ -83,9 +91,12 @@ let elements' = if null elements then [Blk (Para [])] else elements - in inTags True "section" [("id",id')] $ - inTagsSimple "title" (wrap opts title) $$ - vcat (map (elementToDocbook opts) elements') + tag = if writerChapters opts + then "chapter" + else "section" + in inTags True tag [("id",id')] $ + inTagsSimple "title" (inlinesToDocbook opts title) $$ + vcat (map (elementToDocbook opts{ writerChapters = False }) elements') -- | Convert a list of Pandoc blocks to Docbook. blocksToDocbook :: WriterOptions -> [Block] -> Doc @@ -123,7 +134,7 @@ blockToDocbook :: WriterOptions -> Block -> Doc blockToDocbook _ Null = empty blockToDocbook _ (Header _ _) = empty -- should not occur after hierarchicalize -blockToDocbook opts (Plain lst) = wrap opts lst +blockToDocbook opts (Plain lst) = inlinesToDocbook opts lst blockToDocbook opts (Para [Image txt (src,_)]) = let capt = inlinesToDocbook opts txt in inTagsIndented "figure" $ @@ -132,12 +143,13 @@ (inTagsIndented "imageobject" (selfClosingTag "imagedata" [("fileref",src)])) $$ inTagsSimple "textobject" (inTagsSimple "phrase" capt)) -blockToDocbook opts (Para lst) = inTagsIndented "para" $ wrap opts lst +blockToDocbook opts (Para lst) = + inTagsIndented "para" $ inlinesToDocbook opts lst blockToDocbook opts (BlockQuote blocks) = inTagsIndented "blockquote" $ blocksToDocbook opts blocks blockToDocbook _ (CodeBlock (_,classes,_) str) = - text ("\n") <> - text (escapeStringForXML str) <> text "\n" + text ("") <> cr <> + flush (text (escapeStringForXML str) <> cr <> text "") where lang = if null langs then "" else " language=\"" ++ escapeStringForXML (head langs) ++ @@ -154,6 +166,7 @@ let attribs = case numstyle of DefaultStyle -> [] Decimal -> [("numeration", "arabic")] + Example -> [("numeration", "arabic")] UpperAlpha -> [("numeration", "upperalpha")] LowerAlpha -> [("numeration", "loweralpha")] UpperRoman -> [("numeration", "upperroman")] @@ -166,7 +179,10 @@ in inTags True "orderedlist" attribs items blockToDocbook opts (DefinitionList lst) = inTagsIndented "variablelist" $ deflistItemsToDocbook opts lst -blockToDocbook _ (RawHtml str) = text str -- raw XML block +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 blockToDocbook _ HorizontalRule = empty -- not semantic blockToDocbook opts (Table caption aligns widths headers rows) = let alignStrings = map alignmentToString aligns @@ -213,12 +229,6 @@ let attrib = [("align", align)] in inTags True tag attrib $ vcat $ map (blockToDocbook opts) item --- | Take list of inline elements and return wrapped doc. -wrap :: WriterOptions -> [Inline] -> Doc -wrap opts lst = if writerWrapText opts - then fsep $ map (inlinesToDocbook opts) (splitBy Space lst) - else inlinesToDocbook opts lst - -- | Convert a list of inline elements to Docbook. inlinesToDocbook :: WriterOptions -> [Inline] -> Doc inlinesToDocbook opts lst = hcat $ map (inlineToDocbook opts) lst @@ -248,22 +258,21 @@ inlineToDocbook _ Ellipses = text "…" inlineToDocbook _ EmDash = text "—" inlineToDocbook _ EnDash = text "–" -inlineToDocbook _ (Code str) = +inlineToDocbook _ (Code _ str) = inTagsSimple "literal" $ text (escapeStringForXML str) inlineToDocbook opts (Math _ str) = inlinesToDocbook opts $ readTeXMath str -inlineToDocbook _ (TeX _) = empty -inlineToDocbook _ (HtmlInline _) = empty -inlineToDocbook _ LineBreak = text $ "" -inlineToDocbook _ Space = char ' ' +inlineToDocbook _ (RawInline _ _) = empty +inlineToDocbook _ LineBreak = inTagsSimple "literallayout" empty +inlineToDocbook _ Space = space inlineToDocbook opts (Link txt (src, _)) = if isPrefixOf "mailto:" src then let src' = drop 7 src emailLink = inTagsSimple "email" $ text $ escapeStringForXML $ src' - in if txt == [Code src'] - then emailLink - else inlinesToDocbook opts txt <+> char '(' <> emailLink <> - char ')' + in case txt of + [Code _ s] | 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)]) $ @@ -274,6 +283,6 @@ else inTagsIndented "objectinfo" $ inTagsIndented "title" (text $ escapeStringForXML tit) in inTagsIndented "inlinemediaobject" $ inTagsIndented "imageobject" $ - titleDoc $$ selfClosingTag "imagedata" [("fileref", src)] + titleDoc $$ selfClosingTag "imagedata" [("fileref", src)] inlineToDocbook opts (Note contents) = inTagsIndented "footnote" $ blocksToDocbook opts contents diff -Nru pandoc-1.5.1.1/src/Text/Pandoc/Writers/EPUB.hs pandoc-1.8.0.3/src/Text/Pandoc/Writers/EPUB.hs --- pandoc-1.5.1.1/src/Text/Pandoc/Writers/EPUB.hs 1970-01-01 00:00:00.000000000 +0000 +++ pandoc-1.8.0.3/src/Text/Pandoc/Writers/EPUB.hs 2011-02-05 18:48:07.000000000 +0000 @@ -0,0 +1,284 @@ +{- +Copyright (C) 2010 John MacFarlane + +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.Writers.EPUB + Copyright : Copyright (C) 2010 John MacFarlane + License : GNU GPL, version 2 or above + + Maintainer : John MacFarlane + Stability : alpha + Portability : portable + +Conversion of 'Pandoc' documents to EPUB. +-} +module Text.Pandoc.Writers.EPUB ( writeEPUB ) where +import Data.IORef +import Data.Maybe ( fromMaybe, isNothing ) +import Data.List ( findIndices, isPrefixOf ) +import System.Environment ( getEnv ) +import System.FilePath ( (), takeBaseName, takeExtension ) +import qualified Data.ByteString.Lazy as B +import Data.ByteString.Lazy.UTF8 ( fromString ) +import Codec.Archive.Zip +import System.Time +import Text.Pandoc.Shared hiding ( Element ) +import Text.Pandoc.Definition +import Text.Pandoc.Generic +import Control.Monad (liftM) +import Text.XML.Light hiding (ppTopElement) +import Text.Pandoc.UUID +import Text.Pandoc.Writers.HTML +import Text.Pandoc.Writers.Markdown ( writePlain ) +import Data.Char ( toLower ) + +-- | Produce an EPUB file from a Pandoc document. +writeEPUB :: Maybe String -- ^ EPUB stylesheet specified at command line + -> WriterOptions -- ^ Writer options + -> Pandoc -- ^ Document to convert + -> IO B.ByteString +writeEPUB mbStylesheet opts doc@(Pandoc meta _) = do + (TOD epochtime _) <- getClockTime + let mkEntry path content = toEntry path epochtime content + let opts' = opts{ writerEmailObfuscation = NoObfuscation + , writerStandalone = True + , writerWrapText = False } + let sourceDir = writerSourceDirectory opts' + + -- title page + let vars = writerVariables opts' + let tpContent = fromString $ writeHtmlString + opts'{writerTemplate = pageTemplate + ,writerVariables = ("titlepage","yes"):vars} + (Pandoc meta []) + let tpEntry = mkEntry "title_page.xhtml" tpContent + + -- handle pictures + picsRef <- newIORef [] + Pandoc _ blocks <- liftM (bottomUp transformBlock) $ bottomUpM + (transformInlines (writerHTMLMathMethod opts) sourceDir picsRef) doc + pics <- readIORef picsRef + let readPicEntry (oldsrc, newsrc) = readEntry [] oldsrc >>= \e -> + return e{ eRelativePath = newsrc } + picEntries <- mapM readPicEntry pics + + -- body pages + let isH1 (Header 1 _) = True + isH1 _ = False + 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 chapToHtml = writeHtmlString opts'{ writerTemplate = pageTemplate + , writerHTMLMathMethod = PlainMath } + let chapters = map titleize chunks + let chapterToEntry :: Int -> Pandoc -> Entry + chapterToEntry num chap = mkEntry ("ch" ++ show num ++ ".xhtml") $ + fromString $ chapToHtml chap + let chapterEntries = zipWith chapterToEntry [1..] chapters + + -- contents.opf + lang <- catch (liftM (takeWhile (/='.')) $ getEnv "lang") + (\_ -> return "en-US") + uuid <- getRandomUUID + let chapterNode ent = unode "item" ! + [("id", takeBaseName $ eRelativePath ent), + ("href", eRelativePath ent), + ("media-type", "application/xhtml+xml")] $ () + let chapterRefNode ent = unode "itemref" ! + [("idref", takeBaseName $ eRelativePath ent)] $ () + let pictureNode ent = unode "item" ! + [("id", takeBaseName $ eRelativePath ent), + ("href", eRelativePath ent), + ("media-type", fromMaybe "application/octet-stream" + $ imageTypeOf $ eRelativePath ent)] $ () + let plainify t = removeTrailingSpace $ + writePlain opts'{ writerStandalone = False } $ + Pandoc meta [Plain t] + let plainTitle = plainify $ docTitle meta + let plainAuthors = map plainify $ docAuthors meta + let contentsData = fromString $ ppTopElement $ + unode "package" ! [("version","2.0") + ,("xmlns","http://www.idpf.org/2007/opf") + ,("unique-identifier","BookId")] $ + [ metadataElement (writerEPUBMetadata opts') + uuid lang plainTitle plainAuthors + , 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")] $ () + ] ++ + map chapterNode (tpEntry : chapterEntries) ++ + map pictureNode picEntries + , unode "spine" ! [("toc","ncx")] $ + map chapterRefNode (tpEntry : chapterEntries) + ] + 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 $ + unode "ncx" ! [("version","2005-1") + ,("xmlns","http://www.daisy.org/z3986/2005/ncx/")] $ + [ unode "head" + [ unode "meta" ! [("name","dtb:uid") + ,("content", show uuid)] $ () + , unode "meta" ! [("name","dtb:depth") + ,("content", "1")] $ () + , unode "meta" ! [("name","dtb:totalPageCount") + ,("content", "0")] $ () + , unode "meta" ! [("name","dtb:maxPageNumber") + ,("content", "0")] $ () + ] + , unode "docTitle" $ unode "text" $ plainTitle + , unode "navMap" $ zipWith3 navPointNode (tpEntry : chapterEntries) + [1..(length chapterEntries + 1)] + ("Title Page" : map (\(Pandoc m _) -> + plainify $ docTitle m) chapters) + ] + let tocEntry = mkEntry "toc.ncx" tocData + + -- mimetype + let mimetypeEntry = mkEntry "mimetype" $ fromString "application/epub+zip" + + -- container.xml + let containerData = fromString $ ppTopElement $ + unode "container" ! [("version","1.0") + ,("xmlns","urn:oasis:names:tc:opendocument:xmlns:container")] $ + unode "rootfiles" $ + unode "rootfile" ! [("full-path","content.opf") + ,("media-type","application/oebps-package+xml")] $ () + let containerEntry = mkEntry "META-INF/container.xml" containerData + + -- stylesheet + stylesheet <- case mbStylesheet of + Just s -> return s + Nothing -> readDataFile (writerUserDataDir opts) "epub.css" + let stylesheetEntry = mkEntry "stylesheet.css" $ fromString stylesheet + + -- construct archive + let archive = foldr addEntryToArchive emptyArchive + (mimetypeEntry : containerEntry : stylesheetEntry : tpEntry : + contentsEntry : tocEntry : (picEntries ++ chapterEntries) ) + return $ fromArchive archive + +metadataElement :: String -> UUID -> String -> String -> [String] -> Element +metadataElement metadataXML uuid lang title authors = + 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 + 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 + 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 ] + in elt{ elContent = elContent elt ++ map Elem newNodes } + +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 _ sourceDir picsRef (Image lab (src,tit) : xs) = do + pics <- readIORef picsRef + let oldsrc = sourceDir src + let ext = takeExtension src + newsrc <- case lookup oldsrc pics of + Just n -> return n + Nothing -> do + let new = "images/img" ++ show (length pics) ++ ext + modifyIORef picsRef ( (oldsrc, new): ) + return new + return $ Image lab (newsrc, tit) : xs +transformInlines (MathML _) _ _ (x@(Math _ _) : xs) = do + let writeHtmlInline opts z = removeTrailingSpace $ + writeHtmlString opts $ Pandoc (Meta [] [] []) [Plain [z]] + mathml = writeHtmlInline defaultWriterOptions{ + writerHTMLMathMethod = MathML Nothing } x + fallback = writeHtmlInline defaultWriterOptions{ + writerHTMLMathMethod = PlainMath } x + inOps = "" ++ + "" ++ + mathml ++ "" ++ fallback ++ "" ++ + "" + result = if " Block +transformBlock (RawBlock _ _) = Null +transformBlock x = x + +(!) :: Node t => (t -> Element) -> [(String, String)] -> t -> Element +(!) f attrs n = add_attrs (map (\(k,v) -> Attr (unqual k) v) attrs) (f n) + +-- | Version of 'ppTopElement' that specifies UTF-8 encoding. +ppTopElement :: Element -> String +ppTopElement = ("\n" ++) . ppElement + +imageTypeOf :: FilePath -> Maybe String +imageTypeOf x = case drop 1 (map toLower (takeExtension x)) of + "jpg" -> Just "image/jpeg" + "jpeg" -> Just "image/jpeg" + "jfif" -> Just "image/jpeg" + "png" -> Just "image/png" + "gif" -> Just "image/gif" + "svg" -> Just "image/svg+xml" + _ -> Nothing + +pageTemplate :: String +pageTemplate = unlines + [ "" + , "" + , "" + , "" + , "$title$" + , "" + , "" + , "" + , "$if(titlepage)$" + , "

          $title$

          " + , "$for(author)$" + , "

          $author$

          " + , "$endfor$" + , "$else$" + , "

          $title$

          " + , "$body$" + , "$endif$" + , "" + , "" + ] + diff -Nru pandoc-1.5.1.1/src/Text/Pandoc/Writers/HTML.hs pandoc-1.8.0.3/src/Text/Pandoc/Writers/HTML.hs --- pandoc-1.5.1.1/src/Text/Pandoc/Writers/HTML.hs 2010-03-29 14:24:56.000000000 +0000 +++ pandoc-1.8.0.3/src/Text/Pandoc/Writers/HTML.hs 2011-02-05 18:48:07.000000000 +0000 @@ -34,14 +34,15 @@ import Text.Pandoc.Shared import Text.Pandoc.Templates import Text.Pandoc.Readers.TeXMath -import Text.Pandoc.Highlighting ( highlightHtml ) +import Text.Pandoc.Highlighting ( highlightHtml, defaultHighlightingCss ) import Text.Pandoc.XML (stripTags, escapeStringForXML) +import Network.HTTP ( urlEncode ) import Numeric ( showHex ) import Data.Char ( ord, toLower ) import Data.List ( isPrefixOf, intersperse ) import Data.Maybe ( catMaybes ) import Control.Monad.State -import Text.XHtml.Transitional hiding ( stringToHtml ) +import Text.XHtml.Transitional hiding ( stringToHtml, unordList, ordList ) import Text.TeXMath import Text.XML.Light.Output @@ -57,16 +58,17 @@ -- Helpers to render HTML with the appropriate function. -renderFragment :: (HTML html) => WriterOptions -> html -> String -renderFragment opts = if writerWrapText opts - then renderHtmlFragment - else showHtmlFragment - -- | Modified version of Text.XHtml's stringToHtml. -- Use unicode characters wherever possible. stringToHtml :: String -> Html stringToHtml = primHtml . escapeStringForXML +-- | Hard linebreak. +nl :: WriterOptions -> Html +nl opts = if writerWrapText opts + then primHtml "\n" + else noHtml + -- | Convert Pandoc document to Html string. writeHtmlString :: WriterOptions -> Pandoc -> String writeHtmlString opts d = @@ -74,7 +76,7 @@ defaultWriterState in if writerStandalone opts then inTemplate opts tit auths date toc body' newvars - else renderFragment opts body' + else dropWhile (=='\n') $ showHtmlFragment body' -- | Convert Pandoc document to Html structure. writeHtml :: WriterOptions -> Pandoc -> Html @@ -104,10 +106,27 @@ toc <- if writerTableOfContents opts then tableOfContents opts sects else return Nothing - blocks' <- liftM toHtmlFromList $ mapM (elementToHtml opts) sects + let startSlide = RawBlock "html" "
          \n" + endSlide = RawBlock "html" "
          \n" + let cutUp (HorizontalRule : Header 1 ys : xs) = cutUp (Header 1 ys : xs) + cutUp (HorizontalRule : xs) = [endSlide, startSlide] ++ cutUp xs + cutUp (Header 1 ys : xs) = [endSlide, startSlide] ++ + (Header 1 ys : cutUp xs) + cutUp (x:xs) = x : cutUp xs + cutUp [] = [] + let slides = case blocks of + (HorizontalRule : xs) -> [startSlide] ++ cutUp xs ++ [endSlide] + (Header 1 ys : xs) -> [startSlide, Header 1 ys] ++ + cutUp xs ++ [endSlide] + _ -> [startSlide] ++ cutUp blocks ++ + [endSlide] + blocks' <- liftM (toHtmlFromList . intersperse (nl opts)) $ + if writerSlideVariant opts `elem` [SlidySlides, S5Slides] + then mapM (blockToHtml opts) slides + else mapM (elementToHtml opts) sects st <- get let notes = reverse (stNotes st) - let thebody = blocks' +++ footnoteSection notes + let thebody = blocks' +++ footnoteSection opts notes let math = if stMath st then case writerHTMLMathMethod opts of LaTeXMathML (Just url) -> @@ -116,6 +135,8 @@ MathML (Just url) -> script ! [src url, thetype "text/javascript"] $ noHtml + MathJax url -> + script ! [src url, thetype "text/javascript"] $ noHtml JsMath (Just url) -> script ! [src url, thetype "text/javascript"] $ noHtml @@ -125,8 +146,9 @@ primHtml s Nothing -> noHtml else noHtml - let newvars = [("highlighting","yes") | stHighlighting st] ++ - [("math", renderHtmlFragment math) | stMath st] + let newvars = [("highlighting-css", defaultHighlightingCss) | + stHighlighting st] ++ + [("math", showHtmlFragment math) | stMath st] return (tit, auths, date, toc, thebody, newvars) inTemplate :: TemplateTarget a @@ -145,12 +167,13 @@ date' = stripTags $ showHtmlFragment date variables = writerVariables opts ++ newvars context = variables ++ - [ ("body", renderHtmlFragment body') + [ ("body", dropWhile (=='\n') $ showHtmlFragment body') , ("pagetitle", topTitle') - , ("title", renderHtmlFragment tit) + , ("title", dropWhile (=='\n') $ showHtmlFragment tit) , ("date", date') ] ++ + [ ("html5","true") | writerHtml5 opts ] ++ (case toc of - Just t -> [ ("toc", renderHtmlFragment t)] + Just t -> [ ("toc", showHtmlFragment t)] Nothing -> []) ++ [ ("author", a) | a <- authors ] in renderTemplate context $ writerTemplate opts @@ -159,6 +182,14 @@ prefixedId :: WriterOptions -> String -> HtmlAttr prefixedId opts s = identifier $ writerIdentifierPrefix opts ++ s +-- | Replacement for Text.XHtml's unordList. +unordList :: WriterOptions -> ([Html] -> Html) +unordList opts items = ulist << toListItems opts items + +-- | Replacement for Text.XHtml's ordList. +ordList :: WriterOptions -> ([Html] -> Html) +ordList opts items = olist << toListItems opts items + -- | Construct table of contents from list of elements. tableOfContents :: WriterOptions -> [Element] -> State WriterState (Maybe Html) tableOfContents _ [] = return Nothing @@ -168,7 +199,14 @@ let tocList = catMaybes contents return $ if null tocList then Nothing - else Just $ thediv ! [prefixedId opts' "TOC"] $ unordList tocList + else Just $ + if writerHtml5 opts + then (tag "nav" ! [prefixedId opts' "TOC"] $ + nl opts +++ unordList opts tocList +++ nl opts) + +++ nl opts + else (thediv ! [prefixedId opts' "TOC"] $ + nl opts +++ unordList opts tocList +++ nl opts) + +++ nl opts -- | Convert section number to string showSecNum :: [Int] -> String @@ -187,7 +225,7 @@ subHeads <- mapM (elementToListItem opts) subsecs >>= return . catMaybes let subList = if null subHeads then noHtml - else unordList subHeads + else unordList opts subHeads return $ Just $ (anchor ! [href ("#" ++ writerIdentifierPrefix opts ++ id')] $ txt) +++ subList -- | Convert an Element to Html. @@ -197,18 +235,30 @@ innerContents <- mapM (elementToHtml opts) elements modify $ \st -> st{stSecNum = num} -- update section number header' <- blockToHtml opts (Header level title') - return $ if writerS5 opts || (writerStrictMarkdown opts && not (writerTableOfContents opts)) - -- S5 gets confused by the extra divs around sections - then toHtmlFromList (header' : innerContents) - else thediv ! [prefixedId opts id'] << (header' : innerContents) + let slides = writerSlideVariant opts `elem` [SlidySlides, S5Slides] + let header'' = header' ! [prefixedId opts id' | + not (writerStrictMarkdown opts || + writerSectionDivs opts || slides)] + let stuff = header'' : innerContents + return $ if slides -- S5 gets confused by the extra divs around sections + then toHtmlFromList $ intersperse (nl opts) stuff + else if writerSectionDivs opts + then if writerHtml5 opts + then tag "section" ! [prefixedId opts id'] + << intersperse (nl opts) stuff + else thediv ! [prefixedId opts id'] << + intersperse (nl opts) stuff + else toHtmlFromList $ intersperse (nl opts) stuff -- | Convert list of Note blocks to a footnote
          . -- Assumes notes are sorted. -footnoteSection :: [Html] -> Html -footnoteSection notes = +footnoteSection :: WriterOptions -> [Html] -> Html +footnoteSection opts notes = if null notes then noHtml - else thediv ! [theclass "footnotes"] $ hr +++ (olist << notes) + else nl opts +++ (thediv ! [theclass "footnotes"] + $ nl opts +++ hr +++ nl opts +++ + (olist << (notes ++ [nl opts])) +++ nl opts) -- | Parse a mailto link; return Just (name, domain) or Nothing. @@ -262,38 +312,53 @@ obfuscateString :: String -> String obfuscateString = concatMap obfuscateChar . decodeCharacterReferences +attrsToHtml :: WriterOptions -> Attr -> [HtmlAttr] +attrsToHtml opts (id',classes',keyvals) = + [theclass (unwords classes') | not (null classes')] ++ + [prefixedId opts id' | not (null id')] ++ + map (\(x,y) -> strAttr x y) keyvals + -- | Convert Pandoc block element to HTML. blockToHtml :: WriterOptions -> Block -> State WriterState Html -blockToHtml _ Null = return $ noHtml +blockToHtml _ Null = return noHtml blockToHtml opts (Plain lst) = inlineListToHtml opts lst blockToHtml opts (Para [Image txt (s,tit)]) = do img <- inlineToHtml opts (Image txt (s,tit)) capt <- inlineListToHtml opts txt - return $ thediv ! [theclass "figure"] << - [img, paragraph ! [theclass "caption"] << capt] -blockToHtml opts (Para lst) = inlineListToHtml opts lst >>= (return . paragraph) -blockToHtml _ (RawHtml str) = return $ primHtml str -blockToHtml _ (HorizontalRule) = return $ hr + return $ if writerHtml5 opts + then tag "figure" << + [nl opts, img, tag "figcaption" << capt, nl opts] + else thediv ! [theclass "figure"] << + [nl opts, img, paragraph ! [theclass "caption"] << capt, + nl opts] +blockToHtml opts (Para lst) = do + contents <- inlineListToHtml opts lst + return $ paragraph contents +blockToHtml _ (RawBlock "html" str) = return $ primHtml str +blockToHtml _ (RawBlock _ _) = return noHtml +blockToHtml _ (HorizontalRule) = return hr blockToHtml opts (CodeBlock (id',classes,keyvals) rawCode) = do let classes' = if writerLiterateHaskell opts then classes else filter (/= "literate") classes - case highlightHtml (id',classes',keyvals) rawCode of + case highlightHtml False (id',classes',keyvals) rawCode of Left _ -> -- change leading newlines into
          tags, because some -- browsers ignore leading newlines in pre blocks let (leadingBreaks, rawCode') = span (=='\n') rawCode - attrs = [theclass (unwords classes') | not (null classes')] ++ - [prefixedId opts id' | not (null id')] ++ - map (\(x,y) -> strAttr x y) keyvals + attrs = attrsToHtml opts (id', classes', keyvals) + addBird = if "literate" `elem` classes' + then unlines . map ("> " ++) . lines + else unlines . lines in return $ pre ! attrs $ thecode << (replicate (length leadingBreaks) br +++ - [stringToHtml $ rawCode' ++ "\n"]) - Right h -> modify (\st -> st{ stHighlighting = True }) >> return h + [stringToHtml $ addBird rawCode']) + Right h -> modify (\st -> st{ stHighlighting = True }) >> + return h blockToHtml opts (BlockQuote blocks) = -- in S5, treat list in blockquote specially -- if default is incremental, make it nonincremental; -- otherwise incremental - if writerS5 opts + if writerSlideVariant opts /= NoSlides then let inc = not (writerIncremental opts) in case blocks of [BulletList lst] -> blockToHtml (opts {writerIncremental = inc}) @@ -301,9 +366,12 @@ [OrderedList attribs lst] -> blockToHtml (opts {writerIncremental = inc}) (OrderedList attribs lst) - _ -> blockListToHtml opts blocks >>= - (return . blockquote) - else blockListToHtml opts blocks >>= (return . blockquote) + _ -> do contents <- blockListToHtml opts blocks + return $ blockquote (nl opts +++ + contents +++ nl opts) + else do + contents <- blockListToHtml opts blocks + return $ blockquote (nl opts +++ contents +++ nl opts) blockToHtml opts (Header level lst) = do contents <- inlineListToHtml opts lst secnum <- liftM stSecNum get @@ -314,20 +382,20 @@ let contents'' = if writerTableOfContents opts then anchor ! [href $ "#" ++ writerIdentifierPrefix opts ++ "TOC"] $ contents' else contents' - return $ case level of + return $ (case level of 1 -> h1 contents'' 2 -> h2 contents'' 3 -> h3 contents'' 4 -> h4 contents'' 5 -> h5 contents'' 6 -> h6 contents'' - _ -> paragraph contents'' + _ -> paragraph contents'') blockToHtml opts (BulletList lst) = do contents <- mapM (blockListToHtml opts) lst let attribs = if writerIncremental opts then [theclass "incremental"] else [] - return $ unordList ! attribs $ contents + return $ (unordList opts contents) ! attribs blockToHtml opts (OrderedList (startnum, numstyle, _) lst) = do contents <- mapM (blockListToHtml opts) lst let numstyle' = camelCaseToHyphenated $ show numstyle @@ -338,41 +406,60 @@ then [start startnum] else []) ++ (if numstyle /= DefaultStyle - then [thestyle $ "list-style-type: " ++ numstyle' ++ ";"] + then if writerHtml5 opts + then [strAttr "type" $ + case numstyle of + Decimal -> "1" + LowerAlpha -> "a" + UpperAlpha -> "A" + LowerRoman -> "i" + UpperRoman -> "I" + _ -> "1"] + else [thestyle $ "list-style-type: " ++ + numstyle'] else []) - return $ ordList ! attribs $ contents + return $ (ordList opts contents) ! attribs blockToHtml opts (DefinitionList lst) = do contents <- mapM (\(term, defs) -> do term' <- liftM (dterm <<) $ inlineListToHtml opts term - defs' <- mapM (liftM (ddef <<) . blockListToHtml opts) defs - return $ term' : defs') lst + defs' <- mapM ((liftM (\x -> ddef << (x +++ nl opts))) . + blockListToHtml opts) defs + return $ nl opts : term' : nl opts : defs') lst let attribs = if writerIncremental opts then [theclass "incremental"] else [] - return $ dlist ! attribs << concat contents + return $ dlist ! attribs << (concat contents +++ nl opts) blockToHtml opts (Table capt aligns widths headers rows') = do - let alignStrings = map alignmentToString aligns captionDoc <- if null capt then return noHtml - else inlineListToHtml opts capt >>= return . caption + else do + cs <- inlineListToHtml opts capt + return $ caption cs +++ nl opts let percent w = show (truncate (100*w) :: Integer) ++ "%" + let widthAttrs w = if writerHtml5 opts + then [thestyle $ "width: " ++ percent w] + else [width $ percent w] let coltags = if all (== 0.0) widths then noHtml else concatHtml $ map - (\w -> col ! [width $ percent w] $ noHtml) widths + (\w -> (col ! (widthAttrs w)) noHtml +++ nl opts) + widths head' <- if all null headers then return noHtml - else liftM (thead <<) $ tableRowToHtml opts alignStrings 0 headers - body' <- liftM (tbody <<) $ - zipWithM (tableRowToHtml opts alignStrings) [1..] rows' - return $ table $ captionDoc +++ coltags +++ head' +++ body' + else do + contents <- tableRowToHtml opts aligns 0 headers + return $ thead << (nl opts +++ contents) +++ nl opts + body' <- liftM (\x -> tbody << (nl opts +++ x)) $ + zipWithM (tableRowToHtml opts aligns) [1..] rows' + return $ table $ nl opts +++ captionDoc +++ coltags +++ head' +++ + body' +++ nl opts tableRowToHtml :: WriterOptions - -> [String] + -> [Alignment] -> Int -> [[Block]] -> State WriterState Html -tableRowToHtml opts alignStrings rownum cols' = do +tableRowToHtml opts aligns rownum cols' = do let mkcell = if rownum == 0 then th else td let rowclass = case rownum of 0 -> "header" @@ -380,8 +467,9 @@ _ -> "even" cols'' <- sequence $ zipWith (\alignment item -> tableItemToHtml opts mkcell alignment item) - alignStrings cols' - return $ tr ! [theclass rowclass] $ toHtmlFromList cols'' + aligns cols' + return $ (tr ! [theclass rowclass] $ nl opts +++ toHtmlFromList cols'') + +++ nl opts alignmentToString :: Alignment -> [Char] alignmentToString alignment = case alignment of @@ -392,16 +480,26 @@ tableItemToHtml :: WriterOptions -> (Html -> Html) - -> [Char] + -> Alignment -> [Block] -> State WriterState Html tableItemToHtml opts tag' align' item = do contents <- blockListToHtml opts item - return $ tag' ! [align align'] $ contents + let alignAttrs = if writerHtml5 opts + then [thestyle $ "align: " ++ alignmentToString align'] + else [align $ alignmentToString align'] + return $ (tag' ! alignAttrs) contents +++ nl opts + +toListItems :: WriterOptions -> [Html] -> [Html] +toListItems opts items = map (toListItem opts) items ++ [nl opts] + +toListItem :: WriterOptions -> Html -> Html +toListItem opts item = nl opts +++ li item blockListToHtml :: WriterOptions -> [Block] -> State WriterState Html -blockListToHtml opts lst = - mapM (blockToHtml opts) lst >>= return . toHtmlFromList +blockListToHtml opts lst = + mapM (blockToHtml opts) lst >>= + return . toHtmlFromList . intersperse (nl opts) -- | Convert list of Pandoc inline elements to HTML. inlineListToHtml :: WriterOptions -> [Inline] -> State WriterState Html @@ -421,7 +519,11 @@ (Apostrophe) -> return $ stringToHtml "’" (Emph lst) -> inlineListToHtml opts lst >>= return . emphasize (Strong lst) -> inlineListToHtml opts lst >>= return . strong - (Code str) -> return $ thecode << str + (Code attr str) -> case highlightHtml True attr str of + Left _ -> return + $ thecode ! (attrsToHtml opts attr) + $ stringToHtml str + Right h -> return h (Strikeout lst) -> inlineListToHtml opts lst >>= return . (thespan ! [thestyle "text-decoration: line-through;"]) (SmallCaps lst) -> inlineListToHtml opts lst >>= @@ -436,26 +538,31 @@ stringToHtml "”") in do contents <- inlineListToHtml opts lst return $ leftQuote +++ contents +++ rightQuote - (Math t str) -> - modify (\st -> st {stMath = True}) >> + (Math t str) -> modify (\st -> st {stMath = True}) >> (case writerHTMLMathMethod opts of LaTeXMathML _ -> -- putting LaTeXMathML in container with class "LaTeX" prevents -- non-math elements on the page from being treated as math by -- the javascript return $ thespan ! [theclass "LaTeX"] $ - if t == InlineMath - then primHtml ("$" ++ str ++ "$") - else primHtml ("$$" ++ str ++ "$$") - JsMath _ -> - return $ if t == InlineMath - then thespan ! [theclass "math"] $ primHtml str - else thediv ! [theclass "math"] $ primHtml str - MimeTeX url -> - return $ image ! [src (url ++ "?" ++ str), - alt str, title str] + case t of + InlineMath -> primHtml ("$" ++ str ++ "$") + DisplayMath -> primHtml ("$$" ++ str ++ "$$") + JsMath _ -> do + let m = primHtml str + return $ case t of + InlineMath -> thespan ! [theclass "math"] $ m + DisplayMath -> thediv ! [theclass "math"] $ m + WebTeX url -> do + let m = image ! [src (url ++ urlEncode str), + alt str, title str] + return $ case t of + InlineMath -> m + DisplayMath -> br +++ m +++ br GladTeX -> - return $ primHtml $ "" ++ str ++ "" + return $ case t of + InlineMath -> primHtml $ "" ++ str ++ "" + DisplayMath -> primHtml $ "" ++ str ++ "" MathML _ -> do let dt = if t == InlineMath then DisplayInline @@ -466,18 +573,25 @@ Right r -> return $ primHtml $ ppcElement conf r Left _ -> inlineListToHtml opts - (readTeXMath str) >>= - return . (thespan ! - [theclass "math"]) - PlainMath -> - inlineListToHtml opts (readTeXMath str) >>= - return . (thespan ! [theclass "math"]) ) - (TeX str) -> case writerHTMLMathMethod opts of - LaTeXMathML _ -> do modify (\st -> st {stMath = True}) - return $ primHtml str - _ -> return noHtml - (HtmlInline str) -> return $ primHtml str - (Link [Code str] (s,_)) | "mailto:" `isPrefixOf` s -> + (readTeXMath str) >>= return . + (thespan ! [theclass "math"]) + MathJax _ -> return $ primHtml $ + case t of + InlineMath -> "\\(" ++ str ++ "\\)" + DisplayMath -> "\\[" ++ str ++ "\\]" + PlainMath -> do + x <- inlineListToHtml opts (readTeXMath str) + let m = thespan ! [theclass "math"] $ x + return $ case t of + InlineMath -> m + DisplayMath -> br +++ m +++ br ) + (RawInline "latex" str) -> case writerHTMLMathMethod opts of + LaTeXMathML _ -> do modify (\st -> st {stMath = True}) + return $ primHtml str + _ -> return noHtml + (RawInline "html" str) -> return $ primHtml str + (RawInline _ _) -> return noHtml + (Link [Code _ str] (s,_)) | "mailto:" `isPrefixOf` s -> return $ obfuscateLink opts str s (Link txt (s,_)) | "mailto:" `isPrefixOf` s -> do linkText <- inlineListToHtml opts txt @@ -488,8 +602,7 @@ if null tit then [] else [title tit]) $ linkText (Image txt (s,tit)) -> do - alternate <- inlineListToHtml opts txt - let alternate' = renderFragment opts alternate + let alternate' = stringify txt let attributes = [src s] ++ (if null tit then [] @@ -517,7 +630,7 @@ blockListToNote opts ref blocks = -- If last block is Para or Plain, include the backlink at the end of -- that block. Otherwise, insert a new Plain block with the backlink. - let backlink = [HtmlInline $ " "] blocks' = if null blocks @@ -532,5 +645,5 @@ _ -> otherBlocks ++ [lastBlock, Plain backlink] in do contents <- blockListToHtml opts blocks' - return $ li ! [prefixedId opts ("fn" ++ ref)] $ contents + return $ nl opts +++ (li ! [prefixedId opts ("fn" ++ ref)]) contents diff -Nru pandoc-1.5.1.1/src/Text/Pandoc/Writers/LaTeX.hs pandoc-1.8.0.3/src/Text/Pandoc/Writers/LaTeX.hs --- pandoc-1.5.1.1/src/Text/Pandoc/Writers/LaTeX.hs 2010-03-29 14:24:56.000000000 +0000 +++ pandoc-1.8.0.3/src/Text/Pandoc/Writers/LaTeX.hs 2011-02-05 18:48:07.000000000 +0000 @@ -1,3 +1,4 @@ +{-# LANGUAGE OverloadedStrings #-} {- Copyright (C) 2006-2010 John MacFarlane @@ -29,13 +30,15 @@ -} module Text.Pandoc.Writers.LaTeX ( writeLaTeX ) where import Text.Pandoc.Definition +import Text.Pandoc.Generic import Text.Pandoc.Shared import Text.Pandoc.Templates import Text.Printf ( printf ) -import Data.List ( (\\), isSuffixOf, isPrefixOf, intersperse ) -import Data.Char ( toLower ) +import Data.List ( (\\), isSuffixOf, isPrefixOf, intercalate, intersperse ) +import Data.Char ( toLower, isPunctuation ) import Control.Monad.State -import Text.PrettyPrint.HughesPJ hiding ( Str ) +import Text.Pandoc.Pretty +import System.FilePath (dropExtension) data WriterState = WriterState { stInNote :: Bool -- @True@ if we're in a note @@ -60,7 +63,7 @@ stVerbInNote = False, stEnumerate = False, stTable = False, stStrikeout = False, stSubscript = False, stUrl = False, stGraphics = False, - stLHS = False, stBook = False } + stLHS = False, stBook = writerChapters options } pandocToLaTeX :: WriterOptions -> Pandoc -> State WriterState String pandocToLaTeX options (Pandoc (Meta title authors date) blocks) = do @@ -70,13 +73,34 @@ "{report}" `isSuffixOf` x) when (any usesBookClass (lines template)) $ modify $ \s -> s{stBook = True} - titletext <- liftM render $ inlineListToLaTeX title - authorsText <- mapM (liftM render . inlineListToLaTeX) authors - dateText <- liftM render $ inlineListToLaTeX date - body <- blockListToLaTeX blocks - let main = render body + opts <- liftM stOptions get + let colwidth = if writerWrapText opts + then Just $ writerColumns opts + else Nothing + titletext <- liftM (render colwidth) $ inlineListToLaTeX title + authorsText <- mapM (liftM (render colwidth) . inlineListToLaTeX) authors + dateText <- liftM (render colwidth) $ inlineListToLaTeX date + let (blocks', lastHeader) = if writerCiteMethod options == Citeproc then + (blocks, []) + else case last blocks of + Header 1 il -> (init blocks, il) + _ -> (blocks, []) + body <- blockListToLaTeX blocks' + biblioTitle <- liftM (render colwidth) $ inlineListToLaTeX lastHeader + let main = render colwidth body st <- get - let context = writerVariables options ++ + let biblioFiles = intercalate "," $ map dropExtension $ writerBiblioFiles options + citecontext = case writerCiteMethod options of + Natbib -> [ ("biblio-files", biblioFiles) + , ("biblio-title", biblioTitle) + , ("natbib", "yes") + ] + Biblatex -> [ ("biblio-files", biblioFiles) + , ("biblio-title", biblioTitle) + , ("biblatex", "yes") + ] + _ -> [] + context = writerVariables options ++ [ ("toc", if writerTableOfContents options then "yes" else "") , ("body", main) , ("title", titletext) @@ -91,7 +115,10 @@ [ ("url", "yes") | stUrl st ] ++ [ ("numbersections", "yes") | writerNumberSections options ] ++ [ ("lhs", "yes") | stLHS st ] ++ - [ ("graphics", "yes") | stGraphics st ] + [ ("graphics", "yes") | stGraphics st ] ++ + [ ("book-class", "yes") | stBook st] ++ + [ ("listings", "yes") | writerListings options ] ++ + citecontext return $ if writerStandalone options then renderTemplate context template else main @@ -107,7 +134,13 @@ , ('|', "\\textbar{}") , ('<', "\\textless{}") , ('>', "\\textgreater{}") + , ('[', "{[}") -- to avoid interpretation as + , (']', "{]}") -- optional arguments , ('\160', "~") + , ('\x2018', "`") + , ('\x2019', "'") + , ('\x201C', "``") + , ('\x201D', "''") ] -- | Puts contents into LaTeX command. @@ -118,49 +151,73 @@ -- (because it's illegal to have verbatim inside some command arguments) deVerb :: [Inline] -> [Inline] deVerb [] = [] -deVerb ((Code str):rest) = - (TeX $ "\\texttt{" ++ stringToLaTeX str ++ "}"):(deVerb rest) +deVerb ((Code _ str):rest) = + (RawInline "latex" $ "\\texttt{" ++ stringToLaTeX str ++ "}"):(deVerb rest) deVerb (other:rest) = other:(deVerb rest) -- | Convert Pandoc block element to LaTeX. blockToLaTeX :: Block -- ^ Block to convert -> State WriterState Doc blockToLaTeX Null = return empty -blockToLaTeX (Plain lst) = do - st <- get - let opts = stOptions st - wrapTeXIfNeeded opts True inlineListToLaTeX lst +blockToLaTeX (Plain lst) = inlineListToLaTeX lst blockToLaTeX (Para [Image txt (src,tit)]) = do capt <- inlineListToLaTeX txt img <- inlineToLaTeX (Image txt (src,tit)) - return $ text "\\begin{figure}[htb]" $$ text "\\centering" $$ img $$ - (text "\\caption{" <> capt <> char '}') $$ text "\\end{figure}\n" + return $ "\\begin{figure}[htb]" $$ "\\centering" $$ img $$ + ("\\caption{" <> capt <> char '}') $$ "\\end{figure}" $$ blankline blockToLaTeX (Para lst) = do - st <- get - let opts = stOptions st - result <- wrapTeXIfNeeded opts True inlineListToLaTeX lst - return $ result <> char '\n' + result <- inlineListToLaTeX lst + return $ result <> blankline blockToLaTeX (BlockQuote lst) = do contents <- blockListToLaTeX lst - return $ text "\\begin{quote}" $$ contents $$ text "\\end{quote}" -blockToLaTeX (CodeBlock (_,classes,_) str) = do + return $ "\\begin{quote}" $$ contents $$ "\\end{quote}" +blockToLaTeX (CodeBlock (_,classes,keyvalAttr) str) = do st <- get env <- if writerLiterateHaskell (stOptions st) && "haskell" `elem` classes && "literate" `elem` classes then do modify $ \s -> s{ stLHS = True } return "code" - else if stInNote st - then do - modify $ \s -> s{ stVerbInNote = True } - return "Verbatim" - else return "verbatim" - return $ text ("\\begin{" ++ env ++ "}\n") <> text str <> - text ("\n\\end{" ++ env ++ "}") -blockToLaTeX (RawHtml _) = return empty + else if writerListings (stOptions st) + then return "lstlisting" + else if stInNote st + then do + modify $ \s -> s{ stVerbInNote = True } + return "Verbatim" + else return "verbatim" + 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"] + ] ++ + [ key ++ "=" ++ attr | (key,attr) <- keyvalAttr ] + else [] + printParams + | null params = empty + | otherwise = "[" <> hsep (intersperse "," (map text params)) <> + "]" + return $ "\\begin{" <> text env <> "}" <> printParams $$ flush (text str) $$ + "\\end{" <> text env <> "}" $$ cr -- final cr needed because of footnotes +blockToLaTeX (RawBlock "latex" x) = return $ text x <> blankline +blockToLaTeX (RawBlock _ _) = return empty blockToLaTeX (BulletList lst) = do items <- mapM listItemToLaTeX lst - return $ text "\\begin{itemize}" $$ vcat items $$ text "\\end{itemize}" + return $ "\\begin{itemize}" $$ vcat items $$ "\\end{itemize}" blockToLaTeX (OrderedList (start, numstyle, numdelim) lst) = do st <- get let oldlevel = stOLLevel st @@ -179,20 +236,19 @@ map toLower (toRomanNumeral oldlevel) ++ "}{" ++ show (start - 1) ++ "}" else empty - return $ text "\\begin{enumerate}" <> exemplar $$ resetcounter $$ - vcat items $$ text "\\end{enumerate}" + return $ "\\begin{enumerate}" <> exemplar $$ resetcounter $$ + vcat items $$ "\\end{enumerate}" blockToLaTeX (DefinitionList lst) = do items <- mapM defListItemToLaTeX lst - return $ text "\\begin{description}" $$ vcat items $$ - text "\\end{description}" -blockToLaTeX HorizontalRule = return $ text $ - "\\begin{center}\\rule{3in}{0.4pt}\\end{center}\n" + return $ "\\begin{description}" $$ vcat items $$ "\\end{description}" +blockToLaTeX HorizontalRule = return $ + "\\begin{center}\\rule{3in}{0.4pt}\\end{center}" $$ blankline blockToLaTeX (Header level lst) = do let lst' = deVerb lst txt <- inlineListToLaTeX lst' let noNote (Note _) = Str "" noNote x = x - let lstNoNotes = processWith noNote lst' + let lstNoNotes = bottomUp noNote lst' -- footnotes in sections don't work unless you specify an optional -- argument: \section[mysec]{mysec\footnote{blah}} optional <- if lstNoNotes == lst' @@ -202,30 +258,31 @@ return $ char '[' <> res <> char ']' let stuffing = optional <> char '{' <> txt <> char '}' book <- liftM stBook get - return $ case (book, level) of - (True, 1) -> text "\\chapter" <> stuffing <> char '\n' - (True, 2) -> text "\\section" <> stuffing <> char '\n' - (True, 3) -> text "\\subsection" <> stuffing <> char '\n' - (True, 4) -> text "\\subsubsection" <> stuffing <> char '\n' - (False, 1) -> text "\\section" <> stuffing <> char '\n' - (False, 2) -> text "\\subsection" <> stuffing <> char '\n' - (False, 3) -> text "\\subsubsection" <> stuffing <> char '\n' - _ -> txt <> char '\n' + let level' = if book then level - 1 else level + let headerWith x y = text x <> y $$ blankline + return $ case level' of + 0 -> headerWith "\\chapter" stuffing + 1 -> headerWith "\\section" stuffing + 2 -> headerWith "\\subsection" stuffing + 3 -> headerWith "\\subsubsection" stuffing + 4 -> headerWith "\\paragraph" stuffing + 5 -> headerWith "\\subparagraph" stuffing + _ -> txt $$ blankline blockToLaTeX (Table caption aligns widths heads rows) = do headers <- if all null heads then return empty - else liftM ($$ text "\\hline") $ tableRowToLaTeX heads + else liftM ($$ "\\hline") $ (tableRowToLaTeX widths) heads captionText <- inlineListToLaTeX caption - rows' <- mapM tableRowToLaTeX rows + rows' <- mapM (tableRowToLaTeX widths) rows let colDescriptors = concat $ zipWith toColDescriptor widths aligns let tableBody = text ("\\begin{tabular}{" ++ colDescriptors ++ "}") $$ - headers $$ vcat rows' $$ text "\\end{tabular}" - let centered txt = text "\\begin{center}" $$ txt $$ text "\\end{center}" + headers $$ vcat rows' $$ "\\end{tabular}" + let centered txt = "\\begin{center}" $$ txt $$ "\\end{center}" modify $ \s -> s{ stTable = True } return $ if isEmpty captionText - then centered tableBody <> char '\n' - else text "\\begin{table}[h]" $$ centered tableBody $$ - inCmd "caption" captionText $$ text "\\end{table}\n" + then centered tableBody $$ blankline + else "\\begin{table}[h]" $$ centered tableBody $$ + inCmd "caption" captionText $$ "\\end{table}" $$ blankline toColDescriptor :: Double -> Alignment -> String toColDescriptor 0 align = @@ -240,16 +297,19 @@ AlignRight -> "\\raggedleft" AlignCenter -> "\\centering" AlignDefault -> "\\raggedright") ++ - "\\hspace{0pt}}p{" ++ printf "%.2f" width ++ - "\\columnwidth}" + "\\hspace{0pt}}p{" ++ printf "%.2f" width ++ "\\columnwidth}" blockListToLaTeX :: [Block] -> State WriterState Doc blockListToLaTeX lst = mapM blockToLaTeX lst >>= return . vcat -tableRowToLaTeX :: [[Block]] -> State WriterState Doc -tableRowToLaTeX cols = mapM blockListToLaTeX cols >>= - return . ($$ text "\\\\") . foldl (\row item -> row $$ - (if isEmpty row then text "" else text " & ") <> item) empty +tableRowToLaTeX :: [Double] -> [[Block]] -> State WriterState Doc +tableRowToLaTeX widths cols = do + renderedCells <- mapM blockListToLaTeX cols + let toCell 0 c = c + toCell w c = "\\parbox{" <> text (printf "%.2f" w) <> + "\\columnwidth}{" <> c <> cr <> "}" + let cells = zipWith toCell widths renderedCells + return $ (hcat $ intersperse (" & ") cells) <> "\\\\" listItemToLaTeX :: [Block] -> State WriterState Doc listItemToLaTeX lst = blockListToLaTeX lst >>= return . (text "\\item" $$) . @@ -258,8 +318,8 @@ defListItemToLaTeX :: ([Inline], [[Block]]) -> State WriterState Doc defListItemToLaTeX (term, defs) = do term' <- inlineListToLaTeX $ deVerb term - def' <- liftM (vcat . intersperse (text "")) $ mapM blockListToLaTeX defs - return $ text "\\item[" <> term' <> text "]" $$ def' + def' <- liftM vsep $ mapM blockListToLaTeX defs + return $ "\\item" <> brackets term' $$ def' -- | Convert list of inline elements to LaTeX. inlineListToLaTeX :: [Inline] -- ^ Inlines to convert @@ -292,60 +352,161 @@ return $ inCmd "textsubscr" contents inlineToLaTeX (SmallCaps lst) = inlineListToLaTeX (deVerb lst) >>= return . inCmd "textsc" -inlineToLaTeX (Cite _ lst) = - inlineListToLaTeX lst -inlineToLaTeX (Code str) = do +inlineToLaTeX (Cite cits lst) = do + st <- get + let opts = stOptions st + case writerCiteMethod opts of + Natbib -> citationsToNatbib cits + Biblatex -> citationsToBiblatex cits + _ -> inlineListToLaTeX lst + +inlineToLaTeX (Code _ str) = do st <- get when (stInNote st) $ modify $ \s -> s{ stVerbInNote = True } let chr = ((enumFromTo '!' '~') \\ str) !! 0 - return $ text $ "\\verb" ++ [chr] ++ str ++ [chr] + if writerListings (stOptions st) + then return $ text $ "\\lstinline" ++ [chr] ++ str ++ [chr] + else return $ text $ "\\verb" ++ [chr] ++ str ++ [chr] inlineToLaTeX (Quoted SingleQuote lst) = do contents <- inlineListToLaTeX lst let s1 = if (not (null lst)) && (isQuoted (head lst)) - then text "\\," - else empty + then "\\," + else empty let s2 = if (not (null lst)) && (isQuoted (last lst)) - then text "\\," + then "\\," else empty return $ char '`' <> s1 <> contents <> s2 <> char '\'' inlineToLaTeX (Quoted DoubleQuote lst) = do contents <- inlineListToLaTeX lst let s1 = if (not (null lst)) && (isQuoted (head lst)) - then text "\\," - else empty + then "\\," + else empty let s2 = if (not (null lst)) && (isQuoted (last lst)) - then text "\\," + then "\\," else empty - return $ text "``" <> s1 <> contents <> s2 <> text "''" + return $ "``" <> s1 <> contents <> s2 <> "''" inlineToLaTeX Apostrophe = return $ char '\'' -inlineToLaTeX EmDash = return $ text "---" -inlineToLaTeX EnDash = return $ text "--" -inlineToLaTeX Ellipses = return $ text "\\ldots{}" +inlineToLaTeX EmDash = return "---" +inlineToLaTeX EnDash = return "--" +inlineToLaTeX Ellipses = return "\\ldots{}" inlineToLaTeX (Str str) = return $ text $ stringToLaTeX str inlineToLaTeX (Math InlineMath str) = return $ char '$' <> text str <> char '$' -inlineToLaTeX (Math DisplayMath str) = return $ text "\\[" <> text str <> text "\\]" -inlineToLaTeX (TeX str) = return $ text str -inlineToLaTeX (HtmlInline _) = return empty -inlineToLaTeX (LineBreak) = return $ text "\\\\" -inlineToLaTeX Space = return $ char ' ' +inlineToLaTeX (Math DisplayMath str) = return $ "\\[" <> text str <> "\\]" +inlineToLaTeX (RawInline "latex" str) = return $ text str +inlineToLaTeX (RawInline "tex" str) = return $ text str +inlineToLaTeX (RawInline _ _) = return empty +inlineToLaTeX (LineBreak) = return "\\\\" +inlineToLaTeX Space = return space inlineToLaTeX (Link txt (src, _)) = case txt of - [Code x] | x == src -> -- autolink + [Code _ x] | x == src -> -- autolink do modify $ \s -> s{ stUrl = True } return $ text $ "\\url{" ++ x ++ "}" _ -> do contents <- inlineListToLaTeX $ deVerb txt - return $ text ("\\href{" ++ src ++ "}{") <> contents <> - char '}' + return $ text ("\\href{" ++ stringToLaTeX src ++ "}{") <> + contents <> char '}' inlineToLaTeX (Image _ (source, _)) = do modify $ \s -> s{ stGraphics = True } - return $ text $ "\\includegraphics{" ++ source ++ "}" + return $ "\\includegraphics" <> braces (text source) inlineToLaTeX (Note contents) = do - st <- get - put (st {stInNote = True}) + modify (\s -> s{stInNote = True}) contents' <- blockListToLaTeX contents modify (\s -> s {stInNote = False}) - let rawnote = stripTrailingNewlines $ render contents' -- note: a \n before } is needed when note ends with a Verbatim environment - let optNewline = "\\end{Verbatim}" `isSuffixOf` rawnote - return $ text "\\footnote{" <> - text rawnote <> (if optNewline then char '\n' else empty) <> char '}' + return $ "\\footnote" <> braces (nest 2 contents') + + +citationsToNatbib :: [Citation] -> State WriterState Doc +citationsToNatbib (one:[]) + = citeCommand c p s k + where + Citation { citationId = k + , citationPrefix = p + , citationSuffix = s + , citationMode = m + } + = one + c = case m of + AuthorInText -> "citet" + SuppressAuthor -> "citeyearpar" + NormalCitation -> "citep" + +citationsToNatbib cits + | noPrefix (tail cits) && noSuffix (init cits) && ismode NormalCitation cits + = citeCommand "citep" p s ks + where + noPrefix = and . map (null . citationPrefix) + noSuffix = and . map (null . citationSuffix) + ismode m = and . map (((==) m) . citationMode) + p = citationPrefix $ head $ cits + s = citationSuffix $ last $ cits + ks = intercalate ", " $ map citationId cits + +citationsToNatbib (c:cs) | citationMode c == AuthorInText = do + author <- citeCommand "citeauthor" [] [] (citationId c) + cits <- citationsToNatbib (c { citationMode = SuppressAuthor } : cs) + return $ author <+> cits + +citationsToNatbib cits = do + cits' <- mapM convertOne cits + return $ text "\\citetext{" <> foldl combineTwo empty cits' <> text "}" + where + combineTwo a b | isEmpty a = b + | otherwise = a <> text "; " <> b + convertOne Citation { citationId = k + , citationPrefix = p + , citationSuffix = s + , citationMode = m + } + = case m of + AuthorInText -> citeCommand "citealt" p s k + SuppressAuthor -> citeCommand "citeyear" p s k + NormalCitation -> citeCommand "citealp" p s k + +citeCommand :: String -> [Inline] -> [Inline] -> String -> State WriterState Doc +citeCommand c p s k = do + args <- citeArguments p s k + return $ text ("\\" ++ c) <> args + +citeArguments :: [Inline] -> [Inline] -> String -> State WriterState Doc +citeArguments p s k = do + let s' = case s of + (Str (x:[]) : r) | isPunctuation x -> dropWhile (== Space) r + (Str (x:xs) : r) | isPunctuation x -> Str xs : r + _ -> s + pdoc <- inlineListToLaTeX p + sdoc <- inlineListToLaTeX s' + let optargs = case (isEmpty pdoc, isEmpty sdoc) of + (True, True ) -> empty + (True, False) -> brackets sdoc + (_ , _ ) -> brackets pdoc <> brackets sdoc + return $ optargs <> braces (text k) + +citationsToBiblatex :: [Citation] -> State WriterState Doc +citationsToBiblatex (one:[]) + = citeCommand cmd p s k + where + Citation { citationId = k + , citationPrefix = p + , citationSuffix = s + , citationMode = m + } = one + cmd = case m of + SuppressAuthor -> "autocite*" + AuthorInText -> "textcite" + NormalCitation -> "autocite" + +citationsToBiblatex (c:cs) = do + args <- mapM convertOne (c:cs) + return $ text cmd <> foldl (<>) empty args + where + cmd = case citationMode c of + AuthorInText -> "\\textcites" + _ -> "\\autocites" + convertOne Citation { citationId = k + , citationPrefix = p + , citationSuffix = s + } + = citeArguments p s k + +citationsToBiblatex _ = return empty diff -Nru pandoc-1.5.1.1/src/Text/Pandoc/Writers/Man.hs pandoc-1.8.0.3/src/Text/Pandoc/Writers/Man.hs --- pandoc-1.5.1.1/src/Text/Pandoc/Writers/Man.hs 2010-03-29 14:24:56.000000000 +0000 +++ pandoc-1.8.0.3/src/Text/Pandoc/Writers/Man.hs 2011-02-05 18:48:07.000000000 +0000 @@ -32,9 +32,10 @@ import Text.Pandoc.Definition import Text.Pandoc.Templates import Text.Pandoc.Shared +import Text.Pandoc.Readers.TeXMath import Text.Printf ( printf ) import Data.List ( isPrefixOf, intersperse, intercalate ) -import Text.PrettyPrint.HughesPJ hiding ( Str ) +import Text.Pandoc.Pretty import Control.Monad.State type Notes = [[Block]] @@ -51,27 +52,31 @@ titleText <- inlineListToMan opts title authors' <- mapM (inlineListToMan opts) authors date' <- inlineListToMan opts date - let (cmdName, rest) = break (== ' ') $ render titleText + 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'] -> (text (reverse xs), char d) - xs -> (text (reverse xs), doubleQuotes empty) + xs -> (text (reverse xs), doubleQuotes empty) let description = hsep $ map (doubleQuotes . text . removeLeadingTrailingSpace) $ - splitBy '|' rest + splitBy (== '|') rest body <- blockListToMan opts blocks notes <- liftM stNotes get notes' <- notesToMan opts (reverse notes) - let main = render $ body $$ notes' + let main = render' $ body $$ notes' $$ text "" hasTables <- liftM stHasTables get let context = writerVariables opts ++ [ ("body", main) - , ("title", render title') - , ("section", render section) - , ("date", render date') - , ("description", render description) ] ++ + , ("title", render' title') + , ("section", render' section) + , ("date", render' date') + , ("description", render' description) ] ++ [ ("has-tables", "yes") | hasTables ] ++ - [ ("author", render a) | a <- authors' ] + [ ("author", render' a) | a <- authors' ] if writerStandalone opts then return $ renderTemplate context $ writerTemplate opts else return main @@ -88,7 +93,7 @@ noteToMan :: WriterOptions -> Int -> [Block] -> State WriterState Doc noteToMan opts num note = do contents <- blockListToMan opts note - let marker = text "\n.SS [" <> text (show num) <> char ']' + let marker = cr <> text ".SS " <> brackets (text (show num)) return $ marker $$ contents -- | Association list of characters to escape. @@ -135,14 +140,14 @@ -> State WriterState Doc blockToMan _ Null = return empty blockToMan opts (Plain inlines) = - liftM vcat $ mapM (wrapIfNeeded opts (inlineListToMan opts)) $ - splitSentences inlines + liftM vcat $ mapM (inlineListToMan opts) $ splitSentences inlines blockToMan opts (Para inlines) = do - contents <- liftM vcat $ mapM (wrapIfNeeded opts (inlineListToMan opts)) $ + contents <- liftM vcat $ mapM (inlineListToMan opts) $ splitSentences inlines return $ text ".PP" $$ contents -blockToMan _ (RawHtml _) = return empty -blockToMan _ HorizontalRule = return $ text $ ".PP\n * * * * *" +blockToMan _ (RawBlock "man" str) = return $ text str +blockToMan _ (RawBlock _ _) = return empty +blockToMan _ HorizontalRule = return $ text ".PP" $$ text " * * * * *" blockToMan opts (Header level inlines) = do contents <- inlineListToMan opts inlines let heading = case level of @@ -150,8 +155,12 @@ _ -> ".SS " return $ text heading <> contents blockToMan _ (CodeBlock _ str) = return $ - text ".PP" $$ text "\\f[CR]" $$ - text ((unlines . map (" " ++) . lines) (escapeCode str)) <> text "\\f[]" + text ".IP" $$ + text ".nf" $$ + text "\\f[C]" $$ + text (escapeCode str) $$ + text "\\f[]" $$ + text ".fi" blockToMan opts (BlockQuote blocks) = do contents <- blockListToMan opts blocks return $ text ".RS" $$ contents $$ text ".RE" @@ -251,7 +260,7 @@ mapM (\item -> blockToMan opts item) rest first' <- blockToMan opts first return $ first' $$ text ".RS" $$ rest' $$ text ".RE" - return $ text ".TP\n.B " <> labelText $+$ contents + return $ text ".TP" $$ text ".B " <> labelText $$ contents -- | Convert list of Pandoc block elements to man. blockListToMan :: WriterOptions -- ^ Options @@ -298,23 +307,25 @@ inlineToMan _ EnDash = return $ text "\\[en]" inlineToMan _ Apostrophe = return $ char '\'' inlineToMan _ Ellipses = return $ text "\\&..." -inlineToMan _ (Code str) = - return $ text $ "\\f[B]" ++ escapeCode str ++ "\\f[]" +inlineToMan _ (Code _ str) = + return $ text $ "\\f[C]" ++ escapeCode str ++ "\\f[]" inlineToMan _ (Str str) = return $ text $ escapeString str -inlineToMan opts (Math InlineMath str) = inlineToMan opts (Code str) +inlineToMan opts (Math InlineMath str) = inlineListToMan opts $ readTeXMath str inlineToMan opts (Math DisplayMath str) = do - contents <- inlineToMan opts (Code str) - return $ text ".RS" $$ contents $$ text ".RE" -inlineToMan _ (TeX _) = return empty -inlineToMan _ (HtmlInline _) = return empty -inlineToMan _ (LineBreak) = return $ text "\n.PD 0\n.P\n.PD\n" -inlineToMan _ Space = return $ char ' ' + contents <- inlineListToMan opts $ readTeXMath str + return $ cr <> text ".RS" $$ contents $$ text ".RE" +inlineToMan _ (RawInline "man" str) = return $ text str +inlineToMan _ (RawInline _ _) = return empty +inlineToMan _ (LineBreak) = return $ + cr <> text ".PD 0" $$ text ".P" $$ text ".PD" <> cr +inlineToMan _ Space = return space inlineToMan opts (Link txt (src, _)) = do linktext <- inlineListToMan opts txt let srcSuffix = if isPrefixOf "mailto:" src then drop 7 src else src - return $ if txt == [Code srcSuffix] - then char '<' <> text srcSuffix <> char '>' - else linktext <> text " (" <> text src <> char ')' + return $ case txt of + [Code _ s] + | 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 ""]) || (alternate == [Str source]) -- to prevent autolinks diff -Nru pandoc-1.5.1.1/src/Text/Pandoc/Writers/Markdown.hs pandoc-1.8.0.3/src/Text/Pandoc/Writers/Markdown.hs --- pandoc-1.5.1.1/src/Text/Pandoc/Writers/Markdown.hs 2010-03-29 14:24:56.000000000 +0000 +++ pandoc-1.8.0.3/src/Text/Pandoc/Writers/Markdown.hs 2011-02-05 18:48:07.000000000 +0000 @@ -1,3 +1,4 @@ +{-# LANGUAGE OverloadedStrings #-} {- Copyright (C) 2006-2010 John MacFarlane @@ -31,16 +32,17 @@ -} module Text.Pandoc.Writers.Markdown (writeMarkdown, writePlain) where import Text.Pandoc.Definition +import Text.Pandoc.Generic import Text.Pandoc.Templates (renderTemplate) -import Text.Pandoc.Shared -import Text.Pandoc.Blocks -import Text.ParserCombinators.Parsec ( parse, GenParser ) +import Text.Pandoc.Shared +import Text.Pandoc.Parsing hiding (blankline) +import Text.ParserCombinators.Parsec ( runParser, GenParser ) import Data.List ( group, isPrefixOf, find, intersperse, transpose ) -import Text.PrettyPrint.HughesPJ hiding ( Str ) +import Text.Pandoc.Pretty import Control.Monad.State type Notes = [[Block]] -type Refs = KeyTable +type Refs = [([Inline], Target)] data WriterState = WriterState { stNotes :: Notes , stRefs :: Refs , stPlain :: Bool } @@ -56,28 +58,28 @@ -- pictures, or inline formatting). writePlain :: WriterOptions -> Pandoc -> String writePlain opts document = - evalState (pandocToMarkdown opts document') WriterState{ stNotes = [] - , stRefs = [] - , stPlain = True } + evalState (pandocToMarkdown opts{writerStrictMarkdown = True} + document') WriterState{ stNotes = [] + , stRefs = [] + , stPlain = True } where document' = plainify document plainify :: Pandoc -> Pandoc -plainify = processWith go - where go :: [Inline] -> [Inline] - go (Emph xs : ys) = go xs ++ go ys - go (Strong xs : ys) = go xs ++ go ys - go (Strikeout xs : ys) = go xs ++ go ys - go (Superscript xs : ys) = go xs ++ go ys - go (Subscript xs : ys) = go xs ++ go ys - go (SmallCaps xs : ys) = go xs ++ go ys - go (Code s : ys) = Str s : go ys - go (Math _ s : ys) = Str s : go ys - go (TeX _ : ys) = Str "" : go ys - go (HtmlInline _ : ys) = Str "" : go ys - go (Link xs _ : ys) = go xs ++ go ys - go (Image _ _ : ys) = go ys - go (x : ys) = x : go ys - go [] = [] +plainify = bottomUp go + where go :: Inline -> Inline + go (Emph xs) = SmallCaps xs + go (Strong xs) = SmallCaps xs + go (Strikeout xs) = SmallCaps xs + go (Superscript xs) = SmallCaps xs + go (Subscript xs) = SmallCaps xs + go (SmallCaps xs) = SmallCaps xs + go (Code _ s) = Str s + go (Math _ s) = Str s + go (RawInline _ _) = Str "" + go (Link xs _) = SmallCaps xs + go (Image xs _) = SmallCaps $ [Str "["] ++ xs ++ [Str "]"] + go (Cite _ cits) = SmallCaps cits + go x = x -- | Return markdown representation of document. pandocToMarkdown :: WriterOptions -> Pandoc -> State WriterState String @@ -94,46 +96,58 @@ st <- get notes' <- notesToMarkdown opts (reverse $ stNotes st) st' <- get -- note that the notes may contain refs - refs' <- keyTableToMarkdown opts (reverse $ stRefs st') - let main = render $ body $+$ text "" $+$ notes' $+$ text "" $+$ refs' + refs' <- refsToMarkdown opts (reverse $ stRefs st') + let colwidth = if writerWrapText opts + then Just $ writerColumns opts + else Nothing + let main = render colwidth $ body <> + (if isEmpty notes' then empty else blankline <> notes') <> + (if isEmpty refs' then empty else blankline <> refs') let context = writerVariables opts ++ - [ ("toc", render toc) + [ ("toc", render colwidth toc) , ("body", main) - , ("title", render title') - , ("date", render date') + , ("title", render colwidth title') + , ("date", render colwidth date') ] ++ [ ("titleblock", "yes") | titleblock ] ++ - [ ("author", render a) | a <- authors' ] + [ ("author", render colwidth a) | a <- authors' ] if writerStandalone opts then return $ renderTemplate context $ writerTemplate opts else return main -- | Return markdown representation of reference key table. -keyTableToMarkdown :: WriterOptions -> KeyTable -> State WriterState Doc -keyTableToMarkdown opts refs = mapM (keyToMarkdown opts) refs >>= return . vcat - +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)) -> State WriterState Doc keyToMarkdown opts (label, (src, tit)) = do label' <- inlineListToMarkdown opts label - let tit' = if null tit then empty else text $ " \"" ++ tit ++ "\"" - return $ text " " <> char '[' <> label' <> char ']' <> text ": " <> - text src <> tit' + let tit' = if null tit + then empty + else space <> "\"" <> text tit <> "\"" + return $ nest 2 $ hang 2 + ("[" <> label' <> "]:" <> space) (text src <> tit') -- | Return markdown representation of notes. notesToMarkdown :: WriterOptions -> [[Block]] -> State WriterState Doc notesToMarkdown opts notes = - mapM (\(num, note) -> noteToMarkdown opts num note) (zip [1..] notes) >>= - return . vcat + mapM (\(num, note) -> noteToMarkdown opts num note) (zip [1..] notes) >>= + return . vsep -- | Return markdown representation of a note. noteToMarkdown :: WriterOptions -> Int -> [Block] -> State WriterState Doc noteToMarkdown opts num blocks = do contents <- blockListToMarkdown opts blocks - let marker = text "[^" <> text (show num) <> text "]:" - return $ hang' marker (writerTabStop opts) contents + let num' = text $ show num + let marker = 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 -- | Escape special characters for Markdown. escapeString :: String -> String @@ -157,8 +171,24 @@ then [] else [BulletList $ map elementToListItem subsecs] +attrsToMarkdown :: Attr -> Doc +attrsToMarkdown attribs = braces $ hsep [attribId, attribClasses, attribKeys] + where attribId = case attribs of + ([],_,_) -> empty + (i,_,_) -> "#" <> text i + attribClasses = case attribs of + (_,[],_) -> empty + (_,cs,_) -> hsep $ + map (text . ('.':)) + cs + attribKeys = case attribs of + (_,_,[]) -> empty + (_,_,ks) -> hsep $ + map (\(k,v) -> text k + <> "=\"" <> text v <> "\"") ks + -- | Ordered list start parser for use in Para below. -olMarker :: GenParser Char st Char +olMarker :: GenParser Char ParserState Char olMarker = do (start, style', delim) <- anyOrderedListMarker if delim == Period && (style' == UpperAlpha || (style' == UpperRoman && @@ -168,134 +198,139 @@ -- | True if string begins with an ordered list marker beginsWithOrderedListMarker :: String -> Bool -beginsWithOrderedListMarker str = - case parse olMarker "para start" str of - Left _ -> False +beginsWithOrderedListMarker str = + case runParser olMarker defaultParserState "para start" (take 10 str) of + Left _ -> False Right _ -> True -wrappedMarkdown :: WriterOptions -> [Inline] -> State WriterState Doc -wrappedMarkdown opts inlines = do - let chunks = splitBy LineBreak inlines - let chunks' = if null chunks - then [] - else (map (++ [Str " "]) $ init chunks) ++ [last chunks] - lns <- mapM (wrapIfNeeded opts (inlineListToMarkdown opts)) chunks' - return $ vcat lns - -- | Convert Pandoc block element to markdown. blockToMarkdown :: WriterOptions -- ^ Options -> Block -- ^ Block element -> State WriterState Doc blockToMarkdown _ Null = return empty -blockToMarkdown opts (Plain inlines) = - wrappedMarkdown opts inlines +blockToMarkdown opts (Plain inlines) = do + contents <- inlineListToMarkdown opts inlines + return $ contents <> cr blockToMarkdown opts (Para inlines) = do - contents <- wrappedMarkdown opts inlines + contents <- inlineListToMarkdown opts inlines -- escape if para starts with ordered list marker - let esc = if (not (writerStrictMarkdown opts)) && - beginsWithOrderedListMarker (render contents) - then char '\\' - else empty - return $ esc <> contents <> text "\n" -blockToMarkdown _ (RawHtml str) = do st <- get - if stPlain st - then return empty - else return $ text str -blockToMarkdown _ HorizontalRule = return $ text "\n* * * * *\n" + let esc = if (not (writerStrictMarkdown opts)) && + not (stPlain st) && + beginsWithOrderedListMarker (render Nothing contents) + then text "\\" + else empty + return $ esc <> contents <> blankline +blockToMarkdown _ (RawBlock f str) + | f == "html" || 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 contents <- inlineListToMarkdown opts inlines st <- get -- use setext style headers if in literate haskell mode. -- ghc interprets '#' characters in column 1 as line number specifiers. if writerLiterateHaskell opts || stPlain st - then let len = length $ render contents - in return $ contents <> text "\n" <> - case level of - 1 -> text $ replicate len '=' ++ "\n" - 2 -> text $ replicate len '-' ++ "\n" - _ -> empty - else return $ text ((replicate level '#') ++ " ") <> contents <> text "\n" -blockToMarkdown opts (CodeBlock (_,classes,_) str) | "haskell" `elem` classes && - "literate" `elem` classes && - writerLiterateHaskell opts = - return $ (vcat $ map (text "> " <>) $ map text (lines str)) <> text "\n" -blockToMarkdown opts (CodeBlock _ str) = return $ - (nest (writerTabStop opts) $ vcat $ map text (lines str)) <> text "\n" + then let len = offset contents + in return $ contents <> cr <> + (case level of + 1 -> text $ replicate len '=' + 2 -> text $ replicate len '-' + _ -> empty) <> blankline + else return $ + text ((replicate level '#') ++ " ") <> contents <> blankline +blockToMarkdown opts (CodeBlock (_,classes,_) str) + | "haskell" `elem` classes && "literate" `elem` classes && + writerLiterateHaskell 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 + flush (tildes <> space <> attrs <> cr <> text str <> + cr <> tildes) <> blankline + where tildes = text "~~~~" + attrs = attrsToMarkdown attribs 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 - then text . (" > " ++) + then " > " else if stPlain st - then text . (" " ++) - else text . ("> " ++) + then " " + else "> " contents <- blockListToMarkdown opts blocks - return $ (vcat $ map leader $ lines $ render contents) <> - text "\n" + return $ (prefixed leader contents) <> blankline blockToMarkdown opts (Table caption aligns widths headers rows) = do caption' <- inlineListToMarkdown opts caption let caption'' = if null caption then empty - else text "" $+$ (text "Table: " <> caption') + else blankline <> ": " <> caption' <> blankline headers' <- mapM (blockListToMarkdown opts) headers let alignHeader alignment = case alignment of - AlignLeft -> leftAlignBlock - AlignCenter -> centerAlignBlock - AlignRight -> rightAlignBlock - AlignDefault -> leftAlignBlock + AlignLeft -> lblock + AlignCenter -> cblock + AlignRight -> rblock + AlignDefault -> lblock rawRows <- mapM (mapM (blockListToMarkdown opts)) rows let isSimple = all (==0) widths - let numChars = maximum . map (length . render) + let numChars = maximum . map offset let widthsInChars = if isSimple then map ((+2) . numChars) $ transpose (headers' : rawRows) - else map (floor . (78 *)) widths - let makeRow = hsepBlocks . (zipWith alignHeader aligns) . - (zipWith docToBlock widthsInChars) + 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 maxRowHeight = maximum $ map heightOfBlock (head':rows') - let underline = hsep $ - map (\width -> text $ replicate width '-') widthsInChars + 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)) '-' + then text (replicate (sum widthsInChars + + length widthsInChars - 1) '-') else if all null headers then underline else empty let head'' = if all null headers then empty - else border $+$ blockToDoc head' - let spacer = if maxRowHeight > 1 - then text "" - else empty - let body = vcat $ intersperse spacer $ map blockToDoc rows' + else border <> cr <> head' + let body = if maxRowHeight > 1 + then vsep rows' + else vcat rows' let bottom = if all null headers then underline else border - return $ (nest 2 $ head'' $+$ underline $+$ body $+$ - bottom $+$ caption'') <> text "\n" + return $ nest 2 $ head'' $$ underline $$ body $$ + bottom $$ blankline $$ caption'' $$ blankline blockToMarkdown opts (BulletList items) = do contents <- mapM (bulletListItemToMarkdown opts) items - return $ (vcat contents) <> text "\n" + 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 + else m) markers contents <- mapM (\(item, num) -> orderedListItemToMarkdown opts item num) $ - zip markers' items - return $ (vcat contents) <> text "\n" + zip markers' items + return $ cat contents <> blankline blockToMarkdown opts (DefinitionList items) = do contents <- mapM (definitionListItemToMarkdown opts) items - return $ (vcat contents) <> text "\n" + return $ cat contents <> blankline -- | Convert bullet list item (list of blocks) to markdown. bulletListItemToMarkdown :: WriterOptions -> [Block] -> State WriterState Doc bulletListItemToMarkdown opts items = do contents <- blockListToMarkdown opts items - return $ hang' (text "- ") (writerTabStop opts) contents + let sps = replicate (writerTabStop opts - 2) ' ' + let start = text ('-' : ' ' : sps) + return $ hang (writerTabStop opts) start $ contents <> cr -- | Convert ordered list item (a list of blocks) to markdown. orderedListItemToMarkdown :: WriterOptions -- ^ options @@ -304,8 +339,11 @@ -> State WriterState Doc orderedListItemToMarkdown opts marker items = do contents <- blockListToMarkdown opts items - return $ hsep [nest (min (3 - length marker) 0) (text marker), - nest (writerTabStop opts) contents] + let sps = case length marker - writerTabStop opts of + n | n > 0 -> text $ replicate n ' ' + _ -> text " " + let start = text marker <> sps + return $ hang (writerTabStop opts) start $ contents <> cr -- | Convert definition list item (label, list of blocks) to markdown. definitionListItemToMarkdown :: WriterOptions @@ -315,17 +353,20 @@ labelText <- inlineListToMarkdown opts label let tabStop = writerTabStop opts st <- get - let leader = if stPlain st then empty else text " ~" - contents <- liftM vcat $ - mapM (liftM ((leader $$) . nest tabStop . vcat) . mapM (blockToMarkdown opts)) defs - return $ labelText $+$ contents + 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 $ labelText <> cr <> contents <> cr -- | Convert list of Pandoc block elements to markdown. blockListToMarkdown :: WriterOptions -- ^ Options -> [Block] -- ^ List of block elements -> State WriterState Doc blockListToMarkdown opts blocks = - mapM (blockToMarkdown opts) blocks >>= return . vcat + mapM (blockToMarkdown opts) blocks >>= return . cat -- | Get reference for target; if none exists, create unique one and return. -- Prefer label if possible; otherwise, generate a unique key. @@ -348,86 +389,132 @@ -- | Convert list of Pandoc inline elements to markdown. inlineListToMarkdown :: WriterOptions -> [Inline] -> State WriterState Doc inlineListToMarkdown opts lst = - mapM (inlineToMarkdown opts) lst >>= return . hcat + mapM (inlineToMarkdown opts) lst >>= return . cat + +escapeSpaces :: Inline -> Inline +escapeSpaces (Str s) = Str $ substitute " " "\\ " s +escapeSpaces Space = Str "\\ " +escapeSpaces x = x -- | Convert Pandoc inline element to markdown. inlineToMarkdown :: WriterOptions -> Inline -> State WriterState Doc inlineToMarkdown opts (Emph lst) = do contents <- inlineListToMarkdown opts lst - return $ char '*' <> contents <> char '*' + return $ "*" <> contents <> "*" inlineToMarkdown opts (Strong lst) = do contents <- inlineListToMarkdown opts lst - return $ text "**" <> contents <> text "**" + return $ "**" <> contents <> "**" inlineToMarkdown opts (Strikeout lst) = do contents <- inlineListToMarkdown opts lst - return $ text "~~" <> contents <> text "~~" + return $ "~~" <> contents <> "~~" inlineToMarkdown opts (Superscript lst) = do - contents <- inlineListToMarkdown opts lst - let contents' = text $ substitute " " "\\ " $ render contents - return $ char '^' <> contents' <> char '^' + let lst' = bottomUp escapeSpaces lst + contents <- inlineListToMarkdown opts lst' + return $ "^" <> contents <> "^" inlineToMarkdown opts (Subscript lst) = do - contents <- inlineListToMarkdown opts lst - let contents' = text $ substitute " " "\\ " $ render contents - return $ char '~' <> contents' <> char '~' + let lst' = bottomUp escapeSpaces lst + contents <- inlineListToMarkdown opts lst' + return $ "~" <> contents <> "~" inlineToMarkdown opts (SmallCaps lst) = inlineListToMarkdown opts lst inlineToMarkdown opts (Quoted SingleQuote lst) = do contents <- inlineListToMarkdown opts lst - return $ char '\'' <> contents <> char '\'' + return $ "‘" <> contents <> "’" inlineToMarkdown opts (Quoted DoubleQuote lst) = do contents <- inlineListToMarkdown opts lst - return $ char '"' <> contents <> char '"' -inlineToMarkdown _ EmDash = return $ text "--" -inlineToMarkdown _ EnDash = return $ char '-' -inlineToMarkdown _ Apostrophe = return $ char '\'' -inlineToMarkdown _ Ellipses = return $ text "..." -inlineToMarkdown _ (Code str) = + return $ "“" <> contents <> "”" +inlineToMarkdown _ EmDash = return "\8212" +inlineToMarkdown _ EnDash = return "\8211" +inlineToMarkdown _ Apostrophe = return "\8217" +inlineToMarkdown _ Ellipses = return "\8230" +inlineToMarkdown opts (Code attr str) = let tickGroups = filter (\s -> '`' `elem` s) $ group str longest = if null tickGroups then 0 else maximum $ map length tickGroups marker = replicate (longest + 1) '`' - spacer = if (longest == 0) then "" else " " in - return $ text (marker ++ spacer ++ str ++ spacer ++ marker) + spacer = if (longest == 0) then "" else " " + attrs = if writerStrictMarkdown opts || attr == nullAttr + then empty + else attrsToMarkdown attr + 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 $ char '$' <> text str <> char '$' -inlineToMarkdown _ (Math DisplayMath str) = return $ text "$$" <> text str <> text "$$" -inlineToMarkdown _ (TeX str) = return $ text str -inlineToMarkdown _ (HtmlInline str) = return $ text str -inlineToMarkdown _ (LineBreak) = return $ text " \n" -inlineToMarkdown _ Space = return $ char ' ' -inlineToMarkdown opts (Cite _ cits) = inlineListToMarkdown opts cits +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" = + return $ text str +inlineToMarkdown _ (RawInline _ _) = return empty +inlineToMarkdown opts (LineBreak) = return $ + if writerStrictMarkdown opts + then " " <> cr + else "\\" <> cr +inlineToMarkdown _ Space = return space +inlineToMarkdown opts (Cite (c:cs) lst) + | writerCiteMethod opts == Citeproc = inlineListToMarkdown opts lst + | citationMode c == AuthorInText = do + suffs <- inlineListToMarkdown opts $ citationSuffix c + rest <- mapM convertOne cs + let inbr = suffs <+> joincits rest + br = if isEmpty inbr then empty else char '[' <> inbr <> char ']' + return $ text ("@" ++ citationId c) <+> br + | otherwise = do + cits <- mapM convertOne (c:cs) + return $ text "[" <> joincits cits <> text "]" + where + joincits = hcat . intersperse (text "; ") . filter (not . isEmpty) + convertOne Citation { citationId = k + , citationPrefix = pinlines + , citationSuffix = sinlines + , citationMode = m } + = do + pdoc <- inlineListToMarkdown opts pinlines + sdoc <- inlineListToMarkdown opts sinlines + let k' = text (modekey m ++ "@" ++ k) + r = case sinlines of + Str (y:_):_ | y `elem` ",;]@" -> k' <> sdoc + _ -> k' <+> sdoc + return $ pdoc <+> r + modekey SuppressAuthor = "-" + modekey _ = "" +inlineToMarkdown _ (Cite _ _) = return $ text "" inlineToMarkdown opts (Link txt (src', tit)) = do linktext <- inlineListToMarkdown opts txt - let linktitle = if null tit then empty else text $ " \"" ++ tit ++ "\"" + let linktitle = if null tit + then empty + else text $ " \"" ++ tit ++ "\"" let src = unescapeURI src' let srcSuffix = if isPrefixOf "mailto:" src then drop 7 src else src let useRefLinks = writerReferenceLinks opts - let useAuto = null tit && txt == [Code srcSuffix] + let useAuto = case (tit,txt) of + ("", [Code _ s]) | s == srcSuffix -> True + _ -> False ref <- if useRefLinks then getReference txt (src, tit) else return [] reftext <- inlineListToMarkdown opts ref return $ if useAuto - then char '<' <> text srcSuffix <> char '>' + then "<" <> text srcSuffix <> ">" else if useRefLinks - then let first = char '[' <> linktext <> char ']' + then let first = "[" <> linktext <> "]" second = if txt == ref - then text "[]" - else char '[' <> reftext <> char ']' + then "[]" + else "[" <> reftext <> "]" in first <> second - else char '[' <> linktext <> char ']' <> - char '(' <> text src <> linktitle <> char ')' + else "[" <> linktext <> "](" <> + text src <> linktitle <> ")" inlineToMarkdown opts (Image alternate (source, tit)) = do let txt = if (null alternate) || (alternate == [Str ""]) || (alternate == [Str source]) -- to prevent autolinks then [Str "image"] else alternate - linkPart <- inlineToMarkdown opts (Link txt (unescapeURI source, tit)) - return $ char '!' <> linkPart + linkPart <- inlineToMarkdown opts (Link txt (source, tit)) + return $ "!" <> linkPart inlineToMarkdown _ (Note contents) = do modify (\st -> st{ stNotes = contents : stNotes st }) st <- get let ref = show $ (length $ stNotes st) - return $ text "[^" <> text ref <> char ']' + return $ "[^" <> text ref <> "]" diff -Nru pandoc-1.5.1.1/src/Text/Pandoc/Writers/MediaWiki.hs pandoc-1.8.0.3/src/Text/Pandoc/Writers/MediaWiki.hs --- pandoc-1.5.1.1/src/Text/Pandoc/Writers/MediaWiki.hs 2010-03-29 14:24:56.000000000 +0000 +++ pandoc-1.8.0.3/src/Text/Pandoc/Writers/MediaWiki.hs 2011-02-05 18:48:07.000000000 +0000 @@ -96,7 +96,9 @@ then "

          " ++ contents ++ "

          " else contents ++ if null listLevel then "\n" else "" -blockToMediaWiki _ (RawHtml str) = return str +blockToMediaWiki _ (RawBlock "mediawiki" str) = return str +blockToMediaWiki _ (RawBlock "html" str) = return str +blockToMediaWiki _ (RawBlock _ _) = return "" blockToMediaWiki _ HorizontalRule = return "\n-----\n" @@ -360,7 +362,7 @@ inlineToMediaWiki _ Ellipses = return "…" -inlineToMediaWiki _ (Code str) = +inlineToMediaWiki _ (Code _ str) = return $ "" ++ (escapeString str) ++ "" inlineToMediaWiki _ (Str str) = return $ escapeString str @@ -368,9 +370,9 @@ inlineToMediaWiki _ (Math _ str) = return $ "" ++ str ++ "" -- note: str should NOT be escaped -inlineToMediaWiki _ (TeX _) = return "" - -inlineToMediaWiki _ (HtmlInline str) = return str +inlineToMediaWiki _ (RawInline "mediawiki" str) = return str +inlineToMediaWiki _ (RawInline "html" str) = return str +inlineToMediaWiki _ (RawInline _ _) = return "" inlineToMediaWiki _ (LineBreak) = return "
          \n" @@ -378,12 +380,12 @@ inlineToMediaWiki opts (Link txt (src, _)) = do label <- inlineListToMediaWiki opts txt - if txt == [Code src] -- autolink - then return src - else if isURI src - then return $ "[" ++ src ++ " " ++ label ++ "]" - else return $ "[[" ++ src' ++ "|" ++ label ++ "]]" - where src' = case src of + case txt of + [Code _ s] | s == src -> return src + _ -> if isURI src + then return $ "[" ++ src ++ " " ++ label ++ "]" + else return $ "[[" ++ src' ++ "|" ++ label ++ "]]" + where src' = case src of '/':xs -> xs -- with leading / it's a _ -> src -- link to a help page inlineToMediaWiki opts (Image alt (source, tit)) = do diff -Nru pandoc-1.5.1.1/src/Text/Pandoc/Writers/Native.hs pandoc-1.8.0.3/src/Text/Pandoc/Writers/Native.hs --- pandoc-1.5.1.1/src/Text/Pandoc/Writers/Native.hs 1970-01-01 00:00:00.000000000 +0000 +++ pandoc-1.8.0.3/src/Text/Pandoc/Writers/Native.hs 2011-02-05 18:48:07.000000000 +0000 @@ -0,0 +1,78 @@ +{-# LANGUAGE OverloadedStrings #-} +{- +Copyright (C) 2006-2010 John MacFarlane + +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.Writers.Native + Copyright : Copyright (C) 2006-2010 John MacFarlane + License : GNU GPL, version 2 or above + + Maintainer : John MacFarlane + Stability : alpha + Portability : portable + +Conversion of a 'Pandoc' document to a string representation. + +Note: If @writerStandalone@ is @False@, only the document body +is represented; otherwise, the full 'Pandoc' document, including the +metadata. +-} +module Text.Pandoc.Writers.Native ( writeNative ) +where +import Text.Pandoc.Shared ( WriterOptions(..) ) +import Data.List ( intersperse ) +import Text.Pandoc.Definition +import Text.Pandoc.Pretty + +prettyList :: [Doc] -> Doc +prettyList ds = + "[" <> (cat $ intersperse (cr <> ",") $ map (nest 1) ds) <> "]" + +-- | Prettyprint Pandoc block element. +prettyBlock :: Block -> Doc +prettyBlock (BlockQuote blocks) = + "BlockQuote" $$ prettyList (map prettyBlock blocks) +prettyBlock (OrderedList attribs blockLists) = + "OrderedList" <> space <> text (show attribs) $$ + (prettyList $ map (prettyList . map prettyBlock) 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) = + "Table " <> text (show caption) <> " " <> text (show aligns) <> " " <> + text (show widths) $$ + prettyRow header $$ + prettyList (map prettyRow rows) + where prettyRow cols = prettyList (map (prettyList . map prettyBlock) cols) +prettyBlock block = text $ show block + +-- | Prettyprint Pandoc document. +writeNative :: WriterOptions -> Pandoc -> String +writeNative opts (Pandoc meta blocks) = + let colwidth = if writerWrapText opts + then Just $ writerColumns opts + else Nothing + withHead = if writerStandalone opts + then \bs -> text ("Pandoc " ++ "(" ++ show meta ++ ")") $$ + bs $$ cr + else id + in render colwidth $ withHead $ prettyList $ map prettyBlock blocks diff -Nru pandoc-1.5.1.1/src/Text/Pandoc/Writers/ODT.hs pandoc-1.8.0.3/src/Text/Pandoc/Writers/ODT.hs --- pandoc-1.5.1.1/src/Text/Pandoc/Writers/ODT.hs 1970-01-01 00:00:00.000000000 +0000 +++ pandoc-1.8.0.3/src/Text/Pandoc/Writers/ODT.hs 2011-02-05 18:48:07.000000000 +0000 @@ -0,0 +1,84 @@ +{- +Copyright (C) 2008-2010 John MacFarlane + +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.Writers.ODT + Copyright : Copyright (C) 2008-2010 John MacFarlane + License : GNU GPL, version 2 or above + + Maintainer : John MacFarlane + Stability : alpha + Portability : portable + +Conversion of 'Pandoc' documents to ODT. +-} +module Text.Pandoc.Writers.ODT ( writeODT ) where +import Data.IORef +import System.FilePath ( (), takeExtension ) +import qualified Data.ByteString.Lazy as B +import Data.ByteString.Lazy.UTF8 ( fromString ) +import Codec.Archive.Zip +import System.Time +import Paths_pandoc ( getDataFileName ) +import Text.Pandoc.Shared ( WriterOptions(..) ) +import Text.Pandoc.Definition +import Text.Pandoc.Generic +import Text.Pandoc.Writers.OpenDocument ( writeOpenDocument ) +import System.Directory +import Control.Monad (liftM) + +-- | Produce an ODT file from a Pandoc document. +writeODT :: Maybe FilePath -- ^ Path specified by --reference-odt + -> WriterOptions -- ^ Writer options + -> Pandoc -- ^ Document to convert + -> IO B.ByteString +writeODT mbRefOdt opts doc = do + let datadir = writerUserDataDir opts + refArchive <- liftM toArchive $ + case mbRefOdt 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 + -- handle pictures + picEntriesRef <- newIORef ([] :: [Entry]) + let sourceDir = writerSourceDirectory opts + doc' <- bottomUpM (transformPic sourceDir picEntriesRef) doc + let newContents = writeOpenDocument opts{writerWrapText = False} doc' + (TOD epochtime _) <- getClockTime + let contentEntry = toEntry "content.xml" epochtime $ fromString newContents + picEntries <- readIORef picEntriesRef + let archive = foldr addEntryToArchive refArchive (contentEntry : picEntries) + return $ fromArchive archive + +transformPic :: FilePath -> IORef [Entry] -> Inline -> IO Inline +transformPic sourceDir entriesRef (Image lab (src,tit)) = do + entries <- readIORef entriesRef + let newsrc = "Pictures/" ++ show (length entries) ++ takeExtension src + catch (readEntry [] (sourceDir src) >>= \entry -> + modifyIORef entriesRef (entry{ eRelativePath = newsrc } :) >> + return (Image lab (newsrc, tit))) + (\_ -> return (Emph lab)) +transformPic _ _ x = return x + diff -Nru pandoc-1.5.1.1/src/Text/Pandoc/Writers/OpenDocument.hs pandoc-1.8.0.3/src/Text/Pandoc/Writers/OpenDocument.hs --- pandoc-1.5.1.1/src/Text/Pandoc/Writers/OpenDocument.hs 2010-03-29 14:24:56.000000000 +0000 +++ pandoc-1.8.0.3/src/Text/Pandoc/Writers/OpenDocument.hs 2011-02-05 18:48:07.000000000 +0000 @@ -35,7 +35,7 @@ import Text.Pandoc.XML import Text.Pandoc.Templates (renderTemplate) import Text.Pandoc.Readers.TeXMath -import Text.PrettyPrint.HughesPJ hiding ( Str ) +import Text.Pandoc.Pretty import Text.Printf ( printf ) import Control.Applicative ( (<$>) ) import Control.Arrow ( (***), (>>>) ) @@ -112,7 +112,9 @@ setInDefinitionList b = modify $ \s -> s { stInDefinition = b } inParagraphTags :: Doc -> Doc -inParagraphTags = inTags False "text:p" [("text:style-name", "Text_20_body")] +inParagraphTags d | isEmpty d = empty +inParagraphTags d = + inTags False "text:p" [("text:style-name", "Text_20_body")] d inParagraphTagsWithStyle :: String -> Doc -> Doc inParagraphTagsWithStyle sty = inTags False "text:p" [("text:style-name", sty)] @@ -167,7 +169,11 @@ date'' <- inlinesToOpenDocument opts date doc'' <- blocksToOpenDocument opts blocks return (doc'', title'', authors'', date'') - body' = render doc + colwidth = if writerWrapText opts + then Just $ writerColumns opts + else Nothing + render' = render colwidth + body' = render' doc styles = stTableStyles s ++ stParaStyles s ++ stTextStyles s listStyle (n,l) = inTags True "text:list-style" [("style:name", "L" ++ show n)] (vcat l) @@ -176,10 +182,10 @@ reverse $ styles ++ listStyles context = writerVariables opts ++ [ ("body", body') - , ("automatic-styles", render automaticStyles) - , ("title", render title') - , ("date", render date') ] ++ - [ ("author", render a) | a <- authors' ] + , ("automatic-styles", render' automaticStyles) + , ("title", render' title') + , ("date", render' date') ] ++ + [ ("author", render' a) | a <- authors' ] in if writerStandalone opts then renderTemplate context $ writerTemplate opts else body' @@ -273,7 +279,7 @@ | Header i b <- bs = inHeaderTags i <$> inlinesToOpenDocument o b | BlockQuote b <- bs = mkBlockQuote b | CodeBlock _ s <- bs = preformatted s - | RawHtml _ <- bs = return empty + | RawBlock _ _ <- bs = return empty | DefinitionList b <- bs = defList b | BulletList b <- bs = bulletListToOpenDocument o b | OrderedList a b <- bs = orderedList a b @@ -286,7 +292,7 @@ r <- vcat <$> mapM (deflistItemToOpenDocument o) b setInDefinitionList False return r - preformatted s = vcat <$> mapM (inPreformattedTags . escapeStringForXML) (lines s) + preformatted s = (flush . vcat) <$> mapM (inPreformattedTags . escapeStringForXML) (lines s) mkBlockQuote b = do increaseIndent i <- paraStyle "Quotations" [] inBlockQuote o i (map plainToPara b) @@ -346,7 +352,7 @@ | EmDash <- ils = inTextStyle $ text "—" | EnDash <- ils = inTextStyle $ text "–" | Apostrophe <- ils = inTextStyle $ text "’" - | Space <- ils = inTextStyle $ char ' ' + | Space <- ils = inTextStyle space | LineBreak <- ils = return $ selfClosingTag "text:line-break" [] | Str s <- ils = inTextStyle $ handleSpaces $ escapeStringForXML s | Emph l <- ils = withTextStyle Italic $ inlinesToOpenDocument o l @@ -356,11 +362,12 @@ | Subscript l <- ils = withTextStyle Sub $ inlinesToOpenDocument o l | SmallCaps l <- ils = withTextStyle SmallC $ inlinesToOpenDocument o l | Quoted t l <- ils = inQuotes t <$> inlinesToOpenDocument o l - | Code s <- ils = preformatted s + | Code _ s <- ils = preformatted s | Math _ s <- ils = inlinesToOpenDocument o (readTeXMath s) | Cite _ l <- ils = inlinesToOpenDocument o l - | TeX s <- ils = preformatted s - | HtmlInline s <- ils = preformatted s + | RawInline "opendocument" s <- ils = preformatted s + | RawInline "html" s <- ils = preformatted s -- for backwards compat. + | RawInline _ _ <- ils = return empty | Link l (s,t) <- ils = mkLink s t <$> inlinesToOpenDocument o l | Image _ (s,_) <- ils = return $ mkImg s | Note l <- ils = mkNote l diff -Nru pandoc-1.5.1.1/src/Text/Pandoc/Writers/Org.hs pandoc-1.8.0.3/src/Text/Pandoc/Writers/Org.hs --- pandoc-1.5.1.1/src/Text/Pandoc/Writers/Org.hs 1970-01-01 00:00:00.000000000 +0000 +++ pandoc-1.8.0.3/src/Text/Pandoc/Writers/Org.hs 2011-02-05 18:48:07.000000000 +0000 @@ -0,0 +1,284 @@ +{-# LANGUAGE OverloadedStrings #-} +{- +Copyright (C) 2006-2010 Puneeth Chaganti + +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.Writers.Org + Copyright : Copyright (C) 2010 Puneeth Chaganti + License : GNU GPL, version 2 or above + + Maintainer : Puneeth Chaganti + Stability : alpha + Portability : portable + +Conversion of 'Pandoc' documents to Emacs Org-Mode. + +Org-Mode: +-} +module Text.Pandoc.Writers.Org ( writeOrg) where +import Text.Pandoc.Definition +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 = + WriterState { stNotes :: [[Block]] + , stLinks :: Bool + , stImages :: Bool + , stHasMath :: Bool + , stOptions :: WriterOptions + } + +-- | Convert Pandoc to Org. +writeOrg :: WriterOptions -> Pandoc -> String +writeOrg opts document = + let st = WriterState { stNotes = [], stLinks = False, + stImages = False, stHasMath = False, + stOptions = opts } + in evalState (pandocToOrg document) st + +-- | Return Org representation of document. +pandocToOrg :: Pandoc -> State WriterState String +pandocToOrg (Pandoc (Meta tit auth dat) blocks) = do + opts <- liftM stOptions get + title <- titleToOrg tit + authors <- mapM inlineListToOrg auth + date <- inlineListToOrg dat + body <- blockListToOrg blocks + notes <- liftM (reverse . stNotes) get >>= notesToOrg + -- note that the notes may contain refs, so we do them first + hasMath <- liftM stHasMath get + let colwidth = if writerWrapText opts + then Just $ writerColumns opts + else Nothing + let main = render colwidth $ foldl ($+$) empty $ [body, notes] + let context = writerVariables opts ++ + [ ("body", main) + , ("title", render Nothing title) + , ("date", render Nothing date) ] ++ + [ ("math", "yes") | hasMath ] ++ + [ ("author", render Nothing a) | a <- authors ] + if writerStandalone opts + then return $ renderTemplate context $ writerTemplate opts + else return main + +-- | Return Org representation of notes. +notesToOrg :: [[Block]] -> State WriterState Doc +notesToOrg notes = + mapM (\(num, note) -> noteToOrg num note) (zip [1..] notes) >>= + return . vsep + +-- | Return Org representation of a note. +noteToOrg :: Int -> [Block] -> State WriterState Doc +noteToOrg num note = do + contents <- blockListToOrg note + let marker = "[" ++ show num ++ "] " + return $ hang (length marker) (text marker) contents + +-- | Escape special characters for Org. +escapeString :: String -> String +escapeString = escapeStringUsing (backslashEscapes "^_") + +titleToOrg :: [Inline] -> State WriterState Doc +titleToOrg [] = return empty +titleToOrg lst = do + contents <- inlineListToOrg lst + return $ "#+TITLE: " <> contents + +-- | Convert Pandoc block element to Org. +blockToOrg :: Block -- ^ Block element + -> State WriterState Doc +blockToOrg Null = return empty +blockToOrg (Plain inlines) = inlineListToOrg inlines +blockToOrg (Para [Image txt (src,tit)]) = do + capt <- inlineListToOrg txt + img <- inlineToOrg (Image txt (src,tit)) + return $ "#+CAPTION: " <> capt <> blankline <> img +blockToOrg (Para inlines) = do + contents <- inlineListToOrg inlines + return $ contents <> blankline +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 + 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", + "scheme", "screen", "sh", "sql", "sqlite"] + let (beg, end) = if null at + then ("#+BEGIN_EXAMPLE", "#+END_EXAMPLE") + else ("#+BEGIN_SRC" ++ head at, "#+END_SRC") + return $ text beg $$ nest tabstop (text str) $$ text end $$ blankline +blockToOrg (BlockQuote blocks) = do + contents <- blockListToOrg blocks + return $ blankline $$ "#+BEGIN_QUOTE" $$ + nest 2 contents $$ "#+END_QUOTE" $$ blankline +blockToOrg (Table caption' _ _ headers rows) = do + caption'' <- inlineListToOrg caption' + let caption = if null caption' + then empty + else ("#+CAPTION: " <> caption'') + headers' <- mapM blockListToOrg headers + rawRows <- mapM (mapM blockListToOrg) rows + let numChars = maximum . map offset + -- 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] + where h = maximum (map height blocks) + sep' = lblock 3 $ vcat (map text $ replicate h " | ") + beg = lblock 2 $ vcat (map text $ replicate h "| ") + end = lblock 2 $ vcat (map text $ replicate h " |") + middle = hcat $ intersperse sep' blocks + let makeRow = hpipeBlocks . zipWith lblock widthsInChars + let head' = makeRow headers' + 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) $ + map (\l -> text $ replicate l ch) widthsInChars) <> + char ch <> char '|' + let body = vcat rows' + let head'' = if all null headers + then empty + else head' $$ border '-' + return $ head'' $$ body $$ caption $$ blankline +blockToOrg (BulletList items) = do + contents <- mapM bulletListItemToOrg items + -- ensure that sublists have preceding blank line + return $ blankline $+$ vcat contents $$ blankline +blockToOrg (OrderedList (start, _, delim) items) = do + let delim' = case delim of + TwoParens -> OneParen + x -> x + let markers = take (length items) $ orderedListMarkers + (start, Decimal, delim') + let maxMarkerLength = maximum $ map length markers + let markers' = map (\m -> let s = maxMarkerLength - length m + in m ++ replicate s ' ') markers + contents <- mapM (\(item, num) -> orderedListItemToOrg item num) $ + zip markers' items + -- ensure that sublists have preceding blank line + return $ blankline $$ vcat contents $$ blankline +blockToOrg (DefinitionList items) = do + contents <- mapM definitionListItemToOrg items + return $ vcat contents $$ blankline + +-- | Convert bullet list item (list of blocks) to Org. +bulletListItemToOrg :: [Block] -> State WriterState Doc +bulletListItemToOrg items = do + contents <- blockListToOrg items + return $ hang 3 "- " (contents <> cr) + +-- | Convert ordered list item (a list of blocks) to Org. +orderedListItemToOrg :: String -- ^ marker for list item + -> [Block] -- ^ list item (list of blocks) + -> State WriterState Doc +orderedListItemToOrg marker items = do + contents <- blockListToOrg items + return $ hang (length marker + 1) (text marker <> space) (contents <> cr) + +-- | Convert defintion list item (label, list of blocks) to Org. +definitionListItemToOrg :: ([Inline], [[Block]]) -> State WriterState Doc +definitionListItemToOrg (label, defs) = do + label' <- inlineListToOrg label + contents <- liftM vcat $ mapM blockListToOrg defs + return $ hang 3 "- " $ label' <> " :: " <> (contents <> cr) + +-- | Convert list of Pandoc block elements to Org. +blockListToOrg :: [Block] -- ^ List of block elements + -> State WriterState Doc +blockListToOrg blocks = mapM blockToOrg blocks >>= return . vcat + +-- | Convert list of Pandoc inline elements to Org. +inlineListToOrg :: [Inline] -> State WriterState Doc +inlineListToOrg lst = mapM inlineToOrg lst >>= return . hcat + +-- | Convert Pandoc inline element to Org. +inlineToOrg :: Inline -> State WriterState Doc +inlineToOrg (Emph lst) = do + contents <- inlineListToOrg lst + return $ "/" <> contents <> "/" +inlineToOrg (Strong lst) = do + contents <- inlineListToOrg lst + return $ "*" <> contents <> "*" +inlineToOrg (Strikeout lst) = do + contents <- inlineListToOrg lst + return $ "+" <> contents <> "+" +inlineToOrg (Superscript lst) = do + contents <- inlineListToOrg lst + return $ "^{" <> contents <> "}" +inlineToOrg (Subscript lst) = do + contents <- inlineListToOrg lst + return $ "_{" <> contents <> "}" +inlineToOrg (SmallCaps lst) = inlineListToOrg lst +inlineToOrg (Quoted SingleQuote lst) = do + contents <- inlineListToOrg lst + return $ "'" <> contents <> "'" +inlineToOrg (Quoted DoubleQuote lst) = do + contents <- inlineListToOrg lst + return $ "\"" <> contents <> "\"" +inlineToOrg (Cite _ lst) = inlineListToOrg lst +inlineToOrg EmDash = return "---" +inlineToOrg EnDash = return "--" +inlineToOrg Apostrophe = return "'" +inlineToOrg Ellipses = return "..." +inlineToOrg (Code _ str) = return $ "=" <> text str <> "=" +inlineToOrg (Str str) = return $ text $ escapeString str +inlineToOrg (Math t str) = do + modify $ \st -> st{ stHasMath = True } + return $ if t == InlineMath + then "$" <> text str <> "$" + else "$$" <> text str <> "$$" +inlineToOrg (RawInline f str) | f == "tex" || f == "latex" = return $ text str +inlineToOrg (RawInline _ _) = return empty +inlineToOrg (LineBreak) = return cr -- there's no line break in Org +inlineToOrg Space = return space +inlineToOrg (Link txt (src, _)) = do + case txt of + [Code _ x] | x == src -> -- autolink + do modify $ \s -> s{ stLinks = True } + return $ "[[" <> text x <> "]]" + _ -> do contents <- inlineListToOrg txt + modify $ \s -> s{ stLinks = True } + return $ "[[" <> text src <> "][" <> contents <> "]]" +inlineToOrg (Image _ (source', _)) = do + let source = unescapeURI source' + modify $ \s -> s{ stImages = True } + return $ "[[" <> text source <> "]]" +inlineToOrg (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 <> "]" diff -Nru pandoc-1.5.1.1/src/Text/Pandoc/Writers/RST.hs pandoc-1.8.0.3/src/Text/Pandoc/Writers/RST.hs --- pandoc-1.5.1.1/src/Text/Pandoc/Writers/RST.hs 2010-03-29 14:24:56.000000000 +0000 +++ pandoc-1.8.0.3/src/Text/Pandoc/Writers/RST.hs 2011-02-05 18:48:07.000000000 +0000 @@ -1,3 +1,4 @@ +{-# LANGUAGE OverloadedStrings #-} {- Copyright (C) 2006-2010 John MacFarlane @@ -32,17 +33,18 @@ module Text.Pandoc.Writers.RST ( writeRST) where import Text.Pandoc.Definition import Text.Pandoc.Shared -import Text.Pandoc.Blocks import Text.Pandoc.Templates (renderTemplate) -import Data.List ( isPrefixOf, isSuffixOf, intersperse, transpose ) -import Text.PrettyPrint.HughesPJ hiding ( Str ) +import Data.List ( isPrefixOf, intersperse, transpose ) +import Text.Pandoc.Pretty import Control.Monad.State import Control.Applicative ( (<$>) ) +type Refs = [([Inline], Target)] + data WriterState = WriterState { stNotes :: [[Block]] - , stLinks :: KeyTable - , stImages :: KeyTable + , stLinks :: Refs + , stImages :: Refs , stHasMath :: Bool , stOptions :: WriterOptions } @@ -65,66 +67,60 @@ body <- blockListToRST blocks notes <- liftM (reverse . stNotes) get >>= notesToRST -- note that the notes may contain refs, so we do them first - refs <- liftM (reverse . stLinks) get >>= keyTableToRST - pics <- liftM (reverse . stImages) get >>= pictTableToRST + refs <- liftM (reverse . stLinks) get >>= refsToRST + pics <- liftM (reverse . stImages) get >>= pictRefsToRST hasMath <- liftM stHasMath get - let main = render $ body $+$ notes $+$ text "" $+$ refs $+$ pics + let colwidth = if writerWrapText opts + then Just $ writerColumns opts + else Nothing + let main = render colwidth $ foldl ($+$) empty $ [body, notes, refs, pics] let context = writerVariables opts ++ [ ("body", main) - , ("title", render title) - , ("date", render date) ] ++ + , ("title", render Nothing title) + , ("date", render colwidth date) ] ++ [ ("math", "yes") | hasMath ] ++ - [ ("author", render a) | a <- authors ] + [ ("author", render colwidth a) | a <- authors ] if writerStandalone opts then return $ renderTemplate context $ writerTemplate opts else return main -- | Return RST representation of reference key table. -keyTableToRST :: KeyTable -> State WriterState Doc -keyTableToRST refs = mapM keyToRST refs >>= return . vcat - +refsToRST :: Refs -> State WriterState Doc +refsToRST refs = mapM keyToRST refs >>= return . vcat + -- | Return RST representation of a reference key. keyToRST :: ([Inline], (String, String)) -> State WriterState Doc keyToRST (label, (src, _)) = do label' <- inlineListToRST label - let label'' = if ':' `elem` (render label') + let label'' = if ':' `elem` (render Nothing label') then char '`' <> label' <> char '`' else label' - return $ text ".. _" <> label'' <> text ": " <> text src + return $ ".. _" <> label'' <> ": " <> text src -- | Return RST representation of notes. notesToRST :: [[Block]] -> State WriterState Doc notesToRST notes = - mapM (\(num, note) -> noteToRST num note) (zip [1..] notes) >>= - return . vcat + mapM (\(num, note) -> noteToRST num note) (zip [1..] notes) >>= + return . vsep -- | Return RST representation of a note. noteToRST :: Int -> [Block] -> State WriterState Doc noteToRST num note = do contents <- blockListToRST note - let marker = text ".. [" <> text (show num) <> text "]" + let marker = ".. [" <> text (show num) <> "]" return $ marker $$ nest 3 contents -- | Return RST representation of picture reference table. -pictTableToRST :: KeyTable -> State WriterState Doc -pictTableToRST refs = mapM pictToRST refs >>= return . vcat - +pictRefsToRST :: Refs -> State WriterState Doc +pictRefsToRST refs = mapM pictToRST refs >>= return . vcat + -- | Return RST representation of a picture substitution reference. pictToRST :: ([Inline], (String, String)) -> State WriterState Doc pictToRST (label, (src, _)) = do label' <- inlineListToRST label - return $ text ".. " <> char '|' <> label' <> char '|' <> text " image:: " <> - text src - --- | Take list of inline elements and return wrapped doc. -wrappedRST :: WriterOptions -> [Inline] -> State WriterState Doc -wrappedRST opts inlines = do - lineBreakDoc <- inlineToRST LineBreak - chunks <- mapM (wrapIfNeeded opts inlineListToRST) - (splitBy LineBreak inlines) - return $ vcat $ intersperse lineBreakDoc chunks + return $ ".. |" <> label' <> "| image:: " <> text src -- | Escape special characters for RST. escapeString :: String -> String @@ -134,69 +130,66 @@ titleToRST [] = return empty titleToRST lst = do contents <- inlineListToRST lst - let titleLength = length $ render contents + let titleLength = length $ (render Nothing contents :: String) let border = text (replicate titleLength '=') - return $ border $+$ contents $+$ border + return $ border $$ contents $$ border -- | Convert Pandoc block element to RST. blockToRST :: Block -- ^ Block element -> State WriterState Doc blockToRST Null = return empty -blockToRST (Plain inlines) = do - opts <- get >>= (return . stOptions) - wrappedRST opts inlines +blockToRST (Plain inlines) = inlineListToRST inlines blockToRST (Para [Image txt (src,tit)]) = do capt <- inlineListToRST txt - let fig = text "figure:: " <> text src - let align = text ":align: center" - let alt = text ":alt: " <> if null tit then capt else text tit - return $ (text ".. " <> (fig $$ align $$ alt $$ text "" $$ capt)) $$ text "" + 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 - opts <- get >>= (return . stOptions) - contents <- wrappedRST opts inlines - return $ contents <> text "\n" -blockToRST (RawHtml str) = - let str' = if "\n" `isSuffixOf` str then str ++ "\n" else str ++ "\n\n" in - return $ (text "\n.. raw:: html\n") $$ (nest 3 $ vcat $ map text (lines str')) -blockToRST HorizontalRule = return $ text "--------------\n" + 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 contents <- inlineListToRST inlines - let headerLength = length $ render contents let headerChar = if level > 5 then ' ' else "=-~^'" !! (level - 1) - let border = text $ replicate headerLength headerChar - return $ contents $+$ border <> text "\n" + let border = text $ replicate (offset contents) headerChar + return $ contents $$ border $$ blankline blockToRST (CodeBlock (_,classes,_) str) = do opts <- stOptions <$> get let tabstop = writerTabStop opts if "haskell" `elem` classes && "literate" `elem` classes && writerLiterateHaskell opts - then return $ (vcat $ map (text "> " <>) $ map text (lines str)) <> text "\n" - else return $ (text "::\n") $+$ - (nest tabstop $ vcat $ map text (lines str)) <> text "\n" + 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 - return $ (nest tabstop contents) <> text "\n" + return $ (nest tabstop contents) <> blankline blockToRST (Table caption _ widths headers rows) = do caption' <- inlineListToRST caption let caption'' = if null caption then empty - else text "" $+$ (text "Table: " <> caption') + else blankline <> text "Table: " <> caption' headers' <- mapM blockListToRST headers rawRows <- mapM (mapM blockListToRST) rows let isSimple = all (==0) widths && all (all (\bs -> length bs == 1)) rows - let numChars = maximum . map (length . render) + let numChars = maximum . map offset + opts <- get >>= return . stOptions let widthsInChars = if isSimple then map ((+2) . numChars) $ transpose (headers' : rawRows) - else map (floor . (78 *)) widths - let hpipeBlocks blocks = hcatBlocks [beg, middle, end] - where height = maximum (map heightOfBlock blocks) - sep' = TextBlock 3 height (replicate height " | ") - beg = TextBlock 2 height (replicate height "| ") - end = TextBlock 2 height (replicate height " |") - middle = hcatBlocks $ intersperse sep' blocks - let makeRow = hpipeBlocks . zipWith docToBlock widthsInChars + else map (floor . (fromIntegral (writerColumns opts) *)) widths + 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 "| ") + end = lblock 2 $ vcat (map text $ replicate h " |") + middle = hcat $ intersperse sep' blocks + let makeRow = hpipeBlocks . zipWith lblock widthsInChars let head' = makeRow headers' rows' <- mapM (\row -> do cols <- mapM blockListToRST row return $ makeRow cols) rows @@ -204,15 +197,15 @@ (hcat $ intersperse (char ch <> char '+' <> char ch) $ map (\l -> text $ replicate l ch) widthsInChars) <> char ch <> char '+' - let body = vcat $ intersperse (border '-') $ map blockToDoc rows' + let body = vcat $ intersperse (border '-') rows' let head'' = if all null headers then empty - else blockToDoc head' $+$ border '=' - return $ border '-' $+$ head'' $+$ body $+$ border '-' $$ caption'' $$ text "" + else head' $$ border '=' + return $ border '-' $$ head'' $$ body $$ border '-' $$ caption'' $$ blankline blockToRST (BulletList items) = do contents <- mapM bulletListItemToRST items -- ensure that sublists have preceding blank line - return $ text "" $+$ vcat contents <> text "\n" + return $ blankline $$ vcat contents $$ blankline blockToRST (OrderedList (start, style', delim) items) = do let markers = if start == 1 && style' == DefaultStyle && delim == DefaultDelim then take (length items) $ repeat "#." @@ -222,18 +215,19 @@ let markers' = map (\m -> let s = maxMarkerLength - length m in m ++ replicate s ' ') markers contents <- mapM (\(item, num) -> orderedListItemToRST item num) $ - zip markers' items + zip markers' items -- ensure that sublists have preceding blank line - return $ text "" $+$ vcat contents <> text "\n" + return $ blankline $$ vcat contents $$ blankline blockToRST (DefinitionList items) = do contents <- mapM definitionListItemToRST items - return $ (vcat contents) <> text "\n" + -- ensure that sublists have preceding blank line + return $ blankline $$ vcat contents $$ blankline -- | Convert bullet list item (list of blocks) to RST. bulletListItemToRST :: [Block] -> State WriterState Doc bulletListItemToRST items = do contents <- blockListToRST items - return $ (text "- ") <> contents + return $ hang 3 "- " $ contents <> cr -- | Convert ordered list item (a list of blocks) to RST. orderedListItemToRST :: String -- ^ marker for list item @@ -241,7 +235,8 @@ -> State WriterState Doc orderedListItemToRST marker items = do contents <- blockListToRST items - return $ (text marker <> char ' ') <> contents + let marker' = marker ++ " " + return $ hang (length marker') (text marker') $ contents <> cr -- | Convert defintion list item (label, list of blocks) to RST. definitionListItemToRST :: ([Inline], [[Block]]) -> State WriterState Doc @@ -249,7 +244,7 @@ label' <- inlineListToRST label contents <- liftM vcat $ mapM blockListToRST defs tabstop <- get >>= (return . writerTabStop . stOptions) - return $ label' $+$ nest tabstop contents + return $ label' $$ nest tabstop (contents <> cr) -- | Convert list of Pandoc block elements to RST. blockListToRST :: [Block] -- ^ List of block elements @@ -264,65 +259,63 @@ inlineToRST :: Inline -> State WriterState Doc inlineToRST (Emph lst) = do contents <- inlineListToRST lst - return $ char '*' <> contents <> char '*' + return $ "*" <> contents <> "*" inlineToRST (Strong lst) = do contents <- inlineListToRST lst - return $ text "**" <> contents <> text "**" + return $ "**" <> contents <> "**" inlineToRST (Strikeout lst) = do contents <- inlineListToRST lst - return $ text "[STRIKEOUT:" <> contents <> char ']' + return $ "[STRIKEOUT:" <> contents <> "]" inlineToRST (Superscript lst) = do contents <- inlineListToRST lst - return $ text "\\ :sup:`" <> contents <> text "`\\ " + return $ "\\ :sup:`" <> contents <> "`\\ " inlineToRST (Subscript lst) = do contents <- inlineListToRST lst - return $ text "\\ :sub:`" <> contents <> text "`\\ " + return $ "\\ :sub:`" <> contents <> "`\\ " inlineToRST (SmallCaps lst) = inlineListToRST lst inlineToRST (Quoted SingleQuote lst) = do contents <- inlineListToRST lst - return $ char '\'' <> contents <> char '\'' + return $ "‘" <> contents <> "’" inlineToRST (Quoted DoubleQuote lst) = do contents <- inlineListToRST lst - return $ char '"' <> contents <> char '"' + return $ "“" <> contents <> "”" inlineToRST (Cite _ lst) = inlineListToRST lst -inlineToRST EmDash = return $ text "--" -inlineToRST EnDash = return $ char '-' -inlineToRST Apostrophe = return $ char '\'' -inlineToRST Ellipses = return $ text "..." -inlineToRST (Code str) = return $ text $ "``" ++ str ++ "``" +inlineToRST EmDash = return $ char '\8212' +inlineToRST EnDash = return $ char '\8211' +inlineToRST Apostrophe = return $ char '\8217' +inlineToRST Ellipses = return $ char '\8230' +inlineToRST (Code _ str) = return $ "``" <> text str <> "``" inlineToRST (Str str) = return $ text $ escapeString str inlineToRST (Math t str) = do modify $ \st -> st{ stHasMath = True } return $ if t == InlineMath - then text $ ":math:`$" ++ str ++ "$`" - else text $ ":math:`$$" ++ str ++ "$$`" -inlineToRST (TeX _) = return empty -inlineToRST (HtmlInline _) = return empty -inlineToRST (LineBreak) = do - return $ empty -- there's no line break in RST -inlineToRST Space = return $ char ' ' -inlineToRST (Link [Code str] (src, _)) | src == str || - src == "mailto:" ++ str = do + then ":math:`$" <> text str <> "$`" + else ":math:`$$" <> text str <> "$$`" +inlineToRST (RawInline _ _) = return empty +inlineToRST (LineBreak) = return cr -- there's no line break in RST +inlineToRST Space = return space +inlineToRST (Link [Code _ str] (src, _)) | src == str || + src == "mailto:" ++ str = do let srcSuffix = if isPrefixOf "mailto:" src then drop 7 src else src return $ text $ unescapeURI srcSuffix inlineToRST (Link txt (src', tit)) = do let src = unescapeURI src' - useReferenceLinks <- get >>= (return . writerReferenceLinks . stOptions) + useReferenceLinks <- get >>= return . writerReferenceLinks . stOptions linktext <- inlineListToRST $ normalizeSpaces txt if useReferenceLinks - then do refs <- get >>= (return . stLinks) + 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 $ char '`' <> linktext <> text "`_" - else return $ char '`' <> linktext <> text " <" <> text src <> text ">`_" + return $ "`" <> linktext <> "`_" + else return $ "`" <> linktext <> " <" <> text src <> ">`_" inlineToRST (Image alternate (source', tit)) = do let source = unescapeURI source' - pics <- get >>= (return . stImages) + pics <- get >>= return . stImages let labelsUsed = map fst pics - let txt = if null alternate || alternate == [Str ""] || + let txt = if null alternate || alternate == [Str ""] || alternate `elem` labelsUsed then [Str $ "image" ++ show (length pics)] else alternate @@ -331,10 +324,10 @@ else (txt, (source, tit)):pics modify $ \st -> st { stImages = pics' } label <- inlineListToRST txt - return $ char '|' <> label <> char '|' + return $ "|" <> label <> "|" inlineToRST (Note contents) = do -- add to notes in state - notes <- get >>= (return . stNotes) + notes <- get >>= return . stNotes modify $ \st -> st { stNotes = contents:notes } let ref = show $ (length notes) + 1 - return $ text " [" <> text ref <> text "]_" + return $ " [" <> text ref <> "]_" diff -Nru pandoc-1.5.1.1/src/Text/Pandoc/Writers/RTF.hs pandoc-1.8.0.3/src/Text/Pandoc/Writers/RTF.hs --- pandoc-1.5.1.1/src/Text/Pandoc/Writers/RTF.hs 2010-03-29 14:24:56.000000000 +0000 +++ pandoc-1.8.0.3/src/Text/Pandoc/Writers/RTF.hs 2011-02-05 18:48:07.000000000 +0000 @@ -27,13 +27,34 @@ Conversion of 'Pandoc' documents to RTF (rich text format). -} -module Text.Pandoc.Writers.RTF ( writeRTF ) where +module Text.Pandoc.Writers.RTF ( writeRTF, rtfEmbedImage ) where import Text.Pandoc.Definition import Text.Pandoc.Shared import Text.Pandoc.Readers.TeXMath import Text.Pandoc.Templates (renderTemplate) import Data.List ( isSuffixOf, intercalate ) -import Data.Char ( ord, isDigit ) +import Data.Char ( ord, isDigit, toLower ) +import System.FilePath ( takeExtension ) +import qualified Data.ByteString as B +import Text.Printf ( printf ) + +-- | 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. +rtfEmbedImage :: Inline -> IO Inline +rtfEmbedImage x@(Image _ (src,_)) + | map toLower (takeExtension src) `elem` [".jpg",".jpeg",".png"] = do + imgdata <- catch (B.readFile src) (\_ -> return B.empty) + let bytes = map (printf "%02x") $ B.unpack imgdata + let filetype = case map toLower (takeExtension src) of + ".jpg" -> "\\jpegblip" + ".jpeg" -> "\\jpegblip" + ".png" -> "\\pngblip" + _ -> error "Unknown file type" + let raw = "{\\pict" ++ filetype ++ " " ++ concat bytes ++ "}" + return $ if B.null imgdata + then x + else RawInline "rtf" raw +rtfEmbedImage x = return x -- | Convert Pandoc to a string in rich text format. writeRTF :: WriterOptions -> Pandoc -> String @@ -159,7 +180,8 @@ concatMap (blockToRTF (indent + indentIncrement) alignment) lst blockToRTF indent _ (CodeBlock _ str) = rtfPar indent 0 AlignLeft ("\\f1 " ++ (codeStringToRTF str)) -blockToRTF _ _ (RawHtml _) = "" +blockToRTF _ _ (RawBlock "rtf" str) = str +blockToRTF _ _ (RawBlock _ _) = "" blockToRTF indent alignment (BulletList lst) = spaceAtEnd $ concatMap (listItemToRTF alignment indent (bulletMarker indent)) lst blockToRTF indent alignment (OrderedList attribs lst) = spaceAtEnd $ concat $ @@ -264,12 +286,12 @@ inlineToRTF Ellipses = "\\u8230?" inlineToRTF EmDash = "\\u8212-" inlineToRTF EnDash = "\\u8211-" -inlineToRTF (Code str) = "{\\f1 " ++ (codeStringToRTF str) ++ "}" +inlineToRTF (Code _ str) = "{\\f1 " ++ (codeStringToRTF str) ++ "}" inlineToRTF (Str str) = stringToRTF str inlineToRTF (Math _ str) = inlineListToRTF $ readTeXMath str inlineToRTF (Cite _ lst) = inlineListToRTF lst -inlineToRTF (TeX _) = "" -inlineToRTF (HtmlInline _) = "" +inlineToRTF (RawInline "rtf" str) = str +inlineToRTF (RawInline _ _) = "" inlineToRTF (LineBreak) = "\\line " inlineToRTF Space = " " inlineToRTF (Link text (src, _)) = diff -Nru pandoc-1.5.1.1/src/Text/Pandoc/Writers/S5.hs pandoc-1.8.0.3/src/Text/Pandoc/Writers/S5.hs --- pandoc-1.5.1.1/src/Text/Pandoc/Writers/S5.hs 2010-03-29 14:24:56.000000000 +0000 +++ pandoc-1.8.0.3/src/Text/Pandoc/Writers/S5.hs 1970-01-01 00:00:00.000000000 +0000 @@ -1,136 +0,0 @@ -{- -Copyright (C) 2006-2010 John MacFarlane - -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.Writers.S5 - Copyright : Copyright (C) 2006-2010 John MacFarlane - License : GNU GPL, version 2 or above - - Maintainer : John MacFarlane - Stability : alpha - Portability : portable - -Definitions for creation of S5 powerpoint-like HTML. -(See .) --} -module Text.Pandoc.Writers.S5 ( - -- * Header includes - s5HeaderIncludes, - s5Links, - -- * Functions - writeS5, - writeS5String, - insertS5Structure - ) where -import Text.Pandoc.Shared ( WriterOptions, readDataFile ) -import Text.Pandoc.Writers.HTML ( writeHtml, writeHtmlString ) -import Text.Pandoc.Definition -import Text.XHtml.Strict -import System.FilePath ( () ) -import Data.List ( intercalate ) - -s5HeaderIncludes :: Maybe FilePath -> IO String -s5HeaderIncludes datadir = do - c <- s5CSS datadir - j <- s5Javascript datadir - return $ s5Meta ++ c ++ j - -s5Meta :: String -s5Meta = "\n\n\n" - -s5Javascript :: Maybe FilePath -> IO String -s5Javascript datadir = do - jsCom <- readDataFile datadir $ "s5" "default" "slides.js.comment" - jsPacked <- readDataFile datadir $ "s5" "default" "slides.js.packed" - return $ "\n" - -s5CSS :: Maybe FilePath -> IO String -s5CSS datadir = do - s5CoreCSS <- readDataFile datadir $ "s5" "default" "s5-core.css" - s5FramingCSS <- readDataFile datadir $ "s5" "default" "framing.css" - s5PrettyCSS <- readDataFile datadir $ "s5" "default" "pretty.css" - s5OperaCSS <- readDataFile datadir $ "s5" "default" "opera.css" - s5OutlineCSS <- readDataFile datadir $ "s5" "default" "outline.css" - s5PrintCSS <- readDataFile datadir $ "s5" "default" "print.css" - return $ "\n\n\n\n" - -s5Links :: String -s5Links = "\n\n\n\n\n\n\n" - --- | Converts Pandoc document to an S5 HTML presentation (Html structure). -writeS5 :: WriterOptions -> Pandoc -> Html -writeS5 options = (writeHtml options) . insertS5Structure - --- | Converts Pandoc document to an S5 HTML presentation (string). -writeS5String :: WriterOptions -> Pandoc -> String -writeS5String options = (writeHtmlString options) . insertS5Structure - --- | Inserts HTML needed for an S5 presentation (e.g. around slides). -layoutDiv :: [Inline] -- ^ Title of document (for header or footer) - -> [Inline] -- ^ Date of document (for header or footer) - -> [Block] -- ^ List of block elements returned -layoutDiv title' date = [(RawHtml "
          \n
          \n
          \n
          \n
          \n"), (Header 1 date), (Header 2 title'), (RawHtml "
          \n
          \n")] - -presentationStart :: Block -presentationStart = RawHtml "
          \n\n" - -presentationEnd :: Block -presentationEnd = RawHtml "
          \n" - -slideStart :: Block -slideStart = RawHtml "
          \n" - -slideEnd :: Block -slideEnd = RawHtml "
          \n" - --- | Returns 'True' if block is a Header 1. -isH1 :: Block -> Bool -isH1 (Header 1 _) = True -isH1 _ = False - --- | Insert HTML around sections to make individual slides. -insertSlides :: Bool -> [Block] -> [Block] -insertSlides beginning blocks = - let (beforeHead, rest) = break isH1 blocks in - if (null rest) then - if beginning then - beforeHead - else - beforeHead ++ [slideEnd] - else - if beginning then - beforeHead ++ - slideStart:(head rest):(insertSlides False (tail rest)) - else - beforeHead ++ - slideEnd:slideStart:(head rest):(insertSlides False (tail rest)) - --- | Insert blocks into 'Pandoc' for slide structure. -insertS5Structure :: Pandoc -> Pandoc -insertS5Structure (Pandoc meta' []) = Pandoc meta' [] -insertS5Structure (Pandoc (Meta title' authors date) blocks) = - let slides = insertSlides True blocks - firstSlide = if not (null title') - then [slideStart, (Header 1 title'), - (Header 3 (intercalate [LineBreak] authors)), - (Header 4 date), slideEnd] - else [] - newBlocks = (layoutDiv title' date) ++ presentationStart:firstSlide ++ - slides ++ [presentationEnd] - in Pandoc (Meta title' authors date) newBlocks diff -Nru pandoc-1.5.1.1/src/Text/Pandoc/Writers/Texinfo.hs pandoc-1.8.0.3/src/Text/Pandoc/Writers/Texinfo.hs --- pandoc-1.5.1.1/src/Text/Pandoc/Writers/Texinfo.hs 2010-03-29 14:24:56.000000000 +0000 +++ pandoc-1.8.0.3/src/Text/Pandoc/Writers/Texinfo.hs 2011-02-05 18:48:07.000000000 +0000 @@ -31,13 +31,12 @@ import Text.Pandoc.Definition import Text.Pandoc.Shared import Text.Pandoc.Templates (renderTemplate) -import Text.Pandoc.Readers.TeXMath import Text.Printf ( printf ) -import Data.List ( isSuffixOf, transpose, maximumBy ) +import Data.List ( transpose, maximumBy ) import Data.Ord ( comparing ) import Data.Char ( chr, ord ) import Control.Monad.State -import Text.PrettyPrint.HughesPJ hiding ( Str ) +import Text.Pandoc.Pretty data WriterState = WriterState { stStrikeout :: Bool -- document contains strikeout @@ -69,17 +68,20 @@ let titlePage = not $ all null $ title : date : authors main <- blockListToTexinfo blocks st <- get - let body = render main + let colwidth = if writerWrapText options + then Just $ writerColumns options + else Nothing + let body = render colwidth main let context = writerVariables options ++ [ ("body", body) - , ("title", render titleText) - , ("date", render dateText) ] ++ + , ("title", render colwidth titleText) + , ("date", render colwidth dateText) ] ++ [ ("toc", "yes") | writerTableOfContents options ] ++ [ ("titlepage", "yes") | titlePage ] ++ [ ("subscript", "yes") | stSubscript st ] ++ [ ("superscript", "yes") | stSuperscript st ] ++ [ ("strikeout", "yes") | stStrikeout st ] ++ - [ ("author", render a) | a <- authorsText ] + [ ("author", render colwidth a) | a <- authorsText ] if writerStandalone options then return $ renderTemplate context $ writerTemplate options else return body @@ -124,26 +126,30 @@ blockToTexinfo (CodeBlock _ str) = do return $ text "@verbatim" $$ - vcat (map text (lines str)) $$ - text "@end verbatim\n" + flush (text str) $$ + text "@end verbatim" <> blankline -blockToTexinfo (RawHtml _) = return empty +blockToTexinfo (RawBlock "texinfo" str) = return $ text str +blockToTexinfo (RawBlock "latex" str) = + return $ text "@tex" $$ text str $$ text "@end tex" +blockToTexinfo (RawBlock _ _) = return empty blockToTexinfo (BulletList lst) = do items <- mapM listItemToTexinfo lst return $ text "@itemize" $$ vcat items $$ - text "@end itemize\n" + text "@end itemize" <> blankline blockToTexinfo (OrderedList (start, numstyle, _) lst) = do items <- mapM listItemToTexinfo lst return $ text "@enumerate " <> exemplar $$ vcat items $$ - text "@end enumerate\n" + text "@end enumerate" <> blankline where exemplar = case numstyle of DefaultStyle -> decimal Decimal -> decimal + Example -> decimal UpperRoman -> decimal -- Roman numerals not supported LowerRoman -> decimal UpperAlpha -> upperAlpha @@ -158,7 +164,7 @@ items <- mapM defListItemToTexinfo lst return $ text "@table @asis" $$ vcat items $$ - text "@end table\n" + text "@end table" <> blankline blockToTexinfo HorizontalRule = -- XXX can't get the equivalent from LaTeX.hs to work @@ -174,13 +180,13 @@ then return $ text "Top" else inlineListToTexinfo lst return $ text "@node Top" $$ - text "@top " <> txt <> char '\n' + text "@top " <> txt <> blankline blockToTexinfo (Header level lst) = do node <- inlineListForNode lst txt <- inlineListToTexinfo lst return $ if (level > 0) && (level <= 4) - then text "\n@node " <> node <> char '\n' <> + then blankline <> text "@node " <> node <> cr <> text (seccmd level) <> txt else txt where @@ -199,18 +205,18 @@ colDescriptors <- if all (== 0) widths then do -- use longest entry instead of column widths - cols <- mapM (mapM (liftM (render . hcat) . mapM blockToTexinfo)) $ - transpose $ heads : rows + cols <- mapM (mapM (liftM (render Nothing . hcat) . mapM blockToTexinfo)) $ + transpose $ heads : rows return $ concatMap ((\x -> "{"++x++"} ") . maximumBy (comparing length)) cols else return $ "@columnfractions " ++ concatMap (printf "%.2f ") widths let tableBody = text ("@multitable " ++ colDescriptors) $$ headers $$ vcat rowsText $$ - text "@end multitable" + text "@end multitable" return $ if isEmpty captionText - then tableBody <> char '\n' + then tableBody <> blankline else text "@float" $$ - tableBody $$ + tableBody $$ inCmd "caption" captionText $$ text "@end float" @@ -252,7 +258,7 @@ -- | Convert Pandoc block elements to Texinfo. blockListToTexinfo :: [Block] -> State WriterState Doc -blockListToTexinfo [] = return $ empty +blockListToTexinfo [] = return empty blockListToTexinfo (x:xs) = do x' <- blockToTexinfo x case x of @@ -275,7 +281,7 @@ xs' <- blockListToTexinfo xs case xs of ((CodeBlock _ _):_) -> return $ x' $$ xs' - _ -> return $ x' $$ text "" $$ xs' + _ -> return $ x' $+$ xs' _ -> do xs' <- blockListToTexinfo xs return $ x' $$ xs' @@ -306,15 +312,23 @@ listItemToTexinfo :: [Block] -> State WriterState Doc -listItemToTexinfo lst = blockListToTexinfo lst >>= - return . (text "@item" $$) +listItemToTexinfo lst = do + contents <- blockListToTexinfo lst + let spacer = case reverse lst of + (Para{}:_) -> blankline + _ -> empty + return $ text "@item" $$ contents <> spacer defListItemToTexinfo :: ([Inline], [[Block]]) -> State WriterState Doc defListItemToTexinfo (term, defs) = do term' <- inlineListToTexinfo term - def' <- liftM vcat $ mapM blockListToTexinfo defs - return $ text "@item " <> term' <> text "\n" $$ def' + let defToTexinfo bs = do d <- blockListToTexinfo bs + case reverse bs of + (Para{}:_) -> return $ d <> blankline + _ -> return d + defs' <- mapM defToTexinfo defs + return $ text "@item " <> term' $+$ vcat defs' -- | Convert list of inline elements to Texinfo. inlineListToTexinfo :: [Inline] -- ^ Inlines to convert @@ -324,31 +338,7 @@ -- | Convert list of inline elements to Texinfo acceptable for a node name. inlineListForNode :: [Inline] -- ^ Inlines to convert -> State WriterState Doc -inlineListForNode lst = mapM inlineForNode lst >>= return . hcat - -inlineForNode :: Inline -> State WriterState Doc -inlineForNode (Str str) = return $ text $ filter (not.disallowedInNode) str -inlineForNode (Emph lst) = inlineListForNode lst -inlineForNode (Strong lst) = inlineListForNode lst -inlineForNode (Strikeout lst) = inlineListForNode lst -inlineForNode (Superscript lst) = inlineListForNode lst -inlineForNode (Subscript lst) = inlineListForNode lst -inlineForNode (SmallCaps lst) = inlineListForNode lst -inlineForNode (Quoted _ lst) = inlineListForNode lst -inlineForNode (Cite _ lst) = inlineListForNode lst -inlineForNode (Code str) = inlineForNode (Str str) -inlineForNode Space = return $ char ' ' -inlineForNode EmDash = return $ text "---" -inlineForNode EnDash = return $ text "--" -inlineForNode Apostrophe = return $ char '\'' -inlineForNode Ellipses = return $ text "..." -inlineForNode LineBreak = return empty -inlineForNode (Math _ str) = inlineListForNode $ readTeXMath str -inlineForNode (TeX _) = return empty -inlineForNode (HtmlInline _) = return empty -inlineForNode (Link lst _) = inlineListForNode lst -inlineForNode (Image lst _) = inlineListForNode lst -inlineForNode (Note _) = return empty +inlineListForNode = return . text . filter (not . disallowedInNode) . stringify -- periods, commas, colons, and parentheses are disallowed in node names disallowedInNode :: Char -> Bool @@ -382,7 +372,7 @@ inlineToTexinfo (SmallCaps lst) = inlineListToTexinfo lst >>= return . inCmd "sc" -inlineToTexinfo (Code str) = do +inlineToTexinfo (Code _ str) = do return $ text $ "@code{" ++ stringToTexinfo str ++ "}" inlineToTexinfo (Quoted SingleQuote lst) = do @@ -401,14 +391,16 @@ inlineToTexinfo Ellipses = return $ text "@dots{}" inlineToTexinfo (Str str) = return $ text (stringToTexinfo str) inlineToTexinfo (Math _ str) = return $ inCmd "math" $ text str -inlineToTexinfo (TeX str) = return $ text "@tex" $$ text str $$ text "@end tex" -inlineToTexinfo (HtmlInline _) = return empty +inlineToTexinfo (RawInline f str) | f == "latex" || f == "tex" = + return $ text "@tex" $$ text str $$ text "@end tex" +inlineToTexinfo (RawInline "texinfo" str) = return $ text str +inlineToTexinfo (RawInline _ _) = return empty inlineToTexinfo (LineBreak) = return $ text "@*" inlineToTexinfo Space = return $ char ' ' inlineToTexinfo (Link txt (src, _)) = do case txt of - [Code x] | x == src -> -- autolink + [Code _ x] | x == src -> -- autolink do return $ text $ "@url{" ++ x ++ "}" _ -> do contents <- inlineListToTexinfo txt let src1 = stringToTexinfo src @@ -428,9 +420,4 @@ inlineToTexinfo (Note contents) = do contents' <- blockListToTexinfo contents - let rawnote = stripTrailingNewlines $ render contents' - let optNewline = "@end verbatim" `isSuffixOf` rawnote - return $ text "@footnote{" <> - text rawnote <> - (if optNewline then char '\n' else empty) <> - char '}' + return $ text "@footnote" <> braces contents' diff -Nru pandoc-1.5.1.1/src/Text/Pandoc/Writers/Textile.hs pandoc-1.8.0.3/src/Text/Pandoc/Writers/Textile.hs --- pandoc-1.5.1.1/src/Text/Pandoc/Writers/Textile.hs 1970-01-01 00:00:00.000000000 +0000 +++ pandoc-1.8.0.3/src/Text/Pandoc/Writers/Textile.hs 2011-02-05 18:48:07.000000000 +0000 @@ -0,0 +1,422 @@ +{- +Copyright (C) 2010 John MacFarlane + +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.Writers.Textile + Copyright : Copyright (C) 2010 John MacFarlane + License : GNU GPL, version 2 or above + + Maintainer : John MacFarlane + Stability : alpha + Portability : portable + +Conversion of 'Pandoc' documents to Textile markup. + +Textile: +-} +module Text.Pandoc.Writers.Textile ( writeTextile ) where +import Text.Pandoc.Definition +import Text.Pandoc.Shared +import Text.Pandoc.Templates (renderTemplate) +import Text.Pandoc.XML ( escapeStringForXML ) +import Data.List ( intercalate ) +import Control.Monad.State +import Data.Char ( isSpace ) + +data WriterState = WriterState { + stNotes :: [String] -- Footnotes + , stListLevel :: [Char] -- String at beginning of list items, e.g. "**" + , stUseTags :: Bool -- True if we should use HTML tags because we're in a complex list + } + +-- | Convert Pandoc to Textile. +writeTextile :: WriterOptions -> Pandoc -> String +writeTextile opts document = + evalState (pandocToTextile opts document) + (WriterState { stNotes = [], stListLevel = [], stUseTags = False }) + +-- | Return Textile representation of document. +pandocToTextile :: WriterOptions -> Pandoc -> State WriterState String +pandocToTextile opts (Pandoc _ blocks) = do + body <- blockListToTextile opts blocks + notes <- liftM (unlines . reverse . stNotes) get + let main = body ++ if null notes then "" else ("\n\n" ++ notes) + let context = writerVariables opts ++ [ ("body", main) ] + if writerStandalone opts + then return $ renderTemplate context $ writerTemplate opts + else return main + +withUseTags :: State WriterState a -> State WriterState a +withUseTags action = do + oldUseTags <- liftM stUseTags get + modify $ \s -> s { stUseTags = True } + result <- action + modify $ \s -> s { stUseTags = oldUseTags } + return result + +-- | Escape one character as needed for Textile. +escapeCharForTextile :: Char -> String +escapeCharForTextile x = case x of + '&' -> "&" + '<' -> "<" + '>' -> ">" + '"' -> """ + '*' -> "*" + '_' -> "_" + '@' -> "@" + '|' -> "|" + c -> [c] + +-- | Escape string as needed for Textile. +escapeStringForTextile :: String -> String +escapeStringForTextile = concatMap escapeCharForTextile + +-- | Convert Pandoc block element to Textile. +blockToTextile :: WriterOptions -- ^ Options + -> Block -- ^ Block element + -> State WriterState String + +blockToTextile _ Null = return "" + +blockToTextile opts (Plain inlines) = + inlineListToTextile opts inlines + +blockToTextile opts (Para [Image txt (src,tit)]) = do + capt <- blockToTextile opts (Para txt) + im <- inlineToTextile opts (Image txt (src,tit)) + return $ im ++ "\n" ++ capt + +blockToTextile opts (Para inlines) = do + useTags <- liftM stUseTags get + listLevel <- liftM stListLevel get + contents <- inlineListToTextile opts inlines + return $ if useTags + then "

          " ++ contents ++ "

          " + else contents ++ if null listLevel then "\n" else "" + +blockToTextile _ (RawBlock f str) = + if f == "html" || f == "textile" + then return str + else return "" + +blockToTextile _ HorizontalRule = return "
          \n" + +blockToTextile opts (Header level inlines) = do + contents <- inlineListToTextile opts inlines + let prefix = 'h' : (show level ++ ". ") + return $ prefix ++ contents ++ "\n" + +blockToTextile _ (CodeBlock (_,classes,_) str) | any (all isSpace) (lines str) = + return $ "\n" ++ escapeStringForXML str ++ + "\n\n" + where classes' = if null classes + then "" + else " class=\"" ++ unwords classes ++ "\"" + +blockToTextile _ (CodeBlock (_,classes,_) str) = + return $ "bc" ++ classes' ++ ". " ++ str ++ "\n\n" + where classes' = if null classes + then "" + else "(" ++ unwords classes ++ ")" + +blockToTextile opts (BlockQuote bs@[Para _]) = do + contents <- blockListToTextile opts bs + return $ "bq. " ++ contents ++ "\n\n" + +blockToTextile opts (BlockQuote blocks) = do + contents <- blockListToTextile opts blocks + return $ "
          \n\n" ++ contents ++ "\n
          \n" + +blockToTextile opts (Table [] aligns widths headers rows') | + all (==0) widths && all (`elem` [AlignLeft,AlignDefault]) aligns = do + hs <- mapM (liftM (("_. " ++) . stripTrailingNewlines) . blockListToTextile opts) headers + let cellsToRow cells = "|" ++ intercalate "|" cells ++ "|" + let header = if all null headers then "" else cellsToRow hs + let rowToCells = mapM (liftM stripTrailingNewlines . blockListToTextile opts) + bs <- mapM rowToCells rows' + let body = unlines $ map cellsToRow bs + return $ header ++ "\n" ++ body ++ "\n" + +blockToTextile opts (Table capt aligns widths headers rows') = do + let alignStrings = map alignmentToString aligns + captionDoc <- if null capt + then return "" + else do + c <- inlineListToTextile opts capt + return $ "" ++ c ++ "\n" + let percent w = show (truncate (100*w) :: Integer) ++ "%" + let coltags = if all (== 0.0) widths + then "" + else unlines $ map + (\w -> "") widths + head' <- if all null headers + then return "" + else do + hs <- tableRowToTextile opts alignStrings 0 headers + return $ "\n" ++ hs ++ "\n\n" + body' <- zipWithM (tableRowToTextile opts alignStrings) [1..] rows' + return $ "\n" ++ captionDoc ++ coltags ++ head' ++ + "\n" ++ unlines body' ++ "\n
          \n" + +blockToTextile opts x@(BulletList items) = do + oldUseTags <- liftM stUseTags get + let useTags = oldUseTags || not (isSimpleList x) + if useTags + then do + contents <- withUseTags $ mapM (listItemToTextile opts) items + return $ "
            \n" ++ vcat contents ++ "\n
          \n" + else do + modify $ \s -> s { stListLevel = stListLevel s ++ "*" } + level <- get >>= return . length . stListLevel + contents <- mapM (listItemToTextile opts) items + modify $ \s -> s { stListLevel = init (stListLevel s) } + return $ vcat contents ++ (if level > 1 then "" else "\n") + +blockToTextile opts x@(OrderedList attribs items) = do + oldUseTags <- liftM stUseTags get + let useTags = oldUseTags || not (isSimpleList x) + if useTags + then do + contents <- withUseTags $ mapM (listItemToTextile opts) items + return $ "\n" ++ vcat contents ++ + "\n
      \n" + else do + modify $ \s -> s { stListLevel = stListLevel s ++ "#" } + level <- get >>= return . length . stListLevel + contents <- mapM (listItemToTextile opts) items + modify $ \s -> s { stListLevel = init (stListLevel s) } + return $ vcat contents ++ (if level > 1 then "" else "\n") + +blockToTextile opts (DefinitionList items) = do + contents <- withUseTags $ mapM (definitionListItemToTextile opts) items + return $ "
      \n" ++ vcat contents ++ "\n
      \n" + +-- Auxiliary functions for lists: + +-- | Convert ordered list attributes to HTML attribute string +listAttribsToString :: ListAttributes -> String +listAttribsToString (startnum, numstyle, _) = + let numstyle' = camelCaseToHyphenated $ show numstyle + in (if startnum /= 1 + then " start=\"" ++ show startnum ++ "\"" + else "") ++ + (if numstyle /= DefaultStyle + then " style=\"list-style-type: " ++ numstyle' ++ ";\"" + else "") + +-- | Convert bullet or ordered list item (list of blocks) to Textile. +listItemToTextile :: WriterOptions -> [Block] -> State WriterState String +listItemToTextile opts items = do + contents <- blockListToTextile opts items + useTags <- get >>= return . stUseTags + if useTags + then return $ "
    • " ++ contents ++ "
    • " + else do + marker <- get >>= return . stListLevel + return $ marker ++ " " ++ contents + +-- | Convert definition list item (label, list of blocks) to Textile. +definitionListItemToTextile :: WriterOptions + -> ([Inline],[[Block]]) + -> State WriterState String +definitionListItemToTextile opts (label, items) = do + labelText <- inlineListToTextile opts label + contents <- mapM (blockListToTextile opts) items + return $ "
      " ++ labelText ++ "
      \n" ++ + (intercalate "\n" $ map (\d -> "
      " ++ d ++ "
      ") contents) + +-- | True if the list can be handled by simple wiki markup, False if HTML tags will be needed. +isSimpleList :: Block -> Bool +isSimpleList x = + case x of + BulletList items -> all isSimpleListItem items + OrderedList (num, sty, _) items -> all isSimpleListItem items && + num == 1 && sty `elem` [DefaultStyle, Decimal] + _ -> False + +-- | True if list item can be handled with the simple wiki syntax. False if +-- HTML tags will be needed. +isSimpleListItem :: [Block] -> Bool +isSimpleListItem [] = True +isSimpleListItem [x] = + case x of + Plain _ -> True + Para _ -> True + BulletList _ -> isSimpleList x + OrderedList _ _ -> isSimpleList x + _ -> False +isSimpleListItem [x, y] | isPlainOrPara x = + case y of + BulletList _ -> isSimpleList y + OrderedList _ _ -> isSimpleList y + _ -> False +isSimpleListItem _ = False + +isPlainOrPara :: Block -> Bool +isPlainOrPara (Plain _) = True +isPlainOrPara (Para _) = True +isPlainOrPara _ = False + +-- | Concatenates strings with line breaks between them. +vcat :: [String] -> String +vcat = intercalate "\n" + +-- Auxiliary functions for tables. (TODO: these are common to HTML, MediaWiki, +-- and Textile writers, and should be abstracted out.) + +tableRowToTextile :: WriterOptions + -> [String] + -> Int + -> [[Block]] + -> State WriterState String +tableRowToTextile opts alignStrings rownum cols' = do + let celltype = if rownum == 0 then "th" else "td" + let rowclass = case rownum of + 0 -> "header" + x | x `rem` 2 == 1 -> "odd" + _ -> "even" + cols'' <- sequence $ zipWith + (\alignment item -> tableItemToTextile opts celltype alignment item) + alignStrings cols' + return $ "\n" ++ unlines cols'' ++ "" + +alignmentToString :: Alignment -> [Char] +alignmentToString alignment = case alignment of + AlignLeft -> "left" + AlignRight -> "right" + AlignCenter -> "center" + AlignDefault -> "left" + +tableItemToTextile :: WriterOptions + -> String + -> String + -> [Block] + -> State WriterState String +tableItemToTextile opts celltype align' item = do + let mkcell x = "<" ++ celltype ++ " align=\"" ++ align' ++ "\">" ++ + x ++ "" + contents <- blockListToTextile opts item + return $ mkcell contents + +-- | Convert list of Pandoc block elements to Textile. +blockListToTextile :: WriterOptions -- ^ Options + -> [Block] -- ^ List of block elements + -> State WriterState String +blockListToTextile opts blocks = + mapM (blockToTextile opts) blocks >>= return . vcat + +-- | Convert list of Pandoc inline elements to Textile. +inlineListToTextile :: WriterOptions -> [Inline] -> State WriterState String +inlineListToTextile opts lst = + mapM (inlineToTextile opts) lst >>= return . concat + +-- | Convert Pandoc inline element to Textile. +inlineToTextile :: WriterOptions -> Inline -> State WriterState String + +inlineToTextile opts (Emph lst) = do + contents <- inlineListToTextile opts lst + return $ if '_' `elem` contents + then "" ++ contents ++ "" + else "_" ++ contents ++ "_" + +inlineToTextile opts (Strong lst) = do + contents <- inlineListToTextile opts lst + return $ if '*' `elem` contents + then "" ++ contents ++ "" + else "*" ++ contents ++ "*" + +inlineToTextile opts (Strikeout lst) = do + contents <- inlineListToTextile opts lst + return $ if '-' `elem` contents + then "" ++ contents ++ "" + else "-" ++ contents ++ "-" + +inlineToTextile opts (Superscript lst) = do + contents <- inlineListToTextile opts lst + return $ if '^' `elem` contents + then "" ++ contents ++ "" + else "[^" ++ contents ++ "^]" + +inlineToTextile opts (Subscript lst) = do + contents <- inlineListToTextile opts lst + return $ if '~' `elem` contents + then "" ++ contents ++ "" + else "[~" ++ contents ++ "~]" + +inlineToTextile opts (SmallCaps lst) = inlineListToTextile opts lst + +inlineToTextile opts (Quoted SingleQuote lst) = do + contents <- inlineListToTextile opts lst + return $ "'" ++ contents ++ "'" + +inlineToTextile opts (Quoted DoubleQuote lst) = do + contents <- inlineListToTextile opts lst + return $ "\"" ++ contents ++ "\"" + +inlineToTextile opts (Cite _ lst) = inlineListToTextile opts lst + +inlineToTextile _ EmDash = return " -- " + +inlineToTextile _ EnDash = return " - " + +inlineToTextile _ Apostrophe = return "'" + +inlineToTextile _ Ellipses = return "..." + +inlineToTextile _ (Code _ str) = + return $ if '@' `elem` str + then "" ++ escapeStringForXML str ++ "" + else "@" ++ str ++ "@" + +inlineToTextile _ (Str str) = return $ escapeStringForTextile str + +inlineToTextile _ (Math _ str) = + return $ "" ++ escapeStringForXML str ++ "" + +inlineToTextile _ (RawInline f str) = + if f == "html" || f == "textile" + then return str + else return "" + +inlineToTextile _ (LineBreak) = return "\n" + +inlineToTextile _ Space = return " " + +inlineToTextile opts (Link txt (src, _)) = do + label <- case txt of + [Code _ s] -> return s + _ -> inlineListToTextile opts txt + return $ "\"" ++ label ++ "\":" ++ src + +inlineToTextile opts (Image alt (source, tit)) = do + alt' <- inlineListToTextile opts alt + let txt = if null tit + then if null alt' + then "" + else "(" ++ alt' ++ ")" + else "(" ++ tit ++ ")" + return $ "!" ++ source ++ txt ++ "!" + +inlineToTextile opts (Note contents) = do + curNotes <- liftM stNotes get + let newnum = length curNotes + 1 + contents' <- blockListToTextile opts contents + let thisnote = "fn" ++ show newnum ++ ". " ++ contents' ++ "\n" + modify $ \s -> s { stNotes = thisnote : curNotes } + return $ "[" ++ show newnum ++ "]" + -- note - may not work for notes with multiple blocks diff -Nru pandoc-1.5.1.1/src/Text/Pandoc/XML.hs pandoc-1.8.0.3/src/Text/Pandoc/XML.hs --- pandoc-1.5.1.1/src/Text/Pandoc/XML.hs 2010-03-29 14:24:56.000000000 +0000 +++ pandoc-1.8.0.3/src/Text/Pandoc/XML.hs 2011-02-05 18:48:07.000000000 +0000 @@ -34,7 +34,8 @@ selfClosingTag, inTagsSimple, inTagsIndented ) where -import Text.PrettyPrint.HughesPJ + +import Text.Pandoc.Pretty -- | Remove everything between <...> stripTags :: String -> String @@ -55,23 +56,15 @@ '"' -> """ c -> [c] --- | True if the character needs to be escaped. -needsEscaping :: Char -> Bool -needsEscaping c = c `elem` "&<>\"" - -- | Escape string as needed for XML. Entity references are not preserved. escapeStringForXML :: String -> String -escapeStringForXML "" = "" -escapeStringForXML str = - case break needsEscaping str of - (okay, "") -> okay - (okay, (c:cs)) -> okay ++ escapeCharForXML c ++ escapeStringForXML cs +escapeStringForXML = concatMap escapeCharForXML -- | Return a text object with a string of formatted XML attributes. attributeList :: [(String, String)] -> Doc -attributeList = text . concatMap - (\(a, b) -> " " ++ escapeStringForXML a ++ "=\"" ++ - escapeStringForXML b ++ "\"") +attributeList = hcat . map + (\(a, b) -> text (' ' : escapeStringForXML a ++ "=\"" ++ + escapeStringForXML b ++ "\"")) -- | Put the supplied contents between start and end tags of tagType, -- with specified attributes and (if specified) indentation. diff -Nru pandoc-1.5.1.1/src/Text/Pandoc.hs pandoc-1.8.0.3/src/Text/Pandoc.hs --- pandoc-1.5.1.1/src/Text/Pandoc.hs 2010-03-29 14:24:56.000000000 +0000 +++ pandoc-1.8.0.3/src/Text/Pandoc.hs 2011-02-05 18:48:07.000000000 +0000 @@ -57,11 +57,18 @@ ( -- * Definitions module Text.Pandoc.Definition + -- * Generics + , module Text.Pandoc.Generic + -- * Lists of readers and writers + , readers + , writers -- * Readers: converting /to/ Pandoc format , readMarkdown , readRST , readLaTeX , readHtml + , readTextile + , readNative -- * Parser state used in readers , ParserState (..) , defaultParserState @@ -71,6 +78,7 @@ , NoteTable , HeaderType (..) -- * Writers: converting /from/ Pandoc format + , writeNative , writeMarkdown , writePlain , writeRST @@ -79,46 +87,115 @@ , writeTexinfo , writeHtml , writeHtmlString - , writeS5 - , writeS5String , writeDocbook , writeOpenDocument , writeMan , writeMediaWiki + , writeTextile , writeRTF - , prettyPandoc + , writeODT + , writeEPUB + , writeOrg -- * Writer options used in writers , WriterOptions (..) + , HTMLSlideVariant (..) , HTMLMathMethod (..) + , CiteMethod (..) , defaultWriterOptions -- * Rendering templates and default templates , module Text.Pandoc.Templates -- * Version , pandocVersion + -- * Miscellaneous + , rtfEmbedImage + , jsonFilter ) where import Text.Pandoc.Definition +import Text.Pandoc.Generic import Text.Pandoc.Readers.Markdown import Text.Pandoc.Readers.RST import Text.Pandoc.Readers.LaTeX import Text.Pandoc.Readers.HTML +import Text.Pandoc.Readers.Textile +import Text.Pandoc.Readers.Native +import Text.Pandoc.Writers.Native import Text.Pandoc.Writers.Markdown import Text.Pandoc.Writers.RST import Text.Pandoc.Writers.LaTeX import Text.Pandoc.Writers.ConTeXt import Text.Pandoc.Writers.Texinfo import Text.Pandoc.Writers.HTML -import Text.Pandoc.Writers.S5 +import Text.Pandoc.Writers.ODT +import Text.Pandoc.Writers.EPUB import Text.Pandoc.Writers.Docbook import Text.Pandoc.Writers.OpenDocument import Text.Pandoc.Writers.Man import Text.Pandoc.Writers.RTF import Text.Pandoc.Writers.MediaWiki +import Text.Pandoc.Writers.Textile +import Text.Pandoc.Writers.Org import Text.Pandoc.Templates +import Text.Pandoc.Parsing import Text.Pandoc.Shared import Data.Version (showVersion) +import Text.JSON.Generic import Paths_pandoc (version) -- | Version number of pandoc library. pandocVersion :: String pandocVersion = showVersion version + +-- | 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}) + ,("textile" , readTextile) -- TODO : textile+lhs + ,("html" , readHtml) + ,("latex" , readLaTeX) + ,("latex+lhs" , \st -> + readLaTeX st{ stateLiterateHaskell = True}) + ] + +-- | Association list of formats and writers (omitting the +-- binary writers, odt and epub). +writers :: [ ( String, WriterOptions -> Pandoc -> String ) ] +writers = [("native" , writeNative) + ,("json" , \_ -> encodeJSON) + ,("html" , writeHtmlString) + ,("html+lhs" , \o -> + writeHtmlString o{ writerLiterateHaskell = True }) + ,("s5" , writeHtmlString) + ,("slidy" , writeHtmlString) + ,("docbook" , writeDocbook) + ,("opendocument" , writeOpenDocument) + ,("latex" , writeLaTeX) + ,("latex+lhs" , \o -> + writeLaTeX o{ 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) + ] + +-- | Converts a transformation on the Pandoc AST into a function +-- that reads and writes a JSON-encoded string. This is useful +-- for writing small scripts. +jsonFilter :: (Pandoc -> Pandoc) -> String -> String +jsonFilter f = encodeJSON . f . decodeJSON diff -Nru pandoc-1.5.1.1/templates/context.template pandoc-1.8.0.3/templates/context.template --- pandoc-1.5.1.1/templates/context.template 2010-03-29 14:24:56.000000000 +0000 +++ pandoc-1.8.0.3/templates/context.template 2011-02-05 18:48:07.000000000 +0000 @@ -1,6 +1,3 @@ -$if(legacy-header)$ -$legacy-header$ -$else$ \enableregime[utf] % use UTF-8 \setupcolors[state=start] @@ -52,7 +49,6 @@ ] \protect -$endif$ $for(header-includes)$ $header-includes$ $endfor$ diff -Nru pandoc-1.5.1.1/templates/docbook.template pandoc-1.8.0.3/templates/docbook.template --- pandoc-1.5.1.1/templates/docbook.template 2010-03-29 14:24:56.000000000 +0000 +++ pandoc-1.8.0.3/templates/docbook.template 2011-02-05 18:48:07.000000000 +0000 @@ -1,10 +1,6 @@ -$if(legacy-header)$ -$legacy-header$ -$else$ -$endif$
      $title$ @@ -25,4 +21,3 @@ $include-after$ $endfor$
      - diff -Nru pandoc-1.5.1.1/templates/html.template pandoc-1.8.0.3/templates/html.template --- pandoc-1.5.1.1/templates/html.template 2010-03-29 14:24:56.000000000 +0000 +++ pandoc-1.8.0.3/templates/html.template 2011-02-05 18:48:07.000000000 +0000 @@ -1,52 +1,60 @@ +$if(html5)$ + + +$else$ - + +$endif$ - $if(title-prefix)$$title-prefix$ - $endif$$if(pagetitle)$$pagetitle$$endif$ +$if(html5)$ + +$else$ +$endif$ $for(author)$ $endfor$ +$if(date)$ -$if(highlighting)$ +$endif$ + $if(title-prefix)$$title-prefix$ - $endif$$if(pagetitle)$$pagetitle$$endif$ +$if(html5)$ + +$endif$ +$if(highlighting-css)$ $endif$ $for(css)$ - + $endfor$ $if(math)$ +$if(html5)$ +$else$ $math$ $endif$ +$endif$ $for(header-includes)$ $header-includes$ $endfor$ -$if(title)$ -

      $title$

      -$endif$ $for(include-before)$ $include-before$ $endfor$ +$if(title)$ +$if(html5)$ +
      +$endif$ +

      $title$

      +$if(html5)$ +
      +$endif$ +$endif$ $if(toc)$ $toc$ $endif$ diff -Nru pandoc-1.5.1.1/templates/latex.template pandoc-1.8.0.3/templates/latex.template --- pandoc-1.5.1.1/templates/latex.template 2010-03-29 14:24:56.000000000 +0000 +++ pandoc-1.8.0.3/templates/latex.template 2011-02-05 18:48:07.000000000 +0000 @@ -1,8 +1,5 @@ -$if(legacy-header)$ -$legacy-header$ -$else$ -\documentclass{article} -\usepackage{amsmath} +\documentclass$if(fontsize)$[$fontsize$]$endif${article} +\usepackage{amssymb,amsmath} $if(xetex)$ \usepackage{ifxetex} \ifxetex @@ -16,11 +13,20 @@ \usepackage[mathletters]{ucs} \usepackage[utf8x]{inputenc} $endif$ +$if(natbib)$ +\usepackage{natbib} +\bibliographystyle{plainnat} +$endif$ +$if(biblatex)$ +\usepackage{biblatex} +$if(biblio-files)$ +\bibliography{$biblio-files$} +$endif$ +$endif$ $if(lhs)$ \usepackage{listings} \lstnewenvironment{code}{\lstset{language=Haskell,basicstyle=\small\ttfamily}}{} $endif$ -$endif$ $if(verbatim-in-note)$ \usepackage{fancyvrb} $endif$ @@ -41,6 +47,8 @@ $endif$ $if(strikeout)$ \usepackage[normalem]{ulem} +% avoid problems with \sout in headers with hyperref: +\pdfstringdefDisableCommands{\renewcommand{\sout}{}} $endif$ $if(subscript)$ \newcommand{\textsubscr}[1]{\ensuremath{_{\scriptsize\textrm{#1}}}} @@ -50,10 +58,22 @@ $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$ -\usepackage[breaklinks=true,unicode=true]{hyperref} +\usepackage[breaklinks=true,unicode=true,pdfborder={0 0 0}]{hyperref} \setlength{\parindent}{0pt} \setlength{\parskip}{6pt plus 2pt minus 1pt} +$if(listings)$ +\usepackage{listings} +$endif$ $if(numbersections)$ $else$ \setcounter{secnumdepth}{0} @@ -89,6 +109,21 @@ $endif$ $body$ +$if(biblio-files)$ +$if(natbib)$ +$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$ diff -Nru pandoc-1.5.1.1/templates/mediawiki.template pandoc-1.8.0.3/templates/mediawiki.template --- pandoc-1.5.1.1/templates/mediawiki.template 2010-03-29 14:24:56.000000000 +0000 +++ pandoc-1.8.0.3/templates/mediawiki.template 2011-02-05 18:48:07.000000000 +0000 @@ -1,6 +1,3 @@ -$if(legacy-header)$ -$legacy-header$ -$endif$ $for(include-before)$ $include-before$ diff -Nru pandoc-1.5.1.1/templates/org.template pandoc-1.8.0.3/templates/org.template --- pandoc-1.5.1.1/templates/org.template 1970-01-01 00:00:00.000000000 +0000 +++ pandoc-1.8.0.3/templates/org.template 2011-02-05 18:48:07.000000000 +0000 @@ -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$ diff -Nru pandoc-1.5.1.1/templates/rtf.template pandoc-1.8.0.3/templates/rtf.template --- pandoc-1.5.1.1/templates/rtf.template 2010-03-29 14:24:56.000000000 +0000 +++ pandoc-1.8.0.3/templates/rtf.template 2011-02-05 18:48:07.000000000 +0000 @@ -1,10 +1,6 @@ -$if(legacy-header)$ -$legacy-header$ -$else$ {\rtf1\ansi\deff0{\fonttbl{\f0 \fswiss Helvetica;}{\f1 Courier;}} {\colortbl;\red255\green0\blue0;\red0\green0\blue255;} \widowctrl\hyphauto -$endif$ $for(header-includes)$ $header-includes$ $endfor$ diff -Nru pandoc-1.5.1.1/templates/s5.template pandoc-1.8.0.3/templates/s5.template --- pandoc-1.5.1.1/templates/s5.template 1970-01-01 00:00:00.000000000 +0000 +++ pandoc-1.8.0.3/templates/s5.template 2011-02-05 18:48:07.000000000 +0000 @@ -0,0 +1,69 @@ + + + + + +$for(author)$ + +$endfor$ +$if(date)$ + +$endif$ + $if(title-prefix)$$title-prefix$ - $endif$$if(pagetitle)$$pagetitle$$endif$ + + + +$if(highlighting-css)$ + +$endif$ +$for(css)$ + +$endfor$ +$if(s5includes)$ +$s5includes$ +$else$ + + + + + + + +$endif$ +$if(math)$ + $math$ +$endif$ +$for(header-includes)$ + $header-includes$ +$endfor$ + + +$for(include-before)$ +$include-before$ +$endfor$ +
      +
      +
      + + +
      +
      +$if(title)$ +
      +

      $title$

      +

      $for(author)$$author$$sep$
      $endfor$

      +

      $date$

      +
      +$endif$ +$body$ +$for(include-after)$ +$include-after$ +$endfor$ +
      + + diff -Nru pandoc-1.5.1.1/templates/slidy.template pandoc-1.8.0.3/templates/slidy.template --- pandoc-1.5.1.1/templates/slidy.template 1970-01-01 00:00:00.000000000 +0000 +++ pandoc-1.8.0.3/templates/slidy.template 2011-02-05 18:48:07.000000000 +0000 @@ -0,0 +1,66 @@ + + + + + + +$for(author)$ + +$endfor$ +$if(date)$ + +$endif$ +$if(highlighting-css)$ + $if(title-prefix)$$title-prefix$ - $endif$$if(pagetitle)$$pagetitle$$endif$ + +$endif$ +$for(css)$ + +$endfor$ +$if(slidy-css)$ + +$else$ + +$endif$ +$if(math)$ + $math$ +$endif$ +$for(header-includes)$ + $header-includes$ +$endfor$ +$if(slidy-js)$ + +$else$ + +$endif$ + + +$for(include-before)$ +$include-before$ +$endfor$ +$if(title)$ +
      +

      $title$

      +

      +$for(author)$$author$$sep$
      $endfor$ +

      +$if(date)$ +

      $date$

      +$endif$ +
      +$endif$ +$body$ +$for(include-after)$ +$include-after$ +$endfor$ + + diff -Nru pandoc-1.5.1.1/templates/texinfo.template pandoc-1.8.0.3/templates/texinfo.template --- pandoc-1.5.1.1/templates/texinfo.template 2010-03-29 14:24:56.000000000 +0000 +++ pandoc-1.8.0.3/templates/texinfo.template 2011-02-05 18:48:07.000000000 +0000 @@ -1,9 +1,5 @@ -$if(legacy-header)$ -$legacy-header$ -$else$ \input texinfo @documentencoding utf-8 -$endif$ $for(header-includes)$ $header-includes$ $endfor$ diff -Nru pandoc-1.5.1.1/templates/textile.template pandoc-1.8.0.3/templates/textile.template --- pandoc-1.5.1.1/templates/textile.template 1970-01-01 00:00:00.000000000 +0000 +++ pandoc-1.8.0.3/templates/textile.template 2011-02-05 18:48:07.000000000 +0000 @@ -0,0 +1,9 @@ +$for(include-before)$ +$include-before$ + +$endfor$ +$body$ +$for(include-after)$ + +$include-after$ +$endfor$ diff -Nru pandoc-1.5.1.1/tests/biblio.bib pandoc-1.8.0.3/tests/biblio.bib --- pandoc-1.5.1.1/tests/biblio.bib 1970-01-01 00:00:00.000000000 +0000 +++ pandoc-1.8.0.3/tests/biblio.bib 2011-02-05 18:48:07.000000000 +0000 @@ -0,0 +1,26 @@ +@Book{item1, +author="John Doe", +title="First Book", +year="2005", +address="Cambridge", +publisher="Cambridge University Press" +} + +@Article{item2, +author="John Doe", +title="Article", +year="2006", +journal="Journal of Generic Studies", +volume="6", +pages="33-34" +} + +@InCollection{item3, +author="John Doe and Jenny Roe", +title="Why Water Is Wet", +booktitle="Third Book", +editor="Sam Smith", +publisher="Oxford University Press", +address="Oxford", +year="2007" +} diff -Nru pandoc-1.5.1.1/tests/chicago-author-date.csl pandoc-1.8.0.3/tests/chicago-author-date.csl --- pandoc-1.5.1.1/tests/chicago-author-date.csl 1970-01-01 00:00:00.000000000 +0000 +++ pandoc-1.8.0.3/tests/chicago-author-date.csl 2011-02-05 18:48:07.000000000 +0000 @@ -0,0 +1,369 @@ + + diff -Nru pandoc-1.5.1.1/tests/html-reader.html pandoc-1.8.0.3/tests/html-reader.html --- pandoc-1.5.1.1/tests/html-reader.html 2010-03-29 14:24:56.000000000 +0000 +++ pandoc-1.8.0.3/tests/html-reader.html 2011-02-05 18:48:07.000000000 +0000 @@ -340,7 +340,7 @@

      So is this word.

      This is strong and em.

      So is this word.

      -

      This is code: >, $, \, \$, <html>.

      +

      This is code: >, $, \, \$, <html>.


      Smart quotes, ellipses, dashes

      "Hello," said the spider. "'Shelob' is my name."

      @@ -442,8 +442,8 @@ An e-mail address: nobody [at] nowhere.net

      Blockquoted: http://example.com/

      -

      Auto-links should not occur here: <http://example.com/>

      -
      or here: <http://example.com/>
      +

      Auto-links should not occur here: <http://example.com/>

      +
      or here: <http://example.com/>
       

      Images

      diff -Nru pandoc-1.5.1.1/tests/html-reader.native pandoc-1.8.0.3/tests/html-reader.native --- pandoc-1.5.1.1/tests/html-reader.native 2010-03-29 14:24:56.000000000 +0000 +++ pandoc-1.8.0.3/tests/html-reader.native 2011-02-05 18:48:07.000000000 +0000 @@ -1,347 +1,339 @@ 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.",Space,Str "Most",Space,Str "of",Space,Str "them",Space,Str "are",Space,Str "adapted",Space,Str "from",Space,Str "John",Space,Str "Gruber's",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"] -, Para [Str "with",Space,Str "no",Space,Str "blank",Space,Str "line"] -, Header 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's",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's",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,Space,Str "here."] -, HorizontalRule -, 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."] ] - -, BlockQuote - [ 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:"] - , OrderedList (1,DefaultStyle,DefaultDelim) - [ [ Plain [Str "item",Space,Str "one"] ] - , [ Plain [Str "item",Space,Str "two"] ] ] - , 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:",Space,Str "2",Space,Str ">",Space,Str "1."] -, Para [Str "Box-style:"] -, BlockQuote - [ Para [Str "Example:"] - , CodeBlock ("",[],[]) "sub status {\n print \"working\";\n}" ] -, BlockQuote - [ OrderedList (1,DefaultStyle,DefaultDelim) - [ [ Plain [Str "do",Space,Str "laundry"] ] - , [ Plain [Str "take",Space,Str "out",Space,Str "the",Space,Str "trash"] ] ] ] -, Para [Str "Here's",Space,Str "a",Space,Str "nested",Space,Str "one:"] -, BlockQuote - [ Para [Str "Joe",Space,Str "said:"] - , BlockQuote - [ Para [Str "Don't",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"] -, 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"] -, 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:"] -, 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:"] -, 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:"] -, 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:"] -, 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:"] -, 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:"] -, OrderedList (1,DefaultStyle,DefaultDelim) - [ [ Plain [Str "First"] ] - , [ Plain [Str "Second"] ] - , [ Plain [Str "Third"] ] ] -, Para [Str "and:"] -, OrderedList (1,DefaultStyle,DefaultDelim) - [ [ Plain [Str "One"] ] - , [ Plain [Str "Two"] ] - , [ Plain [Str "Three"] ] ] -, Para [Str "Loose",Space,Str "using",Space,Str "tabs:"] -, OrderedList (1,DefaultStyle,DefaultDelim) - [ [ Para [Str "First"] ] - , [ Para [Str "Second"] ] - , [ Para [Str "Third"] ] ] -, Para [Str "and",Space,Str "using",Space,Str "spaces:"] -, OrderedList (1,DefaultStyle,DefaultDelim) - [ [ Para [Str "One"] ] - , [ Para [Str "Two"] ] - , [ Para [Str "Three"] ] ] -, Para [Str "Multiple",Space,Str "paragraphs:"] -, OrderedList (1,DefaultStyle,DefaultDelim) - [ [ 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's",Space,Str "back."] ], [ Para [Str "Item",Space,Str "2."] ] - , [ Para [Str "Item",Space,Str "3."] ] ] -, Header 2 [Str "Nested"] -, BulletList - [ [ Plain [Str "Tab"] - , BulletList - [ [ Plain [Str "Tab"] - , BulletList - [ [ Plain [Str "Tab"] ] - ] ] ] ] ] -, Para [Str "Here's",Space,Str "another:"] -, OrderedList (1,DefaultStyle,DefaultDelim) - [ [ Plain [Str "First"] ] - , [ 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:"] -, OrderedList (1,DefaultStyle,DefaultDelim) - [ [ Para [Str "First"] ] - , [ 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"] -, 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"] -, OrderedList (2,Decimal,DefaultDelim) - [ [ 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,DefaultDelim) - [ [ 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,DefaultDelim) - [ [ Plain [Str "a",Space,Str "subsublist"] ] - , [ Plain [Str "a",Space,Str "subsublist"] ] ] ] ] ] ] -, Para [Str "Nesting:"] -, OrderedList (1,UpperAlpha,DefaultDelim) - [ [ Plain [Str "Upper",Space,Str "Alpha"] - , OrderedList (1,UpperRoman,DefaultDelim) - [ [ Plain [Str "Upper",Space,Str "Roman."] - , OrderedList (6,Decimal,DefaultDelim) - [ [ Plain [Str "Decimal",Space,Str "start",Space,Str "with",Space,Str "6"] - , OrderedList (3,LowerAlpha,DefaultDelim) - [ [ Plain [Str "Lower",Space,Str "alpha",Space,Str "with",Space,Str "paren"] ] - ] ] ] ] ] ] ] -, Para [Str "Autonumbering:"] -, OrderedList (1,DefaultStyle,DefaultDelim) - [ [ Plain [Str "Autonumber."] ] - , [ Plain [Str "More."] - , OrderedList (1,DefaultStyle,DefaultDelim) - [ [ Plain [Str "Nested."] ] - ] ] ] -, HorizontalRule -, Header 2 [Str "Definition"] -, DefinitionList - [ ([Str "Violin"], - [ [ Plain [Str "Stringed",Space,Str "musical",Space,Str "instrument."] ] - , [ Plain [Str "Torture",Space,Str "device."] ] - ]) - , ([Str "Cello",LineBreak,Str "Violoncello"], - [ [ Plain [Str "Low-voiced",Space,Str "stringed",Space,Str "instrument."] ] - ]) ] -, HorizontalRule -, Header 1 [Str "HTML",Space,Str "Blocks"] -, Para [Str "Simple",Space,Str "block",Space,Str "on",Space,Str "one",Space,Str "line:"] -, Plain [Str "foo"] -, Para [Str "And",Space,Str "nested",Space,Str "without",Space,Str "indentation:"] -, Plain [Str "foobar"] -, Para [Str "Interpreted",Space,Str "markdown",Space,Str "in",Space,Str "a",Space,Str "table:"] -, Plain [Str "This",Space,Str "is",Space,Emph [Str "emphasized"],Str ".",Space,Str "And",Space,Str "this",Space,Str "is",Space,Strong [Str "strong"]] -, Para [Str "Here's",Space,Str "a",Space,Str "simple",Space,Str "block:"] -, Plain [Str "foo"] -, Para [Str "This",Space,Str "should",Space,Str "be",Space,Str "a",Space,Str "code",Space,Str "block,",Space,Str "though:"] -, CodeBlock ("",[],[]) "
      \n foo\n
      " -, Para [Str "As",Space,Str "should",Space,Str "this:"] -, CodeBlock ("",[],[]) "
      foo
      " -, Para [Str "Now,",Space,Str "nested:"] -, Plain [Str "foo"] -, Para [Str "This",Space,Str "should",Space,Str "just",Space,Str "be",Space,Str "an",Space,Str "HTML",Space,Str "comment:"] -, Para [Str "Multiline:"] -, Para [Str "Code",Space,Str "block:"] -, CodeBlock ("",[],[]) "" -, 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:"] -, Para [Str "Code:"] -, CodeBlock ("",[],[]) "
      " -, Para [Str "Hr's:"] -, HorizontalRule -, HorizontalRule -, HorizontalRule -, HorizontalRule -, HorizontalRule -, HorizontalRule -, HorizontalRule -, HorizontalRule -, HorizontalRule -, HorizontalRule -, 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 "."] -, 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 "",Str "."] -, HorizontalRule -, Header 1 [Str "Smart",Space,Str "quotes,",Space,Str "ellipses,",Space,Str "dashes"] -, Para [Str "\"Hello,\"",Space,Str "said",Space,Str "the",Space,Str "spider.",Space,Str "\"'Shelob'",Space,Str "is",Space,Str "my",Space,Str "name.\""] -, Para [Str "'A',",Space,Str "'B',",Space,Str "and",Space,Str "'C'",Space,Str "are",Space,Str "letters."] -, Para [Str "'Oak,'",Space,Str "'elm,'",Space,Str "and",Space,Str "'beech'",Space,Str "are",Space,Str "names",Space,Str "of",Space,Str "trees.",Space,Str "So",Space,Str "is",Space,Str "'pine.'"] -, Para [Str "'He",Space,Str "said,",Space,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's?"] -, Para [Str "Here",Space,Str "is",Space,Str "some",Space,Str "quoted",Space,Str "'",Code "code",Str "'",Space,Str "and",Space,Str "a",Space,Str "\"",Link [Str "quoted",Space,Str "link"] ("http://example.com/?foo=1&bar=2",""),Str "\"."] -, Para [Str "Some",Space,Str "dashes:",Space,Str "one---two",Space,Str "---",Space,Str "three--four",Space,Str "--",Space,Str "five."] -, Para [Str "Dashes",Space,Str "between",Space,Str "numbers:",Space,Str "5-7,",Space,Str "255-66,",Space,Str "1987-1999."] -, Para [Str "Ellipses...and.",Space,Str ".",Space,Str ".and",Space,Str ".",Space,Str ".",Space,Str ".",Space,Str "."] -, HorizontalRule -, Header 1 [Str "LaTeX"] -, BulletList - [ [ Plain [Str "\\cite[22-23]{smith.1899}"] ] - , [ Plain [Str "\\doublespacing"] ] - , [ Plain [Str "$2+2=4$"] ] - , [ Plain [Str "$x",Space,Str "\\in",Space,Str "y$"] ] - , [ Plain [Str "$\\alpha",Space,Str "\\wedge",Space,Str "\\omega$"] ] - , [ Plain [Str "$223$"] ] - , [ Plain [Str "$p$-Tree"] ] - , [ Plain [Str "$\\frac{d}{dx}f(x)=\\lim_{h\\to",Space,Str "0}\\frac{f(x+h)-f(x)}{h}$"] ] - , [ Plain [Str "Here's",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,Str "$\\alpha",Space,Str "+",Space,Str "\\omega",Space,Str "\\times",Space,Str "x^2$."] ] ] -, Para [Str "These",Space,Str "shouldn't",Space,Str "be",Space,Str "math:"] -, BulletList - [ [ 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,Str "\"lot\"",Space,Str "is",Space,Str "emphasized.)"] ] - , [ 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'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"] -, Para [Str "Here",Space,Str "is",Space,Str "some",Space,Str "unicode:"] -, BulletList - [ [ 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",Str "&",Str "T",Space,Str "has",Space,Str "an",Space,Str "ampersand",Space,Str "in",Space,Str "their",Space,Str "name."] -, Para [Str "AT",Str "&",Str "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"] -, 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")] -, Plain [Str "Email",Space,Str "link",Space,Str "(nobody",Space,Str "[at]",Space,Str "nowhere.net)"] -, Para [Link [Str "Empty"] ("",""),Str "."] -, 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 "."] -, 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 "[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"] -, Para [Str "Here'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'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",Str "&",Str "T"] ("http://att.com/","AT&T"),Str "."] -, Para [Str "Here's",Space,Str "an",Space,Link [Str "inline",Space,Str "link"] ("/script?foo=1&bar=2",""),Str "."] -, Para [Str "Here'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"] -, Para [Str "With",Space,Str "an",Space,Str "ampersand:",Space,Link [Str "http://example.com/?foo=1",Str "&",Str "bar=2"] ("http://example.com/?foo=1&bar=2","")] -, BulletList - [ [ Plain [Str "In",Space,Str "a",Space,Str "list?"] ] - , [ Plain [Link [Str "http://example.com/"] ("http://example.com/","")] ] - , [ Plain [Str "It",Space,Str "should."] ] ] -, Plain [Str "An",Space,Str "e-mail",Space,Str "address:",Space,Str "nobody",Space,Str "[at]",Space,Str "nowhere.net"] -, BlockQuote - [ 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 ""] -, CodeBlock ("",[],[]) "or here: " -, HorizontalRule -, Header 1 [Str "Images"] -, Para [Str "From",Space,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","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",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)."] -, Para [Link [Str "(1)"] ("#ref_1",""),Space,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 "in",Space,Str "the",Space,Str "document,",Space,Str "not",Space,Str "just",Space,Str "at",Space,Str "the",Space,Str "end."] -, Para [Link [Str "(longnote)"] ("#ref_longnote",""),Space,Str "Here's",Space,Str "the",Space,Str "other",Space,Str "note.",Space,Str "This",Space,Str "one",Space,Str "contains",Space,Str "multiple",Space,Str "blocks."] -, Para [Str "Caret",Space,Str "characters",Space,Str "are",Space,Str "used",Space,Str "to",Space,Str "indicate",Space,Str "that",Space,Str "the",Space,Str "blocks",Space,Str "all",Space,Str "belong",Space,Str "to",Space,Str "a",Space,Str "single",Space,Str "footnote",Space,Str "(as",Space,Str "with",Space,Str "block",Space,Str "quotes)."] -, CodeBlock ("",[],[]) " { }" -, Para [Str "If",Space,Str "you",Space,Str "want,",Space,Str "you",Space,Str "can",Space,Str "use",Space,Str "a",Space,Str "caret",Space,Str "at",Space,Str "the",Space,Str "beginning",Space,Str "of",Space,Str "every",Space,Str "line,",Space,Str "as",Space,Str "with",Space,Str "blockquotes,",Space,Str "but",Space,Str "all",Space,Str "that",Space,Str "you",Space,Str "need",Space,Str "is",Space,Str "a",Space,Str "caret",Space,Str "at",Space,Str "the",Space,Str "beginning",Space,Str "of",Space,Str "the",Space,Str "first",Space,Str "line",Space,Str "of",Space,Str "the",Space,Str "block",Space,Str "and",Space,Str "any",Space,Str "preceding",Space,Str "blank",Space,Str "lines."] ] - +[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"] +,Para [Str "with",Space,Str "no",Space,Str "blank",Space,Str "line"] +,Header 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",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"] +,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 "."]] +,BlockQuote + [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:"] + ,OrderedList (1,DefaultStyle,DefaultDelim) + [[Plain [Str "item",Space,Str "one"]] + ,[Plain [Str "item",Space,Str "two"]]] + ,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:",Space,Str "2",Space,Str ">",Space,Str "1",Str "."] +,Para [Str "Box",Str "-",Str "style:"] +,BlockQuote + [Para [Str "Example:"] + ,CodeBlock ("",[],[]) "sub status {\n print \"working\";\n}"] +,BlockQuote + [OrderedList (1,DefaultStyle,DefaultDelim) + [[Plain [Str "do",Space,Str "laundry"]] + ,[Plain [Str "take",Space,Str "out",Space,Str "the",Space,Str "trash"]]]] +,Para [Str "Here",Str "'",Str "s",Space,Str "a",Space,Str "nested",Space,Str "one:"] +,BlockQuote + [Para [Str "Joe",Space,Str "said:"] + ,BlockQuote + [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"] +,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"] +,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:"] +,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:"] +,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:"] +,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:"] +,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:"] +,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:"] +,OrderedList (1,DefaultStyle,DefaultDelim) + [[Plain [Str "First"]] + ,[Plain [Str "Second"]] + ,[Plain [Str "Third"]]] +,Para [Str "and:"] +,OrderedList (1,DefaultStyle,DefaultDelim) + [[Plain [Str "One"]] + ,[Plain [Str "Two"]] + ,[Plain [Str "Three"]]] +,Para [Str "Loose",Space,Str "using",Space,Str "tabs:"] +,OrderedList (1,DefaultStyle,DefaultDelim) + [[Para [Str "First"]] + ,[Para [Str "Second"]] + ,[Para [Str "Third"]]] +,Para [Str "and",Space,Str "using",Space,Str "spaces:"] +,OrderedList (1,DefaultStyle,DefaultDelim) + [[Para [Str "One"]] + ,[Para [Str "Two"]] + ,[Para [Str "Three"]]] +,Para [Str "Multiple",Space,Str "paragraphs:"] +,OrderedList (1,DefaultStyle,DefaultDelim) + [[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 "'",Str "s",Space,Str "back",Str "."]] + ,[Para [Str "Item",Space,Str "2",Str "."]] + ,[Para [Str "Item",Space,Str "3",Str "."]]] +,Header 2 [Str "Nested"] +,BulletList + [[Plain [Str "Tab"] + ,BulletList + [[Plain [Str "Tab"] + ,BulletList + [[Plain [Str "Tab"]]]]]]] +,Para [Str "Here",Str "'",Str "s",Space,Str "another:"] +,OrderedList (1,DefaultStyle,DefaultDelim) + [[Plain [Str "First"]] + ,[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:"] +,OrderedList (1,DefaultStyle,DefaultDelim) + [[Para [Str "First"]] + ,[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"] +,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"] +,OrderedList (2,Decimal,DefaultDelim) + [[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,DefaultDelim) + [[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,DefaultDelim) + [[Plain [Str "a",Space,Str "subsublist"]] + ,[Plain [Str "a",Space,Str "subsublist"]]]]]]] +,Para [Str "Nesting:"] +,OrderedList (1,UpperAlpha,DefaultDelim) + [[Plain [Str "Upper",Space,Str "Alpha"] + ,OrderedList (1,UpperRoman,DefaultDelim) + [[Plain [Str "Upper",Space,Str "Roman",Str "."] + ,OrderedList (6,Decimal,DefaultDelim) + [[Plain [Str "Decimal",Space,Str "start",Space,Str "with",Space,Str "6"] + ,OrderedList (3,LowerAlpha,DefaultDelim) + [[Plain [Str "Lower",Space,Str "alpha",Space,Str "with",Space,Str "paren"]]]]]]]]] +,Para [Str "Autonumbering:"] +,OrderedList (1,DefaultStyle,DefaultDelim) + [[Plain [Str "Autonumber",Str "."]] + ,[Plain [Str "More",Str "."] + ,OrderedList (1,DefaultStyle,DefaultDelim) + [[Plain [Str "Nested",Str "."]]]]] +,HorizontalRule +,Header 2 [Str "Definition"] +,DefinitionList + [([Str "Violin"], + [[Plain [Str "Stringed",Space,Str "musical",Space,Str "instrument",Str "."]] + ,[Plain [Str "Torture",Space,Str "device",Str "."]]]) + ,([Str "Cello",LineBreak,Str "Violoncello"], + [[Plain [Str "Low",Str "-",Str "voiced",Space,Str "stringed",Space,Str "instrument",Str "."]]])] +,HorizontalRule +,Header 1 [Str "HTML",Space,Str "Blocks"] +,Para [Str "Simple",Space,Str "block",Space,Str "on",Space,Str "one",Space,Str "line:"] +,Plain [Str "foo"] +,Para [Str "And",Space,Str "nested",Space,Str "without",Space,Str "indentation:"] +,Plain [Str "foobar"] +,Para [Str "Interpreted",Space,Str "markdown",Space,Str "in",Space,Str "a",Space,Str "table:"] +,Plain [Str "This",Space,Str "is",Space,Emph [Str "emphasized"],Str ".",Space,Str "And",Space,Str "this",Space,Str "is",Space,Strong [Str "strong"]] +,Para [Str "Here",Str "'",Str "s",Space,Str "a",Space,Str "simple",Space,Str "block:"] +,Plain [Str "foo"] +,Para [Str "This",Space,Str "should",Space,Str "be",Space,Str "a",Space,Str "code",Space,Str "block,",Space,Str "though:"] +,CodeBlock ("",[],[]) "
      \n foo\n
      " +,Para [Str "As",Space,Str "should",Space,Str "this:"] +,CodeBlock ("",[],[]) "
      foo
      " +,Para [Str "Now,",Space,Str "nested:"] +,Plain [Str "foo"] +,Para [Str "This",Space,Str "should",Space,Str "just",Space,Str "be",Space,Str "an",Space,Str "HTML",Space,Str "comment:"] +,Para [Str "Multiline:"] +,Para [Str "Code",Space,Str "block:"] +,CodeBlock ("",[],[]) "" +,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:"] +,Para [Str "Code:"] +,CodeBlock ("",[],[]) "
      " +,Para [Str "Hr",Str "'",Str "s:"] +,HorizontalRule +,HorizontalRule +,HorizontalRule +,HorizontalRule +,HorizontalRule +,HorizontalRule +,HorizontalRule +,HorizontalRule +,HorizontalRule +,HorizontalRule +,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 "."] +,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:",Space,Code ("",[],[]) ">",Str ",",Space,Code ("",[],[]) "$",Str ",",Space,Code ("",[],[]) "\\",Str ",",Space,Code ("",[],[]) "\\$",Str ",",Space,Code ("",[],[]) "",Str "."] +,HorizontalRule +,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 "'"] +,Para [Str "'",Str "He",Space,Str "said,",Space,Str "\"",Str "I",Space,Str "want",Space,Str "to",Space,Str "go",Str ".",Str "\"",Str "'",Space,Str "Were",Space,Str "you",Space,Str "alive",Space,Str "in",Space,Str "the",Space,Str "70",Str "'",Str "s?"] +,Para [Str "Here",Space,Str "is",Space,Str "some",Space,Str "quoted",Space,Str "'",Code ("",[],[]) "code",Str "'",Space,Str "and",Space,Str "a",Space,Str "\"",Link [Str "quoted",Space,Str "link"] ("http://example.com/?foo=1&bar=2",""),Str "\"",Str "."] +,Para [Str "Some",Space,Str "dashes:",Space,Str "one",Str "-",Str "-",Str "-",Str "two",Space,Str "-",Str "-",Str "-",Space,Str "three",Str "-",Str "-",Str "four",Space,Str "-",Str "-",Space,Str "five",Str "."] +,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"] +,BulletList + [[Plain [Str "\\cite[22",Str "-",Str "23]{smith",Str ".",Str "1899}"]] + ,[Plain [Str "\\doublespacing"]] + ,[Plain [Str "$2+2=4$"]] + ,[Plain [Str "$x",Space,Str "\\in",Space,Str "y$"]] + ,[Plain [Str "$\\alpha",Space,Str "\\wedge",Space,Str "\\omega$"]] + ,[Plain [Str "$223$"]] + ,[Plain [Str "$p$",Str "-",Str "Tree"]] + ,[Plain [Str "$\\frac{d}{dx}f(x)=\\lim_{h\\to",Space,Str "0}\\frac{f(x+h)",Str "-",Str "f(x)}{h}$"]] + ,[Plain [Str "Here",Str "'",Str "s",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,Str "$\\alpha",Space,Str "+",Space,Str "\\omega",Space,Str "\\times",Space,Str "x^2$",Str "."]]] +,Para [Str "These",Space,Str "shouldn",Str "'",Str "t",Space,Str "be",Space,Str "math:"] +,BulletList + [[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",Str ".",Space,Str "So",Space,Str "is",Space,Str "$34,000",Str ".",Space,Str "(It",Space,Str "worked",Space,Str "if",Space,Str "\"",Str "lot",Str "\"",Space,Str "is",Space,Str "emphasized",Str ".",Str ")"]] + ,[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$",Str "."]]] +,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"] +,Para [Str "Here",Space,Str "is",Space,Str "some",Space,Str "unicode:"] +,BulletList + [[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",Str "."] +,Para [Str "AT&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:",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",Str "-",Str "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"] +,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")] +,Plain [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"] +,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 "[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",Str "."] +,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 "[not]",Space,Str "be",Space,Str "a",Space,Str "link",Str "."] +,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"] +,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"] +,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?"]] + ,[Plain [Link [Str "http://example",Str ".",Str "com/"] ("http://example.com/","")]] + ,[Plain [Str "It",Space,Str "should",Str "."]]] +,Plain [Str "An",Space,Str "e",Str "-",Str "mail",Space,Str "address:",Space,Str "nobody",Space,Str "[at]",Space,Str "nowhere",Str ".",Str "net"] +,BlockQuote + [Para [Str "Blockquoted:",Space,Link [Str "http://example",Str ".",Str "com/"] ("http://example.com/","")]] +,Para [Str "Auto",Str "-",Str "links",Space,Str "should",Space,Str "not",Space,Str "occur",Space,Str "here:",Space,Code ("",[],[]) ""] +,CodeBlock ("",[],[]) "or here: " +,HorizontalRule +,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"] +,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 "."] +,Para [Str "Caret",Space,Str "characters",Space,Str "are",Space,Str "used",Space,Str "to",Space,Str "indicate",Space,Str "that",Space,Str "the",Space,Str "blocks",Space,Str "all",Space,Str "belong",Space,Str "to",Space,Str "a",Space,Str "single",Space,Str "footnote",Space,Str "(as",Space,Str "with",Space,Str "block",Space,Str "quotes)",Str "."] +,CodeBlock ("",[],[]) " { }" +,Para [Str "If",Space,Str "you",Space,Str "want,",Space,Str "you",Space,Str "can",Space,Str "use",Space,Str "a",Space,Str "caret",Space,Str "at",Space,Str "the",Space,Str "beginning",Space,Str "of",Space,Str "every",Space,Str "line,",Space,Str "as",Space,Str "with",Space,Str "blockquotes,",Space,Str "but",Space,Str "all",Space,Str "that",Space,Str "you",Space,Str "need",Space,Str "is",Space,Str "a",Space,Str "caret",Space,Str "at",Space,Str "the",Space,Str "beginning",Space,Str "of",Space,Str "the",Space,Str "first",Space,Str "line",Space,Str "of",Space,Str "the",Space,Str "block",Space,Str "and",Space,Str "any",Space,Str "preceding",Space,Str "blank",Space,Str "lines",Str "."]] diff -Nru pandoc-1.5.1.1/tests/ieee.csl pandoc-1.8.0.3/tests/ieee.csl --- pandoc-1.5.1.1/tests/ieee.csl 1970-01-01 00:00:00.000000000 +0000 +++ pandoc-1.8.0.3/tests/ieee.csl 2011-02-05 18:48:07.000000000 +0000 @@ -0,0 +1,129 @@ + + \ No newline at end of file diff -Nru pandoc-1.5.1.1/tests/latex-reader.latex pandoc-1.8.0.3/tests/latex-reader.latex --- pandoc-1.5.1.1/tests/latex-reader.latex 2010-03-29 14:24:56.000000000 +0000 +++ pandoc-1.8.0.3/tests/latex-reader.latex 2011-02-05 18:48:07.000000000 +0000 @@ -7,6 +7,8 @@ \newcommand{\textsubscript}[1]{\ensuremath{_{\scriptsize\textrm{#1}}}} \usepackage[breaklinks=true,unicode=true]{hyperref} \usepackage[normalem]{ulem} +% avoid problems with \sout in headers with hyperref: +\pdfstringdefDisableCommands{\renewcommand{\sout}{}} \usepackage{enumerate} \usepackage{fancyvrb} \usepackage{graphicx} @@ -71,7 +73,7 @@ This is a block quote. It is pretty short. \end{quote} -\begin{quote} +\begin {quote} Code in a block quote: \begin{verbatim} diff -Nru pandoc-1.5.1.1/tests/latex-reader.native pandoc-1.8.0.3/tests/latex-reader.native --- pandoc-1.5.1.1/tests/latex-reader.native 2010-03-29 14:24:56.000000000 +0000 +++ pandoc-1.8.0.3/tests/latex-reader.native 2011-02-05 18:48:07.000000000 +0000 @@ -1,378 +1,366 @@ 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",Apostrophe,Str "s",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"]] -, 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"] -, Para [Str "with",Space,Str "no",Space,Str "blank",Space,Str "line"] -, Header 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",Apostrophe,Str "s",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",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."] -, Para [Str "Here",Apostrophe,Str "s",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:"] -, 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."] ] - -, BlockQuote - [ 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:"] - , OrderedList (1,Decimal,Period) - [ [ Para [Str "item",Space,Str "one"] ] - , [ Para [Str "item",Space,Str "two"] ] ] - , 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:",Space,Str "2",Space,Str ">",Space,Str "1."] -, Para [Str "Box",Str "-",Str "style:"] -, BlockQuote - [ Para [Str "Example:"] - , CodeBlock ("",[],[]) "sub status {\n print \"working\";\n}" ] -, BlockQuote - [ OrderedList (1,Decimal,Period) - [ [ Para [Str "do",Space,Str "laundry"] ] - , [ Para [Str "take",Space,Str "out",Space,Str "the",Space,Str "trash"] ] ] ] -, Para [Str "Here",Apostrophe,Str "s",Space,Str "a",Space,Str "nested",Space,Str "one:"] -, BlockQuote - [ Para [Str "Joe",Space,Str "said:"] - , BlockQuote - [ Para [Str "Don",Apostrophe,Str "t",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"] -, 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"] -, Para [Str "Asterisks",Space,Str "tight:"] -, BulletList - [ [ Para [Str "asterisk",Space,Str "1"] ] - , [ Para [Str "asterisk",Space,Str "2"] ] - , [ Para [Str "asterisk",Space,Str "3"] ] ] -, 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:"] -, BulletList - [ [ Para [Str "Plus",Space,Str "1"] ] - , [ Para [Str "Plus",Space,Str "2"] ] - , [ Para [Str "Plus",Space,Str "3"] ] ] -, 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:"] -, BulletList - [ [ Para [Str "Minus",Space,Str "1"] ] - , [ Para [Str "Minus",Space,Str "2"] ] - , [ Para [Str "Minus",Space,Str "3"] ] ] -, 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:"] -, OrderedList (1,Decimal,Period) - [ [ Para [Str "First"] ] - , [ Para [Str "Second"] ] - , [ Para [Str "Third"] ] ] -, Para [Str "and:"] -, OrderedList (1,Decimal,Period) - [ [ Para [Str "One"] ] - , [ Para [Str "Two"] ] - , [ Para [Str "Three"] ] ] -, 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:"] -, OrderedList (1,Decimal,Period) - [ [ Para [Str "One"] ] - , [ Para [Str "Two"] ] - , [ Para [Str "Three"] ] ] -, Para [Str "Multiple",Space,Str "paragraphs:"] -, OrderedList (1,Decimal,Period) - [ [ 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",Apostrophe,Str "s",Space,Str "back."] ], [ Para [Str "Item",Space,Str "2."] ] - , [ Para [Str "Item",Space,Str "3."] ] ] -, Header 2 [Str "Nested"] -, BulletList - [ [ Para [Str "Tab"] - , BulletList - [ [ Para [Str "Tab"] - , BulletList - [ [ Para [Str "Tab"] ] - ] ] ] ] ] -, Para [Str "Here",Apostrophe,Str "s",Space,Str "another:"] -, OrderedList (1,Decimal,Period) - [ [ Para [Str "First"] ] - , [ Para [Str "Second:"] - , BulletList - [ [ Para [Str "Fee"] ] - , [ Para [Str "Fie"] ] - , [ Para [Str "Foe"] ] ] ], [ Para [Str "Third"] ] ] -, 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:"] - , BulletList - [ [ Para [Str "Fee"] ] - , [ Para [Str "Fie"] ] - , [ Para [Str "Foe"] ] ] ], [ Para [Str "Third"] ] ] -, 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"] -, OrderedList (2,Decimal,TwoParens) - [ [ Para [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) - [ [ Para [Str "sublist",Space,Str "with",Space,Str "roman",Space,Str "numerals,",Space,Str "starting",Space,Str "with",Space,Str "4"] ] - , [ Para [Str "more",Space,Str "items"] - , OrderedList (1,UpperAlpha,TwoParens) - [ [ Para [Str "a",Space,Str "subsublist"] ] - , [ Para [Str "a",Space,Str "subsublist"] ] ] ] ] ] ] -, Para [Str "Nesting:"] -, OrderedList (1,UpperAlpha,Period) - [ [ Para [Str "Upper",Space,Str "Alpha"] - , OrderedList (1,UpperRoman,Period) - [ [ 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) - [ [ Para [Str "Lower",Space,Str "alpha",Space,Str "with",Space,Str "paren"] ] - ] ] ] ] ] ] ] -, Para [Str "Autonumbering:"] -, OrderedList (1,DefaultStyle,DefaultDelim) - [ [ Para [Str "Autonumber."] ] - , [ Para [Str "More."] - , OrderedList (1,DefaultStyle,DefaultDelim) - [ [ Para [Str "Nested."] ] - ] ] ] -, Para [Str "Should",Space,Str "not",Space,Str "be",Space,Str "a",Space,Str "list",Space,Str "item:"] -, Para [Str "M.A.",Space,Str "2007"] -, Para [Str "B.",Space,Str "Williams"] -, HorizontalRule -, Header 1 [Str "Definition",Space,Str "Lists"] -, Para [Str "Tight",Space,Str "using",Space,Str "spaces:"] -, DefinitionList - [ ([Str "apple"], - [ [ Para [Str "red",Space,Str "fruit"] ] - ]) - , ([Str "orange"], - [ [ Para [Str "orange",Space,Str "fruit"] ] - ]) - , ([Str "banana"], - [ [ Para [Str "yellow",Space,Str "fruit"] ] - ]) ] -, Para [Str "Tight",Space,Str "using",Space,Str "tabs:"] -, DefinitionList - [ ([Str "apple"], - [ [ Para [Str "red",Space,Str "fruit"] ] - ]) - , ([Str "orange"], - [ [ Para [Str "orange",Space,Str "fruit"] ] - ]) - , ([Str "banana"], - [ [ Para [Str "yellow",Space,Str "fruit"] ] - ]) ] -, Para [Str "Loose:"] -, DefinitionList - [ ([Str "apple"], - [ [ Para [Str "red",Space,Str "fruit"] ] - ]) - , ([Str "orange"], - [ [ 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:"] -, DefinitionList - [ ([Emph [Str "apple"]], - [ [ Para [Str "red",Space,Str "fruit"] - , 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"] ] - ]]) ] -, 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:"] -, Para [Str "This",Space,Str "is",Space,Emph [Str "emphasized"],Space,Str "And",Space,Str "this",Space,Str "is",Space,Strong [Str "strong"],Space,Str "Here",Apostrophe,Str "s",Space,Str "a",Space,Str "simple",Space,Str "block:"] -, Para [Str "foo",Space,Str "This",Space,Str "should",Space,Str "be",Space,Str "a",Space,Str "code",Space,Str "block,",Space,Str "though:"] -, CodeBlock ("",[],[]) "
      \n foo\n
      " -, Para [Str "As",Space,Str "should",Space,Str "this:"] -, CodeBlock ("",[],[]) "
      foo
      " -, Para [Str "Now,",Space,Str "nested:"] -, Para [Str "foo",Space,Str "This",Space,Str "should",Space,Str "just",Space,Str "be",Space,Str "an",Space,Str "HTML",Space,Str "comment:"] -, Para [Str "Multiline:"] -, Para [Str "Code",Space,Str "block:"] -, CodeBlock ("",[],[]) "" -, 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:"] -, Para [Str "Code:"] -, CodeBlock ("",[],[]) "
      " -, Para [Str "Hr",Apostrophe,Str "s:"] -, HorizontalRule -, 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 "."] -, 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 "",Str "."] -, Para [Strikeout [Str "This",Space,Str "is",Space,Emph [Str "strikeout"],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",Space,Str "there"],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",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",Str "^",Str "b",Space,Str "c",Str "^",Str "d,",Space,Str "a",Str "~",Str "b",Space,Str "c",Str "~",Str "d."] -, HorizontalRule -, 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."]] -, 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",Apostrophe,Str "s?"] -, 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:",Space,Str "one",EmDash,Str "two",EmDash,Str "three",EmDash,Str "four",EmDash,Str "five."] -, Para [Str "Dashes",Space,Str "between",Space,Str "numbers:",Space,Str "5",EnDash,Str "7,",Space,Str "255",EnDash,Str "66,",Space,Str "1987",EnDash,Str "1999."] -, Para [Str "Ellipses",Ellipses,Str "and",Ellipses,Str "and",Ellipses,Str "."] -, HorizontalRule -, Header 1 [Str "LaTeX"] -, BulletList - [ [ Para [TeX "\\cite[22-23]{smith.1899}"] ] - , [ Para [TeX "\\doublespacing"] ] - , [ Para [Math InlineMath "2+2=4"] ] - , [ Para [Math InlineMath "x \\in y"] ] - , [ Para [Math InlineMath "\\alpha \\wedge \\omega"] ] - , [ Para [Math InlineMath "223"] ] - , [ Para [Math InlineMath "p",Str "-",Str "Tree"] ] - , [ Para [Math InlineMath "\\frac{d}{dx}f(x)=\\lim_{h\\to 0}\\frac{f(x+h)-f(x)}{h}"] ] - , [ Para [Str "Here",Apostrophe,Str "s",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",Apostrophe,Str "t",Space,Str "be",Space,Str "math:"] -, BulletList - [ [ Para [Str "To",Space,Str "get",Space,Str "the",Space,Str "famous",Space,Str "equation,",Space,Str "write",Space,Code "$e = mc^2$",Str "."] ] - , [ Para [Str "$",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 "$",Str "34,000.",Space,Str "(It",Space,Str "worked",Space,Str "if",Space,Quoted DoubleQuote [Str "lot"],Space,Str "is",Space,Str "emphasized.)"] ] - , [ Para [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",Apostrophe,Str "s",Space,Str "a",Space,Str "LaTeX",Space,Str "table:"] -, Para [TeX "\\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:"] -, BulletList - [ [ Para [Str "I",Space,Str "hat:",Space,Str "\206"] ] - , [ Para [Str "o",Space,Str "umlaut:",Space,Str "\246"] ] - , [ Para [Str "section:",Space,Str "\167"] ] - , [ Para [Str "set",Space,Str "membership:",Space,Str "\8712"] ] - , [ Para [Str "copyright:",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."] -, Para [Str "AT",Str "&",Str "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",Str "-",Str "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"] -, 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 "."] -, Para [Link [Str "URL",Space,Str "and",Space,Str "title"] ("/url/",""),Str "."] -, 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",Str "_",Str "underscore"] ("/url/with_underscore","")] -, Para [Link [Str "Email",Space,Str "link"] ("mailto:nobody@nowhere.net","")] -, Para [Link [Str "Empty"] ("",""),Str "."] -, 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 "."] -, 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 "[not][]",Space,Str "be",Space,Str "a",Space,Str "link."] -, 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"] -, Para [Str "Here",Apostrophe,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",Apostrophe,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",Str "&",Str "T"] ("http://att.com/",""),Str "."] -, Para [Str "Here",Apostrophe,Str "s",Space,Str "an",Space,Link [Str "inline",Space,Str "link"] ("/script?foo=1&bar=2",""),Str "."] -, Para [Str "Here",Apostrophe,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"] -, 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","")] -, BulletList - [ [ Para [Str "In",Space,Str "a",Space,Str "list?"] ] - , [ Para [Link [Code "http://example.com/"] ("http://example.com/","")] ] - , [ Para [Str "It",Space,Str "should."] ] ] -, Para [Str "An",Space,Str "e",Str "-",Str "mail",Space,Str "address:",Space,Link [Code "nobody@nowhere.net"] ("mailto:nobody@nowhere.net","")] -, BlockQuote - [ Para [Str "Blockquoted:",Space,Link [Code "http://example.com/"] ("http://example.com/","")] ] - -, Para [Str "Auto",Str "-",Str "links",Space,Str "should",Space,Str "not",Space,Str "occur",Space,Str "here:",Space,Code ""] -, CodeBlock ("",[],[]) "or here: " -, 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 "(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"] -, 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",Apostrophe,Str "s",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 ("",[],[]) " { }",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.[",Str "^",Str "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,Period) - [ [ 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."] ] - +[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",Apostrophe,Str "s",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"]] +,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"] +,Para [Str "with",Space,Str "no",Space,Str "blank",Space,Str "line"] +,Header 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",Apostrophe,Str "s",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",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."] +,Para [Str "Here",Apostrophe,Str "s",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:"] +,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."]] +,BlockQuote + [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:"] + ,OrderedList (1,Decimal,Period) + [[Para [Str "item",Space,Str "one"]] + ,[Para [Str "item",Space,Str "two"]]] + ,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:",Space,Str "2",Space,Str ">",Space,Str "1."] +,Para [Str "Box",Str "-",Str "style:"] +,BlockQuote + [Para [Str "Example:"] + ,CodeBlock ("",[],[]) "sub status {\n print \"working\";\n}"] +,BlockQuote + [OrderedList (1,Decimal,Period) + [[Para [Str "do",Space,Str "laundry"]] + ,[Para [Str "take",Space,Str "out",Space,Str "the",Space,Str "trash"]]]] +,Para [Str "Here",Apostrophe,Str "s",Space,Str "a",Space,Str "nested",Space,Str "one:"] +,BlockQuote + [Para [Str "Joe",Space,Str "said:"] + ,BlockQuote + [Para [Str "Don",Apostrophe,Str "t",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"] +,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"] +,Para [Str "Asterisks",Space,Str "tight:"] +,BulletList + [[Para [Str "asterisk",Space,Str "1"]] + ,[Para [Str "asterisk",Space,Str "2"]] + ,[Para [Str "asterisk",Space,Str "3"]]] +,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:"] +,BulletList + [[Para [Str "Plus",Space,Str "1"]] + ,[Para [Str "Plus",Space,Str "2"]] + ,[Para [Str "Plus",Space,Str "3"]]] +,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:"] +,BulletList + [[Para [Str "Minus",Space,Str "1"]] + ,[Para [Str "Minus",Space,Str "2"]] + ,[Para [Str "Minus",Space,Str "3"]]] +,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:"] +,OrderedList (1,Decimal,Period) + [[Para [Str "First"]] + ,[Para [Str "Second"]] + ,[Para [Str "Third"]]] +,Para [Str "and:"] +,OrderedList (1,Decimal,Period) + [[Para [Str "One"]] + ,[Para [Str "Two"]] + ,[Para [Str "Three"]]] +,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:"] +,OrderedList (1,Decimal,Period) + [[Para [Str "One"]] + ,[Para [Str "Two"]] + ,[Para [Str "Three"]]] +,Para [Str "Multiple",Space,Str "paragraphs:"] +,OrderedList (1,Decimal,Period) + [[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",Apostrophe,Str "s",Space,Str "back."]] + ,[Para [Str "Item",Space,Str "2."]] + ,[Para [Str "Item",Space,Str "3."]]] +,Header 2 [Str "Nested"] +,BulletList + [[Para [Str "Tab"] + ,BulletList + [[Para [Str "Tab"] + ,BulletList + [[Para [Str "Tab"]]]]]]] +,Para [Str "Here",Apostrophe,Str "s",Space,Str "another:"] +,OrderedList (1,Decimal,Period) + [[Para [Str "First"]] + ,[Para [Str "Second:"] + ,BulletList + [[Para [Str "Fee"]] + ,[Para [Str "Fie"]] + ,[Para [Str "Foe"]]]] + ,[Para [Str "Third"]]] +,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:"] + ,BulletList + [[Para [Str "Fee"]] + ,[Para [Str "Fie"]] + ,[Para [Str "Foe"]]]] + ,[Para [Str "Third"]]] +,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"] +,OrderedList (2,Decimal,TwoParens) + [[Para [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) + [[Para [Str "sublist",Space,Str "with",Space,Str "roman",Space,Str "numerals,",Space,Str "starting",Space,Str "with",Space,Str "4"]] + ,[Para [Str "more",Space,Str "items"] + ,OrderedList (1,UpperAlpha,TwoParens) + [[Para [Str "a",Space,Str "subsublist"]] + ,[Para [Str "a",Space,Str "subsublist"]]]]]]] +,Para [Str "Nesting:"] +,OrderedList (1,UpperAlpha,Period) + [[Para [Str "Upper",Space,Str "Alpha"] + ,OrderedList (1,UpperRoman,Period) + [[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) + [[Para [Str "Lower",Space,Str "alpha",Space,Str "with",Space,Str "paren"]]]]]]]]] +,Para [Str "Autonumbering:"] +,OrderedList (1,DefaultStyle,DefaultDelim) + [[Para [Str "Autonumber."]] + ,[Para [Str "More."] + ,OrderedList (1,DefaultStyle,DefaultDelim) + [[Para [Str "Nested."]]]]] +,Para [Str "Should",Space,Str "not",Space,Str "be",Space,Str "a",Space,Str "list",Space,Str "item:"] +,Para [Str "M.A.",Space,Str "2007"] +,Para [Str "B.",Space,Str "Williams"] +,HorizontalRule +,Header 1 [Str "Definition",Space,Str "Lists"] +,Para [Str "Tight",Space,Str "using",Space,Str "spaces:"] +,DefinitionList + [([Str "apple"], + [[Para [Str "red",Space,Str "fruit"]]]) + ,([Str "orange"], + [[Para [Str "orange",Space,Str "fruit"]]]) + ,([Str "banana"], + [[Para [Str "yellow",Space,Str "fruit"]]])] +,Para [Str "Tight",Space,Str "using",Space,Str "tabs:"] +,DefinitionList + [([Str "apple"], + [[Para [Str "red",Space,Str "fruit"]]]) + ,([Str "orange"], + [[Para [Str "orange",Space,Str "fruit"]]]) + ,([Str "banana"], + [[Para [Str "yellow",Space,Str "fruit"]]])] +,Para [Str "Loose:"] +,DefinitionList + [([Str "apple"], + [[Para [Str "red",Space,Str "fruit"]]]) + ,([Str "orange"], + [[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:"] +,DefinitionList + [([Emph [Str "apple"]], + [[Para [Str "red",Space,Str "fruit"] + ,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"]]]])] +,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:"] +,Para [Str "This",Space,Str "is",Space,Emph [Str "emphasized"],Space,Str "And",Space,Str "this",Space,Str "is",Space,Strong [Str "strong"],Space,Str "Here",Apostrophe,Str "s",Space,Str "a",Space,Str "simple",Space,Str "block:"] +,Para [Str "foo",Space,Str "This",Space,Str "should",Space,Str "be",Space,Str "a",Space,Str "code",Space,Str "block,",Space,Str "though:"] +,CodeBlock ("",[],[]) "
      \n foo\n
      " +,Para [Str "As",Space,Str "should",Space,Str "this:"] +,CodeBlock ("",[],[]) "
      foo
      " +,Para [Str "Now,",Space,Str "nested:"] +,Para [Str "foo",Space,Str "This",Space,Str "should",Space,Str "just",Space,Str "be",Space,Str "an",Space,Str "HTML",Space,Str "comment:"] +,Para [Str "Multiline:"] +,Para [Str "Code",Space,Str "block:"] +,CodeBlock ("",[],[]) "" +,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:"] +,Para [Str "Code:"] +,CodeBlock ("",[],[]) "
      " +,Para [Str "Hr",Apostrophe,Str "s:"] +,HorizontalRule +,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 "."] +,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 ("",[],[]) "",Str "."] +,Para [Strikeout [Str "This",Space,Str "is",Space,Emph [Str "strikeout"],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",Space,Str "there"],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",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",Str "^",Str "b",Space,Str "c",Str "^",Str "d,",Space,Str "a",Str "~",Str "b",Space,Str "c",Str "~",Str "d."] +,HorizontalRule +,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."]] +,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",Apostrophe,Str "s?"] +,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:",Space,Str "one",EmDash,Str "two",EmDash,Str "three",EmDash,Str "four",EmDash,Str "five."] +,Para [Str "Dashes",Space,Str "between",Space,Str "numbers:",Space,Str "5",EnDash,Str "7,",Space,Str "255",EnDash,Str "66,",Space,Str "1987",EnDash,Str "1999."] +,Para [Str "Ellipses",Ellipses,Str "and",Ellipses,Str "and",Ellipses,Str "."] +,HorizontalRule +,Header 1 [Str "LaTeX"] +,BulletList + [[Para [Cite [Citation {citationId = "smith.1899", citationPrefix = [], citationSuffix = [Str "22",Str "-",Str "23"], citationMode = NormalCitation, citationNoteNum = 0, citationHash = 0}] []]] + ,[Para [RawInline "latex" "\\doublespacing"]] + ,[Para [Math InlineMath "2+2=4"]] + ,[Para [Math InlineMath "x \\in y"]] + ,[Para [Math InlineMath "\\alpha \\wedge \\omega"]] + ,[Para [Math InlineMath "223"]] + ,[Para [Math InlineMath "p",Str "-",Str "Tree"]] + ,[Para [Math InlineMath "\\frac{d}{dx}f(x)=\\lim_{h\\to 0}\\frac{f(x+h)-f(x)}{h}"]] + ,[Para [Str "Here",Apostrophe,Str "s",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",Apostrophe,Str "t",Space,Str "be",Space,Str "math:"] +,BulletList + [[Para [Str "To",Space,Str "get",Space,Str "the",Space,Str "famous",Space,Str "equation,",Space,Str "write",Space,Code ("",[],[]) "$e = mc^2$",Str "."]] + ,[Para [Str "$",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 "$",Str "34,000.",Space,Str "(It",Space,Str "worked",Space,Str "if",Space,Quoted DoubleQuote [Str "lot"],Space,Str "is",Space,Str "emphasized.)"]] + ,[Para [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",Apostrophe,Str "s",Space,Str "a",Space,Str "LaTeX",Space,Str "table:"] +,Table [] [AlignLeft,AlignLeft] [0.0,0.0] + [[Plain [Str "Animal"]] + ,[Plain [Str "Number"]]] + [[[Plain [Str "Dog"]] + ,[Plain [Str "2"]]] + ,[[Plain [Str "Cat"]] + ,[Plain [Str "1"]]]] +,HorizontalRule +,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"]] + ,[Para [Str "o",Space,Str "umlaut:",Space,Str "\246"]] + ,[Para [Str "section:",Space,Str "\167"]] + ,[Para [Str "set",Space,Str "membership:",Space,Str "\8712"]] + ,[Para [Str "copyright:",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."] +,Para [Str "AT",Str "&",Str "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",Str "-",Str "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"] +,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 "."] +,Para [Link [Str "URL",Space,Str "and",Space,Str "title"] ("/url/",""),Str "."] +,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",Str "_",Str "underscore"] ("/url/with_underscore","")] +,Para [Link [Str "Email",Space,Str "link"] ("mailto:nobody@nowhere.net","")] +,Para [Link [Str "Empty"] ("",""),Str "."] +,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 "."] +,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."] +,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."] +,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"] +,Para [Str "Here",Apostrophe,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",Apostrophe,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",Str "&",Str "T"] ("http://att.com/",""),Str "."] +,Para [Str "Here",Apostrophe,Str "s",Space,Str "an",Space,Link [Str "inline",Space,Str "link"] ("/script?foo=1&bar=2",""),Str "."] +,Para [Str "Here",Apostrophe,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"] +,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","")] +,BulletList + [[Para [Str "In",Space,Str "a",Space,Str "list?"]] + ,[Para [Link [Code ("",["url"],[]) "http://example.com/"] ("http://example.com/","")]] + ,[Para [Str "It",Space,Str "should."]]] +,Para [Str "An",Space,Str "e",Str "-",Str "mail",Space,Str "address:",Space,Link [Code ("",[],[]) "nobody@nowhere.net"] ("mailto:nobody@nowhere.net","")] +,BlockQuote + [Para [Str "Blockquoted:",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:",Space,Code ("",[],[]) ""] +,CodeBlock ("",[],[]) "or here: " +,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 "(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"] +,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",Apostrophe,Str "s",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 ("",[],[]) " { }",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.",Str "[",Str "^",Str "my",Space,Str "note",Str "]",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 "[",Str "bracketed",Space,Str "text",Str "]",Str "."]]] +,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,Period) + [[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."]] diff -Nru pandoc-1.5.1.1/tests/lhs-test.fragment.html+lhs pandoc-1.8.0.3/tests/lhs-test.fragment.html+lhs --- pandoc-1.5.1.1/tests/lhs-test.fragment.html+lhs 2010-03-29 14:24:56.000000000 +0000 +++ pandoc-1.8.0.3/tests/lhs-test.fragment.html+lhs 2011-02-05 18:48:07.000000000 +0000 @@ -1,51 +1,15 @@ -

      lhs test

      unsplit is an arrow that takes a pair of values and combines them to return a single value:

      > unsplit :: (Arrow a) => (b -> c -> d) -> a (b, c) d
      > unsplit = arr . uncurry
      > -- arr (\op (x,y) -> x `op` y)

      (***) combines two arrows into a new arrow by running the two arrows on a pair of values (one arrow on the first item of the pair and one arrow on the second item of the pair).

      f *** g = first f >>> second g
      -

      Block quote:

      foo bar

      +

      lhs test

      + +

      unsplit is an arrow that takes a pair of values and combines them to return a single value:

      + +
      > unsplit :: (Arrow a) => (b -> c -> d) -> a (b, c) d
      > unsplit = arr . uncurry
      > -- arr (\op (x,y) -> x `op` y)
      + +

      (***) combines two arrows into a new arrow by running the two arrows on a pair of values (one arrow on the first item of the pair and one arrow on the second item of the pair).

      + +
      f *** g = first f >>> second g
      + +

      Block quote:

      + +
      +

      foo bar

      +
      diff -Nru pandoc-1.5.1.1/tests/lhs-test.html pandoc-1.8.0.3/tests/lhs-test.html --- pandoc-1.5.1.1/tests/lhs-test.html 2010-03-29 14:24:56.000000000 +0000 +++ pandoc-1.8.0.3/tests/lhs-test.html 2011-02-05 18:48:07.000000000 +0000 @@ -1,77 +1,39 @@ - - + -

      lhs test

      unsplit is an arrow that takes a pair of values and combines them to return a single value:

      unsplit :: (Arrow a) => (b -> c -> d) -> a (b, c) d
      unsplit = arr . uncurry
      -- arr (\op (x,y) -> x `op` y)

      (***) combines two arrows into a new arrow by running the two arrows on a pair of values (one arrow on the first item of the pair and one arrow on the second item of the pair).

      f *** g = first f >>> second g
      -

      Block quote:

      foo bar

      +

      lhs test

      +

      unsplit is an arrow that takes a pair of values and combines them to return a single value:

      +
      unsplit :: (Arrow a) => (b -> c -> d) -> a (b, c) d
      unsplit = arr . uncurry
      -- arr (\op (x,y) -> x `op` y)
      +

      (***) combines two arrows into a new arrow by running the two arrows on a pair of values (one arrow on the first item of the pair and one arrow on the second item of the pair).

      +
      f *** g = first f >>> second g
      +
      +

      Block quote:

      +
      +

      foo bar

      +
      - diff -Nru pandoc-1.5.1.1/tests/lhs-test.html+lhs pandoc-1.8.0.3/tests/lhs-test.html+lhs --- pandoc-1.5.1.1/tests/lhs-test.html+lhs 2010-03-29 14:24:56.000000000 +0000 +++ pandoc-1.8.0.3/tests/lhs-test.html+lhs 2011-02-05 18:48:07.000000000 +0000 @@ -1,83 +1,39 @@ - - + -

      lhs test

      unsplit is an arrow that takes a pair of values and combines them to return a single value:

      > unsplit :: (Arrow a) => (b -> c -> d) -> a (b, c) d
      > unsplit = arr . uncurry
      > -- arr (\op (x,y) -> x `op` y)

      (***) combines two arrows into a new arrow by running the two arrows on a pair of values (one arrow on the first item of the pair and one arrow on the second item of the pair).

      f *** g = first f >>> second g
      -

      Block quote:

      foo bar

      +

      lhs test

      +

      unsplit is an arrow that takes a pair of values and combines them to return a single value:

      +
      > unsplit :: (Arrow a) => (b -> c -> d) -> a (b, c) d
      > unsplit = arr . uncurry
      > -- arr (\op (x,y) -> x `op` y)
      +

      (***) combines two arrows into a new arrow by running the two arrows on a pair of values (one arrow on the first item of the pair and one arrow on the second item of the pair).

      +
      f *** g = first f >>> second g
      +
      +

      Block quote:

      +
      +

      foo bar

      +
      - diff -Nru pandoc-1.5.1.1/tests/lhs-test.latex pandoc-1.8.0.3/tests/lhs-test.latex --- pandoc-1.5.1.1/tests/lhs-test.latex 2010-03-29 14:24:56.000000000 +0000 +++ pandoc-1.8.0.3/tests/lhs-test.latex 2011-02-05 18:48:07.000000000 +0000 @@ -1,8 +1,8 @@ \documentclass{article} -\usepackage{amsmath} +\usepackage{amssymb,amsmath} \usepackage[mathletters]{ucs} \usepackage[utf8x]{inputenc} -\usepackage[breaklinks=true,unicode=true]{hyperref} +\usepackage[breaklinks=true,unicode=true,pdfborder={0 0 0}]{hyperref} \setlength{\parindent}{0pt} \setlength{\parskip}{6pt plus 2pt minus 1pt} \setcounter{secnumdepth}{0} @@ -12,17 +12,17 @@ \section{lhs test} -\verb!unsplit! is an arrow that takes a pair of values and combines -them to return a single value: +\verb!unsplit! is an arrow that takes a pair of values and combines them to +return a single value: \begin{verbatim} unsplit :: (Arrow a) => (b -> c -> d) -> a (b, c) d unsplit = arr . uncurry -- arr (\op (x,y) -> x `op` y) \end{verbatim} -\verb!(***)! combines two arrows into a new arrow by running the -two arrows on a pair of values (one arrow on the first item of the -pair and one arrow on the second item of the pair). +\verb!(***)! combines two arrows into a new arrow by running the two arrows on +a pair of values (one arrow on the first item of the pair and one arrow on the +second item of the pair). \begin{verbatim} f *** g = first f >>> second g @@ -35,4 +35,3 @@ \end{quote} \end{document} - diff -Nru pandoc-1.5.1.1/tests/lhs-test.latex+lhs pandoc-1.8.0.3/tests/lhs-test.latex+lhs --- pandoc-1.5.1.1/tests/lhs-test.latex+lhs 2010-03-29 14:24:56.000000000 +0000 +++ pandoc-1.8.0.3/tests/lhs-test.latex+lhs 2011-02-05 18:48:07.000000000 +0000 @@ -1,10 +1,10 @@ \documentclass{article} -\usepackage{amsmath} +\usepackage{amssymb,amsmath} \usepackage[mathletters]{ucs} \usepackage[utf8x]{inputenc} \usepackage{listings} \lstnewenvironment{code}{\lstset{language=Haskell,basicstyle=\small\ttfamily}}{} -\usepackage[breaklinks=true,unicode=true]{hyperref} +\usepackage[breaklinks=true,unicode=true,pdfborder={0 0 0}]{hyperref} \setlength{\parindent}{0pt} \setlength{\parskip}{6pt plus 2pt minus 1pt} \setcounter{secnumdepth}{0} @@ -14,17 +14,17 @@ \section{lhs test} -\verb!unsplit! is an arrow that takes a pair of values and combines -them to return a single value: +\verb!unsplit! is an arrow that takes a pair of values and combines them to +return a single value: \begin{code} unsplit :: (Arrow a) => (b -> c -> d) -> a (b, c) d unsplit = arr . uncurry -- arr (\op (x,y) -> x `op` y) \end{code} -\verb!(***)! combines two arrows into a new arrow by running the -two arrows on a pair of values (one arrow on the first item of the -pair and one arrow on the second item of the pair). +\verb!(***)! combines two arrows into a new arrow by running the two arrows on +a pair of values (one arrow on the first item of the pair and one arrow on the +second item of the pair). \begin{verbatim} f *** g = first f >>> second g @@ -37,4 +37,3 @@ \end{quote} \end{document} - diff -Nru pandoc-1.5.1.1/tests/lhs-test.markdown pandoc-1.8.0.3/tests/lhs-test.markdown --- pandoc-1.5.1.1/tests/lhs-test.markdown 2010-03-29 14:24:56.000000000 +0000 +++ pandoc-1.8.0.3/tests/lhs-test.markdown 2011-02-05 18:48:07.000000000 +0000 @@ -1,21 +1,20 @@ # lhs test -`unsplit` is an arrow that takes a pair of values and combines them -to return a single value: +`unsplit` is an arrow that takes a pair of values and combines them to return +a single value: - unsplit :: (Arrow a) => (b -> c -> d) -> a (b, c) d - unsplit = arr . uncurry - -- arr (\op (x,y) -> x `op` y) - -`(***)` combines two arrows into a new arrow by running the two -arrows on a pair of values (one arrow on the first item of the pair -and one arrow on the second item of the pair). +~~~~ {.sourceCode .literate .haskell} +unsplit :: (Arrow a) => (b -> c -> d) -> a (b, c) d +unsplit = arr . uncurry + -- arr (\op (x,y) -> x `op` y) +~~~~ + +`(***)` combines two arrows into a new arrow by running the two arrows on a +pair of values (one arrow on the first item of the pair and one arrow on the +second item of the pair). f *** g = first f >>> second g Block quote: > foo bar - - - diff -Nru pandoc-1.5.1.1/tests/lhs-test.markdown+lhs pandoc-1.8.0.3/tests/lhs-test.markdown+lhs --- pandoc-1.5.1.1/tests/lhs-test.markdown+lhs 2010-03-29 14:24:56.000000000 +0000 +++ pandoc-1.8.0.3/tests/lhs-test.markdown+lhs 2011-02-05 18:48:07.000000000 +0000 @@ -1,22 +1,19 @@ lhs test ======== -`unsplit` is an arrow that takes a pair of values and combines them -to return a single value: +`unsplit` is an arrow that takes a pair of values and combines them to return +a single value: > unsplit :: (Arrow a) => (b -> c -> d) -> a (b, c) d > unsplit = arr . uncurry > -- arr (\op (x,y) -> x `op` y) -`(***)` combines two arrows into a new arrow by running the two -arrows on a pair of values (one arrow on the first item of the pair -and one arrow on the second item of the pair). +`(***)` combines two arrows into a new arrow by running the two arrows on a +pair of values (one arrow on the first item of the pair and one arrow on the +second item of the pair). f *** g = first f >>> second g Block quote: > foo bar - - - diff -Nru pandoc-1.5.1.1/tests/lhs-test.native pandoc-1.8.0.3/tests/lhs-test.native --- pandoc-1.5.1.1/tests/lhs-test.native 2010-03-29 14:24:56.000000000 +0000 +++ pandoc-1.8.0.3/tests/lhs-test.native 2011-02-05 18:48:07.000000000 +0000 @@ -1,11 +1,8 @@ -Pandoc (Meta {docTitle = [], docAuthors = [], docDate = []}) -[ 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 "."] -, CodeBlock ("",[],[]) "f *** g = first f >>> second g" -, Para [Str "Block",Space,Str "quote:"] -, BlockQuote - [ Para [Str "foo",Space,Str "bar"] ] - ] - +[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 ":"] +,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 "."] +,CodeBlock ("",[],[]) "f *** g = first f >>> second g" +,Para [Str "Block",Space,Str "quote",Str ":"] +,BlockQuote + [Para [Str "foo",Space,Str "bar"]]] diff -Nru pandoc-1.5.1.1/tests/lhs-test.nohl.html pandoc-1.8.0.3/tests/lhs-test.nohl.html --- pandoc-1.5.1.1/tests/lhs-test.nohl.html 1970-01-01 00:00:00.000000000 +0000 +++ pandoc-1.8.0.3/tests/lhs-test.nohl.html 2011-02-05 18:48:07.000000000 +0000 @@ -0,0 +1,39 @@ + + + + + + + + + +

      lhs test

      +

      unsplit is an arrow that takes a pair of values and combines them to return a single value:

      +
      unsplit :: (Arrow a) => (b -> c -> d) -> a (b, c) d
      unsplit = arr . uncurry
      -- arr (\op (x,y) -> x `op` y)
      +

      (***) combines two arrows into a new arrow by running the two arrows on a pair of values (one arrow on the first item of the pair and one arrow on the second item of the pair).

      +
      f *** g = first f >>> second g
      +
      +

      Block quote:

      +
      +

      foo bar

      +
      + + diff -Nru pandoc-1.5.1.1/tests/lhs-test.nohl.html+lhs pandoc-1.8.0.3/tests/lhs-test.nohl.html+lhs --- pandoc-1.5.1.1/tests/lhs-test.nohl.html+lhs 1970-01-01 00:00:00.000000000 +0000 +++ pandoc-1.8.0.3/tests/lhs-test.nohl.html+lhs 2011-02-05 18:48:07.000000000 +0000 @@ -0,0 +1,39 @@ + + + + + + + + + +

      lhs test

      +

      unsplit is an arrow that takes a pair of values and combines them to return a single value:

      +
      > unsplit :: (Arrow a) => (b -> c -> d) -> a (b, c) d
      > unsplit = arr . uncurry
      > -- arr (\op (x,y) -> x `op` y)
      +

      (***) combines two arrows into a new arrow by running the two arrows on a pair of values (one arrow on the first item of the pair and one arrow on the second item of the pair).

      +
      f *** g = first f >>> second g
      +
      +

      Block quote:

      +
      +

      foo bar

      +
      + + diff -Nru pandoc-1.5.1.1/tests/lhs-test.rst pandoc-1.8.0.3/tests/lhs-test.rst --- pandoc-1.5.1.1/tests/lhs-test.rst 2010-03-29 14:24:56.000000000 +0000 +++ pandoc-1.8.0.3/tests/lhs-test.rst 2011-02-05 18:48:07.000000000 +0000 @@ -1,8 +1,8 @@ lhs test ======== -``unsplit`` is an arrow that takes a pair of values and combines -them to return a single value: +``unsplit`` is an arrow that takes a pair of values and combines them to +return a single value: :: @@ -10,9 +10,9 @@ unsplit = arr . uncurry -- arr (\op (x,y) -> x `op` y) -``(***)`` combines two arrows into a new arrow by running the two -arrows on a pair of values (one arrow on the first item of the pair -and one arrow on the second item of the pair). +``(***)`` combines two arrows into a new arrow by running the two arrows on a +pair of values (one arrow on the first item of the pair and one arrow on the +second item of the pair). :: @@ -21,6 +21,3 @@ Block quote: foo bar - - - diff -Nru pandoc-1.5.1.1/tests/lhs-test.rst+lhs pandoc-1.8.0.3/tests/lhs-test.rst+lhs --- pandoc-1.5.1.1/tests/lhs-test.rst+lhs 2010-03-29 14:24:56.000000000 +0000 +++ pandoc-1.8.0.3/tests/lhs-test.rst+lhs 2011-02-05 18:48:07.000000000 +0000 @@ -1,16 +1,16 @@ lhs test ======== -``unsplit`` is an arrow that takes a pair of values and combines -them to return a single value: +``unsplit`` is an arrow that takes a pair of values and combines them to +return a single value: > unsplit :: (Arrow a) => (b -> c -> d) -> a (b, c) d > unsplit = arr . uncurry > -- arr (\op (x,y) -> x `op` y) -``(***)`` combines two arrows into a new arrow by running the two -arrows on a pair of values (one arrow on the first item of the pair -and one arrow on the second item of the pair). +``(***)`` combines two arrows into a new arrow by running the two arrows on a +pair of values (one arrow on the first item of the pair and one arrow on the +second item of the pair). :: @@ -19,6 +19,3 @@ Block quote: foo bar - - - diff -Nru pandoc-1.5.1.1/tests/markdown-citations.chicago-author-date.txt pandoc-1.8.0.3/tests/markdown-citations.chicago-author-date.txt --- pandoc-1.5.1.1/tests/markdown-citations.chicago-author-date.txt 1970-01-01 00:00:00.000000000 +0000 +++ pandoc-1.8.0.3/tests/markdown-citations.chicago-author-date.txt 2011-02-05 18:48:07.000000000 +0000 @@ -0,0 +1,43 @@ +# Pandoc with citeproc-hs + +- [@nonexistent] + +- @nonexistent + +- Doe (2005) says blah. + +- Doe (2005, 30) says blah. + +- Doe (2005, 30, with suffix) says blah. + +- Doe (2005; 2006, 30; see also Doe and Roe 2007) says blah. + +- In a note.[^1] + +- A citation group (see Doe 2005, 34–35; also Doe and Roe 2007, chap. 3). + +- Another one (see Doe 2005, 34–35). + +- And another one in a note.[^2] + +- Citation with a suffix and locator (Doe 2005, 33, 35–37, and nowhere else). + +- Citation with suffix only (Doe 2005, and nowhere else). + +- Now some modifiers.[^3] + +- With some markup (*see* Doe 2005, 32). + +# References + +Doe, John. 2005. *First Book*. Cambridge: Cambridge University Press. + +---. 2006. Article. *Journal of Generic Studies* 6: 33–34. + +Doe, John, and Jenny Roe. 2007. Why Water Is Wet. In *Third Book*, ed. Sam Smith. Oxford: Oxford University Press. + +[^1]: A citation without locators (Doe and Roe 2007). + +[^2]: Some citations (see Doe 2006, chap. 3; Doe and Roe 2007; Doe 2005). + +[^3]: Like a citation without author: (2005), and now Doe with a locator (2006, 44). diff -Nru pandoc-1.5.1.1/tests/markdown-citations.ieee.txt pandoc-1.8.0.3/tests/markdown-citations.ieee.txt --- pandoc-1.5.1.1/tests/markdown-citations.ieee.txt 1970-01-01 00:00:00.000000000 +0000 +++ pandoc-1.8.0.3/tests/markdown-citations.ieee.txt 2011-02-05 18:48:07.000000000 +0000 @@ -0,0 +1,43 @@ +# Pandoc with citeproc-hs + +- [@nonexistent] + +- @nonexistent + +- Reference [1] says blah. + +- Reference [1] says blah. + +- Reference [1] says blah. + +- Reference [1] says blah. + +- In a note.[^1] + +- A citation group [1],[3]. + +- Another one [1]. + +- And another one in a note.[^2] + +- Citation with a suffix and locator [1]. + +- Citation with suffix only [1]. + +- Now some modifiers.[^3] + +- With some markup [1]. + +# References + +[1] J. Doe, *First Book*, Cambridge: Cambridge University Press, 2005. + +[2] J. Doe, “Article,” *Journal of Generic Studies*, vol. 6, 2006, pp. 33-34. + +[3] J. Doe and J. Roe, “Why Water Is Wet,” *Third Book*, Smith, S., Ed., Oxford: Oxford University Press, 2007. + +[^1]: A citation without locators [3]. + +[^2]: Some citations [1]-[3]. + +[^3]: Like a citation without author: [1], and now Doe with a locator [2]. diff -Nru pandoc-1.5.1.1/tests/markdown-citations.mhra.txt pandoc-1.8.0.3/tests/markdown-citations.mhra.txt --- pandoc-1.5.1.1/tests/markdown-citations.mhra.txt 1970-01-01 00:00:00.000000000 +0000 +++ pandoc-1.8.0.3/tests/markdown-citations.mhra.txt 2011-02-05 18:48:07.000000000 +0000 @@ -0,0 +1,61 @@ +# Pandoc with citeproc-hs + +- [@nonexistent] + +- @nonexistent + +- John Doe[^1] says blah. + +- Doe[^2] says blah. + +- Doe[^3] says blah. + +- Doe[^4] says blah. + +- In a note.[^5] + +- A citation group.[^6] + +- Another one.[^7] + +- And another one in a note.[^8] + +- Citation with a suffix and locator.[^9] + +- Citation with suffix only.[^10] + +- Now some modifiers.[^11] + +- With some markup.[^12] + +# References + +Doe, John, ‘Article’, *Journal of Generic Studies*, 6 (2006), 33-34. + +---, *First Book* (Cambridge: Cambridge University Press, 2005). + +Doe, John, and Jenny Roe, ‘Why Water Is Wet’, in *Third Book*, ed by Sam Smith (Oxford: Oxford University Press, 2007). + +[^1]: *First Book* (Cambridge: Cambridge University Press, 2005). + +[^2]: First Book, p. 30. + +[^3]: First Book, p. 30, with suffix. + +[^4]: First Book; ‘Article’, *Journal of Generic Studies*, 6 (2006), 33-34 (p. 30); see also John Doe and Jenny Roe, ‘Why Water Is Wet’, in *Third Book*, ed by Sam Smith (Oxford: Oxford University Press, 2007). + +[^5]: A citation without locators Doe and Roe. + +[^6]: See Doe, First Book, pp. 34-35; also Doe and Roe, chap. 3. + +[^7]: See Doe, First Book, pp. 34-35. + +[^8]: Some citations see Doe, Article, 33-34 (chap. 3); Doe and Roe; Doe, First Book. + +[^9]: Doe, First Book, pp. 33, 35-37, and nowhere else. + +[^10]: Doe, First Book, and nowhere else. + +[^11]: Like a citation without author: First Book, and now Doe with a locator Article, 33-34 (p. 44). + +[^12]: *See* Doe, First Book, p. 32. diff -Nru pandoc-1.5.1.1/tests/markdown-citations.txt pandoc-1.8.0.3/tests/markdown-citations.txt --- pandoc-1.5.1.1/tests/markdown-citations.txt 1970-01-01 00:00:00.000000000 +0000 +++ pandoc-1.8.0.3/tests/markdown-citations.txt 2011-02-05 18:48:07.000000000 +0000 @@ -0,0 +1,37 @@ +# Pandoc with citeproc-hs + +- [@nonexistent] + +- @nonexistent + +- @item1 says blah. + +- @item1 [p. 30] says blah. + +- @item1 [p. 30, with suffix] says blah. + +- @item1 [-@item2 p. 30; see also @item3] says blah. + +- In a note.[^1] + +- A citation group [see @item1 p. 34-35; also @item3 chap. 3]. + +- Another one [see @item1 p. 34-35]. + +- And another one in a note.[^2] + +- Citation with a suffix and locator [@item1 pp. 33, 35-37, and nowhere else]. + +- Citation with suffix only [@item1 and nowhere else]. + +- Now some modifiers.[^3] + +- With some markup [*see* @item1 p. **32**]. + +# References + +[^1]: A citation without locators [@item3]. + +[^2]: Some citations [see @item2 chap. 3; @item3; @item1]. + +[^3]: Like a citation without author: [-@item1], and now Doe with a locator [-@item2 p. 44]. diff -Nru pandoc-1.5.1.1/tests/markdown-reader-more.native pandoc-1.8.0.3/tests/markdown-reader-more.native --- pandoc-1.5.1.1/tests/markdown-reader-more.native 2010-03-29 14:24:56.000000000 +0000 +++ pandoc-1.8.0.3/tests/markdown-reader-more.native 2011-02-05 18:48:07.000000000 +0000 @@ -1,35 +1,50 @@ -Pandoc (Meta {docTitle = [Str "Title",Space,Str "spanning",Space,Str "multiple",Space,Str "lines"], docAuthors = [[Str "Author",Space,Str "One"],[Str "Author",Space,Str "Two"],[Str "Author",Space,Str "Three"],[Str "Author",Space,Str "Four"]], docDate = []}) -[ 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"] -, Para [Link [Str "foo"] ("/url",""),Space,Str "and",Space,Link [Str "bar"] ("/url","title")] -, Header 2 [Str "Raw",Space,Str "ConTeXt",Space,Str "environments"] -, Para [TeX "\\placeformula",Space,TeX "\\startformula\n L_{1} = L_{2}\n \\stopformula"] -, Para [TeX "\\start[a2]\n\\start[a2]\n\\stop[a2]\n\\stop[a2]"] -, Header 2 [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%20%20and%20%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"] -, HorizontalRule -, HorizontalRule -, Header 2 [Str "Raw",Space,Str "HTML",Space,Str "before",Space,Str "header"] -, Plain [HtmlInline "",HtmlInline ""] -, Header 3 [Str "my",Space,Str "header"] -, Header 2 [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"] -, BulletList - [ [ Plain [Str "one"] - , RawHtml "" ], [ Plain [Str "three"] ] ] -, Header 2 [Str "Backslash",Space,Str "newline"] -, Para [Str "hi",LineBreak,Str "there"] -, Header 2 [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"] -, Para [Link [Code "http://\27979.com?\27979=\27979"] ("http://%E6%B5%8B.com?%E6%B5%8B=%E6%B5%8B","")] -, Para [Link [Str "foo"] ("/bar/%E6%B5%8B?x=%E6%B5%8B","title")] -, Para [Link [Code "\27979@foo.\27979.baz"] ("mailto:%E6%B5%8B@foo.%E6%B5%8B.baz","")] ] - +[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"] +,Para [Link [Str "foo"] ("/url",""),Space,Str "and",Space,Link [Str "bar"] ("/url","title")] +,Header 2 [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"] +,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"] +,HorizontalRule +,HorizontalRule +,Header 2 [Str "Raw",Space,Str "HTML",Space,Str "before",Space,Str "header"] +,Plain [RawInline "html" "",RawInline "html" ""] +,Header 3 [Str "my",Space,Str "header"] +,Header 2 [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"] +,BulletList + [[Plain [Str "one",Space,RawInline "html" ""]] + ,[Plain [Str "three"]]] +,Header 2 [Str "Backslash",Space,Str "newline"] +,Para [Str "hi",LineBreak,Str "there"] +,Header 2 [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"] +,Para [Link [Code ("",["url"],[]) "http://\27979.com?\27979=\27979"] ("http://%E6%B5%8B.com?%E6%B5%8B=%E6%B5%8B","")] +,Para [Link [Str "foo"] ("/bar/%E6%B5%8B?x=%E6%B5%8B","title")] +,Para [Link [Code ("",["url"],[]) "\27979@foo.\27979.baz"] ("mailto:%E6%B5%8B@foo.%E6%B5%8B.baz","")] +,Header 2 [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 "."] +,OrderedList (3,Example,TwoParens) + [[Plain [Str "Third",Space,Str "example",Str "."]]] +,Header 2 [Str "Macros"] +,Para [Math InlineMath "\\langle x,y \\rangle"] +,Header 2 [Str "Case",Str "-",Str "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"] +,Para [Quoted DoubleQuote [Str "Hi"]] +,Para [Quoted SingleQuote [Str "Hi"]]] diff -Nru pandoc-1.5.1.1/tests/markdown-reader-more.txt pandoc-1.8.0.3/tests/markdown-reader-more.txt --- pandoc-1.5.1.1/tests/markdown-reader-more.txt 2010-03-29 14:24:56.000000000 +0000 +++ pandoc-1.8.0.3/tests/markdown-reader-more.txt 2011-02-05 18:48:07.000000000 +0000 @@ -31,7 +31,8 @@ ## URLs with spaces [foo](/bar and baz) -[foo](/bar and baz ) +[foo](/bar + and baz ) [foo]( /bar and baz ) [foo](bar baz "title" ) @@ -91,3 +92,34 @@ <测@foo.测.baz> +## Numbered examples + +(@) First example. +(@foo) Second example. + +Explanation of examples (@foo) and (@bar). + +(@bar) Third example. + +## Macros + +\newcommand{\tuple}[1]{\langle #1 \rangle} + +$\tuple{x,y}$ + +## Case-insensitive references + +[Fum] + +[FUM] + +[bat] + +[fum]: /fum +[BAT]: /bat + +## Curly smart quotes + +“Hi” + +‘Hi’ diff -Nru pandoc-1.5.1.1/tests/mhra.csl pandoc-1.8.0.3/tests/mhra.csl --- pandoc-1.5.1.1/tests/mhra.csl 1970-01-01 00:00:00.000000000 +0000 +++ pandoc-1.8.0.3/tests/mhra.csl 2011-02-05 18:48:07.000000000 +0000 @@ -0,0 +1,390 @@ + + \ No newline at end of file diff -Nru pandoc-1.5.1.1/tests/rst-reader.native pandoc-1.8.0.3/tests/rst-reader.native --- pandoc-1.5.1.1/tests/rst-reader.native 2010-03-29 14:24:56.000000000 +0000 +++ pandoc-1.8.0.3/tests/rst-reader.native 2011-02-05 18:48:07.000000000 +0000 @@ -1,312 +1,308 @@ Pandoc (Meta {docTitle = [Str "Pandoc",Space,Str "Test",Space,Str "Suite",Str ":",Space,Str "Subtitle"], docAuthors = [[Str "John",Space,Str "MacFarlane"],[Str "Anonymous"]], docDate = [Str "July",Space,Str "17,",Space,Str "2006"]}) -[ DefinitionList - [ ([Str "Revision"], - [ [ Plain [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.",Space,Str "Most",Space,Str "of",Space,Str "them",Space,Str "are",Space,Str "adapted",Space,Str "from",Space,Str "John",Space,Str "Gruber's",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's",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",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."] -, Para [Str "Here's",Space,Str "one",Space,Str "with",Space,Str "a",Space,Str "bullet.",Space,Str "*",Space,Str "criminey."] -, Para [Str "Horizontal",Space,Str "rule",Str ":"] -, HorizontalRule -, Para [Str "Another",Str ":"] -, HorizontalRule -, Header 1 [Str "Block",Space,Str "Quotes"] -, Para [Str "Here's",Space,Str "a",Space,Str "block",Space,Str "quote",Str ":"] -, 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."] ] - -, Para [Str "Here's",Space,Str "another,",Space,Str "differently",Space,Str "indented",Str ":"] -, BlockQuote - [ Para [Str "This",Space,Str "is",Space,Str "a",Space,Str "block",Space,Str "quote.",Space,Str "It's",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",Str ":"] - , CodeBlock ("",[],[]) "sub status {\n print \"working\";\n}" - , Para [Str "List",Space,Str "in",Space,Str "a",Space,Str "block",Space,Str "quote",Str ":"] - , 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 ":"] - , BlockQuote - [ Para [Str "nested"] - , BlockQuote - [ Para [Str "nested"] ] - ] ] -, Header 1 [Str "Code",Space,Str "Blocks"] -, Para [Str "Code",Str ":"] -, 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 ":"] -, CodeBlock ("",[],[]) "this block is indented by two tabs\n\nThese should not be escaped: \\$ \\\\ \\> \\[ \\{" -, Para [Str "And",Str ":"] -, 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 ":"] -, 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 ":"] -, 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 ":"] -, 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 ":"] -, 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 ":"] -, 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 ":"] -, 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 ":"] -, OrderedList (1,Decimal,Period) - [ [ Plain [Str "First"] ] - , [ Plain [Str "Second"] ] - , [ Plain [Str "Third"] ] ] -, Para [Str "and",Str ":"] -, OrderedList (1,Decimal,Period) - [ [ Plain [Str "One"] ] - , [ Plain [Str "Two"] ] - , [ Plain [Str "Three"] ] ] -, Para [Str "Loose",Space,Str "using",Space,Str "tabs",Str ":"] -, OrderedList (1,Decimal,Period) - [ [ Para [Str "First"] ] - , [ Para [Str "Second"] ] - , [ Para [Str "Third"] ] ] -, Para [Str "and",Space,Str "using",Space,Str "spaces",Str ":"] -, OrderedList (1,Decimal,Period) - [ [ Para [Str "One"] ] - , [ Para [Str "Two"] ] - , [ Para [Str "Three"] ] ] -, Para [Str "Multiple",Space,Str "paragraphs",Str ":"] -, OrderedList (1,Decimal,Period) - [ [ 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's",Space,Str "back."] ], [ Para [Str "Item",Space,Str "2."] ] - , [ Para [Str "Item",Space,Str "3."] ] ] -, Para [Str "Nested",Str ":"] -, BulletList - [ [ Para [Str "Tab"] - , BulletList - [ [ Para [Str "Tab"] - , BulletList - [ [ Plain [Str "Tab"] ] - ] ] ] ] ] -, Para [Str "Here's",Space,Str "another",Str ":"] -, OrderedList (1,Decimal,Period) - [ [ Para [Str "First"] ] - , [ Para [Str "Second",Str ":"] - , BlockQuote - [ BulletList - [ [ Plain [Str "Fee"] ] - , [ Plain [Str "Fie"] ] - , [ Plain [Str "Foe"] ] ] ] ], [ Para [Str "Third"] ] ] -, 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"] - , 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,",Space,Str "starting",Space,Str "with",Space,Str "4"] ] - , [ Para [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 ":"] -, OrderedList (1,UpperAlpha,Period) - [ [ Para [Str "Upper",Space,Str "Alpha"] - , OrderedList (1,UpperRoman,Period) - [ [ 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 ":"] -, OrderedList (1,DefaultStyle,DefaultDelim) - [ [ Plain [Str "Autonumber."] ] - , [ Para [Str "More."] - , OrderedList (1,DefaultStyle,DefaultDelim) - [ [ Plain [Str "Nested."] ] - ] ] ] -, Para [Str "Autonumbering",Space,Str "with",Space,Str "explicit",Space,Str "start",Str ":"] -, OrderedList (4,LowerAlpha,TwoParens) - [ [ Plain [Str "item",Space,Str "1"] ] - , [ Plain [Str "item",Space,Str "2"] ] ] -, Header 2 [Str "Definition"] -, DefinitionList - [ ([Str "term",Space,Str "1"], - [ [ Para [Str "Definition",Space,Str "1."] ] - ]) - , ([Str "term",Space,Str "2"], - [ [ 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."] ] - ]) ] -, Header 1 [Str "Field",Space,Str "Lists"] -, DefinitionList - [ ([Str "address"], - [ [ Plain [Str "61",Space,Str "Main",Space,Str "St."] ] - ]) - , ([Str "city"], - [ [ Plain [Emph [Str "Nowhere"],Str ",",Space,Str "MA,",Space,Str "USA"] ] - ]) - , ([Str "phone"], - [ [ Plain [Str "123",Str "-",Str "4567"] ] - ]) ] -, DefinitionList - [ ([Str "address"], - [ [ Plain [Str "61",Space,Str "Main",Space,Str "St."] ] - ]) - , ([Str "city"], - [ [ Plain [Emph [Str "Nowhere"],Str ",",Space,Str "MA,",Space,Str "USA"] ] - ]) - , ([Str "phone"], - [ [ Plain [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 ":"] -, RawHtml "
      foo
      \n" -, Para [Str "Now,",Space,Str "nested",Str ":"] -, RawHtml "
      \n
      \n
      \n foo\n
      \n
      \n
      \n" -, Header 1 [Str "LaTeX",Space,Str "Block"] -, Para [TeX "\\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 "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 "",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 ":"] -, 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."] -, 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",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."] -, Para [Str "Here'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'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 ":"] -, CodeBlock ("",[],[]) "http://example.com/" -, Header 1 [Str "Images"] -, Para [Str "From",Space,Str "\"Voyage",Space,Str "dans",Space,Str "la",Space,Str "Lune\"",Space,Str "by",Space,Str "Georges",Space,Str "Melies",Space,Str "(1902)",Str ":"] -, Plain [Image [Str "image"] ("lalune.jpg","")] -, Plain [Image [Str "Voyage dans la Lune"] ("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."] -, 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"] -, Table [] [AlignDefault,AlignDefault,AlignDefault] [0.0,0.0,0.0] - [ [ Plain [Str "col",Space,Str "1"] ] - , [ Plain [Str "col",Space,Str "2"] ] - , [ Plain [Str "col",Space,Str "3"] ] ] [ - [ [ Plain [Str "r1",Space,Str "a"] ] - , [ Plain [Str "b"] ] - , [ Plain [Str "c"] ] ], - [ [ Plain [Str "r2",Space,Str "d"] ] - , [ Plain [Str "e"] ] - , [ Plain [Str "f"] ] ] ] -, Para [Str "Headless"] -, Table [] [AlignDefault,AlignDefault,AlignDefault] [0.0,0.0,0.0] - [ [] - , [] - , [] ] [ - [ [ Plain [Str "r1",Space,Str "a"] ] - , [ Plain [Str "b"] ] - , [ Plain [Str "c"] ] ], - [ [ Plain [Str "r2",Space,Str "d"] ] - , [ Plain [Str "e"] ] - , [ Plain [Str "f"] ] ] ] -, 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"] ] - , [ Plain [Str "col",Space,Str "3"] ] ] [ - [ [ Plain [Str "r1",Space,Str "a",Space,Str "r1",Space,Str "bis"] ] - , [ Plain [Str "b",Space,Str "b",Space,Str "2"] ] - , [ Plain [Str "c",Space,Str "c",Space,Str "2"] ] ], - [ [ Plain [Str "r2",Space,Str "d"] ] - , [ Plain [Str "e"] ] - , [ Plain [Str "f"] ] ] ] -, Para [Str "Headless"] -, Table [] [AlignDefault,AlignDefault,AlignDefault] [0.2375,0.15,0.1625] - [ [] - , [] - , [] ] [ - [ [ Plain [Str "r1",Space,Str "a",Space,Str "r1",Space,Str "bis"] ] - , [ Plain [Str "b",Space,Str "b",Space,Str "2"] ] - , [ Plain [Str "c",Space,Str "c",Space,Str "2"] ] ], - [ [ Plain [Str "r2",Space,Str "d"] ] - , [ Plain [Str "e"] ] - , [ Plain [Str "f"] ] ] ] -, Para [Str "Spaces",Space,Str "at",Space,Str "ends",Space,Str "of",Space,Str "lines"] -, Table [] [AlignDefault,AlignDefault,AlignDefault] [0.2375,0.15,0.1625] - [ [] - , [] - , [] ] [ - [ [ Plain [Str "r1",Space,Str "a",Space,Str "r1",Space,Str "bis"] ] - , [ Plain [Str "b",Space,Str "b",Space,Str "2"] ] - , [ Plain [Str "c",Space,Str "c",Space,Str "2"] ] ], - [ [ Plain [Str "r2",Space,Str "d"] ] - , [ Plain [Str "e"] ] - , [ Plain [Str "f"] ] ] ] -, Para [Str "Multiple",Space,Str "blocks",Space,Str "in",Space,Str "a",Space,Str "cell"] -, Table [] [AlignDefault,AlignDefault,AlignDefault] [0.2375,0.15,0.1625] - [ [] - , [] - , [] ] [ - [ [ Para [Str "r1",Space,Str "a"] - , Para [Str "r1",Space,Str "bis"] ], [ BulletList - [ [ Plain [Str "b"] ] - , [ 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"] ] ] ] ] - +[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",Apostrophe,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",Apostrophe,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",Apostrophe,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 ":"] +,HorizontalRule +,Para [Str "Another",Str ":"] +,HorizontalRule +,Header 1 [Str "Block",Space,Str "Quotes"] +,Para [Str "Here",Apostrophe,Str "s",Space,Str "a",Space,Str "block",Space,Str "quote",Str ":"] +,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",Apostrophe,Str "s",Space,Str "another,",Space,Str "differently",Space,Str "indented",Str ":"] +,BlockQuote + [Para [Str "This",Space,Str "is",Space,Str "a",Space,Str "block",Space,Str "quote",Str ".",Space,Str "It",Apostrophe,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 ":"] + ,CodeBlock ("",[],[]) "sub status {\n print \"working\";\n}" + ,Para [Str "List",Space,Str "in",Space,Str "a",Space,Str "block",Space,Str "quote",Str ":"] + ,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 ":"] + ,BlockQuote + [Para [Str "nested"] + ,BlockQuote + [Para [Str "nested"]]]] +,Header 1 [Str "Code",Space,Str "Blocks"] +,Para [Str "Code",Str ":"] +,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 ":"] +,CodeBlock ("",[],[]) "this block is indented by two tabs\n\nThese should not be escaped: \\$ \\\\ \\> \\[ \\{" +,Para [Str "And",Str ":"] +,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 ":"] +,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 ":"] +,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 ":"] +,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 ":"] +,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 ":"] +,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 ":"] +,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 ":"] +,OrderedList (1,Decimal,Period) + [[Plain [Str "First"]] + ,[Plain [Str "Second"]] + ,[Plain [Str "Third"]]] +,Para [Str "and",Str ":"] +,OrderedList (1,Decimal,Period) + [[Plain [Str "One"]] + ,[Plain [Str "Two"]] + ,[Plain [Str "Three"]]] +,Para [Str "Loose",Space,Str "using",Space,Str "tabs",Str ":"] +,OrderedList (1,Decimal,Period) + [[Para [Str "First"]] + ,[Para [Str "Second"]] + ,[Para [Str "Third"]]] +,Para [Str "and",Space,Str "using",Space,Str "spaces",Str ":"] +,OrderedList (1,Decimal,Period) + [[Para [Str "One"]] + ,[Para [Str "Two"]] + ,[Para [Str "Three"]]] +,Para [Str "Multiple",Space,Str "paragraphs",Str ":"] +,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",Apostrophe,Str "s",Space,Str "back",Str "."]] + ,[Para [Str "Item",Space,Str "2",Str "."]] + ,[Para [Str "Item",Space,Str "3",Str "."]]] +,Para [Str "Nested",Str ":"] +,BulletList + [[Para [Str "Tab"] + ,BulletList + [[Para [Str "Tab"] + ,BulletList + [[Plain [Str "Tab"]]]]]]] +,Para [Str "Here",Apostrophe,Str "s",Space,Str "another",Str ":"] +,OrderedList (1,Decimal,Period) + [[Para [Str "First"]] + ,[Para [Str "Second",Str ":"] + ,BlockQuote + [BulletList + [[Plain [Str "Fee"]] + ,[Plain [Str "Fie"]] + ,[Plain [Str "Foe"]]]]] + ,[Para [Str "Third"]]] +,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"] + ,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,",Space,Str "starting",Space,Str "with",Space,Str "4"]] + ,[Para [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 ":"] +,OrderedList (1,UpperAlpha,Period) + [[Para [Str "Upper",Space,Str "Alpha"] + ,OrderedList (1,UpperRoman,Period) + [[Para [Str "Upper",Space,Str "Roman",Str "."] + ,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 ":"] +,OrderedList (1,DefaultStyle,DefaultDelim) + [[Plain [Str "Autonumber",Str "."]] + ,[Para [Str "More",Str "."] + ,OrderedList (1,DefaultStyle,DefaultDelim) + [[Plain [Str "Nested",Str "."]]]]] +,Para [Str "Autonumbering",Space,Str "with",Space,Str "explicit",Space,Str "start",Str ":"] +,OrderedList (4,LowerAlpha,TwoParens) + [[Plain [Str "item",Space,Str "1"]] + ,[Plain [Str "item",Space,Str "2"]]] +,Header 2 [Str "Definition"] +,DefinitionList + [([Str "term",Space,Str "1"], + [[Para [Str "Definition",Space,Str "1",Str "."]]]) + ,([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 "."]]]) + ,([Str "term",Space,Str "with",Space,Emph [Str "emphasis"]], + [[Para [Str "Definition",Space,Str "3",Str "."]]])] +,Header 1 [Str "Field",Space,Str "Lists"] +,BlockQuote + [DefinitionList + [([Str "address"], + [[Para [Str "61",Space,Str "Main",Space,Str "St",Str "."]]]) + ,([Str "city"], + [[Para [Emph [Str "Nowhere"],Str ",",Space,Str "MA,",Space,Str "USA"]]]) + ,([Str "phone"], + [[Para [Str "123",EnDash,Str "4567"]]])]] +,DefinitionList + [([Str "address"], + [[Para [Str "61",Space,Str "Main",Space,Str "St",Str "."]]]) + ,([Str "city"], + [[Para [Emph [Str "Nowhere"],Str ",",Space,Str "MA,",Space,Str "USA"]]]) + ,([Str "phone"], + [[Para [Str "123",EnDash,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" "
      foo
      \n" +,Para [Str "Now,",Space,Str "nested",Str ":"] +,RawBlock "html" "
      \n
      \n
      \n foo\n
      \n
      \n
      \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 "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 ("",[],[]) "",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 ":"] +,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",Apostrophe,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",Apostrophe,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 ":"] +,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 "(1902)",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"] +,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"] +,Table [] [AlignDefault,AlignDefault,AlignDefault] [0.0,0.0,0.0] + [[Plain [Str "col",Space,Str "1"]] + ,[Plain [Str "col",Space,Str "2"]] + ,[Plain [Str "col",Space,Str "3"]]] + [[[Plain [Str "r1",Space,Str "a"]] + ,[Plain [Str "b"]] + ,[Plain [Str "c"]]] + ,[[Plain [Str "r2",Space,Str "d"]] + ,[Plain [Str "e"]] + ,[Plain [Str "f"]]]] +,Para [Str "Headless"] +,Table [] [AlignDefault,AlignDefault,AlignDefault] [0.0,0.0,0.0] + [[] + ,[] + ,[]] + [[[Plain [Str "r1",Space,Str "a"]] + ,[Plain [Str "b"]] + ,[Plain [Str "c"]]] + ,[[Plain [Str "r2",Space,Str "d"]] + ,[Plain [Str "e"]] + ,[Plain [Str "f"]]]] +,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"]] + ,[Plain [Str "col",Space,Str "3"]]] + [[[Plain [Str "r1",Space,Str "a",Space,Str "r1",Space,Str "bis"]] + ,[Plain [Str "b",Space,Str "b",Space,Str "2"]] + ,[Plain [Str "c",Space,Str "c",Space,Str "2"]]] + ,[[Plain [Str "r2",Space,Str "d"]] + ,[Plain [Str "e"]] + ,[Plain [Str "f"]]]] +,Para [Str "Headless"] +,Table [] [AlignDefault,AlignDefault,AlignDefault] [0.2375,0.15,0.1625] + [[] + ,[] + ,[]] + [[[Plain [Str "r1",Space,Str "a",Space,Str "r1",Space,Str "bis"]] + ,[Plain [Str "b",Space,Str "b",Space,Str "2"]] + ,[Plain [Str "c",Space,Str "c",Space,Str "2"]]] + ,[[Plain [Str "r2",Space,Str "d"]] + ,[Plain [Str "e"]] + ,[Plain [Str "f"]]]] +,Para [Str "Spaces",Space,Str "at",Space,Str "ends",Space,Str "of",Space,Str "lines"] +,Table [] [AlignDefault,AlignDefault,AlignDefault] [0.2375,0.15,0.1625] + [[] + ,[] + ,[]] + [[[Plain [Str "r1",Space,Str "a",Space,Str "r1",Space,Str "bis"]] + ,[Plain [Str "b",Space,Str "b",Space,Str "2"]] + ,[Plain [Str "c",Space,Str "c",Space,Str "2"]]] + ,[[Plain [Str "r2",Space,Str "d"]] + ,[Plain [Str "e"]] + ,[Plain [Str "f"]]]] +,Para [Str "Multiple",Space,Str "blocks",Space,Str "in",Space,Str "a",Space,Str "cell"] +,Table [] [AlignDefault,AlignDefault,AlignDefault] [0.2375,0.15,0.1625] + [[] + ,[] + ,[]] + [[[Para [Str "r1",Space,Str "a"] + ,Para [Str "r1",Space,Str "bis"]] + ,[BulletList + [[Plain [Str "b"]] + ,[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 "."]] diff -Nru pandoc-1.5.1.1/tests/rst-reader.rst pandoc-1.8.0.3/tests/rst-reader.rst --- pandoc-1.5.1.1/tests/rst-reader.rst 2010-03-29 14:24:56.000000000 +0000 +++ pandoc-1.8.0.3/tests/rst-reader.rst 2011-02-05 18:48:07.000000000 +0000 @@ -508,3 +508,31 @@ | | - b 2 | c 2 | | r1 bis | - b 2 | c 2 | +------------------+-----------+------------+ + +Footnotes +========= + +[1]_ + +[#]_ + +[#]_ + +[*]_ + +.. [1] Note with one line. + +.. [#] Note with + continuation line. + +.. [#] Note with + + continuation block. + +.. [*] Note with + continuation line + + and a second para. + +Not in note. + diff -Nru pandoc-1.5.1.1/tests/RunTests.hs pandoc-1.8.0.3/tests/RunTests.hs --- pandoc-1.5.1.1/tests/RunTests.hs 2010-03-29 14:24:56.000000000 +0000 +++ pandoc-1.8.0.3/tests/RunTests.hs 1970-01-01 00:00:00.000000000 +0000 @@ -1,178 +0,0 @@ -{-# OPTIONS_GHC -Wall #-} --- RunTests.hs - run test suite for pandoc --- This script is designed to be run from the tests directory. --- It assumes the pandoc executable is in dist/build/pandoc. --- --- runhaskell -i.. RunTests.hs [lhs] --- --- If the lhs argument is provided, tests for lhs support will be --- run. These presuppose that pandoc has been compiled with the --- -fhighlighting flag, so these tests are not run by default. --- --- This program assumes that the Diff package has been installed: --- cabal install Diff - -module Main where -import System.IO.UTF8 -import System.IO ( openTempFile, stderr, stdout, hFlush ) -import Prelude hiding ( putStrLn, putStr, readFile ) -import System.Process ( runProcess, waitForProcess ) -import System.FilePath ( (), (<.>) ) -import System.Directory -import System.Environment -import System.Exit -import Text.Printf -import Data.Algorithm.Diff - -pandocPath :: FilePath -pandocPath = ".." "dist" "build" "pandoc" "pandoc" - -data TestResult = TestPassed - | TestError ExitCode - | TestFailed [(DI, String)] - deriving (Eq) - -instance Show TestResult where - show TestPassed = "PASSED" - show (TestError ec) = "ERROR " ++ show ec - show (TestFailed d) = "FAILED\n" ++ showDiff d - -showDiff :: [(DI, String)] -> String -showDiff [] = "" -showDiff ((F, ln) : ds) = "|TEST| " ++ ln ++ "\n" ++ showDiff ds -showDiff ((S, ln) : ds) = "|NORM| " ++ ln ++ "\n" ++ showDiff ds -showDiff ((B, _ ) : ds) = showDiff ds - -writerFormats :: [String] -writerFormats = [ "native" - , "html" - , "docbook" - , "opendocument" - , "latex" - , "context" - , "texinfo" - , "man" - , "plain" - , "markdown" - , "rst" - , "mediawiki" - , "rtf" - ] - -lhsWriterFormats :: [String] -lhsWriterFormats = [ "markdown" - , "markdown+lhs" - , "rst" - , "rst+lhs" - , "latex" - , "latex+lhs" - , "html" - , "html+lhs" - ] - -lhsReaderFormats :: [String] -lhsReaderFormats = [ "markdown+lhs" - , "rst+lhs" - , "latex+lhs" - ] - -main :: IO () -main = do - args <- getArgs - let runLhsTests = "lhs" `elem` args - r1s <- mapM runWriterTest writerFormats - r2 <- runS5WriterTest "basic" ["-s"] "s5" - r3 <- runS5WriterTest "fancy" ["-s","-m","-i"] "s5" - r4 <- runS5WriterTest "fragment" [] "html" - r5 <- runS5WriterTest "inserts" ["-s", "-H", "insert", - "-B", "insert", "-A", "insert", "-c", "main.css"] "html" - r6 <- runTest "markdown reader" ["-r", "markdown", "-w", "native", "-s", "-S"] - "testsuite.txt" "testsuite.native" - r7 <- runTest "markdown reader (tables)" ["-r", "markdown", "-w", "native"] - "tables.txt" "tables.native" - r7a <- runTest "markdown reader (more)" ["-r", "markdown", "-w", "native"] - "markdown-reader-more.txt" "markdown-reader-more.native" - r8 <- runTest "rst reader" ["-r", "rst", "-w", "native", "-s", "-S"] - "rst-reader.rst" "rst-reader.native" - r8a <- runTest "rst reader (tables)" ["-r", "rst", "-w", "native"] - "tables.rst" "tables-rstsubset.native" - r9 <- runTest "html reader" ["-r", "html", "-w", "native", "-s"] - "html-reader.html" "html-reader.native" - r10 <- runTest "latex reader" ["-r", "latex", "-w", "native", "-s", "-R"] - "latex-reader.latex" "latex-reader.native" - r11 <- runTest "native reader" ["-r", "native", "-w", "native", "-s"] - "testsuite.native" "testsuite.native" - r12s <- if runLhsTests - then mapM runLhsWriterTest lhsWriterFormats - else putStrLn "Skipping lhs writer tests because they presuppose highlighting support" >> return [] - r13s <- if runLhsTests - then mapM runLhsReaderTest lhsReaderFormats - else putStrLn "Skipping lhs reader tests because they presuppose highlighting support" >> return [] - let results = r1s ++ - [ r2, r3, r4, r5 -- S5 - , r6, r7, r7a -- markdown reader - , r8, r8a -- rst - , r9 -- html - , r10 -- latex - , r11 -- native - ] ++ r12s ++ r13s - if all id results - then do - putStrLn "\nAll tests passed." - exitWith ExitSuccess - else do - let failures = length $ filter not results - putStrLn $ "\n" ++ show failures ++ " tests failed." - exitWith (ExitFailure failures) - --- makes sure file is fully closed after reading -readFile' :: FilePath -> IO String -readFile' f = do s <- readFile f - return $! (length s `seq` s) - -runLhsWriterTest :: String -> IO Bool -runLhsWriterTest format = - runTest ("(lhs) " ++ format ++ " writer") ["-r", "native", "-s", "-w", format] "lhs-test.native" ("lhs-test" <.> format) - -runLhsReaderTest :: String -> IO Bool -runLhsReaderTest format = - runTest ("(lhs) " ++ format ++ " reader") ["-r", format, "-w", "html+lhs"] ("lhs-test" <.> format) "lhs-test.fragment.html+lhs" - -runWriterTest :: String -> IO Bool -runWriterTest format = do - r1 <- runTest (format ++ " writer") ["-r", "native", "-s", "-w", format] "testsuite.native" ("writer" <.> format) - r2 <- runTest (format ++ " writer (tables)") ["-r", "native", "-w", format] "tables.native" ("tables" <.> format) - return (r1 && r2) - -runS5WriterTest :: String -> [String] -> String -> IO Bool -runS5WriterTest modifier opts format = runTest (format ++ " writer (" ++ modifier ++ ")") - (["-r", "native", "-w", format] ++ opts) "s5.native" ("s5." ++ modifier <.> "html") - --- | Run a test, return True if test passed. -runTest :: String -- ^ Title of test - -> [String] -- ^ Options to pass to pandoc - -> String -- ^ Input filepath - -> FilePath -- ^ Norm (for test results) filepath - -> IO Bool -runTest testname opts inp norm = do - putStr $ printf "%-28s ---> " testname - (outputPath, hOut) <- openTempFile "" "pandoc-test" - let inpPath = inp - let normPath = norm - hFlush stdout - -- Note: COLUMNS must be set for markdown table reader - -- and we need LANG set for ghc 6.12 - ph <- runProcess pandocPath (opts ++ [inpPath] ++ ["--data-dir", ".."]) Nothing (Just [("COLUMNS", "80"),("LANG","en_US.UTF-8")]) Nothing (Just hOut) (Just stderr) - ec <- waitForProcess ph - result <- if ec == ExitSuccess - then do - -- filter \r so the tests will work on Windows machines - outputContents <- readFile' outputPath >>= return . filter (/='\r') - normContents <- readFile' normPath >>= return . filter (/='\r') - if outputContents == normContents - then return TestPassed - else return $ TestFailed $ getDiff (lines outputContents) (lines normContents) - else return $ TestError ec - removeFile outputPath - putStrLn (show result) - return (result == TestPassed) diff -Nru pandoc-1.5.1.1/tests/s5.basic.html pandoc-1.8.0.3/tests/s5.basic.html --- pandoc-1.5.1.1/tests/s5.basic.html 2010-03-29 14:24:56.000000000 +0000 +++ pandoc-1.8.0.3/tests/s5.basic.html 2011-02-05 18:48:07.000000000 +0000 @@ -1,343 +1,55 @@ - My S5 Document + My S5 Document - - - - - + + + + + + + -

      My S5 Document

      +

      July 15, 2006

      +

      My S5 Document

      +
-
-

My S5 Document

Sam Smith
Jen Jones

July 15, 2006

+

My S5 Document

+

Sam Smith
Jen Jones

+

July 15, 2006

+
-

First slide

  • first bullet
  • second bullet
+ +

First slide

+
    +
  • first bullet
  • +
  • second bullet
  • +
+
+
-

Math

  • \frac{d}{dx}f(x)=\limh → 0\frac{f(x+h)-f(x)}{h}
+ +

Math

+
    +
  • $\frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}$
  • +
+
- diff -Nru pandoc-1.5.1.1/tests/s5.fancy.html pandoc-1.8.0.3/tests/s5.fancy.html --- pandoc-1.5.1.1/tests/s5.fancy.html 2010-03-29 14:24:56.000000000 +0000 +++ pandoc-1.8.0.3/tests/s5.fancy.html 2011-02-05 18:48:07.000000000 +0000 @@ -1,14 +1,23 @@ - My S5 Document - + - - - - - - - - -

My S5 Document

+

July 15, 2006

+

My S5 Document

+
-
-

My S5 Document

Sam Smith
Jen Jones

July 15, 2006

+

My S5 Document

+

Sam Smith
Jen Jones

+

July 15, 2006

+
-

First slide

  • first bullet
  • second bullet
+ +

First slide

+
    +
  • first bullet
  • +
  • second bullet
  • +
+ +
-

Math

  • $\frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}$
+ +

Math

+
    +
  • $\frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}$
  • +
+ - diff -Nru pandoc-1.5.1.1/tests/s5.fragment.html pandoc-1.8.0.3/tests/s5.fragment.html --- pandoc-1.5.1.1/tests/s5.fragment.html 2010-03-29 14:24:56.000000000 +0000 +++ pandoc-1.8.0.3/tests/s5.fragment.html 2011-02-05 18:48:07.000000000 +0000 @@ -1,45 +1,9 @@ -

First slide

  • first bullet
  • second bullet

Math

  • \frac{d}{dx}f(x)=\limh → 0\frac{f(x+h)-f(x)}{h}
+

First slide

+
    +
  • first bullet
  • +
  • second bullet
  • +
+

Math

+
    +
  • $\frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}$
  • +
diff -Nru pandoc-1.5.1.1/tests/s5.inserts.html pandoc-1.8.0.3/tests/s5.inserts.html --- pandoc-1.5.1.1/tests/s5.inserts.html 2010-03-29 14:24:56.000000000 +0000 +++ pandoc-1.8.0.3/tests/s5.inserts.html 2011-02-05 18:48:07.000000000 +0000 @@ -1,64 +1,27 @@ - My S5 Document + My S5 Document STUFF INSERTED -

My S5 Document

STUFF INSERTED -

First slide

  • first bullet
  • second bullet

Math

  • \frac{d}{dx}f(x)=\limh → 0\frac{f(x+h)-f(x)}{h}
+

My S5 Document

+

First slide

+
    +
  • first bullet
  • +
  • second bullet
  • +
+

Math

+
    +
  • $\frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}$
  • +
STUFF INSERTED - diff -Nru pandoc-1.5.1.1/tests/s5.native pandoc-1.8.0.3/tests/s5.native --- pandoc-1.5.1.1/tests/s5.native 2010-03-29 14:24:56.000000000 +0000 +++ pandoc-1.8.0.3/tests/s5.native 2011-02-05 18:48:07.000000000 +0000 @@ -1,9 +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"] -, BulletList - [ [ Plain [Str "first",Space,Str "bullet"] ] - , [ Plain [Str "second",Space,Str "bullet"] ] ] -, Header 1 [Str "Math"] -, BulletList - [ [ Plain [Math InlineMath "\\frac{d}{dx}f(x)=\\lim_{h\\to 0}\\frac{f(x+h)-f(x)}{h}"] ] - ] ] +[Header 1 [Str "First",Space,Str "slide"] +,BulletList + [[Plain [Str "first",Space,Str "bullet"]] + ,[Plain [Str "second",Space,Str "bullet"]]] +,Header 1 [Str "Math"] +,BulletList + [[Plain [Math InlineMath "\\frac{d}{dx}f(x)=\\lim_{h\\to 0}\\frac{f(x+h)-f(x)}{h}"]]]] diff -Nru pandoc-1.5.1.1/tests/tables.html pandoc-1.8.0.3/tests/tables.html --- pandoc-1.5.1.1/tests/tables.html 2010-03-29 14:24:56.000000000 +0000 +++ pandoc-1.8.0.3/tests/tables.html 2011-02-05 18:48:07.000000000 +0000 @@ -1,301 +1,198 @@ -

Simple table with caption:

Demonstration of simple table syntax.
RightLeftCenterDefault
12121212
123123123123
1111

Simple table without caption:

RightLeftCenterDefault
12121212
123123123123
1111

Simple table indented two spaces:

Demonstration of simple table syntax.
RightLeftCenterDefault
12121212
123123123123
1111

Multiline table with caption:

Here's the caption. It may span multiple lines.
Centered HeaderLeft AlignedRight AlignedDefault aligned
Firstrow12.0Example of a row that spans multiple lines.
Secondrow5.0Here's another one. Note the blank line between rows.

Multiline table without caption:

Centered HeaderLeft AlignedRight AlignedDefault aligned
Firstrow12.0Example of a row that spans multiple lines.
Secondrow5.0Here's another one. Note the blank line between rows.

Table without column headers:

12121212
123123123123
1111

Multiline table without column headers:

Firstrow12.0Example of a row that spans multiple lines.
Secondrow5.0Here's another one. Note the blank line between rows.
+

Simple table with caption:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Demonstration of simple table syntax.
RightLeftCenterDefault
12121212
123123123123
1111
+

Simple table without caption:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
RightLeftCenterDefault
12121212
123123123123
1111
+

Simple table indented two spaces:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Demonstration of simple table syntax.
RightLeftCenterDefault
12121212
123123123123
1111
+

Multiline table with caption:

+ + +++++ + + + + + + + + + + + + + + + + + + + + + +
Here's the caption. It may span multiple lines.
Centered HeaderLeft AlignedRight AlignedDefault aligned
Firstrow12.0Example of a row that spans multiple lines.
Secondrow5.0Here's another one. Note the blank line between rows.
+

Multiline table without caption:

+ +++++ + + + + + + + + + + + + + + + + + + + + + +
Centered HeaderLeft AlignedRight AlignedDefault aligned
Firstrow12.0Example of a row that spans multiple lines.
Secondrow5.0Here's another one. Note the blank line between rows.
+

Table without column headers:

+ + + + + + + + + + + + + + + + + + + + + +
12121212
123123123123
1111
+

Multiline table without column headers:

+ +++++ + + + + + + + + + + + + + +
Firstrow12.0Example of a row that spans multiple lines.
Secondrow5.0Here's another one. Note the blank line between rows.
diff -Nru pandoc-1.5.1.1/tests/tables.latex pandoc-1.8.0.3/tests/tables.latex --- pandoc-1.5.1.1/tests/tables.latex 2010-03-29 14:24:56.000000000 +0000 +++ pandoc-1.8.0.3/tests/tables.latex 2011-02-05 18:48:07.000000000 +0000 @@ -3,27 +3,11 @@ \begin{table}[h] \begin{center} \begin{tabular}{rlcl} -Right - & Left - & Center - & Default -\\ +Right & Left & Center & Default\\ \hline -12 - & 12 - & 12 - & 12 -\\ -123 - & 123 - & 123 - & 123 -\\ -1 - & 1 - & 1 - & 1 -\\ +12 & 12 & 12 & 12\\ +123 & 123 & 123 & 123\\ +1 & 1 & 1 & 1\\ \end{tabular} \end{center} \caption{Demonstration of simple table syntax.} @@ -33,27 +17,11 @@ \begin{center} \begin{tabular}{rlcl} -Right - & Left - & Center - & Default -\\ +Right & Left & Center & Default\\ \hline -12 - & 12 - & 12 - & 12 -\\ -123 - & 123 - & 123 - & 123 -\\ -1 - & 1 - & 1 - & 1 -\\ +12 & 12 & 12 & 12\\ +123 & 123 & 123 & 123\\ +1 & 1 & 1 & 1\\ \end{tabular} \end{center} @@ -62,27 +30,11 @@ \begin{table}[h] \begin{center} \begin{tabular}{rlcl} -Right - & Left - & Center - & Default -\\ +Right & Left & Center & Default\\ \hline -12 - & 12 - & 12 - & 12 -\\ -123 - & 123 - & 123 - & 123 -\\ -1 - & 1 - & 1 - & 1 -\\ +12 & 12 & 12 & 12\\ +123 & 123 & 123 & 123\\ +1 & 1 & 1 & 1\\ \end{tabular} \end{center} \caption{Demonstration of simple table syntax.} @@ -93,22 +45,23 @@ \begin{table}[h] \begin{center} \begin{tabular}{>{\PBS\centering\hspace{0pt}}p{0.15\columnwidth}>{\PBS\raggedright\hspace{0pt}}p{0.14\columnwidth}>{\PBS\raggedleft\hspace{0pt}}p{0.16\columnwidth}>{\PBS\raggedright\hspace{0pt}}p{0.34\columnwidth}} -Centered Header - & Left Aligned - & Right Aligned - & Default aligned -\\ +\parbox{0.15\columnwidth}{Centered Header +} & \parbox{0.14\columnwidth}{Left Aligned +} & \parbox{0.16\columnwidth}{Right Aligned +} & \parbox{0.34\columnwidth}{Default aligned +}\\ \hline -First - & row - & 12.0 - & Example of a row that spans multiple lines. -\\ -Second - & row - & 5.0 - & Here's another one. Note the blank line between rows. -\\ +\parbox{0.15\columnwidth}{First +} & \parbox{0.14\columnwidth}{row +} & \parbox{0.16\columnwidth}{12.0 +} & \parbox{0.34\columnwidth}{Example of a row that spans multiple lines. +}\\ +\parbox{0.15\columnwidth}{Second +} & \parbox{0.14\columnwidth}{row +} & \parbox{0.16\columnwidth}{5.0 +} & \parbox{0.34\columnwidth}{Here's another one. Note the blank line between +rows. +}\\ \end{tabular} \end{center} \caption{Here's the caption. It may span multiple lines.} @@ -118,22 +71,23 @@ \begin{center} \begin{tabular}{>{\PBS\centering\hspace{0pt}}p{0.15\columnwidth}>{\PBS\raggedright\hspace{0pt}}p{0.14\columnwidth}>{\PBS\raggedleft\hspace{0pt}}p{0.16\columnwidth}>{\PBS\raggedright\hspace{0pt}}p{0.34\columnwidth}} -Centered Header - & Left Aligned - & Right Aligned - & Default aligned -\\ +\parbox{0.15\columnwidth}{Centered Header +} & \parbox{0.14\columnwidth}{Left Aligned +} & \parbox{0.16\columnwidth}{Right Aligned +} & \parbox{0.34\columnwidth}{Default aligned +}\\ \hline -First - & row - & 12.0 - & Example of a row that spans multiple lines. -\\ -Second - & row - & 5.0 - & Here's another one. Note the blank line between rows. -\\ +\parbox{0.15\columnwidth}{First +} & \parbox{0.14\columnwidth}{row +} & \parbox{0.16\columnwidth}{12.0 +} & \parbox{0.34\columnwidth}{Example of a row that spans multiple lines. +}\\ +\parbox{0.15\columnwidth}{Second +} & \parbox{0.14\columnwidth}{row +} & \parbox{0.16\columnwidth}{5.0 +} & \parbox{0.34\columnwidth}{Here's another one. Note the blank line between +rows. +}\\ \end{tabular} \end{center} @@ -141,21 +95,9 @@ \begin{center} \begin{tabular}{rlcr} -12 - & 12 - & 12 - & 12 -\\ -123 - & 123 - & 123 - & 123 -\\ -1 - & 1 - & 1 - & 1 -\\ +12 & 12 & 12 & 12\\ +123 & 123 & 123 & 123\\ +1 & 1 & 1 & 1\\ \end{tabular} \end{center} @@ -163,16 +105,17 @@ \begin{center} \begin{tabular}{>{\PBS\centering\hspace{0pt}}p{0.15\columnwidth}>{\PBS\raggedright\hspace{0pt}}p{0.14\columnwidth}>{\PBS\raggedleft\hspace{0pt}}p{0.16\columnwidth}>{\PBS\raggedright\hspace{0pt}}p{0.34\columnwidth}} -First - & row - & 12.0 - & Example of a row that spans multiple lines. -\\ -Second - & row - & 5.0 - & Here's another one. Note the blank line between rows. -\\ +\parbox{0.15\columnwidth}{First +} & \parbox{0.14\columnwidth}{row +} & \parbox{0.16\columnwidth}{12.0 +} & \parbox{0.34\columnwidth}{Example of a row that spans multiple lines. +}\\ +\parbox{0.15\columnwidth}{Second +} & \parbox{0.14\columnwidth}{row +} & \parbox{0.16\columnwidth}{5.0 +} & \parbox{0.34\columnwidth}{Here's another one. Note the blank line between +rows. +}\\ \end{tabular} \end{center} diff -Nru pandoc-1.5.1.1/tests/tables.markdown pandoc-1.8.0.3/tests/tables.markdown --- pandoc-1.5.1.1/tests/tables.markdown 2010-03-29 14:24:56.000000000 +0000 +++ pandoc-1.8.0.3/tests/tables.markdown 2011-02-05 18:48:07.000000000 +0000 @@ -5,8 +5,8 @@ 12 12 12 12 123 123 123 123 1 1 1 1 - - Table: Demonstration of simple table syntax. + + : Demonstration of simple table syntax. Simple table without caption: @@ -23,34 +23,34 @@ 12 12 12 12 123 123 123 123 1 1 1 1 - - Table: Demonstration of simple table syntax. + + : Demonstration of simple table syntax. Multiline table with caption: -------------------------------------------------------------- Centered Left Right Default aligned - Header Aligned Aligned + Header Aligned Aligned ----------- ---------- ------------ -------------------------- First row 12.0 Example of a row that spans multiple lines. - + Second row 5.0 Here's another one. Note the blank line between rows. -------------------------------------------------------------- - - Table: Here's the caption. It may span multiple lines. + + : Here's the caption. It may span multiple lines. Multiline table without caption: -------------------------------------------------------------- Centered Left Right Default aligned - Header Aligned Aligned + Header Aligned Aligned ----------- ---------- ------------ -------------------------- First row 12.0 Example of a row that spans multiple lines. - + Second row 5.0 Here's another one. Note the blank line between rows. @@ -69,11 +69,10 @@ ----------- ---------- ------------ -------------------------- First row 12.0 Example of a row that spans multiple lines. - + Second row 5.0 Here's another one. Note the blank line between rows. ----------- ---------- ------------ -------------------------- - diff -Nru pandoc-1.5.1.1/tests/tables.native pandoc-1.8.0.3/tests/tables.native --- pandoc-1.5.1.1/tests/tables.native 2010-03-29 14:24:56.000000000 +0000 +++ pandoc-1.8.0.3/tests/tables.native 2011-02-05 18:48:07.000000000 +0000 @@ -1,116 +1,114 @@ -Pandoc (Meta {docTitle = [], docAuthors = [], docDate = []}) -[ 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",Str "."] [AlignRight,AlignLeft,AlignCenter,AlignDefault] [0.0,0.0,0.0,0.0] - [ [ Plain [Str "Right"] ] - , [ Plain [Str "Left"] ] - , [ Plain [Str "Center"] ] - , [ Plain [Str "Default"] ] ] [ - [ [ 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,AlignDefault] [0.0,0.0,0.0,0.0] - [ [ Plain [Str "Right"] ] - , [ Plain [Str "Left"] ] - , [ Plain [Str "Center"] ] - , [ Plain [Str "Default"] ] ] [ - [ [ 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 "indented",Space,Str "two",Space,Str "spaces:"] -, 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] - [ [ Plain [Str "Right"] ] - , [ Plain [Str "Left"] ] - , [ Plain [Str "Center"] ] - , [ Plain [Str "Default"] ] ] [ - [ [ 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 "Multiline",Space,Str "table",Space,Str "with",Space,Str "caption:"] -, 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] - [ [ 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 "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:"] -, 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"] ] - , [ 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 "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:"] -, Table [] [AlignRight,AlignLeft,AlignCenter,AlignRight] [0.0,0.0,0.0,0.0] - [ [] - , [] - , [] - , [] ] [ - [ [ 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 "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] - [ [] - , [] - , [] - , [] ] [ - [ [ 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 "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 "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] + [[Plain [Str "Right"]] + ,[Plain [Str "Left"]] + ,[Plain [Str "Center"]] + ,[Plain [Str "Default"]]] + [[[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",Str ":"] +,Table [] [AlignRight,AlignLeft,AlignCenter,AlignDefault] [0.0,0.0,0.0,0.0] + [[Plain [Str "Right"]] + ,[Plain [Str "Left"]] + ,[Plain [Str "Center"]] + ,[Plain [Str "Default"]]] + [[[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 "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] + [[Plain [Str "Right"]] + ,[Plain [Str "Left"]] + ,[Plain [Str "Center"]] + ,[Plain [Str "Default"]]] + [[[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 "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] + [[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 "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 ":"] +,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"]] + ,[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 "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 ":"] +,Table [] [AlignRight,AlignLeft,AlignCenter,AlignRight] [0.0,0.0,0.0,0.0] + [[] + ,[] + ,[] + ,[]] + [[[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 "Multiline",Space,Str "table",Space,Str "without",Space,Str "column",Space,Str "headers",Str ":"] +,Table [] [AlignCenter,AlignLeft,AlignRight,AlignDefault] [0.15,0.1375,0.1625,0.3375] + [[] + ,[] + ,[] + ,[]] + [[[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 "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 "."]]]]] diff -Nru pandoc-1.5.1.1/tests/tables.opendocument pandoc-1.8.0.3/tests/tables.opendocument --- pandoc-1.5.1.1/tests/tables.opendocument 2010-03-29 14:24:56.000000000 +0000 +++ pandoc-1.8.0.3/tests/tables.opendocument 2011-02-05 18:48:07.000000000 +0000 @@ -63,7 +63,8 @@ -Demonstration of simple table syntax. +Demonstration of simple table +syntax. Simple table without caption: @@ -129,7 +130,8 @@ -Simple table indented two spaces: +Simple table indented two +spaces: @@ -194,7 +196,8 @@ -Demonstration of simple table syntax. +Demonstration of simple table +syntax. Multiline table with caption: @@ -228,7 +231,8 @@ 12.0 - Example of a row that spans multiple lines. + Example of a row that spans + multiple lines. @@ -242,12 +246,15 @@ 5.0 - Here's another one. Note the blank line between rows. + Here's another one. Note the + blank line between rows. -Here's the caption. It may span multiple lines. -Multiline table without caption: +Here's the caption. It may span multiple +lines. +Multiline table without +caption: @@ -280,7 +287,8 @@ 12.0 - Example of a row that spans multiple lines. + Example of a row that spans + multiple lines. @@ -294,7 +302,8 @@ 5.0 - Here's another one. Note the blank line between rows. + Here's another one. Note the + blank line between rows. @@ -347,7 +356,8 @@ -Multiline table without column headers: +Multiline table without column +headers: @@ -364,7 +374,8 @@ 12.0 - Example of a row that spans multiple lines. + Example of a row that spans + multiple lines. @@ -378,7 +389,8 @@ 5.0 - Here's another one. Note the blank line between rows. + Here's another one. Note the + blank line between rows. diff -Nru pandoc-1.5.1.1/tests/tables.org pandoc-1.8.0.3/tests/tables.org --- pandoc-1.5.1.1/tests/tables.org 1970-01-01 00:00:00.000000000 +0000 +++ pandoc-1.8.0.3/tests/tables.org 2011-02-05 18:48:07.000000000 +0000 @@ -0,0 +1,52 @@ +Simple table with caption: + +| Right | Left | Center | Default | +|---------+--------+----------+-----------| +| 12 | 12 | 12 | 12 | +| 123 | 123 | 123 | 123 | +| 1 | 1 | 1 | 1 | +#+CAPTION: Demonstration of simple table syntax. + +Simple table without caption: + +| Right | Left | Center | Default | +|---------+--------+----------+-----------| +| 12 | 12 | 12 | 12 | +| 123 | 123 | 123 | 123 | +| 1 | 1 | 1 | 1 | + +Simple table indented two spaces: + +| Right | Left | Center | Default | +|---------+--------+----------+-----------| +| 12 | 12 | 12 | 12 | +| 123 | 123 | 123 | 123 | +| 1 | 1 | 1 | 1 | +#+CAPTION: Demonstration of simple table syntax. + +Multiline table with caption: + +| Centered Header | Left Aligned | Right Aligned | Default aligned | +|-------------------+----------------+-----------------+---------------------------------------------------------| +| First | row | 12.0 | Example of a row that spans multiple lines. | +| Second | row | 5.0 | Here's another one. Note the blank line between rows. | +#+CAPTION: Here's the caption. It may span multiple lines. + +Multiline table without caption: + +| Centered Header | Left Aligned | Right Aligned | Default aligned | +|-------------------+----------------+-----------------+---------------------------------------------------------| +| First | row | 12.0 | Example of a row that spans multiple lines. | +| Second | row | 5.0 | Here's another one. Note the blank line between rows. | + +Table without column headers: + +| 12 | 12 | 12 | 12 | +| 123 | 123 | 123 | 123 | +| 1 | 1 | 1 | 1 | + +Multiline table without column headers: + +| First | row | 12.0 | Example of a row that spans multiple lines. | +| Second | row | 5.0 | Here's another one. Note the blank line between rows. | + diff -Nru pandoc-1.5.1.1/tests/tables.plain pandoc-1.8.0.3/tests/tables.plain --- pandoc-1.5.1.1/tests/tables.plain 2010-03-29 14:24:56.000000000 +0000 +++ pandoc-1.8.0.3/tests/tables.plain 2011-02-05 18:48:07.000000000 +0000 @@ -5,8 +5,8 @@ 12 12 12 12 123 123 123 123 1 1 1 1 - - Table: Demonstration of simple table syntax. + + : Demonstration of simple table syntax. Simple table without caption: @@ -23,34 +23,34 @@ 12 12 12 12 123 123 123 123 1 1 1 1 - - Table: Demonstration of simple table syntax. + + : Demonstration of simple table syntax. Multiline table with caption: -------------------------------------------------------------- Centered Left Right Default aligned - Header Aligned Aligned + Header Aligned Aligned ----------- ---------- ------------ -------------------------- First row 12.0 Example of a row that spans multiple lines. - + Second row 5.0 Here's another one. Note the blank line between rows. -------------------------------------------------------------- - - Table: Here's the caption. It may span multiple lines. + + : Here's the caption. It may span multiple lines. Multiline table without caption: -------------------------------------------------------------- Centered Left Right Default aligned - Header Aligned Aligned + Header Aligned Aligned ----------- ---------- ------------ -------------------------- First row 12.0 Example of a row that spans multiple lines. - + Second row 5.0 Here's another one. Note the blank line between rows. @@ -69,11 +69,10 @@ ----------- ---------- ------------ -------------------------- First row 12.0 Example of a row that spans multiple lines. - + Second row 5.0 Here's another one. Note the blank line between rows. ----------- ---------- ------------ -------------------------- - diff -Nru pandoc-1.5.1.1/tests/tables.rst pandoc-1.8.0.3/tests/tables.rst --- pandoc-1.5.1.1/tests/tables.rst 2010-03-29 14:24:56.000000000 +0000 +++ pandoc-1.8.0.3/tests/tables.rst 2011-02-05 18:48:07.000000000 +0000 @@ -89,4 +89,3 @@ | | | | rows. | +-------------+------------+--------------+----------------------------+ - diff -Nru pandoc-1.5.1.1/tests/tables-rstsubset.native pandoc-1.8.0.3/tests/tables-rstsubset.native --- pandoc-1.5.1.1/tests/tables-rstsubset.native 2010-03-29 14:24:56.000000000 +0000 +++ pandoc-1.8.0.3/tests/tables-rstsubset.native 2011-02-05 18:48:07.000000000 +0000 @@ -1,119 +1,117 @@ -Pandoc (Meta {docTitle = [], docAuthors = [], docDate = []}) -[ Para [Str "Simple",Space,Str "table",Space,Str "with",Space,Str "caption",Str ":"] -, Table [] [AlignDefault,AlignDefault,AlignDefault,AlignDefault] [0.125,0.1125,0.1375,0.15] - [ [ Plain [Str "Right"] ] - , [ Plain [Str "Left"] ] - , [ Plain [Str "Center"] ] - , [ Plain [Str "Default"] ] ] [ - [ [ 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 "Table",Str ":",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",Str ":"] -, Table [] [AlignDefault,AlignDefault,AlignDefault,AlignDefault] [0.125,0.1125,0.1375,0.15] - [ [ Plain [Str "Right"] ] - , [ Plain [Str "Left"] ] - , [ Plain [Str "Center"] ] - , [ Plain [Str "Default"] ] ] [ - [ [ 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 "indented",Space,Str "two",Space,Str "spaces",Str ":"] -, Table [] [AlignDefault,AlignDefault,AlignDefault,AlignDefault] [0.125,0.1125,0.1375,0.15] - [ [ Plain [Str "Right"] ] - , [ Plain [Str "Left"] ] - , [ Plain [Str "Center"] ] - , [ Plain [Str "Default"] ] ] [ - [ [ 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 "Table",Str ":",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",Str ":"] -, 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"] ] - , [ Plain [Str "Right",Space,Str "Aligned"] ] - , [ Plain [Str "Default",Space,Str "aligned"] ] ] [ - [ [ Plain [Str "First"] ] - , [ Plain [Str "row"] ] - , [ 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.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",Str ":",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",Str ":"] -, 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"] ] - , [ Plain [Str "Right",Space,Str "Aligned"] ] - , [ Plain [Str "Default",Space,Str "aligned"] ] ] [ - [ [ Plain [Str "First"] ] - , [ Plain [Str "row"] ] - , [ 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.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",Str ":"] -, Table [] [AlignDefault,AlignDefault,AlignDefault,AlignDefault] [0.1,0.1,0.1,0.1] - [ [] - , [] - , [] - , [] ] [ - [ [ 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 "Multiline",Space,Str "table",Space,Str "without",Space,Str "column",Space,Str "headers",Str ":"] -, Table [] [AlignDefault,AlignDefault,AlignDefault,AlignDefault] [0.175,0.1625,0.1875,0.3625] - [ [] - , [] - , [] - , [] ] [ - [ [ Plain [Str "First"] ] - , [ Plain [Str "row"] ] - , [ 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.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 "Simple",Space,Str "table",Space,Str "with",Space,Str "caption",Str ":"] +,Table [] [AlignDefault,AlignDefault,AlignDefault,AlignDefault] [0.125,0.1125,0.1375,0.15] + [[Plain [Str "Right"]] + ,[Plain [Str "Left"]] + ,[Plain [Str "Center"]] + ,[Plain [Str "Default"]]] + [[[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 "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 ":"] +,Table [] [AlignDefault,AlignDefault,AlignDefault,AlignDefault] [0.125,0.1125,0.1375,0.15] + [[Plain [Str "Right"]] + ,[Plain [Str "Left"]] + ,[Plain [Str "Center"]] + ,[Plain [Str "Default"]]] + [[[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 "indented",Space,Str "two",Space,Str "spaces",Str ":"] +,Table [] [AlignDefault,AlignDefault,AlignDefault,AlignDefault] [0.125,0.1125,0.1375,0.15] + [[Plain [Str "Right"]] + ,[Plain [Str "Left"]] + ,[Plain [Str "Center"]] + ,[Plain [Str "Default"]]] + [[[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 "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 ":"] +,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"]] + ,[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 "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 ":"] +,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"]] + ,[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 "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 ":"] +,Table [] [AlignDefault,AlignDefault,AlignDefault,AlignDefault] [0.1,0.1,0.1,0.1] + [[] + ,[] + ,[] + ,[]] + [[[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 "Multiline",Space,Str "table",Space,Str "without",Space,Str "column",Space,Str "headers",Str ":"] +,Table [] [AlignDefault,AlignDefault,AlignDefault,AlignDefault] [0.175,0.1625,0.1875,0.3625] + [[] + ,[] + ,[] + ,[]] + [[[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 "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 "."]]]]] diff -Nru pandoc-1.5.1.1/tests/tables.texinfo pandoc-1.8.0.3/tests/tables.texinfo --- pandoc-1.5.1.1/tests/tables.texinfo 2010-03-29 14:24:56.000000000 +0000 +++ pandoc-1.8.0.3/tests/tables.texinfo 2011-02-05 18:48:07.000000000 +0000 @@ -156,4 +156,3 @@ @tab 5.0 @tab Here's another one. Note the blank line between rows. @end multitable - diff -Nru pandoc-1.5.1.1/tests/tables.textile pandoc-1.8.0.3/tests/tables.textile --- pandoc-1.5.1.1/tests/tables.textile 1970-01-01 00:00:00.000000000 +0000 +++ pandoc-1.8.0.3/tests/tables.textile 2011-02-05 18:48:07.000000000 +0000 @@ -0,0 +1,212 @@ +Simple table with caption: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Demonstration of simple table syntax.
RightLeftCenterDefault
12121212
123123123123
1111
+ +Simple table without caption: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
RightLeftCenterDefault
12121212
123123123123
1111
+ +Simple table indented two spaces: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Demonstration of simple table syntax.
RightLeftCenterDefault
12121212
123123123123
1111
+ +Multiline table with caption: + + + +++++ + + + + + + + + + + + + + + + + + + + + + +
Here's the caption. It may span multiple lines.
Centered HeaderLeft AlignedRight AlignedDefault aligned
Firstrow12.0Example of a row that spans multiple lines.
Secondrow5.0Here's another one. Note the blank line between rows.
+ +Multiline table without caption: + + +++++ + + + + + + + + + + + + + + + + + + + + + +
Centered HeaderLeft AlignedRight AlignedDefault aligned
Firstrow12.0Example of a row that spans multiple lines.
Secondrow5.0Here's another one. Note the blank line between rows.
+ +Table without column headers: + + + + + + + + + + + + + + + + + + + + + + +
12121212
123123123123
1111
+ +Multiline table without column headers: + + +++++ + + + + + + + + + + + + + +
Firstrow12.0Example of a row that spans multiple lines.
Secondrow5.0Here's another one. Note the blank line between rows.
+ diff -Nru pandoc-1.5.1.1/tests/tables.txt pandoc-1.8.0.3/tests/tables.txt --- pandoc-1.5.1.1/tests/tables.txt 2010-03-29 14:24:56.000000000 +0000 +++ pandoc-1.8.0.3/tests/tables.txt 2011-02-05 18:48:07.000000000 +0000 @@ -24,10 +24,13 @@ 123 123 123 123 1 1 1 1 - Table: Demonstration of simple table syntax. + : Demonstration of simple table syntax. Multiline table with caption: +: Here's the caption. +It may span multiple lines. + --------------------------------------------------------------- Centered Left Right Header Aligned Aligned Default aligned @@ -39,9 +42,6 @@ the blank line between rows. --------------------------------------------------------------- -Table: Here's the caption. -It may span multiple lines. - Multiline table without caption: --------------------------------------------------------------- diff -Nru pandoc-1.5.1.1/tests/testsuite.native pandoc-1.8.0.3/tests/testsuite.native --- pandoc-1.5.1.1/tests/testsuite.native 2010-03-29 14:24:56.000000000 +0000 +++ pandoc-1.8.0.3/tests/testsuite.native 2011-02-05 18:48:07.000000000 +0000 @@ -1,418 +1,396 @@ -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",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",Apostrophe,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"] -, Para [Str "with",Space,Str "no",Space,Str "blank",Space,Str "line"] -, Header 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",Apostrophe,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",Apostrophe,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,Str "here",Str "."] -, HorizontalRule -, 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 "."] ] - -, BlockQuote - [ 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:"] - , 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:"] - , 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:",Space,Str "2",Space,Str ">",Space,Str "1",Str "."] -, Para [Str "And",Space,Str "a",Space,Str "following",Space,Str "paragraph",Str "."] -, HorizontalRule -, 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"] -, 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:"] -, 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:"] -, 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:"] -, 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:"] -, 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:"] -, 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:"] -, OrderedList (1,Decimal,Period) - [ [ Plain [Str "First"] ] - , [ Plain [Str "Second"] ] - , [ Plain [Str "Third"] ] ] -, 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:"] -, OrderedList (1,Decimal,Period) - [ [ Para [Str "First"] ] - , [ Para [Str "Second"] ] - , [ Para [Str "Third"] ] ] -, 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:"] -, 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",Apostrophe,Str "s",Space,Str "back",Str "."] ], [ Para [Str "Item",Space,Str "2",Str "."] ] - , [ Para [Str "Item",Space,Str "3",Str "."] ] ] -, Header 2 [Str "Nested"] -, BulletList - [ [ Plain [Str "Tab"] - , BulletList - [ [ Plain [Str "Tab"] - , BulletList - [ [ Plain [Str "Tab"] ] - ] ] ] ] ] -, Para [Str "Here",Apostrophe,Str "s",Space,Str "another:"] -, OrderedList (1,Decimal,Period) - [ [ Plain [Str "First"] ] - , [ 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:"] -, OrderedList (1,Decimal,Period) - [ [ Para [Str "First"] ] - , [ 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"] -, 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"] -, 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,",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:"] -, OrderedList (1,UpperAlpha,Period) - [ [ Plain [Str "Upper",Space,Str "Alpha"] - , OrderedList (1,UpperRoman,Period) - [ [ Plain [Str "Upper",Space,Str "Roman",Str "."] - , 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:"] -, OrderedList (1,DefaultStyle,DefaultDelim) - [ [ Plain [Str "Autonumber",Str "."] ] - , [ Plain [Str "More",Str "."] - , 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:"] -, Para [Str "M.A.\160",Str "2007"] -, Para [Str "B",Str ".",Space,Str "Williams"] -, HorizontalRule -, Header 1 [Str "Definition",Space,Str "Lists"] -, Para [Str "Tight",Space,Str "using",Space,Str "spaces:"] -, DefinitionList - [ ([Str "apple"], - [ [ Plain [Str "red",Space,Str "fruit"] ] - ]) - , ([Str "orange"], - [ [ Plain [Str "orange",Space,Str "fruit"] ] - ]) - , ([Str "banana"], - [ [ Plain [Str "yellow",Space,Str "fruit"] ] - ]) ] -, Para [Str "Tight",Space,Str "using",Space,Str "tabs:"] -, DefinitionList - [ ([Str "apple"], - [ [ Plain [Str "red",Space,Str "fruit"] ] - ]) - , ([Str "orange"], - [ [ Plain [Str "orange",Space,Str "fruit"] ] - ]) - , ([Str "banana"], - [ [ Plain [Str "yellow",Space,Str "fruit"] ] - ]) ] -, Para [Str "Loose:"] -, DefinitionList - [ ([Str "apple"], - [ [ Para [Str "red",Space,Str "fruit"] ] - ]) - , ([Str "orange"], - [ [ 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:"] -, DefinitionList - [ ([Emph [Str "apple"]], - [ [ Para [Str "red",Space,Str "fruit"] - , 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,",Space,Str "tight:"] -, DefinitionList - [ ([Str "apple"], - [ [ Plain [Str "red",Space,Str "fruit"] ] - , [ Plain [Str "computer"] ] - ]) - , ([Str "orange"], - [ [ Plain [Str "orange",Space,Str "fruit"] ] - , [ Plain [Str "bank"] ] - ]) ] -, Para [Str "Multiple",Space,Str "definitions,",Space,Str "loose:"] -, DefinitionList - [ ([Str "apple"], - [ [ Para [Str "red",Space,Str "fruit"] ] - , [ Para [Str "computer"] ] - ]) - , ([Str "orange"], - [ [ Para [Str "orange",Space,Str "fruit"] ] - , [ Para [Str "bank"] ] - ]) ] -, 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"] ] - , [ Para [Str "computer"] ] - ]) - , ([Str "orange"], - [ [ Para [Str "orange",Space,Str "fruit"] - , 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:"] -, RawHtml "
" -, Plain [Str "foo"] -, RawHtml "
\n" -, Para [Str "And",Space,Str "nested",Space,Str "without",Space,Str "indentation:"] -, RawHtml "
\n
\n
" -, Plain [Str "foo"] -, RawHtml "
\n
\n
" -, Plain [Str "bar"] -, RawHtml "
\n
\n" -, Para [Str "Interpreted",Space,Str "markdown",Space,Str "in",Space,Str "a",Space,Str "table:"] -, RawHtml "\n\n\n\n\n
" -, Plain [Str "This",Space,Str "is",Space,Emph [Str "emphasized"]] -, RawHtml "" -, Plain [Str "And",Space,Str "this",Space,Str "is",Space,Strong [Str "strong"]] -, RawHtml "
\n\n\n" -, Para [Str "Here",Apostrophe,Str "s",Space,Str "a",Space,Str "simple",Space,Str "block:"] -, RawHtml "
\n " -, Plain [Str "foo"] -, RawHtml "
\n" -, Para [Str "This",Space,Str "should",Space,Str "be",Space,Str "a",Space,Str "code",Space,Str "block,",Space,Str "though:"] -, CodeBlock ("",[],[]) "
\n foo\n
" -, Para [Str "As",Space,Str "should",Space,Str "this:"] -, CodeBlock ("",[],[]) "
foo
" -, Para [Str "Now,",Space,Str "nested:"] -, RawHtml "
\n
\n
\n " -, Plain [Str "foo"] -, RawHtml "
\n
\n
\n" -, Para [Str "This",Space,Str "should",Space,Str "just",Space,Str "be",Space,Str "an",Space,Str "HTML",Space,Str "comment:"] -, RawHtml "\n" -, Para [Str "Multiline:"] -, RawHtml "\n\n\n" -, Para [Str "Code",Space,Str "block:"] -, CodeBlock ("",[],[]) "" -, 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:"] -, RawHtml " \n" -, Para [Str "Code:"] -, CodeBlock ("",[],[]) "
" -, Para [Str "Hr",Apostrophe,Str "s:"] -, RawHtml "
\n\n
\n\n
\n\n
\n\n
\n\n
\n\n
\n\n
\n\n
\n" -, HorizontalRule -, 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 "."] -, 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:",Space,Code ">",Str ",",Space,Code "$",Str ",",Space,Code "\\",Str ",",Space,Code "\\$",Str ",",Space,Code "",Str "."] -, Para [Strikeout [Str "This",Space,Str "is",Space,Emph [Str "strikeout"],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",Str "\160",Str "there"],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",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,",Space,Str "because",Space,Str "of",Space,Str "the",Space,Str "unescaped",Space,Str "spaces:",Space,Str "a",Str "^",Str "b",Space,Str "c",Str "^",Str "d,",Space,Str "a",Str "~",Str "b",Space,Str "c",Str "~",Str "d",Str "."] -, HorizontalRule -, 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",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,"],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",Str ".",Space,Str "So",Space,Str "is",Space,Quoted SingleQuote [Str "pine",Str "."]] -, Para [Quoted SingleQuote [Str "He",Space,Str "said,",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",Apostrophe,Str "s?"] -, 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:",Space,Str "one",EmDash,Str "two",Space,EmDash,Space,Str "three",EmDash,Str "four",Space,EmDash,Space,Str "five",Str "."] -, Para [Str "Dashes",Space,Str "between",Space,Str "numbers:",Space,Str "5",EnDash,Str "7,",Space,Str "255",EnDash,Str "66,",Space,Str "1987",EnDash,Str "1999",Str "."] -, Para [Str "Ellipses",Ellipses,Str "and",Ellipses,Str "and",Ellipses,Str "."] -, HorizontalRule -, Header 1 [Str "LaTeX"] -, BulletList - [ [ Plain [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",Apostrophe,Str "s",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",Apostrophe,Str "s",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",Apostrophe,Str "t",Space,Str "be",Space,Str "math:"] -, BulletList - [ [ 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 "$",Str "22,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,000",Str ".",Space,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)",Space,Str "and",Space,Str "socks",Space,Str "(",Str "$",Str "5)",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",Apostrophe,Str "s",Space,Str "a",Space,Str "LaTeX",Space,Str "table:"] -, Para [TeX "\\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:"] -, BulletList - [ [ 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",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:",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",Str "-",Str "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"] -, 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 "Email",Space,Str "link"] ("mailto:nobody@nowhere.net","")] -, Para [Link [Str "Empty"] ("",""),Str "."] -, 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 "."] -, 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 "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 "."] -, 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"] -, Para [Str "Here",Apostrophe,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",Apostrophe,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",Str "&",Str "T"] ("http://att.com/","AT&T"),Str "."] -, Para [Str "Here",Apostrophe,Str "s",Space,Str "an",Space,Link [Str "inline",Space,Str "link"] ("/script?foo=1&bar=2",""),Str "."] -, Para [Str "Here",Apostrophe,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"] -, 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","")] -, BulletList - [ [ Plain [Str "In",Space,Str "a",Space,Str "list?"] ] - , [ Plain [Link [Code "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:",Space,Link [Code "nobody@nowhere.net"] ("mailto:nobody@nowhere.net","")] -, BlockQuote - [ Para [Str "Blockquoted:",Space,Link [Code "http://example.com/"] ("http://example.com/","")] ] - -, Para [Str "Auto",Str "-",Str "links",Space,Str "should",Space,Str "not",Space,Str "occur",Space,Str "here:",Space,Code ""] -, CodeBlock ("",[],[]) "or here: " -, 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 "(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"] -, 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",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",Apostrophe,Str "s",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 "(as",Space,Str "with",Space,Str "list",Space,Str "items)",Str "."],CodeBlock ("",[],[]) " { }",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",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",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,",Space,Str "as",Space,Str "well",Space,Str "as",Space,Str "[",Str "bracketed",Space,Str "text",Str "]",Str "."]]] -, 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 "."]]] ] - -, 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,",Space,Str "as",Space,Str "it",Space,Str "is",Space,Str "not",Space,Str "indented",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",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",Apostrophe,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"] +,Para [Str "with",Space,Str "no",Space,Str "blank",Space,Str "line"] +,Header 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",Apostrophe,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",Apostrophe,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,Str "here",Str "."] +,HorizontalRule +,Header 1 [Str "Block",Space,Str "Quotes"] +,Para [Str "E",Str "-",Str "mail",Space,Str "style",Str ":"] +,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 "."]] +,BlockQuote + [Para [Str "Code",Space,Str "in",Space,Str "a",Space,Str "block",Space,Str "quote",Str ":"] + ,CodeBlock ("",[],[]) "sub status {\n print \"working\";\n}" + ,Para [Str "A",Space,Str "list",Str ":"] + ,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 ":"] + ,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 "."] +,HorizontalRule +,Header 1 [Str "Code",Space,Str "Blocks"] +,Para [Str "Code",Str ":"] +,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 ":"] +,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 ":"] +,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 ":"] +,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 ":"] +,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 ":"] +,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 ":"] +,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 ":"] +,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 ":"] +,OrderedList (1,Decimal,Period) + [[Plain [Str "First"]] + ,[Plain [Str "Second"]] + ,[Plain [Str "Third"]]] +,Para [Str "and",Str ":"] +,OrderedList (1,Decimal,Period) + [[Plain [Str "One"]] + ,[Plain [Str "Two"]] + ,[Plain [Str "Three"]]] +,Para [Str "Loose",Space,Str "using",Space,Str "tabs",Str ":"] +,OrderedList (1,Decimal,Period) + [[Para [Str "First"]] + ,[Para [Str "Second"]] + ,[Para [Str "Third"]]] +,Para [Str "and",Space,Str "using",Space,Str "spaces",Str ":"] +,OrderedList (1,Decimal,Period) + [[Para [Str "One"]] + ,[Para [Str "Two"]] + ,[Para [Str "Three"]]] +,Para [Str "Multiple",Space,Str "paragraphs",Str ":"] +,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",Apostrophe,Str "s",Space,Str "back",Str "."]] + ,[Para [Str "Item",Space,Str "2",Str "."]] + ,[Para [Str "Item",Space,Str "3",Str "."]]] +,Header 2 [Str "Nested"] +,BulletList + [[Plain [Str "Tab"] + ,BulletList + [[Plain [Str "Tab"] + ,BulletList + [[Plain [Str "Tab"]]]]]]] +,Para [Str "Here",Apostrophe,Str "s",Space,Str "another",Str ":"] +,OrderedList (1,Decimal,Period) + [[Plain [Str "First"]] + ,[Plain [Str "Second",Str ":"] + ,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 ":"] +,OrderedList (1,Decimal,Period) + [[Para [Str "First"]] + ,[Para [Str "Second",Str ":"] + ,BulletList + [[Plain [Str "Fee"]] + ,[Plain [Str "Fie"]] + ,[Plain [Str "Foe"]]]] + ,[Para [Str "Third"]]] +,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"] +,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 "more",Space,Str "items"] + ,OrderedList (1,UpperAlpha,TwoParens) + [[Plain [Str "a",Space,Str "subsublist"]] + ,[Plain [Str "a",Space,Str "subsublist"]]]]]]] +,Para [Str "Nesting",Str ":"] +,OrderedList (1,UpperAlpha,Period) + [[Plain [Str "Upper",Space,Str "Alpha"] + ,OrderedList (1,UpperRoman,Period) + [[Plain [Str "Upper",Space,Str "Roman",Str "."] + ,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 ":"] +,OrderedList (1,DefaultStyle,DefaultDelim) + [[Plain [Str "Autonumber",Str "."]] + ,[Plain [Str "More",Str "."] + ,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"] +,HorizontalRule +,Header 1 [Str "Definition",Space,Str "Lists"] +,Para [Str "Tight",Space,Str "using",Space,Str "spaces",Str ":"] +,DefinitionList + [([Str "apple"], + [[Plain [Str "red",Space,Str "fruit"]]]) + ,([Str "orange"], + [[Plain [Str "orange",Space,Str "fruit"]]]) + ,([Str "banana"], + [[Plain [Str "yellow",Space,Str "fruit"]]])] +,Para [Str "Tight",Space,Str "using",Space,Str "tabs",Str ":"] +,DefinitionList + [([Str "apple"], + [[Plain [Str "red",Space,Str "fruit"]]]) + ,([Str "orange"], + [[Plain [Str "orange",Space,Str "fruit"]]]) + ,([Str "banana"], + [[Plain [Str "yellow",Space,Str "fruit"]]])] +,Para [Str "Loose",Str ":"] +,DefinitionList + [([Str "apple"], + [[Para [Str "red",Space,Str "fruit"]]]) + ,([Str "orange"], + [[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 ":"] +,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"]]]) + ,([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 ":"] +,DefinitionList + [([Str "apple"], + [[Plain [Str "red",Space,Str "fruit"]] + ,[Plain [Str "computer"]]]) + ,([Str "orange"], + [[Plain [Str "orange",Space,Str "fruit"]] + ,[Plain [Str "bank"]]])] +,Para [Str "Multiple",Space,Str "definitions",Str ",",Space,Str "loose",Str ":"] +,DefinitionList + [([Str "apple"], + [[Para [Str "red",Space,Str "fruit"]] + ,[Para [Str "computer"]]]) + ,([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 ":"] +,DefinitionList + [([Str "apple"], + [[Para [Str "red",Space,Str "fruit"]] + ,[Para [Str "computer"]]]) + ,([Str "orange"], + [[Para [Str "orange",Space,Str "fruit"] + ,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 ":"] +,RawBlock "html" "
" +,Plain [Str "foo"] +,RawBlock "html" "
\n" +,Para [Str "And",Space,Str "nested",Space,Str "without",Space,Str "indentation",Str ":"] +,RawBlock "html" "
\n
\n
" +,Plain [Str "foo"] +,RawBlock "html" "
\n
\n
" +,Plain [Str "bar"] +,RawBlock "html" "
\n
\n" +,Para [Str "Interpreted",Space,Str "markdown",Space,Str "in",Space,Str "a",Space,Str "table",Str ":"] +,RawBlock "html" "\n\n\n\n\n
" +,Plain [Str "This",Space,Str "is",Space,Emph [Str "emphasized"]] +,RawBlock "html" "" +,Plain [Str "And",Space,Str "this",Space,Str "is",Space,Strong [Str "strong"]] +,RawBlock "html" "
\n\n\n" +,Para [Str "Here",Apostrophe,Str "s",Space,Str "a",Space,Str "simple",Space,Str "block",Str ":"] +,RawBlock "html" "
\n " +,Plain [Str "foo"] +,RawBlock "html" "
\n" +,Para [Str "This",Space,Str "should",Space,Str "be",Space,Str "a",Space,Str "code",Space,Str "block",Str ",",Space,Str "though",Str ":"] +,CodeBlock ("",[],[]) "
\n foo\n
" +,Para [Str "As",Space,Str "should",Space,Str "this",Str ":"] +,CodeBlock ("",[],[]) "
foo
" +,Para [Str "Now",Str ",",Space,Str "nested",Str ":"] +,RawBlock "html" "
\n
\n
\n " +,Plain [Str "foo"] +,RawBlock "html" "
\n
\n
\n" +,Para [Str "This",Space,Str "should",Space,Str "just",Space,Str "be",Space,Str "an",Space,Str "HTML",Space,Str "comment",Str ":"] +,RawBlock "html" "\n" +,Para [Str "Multiline",Str ":"] +,RawBlock "html" "\n\n\n" +,Para [Str "Code",Space,Str "block",Str ":"] +,CodeBlock ("",[],[]) "" +,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 ":"] +,RawBlock "html" " \n" +,Para [Str "Code",Str ":"] +,CodeBlock ("",[],[]) "
" +,Para [Str "Hr",Apostrophe,Str "s",Str ":"] +,RawBlock "html" "
\n\n
\n\n
\n\n
\n\n
\n\n
\n\n
\n\n
\n\n
\n" +,HorizontalRule +,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 "."] +,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 ("",[],[]) "",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 "."] +,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",Apostrophe,Str "s",Str "?"] +,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",EmDash,Str "two",Space,EmDash,Space,Str "three",EmDash,Str "four",Space,EmDash,Space,Str "five",Str "."] +,Para [Str "Dashes",Space,Str "between",Space,Str "numbers",Str ":",Space,Str "5",EnDash,Str "7",Str ",",Space,Str "255",EnDash,Str "66",Str ",",Space,Str "1987",EnDash,Str "1999",Str "."] +,Para [Str "Ellipses",Ellipses,Str "and",Ellipses,Str "and",Ellipses,Str "."] +,HorizontalRule +,Header 1 [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",Apostrophe,Str "s",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",Apostrophe,Str "s",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",Apostrophe,Str "t",Space,Str "be",Space,Str "math",Str ":"] +,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",Apostrophe,Str "s",Space,Str "a",Space,Str "LaTeX",Space,Str "table",Str ":"] +,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 ":"] +,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 "-"] +,HorizontalRule +,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 "."] +,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 "Email",Space,Str "link"] ("mailto:nobody@nowhere.net","")] +,Para [Link [Str "Empty"] ("",""),Str "."] +,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 "."] +,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 "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 "."] +,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"] +,Para [Str "Here",Apostrophe,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",Apostrophe,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",Str "&",Str "T"] ("http://att.com/","AT&T"),Str "."] +,Para [Str "Here",Apostrophe,Str "s",Space,Str "an",Space,Link [Str "inline",Space,Str "link"] ("/script?foo=1&bar=2",""),Str "."] +,Para [Str "Here",Apostrophe,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"] +,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","")] +,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","")] +,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 ("",[],[]) ""] +,CodeBlock ("",[],[]) "or here: " +,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 "."] +,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",Apostrophe,Str "s",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 ("",[],[]) " { }",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 "."]]] +,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 "."]]]] +,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 "."]] diff -Nru pandoc-1.5.1.1/tests/testsuite.txt pandoc-1.8.0.3/tests/testsuite.txt --- pandoc-1.5.1.1/tests/testsuite.txt 2010-03-29 14:24:56.000000000 +0000 +++ pandoc-1.8.0.3/tests/testsuite.txt 2011-02-05 18:48:07.000000000 +0000 @@ -431,21 +431,21 @@
-
+


-
+


-
+
-
+
----- @@ -496,7 +496,7 @@ Dashes between numbers: 5-7, 255-66, 1987-1999. -Ellipses...and. . .and . . . . +Ellipses...and...and.... ----- @@ -631,7 +631,6 @@ This should [not][] be a link. [once]: /url - [twice]: /url [thrice]: /url diff -Nru pandoc-1.5.1.1/tests/textile-reader.native pandoc-1.8.0.3/tests/textile-reader.native --- pandoc-1.5.1.1/tests/textile-reader.native 1970-01-01 00:00:00.000000000 +0000 +++ pandoc-1.8.0.3/tests/textile-reader.native 2011-02-05 18:48:07.000000000 +0000 @@ -0,0 +1,148 @@ +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",Apostrophe,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"] +,Para [Str "Here",Apostrophe,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",Apostrophe,Str "s",Space,Str "one",Space,Str "with",Space,Str "a",Space,Str "bullet",Str "."] +,BulletList + [[Plain [Str "criminey",Str "."]]] +,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"] +,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"] +,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 @",Str ",",Space,Code ("",[],[]) "@",Str "."] +,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 "Tight",Str ":"] +,OrderedList (1,DefaultStyle,DefaultDelim) + [[Plain [Str "First"]] + ,[Plain [Str "Second"]] + ,[Plain [Str "Third"]]] +,Header 2 [Str "Nested"] +,BulletList + [[Plain [Str "ui",Space,Str "1"] + ,BulletList + [[Plain [Str "ui",Space,Str "1",Str ".",Str "1"] + ,OrderedList (1,DefaultStyle,DefaultDelim) + [[Plain [Str "oi",Space,Str "1",Str ".",Str "1",Str ".",Str "1"]] + ,[Plain [Str "oi",Space,Str "1",Str ".",Str "1",Str ".",Str "2"]]]] + ,[Plain [Str "ui",Space,Str "1",Str ".",Str "2"]]]] + ,[Plain [Str "ui",Space,Str "2"] + ,OrderedList (1,DefaultStyle,DefaultDelim) + [[Plain [Str "oi",Space,Str "2",Str ".",Str "1"] + ,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"] +,DefinitionList + [([Str "coffee"], + [[Plain [Str "Hot",Space,Str "and",Space,Str "black"]]]) + ,([Str "tea"], + [[Plain [Str "Also",Space,Str "hot",Str ",",Space,Str "but",Space,Str "a",Space,Str "little",Space,Str "less",Space,Str "black"]]]) + ,([Str "milk"], + [[Para [Str "Nourishing",Space,Str "beverage",Space,Str "for",Space,Str "baby",Space,Str "cows",Str "."] + ,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"] +,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 "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,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,EmDash,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,Ellipses,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",Apostrophe,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"] +,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 "."] +,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"] +,Table [] [AlignDefault,AlignDefault,AlignDefault] [0.0,0.0,0.0] + [] + [[[Plain [Str "name"]] + ,[Plain [Str "age"]] + ,[Plain [Str "sex"]]] + ,[[Plain [Str "joan"]] + ,[Plain [Str "24"]] + ,[Plain [Str "f"]]] + ,[[Plain [Str "archie"]] + ,[Plain [Str "29"]] + ,[Plain [Str "m"]]] + ,[[Plain [Str "bella"]] + ,[Plain [Str "45"]] + ,[Plain [Str "f"]]]] +,Para [Str "and",Space,Str "some",Space,Str "text",Space,Str "following",Space,Ellipses] +,Header 2 [Str "With",Space,Str "headers"] +,Table [] [AlignDefault,AlignDefault,AlignDefault] [0.0,0.0,0.0] + [[Plain [Str "name"]] + ,[Plain [Str "age"]] + ,[Plain [Str "sex"]]] + [[[Plain [Str "joan"]] + ,[Plain [Str "24"]] + ,[Plain [Str "f"]]] + ,[[Plain [Str "archie"]] + ,[Plain [Str "29"]] + ,[Plain [Str "m"]]] + ,[[Plain [Str "bella"]] + ,[Plain [Str "45"]] + ,[Plain [Str "f"]]]] +,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"] +,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] + [] + [[[Plain [Str "name"]] + ,[Plain [Str "age"]] + ,[Plain [Str "sex"]]] + ,[[Plain [Str "joan"]] + ,[Plain [Str "24"]] + ,[Plain [Str "f"]]]] +,Header 1 [Str "Raw",Space,Str "HTML"] +,Para [Str "However",Str ",",Space,RawInline "html" "",Space,Str "raw",Space,Str "HTML",Space,Str "inlines",Space,RawInline "html" "",Space,Str "are",Space,Str "accepted",Str ",",Space,Str "as",Space,Str "well",Space,Str "as",Space,Str ":"] +,RawBlock "html" "
" +,Para [Str "any",Space,Strong [Str "Raw",Space,Str "HTML",Space,Str "Block"],Space,Str "with",Space,Str "bold",LineBreak] +,RawBlock "html" "
" +,Para [Str "Html",Space,Str "blocks",Space,Str "can",Space,Str "be"] +,RawBlock "html" "
" +,Para [Str "inlined"] +,RawBlock "html" "
" +,Para [Str "as",Space,Str "well",Str "."] +,BulletList + [[Plain [Str "this",Space,Str "<",Str "div",Str ">",Space,Str "won",Apostrophe,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" "",Space,Str "will",Space,Str "produce",Space,Str "inline",Space,Str "html",Space,RawInline "html" ""]]] +,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 "Acronyms",Space,Str "and",Space,Str "marks"] +,Para [Str "PBS",Space,Str "(",Str "Public",Space,Str "Broadcasting",Space,Str "System",Str ")"] +,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 "!"]]]] diff -Nru pandoc-1.5.1.1/tests/textile-reader.textile pandoc-1.8.0.3/tests/textile-reader.textile --- pandoc-1.5.1.1/tests/textile-reader.textile 1970-01-01 00:00:00.000000000 +0000 +++ pandoc-1.8.0.3/tests/textile-reader.textile 2011-02-05 18:48:07.000000000 +0000 @@ -0,0 +1,216 @@ +This is a set of tests for pandoc Textile Reader. Part of it comes +from John Gruber's markdown test suite. + +----- + +h1. Headers + +h2. Level 2 with an "embeded link":http://www.example.com + +h3. Level 3 with *emphasis* + +h4. Level 4 + +h5. Level 5 + +h6. Level 6 + + +h1. Paragraphs + +Here's a regular paragraph. + +Line breaks are preserved in textile, so you can not wrap your very +long paragraph with your favourite text editor and have it rendered +with no break. + + +Here's one with a bullet. + +* criminey. + +There should be a paragraph break between here + +and here. + +pandoc converts textile. + +h1. Block Quotes + +bq. This is a famous quote from somebody. He had a lot of things to +say, so the text is really really long and spans on multiple lines. + +And a following paragraph. + +h1. Code Blocks + +Code: + +
+    ---- (should be four hyphens)
+
+    sub status {
+        print "working";
+    }
+
+	this code block is indented by one tab
+
+ +And: + +
+		this code block is indented by two tabs
+
+    These should not be escaped:  \$ \\ \> \[ \{
+
+ +bc. Code block with .bc + continued + @@, @. + +h1. Lists + +h2. Unordered + +Asterisks tight: + +* asterisk 1 +* asterisk 2 +* asterisk 3 + +h2. Ordered + +Tight: + +# First +# Second +# Third + +h2. Nested + +* ui 1 +** ui 1.1 +### oi 1.1.1 +### oi 1.1.2 +** ui 1.2 +* ui 2 +## oi 2.1 +*** ui 2.1.1 +*** ui 2.1.2 + +h2. Definition List + +- coffee := Hot and black +- tea := Also hot, but a little less black +- milk := +Nourishing beverage for baby cows. + +Cold drink that goes great with cookies.=: +- beer := fresh and bitter + + +h1. Inline Markup + +This is _emphasized_, and so __is this__. +This is *strong*, and so **is this**. +A "*strong link*":http://www.foobar.com. + +_*This is strong and em.*_ +So is *_this_* word and __**that one**__. +-This is strikeout and *strong*- + +Superscripts: a^bc^d a^*hello*^ a^hello there^. +Subscripts: H~2~O, H~23~O, H~many of them~O. + +Dashes : How cool -- automatic dashes. + +Elipses : He thought and thought ... and then thought some more. + +Quotes and apostrophes : "I'd like to thank you" for example. + + +h1. Links + +h2. Explicit + +Just a "url":http://www.url.com + +"Email link":mailto:nobody@nowhere.net + +Automatic linking to http://www.example.com and foobar@example.com. + +h1. Tables + +Textile allows tables with and without headers : + +h2. Without headers + +| name | age | sex | +| joan | 24 | f | +| archie | 29 | m | +| bella | 45 | f | + +and some text following ... + +h2. With headers + +|_. name |_. age |_. sex | +| joan | 24 | f | +| archie | 29 | m | +| bella | 45 | f | + + + +h1. Images + +Textile inline image syntax, like +here !this_is_an_image.png(this is the alt text)! +and here !this_is_an_image.png!. + +h1. Attributes + +h2{color:red}. HTML and CSS attributes are ignored + +as well as *(foo)inline attributes* of %{color:red} all kind% + +p{color:green}. and paragraph attributes, and table attributes. + +table{foo:bar}. +| name | age | sex | +| joan | 24 | f | + +h1. Raw HTML + +However, raw HTML inlines are accepted, as well as : + +
+ any *Raw HTML Block* with bold +
+ +Html blocks can be
inlined
as well. + +* this
won't produce raw html blocks
+* but this will produce inline html + +Can you prove that 2 < 3 ? + +h1. Acronyms and marks + +PBS(Public Broadcasting System) + +Hi(tm) + +Hi (TM) + +(r) Hi(r) + +Hi(c)2008 (C) 2008 + +h1. Footnotes + +A note.[1] + +fn1. The note +is here! diff -Nru pandoc-1.5.1.1/tests/writer.context pandoc-1.8.0.3/tests/writer.context --- pandoc-1.5.1.1/tests/writer.context 2010-03-29 14:24:56.000000000 +0000 +++ pandoc-1.8.0.3/tests/writer.context 2011-02-05 18:48:07.000000000 +0000 @@ -61,8 +61,8 @@ \blank[3*medium] \stopalignment -This is a set of tests for pandoc. Most of them are adapted from -John Gruber's markdown test suite. +This is a set of tests for pandoc. Most of them are adapted from John Gruber's +markdown test suite. \thinrule @@ -94,9 +94,9 @@ 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. +In Markdown 1.0.0 and earlier. Version 8. This line turns into a list item. +Because a hard-wrapped line in the middle of a paragraph looked like a list +item. Here's one with a bullet. * criminey. @@ -293,9 +293,8 @@ \startitemize[n][stopper=.] \item Item 1, graf one. - - Item 1. graf two. The quick brown fox jumped over the lazy dog's - back. + + Item 1. graf two. The quick brown fox jumped over the lazy dog's back. \item Item 2. \item @@ -343,7 +342,7 @@ First \item Second: - + \startitemize \item Fee @@ -363,7 +362,7 @@ this is a list item indented with tabs \item this is a list item indented with spaces - + \startitemize \item this is an example list item indented with tabs @@ -379,9 +378,9 @@ begins with 2 \item and now 3 - + with a continuation - + \startitemize[r][start=4,stopper=.,width=2.0em] \item sublist with roman numerals, starting with 4 @@ -441,110 +440,110 @@ Tight using spaces: \startdescr{apple} -red fruit + red fruit \stopdescr \startdescr{orange} -orange fruit + orange fruit \stopdescr \startdescr{banana} -yellow fruit + yellow fruit \stopdescr Tight using tabs: \startdescr{apple} -red fruit + red fruit \stopdescr \startdescr{orange} -orange fruit + orange fruit \stopdescr \startdescr{banana} -yellow fruit + yellow fruit \stopdescr Loose: \startdescr{apple} -red fruit + red fruit \stopdescr \startdescr{orange} -orange fruit + orange fruit \stopdescr \startdescr{banana} -yellow fruit + yellow fruit \stopdescr Multiple blocks with italics: \startdescr{{\em apple}} -red fruit + red fruit -contains seeds, crisp, pleasant to taste + contains seeds, crisp, pleasant to taste \stopdescr \startdescr{{\em orange}} -orange fruit + orange fruit -\starttyping + \starttyping { orange code block } -\stoptyping + \stoptyping -\startblockquote -orange block quote -\stopblockquote + \startblockquote + orange block quote + \stopblockquote \stopdescr Multiple definitions, tight: \startdescr{apple} -red fruit + red fruit -computer + computer \stopdescr \startdescr{orange} -orange fruit + orange fruit -bank + bank \stopdescr Multiple definitions, loose: \startdescr{apple} -red fruit + red fruit -computer + computer \stopdescr \startdescr{orange} -orange fruit + orange fruit -bank + bank \stopdescr Blank line after term, indented marker, alternate markers: \startdescr{apple} -red fruit + red fruit -computer + computer \stopdescr \startdescr{orange} -orange fruit + orange fruit -\startitemize[n][stopper=.] -\item - sublist -\item - sublist -\stopitemize + \startitemize[n][stopper=.] + \item + sublist + \item + sublist + \stopitemize \stopdescr \subject{HTML Blocks} @@ -618,8 +617,7 @@ So is {\bf {\em this}} word. -This is code: \type{>}, \type{$}, \type{\}, \type{\$}, -\type{}. +This is code: \type{>}, \type{$}, \type{\}, \type{\$}, \type{}. \overstrikes{This is {\em strikeout}.} @@ -627,27 +625,25 @@ Subscripts: H\low{2}O, H\low{23}O, H\low{many~of~them}O. -These should not be superscripts or subscripts, because of the -unescaped spaces: a\letterhat{}b c\letterhat{}d, a\lettertilde{}b -c\lettertilde{}d. +These should not be superscripts or subscripts, because of the unescaped +spaces: a\letterhat{}b c\letterhat{}d, a\lettertilde{}b c\lettertilde{}d. \thinrule \subject{Smart quotes, ellipses, dashes} -\quotation{Hello,} said the spider. -\quotation{\quote{Shelob} is my name.} +\quotation{Hello,} said the spider. \quotation{\quote{Shelob} is my name.} \quote{A}, \quote{B}, and \quote{C} are letters. -\quote{Oak,} \quote{elm,} and \quote{beech} are names of trees. So -is \quote{pine.} +\quote{Oak,} \quote{elm,} and \quote{beech} are names of trees. So is +\quote{pine.} -\quote{He said, \quotation{I want to go.}} Were you alive in the -70's? +\quote{He said, \quotation{I want to go.}} Were you alive in the 70's? Here is some quoted \quote{\type{code}} and a -\quotation{\useURL[3][http://example.com/?foo=1&bar=2][][quoted link]\from[3]}. +\quotation{\useURL[3][http://example.com/?foo=1&bar=2][][quoted +link]\from[3]}. Some dashes: one---two --- three---four --- five. @@ -676,8 +672,7 @@ Here's some display math: \startformula \frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h} \stopformula \item - Here's one that has a line break in it: - $\alpha + \omega \times x^2$. + Here's one that has a line break in it: $\alpha + \omega \times x^2$. \stopitemize These shouldn't be math: @@ -696,12 +691,6 @@ Here's a LaTeX table: -\begin{tabular}{|l|l|}\hline -Animal & Number \\ \hline -Dog & 2 \\ -Cat & 1 \\ \hline -\end{tabular} - \thinrule \subject{Special Characters} @@ -743,9 +732,9 @@ Right brace: \letterclosebrace{} -Left bracket: [ +Left bracket: {[} -Right bracket: ] +Right bracket: {]} Left paren: ( @@ -795,7 +784,7 @@ Foo \useURL[15][/url/][][bar]\from[15]. -With \useURL[16][/url/][][embedded [brackets]]\from[16]. +With \useURL[16][/url/][][embedded {[}brackets{]}]\from[16]. \useURL[17][/url/][][b]\from[17] by itself should be a link. @@ -805,7 +794,7 @@ Indented \useURL[20][/url][][thrice]\from[20]. -This should [not][] be a link. +This should {[}not{]}{[}{]} be a link. \starttyping [not]: /url @@ -817,16 +806,16 @@ \subsubject{With ampersands} -Here's a -\useURL[23][http://example.com/?foo=1&bar=2][][link with an ampersand in the URL]\from[23]. +Here's a \useURL[23][http://example.com/?foo=1&bar=2][][link with an ampersand +in the URL]\from[23]. Here's a link with an amersand in the link text: \useURL[24][http://att.com/][][AT\&T]\from[24]. Here's an \useURL[25][/script?foo=1&bar=2][][inline link]\from[25]. -Here's an -\useURL[26][/script?foo=1&bar=2][][inline link in pointy braces]\from[26]. +Here's an \useURL[26][/script?foo=1&bar=2][][inline link in pointy +braces]\from[26]. \subsubject{Autolinks} @@ -846,8 +835,7 @@ \useURL[29][mailto:nobody@nowhere.net][][nobody@nowhere.net]\from[29] \startblockquote -Blockquoted: -\useURL[30][http://example.com/][][http://example.com/]\from[30] +Blockquoted: \useURL[30][http://example.com/][][http://example.com/]\from[30] \stopblockquote Auto-links should not occur here: \type{} @@ -870,40 +858,34 @@ \subject{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. +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). + Subsequent blocks are indented to show that they belong to the footnote (as + with list items). -\starttyping + \starttyping { } -\stoptyping + \stoptyping -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 {\em not} be a footnote reference, because it contains -a space.[\letterhat{}my note] Here is an inline note. -\footnote{This is {\em easier} to type. Inline notes may contain -\useURL[31][http://google.com][][links]\from[31] and \type{]} -verbatim characters, 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 {\em not} be a footnote +reference, because it contains a space.{[}\letterhat{}my note{]} Here is an +inline note.\footnote{This is {\em easier} to type. Inline notes may contain + \useURL[31][http://google.com][][links]\from[31] and \type{]} verbatim + characters, as well as {[}bracketed text{]}.} \startblockquote -Notes can go in quotes. -\footnote{In quote.} +Notes can go in quotes.\footnote{In quote.} \stopblockquote \startitemize[n][stopper=.] \item - And in list items. - \footnote{In list.} + And in list items.\footnote{In list.} \stopitemize -This paragraph should not be part of the note, as it is not -indented. +This paragraph should not be part of the note, as it is not indented. \stoptext - diff -Nru pandoc-1.5.1.1/tests/writer.docbook pandoc-1.8.0.3/tests/writer.docbook --- pandoc-1.5.1.1/tests/writer.docbook 2010-03-29 14:24:56.000000000 +0000 +++ pandoc-1.8.0.3/tests/writer.docbook 2011-02-05 18:48:07.000000000 +0000 @@ -15,14 +15,13 @@ July 17, 2006 - This is a set of tests for pandoc. Most of them are adapted from - John Gruber's markdown test suite. + This is a set of tests for pandoc. Most of them are adapted from John + Gruber's markdown test suite.
Headers