├── tests ├── insert ├── bodybg.gif ├── lalune.jpg ├── movie.jpg ├── MarkdownTest_1.0.3 │ ├── Tests │ │ ├── Nested blockquotes.text │ │ ├── Tidyness.text │ │ ├── Strong and em together.text │ │ ├── Literal quotes in titles.text │ │ ├── Nested blockquotes.html │ │ ├── Tidyness.html │ │ ├── Code Spans.text │ │ ├── Literal quotes in titles.html │ │ ├── Blockquotes with code blocks.text │ │ ├── Inline HTML (Advanced).text │ │ ├── Inline HTML comments.text │ │ ├── Code Spans.html │ │ ├── Inline HTML (Advanced).html │ │ ├── Strong and em together.html │ │ ├── Code Blocks.text │ │ ├── Hard-wrapped paragraphs with list-like lines.text │ │ ├── Inline HTML comments.html │ │ ├── Hard-wrapped paragraphs with list-like lines.html │ │ ├── Blockquotes with code blocks.html │ │ ├── Links, inline style.text │ │ ├── Links, shortcut references.html │ │ ├── Auto links.text │ │ ├── Links, shortcut references.text │ │ ├── Code Blocks.html │ │ ├── Tabs.text │ │ ├── Links, inline style.html │ │ ├── Amps and angle encoding.text │ │ ├── Tabs.html │ │ ├── Amps and angle encoding.html │ │ ├── Horizontal rules.text │ │ ├── Auto links.html │ │ ├── Horizontal rules.html │ │ ├── Inline HTML (Simple).text │ │ ├── Inline HTML (Simple).html │ │ ├── Links, reference style.text │ │ ├── Links, reference style.html │ │ ├── Ordered and unordered lists.text │ │ ├── Backslash escapes.text │ │ ├── Backslash escapes.html │ │ └── Ordered and unordered lists.html │ └── MarkdownTest.pl ├── s5.fragment.html ├── s5.native ├── biblio.bib ├── lhs-test.markdown+lhs ├── lhs-test.rst+lhs ├── lhs-test.rst ├── lhs-test.markdown ├── lhs-test.fragment.html+lhs ├── markdown-citations.txt ├── markdown-citations.ieee.txt ├── s5.inserts.html ├── lhs-test.native ├── markdown-citations.chicago-author-date.txt ├── markdown-citations.mhra.txt ├── s5.basic.html ├── markdown-reader-more.txt ├── lhs-test.latex+lhs ├── lhs-test.html ├── lhs-test.html+lhs ├── tables.org ├── tables.asciidoc ├── tables.plain ├── tables.markdown ├── tables.txt ├── tables.texinfo ├── tables.context ├── markdown-reader-more.native ├── tables.man ├── lhs-test.latex ├── tables.latex ├── tables.rst ├── textile-reader.textile ├── tables.html ├── tables.native ├── tables.textile └── tables.mediawiki ├── reference.odt ├── reference.docx ├── windows ├── pcre3.dll ├── make-windows-installer.bat ├── pcre-license.txt └── pandoc-setup.iss ├── s5 └── default │ ├── blank.gif │ ├── bodybg.gif │ ├── opera.css │ ├── slides.css │ ├── s5-core.css │ ├── outline.css │ ├── framing.css │ ├── print.css │ ├── iepngfix.htc │ └── pretty.css ├── slidy ├── graphics │ ├── fold.gif │ ├── unfold.gif │ ├── fold-dim.gif │ ├── nofold-dim.gif │ └── unfold-dim.gif └── scripts │ └── slidy.js.gz ├── .gitmodules ├── BUGS ├── osx-resources ├── InstallationCheck.strings └── InstallationCheck ├── PROFILING ├── .gitignore ├── .travis.yml ├── man ├── man5 │ └── pandoc_markdown.5.template └── man1 │ └── pandoc.1.template ├── hsmarkdown ├── googlecode-upload.sh ├── src ├── Tests │ ├── Writers │ │ ├── Native.hs │ │ ├── Markdown.hs │ │ ├── HTML.hs │ │ └── ConTeXt.hs │ ├── Shared.hs │ ├── Readers │ │ ├── RST.hs │ │ └── Markdown.hs │ └── Helpers.hs ├── test-pandoc.hs └── Text │ └── Pandoc │ ├── Slides.hs │ ├── UUID.hs │ ├── Readers │ ├── Native.hs │ └── TeXMath.hs │ ├── Highlighting.hs │ ├── Writers │ └── Native.hs │ ├── UTF8.hs │ └── XML.hs ├── stats.sh ├── RELEASE-CHECKLIST ├── Interact.hs ├── make_osx_package.sh ├── epub.css ├── HCAR-Pandoc.tex ├── Benchmark.hs ├── data └── MathMLinHTML.js ├── MakeManPage.hs ├── COPYRIGHT ├── INSTALL └── Setup.hs /tests/insert: -------------------------------------------------------------------------------- 1 | STUFF INSERTED 2 | -------------------------------------------------------------------------------- /reference.odt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scslab/pandoc/master/reference.odt -------------------------------------------------------------------------------- /reference.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scslab/pandoc/master/reference.docx -------------------------------------------------------------------------------- /tests/bodybg.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scslab/pandoc/master/tests/bodybg.gif -------------------------------------------------------------------------------- /tests/lalune.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scslab/pandoc/master/tests/lalune.jpg -------------------------------------------------------------------------------- /tests/movie.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scslab/pandoc/master/tests/movie.jpg -------------------------------------------------------------------------------- /windows/pcre3.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scslab/pandoc/master/windows/pcre3.dll -------------------------------------------------------------------------------- /s5/default/blank.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scslab/pandoc/master/s5/default/blank.gif -------------------------------------------------------------------------------- /s5/default/bodybg.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scslab/pandoc/master/s5/default/bodybg.gif -------------------------------------------------------------------------------- /slidy/graphics/fold.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scslab/pandoc/master/slidy/graphics/fold.gif -------------------------------------------------------------------------------- /tests/MarkdownTest_1.0.3/Tests/Nested blockquotes.text: -------------------------------------------------------------------------------- 1 | > foo 2 | > 3 | > > bar 4 | > 5 | > foo 6 | -------------------------------------------------------------------------------- /slidy/graphics/unfold.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scslab/pandoc/master/slidy/graphics/unfold.gif -------------------------------------------------------------------------------- /slidy/scripts/slidy.js.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scslab/pandoc/master/slidy/scripts/slidy.js.gz -------------------------------------------------------------------------------- /slidy/graphics/fold-dim.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scslab/pandoc/master/slidy/graphics/fold-dim.gif -------------------------------------------------------------------------------- /slidy/graphics/nofold-dim.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scslab/pandoc/master/slidy/graphics/nofold-dim.gif -------------------------------------------------------------------------------- /slidy/graphics/unfold-dim.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scslab/pandoc/master/slidy/graphics/unfold-dim.gif -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "templates"] 2 | path = templates 3 | url = git://github.com/jgm/pandoc-templates.git 4 | -------------------------------------------------------------------------------- /tests/MarkdownTest_1.0.3/Tests/Tidyness.text: -------------------------------------------------------------------------------- 1 | > A list within a blockquote: 2 | > 3 | > * asterisk 1 4 | > * asterisk 2 5 | > * asterisk 3 6 | -------------------------------------------------------------------------------- /BUGS: -------------------------------------------------------------------------------- 1 | To view a list of known bugs, or to enter a bug report, please use 2 | Pandoc's issue tracker: 3 | -------------------------------------------------------------------------------- /osx-resources/InstallationCheck.strings: -------------------------------------------------------------------------------- 1 | "16" = "This installer works only on Intel Macs."; 2 | "17" = "This installer requires a 64-bit processor."; 3 | 4 | -------------------------------------------------------------------------------- /PROFILING: -------------------------------------------------------------------------------- 1 | To use the GHC profiler: 2 | 3 | cabal clean 4 | cabal install --enable-library-profiling --enable-executable-profiling 5 | pandoc +RTS -p -RTS [file]... 6 | less pandoc.prof 7 | -------------------------------------------------------------------------------- /tests/MarkdownTest_1.0.3/Tests/Strong and em together.text: -------------------------------------------------------------------------------- 1 | ***This is strong and em.*** 2 | 3 | So is ***this*** word. 4 | 5 | ___This is strong and em.___ 6 | 7 | So is ___this___ word. 8 | -------------------------------------------------------------------------------- /tests/MarkdownTest_1.0.3/Tests/Literal quotes in titles.text: -------------------------------------------------------------------------------- 1 | Foo [bar][]. 2 | 3 | Foo [bar](/url/ "Title with "quotes" inside"). 4 | 5 | 6 | [bar]: /url/ "Title with "quotes" inside" 7 | 8 | -------------------------------------------------------------------------------- /tests/MarkdownTest_1.0.3/Tests/Nested blockquotes.html: -------------------------------------------------------------------------------- 1 |
2 |

foo

3 | 4 |
5 |

bar

6 |
7 | 8 |

foo

9 |
10 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | dist/* 2 | README.* 3 | !README.Debian 4 | INSTALL.* 5 | .configure-stamp 6 | man/man?/*.1 7 | man/man?/*.5 8 | man/man?/*.html 9 | *.diff 10 | pandoc.cabal.orig 11 | *.o 12 | *.hi 13 | 14 | -------------------------------------------------------------------------------- /tests/MarkdownTest_1.0.3/Tests/Tidyness.html: -------------------------------------------------------------------------------- 1 |
2 |

A list within a blockquote:

3 | 8 |
9 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: haskell 2 | before_install: 3 | - git submodule update --init --recursive 4 | install: 5 | - cabal update 6 | - cabal install -ftests 7 | script: cabal configure -ftests && cabal build && cabal test 8 | -------------------------------------------------------------------------------- /tests/MarkdownTest_1.0.3/Tests/Code Spans.text: -------------------------------------------------------------------------------- 1 | `` 2 | 3 | Fix for backticks within HTML tag: like this 4 | 5 | Here's how you put `` `backticks` `` in a code span. 6 | 7 | -------------------------------------------------------------------------------- /tests/MarkdownTest_1.0.3/Tests/Literal quotes in titles.html: -------------------------------------------------------------------------------- 1 |

Foo bar.

2 | 3 |

Foo bar.

4 | -------------------------------------------------------------------------------- /s5/default/opera.css: -------------------------------------------------------------------------------- 1 | /* DO NOT CHANGE THESE unless you really want to break Opera Show */ 2 | .slide { 3 | visibility: visible !important; 4 | position: static !important; 5 | page-break-before: always; 6 | } 7 | #slide0 {page-break-before: avoid;} 8 | -------------------------------------------------------------------------------- /tests/MarkdownTest_1.0.3/Tests/Blockquotes with code blocks.text: -------------------------------------------------------------------------------- 1 | > Example: 2 | > 3 | > sub status { 4 | > print "working"; 5 | > } 6 | > 7 | > Or: 8 | > 9 | > sub status { 10 | > return "working"; 11 | > } 12 | -------------------------------------------------------------------------------- /s5/default/slides.css: -------------------------------------------------------------------------------- 1 | @import url(s5-core.css); /* required to make the slide show run at all */ 2 | @import url(framing.css); /* sets basic placement and size of slide components */ 3 | @import url(pretty.css); /* stuff that makes the slides look better than blah */ -------------------------------------------------------------------------------- /man/man5/pandoc_markdown.5.template: -------------------------------------------------------------------------------- 1 | $if(has-tables)$ 2 | .\"t 3 | $endif$ 4 | .TH PANDOC_MARKDOWN 5 "$date$" "$title$" 5 | .SH NAME 6 | pandoc_markdown - markdown syntax for pandoc(1) 7 | .SH DESCRIPTION 8 | $body$ 9 | .SH SEE ALSO 10 | .PP 11 | \f[C]pandoc\f[] (1). 12 | -------------------------------------------------------------------------------- /hsmarkdown: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # hsmarkdown - intended as a drop-in replacement for Markdown.pl. 3 | # Uses pandoc to convert from markdown to HTML, using --strict mode 4 | # for maximum compatibility with official markdown syntax. 5 | exec pandoc --from markdown --to html --strict -- "$@" 6 | -------------------------------------------------------------------------------- /tests/MarkdownTest_1.0.3/Tests/Inline HTML (Advanced).text: -------------------------------------------------------------------------------- 1 | Simple block on one line: 2 | 3 |
foo
4 | 5 | And nested without indentation: 6 | 7 |
8 |
9 |
10 | foo 11 |
12 |
13 |
14 |
bar
15 |
16 | -------------------------------------------------------------------------------- /tests/MarkdownTest_1.0.3/Tests/Inline HTML comments.text: -------------------------------------------------------------------------------- 1 | Paragraph one. 2 | 3 | 4 | 5 | 8 | 9 | Paragraph two. 10 | 11 | 12 | 13 | The end. 14 | -------------------------------------------------------------------------------- /tests/s5.fragment.html: -------------------------------------------------------------------------------- 1 |

First slide

2 |
    3 |
  • first bullet
  • 4 |
  • second bullet
  • 5 |
6 |

Math

7 |
    8 |
  • $\frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}$
  • 9 |
10 | -------------------------------------------------------------------------------- /tests/MarkdownTest_1.0.3/Tests/Code Spans.html: -------------------------------------------------------------------------------- 1 |

<test a=" content of attribute ">

2 | 3 |

Fix for backticks within HTML tag: like this

4 | 5 |

Here's how you put `backticks` in a code span.

6 | 7 | -------------------------------------------------------------------------------- /osx-resources/InstallationCheck: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | cputype=`sysctl -n hw.cputype` 3 | sixtyfourbit=`sysctl -n hw.cpu64bit_capable` 4 | 5 | if [ "x$cputype" != "x7" ] # x86 6 | then 7 | exit 112 8 | fi 9 | 10 | if [ "x$sixtyfourbit" != "x1" ] # 64 bit 11 | then 12 | exit 113 13 | fi 14 | 15 | -------------------------------------------------------------------------------- /tests/MarkdownTest_1.0.3/Tests/Inline HTML (Advanced).html: -------------------------------------------------------------------------------- 1 |

Simple block on one line:

2 | 3 |
foo
4 | 5 |

And nested without indentation:

6 | 7 |
8 |
9 |
10 | foo 11 |
12 |
13 |
14 |
bar
15 |
16 | -------------------------------------------------------------------------------- /tests/MarkdownTest_1.0.3/Tests/Strong and em together.html: -------------------------------------------------------------------------------- 1 |

This is strong and em.

2 | 3 |

So is this word.

4 | 5 |

This is strong and em.

6 | 7 |

So is this word.

8 | -------------------------------------------------------------------------------- /tests/MarkdownTest_1.0.3/Tests/Code Blocks.text: -------------------------------------------------------------------------------- 1 | code block on the first line 2 | 3 | Regular text. 4 | 5 | code block indented by spaces 6 | 7 | Regular text. 8 | 9 | the lines in this block 10 | all contain trailing spaces 11 | 12 | Regular Text. 13 | 14 | code block on the last line -------------------------------------------------------------------------------- /tests/MarkdownTest_1.0.3/Tests/Hard-wrapped paragraphs with list-like lines.text: -------------------------------------------------------------------------------- 1 | In Markdown 1.0.0 and earlier. Version 2 | 8. This line turns into a list item. 3 | Because a hard-wrapped line in the 4 | middle of a paragraph looked like a 5 | list item. 6 | 7 | Here's one with a bullet. 8 | * criminey. 9 | -------------------------------------------------------------------------------- /tests/MarkdownTest_1.0.3/Tests/Inline HTML comments.html: -------------------------------------------------------------------------------- 1 |

Paragraph one.

2 | 3 | 4 | 5 | 8 | 9 |

Paragraph two.

10 | 11 | 12 | 13 |

The end.

14 | -------------------------------------------------------------------------------- /tests/MarkdownTest_1.0.3/Tests/Hard-wrapped paragraphs with list-like lines.html: -------------------------------------------------------------------------------- 1 |

In Markdown 1.0.0 and earlier. Version 2 | 8. This line turns into a list item. 3 | Because a hard-wrapped line in the 4 | middle of a paragraph looked like a 5 | list item.

6 | 7 |

Here's one with a bullet. 8 | * criminey.

9 | -------------------------------------------------------------------------------- /tests/MarkdownTest_1.0.3/Tests/Blockquotes with code blocks.html: -------------------------------------------------------------------------------- 1 |
2 |

Example:

3 | 4 |
sub status {
 5 |     print "working";
 6 | }
 7 | 
8 | 9 |

Or:

10 | 11 |
sub status {
12 |     return "working";
13 | }
14 | 
15 |
16 | -------------------------------------------------------------------------------- /tests/MarkdownTest_1.0.3/Tests/Links, inline style.text: -------------------------------------------------------------------------------- 1 | Just a [URL](/url/). 2 | 3 | [URL and title](/url/ "title"). 4 | 5 | [URL and title](/url/ "title preceded by two spaces"). 6 | 7 | [URL and title](/url/ "title preceded by a tab"). 8 | 9 | [URL and title](/url/ "title has spaces afterward" ). 10 | 11 | 12 | [Empty](). 13 | -------------------------------------------------------------------------------- /tests/MarkdownTest_1.0.3/Tests/Links, shortcut references.html: -------------------------------------------------------------------------------- 1 |

This is the simple case.

2 | 3 |

This one has a line 4 | break.

5 | 6 |

This one has a line 7 | break with a line-ending space.

8 | 9 |

this and the other

10 | -------------------------------------------------------------------------------- /tests/MarkdownTest_1.0.3/Tests/Auto links.text: -------------------------------------------------------------------------------- 1 | Link: . 2 | 3 | With an ampersand: 4 | 5 | * In a list? 6 | * 7 | * It should. 8 | 9 | > Blockquoted: 10 | 11 | Auto-links should not occur here: `` 12 | 13 | or here: -------------------------------------------------------------------------------- /tests/MarkdownTest_1.0.3/Tests/Links, shortcut references.text: -------------------------------------------------------------------------------- 1 | This is the [simple case]. 2 | 3 | [simple case]: /simple 4 | 5 | 6 | 7 | This one has a [line 8 | break]. 9 | 10 | This one has a [line 11 | break] with a line-ending space. 12 | 13 | [line break]: /foo 14 | 15 | 16 | [this] [that] and the [other] 17 | 18 | [this]: /this 19 | [that]: /that 20 | [other]: /other 21 | -------------------------------------------------------------------------------- /tests/MarkdownTest_1.0.3/Tests/Code Blocks.html: -------------------------------------------------------------------------------- 1 |
code block on the first line
 2 | 
3 | 4 |

Regular text.

5 | 6 |
code block indented by spaces
 7 | 
8 | 9 |

Regular text.

10 | 11 |
the lines in this block  
12 | all contain trailing spaces  
13 | 
14 | 15 |

Regular Text.

16 | 17 |
code block on the last line
18 | 
19 | -------------------------------------------------------------------------------- /tests/MarkdownTest_1.0.3/Tests/Tabs.text: -------------------------------------------------------------------------------- 1 | + this is a list item 2 | indented with tabs 3 | 4 | + this is a list item 5 | indented with spaces 6 | 7 | Code: 8 | 9 | this code block is indented by one tab 10 | 11 | And: 12 | 13 | this code block is indented by two tabs 14 | 15 | And: 16 | 17 | + this is an example list item 18 | indented with tabs 19 | 20 | + this is an example list item 21 | indented with spaces 22 | -------------------------------------------------------------------------------- /s5/default/s5-core.css: -------------------------------------------------------------------------------- 1 | /* Do not edit or override these styles! The system will likely break if you do. */ 2 | 3 | div#header, div#footer, div#controls, .slide {position: absolute;} 4 | html>body div#header, html>body div#footer, 5 | html>body div#controls, html>body .slide {position: fixed;} 6 | .handout {display: none;} 7 | .layout {display: block;} 8 | .slide, .hideme, .incremental {visibility: hidden;} 9 | #slide0 {visibility: visible;} 10 | -------------------------------------------------------------------------------- /tests/MarkdownTest_1.0.3/Tests/Links, inline style.html: -------------------------------------------------------------------------------- 1 |

Just a URL.

2 | 3 |

URL and title.

4 | 5 |

URL and title.

6 | 7 |

URL and title.

8 | 9 |

URL and title.

10 | 11 |

Empty.

12 | -------------------------------------------------------------------------------- /googlecode-upload.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | VERSION=$1 3 | googlecode_upload.py -s "Source tarball" -p pandoc -u fiddlosopher --labels=Featured,Type-Source,OpSys-All dist/pandoc-$VERSION.tar.gz 4 | googlecode_upload.py -s "Windows installer" -p pandoc -u fiddlosopher --labels=Featured,Type-Installer,OpSys-Windows pandoc-$VERSION-setup.exe 5 | googlecode_upload.py -s "Mac OS X installer" -p pandoc -u fiddlosopher --labels=Featured,Type-Installer,OpSys-OSX pandoc-$VERSION.dmg 6 | -------------------------------------------------------------------------------- /tests/s5.native: -------------------------------------------------------------------------------- 1 | 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"]}) 2 | [Header 1 [Str "First",Space,Str "slide"] 3 | ,BulletList 4 | [[Plain [Str "first",Space,Str "bullet"]] 5 | ,[Plain [Str "second",Space,Str "bullet"]]] 6 | ,Header 1 [Str "Math"] 7 | ,BulletList 8 | [[Plain [Math InlineMath "\\frac{d}{dx}f(x)=\\lim_{h\\to 0}\\frac{f(x+h)-f(x)}{h}"]]]] 9 | -------------------------------------------------------------------------------- /man/man1/pandoc.1.template: -------------------------------------------------------------------------------- 1 | $if(has-tables)$ 2 | .\"t 3 | $endif$ 4 | .TH PANDOC 1 "$date$" "$title$" 5 | .SH NAME 6 | pandoc - general markup converter 7 | $body$ 8 | .SH PANDOC'S MARKDOWN 9 | For a complete description of pandoc's extensions to standard markdown, 10 | see \f[C]pandoc_markdown\f[] (5). 11 | .SH SEE ALSO 12 | .PP 13 | \f[C]markdown2pdf\f[] (1), \f[C]pandoc_markdown\f[] (5). 14 | .PP 15 | The Pandoc source code and all documentation may be downloaded 16 | from . 17 | -------------------------------------------------------------------------------- /tests/MarkdownTest_1.0.3/Tests/Amps and angle encoding.text: -------------------------------------------------------------------------------- 1 | AT&T has an ampersand in their name. 2 | 3 | AT&T is another way to write it. 4 | 5 | This & that. 6 | 7 | 4 < 5. 8 | 9 | 6 > 5. 10 | 11 | Here's a [link] [1] with an ampersand in the URL. 12 | 13 | Here's a link with an amersand in the link text: [AT&T] [2]. 14 | 15 | Here's an inline [link](/script?foo=1&bar=2). 16 | 17 | Here's an inline [link](). 18 | 19 | 20 | [1]: http://example.com/?foo=1&bar=2 21 | [2]: http://att.com/ "AT&T" -------------------------------------------------------------------------------- /tests/biblio.bib: -------------------------------------------------------------------------------- 1 | @Book{item1, 2 | author="John Doe", 3 | title="First Book", 4 | year="2005", 5 | address="Cambridge", 6 | publisher="Cambridge University Press" 7 | } 8 | 9 | @Article{item2, 10 | author="John Doe", 11 | title="Article", 12 | year="2006", 13 | journal="Journal of Generic Studies", 14 | volume="6", 15 | pages="33-34" 16 | } 17 | 18 | @InCollection{пункт3, 19 | author="John Doe and Jenny Roe", 20 | title="Why Water Is Wet", 21 | booktitle="Third Book", 22 | editor="Sam Smith", 23 | publisher="Oxford University Press", 24 | address="Oxford", 25 | year="2007" 26 | } 27 | -------------------------------------------------------------------------------- /tests/MarkdownTest_1.0.3/Tests/Tabs.html: -------------------------------------------------------------------------------- 1 |
    2 |
  • this is a list item 3 | indented with tabs

  • 4 |
  • this is a list item 5 | indented with spaces

  • 6 |
7 | 8 |

Code:

9 | 10 |
this code block is indented by one tab
11 | 
12 | 13 |

And:

14 | 15 |
    this code block is indented by two tabs
16 | 
17 | 18 |

And:

19 | 20 |
+   this is an example list item
21 |     indented with tabs
22 | 
23 | +   this is an example list item
24 |     indented with spaces
25 | 
26 | -------------------------------------------------------------------------------- /tests/lhs-test.markdown+lhs: -------------------------------------------------------------------------------- 1 | lhs test 2 | ======== 3 | 4 | `unsplit` is an arrow that takes a pair of values and combines them to return 5 | a single value: 6 | 7 | > unsplit :: (Arrow a) => (b -> c -> d) -> a (b, c) d 8 | > unsplit = arr . uncurry 9 | > -- arr (\op (x,y) -> x `op` y) 10 | 11 | `(***)` combines two arrows into a new arrow by running the two arrows on a 12 | pair of values (one arrow on the first item of the pair and one arrow on the 13 | second item of the pair). 14 | 15 | f *** g = first f >>> second g 16 | 17 | Block quote: 18 | 19 | > foo bar 20 | -------------------------------------------------------------------------------- /tests/lhs-test.rst+lhs: -------------------------------------------------------------------------------- 1 | lhs test 2 | ======== 3 | 4 | ``unsplit`` is an arrow that takes a pair of values and combines them to 5 | return a single value: 6 | 7 | > unsplit :: (Arrow a) => (b -> c -> d) -> a (b, c) d 8 | > unsplit = arr . uncurry 9 | > -- arr (\op (x,y) -> x `op` y) 10 | 11 | ``(***)`` combines two arrows into a new arrow by running the two arrows on a 12 | pair of values (one arrow on the first item of the pair and one arrow on the 13 | second item of the pair). 14 | 15 | :: 16 | 17 | f *** g = first f >>> second g 18 | 19 | Block quote: 20 | 21 | foo bar 22 | -------------------------------------------------------------------------------- /tests/lhs-test.rst: -------------------------------------------------------------------------------- 1 | lhs test 2 | ======== 3 | 4 | ``unsplit`` is an arrow that takes a pair of values and combines them to 5 | return a single value: 6 | 7 | :: 8 | 9 | unsplit :: (Arrow a) => (b -> c -> d) -> a (b, c) d 10 | unsplit = arr . uncurry 11 | -- arr (\op (x,y) -> x `op` y) 12 | 13 | ``(***)`` combines two arrows into a new arrow by running the two arrows on a 14 | pair of values (one arrow on the first item of the pair and one arrow on the 15 | second item of the pair). 16 | 17 | :: 18 | 19 | f *** g = first f >>> second g 20 | 21 | Block quote: 22 | 23 | foo bar 24 | -------------------------------------------------------------------------------- /windows/make-windows-installer.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | cd .. 3 | cabal-dev install --disable-library-for-ghci highlighting-kate 4 | cabal-dev install --flags="embed_data_files" citeproc-hs 5 | cabal-dev install --flags="executable -library" --datasubdir= 6 | rem note: we use -f-library in building pandoc, because 7 | rem if the library is built, the data file paths will not be relocatable! 8 | strip cabal-dev\bin\pandoc.exe 9 | cabal-dev\bin\pandoc.exe -s --template templates\default.html -S README -o README.html 10 | copy COPYING COPYING.txt 11 | copy COPYRIGHT COPYRIGHT.txt 12 | cd windows 13 | ISCC pandoc-setup.iss 14 | -------------------------------------------------------------------------------- /tests/MarkdownTest_1.0.3/Tests/Amps and angle encoding.html: -------------------------------------------------------------------------------- 1 |

AT&T has an ampersand in their name.

2 | 3 |

AT&T is another way to write it.

4 | 5 |

This & that.

6 | 7 |

4 < 5.

8 | 9 |

6 > 5.

10 | 11 |

Here's a link with an ampersand in the URL.

12 | 13 |

Here's a link with an amersand in the link text: AT&T.

14 | 15 |

Here's an inline link.

16 | 17 |

Here's an inline link.

18 | -------------------------------------------------------------------------------- /tests/lhs-test.markdown: -------------------------------------------------------------------------------- 1 | lhs test 2 | ======== 3 | 4 | `unsplit` is an arrow that takes a pair of values and combines them to return 5 | a single value: 6 | 7 | ~~~~ {.sourceCode .literate .haskell} 8 | unsplit :: (Arrow a) => (b -> c -> d) -> a (b, c) d 9 | unsplit = arr . uncurry 10 | -- arr (\op (x,y) -> x `op` y) 11 | ~~~~ 12 | 13 | `(***)` combines two arrows into a new arrow by running the two arrows on a 14 | pair of values (one arrow on the first item of the pair and one arrow on the 15 | second item of the pair). 16 | 17 | f *** g = first f >>> second g 18 | 19 | Block quote: 20 | 21 | > foo bar 22 | -------------------------------------------------------------------------------- /tests/MarkdownTest_1.0.3/Tests/Horizontal rules.text: -------------------------------------------------------------------------------- 1 | Dashes: 2 | 3 | --- 4 | 5 | --- 6 | 7 | --- 8 | 9 | --- 10 | 11 | --- 12 | 13 | - - - 14 | 15 | - - - 16 | 17 | - - - 18 | 19 | - - - 20 | 21 | - - - 22 | 23 | 24 | Asterisks: 25 | 26 | *** 27 | 28 | *** 29 | 30 | *** 31 | 32 | *** 33 | 34 | *** 35 | 36 | * * * 37 | 38 | * * * 39 | 40 | * * * 41 | 42 | * * * 43 | 44 | * * * 45 | 46 | 47 | Underscores: 48 | 49 | ___ 50 | 51 | ___ 52 | 53 | ___ 54 | 55 | ___ 56 | 57 | ___ 58 | 59 | _ _ _ 60 | 61 | _ _ _ 62 | 63 | _ _ _ 64 | 65 | _ _ _ 66 | 67 | _ _ _ 68 | -------------------------------------------------------------------------------- /tests/MarkdownTest_1.0.3/Tests/Auto links.html: -------------------------------------------------------------------------------- 1 |

Link: http://example.com/.

2 | 3 |

With an ampersand: http://example.com/?foo=1&bar=2

4 | 5 | 10 | 11 |
12 |

Blockquoted: http://example.com/

13 |
14 | 15 |

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

16 | 17 |
or here: <http://example.com/>
18 | 
19 | -------------------------------------------------------------------------------- /src/Tests/Writers/Native.hs: -------------------------------------------------------------------------------- 1 | module Tests.Writers.Native (tests) where 2 | 3 | import Test.Framework 4 | import Text.Pandoc.Builder 5 | import Text.Pandoc 6 | import Tests.Helpers 7 | import Tests.Arbitrary() 8 | 9 | p_write_rt :: Pandoc -> Bool 10 | p_write_rt d = 11 | read (writeNative defaultWriterOptions{ writerStandalone = True } d) == d 12 | 13 | p_write_blocks_rt :: [Block] -> Bool 14 | p_write_blocks_rt bs = length bs > 20 || 15 | read (writeNative defaultWriterOptions (Pandoc (Meta [] [] []) bs)) == 16 | bs 17 | 18 | tests :: [Test] 19 | tests = [ property "p_write_rt" p_write_rt 20 | , property "p_write_blocks_rt" p_write_blocks_rt 21 | ] 22 | -------------------------------------------------------------------------------- /s5/default/outline.css: -------------------------------------------------------------------------------- 1 | /* don't change this unless you want the layout stuff to show up in the outline view! */ 2 | 3 | .layout div, #footer *, #controlForm * {display: none;} 4 | #footer, #controls, #controlForm, #navLinks, #toggle { 5 | display: block; visibility: visible; margin: 0; padding: 0;} 6 | #toggle {float: right; padding: 0.5em;} 7 | html>body #toggle {position: fixed; top: 0; right: 0;} 8 | 9 | /* making the outline look pretty-ish */ 10 | 11 | #slide0 h1, #slide0 h2, #slide0 h3, #slide0 h4 {border: none; margin: 0;} 12 | #slide0 h1 {padding-top: 1.5em;} 13 | .slide h1 {margin: 1.5em 0 0; padding-top: 0.25em; 14 | border-top: 1px solid #888; border-bottom: 1px solid #AAA;} 15 | #toggle {border: 1px solid; border-width: 0 0 1px 1px; background: #FFF;} 16 | -------------------------------------------------------------------------------- /tests/MarkdownTest_1.0.3/Tests/Horizontal rules.html: -------------------------------------------------------------------------------- 1 |

Dashes:

2 | 3 |
4 | 5 |
6 | 7 |
8 | 9 |
10 | 11 |
---
12 | 
13 | 14 |
15 | 16 |
17 | 18 |
19 | 20 |
21 | 22 |
- - -
23 | 
24 | 25 |

Asterisks:

26 | 27 |
28 | 29 |
30 | 31 |
32 | 33 |
34 | 35 |
***
36 | 
37 | 38 |
39 | 40 |
41 | 42 |
43 | 44 |
45 | 46 |
* * *
47 | 
48 | 49 |

Underscores:

50 | 51 |
52 | 53 |
54 | 55 |
56 | 57 |
58 | 59 |
___
60 | 
61 | 62 |
63 | 64 |
65 | 66 |
67 | 68 |
69 | 70 |
_ _ _
71 | 
72 | -------------------------------------------------------------------------------- /tests/MarkdownTest_1.0.3/Tests/Inline HTML (Simple).text: -------------------------------------------------------------------------------- 1 | Here's a simple block: 2 | 3 |
4 | foo 5 |
6 | 7 | This should be a code block, though: 8 | 9 |
10 | foo 11 |
12 | 13 | As should this: 14 | 15 |
foo
16 | 17 | Now, nested: 18 | 19 |
20 |
21 |
22 | foo 23 |
24 |
25 |
26 | 27 | This should just be an HTML comment: 28 | 29 | 30 | 31 | Multiline: 32 | 33 | 37 | 38 | Code block: 39 | 40 | 41 | 42 | Just plain comment, with trailing spaces on the line: 43 | 44 | 45 | 46 | Code: 47 | 48 |
49 | 50 | Hr's: 51 | 52 |
53 | 54 |
55 | 56 |
57 | 58 |
59 | 60 |
61 | 62 |
63 | 64 |
65 | 66 |
67 | 68 |
69 | 70 | -------------------------------------------------------------------------------- /src/Tests/Writers/Markdown.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE OverloadedStrings, QuasiQuotes #-} 2 | module Tests.Writers.Markdown (tests) where 3 | 4 | import Test.Framework 5 | import Text.Pandoc.Builder 6 | import Text.Pandoc 7 | import Tests.Helpers 8 | import Tests.Arbitrary() 9 | 10 | markdown :: (ToString a, ToPandoc a) => a -> String 11 | markdown = writeMarkdown defaultWriterOptions . toPandoc 12 | 13 | {- 14 | "my test" =: X =?> Y 15 | 16 | is shorthand for 17 | 18 | test markdown "my test" $ X =?> Y 19 | 20 | which is in turn shorthand for 21 | 22 | test markdown "my test" (X,Y) 23 | -} 24 | 25 | infix 4 =: 26 | (=:) :: (ToString a, ToPandoc a) 27 | => String -> (a, String) -> Test 28 | (=:) = test markdown 29 | 30 | tests :: [Test] 31 | tests = [ "indented code after list" 32 | =: (orderedList [ para "one" <> para "two" ] <> codeBlock "test") 33 | =?> "1. one\n\n two\n\n\n\n test" 34 | ] 35 | -------------------------------------------------------------------------------- /src/Tests/Shared.hs: -------------------------------------------------------------------------------- 1 | module Tests.Shared (tests) where 2 | 3 | import Text.Pandoc.Definition 4 | import Text.Pandoc.Shared 5 | import Test.Framework 6 | import Tests.Helpers 7 | import Tests.Arbitrary() 8 | 9 | tests :: [Test] 10 | tests = [ testGroup "normalize" 11 | [ property "p_normalize_blocks_rt" p_normalize_blocks_rt 12 | , property "p_normalize_inlines_rt" p_normalize_inlines_rt 13 | , property "p_normalize_no_trailing_spaces" 14 | p_normalize_no_trailing_spaces 15 | ] 16 | ] 17 | 18 | p_normalize_blocks_rt :: [Block] -> Bool 19 | p_normalize_blocks_rt bs = normalize bs == normalize (normalize bs) 20 | 21 | p_normalize_inlines_rt :: [Inline] -> Bool 22 | p_normalize_inlines_rt ils = normalize ils == normalize (normalize ils) 23 | 24 | p_normalize_no_trailing_spaces :: [Inline] -> Bool 25 | p_normalize_no_trailing_spaces ils = null ils' || last ils' /= Space 26 | where ils' = normalize $ ils ++ [Space] 27 | -------------------------------------------------------------------------------- /stats.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Generates statistics on pandoc: benchmarks and lines of code 4 | # The stats are put in the stats directory, marked with date and revision hash. 5 | 6 | STATSDIR=stats 7 | mkdir $STATSDIR 8 | 9 | DATE=`date +%Y_%m_%d` 10 | REV=`git rev-parse --short HEAD` 11 | 12 | EXT=$DATE.$REV 13 | BENCH=$STATSDIR/benchmark.$EXT 14 | LOC=$STATSDIR/loc.$EXT 15 | SUMMARY=$STATSDIR/summary.$EXT 16 | 17 | runghc Benchmark.hs > $BENCH 18 | find src -name '*.hs' | xargs wc -l > $LOC 19 | 20 | LOCSUM=`tail -1 $LOC | sed -Ee 's/^ *([0-9]+).*/\1/'` 21 | 22 | echo "Revision $REV" > $SUMMARY 23 | echo `date` >> $SUMMARY 24 | echo "$LOCSUM lines of code" >> $SUMMARY 25 | echo "" >> $SUMMARY 26 | 27 | sed -nEe '/^(benchmarking|mean:)/p' $BENCH | \ 28 | sed -Ee '/benchmarking/N;s/\n/: /' | \ 29 | sed -Ee 's/benchmarking (.*)/\1/' | \ 30 | sed -Ee 's/mean: ([^ ]*) *([^,]*).*/\1:\2/' | \ 31 | awk 'BEGIN { FS = ": *" } ; { printf("%s:%7.2f %s\n", $1, $2, $3); }' | \ 32 | column -t -s ":" >> $SUMMARY 33 | 34 | -------------------------------------------------------------------------------- /tests/lhs-test.fragment.html+lhs: -------------------------------------------------------------------------------- 1 |

lhs test

2 | 3 |

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

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

(***) 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).

8 | 9 |
f *** g = first f >>> second g
10 | 11 |

Block quote:

12 | 13 |
14 |

foo bar

15 |
16 | -------------------------------------------------------------------------------- /tests/markdown-citations.txt: -------------------------------------------------------------------------------- 1 | Pandoc with citeproc-hs 2 | ======================= 3 | 4 | - [@nonexistent] 5 | 6 | - @nonexistent 7 | 8 | - @item1 says blah. 9 | 10 | - @item1 [p. 30] says blah. 11 | 12 | - @item1 [p. 30, with suffix] says blah. 13 | 14 | - @item1 [-@item2 p. 30; see also @пункт3] says blah. 15 | 16 | - In a note.[^1] 17 | 18 | - A citation group [see @item1 chap. 3; also @пункт3 p. 34-35]. 19 | 20 | - Another one [see @item1 p. 34-35]. 21 | 22 | - And another one in a note.[^2] 23 | 24 | - Citation with a suffix and locator [@item1 pp. 33, 35-37, and nowhere else]. 25 | 26 | - Citation with suffix only [@item1 and nowhere else]. 27 | 28 | - Now some modifiers.[^3] 29 | 30 | - With some markup [*see* @item1 p. **32**]. 31 | 32 | References 33 | ========== 34 | 35 | [^1]: A citation without locators [@пункт3]. 36 | 37 | [^2]: Some citations [see @item1 chap. 3; @пункт3; @item2]. 38 | 39 | [^3]: Like a citation without author: [-@item1], and now Doe with a locator [-@item2 p. 44]. 40 | -------------------------------------------------------------------------------- /s5/default/framing.css: -------------------------------------------------------------------------------- 1 | /* The following styles size, place, and layer the slide components. 2 | Edit these if you want to change the overall slide layout. 3 | The commented lines can be uncommented (and modified, if necessary) 4 | to help you with the rearrangement process. */ 5 | 6 | /* target = 1024x768 */ 7 | 8 | div#header, div#footer, .slide {width: 100%; top: 0; left: 0;} 9 | div#header {top: 0; height: 3em; z-index: 1;} 10 | div#footer {top: auto; bottom: 0; height: 2.5em; z-index: 5;} 11 | .slide {top: 0; width: 92%; padding: 3.5em 4% 4%; z-index: 2; list-style: none;} 12 | div#controls {left: 50%; bottom: 0; width: 50%; z-index: 100;} 13 | div#controls form {position: absolute; bottom: 0; right: 0; width: 100%; 14 | margin: 0;} 15 | #currentSlide {position: absolute; width: 10%; left: 45%; bottom: 1em; z-index: 10;} 16 | html>body #currentSlide {position: fixed;} 17 | 18 | /* 19 | div#header {background: #FCC;} 20 | div#footer {background: #CCF;} 21 | div#controls {background: #BBD;} 22 | div#currentSlide {background: #FFC;} 23 | */ 24 | -------------------------------------------------------------------------------- /s5/default/print.css: -------------------------------------------------------------------------------- 1 | /* The following rule is necessary to have all slides appear in print! DO NOT REMOVE IT! */ 2 | .slide, ul {page-break-inside: avoid; visibility: visible !important;} 3 | h1 {page-break-after: avoid;} 4 | 5 | body {font-size: 12pt; background: white;} 6 | * {color: black;} 7 | 8 | #slide0 h1 {font-size: 200%; border: none; margin: 0.5em 0 0.25em;} 9 | #slide0 h3 {margin: 0; padding: 0;} 10 | #slide0 h4 {margin: 0 0 0.5em; padding: 0;} 11 | #slide0 {margin-bottom: 3em;} 12 | 13 | h1 {border-top: 2pt solid gray; border-bottom: 1px dotted silver;} 14 | .extra {background: transparent !important;} 15 | div.extra, pre.extra, .example {font-size: 10pt; color: #333;} 16 | ul.extra a {font-weight: bold;} 17 | p.example {display: none;} 18 | 19 | #header {display: none;} 20 | #footer h1 {margin: 0; border-bottom: 1px solid; color: gray; font-style: italic;} 21 | #footer h2, #controls {display: none;} 22 | 23 | /* The following rule keeps the layout stuff out of print. Remove at your own risk! */ 24 | .layout, .layout * {display: none !important;} 25 | -------------------------------------------------------------------------------- /tests/markdown-citations.ieee.txt: -------------------------------------------------------------------------------- 1 | Pandoc with citeproc-hs 2 | ======================= 3 | 4 | - [@nonexistent] 5 | 6 | - @nonexistent 7 | 8 | - Reference 1 says blah. 9 | 10 | - Reference 1 says blah. 11 | 12 | - Reference 1 says blah. 13 | 14 | - Reference 1 [3] says blah. 15 | 16 | - In a note.[^1] 17 | 18 | - A citation group [1], [3]. 19 | 20 | - Another one [1]. 21 | 22 | - And another one in a note.[^2] 23 | 24 | - Citation with a suffix and locator [1]. 25 | 26 | - Citation with suffix only [1]. 27 | 28 | - Now some modifiers.[^3] 29 | 30 | - With some markup [1]. 31 | 32 | References 33 | ========== 34 | 35 | [1] J. Doe, *First Book*. Cambridge: Cambridge University Press, 2005. 36 | 37 | [2] J. Doe, “Article,” *Journal of Generic Studies*, vol. 6, pp. 33–34, 2006. 38 | 39 | [3] J. Doe and J. Roe, “Why Water Is Wet,” in *Third Book*, S. Smith, Ed. Oxford: Oxford University Press, 2007. 40 | 41 | [^1]: A citation without locators [3]. 42 | 43 | [^2]: Some citations [1–3]. 44 | 45 | [^3]: Like a citation without author: [1], and now Doe with a locator [2]. 46 | -------------------------------------------------------------------------------- /tests/MarkdownTest_1.0.3/Tests/Inline HTML (Simple).html: -------------------------------------------------------------------------------- 1 |

Here's a simple block:

2 | 3 |
4 | foo 5 |
6 | 7 |

This should be a code block, though:

8 | 9 |
<div>
10 |     foo
11 | </div>
12 | 
13 | 14 |

As should this:

15 | 16 |
<div>foo</div>
17 | 
18 | 19 |

Now, nested:

20 | 21 |
22 |
23 |
24 | foo 25 |
26 |
27 |
28 | 29 |

This should just be an HTML comment:

30 | 31 | 32 | 33 |

Multiline:

34 | 35 | 39 | 40 |

Code block:

41 | 42 |
<!-- Comment -->
43 | 
44 | 45 |

Just plain comment, with trailing spaces on the line:

46 | 47 | 48 | 49 |

Code:

50 | 51 |
<hr />
52 | 
53 | 54 |

Hr's:

55 | 56 |
57 | 58 |
59 | 60 |
61 | 62 |
63 | 64 |
65 | 66 |
67 | 68 |
69 | 70 |
71 | 72 |
73 | -------------------------------------------------------------------------------- /tests/MarkdownTest_1.0.3/Tests/Links, reference style.text: -------------------------------------------------------------------------------- 1 | Foo [bar] [1]. 2 | 3 | Foo [bar][1]. 4 | 5 | Foo [bar] 6 | [1]. 7 | 8 | [1]: /url/ "Title" 9 | 10 | 11 | With [embedded [brackets]] [b]. 12 | 13 | 14 | Indented [once][]. 15 | 16 | Indented [twice][]. 17 | 18 | Indented [thrice][]. 19 | 20 | Indented [four][] times. 21 | 22 | [once]: /url 23 | 24 | [twice]: /url 25 | 26 | [thrice]: /url 27 | 28 | [four]: /url 29 | 30 | 31 | [b]: /url/ 32 | 33 | * * * 34 | 35 | [this] [this] should work 36 | 37 | So should [this][this]. 38 | 39 | And [this] []. 40 | 41 | And [this][]. 42 | 43 | And [this]. 44 | 45 | But not [that] []. 46 | 47 | Nor [that][]. 48 | 49 | Nor [that]. 50 | 51 | [Something in brackets like [this][] should work] 52 | 53 | [Same with [this].] 54 | 55 | In this case, [this](/somethingelse/) points to something else. 56 | 57 | Backslashing should suppress \[this] and [this\]. 58 | 59 | [this]: foo 60 | 61 | 62 | * * * 63 | 64 | Here's one where the [link 65 | breaks] across lines. 66 | 67 | Here's another where the [link 68 | breaks] across lines, but with a line-ending space. 69 | 70 | 71 | [link breaks]: /url/ 72 | -------------------------------------------------------------------------------- /src/test-pandoc.hs: -------------------------------------------------------------------------------- 1 | {-# OPTIONS_GHC -Wall #-} 2 | 3 | module Main where 4 | 5 | import Test.Framework 6 | 7 | import qualified Tests.Old 8 | import qualified Tests.Readers.LaTeX 9 | import qualified Tests.Readers.Markdown 10 | import qualified Tests.Readers.RST 11 | import qualified Tests.Writers.ConTeXt 12 | import qualified Tests.Writers.HTML 13 | import qualified Tests.Writers.Native 14 | import qualified Tests.Writers.Markdown 15 | import qualified Tests.Shared 16 | 17 | tests :: [Test] 18 | tests = [ testGroup "Old" Tests.Old.tests 19 | , testGroup "Shared" Tests.Shared.tests 20 | , testGroup "Writers" 21 | [ testGroup "Native" Tests.Writers.Native.tests 22 | , testGroup "ConTeXt" Tests.Writers.ConTeXt.tests 23 | , testGroup "HTML" Tests.Writers.HTML.tests 24 | , testGroup "Markdown" Tests.Writers.Markdown.tests 25 | ] 26 | , testGroup "Readers" 27 | [ testGroup "LaTeX" Tests.Readers.LaTeX.tests 28 | , testGroup "Markdown" Tests.Readers.Markdown.tests 29 | , testGroup "RST" Tests.Readers.RST.tests 30 | ] 31 | ] 32 | 33 | main :: IO () 34 | main = defaultMain tests 35 | -------------------------------------------------------------------------------- /tests/s5.inserts.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | My S5 Document 11 | 12 | STUFF INSERTED 13 | 14 | 15 | STUFF INSERTED 16 | 22 |

First slide

23 |
    24 |
  • first bullet
  • 25 |
  • second bullet
  • 26 |
27 |

Math

28 |
    29 |
  • $\frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}$
  • 30 |
31 | STUFF INSERTED 32 | 33 | 34 | -------------------------------------------------------------------------------- /RELEASE-CHECKLIST: -------------------------------------------------------------------------------- 1 | _ Test, on linux, windows, mac (inc. website demos) 2 | 3 | _ Finalize changelog 4 | 5 | _ Tag release in git 6 | 7 | _ Generate tarball (make tarball) 8 | 9 | _ Generate Windows package and copy to directory. (First, do 10 | a cabal install and test, and then switch to windows directory 11 | and run the batch file there.) 12 | 13 | _ Generate Mac OSX package. 14 | 15 | _ Upload to Google Code 16 | googlecode_upload.py -s "Source tarball" -p pandoc -u fiddlosopher --labels=Featured,Type-Source,OpSys-All dist/pandoc-1.2.tar.gz 17 | googlecode_upload.py -s "Windows installer" -p pandoc -u fiddlosopher --labels=Featured,Type-Installer,OpSys-Windows pandoc-1.2-setup.exe 18 | googlecode_upload.py -s "Mac OS X installer" -p pandoc -u fiddlosopher --labels=Featured,Type-Installer,OpSys-OSX pandoc-1.2.dmg 19 | To get password: http://code.google.com/hosting/settings 20 | 21 | _ Go to Google code and deprecate the old versions 22 | 23 | _ Upload to HackageDB 24 | 25 | _ Update website, including short description of changes 26 | 27 | _ Announce on pandoc-announce, pandoc-discuss 28 | 29 | _ Update freshmeat page 30 | 31 | _ recompile trypandoc 32 | 33 | _ recompile gitit 34 | 35 | -------------------------------------------------------------------------------- /Interact.hs: -------------------------------------------------------------------------------- 1 | -- Get an interactive shell with the right packages to load 2 | -- pandoc modules. 3 | 4 | -- To use: 5 | -- runghc Interact.hs 6 | -- then, 7 | -- :l Text/Pandoc.hs 8 | -- (or whichever package you like) 9 | 10 | -- You must have first done a 'cabal configure' or 'cabal install' 11 | 12 | import System.Process 13 | import Distribution.Simple.LocalBuildInfo 14 | import Distribution.Package 15 | import Distribution.Version 16 | import Data.List (intercalate) 17 | 18 | main = do 19 | setupConfig' <- readFile "dist/setup-config" 20 | let setupConfig = read $ unlines $ drop 1 $ lines setupConfig' 21 | let (Just (ComponentLocalBuildInfo { componentPackageDeps = deps })) = libraryConfig setupConfig 22 | let packageSpecs = map (toPackageSpec . snd) deps 23 | let args = ["-optP-include", "-optP../dist/build/autogen/cabal_macros.h","-cpp","-I../dist/build/autogen","-i../dist/build/autogen"] ++ concatMap (\p -> ["-package",p]) packageSpecs 24 | print args 25 | ph <- runProcess "ghci" args (Just "src") Nothing Nothing Nothing Nothing 26 | waitForProcess ph 27 | 28 | toPackageSpec pkg = pkgN ++ "-" ++ pkgV 29 | where (PackageName pkgN) = pkgName pkg 30 | pkgV = intercalate "." $ map show $ versionBranch $ pkgVersion pkg 31 | -------------------------------------------------------------------------------- /tests/lhs-test.native: -------------------------------------------------------------------------------- 1 | [Header 1 [Str "lhs",Space,Str "test"] 2 | ,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 ":"] 3 | ,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) " 4 | ,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 "."] 5 | ,CodeBlock ("",[],[]) "f *** g = first f >>> second g" 6 | ,Para [Str "Block",Space,Str "quote",Str ":"] 7 | ,BlockQuote 8 | [Para [Str "foo",Space,Str "bar"]]] 9 | -------------------------------------------------------------------------------- /tests/markdown-citations.chicago-author-date.txt: -------------------------------------------------------------------------------- 1 | Pandoc with citeproc-hs 2 | ======================= 3 | 4 | - [@nonexistent] 5 | 6 | - @nonexistent 7 | 8 | - Doe (2005) says blah. 9 | 10 | - Doe (2005, 30) says blah. 11 | 12 | - Doe (2005, 30, with suffix) says blah. 13 | 14 | - Doe (2005; 2006, 30; see also Doe and Roe 2007) says blah. 15 | 16 | - In a note.[^1] 17 | 18 | - A citation group (see Doe 2005, chap. 3; also Doe and Roe 2007, 34–35). 19 | 20 | - Another one (see Doe 2005, 34–35). 21 | 22 | - And another one in a note.[^2] 23 | 24 | - Citation with a suffix and locator (Doe 2005, 33, 35–37, and nowhere else). 25 | 26 | - Citation with suffix only (Doe 2005 and nowhere else). 27 | 28 | - Now some modifiers.[^3] 29 | 30 | - With some markup (*see* Doe 2005, 32). 31 | 32 | References 33 | ========== 34 | 35 | Doe, John. 2005. *First Book*. Cambridge: Cambridge University Press. 36 | 37 | ———. 2006. “Article.” *Journal of Generic Studies* 6: 33–34. 38 | 39 | Doe, John, and Jenny Roe. 2007. “Why Water Is Wet.” In *Third Book*, ed. Sam Smith. Oxford: Oxford University Press. 40 | 41 | [^1]: A citation without locators (Doe and Roe 2007). 42 | 43 | [^2]: Some citations (see Doe 2005, chap. 3; Doe and Roe 2007; Doe 2006). 44 | 45 | [^3]: Like a citation without author: (2005), and now Doe with a locator (2006, 44). 46 | -------------------------------------------------------------------------------- /tests/MarkdownTest_1.0.3/Tests/Links, reference style.html: -------------------------------------------------------------------------------- 1 |

Foo bar.

2 | 3 |

Foo bar.

4 | 5 |

Foo bar.

6 | 7 |

With embedded [brackets].

8 | 9 |

Indented once.

10 | 11 |

Indented twice.

12 | 13 |

Indented thrice.

14 | 15 |

Indented [four][] times.

16 | 17 |
[four]: /url
18 | 
19 | 20 |
21 | 22 |

this should work

23 | 24 |

So should this.

25 | 26 |

And this.

27 | 28 |

And this.

29 | 30 |

And this.

31 | 32 |

But not [that] [].

33 | 34 |

Nor [that][].

35 | 36 |

Nor [that].

37 | 38 |

[Something in brackets like this should work]

39 | 40 |

[Same with this.]

41 | 42 |

In this case, this points to something else.

43 | 44 |

Backslashing should suppress [this] and [this].

45 | 46 |
47 | 48 |

Here's one where the link 49 | breaks across lines.

50 | 51 |

Here's another where the link 52 | breaks across lines, but with a line-ending space.

53 | -------------------------------------------------------------------------------- /s5/default/iepngfix.htc: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 42 | -------------------------------------------------------------------------------- /make_osx_package.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh -e 2 | 3 | DIST=osx_package 4 | VERSION=$(grep -e '^Version' pandoc.cabal | awk '{print $2}') 5 | RESOURCES=$DIST/Resources 6 | ROOT=$DIST/pandoc 7 | SCRIPTS=osx-resources 8 | BASE=pandoc-$VERSION 9 | ME=jgm 10 | 11 | echo Removing old files... 12 | rm -rf $DIST 13 | mkdir -p $RESOURCES 14 | 15 | echo Building pandoc... 16 | sudo cabal-dev install-deps 17 | sudo cabal-dev install --flags="embed_data_files" citeproc-hs 18 | sudo cabal-dev install --disable-library-for-ghci highlighting-kate 19 | sudo cabal-dev install --prefix=/usr/local --datasubdir=$BASE --docdir=/usr/local/doc/$BASE --flags="executable -library" 20 | sudo cabal-dev copy --destdir=$ROOT 21 | sudo chown -R $ME:staff $DIST 22 | 23 | gzip $ROOT/usr/local/share/man/man?/*.* 24 | # cabal gives man pages the wrong permissions 25 | chmod +r $ROOT/usr/local/share/man/man?/*.* 26 | 27 | echo Copying license... 28 | cp COPYING $RESOURCES/License.txt 29 | 30 | PACKAGEMAKER=/Developer/Applications/Utilities/PackageMaker.app/Contents/MacOS/PackageMaker 31 | 32 | echo Creating OSX package... 33 | 34 | $PACKAGEMAKER \ 35 | --root $ROOT \ 36 | --id net.johnmacfarlane.pandoc \ 37 | --resources $RESOURCES \ 38 | --version $VERSION \ 39 | --no-relocate \ 40 | --scripts $SCRIPTS \ 41 | --out $BASE.pkg 42 | 43 | echo Creating disk image... 44 | 45 | hdiutil create "$BASE.dmg" \ 46 | -format UDZO -ov \ 47 | -volname "pandoc $VERSION" \ 48 | -srcfolder $BASE.pkg 49 | hdiutil internet-enable "$BASE.dmg" 50 | 51 | -------------------------------------------------------------------------------- /epub.css: -------------------------------------------------------------------------------- 1 | /* This defines styles and classes used in the book */ 2 | body { margin-left: 5%; margin-right: 5%; margin-top: 5%; margin-bottom: 5%; text-align: justify; font-size: medium; } 3 | code { font-family: monospace; } 4 | h1 { text-align: center; } 5 | h2 { text-align: center; } 6 | h3 { text-align: center; } 7 | h4 { text-align: center; } 8 | h5 { text-align: center; } 9 | h6 { text-align: center; } 10 | h1.title { } 11 | h2.author { } 12 | h3.date { } 13 | /* For source-code highlighting */ 14 | table.sourceCode, tr.sourceCode, td.lineNumbers, td.sourceCode, table.sourceCode pre 15 | { margin: 0; padding: 0; border: 0; vertical-align: baseline; border: none; } 16 | td.lineNumbers { border-right: 1px solid #AAAAAA; text-align: right; color: #AAAAAA; padding-right: 5px; padding-left: 5px; } 17 | td.sourceCode { padding-left: 5px; } 18 | pre.sourceCode { } 19 | code.sourceCode span.kw { color: #007020; font-weight: bold; } 20 | code.sourceCode span.dt { color: #902000; } 21 | code.sourceCode span.dv { color: #40a070; } 22 | code.sourceCode span.bn { color: #40a070; } 23 | code.sourceCode span.fl { color: #40a070; } 24 | code.sourceCode span.ch { color: #4070a0; } 25 | code.sourceCode span.st { color: #4070a0; } 26 | code.sourceCode span.co { color: #60a0b0; font-style: italic; } 27 | code.sourceCode span.ot { color: #007020; } 28 | code.sourceCode span.al { color: red; font-weight: bold; } 29 | code.sourceCode span.fu { color: #06287e; } 30 | code.sourceCode span.re { } 31 | code.sourceCode span.er { color: red; font-weight: bold; } 32 | -------------------------------------------------------------------------------- /HCAR-Pandoc.tex: -------------------------------------------------------------------------------- 1 | % Pandoc-JP.tex 2 | \begin{hcarentry}{Pandoc} 3 | \label{pandoc} 4 | \report{John MacFarlane}%05/11 5 | \status{active development} 6 | \participants{Andrea Rossato, Peter Wang, Paulo Tanimoto, Eric Kow, 7 | Luke Plant, Justin Bogner, Paul Rivier, Nathan Gass, Puneeth Chaganti, 8 | Josef Svenningsson, Etienne Millon, Joost Kremers} 9 | \makeheader 10 | 11 | Pandoc aspires to be the swiss army knife of text markup formats: it 12 | can read markdown and (with some limitations) HTML, LaTeX, Textile, and 13 | reStructuredText, and it can write markdown, reStructuredText, HTML, 14 | DocBook XML, OpenDocument XML, ODT, RTF, groff man, MediaWiki markup, 15 | GNU Texinfo, LaTeX, ConTeXt, EPUB, Textile, Emacs org-mode, 16 | Slidy, and S5. Pandoc's markdown syntax includes extensions for LaTeX math, 17 | tables, definition lists, footnotes, and more. 18 | 19 | Since the last report, many new features have been added and improvements 20 | made. Some highlights: 21 | \begin{compactitem} 22 | \item Support for Textile input and output. 23 | \item Support for Emacs org-mode output. 24 | \item A new ``builder'' module for constructing Pandoc documents programatically. 25 | \item Support for \LaTeX math macros in markdown documents. 26 | \item Support for automatic citations and bibliographies using Andrea 27 | Rossato's citeproc-hs library. 28 | \end{compactitem} 29 | 30 | These last two changes bring two of the most powerful features of \LaTeX 31 | to pandoc. 32 | 33 | \FurtherReading 34 | \url{http://johnmacfarlane.net/pandoc/} 35 | \end{hcarentry} 36 | -------------------------------------------------------------------------------- /src/Tests/Writers/HTML.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE OverloadedStrings, QuasiQuotes #-} 2 | module Tests.Writers.HTML (tests) where 3 | 4 | import Test.Framework 5 | import Text.Pandoc.Builder 6 | import Text.Pandoc 7 | import Tests.Helpers 8 | import Tests.Arbitrary() 9 | import Text.Pandoc.Highlighting (languages) -- null if no hl support 10 | 11 | html :: (ToString a, ToPandoc a) => a -> String 12 | html = writeHtmlString defaultWriterOptions{ writerWrapText = False } . toPandoc 13 | 14 | {- 15 | "my test" =: X =?> Y 16 | 17 | is shorthand for 18 | 19 | test html "my test" $ X =?> Y 20 | 21 | which is in turn shorthand for 22 | 23 | test html "my test" (X,Y) 24 | -} 25 | 26 | infix 4 =: 27 | (=:) :: (ToString a, ToPandoc a) 28 | => String -> (a, String) -> Test 29 | (=:) = test html 30 | 31 | tests :: [Test] 32 | tests = [ testGroup "inline code" 33 | [ "basic" =: code "@&" =?> "@&" 34 | , "haskell" =: codeWith ("",["haskell"],[]) ">>=" 35 | =?> if null languages 36 | then ">>=" 37 | else ">>=" 38 | , "nolanguage" =: codeWith ("",["nolanguage"],[]) ">>=" 39 | =?> ">>=" 40 | ] 41 | , testGroup "images" 42 | [ "alt with formatting" =: 43 | image "/url" "title" ("my " <> emph "image") 44 | =?> "\"my" 45 | ] 46 | ] 47 | -------------------------------------------------------------------------------- /tests/MarkdownTest_1.0.3/Tests/Ordered and unordered lists.text: -------------------------------------------------------------------------------- 1 | ## Unordered 2 | 3 | Asterisks tight: 4 | 5 | * asterisk 1 6 | * asterisk 2 7 | * asterisk 3 8 | 9 | 10 | Asterisks loose: 11 | 12 | * asterisk 1 13 | 14 | * asterisk 2 15 | 16 | * asterisk 3 17 | 18 | * * * 19 | 20 | Pluses tight: 21 | 22 | + Plus 1 23 | + Plus 2 24 | + Plus 3 25 | 26 | 27 | Pluses loose: 28 | 29 | + Plus 1 30 | 31 | + Plus 2 32 | 33 | + Plus 3 34 | 35 | * * * 36 | 37 | 38 | Minuses tight: 39 | 40 | - Minus 1 41 | - Minus 2 42 | - Minus 3 43 | 44 | 45 | Minuses loose: 46 | 47 | - Minus 1 48 | 49 | - Minus 2 50 | 51 | - Minus 3 52 | 53 | 54 | ## Ordered 55 | 56 | Tight: 57 | 58 | 1. First 59 | 2. Second 60 | 3. Third 61 | 62 | and: 63 | 64 | 1. One 65 | 2. Two 66 | 3. Three 67 | 68 | 69 | Loose using tabs: 70 | 71 | 1. First 72 | 73 | 2. Second 74 | 75 | 3. Third 76 | 77 | and using spaces: 78 | 79 | 1. One 80 | 81 | 2. Two 82 | 83 | 3. Three 84 | 85 | Multiple paragraphs: 86 | 87 | 1. Item 1, graf one. 88 | 89 | Item 2. graf two. The quick brown fox jumped over the lazy dog's 90 | back. 91 | 92 | 2. Item 2. 93 | 94 | 3. Item 3. 95 | 96 | 97 | 98 | ## Nested 99 | 100 | * Tab 101 | * Tab 102 | * Tab 103 | 104 | Here's another: 105 | 106 | 1. First 107 | 2. Second: 108 | * Fee 109 | * Fie 110 | * Foe 111 | 3. Third 112 | 113 | Same thing but with paragraphs: 114 | 115 | 1. First 116 | 117 | 2. Second: 118 | * Fee 119 | * Fie 120 | * Foe 121 | 122 | 3. Third 123 | 124 | 125 | This was an error in Markdown 1.0.1: 126 | 127 | * this 128 | 129 | * sub 130 | 131 | that 132 | -------------------------------------------------------------------------------- /tests/markdown-citations.mhra.txt: -------------------------------------------------------------------------------- 1 | Pandoc with citeproc-hs 2 | ======================= 3 | 4 | - [@nonexistent] 5 | 6 | - @nonexistent 7 | 8 | - John Doe[^1] says blah. 9 | 10 | - Doe[^2] says blah. 11 | 12 | - Doe[^3] says blah. 13 | 14 | - Doe[^4] says blah. 15 | 16 | - In a note.[^5] 17 | 18 | - A citation group.[^6] 19 | 20 | - Another one.[^7] 21 | 22 | - And another one in a note.[^8] 23 | 24 | - Citation with a suffix and locator.[^9] 25 | 26 | - Citation with suffix only.[^10] 27 | 28 | - Now some modifiers.[^11] 29 | 30 | - With some markup.[^12] 31 | 32 | References 33 | ========== 34 | 35 | Doe, John, ‘Article’, *Journal of Generic Studies*, 6 (2006), 33–34. 36 | 37 | ---, *First Book* (Cambridge: Cambridge University Press, 2005). 38 | 39 | Doe, John, and Jenny Roe, ‘Why Water Is Wet’, in *Third Book*, ed. by Sam Smith (Oxford: Oxford University Press, 2007). 40 | 41 | [^1]: *First Book* (Cambridge: Cambridge University Press, 2005). 42 | 43 | [^2]: *First Book*, p. 30. 44 | 45 | [^3]: *First Book*, p. 30, with suffix. 46 | 47 | [^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). 48 | 49 | [^5]: A citation without locators Doe and Roe. 50 | 51 | [^6]: See Doe, *First Book*, chap. 3; also Doe and Roe, pp. 34–35. 52 | 53 | [^7]: See Doe, *First Book*, pp. 34–35. 54 | 55 | [^8]: Some citations see Doe, *First Book*, chap. 3; Doe and Roe; Doe, ‘Article’, 33–34. 56 | 57 | [^9]: Doe, *First Book*, pp. 33, 35–37, and nowhere else. 58 | 59 | [^10]: Doe, *First Book* and nowhere else. 60 | 61 | [^11]: Like a citation without author: *First Book*, and now Doe with a locator ‘Article’, 33–34 (p. 44). 62 | 63 | [^12]: *See* Doe, *First Book*, p. 32. 64 | -------------------------------------------------------------------------------- /tests/MarkdownTest_1.0.3/Tests/Backslash escapes.text: -------------------------------------------------------------------------------- 1 | These should all get escaped: 2 | 3 | Backslash: \\ 4 | 5 | Backtick: \` 6 | 7 | Asterisk: \* 8 | 9 | Underscore: \_ 10 | 11 | Left brace: \{ 12 | 13 | Right brace: \} 14 | 15 | Left bracket: \[ 16 | 17 | Right bracket: \] 18 | 19 | Left paren: \( 20 | 21 | Right paren: \) 22 | 23 | Greater-than: \> 24 | 25 | Hash: \# 26 | 27 | Period: \. 28 | 29 | Bang: \! 30 | 31 | Plus: \+ 32 | 33 | Minus: \- 34 | 35 | 36 | 37 | These should not, because they occur within a code block: 38 | 39 | Backslash: \\ 40 | 41 | Backtick: \` 42 | 43 | Asterisk: \* 44 | 45 | Underscore: \_ 46 | 47 | Left brace: \{ 48 | 49 | Right brace: \} 50 | 51 | Left bracket: \[ 52 | 53 | Right bracket: \] 54 | 55 | Left paren: \( 56 | 57 | Right paren: \) 58 | 59 | Greater-than: \> 60 | 61 | Hash: \# 62 | 63 | Period: \. 64 | 65 | Bang: \! 66 | 67 | Plus: \+ 68 | 69 | Minus: \- 70 | 71 | 72 | Nor should these, which occur in code spans: 73 | 74 | Backslash: `\\` 75 | 76 | Backtick: `` \` `` 77 | 78 | Asterisk: `\*` 79 | 80 | Underscore: `\_` 81 | 82 | Left brace: `\{` 83 | 84 | Right brace: `\}` 85 | 86 | Left bracket: `\[` 87 | 88 | Right bracket: `\]` 89 | 90 | Left paren: `\(` 91 | 92 | Right paren: `\)` 93 | 94 | Greater-than: `\>` 95 | 96 | Hash: `\#` 97 | 98 | Period: `\.` 99 | 100 | Bang: `\!` 101 | 102 | Plus: `\+` 103 | 104 | Minus: `\-` 105 | 106 | 107 | These should get escaped, even though they're matching pairs for 108 | other Markdown constructs: 109 | 110 | \*asterisks\* 111 | 112 | \_underscores\_ 113 | 114 | \`backticks\` 115 | 116 | This is a code span with a literal backslash-backtick sequence: `` \` `` 117 | 118 | This is a tag with unescaped backticks bar. 119 | 120 | This is a tag with backslashes bar. 121 | -------------------------------------------------------------------------------- /Benchmark.hs: -------------------------------------------------------------------------------- 1 | import Text.Pandoc 2 | import Text.Pandoc.Shared (readDataFile, normalize) 3 | import Criterion.Main 4 | import Data.List (isSuffixOf) 5 | import Text.JSON.Generic 6 | 7 | readerBench :: Pandoc 8 | -> (String, ParserState -> String -> Pandoc) 9 | -> Benchmark 10 | readerBench doc (name, reader) = 11 | let writer = case lookup name writers of 12 | Just w -> w 13 | Nothing -> error $ "Could not find writer for " ++ name 14 | inp = writer defaultWriterOptions{ writerWrapText = True 15 | , writerLiterateHaskell = 16 | "+lhs" `isSuffixOf` name } doc 17 | -- we compute the length to force full evaluation 18 | getLength (Pandoc (Meta a b c) d) = 19 | length a + length b + length c + length d 20 | in bench (name ++ " reader") $ whnf (getLength . 21 | reader defaultParserState{ stateSmart = True 22 | , stateStandalone = True 23 | , stateLiterateHaskell = 24 | "+lhs" `isSuffixOf` name }) inp 25 | 26 | writerBench :: Pandoc 27 | -> (String, WriterOptions -> Pandoc -> String) 28 | -> Benchmark 29 | writerBench doc (name, writer) = bench (name ++ " writer") $ nf 30 | (writer defaultWriterOptions{ 31 | writerWrapText = True 32 | , writerLiterateHaskell = "+lhs" `isSuffixOf` name }) doc 33 | 34 | normalizeBench :: Pandoc -> [Benchmark] 35 | normalizeBench doc = [ bench "normalize - with" $ nf (encodeJSON . normalize) doc 36 | , bench "normalize - without" $ nf encodeJSON doc 37 | ] 38 | 39 | main = do 40 | inp <- readDataFile (Just ".") "README" 41 | let ps = defaultParserState{ stateSmart = True } 42 | let doc = readMarkdown ps inp 43 | let readerBs = map (readerBench doc) readers 44 | defaultMain $ map (writerBench doc) writers ++ readerBs ++ normalizeBench doc 45 | 46 | -------------------------------------------------------------------------------- /src/Tests/Writers/ConTeXt.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE OverloadedStrings, QuasiQuotes #-} 2 | module Tests.Writers.ConTeXt (tests) where 3 | 4 | import Test.Framework 5 | import Text.Pandoc.Builder 6 | import Text.Pandoc 7 | import Tests.Helpers 8 | import Tests.Arbitrary() 9 | 10 | context :: (ToString a, ToPandoc a) => a -> String 11 | context = writeConTeXt defaultWriterOptions . toPandoc 12 | 13 | context' :: (ToString a, ToPandoc a) => a -> String 14 | context' = writeConTeXt defaultWriterOptions{ writerWrapText = False } 15 | . toPandoc 16 | 17 | {- 18 | "my test" =: X =?> Y 19 | 20 | is shorthand for 21 | 22 | test context "my test" $ X =?> Y 23 | 24 | which is in turn shorthand for 25 | 26 | test context "my test" (X,Y) 27 | -} 28 | 29 | infix 4 =: 30 | (=:) :: (ToString a, ToPandoc a) 31 | => String -> (a, String) -> Test 32 | (=:) = test context 33 | 34 | tests :: [Test] 35 | tests = [ testGroup "inline code" 36 | [ "with '}'" =: code "}" =?> "\\mono{\\letterclosebrace{}}" 37 | , "without '}'" =: code "]" =?> "\\type{]}" 38 | , property "code property" $ \s -> null s || 39 | if '{' `elem` s || '}' `elem` s 40 | then (context' $ code s) == "\\mono{" ++ 41 | (context' $ str s) ++ "}" 42 | else (context' $ code s) == "\\type{" ++ s ++ "}" 43 | ] 44 | , testGroup "headers" 45 | [ "level 1" =: 46 | header 1 "My header" =?> "\\section[my-header]{My header}" 47 | ] 48 | , testGroup "bullet lists" 49 | [ "nested" =: 50 | bulletList [plain (text "top") 51 | ,bulletList [plain (text "next") 52 | ,bulletList [plain (text "bot")]]] 53 | =?> [_LIT| 54 | \startitemize 55 | \item 56 | top 57 | \item 58 | \startitemize 59 | \item 60 | next 61 | \item 62 | \startitemize 63 | \item 64 | bot 65 | \stopitemize 66 | \stopitemize 67 | \stopitemize|] 68 | ] 69 | ] 70 | 71 | -------------------------------------------------------------------------------- /tests/s5.basic.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | My S5 Document 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 |
25 |
26 | 27 | 31 |
32 |
33 |
34 |

My S5 Document

35 |

Sam Smith
Jen Jones

36 |

July 15, 2006

37 |
38 |
39 |

First slide

40 |
    41 |
  • first bullet
  • 42 |
  • second bullet
  • 43 |
44 |
45 |
46 |

Math

47 |
    48 |
  • $\frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}$
  • 49 |
50 |
51 |
52 | 53 | 54 | -------------------------------------------------------------------------------- /tests/markdown-reader-more.txt: -------------------------------------------------------------------------------- 1 | % Title 2 | spanning multiple lines 3 | % Author One 4 | Author Two; Author Three; 5 | Author Four 6 | 7 | # Additional markdown reader tests 8 | 9 | ## Blank line before URL in link reference 10 | 11 | [foo] and [bar] 12 | 13 | [foo]: 14 | /url 15 | 16 | [bar]: 17 | /url 18 | "title" 19 | 20 | ## Raw ConTeXt environments 21 | 22 | \placeformula \startformula 23 | L_{1} = L_{2} 24 | \stopformula 25 | 26 | \start[a2] 27 | \start[a2] 28 | \stop[a2] 29 | \stop[a2] 30 | 31 | ## URLs with spaces 32 | 33 | [foo](/bar and baz) 34 | [foo](/bar 35 | and baz ) 36 | [foo]( /bar and baz ) 37 | [foo](bar baz "title" ) 38 | 39 | [baz][] [bam][] [bork][] 40 | 41 | [baz]: /foo foo 42 | [bam]: /foo fee 43 | [bork]: /foo/zee zob (title) 44 | 45 | ## Horizontal rules with spaces at end 46 | 47 | * * * * * 48 | 49 | -- - -- -- - 50 | 51 | ## Raw HTML before header 52 | 53 | 54 | 55 | ### my header 56 | 57 | ## $ in math 58 | 59 | $\$2 + \$3$ 60 | 61 | ## Commented-out list item 62 | 63 | - one 64 | 67 | - three 68 | 69 | ## Backslash newline 70 | 71 | hi\ 72 | there 73 | 74 | ## Code spans 75 | 76 | `hi\` 77 | 78 | `hi 79 | there` 80 | 81 | `` hi````there `` 82 | 83 | `hi 84 | 85 | there` 86 | 87 | ## Multilingual URLs 88 | 89 | 90 | 91 | [foo](/bar/测?x=测 "title") 92 | 93 | <测@foo.测.baz> 94 | 95 | ## Numbered examples 96 | 97 | (@) First example. 98 | (@foo) Second example. 99 | 100 | Explanation of examples (@foo) and (@bar). 101 | 102 | (@bar) Third example. 103 | 104 | ## Macros 105 | 106 | \newcommand{\tuple}[1]{\langle #1 \rangle} 107 | 108 | $\tuple{x,y}$ 109 | 110 | ## Case-insensitive references 111 | 112 | [Fum] 113 | 114 | [FUM] 115 | 116 | [bat] 117 | 118 | [fum]: /fum 119 | [BAT]: /bat 120 | 121 | ## Curly smart quotes 122 | 123 | “Hi” 124 | 125 | ‘Hi’ 126 | 127 | ## Consecutive lists 128 | 129 | - one 130 | - two 131 | 1. one 132 | 2. two 133 | 134 | a. one 135 | b. two 136 | -------------------------------------------------------------------------------- /tests/lhs-test.latex+lhs: -------------------------------------------------------------------------------- 1 | \documentclass[]{article} 2 | \usepackage{amssymb,amsmath} 3 | \usepackage{ifxetex,ifluatex} 4 | \ifxetex 5 | \usepackage{fontspec,xltxtra,xunicode} 6 | \defaultfontfeatures{Mapping=tex-text,Scale=MatchLowercase} 7 | \newcommand{\euro}{€} 8 | \else 9 | \ifluatex 10 | \usepackage{fontspec} 11 | \defaultfontfeatures{Mapping=tex-text,Scale=MatchLowercase} 12 | \newcommand{\euro}{€} 13 | \else 14 | \usepackage[utf8]{inputenc} 15 | \fi 16 | \fi 17 | \usepackage{listings} 18 | \lstnewenvironment{code}{\lstset{language=Haskell,basicstyle=\small\ttfamily}}{} 19 | \ifxetex 20 | \usepackage[setpagesize=false, % page size defined by xetex 21 | unicode=false, % unicode breaks when used with xetex 22 | xetex, 23 | bookmarks=true, 24 | pdfauthor={}, 25 | pdftitle={}, 26 | colorlinks=true, 27 | linkcolor=blue]{hyperref} 28 | \else 29 | \usepackage[unicode=true, 30 | bookmarks=true, 31 | pdfauthor={}, 32 | pdftitle={}, 33 | colorlinks=true, 34 | linkcolor=blue]{hyperref} 35 | \fi 36 | \hypersetup{breaklinks=true, pdfborder={0 0 0}} 37 | \setlength{\parindent}{0pt} 38 | \setlength{\parskip}{6pt plus 2pt minus 1pt} 39 | \setlength{\emergencystretch}{3em} % prevent overfull lines 40 | \setcounter{secnumdepth}{0} 41 | 42 | 43 | \begin{document} 44 | 45 | \section{lhs test} 46 | 47 | \texttt{unsplit} is an arrow that takes a pair of values and combines them to 48 | return a single value: 49 | 50 | \begin{code} 51 | unsplit :: (Arrow a) => (b -> c -> d) -> a (b, c) d 52 | unsplit = arr . uncurry 53 | -- arr (\op (x,y) -> x `op` y) 54 | \end{code} 55 | \texttt{(***)} combines two arrows into a new arrow by running the two arrows 56 | on a pair of values (one arrow on the first item of the pair and one arrow on 57 | the second item of the pair). 58 | 59 | \begin{verbatim} 60 | f *** g = first f >>> second g 61 | \end{verbatim} 62 | Block quote: 63 | 64 | \begin{quote} 65 | foo bar 66 | 67 | \end{quote} 68 | 69 | \end{document} 70 | -------------------------------------------------------------------------------- /tests/lhs-test.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 27 | 28 | 29 |

lhs test

30 |

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

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

(***) 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).

35 |
f *** g = first f >>> second g
36 |

Block quote:

37 |
38 |

foo bar

39 |
40 | 41 | 42 | -------------------------------------------------------------------------------- /tests/MarkdownTest_1.0.3/Tests/Backslash escapes.html: -------------------------------------------------------------------------------- 1 |

These should all get escaped:

2 | 3 |

Backslash: \

4 | 5 |

Backtick: `

6 | 7 |

Asterisk: *

8 | 9 |

Underscore: _

10 | 11 |

Left brace: {

12 | 13 |

Right brace: }

14 | 15 |

Left bracket: [

16 | 17 |

Right bracket: ]

18 | 19 |

Left paren: (

20 | 21 |

Right paren: )

22 | 23 |

Greater-than: >

24 | 25 |

Hash: #

26 | 27 |

Period: .

28 | 29 |

Bang: !

30 | 31 |

Plus: +

32 | 33 |

Minus: -

34 | 35 |

These should not, because they occur within a code block:

36 | 37 |
Backslash: \\
 38 | 
 39 | Backtick: \`
 40 | 
 41 | Asterisk: \*
 42 | 
 43 | Underscore: \_
 44 | 
 45 | Left brace: \{
 46 | 
 47 | Right brace: \}
 48 | 
 49 | Left bracket: \[
 50 | 
 51 | Right bracket: \]
 52 | 
 53 | Left paren: \(
 54 | 
 55 | Right paren: \)
 56 | 
 57 | Greater-than: \>
 58 | 
 59 | Hash: \#
 60 | 
 61 | Period: \.
 62 | 
 63 | Bang: \!
 64 | 
 65 | Plus: \+
 66 | 
 67 | Minus: \-
 68 | 
69 | 70 |

Nor should these, which occur in code spans:

71 | 72 |

Backslash: \\

73 | 74 |

Backtick: \`

75 | 76 |

Asterisk: \*

77 | 78 |

Underscore: \_

79 | 80 |

Left brace: \{

81 | 82 |

Right brace: \}

83 | 84 |

Left bracket: \[

85 | 86 |

Right bracket: \]

87 | 88 |

Left paren: \(

89 | 90 |

Right paren: \)

91 | 92 |

Greater-than: \>

93 | 94 |

Hash: \#

95 | 96 |

Period: \.

97 | 98 |

Bang: \!

99 | 100 |

Plus: \+

101 | 102 |

Minus: \-

103 | 104 | 105 |

These should get escaped, even though they're matching pairs for 106 | other Markdown constructs:

107 | 108 |

*asterisks*

109 | 110 |

_underscores_

111 | 112 |

`backticks`

113 | 114 |

This is a code span with a literal backslash-backtick sequence: \`

115 | 116 |

This is a tag with unescaped backticks bar.

117 | 118 |

This is a tag with backslashes bar.

119 | -------------------------------------------------------------------------------- /tests/lhs-test.html+lhs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 27 | 28 | 29 |

lhs test

30 |

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

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

(***) 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).

35 |
f *** g = first f >>> second g
36 |

Block quote:

37 |
38 |

foo bar

39 |
40 | 41 | 42 | -------------------------------------------------------------------------------- /tests/tables.org: -------------------------------------------------------------------------------- 1 | Simple table with caption: 2 | 3 | | Right | Left | Center | Default | 4 | |---------+--------+----------+-----------| 5 | | 12 | 12 | 12 | 12 | 6 | | 123 | 123 | 123 | 123 | 7 | | 1 | 1 | 1 | 1 | 8 | #+CAPTION: Demonstration of simple table syntax. 9 | 10 | Simple table without caption: 11 | 12 | | Right | Left | Center | Default | 13 | |---------+--------+----------+-----------| 14 | | 12 | 12 | 12 | 12 | 15 | | 123 | 123 | 123 | 123 | 16 | | 1 | 1 | 1 | 1 | 17 | 18 | Simple table indented two spaces: 19 | 20 | | Right | Left | Center | Default | 21 | |---------+--------+----------+-----------| 22 | | 12 | 12 | 12 | 12 | 23 | | 123 | 123 | 123 | 123 | 24 | | 1 | 1 | 1 | 1 | 25 | #+CAPTION: Demonstration of simple table syntax. 26 | 27 | Multiline table with caption: 28 | 29 | | Centered Header | Left Aligned | Right Aligned | Default aligned | 30 | |-------------------+----------------+-----------------+---------------------------------------------------------| 31 | | First | row | 12.0 | Example of a row that spans multiple lines. | 32 | | Second | row | 5.0 | Here's another one. Note the blank line between rows. | 33 | #+CAPTION: Here's the caption. It may span multiple lines. 34 | 35 | Multiline table without caption: 36 | 37 | | Centered Header | Left Aligned | Right Aligned | Default aligned | 38 | |-------------------+----------------+-----------------+---------------------------------------------------------| 39 | | First | row | 12.0 | Example of a row that spans multiple lines. | 40 | | Second | row | 5.0 | Here's another one. Note the blank line between rows. | 41 | 42 | Table without column headers: 43 | 44 | | 12 | 12 | 12 | 12 | 45 | | 123 | 123 | 123 | 123 | 46 | | 1 | 1 | 1 | 1 | 47 | 48 | Multiline table without column headers: 49 | 50 | | First | row | 12.0 | Example of a row that spans multiple lines. | 51 | | Second | row | 5.0 | Here's another one. Note the blank line between rows. | 52 | 53 | -------------------------------------------------------------------------------- /tests/tables.asciidoc: -------------------------------------------------------------------------------- 1 | Simple table with caption: 2 | 3 | .Demonstration of simple table syntax. 4 | [cols=">,<,^,",options="header",] 5 | |============================ 6 | |Right |Left |Center |Default 7 | |12 |12 |12 |12 8 | |123 |123 |123 |123 9 | |1 |1 |1 |1 10 | |============================ 11 | 12 | Simple table without caption: 13 | 14 | [cols=">,<,^,",options="header",] 15 | |============================ 16 | |Right |Left |Center |Default 17 | |12 |12 |12 |12 18 | |123 |123 |123 |123 19 | |1 |1 |1 |1 20 | |============================ 21 | 22 | Simple table indented two spaces: 23 | 24 | .Demonstration of simple table syntax. 25 | [cols=">,<,^,",options="header",] 26 | |============================ 27 | |Right |Left |Center |Default 28 | |12 |12 |12 |12 29 | |123 |123 |123 |123 30 | |1 |1 |1 |1 31 | |============================ 32 | 33 | Multiline table with caption: 34 | 35 | .Here's the caption. It may span multiple lines. 36 | [width="78%",cols="^21%,<17%,>20%,<42%",options="header",] 37 | |======================================================================= 38 | |Centered Header |Left Aligned |Right Aligned |Default aligned 39 | |First |row |12.0 |Example of a row that spans multiple lines. 40 | |Second |row |5.0 |Here's another one. Note the blank line between rows. 41 | |======================================================================= 42 | 43 | Multiline table without caption: 44 | 45 | [width="78%",cols="^21%,<17%,>20%,<42%",options="header",] 46 | |======================================================================= 47 | |Centered Header |Left Aligned |Right Aligned |Default aligned 48 | |First |row |12.0 |Example of a row that spans multiple lines. 49 | |Second |row |5.0 |Here's another one. Note the blank line between rows. 50 | |======================================================================= 51 | 52 | Table without column headers: 53 | 54 | [cols=">,<,^,>",] 55 | |============================================================================= 56 | |12 |12 |12 |12 57 | 58 | |123 |123 |123 |123 59 | 60 | |1 |1 |1 |1 61 | |============================================================================= 62 | 63 | Multiline table without column headers: 64 | 65 | [width="78%",cols="^21%,<17%,>20%,42%",] 66 | |============================================================================= 67 | |First |row |12.0 |Example of a row that spans multiple lines. 68 | 69 | |Second |row |5.0 |Here's another one. Note the blank line between rows. 70 | |============================================================================= 71 | 72 | -------------------------------------------------------------------------------- /src/Text/Pandoc/Slides.hs: -------------------------------------------------------------------------------- 1 | {- 2 | Copyright (C) 2012 John MacFarlane 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, write to the Free Software 16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | -} 18 | 19 | {- | 20 | Module : Text.Pandoc.Slides 21 | Copyright : Copyright (C) 2012 John MacFarlane 22 | License : GNU GPL, version 2 or above 23 | 24 | Maintainer : John MacFarlane 25 | Stability : alpha 26 | Portability : portable 27 | 28 | Utility functions for splitting documents into slides for slide 29 | show formats (dzslides, s5, slidy, beamer). 30 | -} 31 | module Text.Pandoc.Slides ( getSlideLevel, prepSlides ) where 32 | import Text.Pandoc.Definition 33 | 34 | -- | Find level of header that starts slides (defined as the least header 35 | -- level that occurs before a non-header/non-hrule in the blocks). 36 | getSlideLevel :: [Block] -> Int 37 | getSlideLevel = go 6 38 | where go least (Header n _ : x : xs) 39 | | n < least && nonHOrHR x = go n xs 40 | | otherwise = go least (x:xs) 41 | go least (_ : xs) = go least xs 42 | go least [] = least 43 | nonHOrHR (Header _ _) = False 44 | nonHOrHR (HorizontalRule) = False 45 | nonHOrHR _ = True 46 | 47 | -- | Prepare a block list to be passed to hierarchicalize. 48 | prepSlides :: Int -> [Block] -> [Block] 49 | prepSlides slideLevel = ensureStartWithH . splitHrule 50 | where splitHrule (HorizontalRule : Header n xs : ys) 51 | | n == slideLevel = Header slideLevel xs : splitHrule ys 52 | splitHrule (HorizontalRule : xs) = Header slideLevel [] : splitHrule xs 53 | splitHrule (x : xs) = x : splitHrule xs 54 | splitHrule [] = [] 55 | ensureStartWithH bs@(Header n _:_) 56 | | n <= slideLevel = bs 57 | ensureStartWithH bs = Header slideLevel [] : bs 58 | -------------------------------------------------------------------------------- /tests/MarkdownTest_1.0.3/Tests/Ordered and unordered lists.html: -------------------------------------------------------------------------------- 1 |

Unordered

2 | 3 |

Asterisks tight:

4 | 5 |
    6 |
  • asterisk 1
  • 7 |
  • asterisk 2
  • 8 |
  • asterisk 3
  • 9 |
10 | 11 |

Asterisks loose:

12 | 13 |
    14 |
  • asterisk 1

  • 15 |
  • asterisk 2

  • 16 |
  • asterisk 3

  • 17 |
18 | 19 |
20 | 21 |

Pluses tight:

22 | 23 |
    24 |
  • Plus 1
  • 25 |
  • Plus 2
  • 26 |
  • Plus 3
  • 27 |
28 | 29 |

Pluses loose:

30 | 31 |
    32 |
  • Plus 1

  • 33 |
  • Plus 2

  • 34 |
  • Plus 3

  • 35 |
36 | 37 |
38 | 39 |

Minuses tight:

40 | 41 |
    42 |
  • Minus 1
  • 43 |
  • Minus 2
  • 44 |
  • Minus 3
  • 45 |
46 | 47 |

Minuses loose:

48 | 49 |
    50 |
  • Minus 1

  • 51 |
  • Minus 2

  • 52 |
  • Minus 3

  • 53 |
54 | 55 |

Ordered

56 | 57 |

Tight:

58 | 59 |
    60 |
  1. First
  2. 61 |
  3. Second
  4. 62 |
  5. Third
  6. 63 |
64 | 65 |

and:

66 | 67 |
    68 |
  1. One
  2. 69 |
  3. Two
  4. 70 |
  5. Three
  6. 71 |
72 | 73 |

Loose using tabs:

74 | 75 |
    76 |
  1. First

  2. 77 |
  3. Second

  4. 78 |
  5. Third

  6. 79 |
80 | 81 |

and using spaces:

82 | 83 |
    84 |
  1. One

  2. 85 |
  3. Two

  4. 86 |
  5. Three

  6. 87 |
88 | 89 |

Multiple paragraphs:

90 | 91 |
    92 |
  1. Item 1, graf one.

    93 | 94 |

    Item 2. graf two. The quick brown fox jumped over the lazy dog's 95 | back.

  2. 96 |
  3. Item 2.

  4. 97 |
  5. Item 3.

  6. 98 |
99 | 100 |

Nested

101 | 102 |
    103 |
  • Tab 104 |
      105 |
    • Tab 106 |
        107 |
      • Tab
      • 108 |
    • 109 |
  • 110 |
111 | 112 |

Here's another:

113 | 114 |
    115 |
  1. First
  2. 116 |
  3. Second: 117 |
      118 |
    • Fee
    • 119 |
    • Fie
    • 120 |
    • Foe
    • 121 |
  4. 122 |
  5. Third
  6. 123 |
124 | 125 |

Same thing but with paragraphs:

126 | 127 |
    128 |
  1. First

  2. 129 |
  3. Second:

    130 | 131 |
      132 |
    • Fee
    • 133 |
    • Fie
    • 134 |
    • Foe
    • 135 |
  4. 136 |
  5. Third

  6. 137 |
138 | 139 | 140 |

This was an error in Markdown 1.0.1:

141 | 142 |
    143 |
  • this

    144 | 145 |
    • sub
    146 | 147 |

    that

  • 148 |
149 | -------------------------------------------------------------------------------- /src/Text/Pandoc/UUID.hs: -------------------------------------------------------------------------------- 1 | {- 2 | Copyright (C) 2010 John MacFarlane 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, write to the Free Software 16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | -} 18 | 19 | {- | 20 | Module : Text.Pandoc.UUID 21 | Copyright : Copyright (C) 2010 John MacFarlane 22 | License : GNU GPL, version 2 or above 23 | 24 | Maintainer : John MacFarlane 25 | Stability : alpha 26 | Portability : portable 27 | 28 | UUID generation using Version 4 (random method) described 29 | in RFC4122. See http://tools.ietf.org/html/rfc4122 30 | -} 31 | 32 | module Text.Pandoc.UUID ( UUID, getRandomUUID ) where 33 | 34 | import Text.Printf ( printf ) 35 | import System.Random ( randomIO ) 36 | import Data.Word 37 | import Data.Bits ( setBit, clearBit ) 38 | import Control.Monad ( liftM ) 39 | 40 | data UUID = UUID Word8 Word8 Word8 Word8 Word8 Word8 Word8 Word8 41 | Word8 Word8 Word8 Word8 Word8 Word8 Word8 Word8 42 | 43 | instance Show UUID where 44 | show (UUID a b c d e f g h i j k l m n o p) = 45 | "urn:uuid:" ++ 46 | printf "%02x" a ++ 47 | printf "%02x" b ++ 48 | printf "%02x" c ++ 49 | printf "%02x" d ++ 50 | "-" ++ 51 | printf "%02x" e ++ 52 | printf "%02x" f ++ 53 | "-" ++ 54 | printf "%02x" g ++ 55 | printf "%02x" h ++ 56 | "-" ++ 57 | printf "%02x" i ++ 58 | printf "%02x" j ++ 59 | "-" ++ 60 | printf "%02x" k ++ 61 | printf "%02x" l ++ 62 | printf "%02x" m ++ 63 | printf "%02x" n ++ 64 | printf "%02x" o ++ 65 | printf "%02x" p 66 | 67 | getRandomUUID :: IO UUID 68 | getRandomUUID = do 69 | let getRN :: a -> IO Word8 70 | getRN _ = liftM fromIntegral (randomIO :: IO Int) 71 | [a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p] <- mapM getRN ([1..16] :: [Int]) 72 | -- set variant 73 | let i' = i `setBit` 7 `clearBit` 6 74 | -- set version (0100 for random) 75 | let g' = g `clearBit` 7 `setBit` 6 `clearBit` 5 `clearBit` 4 76 | return $ UUID a b c d e f g' h i' j k l m n o p 77 | 78 | -------------------------------------------------------------------------------- /src/Tests/Readers/RST.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE OverloadedStrings, QuasiQuotes #-} 2 | module Tests.Readers.RST (tests) where 3 | 4 | import Text.Pandoc.Definition 5 | import Test.Framework 6 | import Tests.Helpers 7 | import Tests.Arbitrary() 8 | import Text.Pandoc.Builder 9 | import Text.Pandoc 10 | 11 | rst :: String -> Pandoc 12 | rst = readRST defaultParserState{ stateStandalone = True } 13 | 14 | infix 4 =: 15 | (=:) :: ToString c 16 | => String -> (String, c) -> Test 17 | (=:) = test rst 18 | 19 | tests :: [Test] 20 | tests = [ "line block with blank line" =: 21 | "| a\n|\n| b" =?> para (str "a" <> linebreak <> 22 | linebreak <> str " " <> str "b") 23 | , "field list" =: 24 | [_LIT| 25 | :Hostname: media08 26 | :IP address: 10.0.0.19 27 | :Size: 3ru 28 | :Date: 2001-08-16 29 | :Version: 1 30 | :Authors: - Me 31 | - Myself 32 | - I 33 | :Indentation: Since the field marker may be quite long, the second 34 | and subsequent lines of the field body do not have to line up 35 | with the first line, but they must be indented relative to the 36 | field name marker, and they must line up with each other. 37 | :Parameter i: integer 38 | :Final: item 39 | on two lines 40 | |] =?> ( setAuthors ["Me","Myself","I"] 41 | $ setDate "2001-08-16" 42 | $ doc 43 | $ definitionList [ (str "Hostname", [para "media08"]) 44 | , (str "IP address", [para "10.0.0.19"]) 45 | , (str "Size", [para "3ru"]) 46 | , (str "Version", [para "1"]) 47 | , (str "Indentation", [para "Since the field marker may be quite long, the second and subsequent lines of the field body do not have to line up with the first line, but they must be indented relative to the field name marker, and they must line up with each other."]) 48 | , (str "Parameter i", [para "integer"]) 49 | , (str "Final", [para "item on two lines"]) 50 | ]) 51 | , "URLs with following punctuation" =: 52 | ("http://google.com, http://yahoo.com; http://foo.bar.baz.\n" ++ 53 | "http://foo.bar/baz_(bam) (http://foo.bar)") =?> 54 | para (link "http://google.com" "" "http://google.com" <> ", " <> 55 | link "http://yahoo.com" "" "http://yahoo.com" <> "; " <> 56 | link "http://foo.bar.baz" "" "http://foo.bar.baz" <> ". " <> 57 | link "http://foo.bar/baz_(bam)" "" "http://foo.bar/baz_(bam)" 58 | <> " (" <> link "http://foo.bar" "" "http://foo.bar" <> ")") 59 | ] 60 | 61 | -------------------------------------------------------------------------------- /windows/pcre-license.txt: -------------------------------------------------------------------------------- 1 | PCRE LICENCE 2 | ------------ 3 | 4 | PCRE is a library of functions to support regular expressions whose syntax 5 | and semantics are as close as possible to those of the Perl 5 language. 6 | 7 | Release 8 of PCRE is distributed under the terms of the "BSD" licence, as 8 | specified below. The documentation for PCRE, supplied in the "doc" 9 | directory, is distributed under the same terms as the software itself. 10 | 11 | The basic library functions are written in C and are freestanding. Also 12 | included in the distribution is a set of C++ wrapper functions. 13 | 14 | 15 | THE BASIC LIBRARY FUNCTIONS 16 | --------------------------- 17 | 18 | Written by: Philip Hazel 19 | Email local part: ph10 20 | Email domain: cam.ac.uk 21 | 22 | University of Cambridge Computing Service, 23 | Cambridge, England. 24 | 25 | Copyright (c) 1997-2009 University of Cambridge 26 | All rights reserved. 27 | 28 | 29 | THE C++ WRAPPER FUNCTIONS 30 | ------------------------- 31 | 32 | Contributed by: Google Inc. 33 | 34 | Copyright (c) 2007-2008, Google Inc. 35 | All rights reserved. 36 | 37 | 38 | THE "BSD" LICENCE 39 | ----------------- 40 | 41 | Redistribution and use in source and binary forms, with or without 42 | modification, are permitted provided that the following conditions are met: 43 | 44 | * Redistributions of source code must retain the above copyright notice, 45 | this list of conditions and the following disclaimer. 46 | 47 | * Redistributions in binary form must reproduce the above copyright 48 | notice, this list of conditions and the following disclaimer in the 49 | documentation and/or other materials provided with the distribution. 50 | 51 | * Neither the name of the University of Cambridge nor the name of Google 52 | Inc. nor the names of their contributors may be used to endorse or 53 | promote products derived from this software without specific prior 54 | written permission. 55 | 56 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 57 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 58 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 59 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 60 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 61 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 62 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 63 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 64 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 65 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 66 | POSSIBILITY OF SUCH DAMAGE. 67 | 68 | End 69 | -------------------------------------------------------------------------------- /src/Text/Pandoc/Readers/Native.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE CPP #-} 2 | #if __GLASGOW_HASKELL__ >= 702 3 | {-# LANGUAGE Trustworthy #-} 4 | #endif 5 | {- 6 | Copyright (C) 2011 John MacFarlane 7 | 8 | This program is free software; you can redistribute it and/or modify 9 | it under the terms of the GNU General Public License as published by 10 | the Free Software Foundation; either version 2 of the License, or 11 | (at your option) any later version. 12 | 13 | This program is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU General Public License for more details. 17 | 18 | You should have received a copy of the GNU General Public License 19 | along with this program; if not, write to the Free Software 20 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 | -} 22 | 23 | {- | 24 | Module : Text.Pandoc.Readers.Native 25 | Copyright : Copyright (C) 2011 John MacFarlane 26 | License : GNU GPL, version 2 or above 27 | 28 | Maintainer : John MacFarlane 29 | Stability : alpha 30 | Portability : portable 31 | 32 | Conversion of a string representation of a pandoc type (@Pandoc@, 33 | @[Block]@, @Block@, @[Inline]@, or @Inline@) to a @Pandoc@ document. 34 | -} 35 | module Text.Pandoc.Readers.Native ( readNative ) where 36 | 37 | import Text.Pandoc.Definition 38 | 39 | nullMeta :: Meta 40 | nullMeta = Meta{ docTitle = [] 41 | , docAuthors = [] 42 | , docDate = [] 43 | } 44 | 45 | -- | Read native formatted text and return a Pandoc document. 46 | -- The input may be a full pandoc document, a block list, a block, 47 | -- an inline list, or an inline. Thus, for example, 48 | -- 49 | -- > Str "hi" 50 | -- 51 | -- will be treated as if it were 52 | -- 53 | -- > Pandoc (Meta [] [] []) [Plain [Str "hi"]] 54 | -- 55 | readNative :: String -- ^ String to parse (assuming @'\n'@ line endings) 56 | -> Pandoc 57 | readNative s = 58 | case reads s of 59 | (d,_):_ -> d 60 | [] -> Pandoc nullMeta $ readBlocks s 61 | 62 | readBlocks :: String -> [Block] 63 | readBlocks s = 64 | case reads s of 65 | (d,_):_ -> d 66 | [] -> [readBlock s] 67 | 68 | readBlock :: String -> Block 69 | readBlock s = 70 | case reads s of 71 | (d,_):_ -> d 72 | [] -> Plain $ readInlines s 73 | 74 | readInlines :: String -> [Inline] 75 | readInlines s = 76 | case reads s of 77 | (d,_):_ -> d 78 | [] -> [readInline s] 79 | 80 | readInline :: String -> Inline 81 | readInline s = 82 | case reads s of 83 | (d,_):_ -> d 84 | [] -> error "Cannot parse document" 85 | 86 | -------------------------------------------------------------------------------- /data/MathMLinHTML.js: -------------------------------------------------------------------------------- 1 | /* 2 | March 19, 2004 MathHTML (c) Peter Jipsen http://www.chapman.edu/~jipsen 3 | Released under the GNU General Public License version 2 or later. 4 | See the GNU General Public License (at http://www.gnu.org/copyleft/gpl.html) 5 | for more details. 6 | */ 7 | 8 | function convertMath(node) {// for Gecko 9 | if (node.nodeType==1) { 10 | var newnode = 11 | document.createElementNS("http://www.w3.org/1998/Math/MathML", 12 | node.nodeName.toLowerCase()); 13 | for(var i=0; i < node.attributes.length; i++) 14 | newnode.setAttribute(node.attributes[i].nodeName, 15 | node.attributes[i].nodeValue); 16 | for (var i=0; i"); 63 | document.write(""); 64 | } 65 | if(typeof window.addEventListener != 'undefined'){ 66 | window.addEventListener('load', convert, false); 67 | } 68 | if(typeof window.attachEvent != 'undefined') { 69 | window.attachEvent('onload', convert); 70 | } 71 | -------------------------------------------------------------------------------- /tests/tables.plain: -------------------------------------------------------------------------------- 1 | Simple table with caption: 2 | 3 | Right Left Center Default 4 | ------- ------ -------- --------- 5 | 12 12 12 12 6 | 123 123 123 123 7 | 1 1 1 1 8 | 9 | : Demonstration of simple table syntax. 10 | 11 | Simple table without caption: 12 | 13 | Right Left Center Default 14 | ------- ------ -------- --------- 15 | 12 12 12 12 16 | 123 123 123 123 17 | 1 1 1 1 18 | 19 | Simple table indented two spaces: 20 | 21 | Right Left Center Default 22 | ------- ------ -------- --------- 23 | 12 12 12 12 24 | 123 123 123 123 25 | 1 1 1 1 26 | 27 | : Demonstration of simple table syntax. 28 | 29 | Multiline table with caption: 30 | 31 | -------------------------------------------------------------- 32 | Centered Left Right Default aligned 33 | Header Aligned Aligned 34 | ----------- ---------- ------------ -------------------------- 35 | First row 12.0 Example of a row that 36 | spans multiple lines. 37 | 38 | Second row 5.0 Here's another one. Note 39 | the blank line between 40 | rows. 41 | -------------------------------------------------------------- 42 | 43 | : Here's the caption. It may span multiple lines. 44 | 45 | Multiline table without caption: 46 | 47 | -------------------------------------------------------------- 48 | Centered Left Right Default aligned 49 | Header Aligned Aligned 50 | ----------- ---------- ------------ -------------------------- 51 | First row 12.0 Example of a row that 52 | spans multiple lines. 53 | 54 | Second row 5.0 Here's another one. Note 55 | the blank line between 56 | rows. 57 | -------------------------------------------------------------- 58 | 59 | Table without column headers: 60 | 61 | ----- ----- ----- ----- 62 | 12 12 12 12 63 | 123 123 123 123 64 | 1 1 1 1 65 | ----- ----- ----- ----- 66 | 67 | Multiline table without column headers: 68 | 69 | ----------- ---------- ------------ -------------------------- 70 | First row 12.0 Example of a row that 71 | spans multiple lines. 72 | 73 | Second row 5.0 Here's another one. Note 74 | the blank line between 75 | rows. 76 | ----------- ---------- ------------ -------------------------- 77 | 78 | 79 | -------------------------------------------------------------------------------- /tests/tables.markdown: -------------------------------------------------------------------------------- 1 | Simple table with caption: 2 | 3 | Right Left Center Default 4 | ------- ------ -------- --------- 5 | 12 12 12 12 6 | 123 123 123 123 7 | 1 1 1 1 8 | 9 | : Demonstration of simple table syntax. 10 | 11 | Simple table without caption: 12 | 13 | Right Left Center Default 14 | ------- ------ -------- --------- 15 | 12 12 12 12 16 | 123 123 123 123 17 | 1 1 1 1 18 | 19 | Simple table indented two spaces: 20 | 21 | Right Left Center Default 22 | ------- ------ -------- --------- 23 | 12 12 12 12 24 | 123 123 123 123 25 | 1 1 1 1 26 | 27 | : Demonstration of simple table syntax. 28 | 29 | Multiline table with caption: 30 | 31 | -------------------------------------------------------------- 32 | Centered Left Right Default aligned 33 | Header Aligned Aligned 34 | ----------- ---------- ------------ -------------------------- 35 | First row 12.0 Example of a row that 36 | spans multiple lines. 37 | 38 | Second row 5.0 Here's another one. Note 39 | the blank line between 40 | rows. 41 | -------------------------------------------------------------- 42 | 43 | : Here's the caption. It may span multiple lines. 44 | 45 | Multiline table without caption: 46 | 47 | -------------------------------------------------------------- 48 | Centered Left Right Default aligned 49 | Header Aligned Aligned 50 | ----------- ---------- ------------ -------------------------- 51 | First row 12.0 Example of a row that 52 | spans multiple lines. 53 | 54 | Second row 5.0 Here's another one. Note 55 | the blank line between 56 | rows. 57 | -------------------------------------------------------------- 58 | 59 | Table without column headers: 60 | 61 | ----- ----- ----- ----- 62 | 12 12 12 12 63 | 123 123 123 123 64 | 1 1 1 1 65 | ----- ----- ----- ----- 66 | 67 | Multiline table without column headers: 68 | 69 | ----------- ---------- ------------ -------------------------- 70 | First row 12.0 Example of a row that 71 | spans multiple lines. 72 | 73 | Second row 5.0 Here's another one. Note 74 | the blank line between 75 | rows. 76 | ----------- ---------- ------------ -------------------------- 77 | 78 | 79 | -------------------------------------------------------------------------------- /tests/tables.txt: -------------------------------------------------------------------------------- 1 | Simple table with caption: 2 | 3 | Right Left Center Default 4 | ------- ------ ---------- ------- 5 | 12 12 12 12 6 | 123 123 123 123 7 | 1 1 1 1 8 | 9 | Table: Demonstration of simple table syntax. 10 | 11 | Simple table without caption: 12 | 13 | Right Left Center Default 14 | ------- ------ ---------- ------- 15 | 12 12 12 12 16 | 123 123 123 123 17 | 1 1 1 1 18 | 19 | Simple table indented two spaces: 20 | 21 | Right Left Center Default 22 | ------- ------ ---------- ------- 23 | 12 12 12 12 24 | 123 123 123 123 25 | 1 1 1 1 26 | 27 | : Demonstration of simple table syntax. 28 | 29 | Multiline table with caption: 30 | 31 | : Here's the caption. 32 | It may span multiple lines. 33 | 34 | --------------------------------------------------------------- 35 | Centered Left Right 36 | Header Aligned Aligned Default aligned 37 | ---------- --------- ----------- --------------------------- 38 | First row 12.0 Example of a row that spans 39 | multiple lines. 40 | 41 | Second row 5.0 Here's another one. Note 42 | the blank line between rows. 43 | --------------------------------------------------------------- 44 | 45 | Multiline table without caption: 46 | 47 | --------------------------------------------------------------- 48 | Centered Left Right 49 | Header Aligned Aligned Default aligned 50 | ---------- --------- ----------- --------------------------- 51 | First row 12.0 Example of a row that spans 52 | multiple lines. 53 | 54 | Second row 5.0 Here's another one. Note 55 | the blank line between rows. 56 | --------------------------------------------------------------- 57 | 58 | Table without column headers: 59 | 60 | ------- ------ ---------- ------- 61 | 12 12 12 12 62 | 123 123 123 123 63 | 1 1 1 1 64 | ------- ------ ---------- ------- 65 | 66 | Multiline table without column headers: 67 | 68 | ---------- --------- ----------- --------------------------- 69 | First row 12.0 Example of a row that spans 70 | multiple lines. 71 | 72 | Second row 5.0 Here's another one. Note 73 | the blank line between rows. 74 | ---------- --------- ----------- --------------------------- 75 | 76 | -------------------------------------------------------------------------------- /tests/tables.texinfo: -------------------------------------------------------------------------------- 1 | @node Top 2 | @top Top 3 | 4 | Simple table with caption: 5 | 6 | @float 7 | @multitable {Right} {Left} {Center} {Default} 8 | @headitem 9 | Right 10 | @tab Left 11 | @tab Center 12 | @tab Default 13 | @item 14 | 12 15 | @tab 12 16 | @tab 12 17 | @tab 12 18 | @item 19 | 123 20 | @tab 123 21 | @tab 123 22 | @tab 123 23 | @item 24 | 1 25 | @tab 1 26 | @tab 1 27 | @tab 1 28 | @end multitable 29 | @caption{Demonstration of simple table syntax.} 30 | @end float 31 | Simple table without caption: 32 | 33 | @multitable {Right} {Left} {Center} {Default} 34 | @headitem 35 | Right 36 | @tab Left 37 | @tab Center 38 | @tab Default 39 | @item 40 | 12 41 | @tab 12 42 | @tab 12 43 | @tab 12 44 | @item 45 | 123 46 | @tab 123 47 | @tab 123 48 | @tab 123 49 | @item 50 | 1 51 | @tab 1 52 | @tab 1 53 | @tab 1 54 | @end multitable 55 | 56 | Simple table indented two spaces: 57 | 58 | @float 59 | @multitable {Right} {Left} {Center} {Default} 60 | @headitem 61 | Right 62 | @tab Left 63 | @tab Center 64 | @tab Default 65 | @item 66 | 12 67 | @tab 12 68 | @tab 12 69 | @tab 12 70 | @item 71 | 123 72 | @tab 123 73 | @tab 123 74 | @tab 123 75 | @item 76 | 1 77 | @tab 1 78 | @tab 1 79 | @tab 1 80 | @end multitable 81 | @caption{Demonstration of simple table syntax.} 82 | @end float 83 | Multiline table with caption: 84 | 85 | @float 86 | @multitable @columnfractions 0.15 0.14 0.16 0.34 87 | @headitem 88 | Centered Header 89 | @tab Left Aligned 90 | @tab Right Aligned 91 | @tab Default aligned 92 | @item 93 | First 94 | @tab row 95 | @tab 12.0 96 | @tab Example of a row that spans multiple lines. 97 | @item 98 | Second 99 | @tab row 100 | @tab 5.0 101 | @tab Here's another one. Note the blank line between rows. 102 | @end multitable 103 | @caption{Here's the caption. It may span multiple lines.} 104 | @end float 105 | Multiline table without caption: 106 | 107 | @multitable @columnfractions 0.15 0.14 0.16 0.34 108 | @headitem 109 | Centered Header 110 | @tab Left Aligned 111 | @tab Right Aligned 112 | @tab Default aligned 113 | @item 114 | First 115 | @tab row 116 | @tab 12.0 117 | @tab Example of a row that spans multiple lines. 118 | @item 119 | Second 120 | @tab row 121 | @tab 5.0 122 | @tab Here's another one. Note the blank line between rows. 123 | @end multitable 124 | 125 | Table without column headers: 126 | 127 | @multitable {123} {123} {123} {123} 128 | @item 129 | 12 130 | @tab 12 131 | @tab 12 132 | @tab 12 133 | @item 134 | 123 135 | @tab 123 136 | @tab 123 137 | @tab 123 138 | @item 139 | 1 140 | @tab 1 141 | @tab 1 142 | @tab 1 143 | @end multitable 144 | 145 | Multiline table without column headers: 146 | 147 | @multitable @columnfractions 0.15 0.14 0.16 0.34 148 | @item 149 | First 150 | @tab row 151 | @tab 12.0 152 | @tab Example of a row that spans multiple lines. 153 | @item 154 | Second 155 | @tab row 156 | @tab 5.0 157 | @tab Here's another one. Note the blank line between rows. 158 | @end multitable 159 | -------------------------------------------------------------------------------- /tests/tables.context: -------------------------------------------------------------------------------- 1 | Simple table with caption: 2 | 3 | \placetable[here]{Demonstration of simple table syntax.} 4 | \starttable[|r|l|c|l|] 5 | \HL 6 | \NC Right 7 | \NC Left 8 | \NC Center 9 | \NC Default 10 | \NC\AR 11 | \HL 12 | \NC 12 13 | \NC 12 14 | \NC 12 15 | \NC 12 16 | \NC\AR 17 | \NC 123 18 | \NC 123 19 | \NC 123 20 | \NC 123 21 | \NC\AR 22 | \NC 1 23 | \NC 1 24 | \NC 1 25 | \NC 1 26 | \NC\AR 27 | \HL 28 | \stoptable 29 | 30 | Simple table without caption: 31 | 32 | \placetable[here]{none} 33 | \starttable[|r|l|c|l|] 34 | \HL 35 | \NC Right 36 | \NC Left 37 | \NC Center 38 | \NC Default 39 | \NC\AR 40 | \HL 41 | \NC 12 42 | \NC 12 43 | \NC 12 44 | \NC 12 45 | \NC\AR 46 | \NC 123 47 | \NC 123 48 | \NC 123 49 | \NC 123 50 | \NC\AR 51 | \NC 1 52 | \NC 1 53 | \NC 1 54 | \NC 1 55 | \NC\AR 56 | \HL 57 | \stoptable 58 | 59 | Simple table indented two spaces: 60 | 61 | \placetable[here]{Demonstration of simple table syntax.} 62 | \starttable[|r|l|c|l|] 63 | \HL 64 | \NC Right 65 | \NC Left 66 | \NC Center 67 | \NC Default 68 | \NC\AR 69 | \HL 70 | \NC 12 71 | \NC 12 72 | \NC 12 73 | \NC 12 74 | \NC\AR 75 | \NC 123 76 | \NC 123 77 | \NC 123 78 | \NC 123 79 | \NC\AR 80 | \NC 1 81 | \NC 1 82 | \NC 1 83 | \NC 1 84 | \NC\AR 85 | \HL 86 | \stoptable 87 | 88 | Multiline table with caption: 89 | 90 | \placetable[here]{Here's the caption. It may span multiple lines.} 91 | \starttable[|cp(0.15\textwidth)|lp(0.14\textwidth)|rp(0.16\textwidth)|lp(0.34\textwidth)|] 92 | \HL 93 | \NC Centered Header 94 | \NC Left Aligned 95 | \NC Right Aligned 96 | \NC Default aligned 97 | \NC\AR 98 | \HL 99 | \NC First 100 | \NC row 101 | \NC 12.0 102 | \NC Example of a row that spans multiple lines. 103 | \NC\AR 104 | \NC Second 105 | \NC row 106 | \NC 5.0 107 | \NC Here's another one. Note the blank line between rows. 108 | \NC\AR 109 | \HL 110 | \stoptable 111 | 112 | Multiline table without caption: 113 | 114 | \placetable[here]{none} 115 | \starttable[|cp(0.15\textwidth)|lp(0.14\textwidth)|rp(0.16\textwidth)|lp(0.34\textwidth)|] 116 | \HL 117 | \NC Centered Header 118 | \NC Left Aligned 119 | \NC Right Aligned 120 | \NC Default aligned 121 | \NC\AR 122 | \HL 123 | \NC First 124 | \NC row 125 | \NC 12.0 126 | \NC Example of a row that spans multiple lines. 127 | \NC\AR 128 | \NC Second 129 | \NC row 130 | \NC 5.0 131 | \NC Here's another one. Note the blank line between rows. 132 | \NC\AR 133 | \HL 134 | \stoptable 135 | 136 | Table without column headers: 137 | 138 | \placetable[here]{none} 139 | \starttable[|r|l|c|r|] 140 | \HL 141 | \NC 12 142 | \NC 12 143 | \NC 12 144 | \NC 12 145 | \NC\AR 146 | \NC 123 147 | \NC 123 148 | \NC 123 149 | \NC 123 150 | \NC\AR 151 | \NC 1 152 | \NC 1 153 | \NC 1 154 | \NC 1 155 | \NC\AR 156 | \HL 157 | \stoptable 158 | 159 | Multiline table without column headers: 160 | 161 | \placetable[here]{none} 162 | \starttable[|cp(0.15\textwidth)|lp(0.14\textwidth)|rp(0.16\textwidth)|lp(0.34\textwidth)|] 163 | \HL 164 | \NC First 165 | \NC row 166 | \NC 12.0 167 | \NC Example of a row that spans multiple lines. 168 | \NC\AR 169 | \NC Second 170 | \NC row 171 | \NC 5.0 172 | \NC Here's another one. Note the blank line between rows. 173 | \NC\AR 174 | \HL 175 | \stoptable 176 | -------------------------------------------------------------------------------- /windows/pandoc-setup.iss: -------------------------------------------------------------------------------- 1 | ; Script generated by the Inno Setup Script Wizard. 2 | ; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES! 3 | 4 | [Setup] 5 | ; NOTE: The value of AppId uniquely identifies this application. 6 | ; Do not use the same AppId value in installers for other applications. 7 | ; (To generate a new GUID, click Tools | Generate GUID inside the IDE.) 8 | AppId={{3CEE7B38-B19D-4980-9CAD-DF53600BD4CA} 9 | ; Version 5.1 is XP 10 | MinVersion=5.1,5.1 11 | AppName=Pandoc 12 | AppVerName=Pandoc 1.9.2 13 | AppPublisher=John MacFarlane 14 | AppPublisherURL=http://johnmacfarlane.net/pandoc/ 15 | AppSupportURL=http://johnmacfarlane.net/pandoc/ 16 | AppUpdatesURL=http://johnmacfarlane.net/pandoc/ 17 | DefaultDirName={code:DefDirRoot}\Pandoc 18 | DefaultGroupName=Pandoc 19 | AllowNoIcons=yes 20 | LicenseFile="..\COPYING.txt" 21 | OutputBaseFilename=pandoc-setup 22 | Compression=lzma 23 | SolidCompression=yes 24 | ChangesEnvironment=yes 25 | PrivilegesRequired=none 26 | 27 | [Tasks] 28 | Name: modifypath; Description: Add application directory to your path 29 | 30 | [Code] 31 | function ModPathDir(): TArrayOfString; 32 | var 33 | Dir: TArrayOfString; 34 | begin 35 | setArrayLength(Dir, 1) 36 | Dir[0] := ExpandConstant('{app}\bin'); 37 | Result := Dir; 38 | end; 39 | #include "modpath.iss" 40 | 41 | function IsRegularUser(): Boolean; 42 | begin 43 | Result := not (IsAdminLoggedOn or IsPowerUserLoggedOn); 44 | end; 45 | 46 | function DefDirRoot(Param: String): String; 47 | begin 48 | if IsRegularUser then 49 | Result := ExpandConstant('{localappdata}') 50 | else 51 | Result := ExpandConstant('{pf}') 52 | end; 53 | 54 | [Languages] 55 | Name: "english"; MessagesFile: "compiler:Default.isl" 56 | 57 | [Files] 58 | Source: "..\cabal-dev\bin\pandoc.exe"; DestDir: "{app}\bin"; Flags: ignoreversion 59 | Source: "..\README.html"; DestDir: "{app}"; Flags: ignoreversion 60 | Source: "..\COPYRIGHT.txt"; DestDir: "{app}"; Flags: ignoreversion 61 | Source: "..\COPYING.txt"; DestDir: "{app}"; Flags: ignoreversion 62 | Source: "..\reference.odt"; DestDir: "{app}"; Flags: ignoreversion 63 | Source: "..\reference.docx"; DestDir: "{app}"; Flags: ignoreversion 64 | Source: "..\epub.css"; DestDir: "{app}"; Flags: ignoreversion 65 | Source: "..\default.csl"; DestDir: "{app}"; Flags: ignoreversion 66 | Source: "..\templates\*"; DestDir: "{app}\templates"; Flags: ignoreversion 67 | Source: "..\data\*"; DestDir: "{app}\data"; Flags: ignoreversion 68 | Source: "..\s5\default\*"; DestDir: "{app}\s5\default"; Flags: ignoreversion 69 | Source: "..\slidy\graphics\*"; DestDir: "{app}\slidy\graphics"; Flags: ignoreversion 70 | Source: "..\slidy\scripts\*"; DestDir: "{app}\slidy\scripts"; Flags: ignoreversion 71 | Source: "..\slidy\styles\*"; DestDir: "{app}\slidy\styles"; Flags: ignoreversion 72 | Source: "..\dzslides\*"; DestDir: "{app}\dzslides"; Flags: ignoreversion 73 | Source: "pcre-license.txt"; DestDir: "{app}"; Flags: ignoreversion 74 | Source: "pcre3.dll"; DestDir: "{sys}"; Flags: onlyifdoesntexist sharedfile 75 | ; NOTE: Don't use "Flags: ignoreversion" on any shared system files 76 | 77 | [Icons] 78 | Name: "{group}\{cm:UninstallProgram,Pandoc}"; Filename: "{uninstallexe}" 79 | Name: "{group}\Pandoc User's Guide"; Filename: "{app}\README.html" 80 | 81 | -------------------------------------------------------------------------------- /tests/markdown-reader-more.native: -------------------------------------------------------------------------------- 1 | [Header 1 [Str "Additional",Space,Str "markdown",Space,Str "reader",Space,Str "tests"] 2 | ,Header 2 [Str "Blank",Space,Str "line",Space,Str "before",Space,Str "URL",Space,Str "in",Space,Str "link",Space,Str "reference"] 3 | ,Para [Link [Str "foo"] ("/url",""),Space,Str "and",Space,Link [Str "bar"] ("/url","title")] 4 | ,Header 2 [Str "Raw",Space,Str "ConTeXt",Space,Str "environments"] 5 | ,Plain [RawInline "tex" "\\placeformula "] 6 | ,RawBlock "context" "\\startformula\n L_{1} = L_{2}\n \\stopformula" 7 | ,RawBlock "context" "\\start[a2]\n\\start[a2]\n\\stop[a2]\n\\stop[a2]" 8 | ,Header 2 [Str "URLs",Space,Str "with",Space,Str "spaces"] 9 | ,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")] 10 | ,Para [Link [Str "baz"] ("/foo%20foo",""),Space,Link [Str "bam"] ("/foo%20fee",""),Space,Link [Str "bork"] ("/foo/zee%20zob","title")] 11 | ,Header 2 [Str "Horizontal",Space,Str "rules",Space,Str "with",Space,Str "spaces",Space,Str "at",Space,Str "end"] 12 | ,HorizontalRule 13 | ,HorizontalRule 14 | ,Header 2 [Str "Raw",Space,Str "HTML",Space,Str "before",Space,Str "header"] 15 | ,Plain [RawInline "html" "",RawInline "html" ""] 16 | ,Header 3 [Str "my",Space,Str "header"] 17 | ,Header 2 [Str "$",Space,Str "in",Space,Str "math"] 18 | ,Para [Math InlineMath "\\$2 + \\$3"] 19 | ,Header 2 [Str "Commented",Str "-",Str "out",Space,Str "list",Space,Str "item"] 20 | ,BulletList 21 | [[Plain [Str "one",Space,RawInline "html" ""]] 22 | ,[Plain [Str "three"]]] 23 | ,Header 2 [Str "Backslash",Space,Str "newline"] 24 | ,Para [Str "hi",LineBreak,Str "there"] 25 | ,Header 2 [Str "Code",Space,Str "spans"] 26 | ,Para [Code ("",[],[]) "hi\\"] 27 | ,Para [Code ("",[],[]) "hi there"] 28 | ,Para [Code ("",[],[]) "hi````there"] 29 | ,Para [Str "`",Str "hi"] 30 | ,Para [Str "there",Str "`"] 31 | ,Header 2 [Str "Multilingual",Space,Str "URLs"] 32 | ,Plain [RawInline "html" ""] 33 | ,Para [Link [Str "foo"] ("/bar/\27979?x=\27979","title")] 34 | ,Para [Link [Code ("",["url"],[]) "\27979@foo.\27979.baz"] ("mailto:\27979@foo.\27979.baz","")] 35 | ,Header 2 [Str "Numbered",Space,Str "examples"] 36 | ,OrderedList (1,Example,TwoParens) 37 | [[Plain [Str "First",Space,Str "example",Str "."]] 38 | ,[Plain [Str "Second",Space,Str "example",Str "."]]] 39 | ,Para [Str "Explanation",Space,Str "of",Space,Str "examples",Space,Str "(",Str "2",Str ")",Space,Str "and",Space,Str "(",Str "3",Str ")",Str "."] 40 | ,OrderedList (3,Example,TwoParens) 41 | [[Plain [Str "Third",Space,Str "example",Str "."]]] 42 | ,Header 2 [Str "Macros"] 43 | ,Para [Math InlineMath "\\langle x,y \\rangle"] 44 | ,Header 2 [Str "Case",Str "-",Str "insensitive",Space,Str "references"] 45 | ,Para [Link [Str "Fum"] ("/fum","")] 46 | ,Para [Link [Str "FUM"] ("/fum","")] 47 | ,Para [Link [Str "bat"] ("/bat","")] 48 | ,Header 2 [Str "Curly",Space,Str "smart",Space,Str "quotes"] 49 | ,Para [Quoted DoubleQuote [Str "Hi"]] 50 | ,Para [Quoted SingleQuote [Str "Hi"]] 51 | ,Header 2 [Str "Consecutive",Space,Str "lists"] 52 | ,BulletList 53 | [[Plain [Str "one"]] 54 | ,[Plain [Str "two"]]] 55 | ,OrderedList (1,Decimal,Period) 56 | [[Plain [Str "one"]] 57 | ,[Plain [Str "two"]]] 58 | ,OrderedList (1,LowerAlpha,Period) 59 | [[Plain [Str "one"]] 60 | ,[Plain [Str "two"]]]] 61 | -------------------------------------------------------------------------------- /src/Text/Pandoc/Highlighting.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE CPP #-} 2 | #if __GLASGOW_HASKELL__ >= 702 3 | {-# LANGUAGE Trustworthy #-} 4 | #endif 5 | {- 6 | Copyright (C) 2008 John MacFarlane 7 | 8 | This program is free software; you can redistribute it and/or modify 9 | it under the terms of the GNU General Public License as published by 10 | the Free Software Foundation; either version 2 of the License, or 11 | (at your option) any later version. 12 | 13 | This program is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU General Public License for more details. 17 | 18 | You should have received a copy of the GNU General Public License 19 | along with this program; if not, write to the Free Software 20 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 | -} 22 | 23 | {- | 24 | Module : Text.Pandoc.Highlighting 25 | Copyright : Copyright (C) 2008 John MacFarlane 26 | License : GNU GPL, version 2 or above 27 | 28 | Maintainer : John MacFarlane 29 | Stability : alpha 30 | Portability : portable 31 | 32 | Exports functions for syntax highlighting. 33 | -} 34 | 35 | module Text.Pandoc.Highlighting ( languages 36 | , languagesByExtension 37 | , highlight 38 | , formatLaTeXInline 39 | , formatLaTeXBlock 40 | , styleToLaTeX 41 | , formatHtmlInline 42 | , formatHtmlBlock 43 | , styleToCss 44 | , pygments 45 | , espresso 46 | , tango 47 | , kate 48 | , monochrome 49 | , haddock 50 | , Style 51 | ) where 52 | import Text.Pandoc.Definition 53 | import Text.Highlighting.Kate 54 | import Data.List (find) 55 | import Data.Maybe (fromMaybe) 56 | import Data.Char (toLower) 57 | 58 | lcLanguages :: [String] 59 | lcLanguages = map (map toLower) languages 60 | 61 | highlight :: (FormatOptions -> [SourceLine] -> a) -- ^ Formatter 62 | -> Attr -- ^ Attributes of the CodeBlock 63 | -> String -- ^ Raw contents of the CodeBlock 64 | -> Maybe a -- ^ Maybe the formatted result 65 | highlight formatter (_, classes, keyvals) rawCode = 66 | let firstNum = case reads (fromMaybe "1" $ lookup "startFrom" keyvals) of 67 | ((n,_):_) -> n 68 | [] -> 1 69 | fmtOpts = defaultFormatOpts{ 70 | startNumber = firstNum, 71 | numberLines = any (`elem` 72 | ["number","numberLines", "number-lines"]) classes } 73 | lcclasses = map (map toLower) classes 74 | in case find (`elem` lcLanguages) lcclasses of 75 | Nothing -> Nothing 76 | Just language -> Just 77 | $ formatter fmtOpts{ codeClasses = [language], 78 | containerClasses = classes } 79 | $ highlightAs language rawCode 80 | 81 | -------------------------------------------------------------------------------- /src/Text/Pandoc/Writers/Native.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE CPP #-} 2 | #if __GLASGOW_HASKELL__ >= 702 3 | {-# LANGUAGE Trustworthy #-} 4 | #endif 5 | {-# LANGUAGE OverloadedStrings #-} 6 | {- 7 | Copyright (C) 2006-2010 John MacFarlane 8 | 9 | This program is free software; you can redistribute it and/or modify 10 | it under the terms of the GNU General Public License as published by 11 | the Free Software Foundation; either version 2 of the License, or 12 | (at your option) any later version. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program; if not, write to the Free Software 21 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | -} 23 | 24 | {- | 25 | Module : Text.Pandoc.Writers.Native 26 | Copyright : Copyright (C) 2006-2010 John MacFarlane 27 | License : GNU GPL, version 2 or above 28 | 29 | Maintainer : John MacFarlane 30 | Stability : alpha 31 | Portability : portable 32 | 33 | Conversion of a 'Pandoc' document to a string representation. 34 | 35 | Note: If @writerStandalone@ is @False@, only the document body 36 | is represented; otherwise, the full 'Pandoc' document, including the 37 | metadata. 38 | -} 39 | module Text.Pandoc.Writers.Native ( writeNative ) 40 | where 41 | import Text.Pandoc.Shared ( WriterOptions(..) ) 42 | import Data.List ( intersperse ) 43 | import Text.Pandoc.Definition 44 | import Text.Pandoc.Pretty 45 | 46 | prettyList :: [Doc] -> Doc 47 | prettyList ds = 48 | "[" <> (cat $ intersperse (cr <> ",") $ map (nest 1) ds) <> "]" 49 | 50 | -- | Prettyprint Pandoc block element. 51 | prettyBlock :: Block -> Doc 52 | prettyBlock (BlockQuote blocks) = 53 | "BlockQuote" $$ prettyList (map prettyBlock blocks) 54 | prettyBlock (OrderedList attribs blockLists) = 55 | "OrderedList" <> space <> text (show attribs) $$ 56 | (prettyList $ map (prettyList . map prettyBlock) blockLists) 57 | prettyBlock (BulletList blockLists) = 58 | "BulletList" $$ 59 | (prettyList $ map (prettyList . map prettyBlock) blockLists) 60 | prettyBlock (DefinitionList items) = "DefinitionList" $$ 61 | (prettyList $ map deflistitem items) 62 | where deflistitem (term, defs) = "(" <> text (show term) <> "," <> cr <> 63 | nest 1 (prettyList $ map (prettyList . map prettyBlock) defs) <> ")" 64 | prettyBlock (Table caption aligns widths header rows) = 65 | "Table " <> text (show caption) <> " " <> text (show aligns) <> " " <> 66 | text (show widths) $$ 67 | prettyRow header $$ 68 | prettyList (map prettyRow rows) 69 | where prettyRow cols = prettyList (map (prettyList . map prettyBlock) cols) 70 | prettyBlock block = text $ show block 71 | 72 | -- | Prettyprint Pandoc document. 73 | writeNative :: WriterOptions -> Pandoc -> String 74 | writeNative opts (Pandoc meta blocks) = 75 | let colwidth = if writerWrapText opts 76 | then Just $ writerColumns opts 77 | else Nothing 78 | withHead = if writerStandalone opts 79 | then \bs -> text ("Pandoc " ++ "(" ++ show meta ++ ")") $$ 80 | bs $$ cr 81 | else id 82 | in render colwidth $ withHead $ prettyList $ map prettyBlock blocks 83 | -------------------------------------------------------------------------------- /tests/tables.man: -------------------------------------------------------------------------------- 1 | .PP 2 | Simple table with caption: 3 | .PP 4 | Demonstration of simple table syntax. 5 | .TS 6 | tab(@); 7 | r l c l. 8 | T{ 9 | Right 10 | T}@T{ 11 | Left 12 | T}@T{ 13 | Center 14 | T}@T{ 15 | Default 16 | T} 17 | _ 18 | T{ 19 | 12 20 | T}@T{ 21 | 12 22 | T}@T{ 23 | 12 24 | T}@T{ 25 | 12 26 | T} 27 | T{ 28 | 123 29 | T}@T{ 30 | 123 31 | T}@T{ 32 | 123 33 | T}@T{ 34 | 123 35 | T} 36 | T{ 37 | 1 38 | T}@T{ 39 | 1 40 | T}@T{ 41 | 1 42 | T}@T{ 43 | 1 44 | T} 45 | .TE 46 | .PP 47 | Simple table without caption: 48 | .PP 49 | .TS 50 | tab(@); 51 | r l c l. 52 | T{ 53 | Right 54 | T}@T{ 55 | Left 56 | T}@T{ 57 | Center 58 | T}@T{ 59 | Default 60 | T} 61 | _ 62 | T{ 63 | 12 64 | T}@T{ 65 | 12 66 | T}@T{ 67 | 12 68 | T}@T{ 69 | 12 70 | T} 71 | T{ 72 | 123 73 | T}@T{ 74 | 123 75 | T}@T{ 76 | 123 77 | T}@T{ 78 | 123 79 | T} 80 | T{ 81 | 1 82 | T}@T{ 83 | 1 84 | T}@T{ 85 | 1 86 | T}@T{ 87 | 1 88 | T} 89 | .TE 90 | .PP 91 | Simple table indented two spaces: 92 | .PP 93 | Demonstration of simple table syntax. 94 | .TS 95 | tab(@); 96 | r l c l. 97 | T{ 98 | Right 99 | T}@T{ 100 | Left 101 | T}@T{ 102 | Center 103 | T}@T{ 104 | Default 105 | T} 106 | _ 107 | T{ 108 | 12 109 | T}@T{ 110 | 12 111 | T}@T{ 112 | 12 113 | T}@T{ 114 | 12 115 | T} 116 | T{ 117 | 123 118 | T}@T{ 119 | 123 120 | T}@T{ 121 | 123 122 | T}@T{ 123 | 123 124 | T} 125 | T{ 126 | 1 127 | T}@T{ 128 | 1 129 | T}@T{ 130 | 1 131 | T}@T{ 132 | 1 133 | T} 134 | .TE 135 | .PP 136 | Multiline table with caption: 137 | .PP 138 | Here\[aq]s the caption. It may span multiple lines. 139 | .TS 140 | tab(@); 141 | cw(10.50n) lw(9.63n) rw(11.38n) lw(23.63n). 142 | T{ 143 | Centered Header 144 | T}@T{ 145 | Left Aligned 146 | T}@T{ 147 | Right Aligned 148 | T}@T{ 149 | Default aligned 150 | T} 151 | _ 152 | T{ 153 | First 154 | T}@T{ 155 | row 156 | T}@T{ 157 | 12.0 158 | T}@T{ 159 | Example of a row that spans multiple lines. 160 | T} 161 | T{ 162 | Second 163 | T}@T{ 164 | row 165 | T}@T{ 166 | 5.0 167 | T}@T{ 168 | Here\[aq]s another one. 169 | Note the blank line between rows. 170 | T} 171 | .TE 172 | .PP 173 | Multiline table without caption: 174 | .PP 175 | .TS 176 | tab(@); 177 | cw(10.50n) lw(9.63n) rw(11.38n) lw(23.63n). 178 | T{ 179 | Centered Header 180 | T}@T{ 181 | Left Aligned 182 | T}@T{ 183 | Right Aligned 184 | T}@T{ 185 | Default aligned 186 | T} 187 | _ 188 | T{ 189 | First 190 | T}@T{ 191 | row 192 | T}@T{ 193 | 12.0 194 | T}@T{ 195 | Example of a row that spans multiple lines. 196 | T} 197 | T{ 198 | Second 199 | T}@T{ 200 | row 201 | T}@T{ 202 | 5.0 203 | T}@T{ 204 | Here\[aq]s another one. 205 | Note the blank line between rows. 206 | T} 207 | .TE 208 | .PP 209 | Table without column headers: 210 | .PP 211 | .TS 212 | tab(@); 213 | r l c r. 214 | T{ 215 | 12 216 | T}@T{ 217 | 12 218 | T}@T{ 219 | 12 220 | T}@T{ 221 | 12 222 | T} 223 | T{ 224 | 123 225 | T}@T{ 226 | 123 227 | T}@T{ 228 | 123 229 | T}@T{ 230 | 123 231 | T} 232 | T{ 233 | 1 234 | T}@T{ 235 | 1 236 | T}@T{ 237 | 1 238 | T}@T{ 239 | 1 240 | T} 241 | .TE 242 | .PP 243 | Multiline table without column headers: 244 | .PP 245 | .TS 246 | tab(@); 247 | cw(10.50n) lw(9.63n) rw(11.38n) lw(23.63n). 248 | T{ 249 | First 250 | T}@T{ 251 | row 252 | T}@T{ 253 | 12.0 254 | T}@T{ 255 | Example of a row that spans multiple lines. 256 | T} 257 | T{ 258 | Second 259 | T}@T{ 260 | row 261 | T}@T{ 262 | 5.0 263 | T}@T{ 264 | Here\[aq]s another one. 265 | Note the blank line between rows. 266 | T} 267 | .TE 268 | -------------------------------------------------------------------------------- /tests/lhs-test.latex: -------------------------------------------------------------------------------- 1 | \documentclass[]{article} 2 | \usepackage{amssymb,amsmath} 3 | \usepackage{ifxetex,ifluatex} 4 | \ifxetex 5 | \usepackage{fontspec,xltxtra,xunicode} 6 | \defaultfontfeatures{Mapping=tex-text,Scale=MatchLowercase} 7 | \newcommand{\euro}{€} 8 | \else 9 | \ifluatex 10 | \usepackage{fontspec} 11 | \defaultfontfeatures{Mapping=tex-text,Scale=MatchLowercase} 12 | \newcommand{\euro}{€} 13 | \else 14 | \usepackage[utf8]{inputenc} 15 | \fi 16 | \fi 17 | \usepackage{color} 18 | \usepackage{fancyvrb} 19 | \DefineShortVerb[commandchars=\\\{\}]{\|} 20 | \DefineVerbatimEnvironment{Highlighting}{Verbatim}{commandchars=\\\{\}} 21 | % Add ',fontsize=\small' for more characters per line 22 | \newenvironment{Shaded}{}{} 23 | \newcommand{\KeywordTok}[1]{\textcolor[rgb]{0.00,0.44,0.13}{\textbf{{#1}}}} 24 | \newcommand{\DataTypeTok}[1]{\textcolor[rgb]{0.56,0.13,0.00}{{#1}}} 25 | \newcommand{\DecValTok}[1]{\textcolor[rgb]{0.25,0.63,0.44}{{#1}}} 26 | \newcommand{\BaseNTok}[1]{\textcolor[rgb]{0.25,0.63,0.44}{{#1}}} 27 | \newcommand{\FloatTok}[1]{\textcolor[rgb]{0.25,0.63,0.44}{{#1}}} 28 | \newcommand{\CharTok}[1]{\textcolor[rgb]{0.25,0.44,0.63}{{#1}}} 29 | \newcommand{\StringTok}[1]{\textcolor[rgb]{0.25,0.44,0.63}{{#1}}} 30 | \newcommand{\CommentTok}[1]{\textcolor[rgb]{0.38,0.63,0.69}{\textit{{#1}}}} 31 | \newcommand{\OtherTok}[1]{\textcolor[rgb]{0.00,0.44,0.13}{{#1}}} 32 | \newcommand{\AlertTok}[1]{\textcolor[rgb]{1.00,0.00,0.00}{\textbf{{#1}}}} 33 | \newcommand{\FunctionTok}[1]{\textcolor[rgb]{0.02,0.16,0.49}{{#1}}} 34 | \newcommand{\RegionMarkerTok}[1]{{#1}} 35 | \newcommand{\ErrorTok}[1]{\textcolor[rgb]{1.00,0.00,0.00}{\textbf{{#1}}}} 36 | \newcommand{\NormalTok}[1]{{#1}} 37 | \ifxetex 38 | \usepackage[setpagesize=false, % page size defined by xetex 39 | unicode=false, % unicode breaks when used with xetex 40 | xetex, 41 | bookmarks=true, 42 | pdfauthor={}, 43 | pdftitle={}, 44 | colorlinks=true, 45 | linkcolor=blue]{hyperref} 46 | \else 47 | \usepackage[unicode=true, 48 | bookmarks=true, 49 | pdfauthor={}, 50 | pdftitle={}, 51 | colorlinks=true, 52 | linkcolor=blue]{hyperref} 53 | \fi 54 | \hypersetup{breaklinks=true, pdfborder={0 0 0}} 55 | \setlength{\parindent}{0pt} 56 | \setlength{\parskip}{6pt plus 2pt minus 1pt} 57 | \setlength{\emergencystretch}{3em} % prevent overfull lines 58 | \setcounter{secnumdepth}{0} 59 | 60 | 61 | \begin{document} 62 | 63 | \section{lhs test} 64 | 65 | \texttt{unsplit} is an arrow that takes a pair of values and combines them to 66 | return a single value: 67 | 68 | \begin{Shaded} 69 | \begin{Highlighting}[] 70 | \OtherTok{unsplit ::} \NormalTok{(}\DataTypeTok{Arrow} \NormalTok{a) }\OtherTok{=>} \NormalTok{(b }\OtherTok{->} \NormalTok{c }\OtherTok{->} \NormalTok{d) }\OtherTok{->} \NormalTok{a (b, c) d} 71 | \NormalTok{unsplit }\FunctionTok{=} \NormalTok{arr }\FunctionTok{.} \FunctionTok{uncurry} 72 | \CommentTok{-- arr (\textbackslash{}op (x,y) -> x `op` y) } 73 | \end{Highlighting} 74 | \end{Shaded} 75 | \texttt{(***)} combines two arrows into a new arrow by running the two arrows 76 | on a pair of values (one arrow on the first item of the pair and one arrow on 77 | the second item of the pair). 78 | 79 | \begin{verbatim} 80 | f *** g = first f >>> second g 81 | \end{verbatim} 82 | Block quote: 83 | 84 | \begin{quote} 85 | foo bar 86 | 87 | \end{quote} 88 | 89 | \end{document} 90 | -------------------------------------------------------------------------------- /MakeManPage.hs: -------------------------------------------------------------------------------- 1 | -- Create pandoc.1 man and pandoc_markdown.5 man pages from README 2 | import Text.Pandoc 3 | import Data.ByteString.UTF8 (toString, fromString) 4 | import Data.Char (toUpper) 5 | import qualified Data.ByteString as B 6 | import Control.Monad 7 | import System.FilePath 8 | import System.Environment (getArgs) 9 | import Text.Pandoc.Shared (normalize) 10 | import System.Directory (getModificationTime) 11 | import System.IO.Error (isDoesNotExistError) 12 | import System.Time (ClockTime(..)) 13 | import Data.Maybe (catMaybes) 14 | 15 | main = do 16 | rmContents <- liftM toString $ B.readFile "README" 17 | let (Pandoc meta blocks) = readMarkdown defaultParserState rmContents 18 | let manBlocks = removeSect [Str "Wrappers"] 19 | $ removeSect [Str "Pandoc's",Space,Str "markdown"] blocks 20 | let syntaxBlocks = extractSect [Str "Pandoc's",Space,Str "markdown"] blocks 21 | args <- getArgs 22 | let verbose = "--verbose" `elem` args 23 | makeManPage verbose ("man" "man1" "pandoc.1") 24 | meta manBlocks 25 | makeManPage verbose ("man" "man5" "pandoc_markdown.5") 26 | meta syntaxBlocks 27 | 28 | makeManPage :: Bool -> FilePath -> Meta -> [Block] -> IO () 29 | makeManPage verbose page meta blocks = do 30 | let templ = page <.> "template" 31 | modDeps <- modifiedDependencies page ["README", templ] 32 | unless (null modDeps) $ do 33 | manTemplate <- liftM toString $ B.readFile templ 34 | writeManPage page manTemplate (Pandoc meta blocks) 35 | when verbose $ 36 | putStrLn $ "Created " ++ page 37 | 38 | writeManPage :: FilePath -> String -> Pandoc -> IO () 39 | writeManPage page templ doc = do 40 | let opts = defaultWriterOptions{ writerStandalone = True 41 | , writerTemplate = templ } 42 | let manPage = writeMan opts $ 43 | bottomUp (concatMap removeLinks) $ 44 | bottomUp capitalizeHeaders doc 45 | B.writeFile page $ fromString manPage 46 | 47 | -- | Returns a list of 'dependencies' that have been modified after 'file'. 48 | modifiedDependencies :: FilePath -> [FilePath] -> IO [FilePath] 49 | modifiedDependencies file dependencies = do 50 | fileModTime <- catch (getModificationTime file) $ 51 | \e -> if isDoesNotExistError e 52 | then return (TOD 0 0) -- the minimum ClockTime 53 | else ioError e 54 | depModTimes <- mapM getModificationTime dependencies 55 | let modified = zipWith (\dep time -> if time > fileModTime then Just dep else Nothing) dependencies depModTimes 56 | return $ catMaybes modified 57 | 58 | removeLinks :: Inline -> [Inline] 59 | removeLinks (Link l _) = l 60 | removeLinks x = [x] 61 | 62 | capitalizeHeaders :: Block -> Block 63 | capitalizeHeaders (Header 1 xs) = Header 1 $ bottomUp capitalize xs 64 | capitalizeHeaders x = x 65 | 66 | capitalize :: Inline -> Inline 67 | capitalize (Str xs) = Str $ map toUpper xs 68 | capitalize x = x 69 | 70 | removeSect :: [Inline] -> [Block] -> [Block] 71 | removeSect ils (Header 1 x:xs) | normalize x == normalize ils = 72 | dropWhile (not . isHeader1) xs 73 | removeSect ils (x:xs) = x : removeSect ils xs 74 | removeSect _ [] = [] 75 | 76 | extractSect :: [Inline] -> [Block] -> [Block] 77 | extractSect ils (Header 1 z:xs) | normalize z == normalize ils = 78 | bottomUp promoteHeader $ takeWhile (not . isHeader1) xs 79 | where promoteHeader (Header n x) = Header (n-1) x 80 | promoteHeader x = x 81 | extractSect ils (x:xs) = extractSect ils xs 82 | extractSect _ [] = [] 83 | 84 | isHeader1 :: Block -> Bool 85 | isHeader1 (Header 1 _) = True 86 | isHeader1 _ = False 87 | 88 | -------------------------------------------------------------------------------- /COPYRIGHT: -------------------------------------------------------------------------------- 1 | Pandoc 2 | Copyright (C) 2006-2012 John MacFarlane 3 | 4 | This code is released under the [GPL], version 2 or later: 5 | 6 | This program is free software; you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation; either version 2 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 | 20 | The GNU General Public License is available in the file COPYING in 21 | the source distribution. On Debian systems, the complete text of the 22 | GPL can be found in `/usr/share/common-licenses/GPL`. 23 | 24 | [GPL]: http://www.gnu.org/copyleft/gpl.html 25 | 26 | Pandoc's complete source code is available from the [Pandoc home page]. 27 | 28 | [Pandoc home page]: http://johnmacfarlane.net/pandoc/ 29 | 30 | Pandoc includes some code from other authors. The copyright and license 31 | statements for these sources are included below. All are GPL-compatible 32 | licenses. 33 | 34 | ---------------------------------------------------------------------- 35 | src/Text/Pandoc/Writers/Texinfo.hs 36 | Copyright (C) 2008-2010 John MacFarlane and Peter Wang 37 | 38 | Released under the GPL. 39 | 40 | ---------------------------------------------------------------------- 41 | src/Text/Pandoc/Writers/OpenDocument.hs 42 | Copyright (C) 2008-2010 Andrea Rossato and John MacFarlane 43 | 44 | Released under the GPL. 45 | 46 | ---------------------------------------------------------------------- 47 | src/Text/Pandoc/Writers/Org.hs 48 | Copyright (C) 2010 Puneeth Chaganti 49 | 50 | Released under the GPL. 51 | 52 | ---------------------------------------------------------------------- 53 | src/Text/Pandoc/Readers/Textile.hs 54 | Copyright (C) 2010 Paul Rivier 55 | 56 | Released under the GPL. 57 | 58 | ---------------------------------------------------------------------- 59 | src/Text/Pandoc/Biblio.hs 60 | Copyright (C) 2008-2010 Andrea Rossato 61 | 62 | Released under the GPL. 63 | 64 | ---------------------------------------------------------------------- 65 | data/LaTeXMathML.js 66 | Adapted by Jeff Knisely and Douglas Woodall from 67 | ASCIIMathML.js v. 1.4.7 68 | Copyright (C) 2005 Peter Jipsen 69 | 70 | Released under the GPL. 71 | 72 | ---------------------------------------------------------------------- 73 | data/MathMLInHTML.js 74 | Copyright (C) 2004 Peter Jipsen http://www.chapman.edu/~jipsen 75 | 76 | Released under the GNU General Public License version 2 or later. 77 | See the GNU General Public License 78 | (at http://www.gnu.org/copyleft/gpl.html) for more details. 79 | 80 | ---------------------------------------------------------------------- 81 | s5/default 82 | S5 slides.js and css files 83 | by Eric A. Meyer 84 | body div#controls {position: fixed; padding: 0 0 1em 0; 52 | top: auto;} 53 | div#controls form {position: absolute; bottom: 0; right: 0; width: 100%; 54 | margin: 0; padding: 0;} 55 | #controls #navLinks a {padding: 0; margin: 0 0.5em; 56 | background: #005; border: none; color: #779; 57 | cursor: pointer;} 58 | #controls #navList {height: 1em;} 59 | #controls #navList #jumplist {position: absolute; bottom: 0; right: 0; background: #DDD; color: #227;} 60 | 61 | #currentSlide {text-align: center; font-size: 0.5em; color: #449;} 62 | 63 | #slide0 {padding-top: 3.5em; font-size: 90%;} 64 | #slide0 h1 {position: static; margin: 1em 0 0; padding: 0; 65 | font: bold 2em Helvetica, sans-serif; white-space: normal; 66 | color: #000; background: transparent;} 67 | #slide0 h2 {font: bold italic 1em Helvetica, sans-serif; margin: 0.25em;} 68 | #slide0 h3 {margin-top: 1.5em; font-size: 1.5em;} 69 | #slide0 h4 {margin-top: 0; font-size: 1em;} 70 | 71 | ul.urls {list-style: none; display: inline; margin: 0;} 72 | .urls li {display: inline; margin: 0;} 73 | .note {display: none;} 74 | .external {border-bottom: 1px dotted gray;} 75 | html>body .external {border-bottom: none;} 76 | .external:after {content: " \274F"; font-size: smaller; color: #77B;} 77 | 78 | .incremental, .incremental *, .incremental *:after {color: #DDE; visibility: visible;} 79 | img.incremental {visibility: hidden;} 80 | .slide .current {color: #B02;} 81 | 82 | 83 | /* diagnostics 84 | 85 | li:after {content: " [" attr(class) "]"; color: #F88;} 86 | */ 87 | -------------------------------------------------------------------------------- /src/Text/Pandoc/UTF8.hs: -------------------------------------------------------------------------------- 1 | {- 2 | Copyright (C) 2010 John MacFarlane 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, write to the Free Software 16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | -} 18 | 19 | {- | 20 | Module : Text.Pandoc.UTF8 21 | Copyright : Copyright (C) 2010 John MacFarlane 22 | License : GNU GPL, version 2 or above 23 | 24 | Maintainer : John MacFarlane 25 | Stability : alpha 26 | Portability : portable 27 | 28 | UTF-8 aware string IO functions that will work with GHC 6.10, 6.12, or 7. 29 | -} 30 | module Text.Pandoc.UTF8 ( readFile 31 | , writeFile 32 | , getContents 33 | , putStr 34 | , putStrLn 35 | , hPutStr 36 | , hPutStrLn 37 | , hGetContents 38 | ) 39 | 40 | where 41 | 42 | #if MIN_VERSION_base(4,2,0) 43 | 44 | import System.IO hiding (readFile, writeFile, getContents, 45 | putStr, putStrLn, hPutStr, hPutStrLn, hGetContents) 46 | import Prelude hiding (readFile, writeFile, getContents, putStr, putStrLn ) 47 | import Codec.Binary.UTF8.String (encodeString) 48 | import qualified System.IO as IO 49 | 50 | readFile :: FilePath -> IO String 51 | readFile f = do 52 | h <- openFile (encodeString f) ReadMode 53 | hGetContents h 54 | 55 | writeFile :: FilePath -> String -> IO () 56 | writeFile f s = withFile (encodeString f) WriteMode $ \h -> hPutStr h s 57 | 58 | getContents :: IO String 59 | getContents = hGetContents stdin 60 | 61 | putStr :: String -> IO () 62 | putStr s = hPutStr stdout s 63 | 64 | putStrLn :: String -> IO () 65 | putStrLn s = hPutStrLn stdout s 66 | 67 | hPutStr :: Handle -> String -> IO () 68 | hPutStr h s = hSetEncoding h utf8 >> IO.hPutStr h s 69 | 70 | hPutStrLn :: Handle -> String -> IO () 71 | hPutStrLn h s = hSetEncoding h utf8 >> IO.hPutStrLn h s 72 | 73 | hGetContents :: Handle -> IO String 74 | hGetContents h = hSetEncoding h utf8_bom >> IO.hGetContents h 75 | 76 | #else 77 | 78 | import qualified Data.ByteString as B 79 | import Codec.Binary.UTF8.String (encodeString) 80 | import Data.ByteString.UTF8 (toString, fromString) 81 | import Prelude hiding (readFile, writeFile, getContents, putStr, putStrLn) 82 | import System.IO (Handle) 83 | import Control.Monad (liftM) 84 | 85 | 86 | bom :: B.ByteString 87 | bom = B.pack [0xEF, 0xBB, 0xBF] 88 | 89 | stripBOM :: B.ByteString -> B.ByteString 90 | stripBOM s | bom `B.isPrefixOf` s = B.drop 3 s 91 | stripBOM s = s 92 | 93 | readFile :: FilePath -> IO String 94 | readFile = liftM (toString . stripBOM) . B.readFile . encodeString 95 | 96 | writeFile :: FilePath -> String -> IO () 97 | writeFile f = B.writeFile (encodeString f) . fromString 98 | 99 | getContents :: IO String 100 | getContents = liftM (toString . stripBOM) B.getContents 101 | 102 | hGetContents :: Handle -> IO String 103 | hGetContents h = liftM (toString . stripBOM) (B.hGetContents h) 104 | 105 | putStr :: String -> IO () 106 | putStr = B.putStr . fromString 107 | 108 | putStrLn :: String -> IO () 109 | putStrLn = B.putStrLn . fromString 110 | 111 | hPutStr :: Handle -> String -> IO () 112 | hPutStr h = B.hPutStr h . fromString 113 | 114 | hPutStrLn :: Handle -> String -> IO () 115 | hPutStrLn h s = hPutStr h (s ++ "\n") 116 | 117 | #endif 118 | -------------------------------------------------------------------------------- /tests/tables.latex: -------------------------------------------------------------------------------- 1 | Simple table with caption: 2 | 3 | \ctable[caption = {Demonstration of simple table syntax.}, 4 | pos = H, center, botcap]{rlcl} 5 | {% notes 6 | } 7 | {% rows 8 | \FL 9 | Right & Left & Center & Default 10 | \ML 11 | 12 & 12 & 12 & 12 12 | \\\noalign{\medskip} 13 | 123 & 123 & 123 & 123 14 | \\\noalign{\medskip} 15 | 1 & 1 & 1 & 1 16 | \LL 17 | } 18 | 19 | Simple table without caption: 20 | 21 | \ctable[pos = H, center, botcap]{rlcl} 22 | {% notes 23 | } 24 | {% rows 25 | \FL 26 | Right & Left & Center & Default 27 | \ML 28 | 12 & 12 & 12 & 12 29 | \\\noalign{\medskip} 30 | 123 & 123 & 123 & 123 31 | \\\noalign{\medskip} 32 | 1 & 1 & 1 & 1 33 | \LL 34 | } 35 | 36 | Simple table indented two spaces: 37 | 38 | \ctable[caption = {Demonstration of simple table syntax.}, 39 | pos = H, center, botcap]{rlcl} 40 | {% notes 41 | } 42 | {% rows 43 | \FL 44 | Right & Left & Center & Default 45 | \ML 46 | 12 & 12 & 12 & 12 47 | \\\noalign{\medskip} 48 | 123 & 123 & 123 & 123 49 | \\\noalign{\medskip} 50 | 1 & 1 & 1 & 1 51 | \LL 52 | } 53 | 54 | Multiline table with caption: 55 | 56 | \ctable[caption = {Here's the caption. It may span multiple lines.}, 57 | pos = H, center, botcap]{clrl} 58 | {% notes 59 | } 60 | {% rows 61 | \FL 62 | \parbox[b]{0.15\columnwidth}{\centering 63 | Centered Header 64 | } & \parbox[b]{0.14\columnwidth}{\raggedright 65 | Left Aligned 66 | } & \parbox[b]{0.16\columnwidth}{\raggedleft 67 | Right Aligned 68 | } & \parbox[b]{0.34\columnwidth}{\raggedright 69 | Default aligned 70 | } 71 | \ML 72 | \parbox[t]{0.15\columnwidth}{\centering 73 | First 74 | } & \parbox[t]{0.14\columnwidth}{\raggedright 75 | row 76 | } & \parbox[t]{0.16\columnwidth}{\raggedleft 77 | 12.0 78 | } & \parbox[t]{0.34\columnwidth}{\raggedright 79 | Example of a row that spans multiple lines. 80 | } 81 | \\\noalign{\medskip} 82 | \parbox[t]{0.15\columnwidth}{\centering 83 | Second 84 | } & \parbox[t]{0.14\columnwidth}{\raggedright 85 | row 86 | } & \parbox[t]{0.16\columnwidth}{\raggedleft 87 | 5.0 88 | } & \parbox[t]{0.34\columnwidth}{\raggedright 89 | Here's another one. Note the blank line between rows. 90 | } 91 | \LL 92 | } 93 | 94 | Multiline table without caption: 95 | 96 | \ctable[pos = H, center, botcap]{clrl} 97 | {% notes 98 | } 99 | {% rows 100 | \FL 101 | \parbox[b]{0.15\columnwidth}{\centering 102 | Centered Header 103 | } & \parbox[b]{0.14\columnwidth}{\raggedright 104 | Left Aligned 105 | } & \parbox[b]{0.16\columnwidth}{\raggedleft 106 | Right Aligned 107 | } & \parbox[b]{0.34\columnwidth}{\raggedright 108 | Default aligned 109 | } 110 | \ML 111 | \parbox[t]{0.15\columnwidth}{\centering 112 | First 113 | } & \parbox[t]{0.14\columnwidth}{\raggedright 114 | row 115 | } & \parbox[t]{0.16\columnwidth}{\raggedleft 116 | 12.0 117 | } & \parbox[t]{0.34\columnwidth}{\raggedright 118 | Example of a row that spans multiple lines. 119 | } 120 | \\\noalign{\medskip} 121 | \parbox[t]{0.15\columnwidth}{\centering 122 | Second 123 | } & \parbox[t]{0.14\columnwidth}{\raggedright 124 | row 125 | } & \parbox[t]{0.16\columnwidth}{\raggedleft 126 | 5.0 127 | } & \parbox[t]{0.34\columnwidth}{\raggedright 128 | Here's another one. Note the blank line between rows. 129 | } 130 | \LL 131 | } 132 | 133 | Table without column headers: 134 | 135 | \ctable[pos = H, center, botcap]{rlcr} 136 | {% notes 137 | } 138 | {% rows 139 | \FL 140 | 12 & 12 & 12 & 12 141 | \\\noalign{\medskip} 142 | 123 & 123 & 123 & 123 143 | \\\noalign{\medskip} 144 | 1 & 1 & 1 & 1 145 | \LL 146 | } 147 | 148 | Multiline table without column headers: 149 | 150 | \ctable[pos = H, center, botcap]{clrl} 151 | {% notes 152 | } 153 | {% rows 154 | \FL 155 | \parbox[t]{0.15\columnwidth}{\centering 156 | First 157 | } & \parbox[t]{0.14\columnwidth}{\raggedright 158 | row 159 | } & \parbox[t]{0.16\columnwidth}{\raggedleft 160 | 12.0 161 | } & \parbox[t]{0.34\columnwidth}{\raggedright 162 | Example of a row that spans multiple lines. 163 | } 164 | \\\noalign{\medskip} 165 | \parbox[t]{0.15\columnwidth}{\centering 166 | Second 167 | } & \parbox[t]{0.14\columnwidth}{\raggedright 168 | row 169 | } & \parbox[t]{0.16\columnwidth}{\raggedleft 170 | 5.0 171 | } & \parbox[t]{0.34\columnwidth}{\raggedright 172 | Here's another one. Note the blank line between rows. 173 | } 174 | \LL 175 | } 176 | 177 | -------------------------------------------------------------------------------- /src/Tests/Helpers.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE TypeSynonymInstances, FlexibleInstances, TemplateHaskell #-} 2 | -- Utility functions for the test suite. 3 | 4 | module Tests.Helpers ( lit 5 | , file 6 | , test 7 | , (=?>) 8 | , property 9 | , ToString(..) 10 | , ToPandoc(..) 11 | ) 12 | where 13 | 14 | import Text.Pandoc.Definition 15 | import Text.Pandoc.Builder (Inlines, Blocks, doc, plain) 16 | import Test.Framework 17 | import Test.Framework.Providers.HUnit 18 | import Test.Framework.Providers.QuickCheck2 19 | import Test.HUnit (assertBool) 20 | import Text.Pandoc.Shared (normalize, defaultWriterOptions, 21 | WriterOptions(..), removeTrailingSpace) 22 | import Text.Pandoc.Writers.Native (writeNative) 23 | import Language.Haskell.TH.Quote (QuasiQuoter(..)) 24 | import Language.Haskell.TH.Syntax (Q, runIO) 25 | import qualified Test.QuickCheck.Property as QP 26 | import System.Console.ANSI 27 | import Data.Algorithm.Diff 28 | 29 | lit :: QuasiQuoter 30 | lit = QuasiQuoter { 31 | quoteExp = (\a -> let b = rnl a in [|b|]) . filter (/= '\r') 32 | , quotePat = error "Cannot use lit as a pattern" 33 | } 34 | where rnl ('\n':xs) = xs 35 | rnl xs = xs 36 | 37 | file :: QuasiQuoter 38 | file = quoteFile lit 39 | 40 | -- adapted from TH 2.5 code 41 | quoteFile :: QuasiQuoter -> QuasiQuoter 42 | quoteFile (QuasiQuoter { quoteExp = qe, quotePat = qp }) = 43 | QuasiQuoter { quoteExp = get qe, quotePat = get qp } 44 | where 45 | get :: (String -> Q a) -> String -> Q a 46 | get old_quoter file_name = do { file_cts <- runIO (readFile file_name) 47 | ; old_quoter file_cts } 48 | 49 | test :: (ToString a, ToString b, ToString c) 50 | => (a -> b) -- ^ function to test 51 | -> String -- ^ name of test case 52 | -> (a, c) -- ^ (input, expected value) 53 | -> Test 54 | test fn name (input, expected) = 55 | testCase name $ assertBool msg (actual' == expected') 56 | where msg = nl ++ dashes "input" ++ nl ++ input' ++ nl ++ 57 | dashes "expected" ++ nl ++ expected'' ++ 58 | dashes "got" ++ nl ++ actual'' ++ 59 | dashes "" 60 | nl = "\n" 61 | input' = toString input 62 | actual' = toString $ fn input 63 | expected' = toString expected 64 | diff = getDiff (lines expected') (lines actual') 65 | expected'' = unlines $ map vividize $ filter (\(d,_) -> d /= S) diff 66 | actual'' = unlines $ map vividize $ filter (\(d,_) -> d /= F) diff 67 | dashes "" = replicate 72 '-' 68 | dashes x = replicate (72 - length x - 5) '-' ++ " " ++ x ++ " ---" 69 | 70 | vividize :: (DI,String) -> String 71 | vividize (B,s) = s 72 | vividize (F,s) = s 73 | vividize (S,s) = setSGRCode [SetColor Background Dull Red 74 | , SetColor Foreground Vivid White] ++ s 75 | ++ setSGRCode [Reset] 76 | 77 | property :: QP.Testable a => TestName -> a -> Test 78 | property = testProperty 79 | 80 | infix 5 =?> 81 | (=?>) :: a -> b -> (a,b) 82 | x =?> y = (x, y) 83 | 84 | class ToString a where 85 | toString :: a -> String 86 | 87 | instance ToString Pandoc where 88 | toString d = writeNative defaultWriterOptions{ writerStandalone = s } 89 | $ toPandoc d 90 | where s = case d of 91 | (Pandoc (Meta [] [] []) _) -> False 92 | _ -> True 93 | 94 | instance ToString Blocks where 95 | toString = writeNative defaultWriterOptions . toPandoc 96 | 97 | instance ToString Inlines where 98 | toString = removeTrailingSpace . writeNative defaultWriterOptions . 99 | toPandoc 100 | 101 | instance ToString String where 102 | toString = id 103 | 104 | class ToPandoc a where 105 | toPandoc :: a -> Pandoc 106 | 107 | instance ToPandoc Pandoc where 108 | toPandoc = normalize 109 | 110 | instance ToPandoc Blocks where 111 | toPandoc = normalize . doc 112 | 113 | instance ToPandoc Inlines where 114 | toPandoc = normalize . doc . plain 115 | -------------------------------------------------------------------------------- /tests/tables.rst: -------------------------------------------------------------------------------- 1 | Simple table with caption: 2 | 3 | +---------+--------+----------+-----------+ 4 | | Right | Left | Center | Default | 5 | +=========+========+==========+===========+ 6 | | 12 | 12 | 12 | 12 | 7 | +---------+--------+----------+-----------+ 8 | | 123 | 123 | 123 | 123 | 9 | +---------+--------+----------+-----------+ 10 | | 1 | 1 | 1 | 1 | 11 | +---------+--------+----------+-----------+ 12 | 13 | Table: Demonstration of simple table syntax. 14 | 15 | Simple table without caption: 16 | 17 | +---------+--------+----------+-----------+ 18 | | Right | Left | Center | Default | 19 | +=========+========+==========+===========+ 20 | | 12 | 12 | 12 | 12 | 21 | +---------+--------+----------+-----------+ 22 | | 123 | 123 | 123 | 123 | 23 | +---------+--------+----------+-----------+ 24 | | 1 | 1 | 1 | 1 | 25 | +---------+--------+----------+-----------+ 26 | 27 | Simple table indented two spaces: 28 | 29 | +---------+--------+----------+-----------+ 30 | | Right | Left | Center | Default | 31 | +=========+========+==========+===========+ 32 | | 12 | 12 | 12 | 12 | 33 | +---------+--------+----------+-----------+ 34 | | 123 | 123 | 123 | 123 | 35 | +---------+--------+----------+-----------+ 36 | | 1 | 1 | 1 | 1 | 37 | +---------+--------+----------+-----------+ 38 | 39 | Table: Demonstration of simple table syntax. 40 | 41 | Multiline table with caption: 42 | 43 | +-------------+------------+--------------+----------------------------+ 44 | | Centered | Left | Right | Default aligned | 45 | | Header | Aligned | Aligned | | 46 | +=============+============+==============+============================+ 47 | | First | row | 12.0 | Example of a row that | 48 | | | | | spans multiple lines. | 49 | +-------------+------------+--------------+----------------------------+ 50 | | Second | row | 5.0 | Here's another one. Note | 51 | | | | | the blank line between | 52 | | | | | rows. | 53 | +-------------+------------+--------------+----------------------------+ 54 | 55 | Table: Here's the caption. It may span multiple lines. 56 | 57 | Multiline table without caption: 58 | 59 | +-------------+------------+--------------+----------------------------+ 60 | | Centered | Left | Right | Default aligned | 61 | | Header | Aligned | Aligned | | 62 | +=============+============+==============+============================+ 63 | | First | row | 12.0 | Example of a row that | 64 | | | | | spans multiple lines. | 65 | +-------------+------------+--------------+----------------------------+ 66 | | Second | row | 5.0 | Here's another one. Note | 67 | | | | | the blank line between | 68 | | | | | rows. | 69 | +-------------+------------+--------------+----------------------------+ 70 | 71 | Table without column headers: 72 | 73 | +-------+-------+-------+-------+ 74 | | 12 | 12 | 12 | 12 | 75 | +-------+-------+-------+-------+ 76 | | 123 | 123 | 123 | 123 | 77 | +-------+-------+-------+-------+ 78 | | 1 | 1 | 1 | 1 | 79 | +-------+-------+-------+-------+ 80 | 81 | Multiline table without column headers: 82 | 83 | +-------------+------------+--------------+----------------------------+ 84 | | First | row | 12.0 | Example of a row that | 85 | | | | | spans multiple lines. | 86 | +-------------+------------+--------------+----------------------------+ 87 | | Second | row | 5.0 | Here's another one. Note | 88 | | | | | the blank line between | 89 | | | | | rows. | 90 | +-------------+------------+--------------+----------------------------+ 91 | 92 | -------------------------------------------------------------------------------- /INSTALL: -------------------------------------------------------------------------------- 1 | % Installing pandoc 2 | 3 | These instructions explain how to install pandoc from source. 4 | Binary packages or ports of pandoc are available for freebsd 5 | and several linux distributions, so check your package manager. 6 | There is also a Windows installer. 7 | 8 | Quick install 9 | ------------- 10 | 11 | 1. Install the [Haskell platform]. This will give you [GHC] and 12 | the [cabal-install] build tool. 13 | 14 | 2. Use `cabal` to install pandoc and its dependencies: 15 | 16 | cabal install pandoc 17 | 18 | This procedure will install the released version of pandoc, 19 | which will be downloaded automatically from HackageDB. 20 | If you want to install a modified or development version 21 | of pandoc instead, switch to the source directory and do 22 | as above, but without the 'pandoc': 23 | 24 | cabal install 25 | 26 | 3. Make sure the `$CABALDIR/bin` directory is in your path. You should 27 | now be able to run `pandoc`: 28 | 29 | pandoc --help 30 | 31 | 4. Make sure the `$CABALDIR/share/man/man1` directory is in your `MANPATH`. 32 | You should now be able to access the `pandoc` man page: 33 | 34 | man pandoc 35 | 36 | [GHC]: http://www.haskell.org/ghc/ 37 | [Haskell platform]: http://hackage.haskell.org/platform/ 38 | [cabal-install]: http://hackage.haskell.org/trac/hackage/wiki/CabalInstall 39 | 40 | Custom install 41 | -------------- 42 | 43 | This is a step-by-step procedure that offers maximal control 44 | over the build and installation. Most users should use the 45 | quick install, but this information may be of use to packagers. 46 | For more details, see the [Cabal User's Guide]. 47 | 48 | 1. Install dependencies: in addition to the [Haskell platform], 49 | you will need [zip-archive], [blaze-html], and [highlighting-kate]. 50 | 51 | 2. Configure: 52 | 53 | runghc Setup.hs configure --prefix=DIR --bindir=DIR --libdir=DIR \ 54 | --datadir=DIR --libsubdir=DIR --datasubdir=DIR --docdir=DIR \ 55 | --htmldir=DIR --program-prefix=PREFIX --program-suffix=SUFFIX \ 56 | --mandir=DIR --flags=FLAGSPEC 57 | 58 | All of the options have sensible defaults that can be overridden 59 | as needed. 60 | 61 | `FLAGSPEC` is a list of Cabal configuration flags, optionally 62 | preceded by a `-` (to force the flag to `false`), and separated 63 | by spaces. Pandoc's flags include: 64 | 65 | - `executable`: build the pandoc executable (default yes) 66 | - `library`: build the pandoc library (default yes) 67 | 68 | So, for example, 69 | 70 | --flags="-executable" 71 | 72 | tells Cabal to build the library but not the executables, 73 | and to compile with syntax highlighting support. 74 | 75 | 3. Build: 76 | 77 | runghc Setup.hs build 78 | 79 | 4. Build API documentation: 80 | 81 | runghc Setup.hs haddock --html-location=URL --hyperlink-source 82 | 83 | 5. Copy the files: 84 | 85 | runghc Setup.hs copy --destdir=PATH 86 | 87 | The default destdir is `/`. 88 | 89 | 6. Register pandoc as a GHC package: 90 | 91 | runghc Setup.hs register 92 | 93 | Package managers may want to use the `--gen-script` option to 94 | generate a script that can be run to register the package at 95 | install time. 96 | 97 | Creating a relocatable Windows binary 98 | ------------------------------------- 99 | 100 | On Windows it is possible to compile pandoc such that it 101 | (and its data files) are "relocatable." You can put the relocatable 102 | binary in any directory (even on a USB drive), and it will look for its 103 | data files there. 104 | 105 | cabal install --flags="embed_data_files" citeproc-hs 106 | cabal install --flags="executable -library" --datasubdir= 107 | 108 | You can find `pandoc.exe` in `dist/build/pandoc`. Copy this wherever 109 | you please, and copy the following data files to the same place: 110 | 111 | README 112 | COPYRIGHT 113 | COPYING 114 | reference.odt 115 | reference.docx 116 | epub.css 117 | default.csl 118 | templates/ 119 | data/ 120 | s5/ 121 | slidy/ 122 | dzslides/ 123 | pcre-license.txt 124 | pcre3.dll 125 | 126 | This is essentially what the binary installer does. 127 | 128 | [zip-archive]: http://hackage.haskell.org/package/zip-archive 129 | [highlighting-kate]: http://hackage.haskell.org/package/highlighting-kate 130 | [blaze-html]: http://hackage.haskell.org/package/blaze-html 131 | [Cabal User's Guide]: http://www.haskell.org/cabal/release/latest/doc/users-guide/builders.html#setup-configure-paths 132 | 133 | -------------------------------------------------------------------------------- /src/Text/Pandoc/XML.hs: -------------------------------------------------------------------------------- 1 | {- 2 | Copyright (C) 2006-2010 John MacFarlane 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, write to the Free Software 16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | -} 18 | 19 | {- | 20 | Module : Text.Pandoc.XML 21 | Copyright : Copyright (C) 2006-2010 John MacFarlane 22 | License : GNU GPL, version 2 or above 23 | 24 | Maintainer : John MacFarlane 25 | Stability : alpha 26 | Portability : portable 27 | 28 | Functions for escaping and formatting XML. 29 | -} 30 | module Text.Pandoc.XML ( stripTags, 31 | escapeCharForXML, 32 | escapeStringForXML, 33 | inTags, 34 | selfClosingTag, 35 | inTagsSimple, 36 | inTagsIndented, 37 | toEntities, 38 | fromEntities ) where 39 | 40 | import Text.Pandoc.Pretty 41 | import Data.Char (ord, isAscii) 42 | import Text.HTML.TagSoup.Entity (lookupEntity) 43 | 44 | -- | Remove everything between <...> 45 | stripTags :: String -> String 46 | stripTags ('<':xs) = 47 | let (_,rest) = break (=='>') xs 48 | in if null rest 49 | then "" 50 | else stripTags (tail rest) -- leave off > 51 | stripTags (x:xs) = x : stripTags xs 52 | stripTags [] = [] 53 | 54 | -- | Escape one character as needed for XML. 55 | escapeCharForXML :: Char -> String 56 | escapeCharForXML x = case x of 57 | '&' -> "&" 58 | '<' -> "<" 59 | '>' -> ">" 60 | '"' -> """ 61 | c -> [c] 62 | 63 | -- | Escape string as needed for XML. Entity references are not preserved. 64 | escapeStringForXML :: String -> String 65 | escapeStringForXML = concatMap escapeCharForXML 66 | 67 | -- | Return a text object with a string of formatted XML attributes. 68 | attributeList :: [(String, String)] -> Doc 69 | attributeList = hcat . map 70 | (\(a, b) -> text (' ' : escapeStringForXML a ++ "=\"" ++ 71 | escapeStringForXML b ++ "\"")) 72 | 73 | -- | Put the supplied contents between start and end tags of tagType, 74 | -- with specified attributes and (if specified) indentation. 75 | inTags:: Bool -> String -> [(String, String)] -> Doc -> Doc 76 | inTags isIndented tagType attribs contents = 77 | let openTag = char '<' <> text tagType <> attributeList attribs <> 78 | char '>' 79 | closeTag = text " text tagType <> char '>' 80 | in if isIndented 81 | then openTag $$ nest 2 contents $$ closeTag 82 | else openTag <> contents <> closeTag 83 | 84 | -- | Return a self-closing tag of tagType with specified attributes 85 | selfClosingTag :: String -> [(String, String)] -> Doc 86 | selfClosingTag tagType attribs = 87 | char '<' <> text tagType <> attributeList attribs <> text " />" 88 | 89 | -- | Put the supplied contents between start and end tags of tagType. 90 | inTagsSimple :: String -> Doc -> Doc 91 | inTagsSimple tagType = inTags False tagType [] 92 | 93 | -- | Put the supplied contents in indented block btw start and end tags. 94 | inTagsIndented :: String -> Doc -> Doc 95 | inTagsIndented tagType = inTags True tagType [] 96 | 97 | -- | Escape all non-ascii characters using numerical entities. 98 | toEntities :: String -> String 99 | toEntities [] = "" 100 | toEntities (c:cs) 101 | | isAscii c = c : toEntities cs 102 | | otherwise = "&#" ++ show (ord c) ++ ";" ++ toEntities cs 103 | 104 | -- Unescapes XML entities 105 | fromEntities :: String -> String 106 | fromEntities ('&':xs) = 107 | case lookupEntity ent of 108 | Just c -> c : fromEntities rest 109 | Nothing -> '&' : fromEntities rest 110 | where (ent, rest) = case break (==';') xs of 111 | (zs,';':ys) -> (zs,ys) 112 | _ -> ("",xs) 113 | fromEntities (x:xs) = x : fromEntities xs 114 | fromEntities [] = [] 115 | -------------------------------------------------------------------------------- /tests/textile-reader.textile: -------------------------------------------------------------------------------- 1 | This is a set of tests for pandoc Textile Reader. Part of it comes 2 | from John Gruber's markdown test suite. 3 | 4 | ----- 5 | 6 | h1. Headers 7 | 8 | h2. Level 2 with an "embeded link":http://www.example.com 9 | 10 | h3. Level 3 with *emphasis* 11 | 12 | h4. Level 4 13 | 14 | h5. Level 5 15 | 16 | h6. Level 6 17 | 18 | 19 | h1. Paragraphs 20 | 21 | Here's a regular paragraph. 22 | 23 | Line breaks are preserved in textile, so you can not wrap your very 24 | long paragraph with your favourite text editor and have it rendered 25 | with no break. 26 | 27 | 28 | Here's one with a bullet. 29 | 30 | * criminey. 31 | 32 | There should be a paragraph break between here 33 | 34 | and here. 35 | 36 | pandoc converts textile. 37 | 38 | h1. Block Quotes 39 | 40 | bq. This is a famous quote from somebody. He had a lot of things to 41 | say, so the text is really really long and spans on multiple lines. 42 | 43 | And a following paragraph. 44 | 45 | h1. Code Blocks 46 | 47 | Code: 48 | 49 |
 50 |     ---- (should be four hyphens)
 51 | 
 52 |     sub status {
 53 |         print "working";
 54 |     }
 55 | 
 56 | 	this code block is indented by one tab
 57 | 
58 | 59 | And: 60 | 61 |
 62 | 		this code block is indented by two tabs
 63 | 
 64 |     These should not be escaped:  \$ \\ \> \[ \{
 65 | 
66 | 67 | bc. Code block with .bc 68 | continued 69 | @@, @. 72 | 73 | h1. Lists 74 | 75 | h2. Unordered 76 | 77 | Asterisks tight: 78 | 79 | * asterisk 1 80 | * asterisk 2 81 | * asterisk 3 82 | 83 | h2. Ordered 84 | 85 | Tight: 86 | 87 | # First 88 | # Second 89 | # Third 90 | 91 | h2. Nested 92 | 93 | * ui 1 94 | ** ui 1.1 95 | ### oi 1.1.1 96 | ### oi 1.1.2 97 | ** ui 1.2 98 | * ui 2 99 | ## oi 2.1 100 | *** ui 2.1.1 101 | *** ui 2.1.2 102 | 103 | h2. Definition List 104 | 105 | - coffee := Hot and black 106 | - tea := Also hot, but a little less black 107 | - milk := 108 | Nourishing beverage for baby cows. 109 | 110 | Cold drink that goes great with cookies.=: 111 | - beer := fresh and bitter 112 | 113 | 114 | h1. Inline Markup 115 | 116 | This is _emphasized_, and so __is this__. 117 | This is *strong*, and so **is this**. 118 | A "*strong link*":http://www.foobar.com. 119 | 120 | _*This is strong and em.*_ 121 | So is *_this_* word and __**that one**__. 122 | -This is strikeout and *strong*- 123 | 124 | Superscripts: a^bc^d a^*hello*^ a^hello there^. 125 | Subscripts: H~2~O, H~23~O, H~many of them~O. 126 | 127 | Dashes : How cool -- automatic dashes. 128 | 129 | Elipses : He thought and thought ... and then thought some more. 130 | 131 | Quotes and apostrophes : "I'd like to thank you" for example. 132 | 133 | 134 | h1. Links 135 | 136 | h2. Explicit 137 | 138 | Just a "url":http://www.url.com 139 | 140 | "Email link":mailto:nobody@nowhere.net 141 | 142 | Automatic linking to http://www.example.com and foobar@example.com. 143 | 144 | "Example":http://www.example.com/: Example of a link followed by a colon. 145 | 146 | h1. Tables 147 | 148 | Textile allows tables with and without headers : 149 | 150 | h2. Without headers 151 | 152 | | name | age | sex | 153 | | joan | 24 | f | 154 | | archie | 29 | m | 155 | | bella | 45 | f | 156 | 157 | and some text following ... 158 | 159 | h2. With headers 160 | 161 | |_. name |_. age |_. sex | 162 | | joan | 24 | f | 163 | | archie | 29 | m | 164 | | bella | 45 | f | 165 | 166 | 167 | 168 | h1. Images 169 | 170 | Textile inline image syntax, like 171 | here !this_is_an_image.png(this is the alt text)! 172 | and here !this_is_an_image.png!. 173 | 174 | h1. Attributes 175 | 176 | h2{color:red}. HTML and CSS attributes are ignored 177 | 178 | as well as *(foo)inline attributes* of %{color:red} all kind% 179 | 180 | p{color:green}. and paragraph attributes, and table attributes. 181 | 182 | table{foo:bar}. 183 | | name | age | sex | 184 | | joan | 24 | f | 185 | 186 | h1. Raw HTML 187 | 188 | However, raw HTML inlines are accepted, as well as : 189 | 190 |
191 | any *Raw HTML Block* with bold 192 |
193 | 194 | Html blocks can be
inlined
as well. 195 | 196 | * this
won't produce raw html blocks
197 | * but this will produce inline html 198 | 199 | Can you prove that 2 < 3 ? 200 | 201 | h1. Acronyms and marks 202 | 203 | PBS(Public Broadcasting System) 204 | 205 | Hi(tm) 206 | 207 | Hi (TM) 208 | 209 | (r) Hi(r) 210 | 211 | Hi(c)2008 (C) 2008 212 | 213 | h1. Footnotes 214 | 215 | A note.[1] 216 | 217 | fn1. The note 218 | is here! 219 | -------------------------------------------------------------------------------- /src/Tests/Readers/Markdown.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE OverloadedStrings, QuasiQuotes #-} 2 | module Tests.Readers.Markdown (tests) where 3 | 4 | import Text.Pandoc.Definition 5 | import Test.Framework 6 | import Tests.Helpers 7 | import Tests.Arbitrary() 8 | import Text.Pandoc.Builder 9 | -- import Text.Pandoc.Shared ( normalize ) 10 | import Text.Pandoc 11 | 12 | markdown :: String -> Pandoc 13 | markdown = readMarkdown defaultParserState{ stateStandalone = True } 14 | 15 | markdownSmart :: String -> Pandoc 16 | markdownSmart = readMarkdown defaultParserState{ stateSmart = True } 17 | 18 | infix 4 =: 19 | (=:) :: ToString c 20 | => String -> (String, c) -> Test 21 | (=:) = test markdown 22 | 23 | {- 24 | p_markdown_round_trip :: Block -> Bool 25 | p_markdown_round_trip b = matches d' d'' 26 | where d' = normalize $ Pandoc (Meta [] [] []) [b] 27 | d'' = normalize 28 | $ readMarkdown defaultParserState{ stateSmart = True } 29 | $ writeMarkdown defaultWriterOptions d' 30 | matches (Pandoc _ [Plain []]) (Pandoc _ []) = True 31 | matches (Pandoc _ [Para []]) (Pandoc _ []) = True 32 | matches (Pandoc _ [Plain xs]) (Pandoc _ [Para xs']) = xs == xs' 33 | matches x y = x == y 34 | -} 35 | 36 | tests :: [Test] 37 | tests = [ testGroup "inline code" 38 | [ "with attribute" =: 39 | "`document.write(\"Hello\");`{.javascript}" 40 | =?> para 41 | (codeWith ("",["javascript"],[]) "document.write(\"Hello\");") 42 | , "with attribute space" =: 43 | "`*` {.haskell .special x=\"7\"}" 44 | =?> para (codeWith ("",["haskell","special"],[("x","7")]) "*") 45 | ] 46 | , testGroup "backslash escapes" 47 | [ "in URL" =: 48 | "[hi](/there\\))" 49 | =?> para (link "/there)" "" "hi") 50 | , "in title" =: 51 | "[hi](/there \"a\\\"a\")" 52 | =?> para (link "/there" "a\"a" "hi") 53 | , "in reference link title" =: 54 | "[hi]\n\n[hi]: /there (a\\)a)" 55 | =?> para (link "/there" "a)a" "hi") 56 | , "in reference link URL" =: 57 | "[hi]\n\n[hi]: /there\\.0" 58 | =?> para (link "/there.0" "" "hi") 59 | ] 60 | , testGroup "smart punctuation" 61 | [ test markdownSmart "quote before ellipses" 62 | ("'...hi'" 63 | =?> para (singleQuoted ("…hi"))) 64 | , test markdownSmart "apostrophe before emph" 65 | ("D'oh! A l'*aide*!" 66 | =?> para ("D’oh! A l’" <> emph "aide" <> "!")) 67 | , test markdownSmart "apostrophe in French" 68 | ("À l'arrivée de la guerre, le thème de l'«impossibilité du socialisme»" 69 | =?> para ("À l’arrivée de la guerre, le thème de l’«impossibilité du socialisme»")) 70 | ] 71 | , testGroup "mixed emphasis and strong" 72 | [ "emph and strong emph alternating" =: 73 | "*xxx* ***xxx*** xxx\n*xxx* ***xxx*** xxx" 74 | =?> para (emph "xxx" <> space <> strong (emph "xxx") <> 75 | space <> "xxx" <> space <> 76 | emph "xxx" <> space <> strong (emph "xxx") <> 77 | space <> "xxx") 78 | , "emph with spaced strong" =: 79 | "*x **xx** x*" 80 | =?> para (emph ("x" <> space <> strong "xx" <> space <> "x")) 81 | ] 82 | , testGroup "footnotes" 83 | [ "indent followed by newline and flush-left text" =: 84 | "[^1]\n\n[^1]: my note\n\n \nnot in note\n" 85 | =?> para (note (para "my note")) <> para "not in note" 86 | , "indent followed by newline and indented text" =: 87 | "[^1]\n\n[^1]: my note\n \n in note\n" 88 | =?> para (note (para "my note" <> para "in note")) 89 | , "recursive note" =: 90 | "[^1]\n\n[^1]: See [^1]\n" 91 | =?> para (note (para "See [^1]")) 92 | ] 93 | , testGroup "lhs" 94 | [ test (readMarkdown defaultParserState{stateLiterateHaskell = True}) 95 | "inverse bird tracks and html" $ 96 | "> a\n\n< b\n\n
\n" 97 | =?> codeBlockWith ("",["sourceCode","literate","haskell"],[]) "a" 98 | <> 99 | codeBlockWith ("",["sourceCode","haskell"],[]) "b" 100 | <> 101 | rawBlock "html" "
\n\n" 102 | ] 103 | -- the round-trip properties frequently fail 104 | -- , testGroup "round trip" 105 | -- [ property "p_markdown_round_trip" p_markdown_round_trip 106 | -- ] 107 | ] 108 | -------------------------------------------------------------------------------- /tests/MarkdownTest_1.0.3/MarkdownTest.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | # 4 | # MarkdownTester -- Run tests for Markdown implementations 5 | # 6 | # Copyright (c) 2004-2005 John Gruber 7 | # 8 | # 9 | 10 | use strict; 11 | use warnings; 12 | use Getopt::Long; 13 | use Benchmark; 14 | 15 | our $VERSION = '1.0.2'; 16 | # Sat 24 Dec 2005 17 | 18 | my $time_start = new Benchmark; 19 | my $test_dir = "Tests"; 20 | my $script = "./Markdown.pl"; 21 | my $use_tidy = 0; 22 | my ($flag_version); 23 | 24 | GetOptions ( 25 | "script=s" => \$script, 26 | "testdir=s" => \$test_dir, 27 | "tidy" => \$use_tidy, 28 | "version" => \$flag_version, 29 | ); 30 | 31 | if($flag_version) { 32 | my $progname = $0; 33 | $progname =~ s{.*/}{}; 34 | die "$progname version $VERSION\n"; 35 | } 36 | 37 | unless (-d $test_dir) { die "'$test_dir' is not a directory.\n"; } 38 | unless (-f $script) { die "$script does not exist.\n"; } 39 | unless (-x $script) { die "$script is not executable.\n"; } 40 | 41 | my $tests_passed = 0; 42 | my $tests_failed = 0; 43 | 44 | TEST: 45 | foreach my $testfile (glob "$test_dir/*.text") { 46 | my $testname = $testfile; 47 | $testname =~ s{.*/(.+)\.text$}{$1}i; 48 | print "$testname ... "; 49 | 50 | # Look for a corresponding .html file for each .text file: 51 | my $resultfile = $testfile; 52 | $resultfile =~ s{\.text$}{\.html}i; 53 | unless (-f $resultfile) { 54 | print "'$resultfile' does not exist.\n\n"; 55 | next TEST; 56 | } 57 | 58 | # open(TEST, $testfile) || die("Can't open testfile: $!"); 59 | open(RESULT, $resultfile) || die("Can't open resultfile: $!"); 60 | undef $/; 61 | # my $t_input = ; 62 | my $t_result = ; 63 | 64 | my $t_output = `'$script' '$testfile'`; 65 | 66 | # Normalize the output and expected result strings: 67 | $t_result =~ s/\s+\z//; # trim trailing whitespace 68 | $t_output =~ s/\s+\z//; # trim trailing whitespace 69 | if ($use_tidy) { 70 | # Escape the strings, pass them through to CLI tidy tool for tag-level equivalency 71 | $t_result =~ s{'}{'\\''}g; # escape ' chars for shell 72 | $t_output =~ s{'}{'\\''}g; 73 | $t_result = `echo '$t_result' | tidy --show-body-only 1 --quiet 1 --show-warnings 0`; 74 | $t_output = `echo '$t_output' | tidy --show-body-only 1 --quiet 1 --show-warnings 0`; 75 | } 76 | 77 | if ($t_output eq $t_result) { 78 | print "OK\n"; 79 | $tests_passed++; 80 | } 81 | else { 82 | print "FAILED\n\n"; 83 | # This part added by JM to print diffs 84 | open(OUT, '>tmp1') or die $!; 85 | print OUT $t_output or die $!; 86 | open(RES, '>tmp2') or die $!; 87 | print RES $t_result or die $!; 88 | print `diff tmp1 tmp2`; 89 | close RES; 90 | close OUT; 91 | print "\n"; 92 | `rm tmp?`; 93 | # End of added part 94 | $tests_failed++; 95 | } 96 | } 97 | 98 | print "\n\n"; 99 | print "$tests_passed passed; $tests_failed failed.\n"; 100 | 101 | my $time_end = new Benchmark; 102 | my $time_diff = timediff($time_end, $time_start); 103 | print "Benchmark: ", timestr($time_diff), "\n"; 104 | 105 | 106 | __END__ 107 | 108 | =pod 109 | 110 | =head1 NAME 111 | 112 | B 113 | 114 | 115 | =head1 SYNOPSIS 116 | 117 | B [ B<--options> ] [ I ... ] 118 | 119 | 120 | =head1 DESCRIPTION 121 | 122 | 123 | =head1 OPTIONS 124 | 125 | Use "--" to end switch parsing. For example, to open a file named "-z", use: 126 | 127 | MarkdownTest.pl -- -z 128 | 129 | =over 4 130 | 131 | =item B<--script> 132 | 133 | Specify the path to the Markdown script to test. Defaults to 134 | "./Markdown.pl". Example: 135 | 136 | ./MarkdownTest.pl --script ./PHP-Markdown/php-markdown 137 | 138 | =item B<--testdir> 139 | 140 | Specify the path to a directory containing test data. Defaults to "Tests". 141 | 142 | =item B<--tidy> 143 | 144 | Flag to turn on using the command line 'tidy' tool to normalize HTML 145 | output before comparing script output to the expected test result. 146 | Assumes that the 'tidy' command is available in your PATH. Defaults to 147 | off. 148 | 149 | =back 150 | 151 | 152 | 153 | =head1 BUGS 154 | 155 | 156 | 157 | =head1 VERSION HISTORY 158 | 159 | 1.0 Mon 13 Dec 2004-2005 160 | 161 | 1.0.1 Mon 19 Sep 2005 162 | 163 | + Better handling of case when foo.text exists, but foo.html doesn't. 164 | It now prints a message and moves on, rather than dying. 165 | 166 | 167 | =head1 COPYRIGHT AND LICENSE 168 | 169 | Copyright (c) 2004-2005 John Gruber 170 | 171 | All rights reserved. 172 | 173 | This is free software; you may redistribute it and/or modify it under 174 | the same terms as Perl itself. 175 | 176 | =cut 177 | -------------------------------------------------------------------------------- /Setup.hs: -------------------------------------------------------------------------------- 1 | import Distribution.Simple 2 | import Distribution.Simple.Setup 3 | (copyDest, copyVerbosity, fromFlag, installVerbosity, BuildFlags(..)) 4 | import Distribution.PackageDescription 5 | (PackageDescription(..), Executable(..), BuildInfo(..)) 6 | import Distribution.Simple.LocalBuildInfo 7 | (LocalBuildInfo(..), absoluteInstallDirs) 8 | import Distribution.Verbosity ( Verbosity, silent ) 9 | import Distribution.Simple.GHC (ghcPackageDbOptions) 10 | import Distribution.Simple.InstallDirs (mandir, bindir, CopyDest (NoCopyDest)) 11 | import Distribution.Simple.Utils (installOrdinaryFiles) 12 | import Control.Exception ( bracket_ ) 13 | import Control.Monad ( unless ) 14 | import System.Process ( rawSystem, runCommand, waitForProcess ) 15 | import System.FilePath ( () ) 16 | import System.Directory 17 | import System.Exit 18 | import System.Time 19 | import System.IO.Error ( isDoesNotExistError ) 20 | import Data.Maybe ( catMaybes ) 21 | import Data.List ( (\\) ) 22 | 23 | main :: IO () 24 | main = do 25 | defaultMainWithHooks $ simpleUserHooks { 26 | runTests = runTestSuite 27 | , postBuild = makeManPages 28 | , postCopy = \ _ flags pkg lbi -> 29 | installManpages pkg lbi (fromFlag $ copyVerbosity flags) 30 | (fromFlag $ copyDest flags) 31 | , postInst = \ _ flags pkg lbi -> 32 | installManpages pkg lbi (fromFlag $ installVerbosity flags) NoCopyDest 33 | } 34 | exitWith ExitSuccess 35 | 36 | -- | Run test suite. 37 | runTestSuite :: Args -> Bool -> PackageDescription -> LocalBuildInfo -> IO a 38 | runTestSuite args _ pkg lbi = do 39 | let testDir = buildDir lbi "test-pandoc" 40 | testDir' <- canonicalizePath testDir 41 | let testArgs = "--timeout=5" : concatMap (\arg -> ["-t",arg]) args 42 | if any id [buildable (buildInfo exe) | exe <- executables pkg, exeName exe == "test-pandoc"] 43 | then inDirectory "tests" $ rawSystem (testDir' "test-pandoc") testArgs >>= exitWith 44 | else do 45 | putStrLn "Build pandoc with the 'tests' flag to run tests" 46 | exitWith $ ExitFailure 3 47 | 48 | -- | Build man pages from markdown sources in man/ 49 | makeManPages :: Args -> BuildFlags -> PackageDescription -> LocalBuildInfo -> IO () 50 | makeManPages _ flags _ lbi = do 51 | ds1 <- modifiedDependencies (manDir "man1" "pandoc.1") 52 | ["README", manDir "man1" "pandoc.1.template"] 53 | ds2 <- modifiedDependencies (manDir "man5" "pandoc_markdown.5") 54 | ["README", manDir "man5" "pandoc_markdown.5.template"] 55 | 56 | let distPref = fromFlag (buildDistPref flags) 57 | packageDB = 58 | withPackageDB lbi 59 | ++ [SpecificPackageDB $ distPref "package.conf.inplace"] 60 | 61 | verbosity = fromFlag $ buildVerbosity flags 62 | 63 | args = makeGhcArgs (ghcPackageDbOptions packageDB) 64 | ++ ["MakeManPage.hs"] 65 | args' = if verbosity == silent 66 | then args 67 | else args ++ ["--verbose"] 68 | -- Don't run MakeManPage.hs unless we have to 69 | unless (null ds1 && null ds2) $ do 70 | rawSystem "runghc" args' >>= exitWith 71 | 72 | -- format arguments to runghc that we wish to pass to ghc 73 | -- normally runghc gets it right, unless the argument does 74 | -- not begin with a '-' charecter, so we need to give clear 75 | -- directions. 76 | makeGhcArgs :: [String] -> [String] 77 | makeGhcArgs = map ("--ghc-arg="++) 78 | 79 | manpages :: [FilePath] 80 | manpages = ["man1" "pandoc.1" 81 | ,"man5" "pandoc_markdown.5"] 82 | 83 | manDir :: FilePath 84 | manDir = "man" 85 | 86 | installManpages :: PackageDescription -> LocalBuildInfo 87 | -> Verbosity -> CopyDest -> IO () 88 | installManpages pkg lbi verbosity copy = 89 | installOrdinaryFiles verbosity (mandir (absoluteInstallDirs pkg lbi copy)) 90 | (zip (repeat manDir) manpages) 91 | 92 | -- | Returns a list of 'dependencies' that have been modified after 'file'. 93 | modifiedDependencies :: FilePath -> [FilePath] -> IO [FilePath] 94 | modifiedDependencies file dependencies = do 95 | fileModTime <- catch (getModificationTime file) $ 96 | \e -> if isDoesNotExistError e 97 | then return (TOD 0 0) -- the minimum ClockTime 98 | else ioError e 99 | depModTimes <- mapM getModificationTime dependencies 100 | let modified = zipWith (\dep time -> if time > fileModTime then Just dep else Nothing) dependencies depModTimes 101 | return $ catMaybes modified 102 | 103 | -- | Perform an IO action in a directory. 104 | inDirectory :: FilePath -> IO a -> IO a 105 | inDirectory dir action = do 106 | oldDir <- getCurrentDirectory 107 | bracket_ (setCurrentDirectory dir) (setCurrentDirectory oldDir) action 108 | 109 | -------------------------------------------------------------------------------- /tests/tables.html: -------------------------------------------------------------------------------- 1 |

Simple table with caption:

2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 |
Demonstration of simple table syntax.
RightLeftCenterDefault
12121212
123123123123
1111
33 |

Simple table without caption:

34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 |
RightLeftCenterDefault
12121212
123123123123
1111
64 |

Simple table indented two spaces:

65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 |
Demonstration of simple table syntax.
RightLeftCenterDefault
12121212
123123123123
1111
96 |

Multiline table with caption:

97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 |
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.
126 |

Multiline table without caption:

127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 |
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.
155 |

Table without column headers:

156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 |
12121212
123123123123
1111
178 |

Multiline table without column headers:

179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 |
Firstrow12.0Example of a row that spans multiple lines.
Secondrow5.0Here's another one. Note the blank line between rows.
199 | -------------------------------------------------------------------------------- /tests/tables.native: -------------------------------------------------------------------------------- 1 | [Para [Str "Simple",Space,Str "table",Space,Str "with",Space,Str "caption",Str ":"] 2 | ,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] 3 | [[Plain [Str "Right"]] 4 | ,[Plain [Str "Left"]] 5 | ,[Plain [Str "Center"]] 6 | ,[Plain [Str "Default"]]] 7 | [[[Plain [Str "12"]] 8 | ,[Plain [Str "12"]] 9 | ,[Plain [Str "12"]] 10 | ,[Plain [Str "12"]]] 11 | ,[[Plain [Str "123"]] 12 | ,[Plain [Str "123"]] 13 | ,[Plain [Str "123"]] 14 | ,[Plain [Str "123"]]] 15 | ,[[Plain [Str "1"]] 16 | ,[Plain [Str "1"]] 17 | ,[Plain [Str "1"]] 18 | ,[Plain [Str "1"]]]] 19 | ,Para [Str "Simple",Space,Str "table",Space,Str "without",Space,Str "caption",Str ":"] 20 | ,Table [] [AlignRight,AlignLeft,AlignCenter,AlignDefault] [0.0,0.0,0.0,0.0] 21 | [[Plain [Str "Right"]] 22 | ,[Plain [Str "Left"]] 23 | ,[Plain [Str "Center"]] 24 | ,[Plain [Str "Default"]]] 25 | [[[Plain [Str "12"]] 26 | ,[Plain [Str "12"]] 27 | ,[Plain [Str "12"]] 28 | ,[Plain [Str "12"]]] 29 | ,[[Plain [Str "123"]] 30 | ,[Plain [Str "123"]] 31 | ,[Plain [Str "123"]] 32 | ,[Plain [Str "123"]]] 33 | ,[[Plain [Str "1"]] 34 | ,[Plain [Str "1"]] 35 | ,[Plain [Str "1"]] 36 | ,[Plain [Str "1"]]]] 37 | ,Para [Str "Simple",Space,Str "table",Space,Str "indented",Space,Str "two",Space,Str "spaces",Str ":"] 38 | ,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] 39 | [[Plain [Str "Right"]] 40 | ,[Plain [Str "Left"]] 41 | ,[Plain [Str "Center"]] 42 | ,[Plain [Str "Default"]]] 43 | [[[Plain [Str "12"]] 44 | ,[Plain [Str "12"]] 45 | ,[Plain [Str "12"]] 46 | ,[Plain [Str "12"]]] 47 | ,[[Plain [Str "123"]] 48 | ,[Plain [Str "123"]] 49 | ,[Plain [Str "123"]] 50 | ,[Plain [Str "123"]]] 51 | ,[[Plain [Str "1"]] 52 | ,[Plain [Str "1"]] 53 | ,[Plain [Str "1"]] 54 | ,[Plain [Str "1"]]]] 55 | ,Para [Str "Multiline",Space,Str "table",Space,Str "with",Space,Str "caption",Str ":"] 56 | ,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] 57 | [[Plain [Str "Centered",Space,Str "Header"]] 58 | ,[Plain [Str "Left",Space,Str "Aligned"]] 59 | ,[Plain [Str "Right",Space,Str "Aligned"]] 60 | ,[Plain [Str "Default",Space,Str "aligned"]]] 61 | [[[Plain [Str "First"]] 62 | ,[Plain [Str "row"]] 63 | ,[Plain [Str "12",Str ".",Str "0"]] 64 | ,[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 "."]]] 65 | ,[[Plain [Str "Second"]] 66 | ,[Plain [Str "row"]] 67 | ,[Plain [Str "5",Str ".",Str "0"]] 68 | ,[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 "."]]]] 69 | ,Para [Str "Multiline",Space,Str "table",Space,Str "without",Space,Str "caption",Str ":"] 70 | ,Table [] [AlignCenter,AlignLeft,AlignRight,AlignLeft] [0.15,0.1375,0.1625,0.3375] 71 | [[Plain [Str "Centered",Space,Str "Header"]] 72 | ,[Plain [Str "Left",Space,Str "Aligned"]] 73 | ,[Plain [Str "Right",Space,Str "Aligned"]] 74 | ,[Plain [Str "Default",Space,Str "aligned"]]] 75 | [[[Plain [Str "First"]] 76 | ,[Plain [Str "row"]] 77 | ,[Plain [Str "12",Str ".",Str "0"]] 78 | ,[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 "."]]] 79 | ,[[Plain [Str "Second"]] 80 | ,[Plain [Str "row"]] 81 | ,[Plain [Str "5",Str ".",Str "0"]] 82 | ,[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 "."]]]] 83 | ,Para [Str "Table",Space,Str "without",Space,Str "column",Space,Str "headers",Str ":"] 84 | ,Table [] [AlignRight,AlignLeft,AlignCenter,AlignRight] [0.0,0.0,0.0,0.0] 85 | [[] 86 | ,[] 87 | ,[] 88 | ,[]] 89 | [[[Plain [Str "12"]] 90 | ,[Plain [Str "12"]] 91 | ,[Plain [Str "12"]] 92 | ,[Plain [Str "12"]]] 93 | ,[[Plain [Str "123"]] 94 | ,[Plain [Str "123"]] 95 | ,[Plain [Str "123"]] 96 | ,[Plain [Str "123"]]] 97 | ,[[Plain [Str "1"]] 98 | ,[Plain [Str "1"]] 99 | ,[Plain [Str "1"]] 100 | ,[Plain [Str "1"]]]] 101 | ,Para [Str "Multiline",Space,Str "table",Space,Str "without",Space,Str "column",Space,Str "headers",Str ":"] 102 | ,Table [] [AlignCenter,AlignLeft,AlignRight,AlignDefault] [0.15,0.1375,0.1625,0.3375] 103 | [[] 104 | ,[] 105 | ,[] 106 | ,[]] 107 | [[[Plain [Str "First"]] 108 | ,[Plain [Str "row"]] 109 | ,[Plain [Str "12",Str ".",Str "0"]] 110 | ,[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 "."]]] 111 | ,[[Plain [Str "Second"]] 112 | ,[Plain [Str "row"]] 113 | ,[Plain [Str "5",Str ".",Str "0"]] 114 | ,[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 "."]]]]] 115 | -------------------------------------------------------------------------------- /tests/tables.textile: -------------------------------------------------------------------------------- 1 | Simple table with caption: 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 |
Demonstration of simple table syntax.
RightLeftCenterDefault
12121212
123123123123
1111
34 | 35 | Simple table without caption: 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 |
RightLeftCenterDefault
12121212
123123123123
1111
67 | 68 | Simple table indented two spaces: 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 |
Demonstration of simple table syntax.
RightLeftCenterDefault
12121212
123123123123
1111
101 | 102 | Multiline table with caption: 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 |
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.
133 | 134 | Multiline table without caption: 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 |
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.
164 | 165 | Table without column headers: 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 |
12121212
123123123123
1111
189 | 190 | Multiline table without column headers: 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 |
Firstrow12.0Example of a row that spans multiple lines.
Secondrow5.0Here's another one. Note the blank line between rows.
212 | 213 | -------------------------------------------------------------------------------- /tests/tables.mediawiki: -------------------------------------------------------------------------------- 1 | Simple table with caption: 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 |
Demonstration of simple table syntax.
RightLeftCenterDefault
12121212
123123123123
1111
34 | 35 | Simple table without caption: 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 |
RightLeftCenterDefault
12121212
123123123123
1111
67 | 68 | Simple table indented two spaces: 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 |
Demonstration of simple table syntax.
RightLeftCenterDefault
12121212
123123123123
1111
101 | 102 | Multiline table with caption: 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 |
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.
133 | 134 | Multiline table without caption: 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 |
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.
164 | 165 | Table without column headers: 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 |
12121212
123123123123
1111
189 | 190 | Multiline table without column headers: 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 |
Firstrow12.0Example of a row that spans multiple lines.
Secondrow5.0Here's another one. Note the blank line between rows.
212 | 213 | -------------------------------------------------------------------------------- /src/Text/Pandoc/Readers/TeXMath.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE CPP #-} 2 | #if __GLASGOW_HASKELL__ >= 702 3 | {-# LANGUAGE Trustworthy #-} 4 | #endif 5 | {- 6 | Copyright (C) 2007-2010 John MacFarlane 7 | 8 | This program is free software; you can redistribute it and/or modify 9 | it under the terms of the GNU General Public License as published by 10 | the Free Software Foundation; either version 2 of the License, or 11 | (at your option) any later version. 12 | 13 | This program is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU General Public License for more details. 17 | 18 | You should have received a copy of the GNU General Public License 19 | along with this program; if not, write to the Free Software 20 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 | -} 22 | 23 | {- | 24 | Module : Text.Pandoc.Readers.TeXMath 25 | Copyright : Copyright (C) 2007-2010 John MacFarlane 26 | License : GNU GPL, version 2 or above 27 | 28 | Maintainer : John MacFarlane 29 | Stability : alpha 30 | Portability : portable 31 | 32 | Conversion of TeX math to a list of 'Pandoc' inline elements. 33 | -} 34 | module Text.Pandoc.Readers.TeXMath ( readTeXMath ) where 35 | 36 | import Text.Pandoc.Definition 37 | import Text.TeXMath.Types 38 | import Text.TeXMath.Parser 39 | 40 | -- | Converts a raw TeX math formula to a list of 'Pandoc' inlines. 41 | -- Defaults to raw formula between @$@ characters if entire formula 42 | -- can't be converted. 43 | readTeXMath :: String -- ^ String to parse (assumes @'\n'@ line endings) 44 | -> [Inline] 45 | readTeXMath inp = case texMathToPandoc inp of 46 | Left _ -> [Str ("$" ++ inp ++ "$")] 47 | Right res -> res 48 | 49 | texMathToPandoc :: String -> Either String [Inline] 50 | texMathToPandoc inp = inp `seq` 51 | case parseFormula inp of 52 | Left err -> Left err 53 | Right exps -> case expsToInlines exps of 54 | Nothing -> Left "Formula too complex for [Inline]" 55 | Just r -> Right r 56 | 57 | expsToInlines :: [Exp] -> Maybe [Inline] 58 | expsToInlines xs = do 59 | res <- mapM expToInlines xs 60 | return (concat res) 61 | 62 | expToInlines :: Exp -> Maybe [Inline] 63 | expToInlines (ENumber s) = Just [Str s] 64 | expToInlines (EIdentifier s) = Just [Emph [Str s]] 65 | expToInlines (EMathOperator s) = Just [Str s] 66 | expToInlines (ESymbol t s) = Just $ addSpace t (Str s) 67 | where addSpace Op x = [x, thinspace] 68 | addSpace Bin x = [medspace, x, medspace] 69 | addSpace Rel x = [widespace, x, widespace] 70 | addSpace Pun x = [x, thinspace] 71 | addSpace _ x = [x] 72 | thinspace = Str "\x2006" 73 | medspace = Str "\x2005" 74 | widespace = Str "\x2004" 75 | expToInlines (EStretchy x) = expToInlines x 76 | expToInlines (EDelimited start end xs) = do 77 | xs' <- mapM expToInlines xs 78 | return $ [Str start] ++ concat xs' ++ [Str end] 79 | expToInlines (EGrouped xs) = expsToInlines xs 80 | expToInlines (ESpace "0.167em") = Just [Str "\x2009"] 81 | expToInlines (ESpace "0.222em") = Just [Str "\x2005"] 82 | expToInlines (ESpace "0.278em") = Just [Str "\x2004"] 83 | expToInlines (ESpace "0.333em") = Just [Str "\x2004"] 84 | expToInlines (ESpace "1em") = Just [Str "\x2001"] 85 | expToInlines (ESpace "2em") = Just [Str "\x2001\x2001"] 86 | expToInlines (ESpace _) = Just [Str " "] 87 | expToInlines (EBinary _ _ _) = Nothing 88 | expToInlines (ESub x y) = do 89 | x' <- expToInlines x 90 | y' <- expToInlines y 91 | return $ x' ++ [Subscript y'] 92 | expToInlines (ESuper x y) = do 93 | x' <- expToInlines x 94 | y' <- expToInlines y 95 | return $ x' ++ [Superscript y'] 96 | expToInlines (ESubsup x y z) = do 97 | x' <- expToInlines x 98 | y' <- expToInlines y 99 | z' <- expToInlines z 100 | return $ x' ++ [Subscript y'] ++ [Superscript z'] 101 | expToInlines (EDown x y) = expToInlines (ESub x y) 102 | expToInlines (EUp x y) = expToInlines (ESuper x y) 103 | expToInlines (EDownup x y z) = expToInlines (ESubsup x y z) 104 | expToInlines (EText TextNormal x) = Just [Str x] 105 | expToInlines (EText TextBold x) = Just [Strong [Str x]] 106 | expToInlines (EText TextMonospace x) = Just [Code nullAttr x] 107 | expToInlines (EText TextItalic x) = Just [Emph [Str x]] 108 | expToInlines (EText _ x) = Just [Str x] 109 | expToInlines (EOver (EGrouped [EIdentifier [c]]) (ESymbol Accent [accent])) = 110 | case accent of 111 | '\x203E' -> Just [Emph [Str [c,'\x0304']]] -- bar 112 | '\x00B4' -> Just [Emph [Str [c,'\x0301']]] -- acute 113 | '\x0060' -> Just [Emph [Str [c,'\x0300']]] -- grave 114 | '\x02D8' -> Just [Emph [Str [c,'\x0306']]] -- breve 115 | '\x02C7' -> Just [Emph [Str [c,'\x030C']]] -- check 116 | '.' -> Just [Emph [Str [c,'\x0307']]] -- dot 117 | '\x00B0' -> Just [Emph [Str [c,'\x030A']]] -- ring 118 | '\x20D7' -> Just [Emph [Str [c,'\x20D7']]] -- arrow right 119 | '\x20D6' -> Just [Emph [Str [c,'\x20D6']]] -- arrow left 120 | '\x005E' -> Just [Emph [Str [c,'\x0302']]] -- hat 121 | '\x0302' -> Just [Emph [Str [c,'\x0302']]] -- hat 122 | '~' -> Just [Emph [Str [c,'\x0303']]] -- tilde 123 | _ -> Nothing 124 | expToInlines _ = Nothing 125 | 126 | 127 | --------------------------------------------------------------------------------