git.iko.soy/typeable/pandoc
on master help sign in
Added tests.

+ Added tables.org and writer.org to tests. + Added org.template to templates. + Changed RunTests.hs as required. + Minor changes to Org writer.

commit4d48abcb12f11e05091669c462c2ac8248f4c7aa authorPuneeth Chaganti <punchagan@gmail.com> dateSat 4 Dec 2010, 23:49 (16 years ago) parent921e2b6
5 files changed+961−1
src/Text/Pandoc/Writers/Org.hs+1−1 templates/org.template+22 tests/RunTests.hs+1 tests/tables.org+51 tests/writer.org+886
src/Text/Pandoc/Writers/Org.hs+1−1
@@ -107,7 +107,7 @@ titleToOrg [] = return empty
107107titleToOrg lst = do
108108 contents <- inlineListToOrg lst
109109 let titleName = text "#+TITLE: "
110− return $ titleName $+$ contents
110+ return $ titleName <> contents
111111
112112-- | Convert Pandoc block element to Org.
113113blockToOrg :: Block -- ^ Block element
templates/org.templatenew file+22
@@ -0,0 +1,22 @@
1+$if(title)$
2+$title$
3+
4+$endif$
5+#+AUTHOR: $for(author)$$author$$sep$; $endfor$
6+$if(date)$
7+#+DATE: $date$
8+
9+$endif$
10+$for(header-includes)$
11+$header-includes$
12+
13+$endfor$
14+$for(include-before)$
15+$include-before$
16+
17+$endfor$
18+$body$
19+$for(include-after)$
20+
21+$include-after$
22+$endfor$
tests/RunTests.hs+1
@@ -62,6 +62,7 @@ writerFormats = [ "native"
6262 , "mediawiki"
6363 , "textile"
6464 , "rtf"
65+ , "org"
6566 ]
6667
6768lhsWriterFormats :: [String]
tests/tables.orgnew file+51
@@ -0,0 +1,51 @@
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. |
tests/writer.orgnew file+886
@@ -0,0 +1,886 @@
1+#+TITLE: Pandoc Test Suite
2+
3+#+AUTHOR: John MacFarlane; Anonymous
4+#+DATE: July 17, 2006
5+
6+This is a set of tests for pandoc. Most of them are adapted from
7+John Gruber's markdown test suite.
8+
9+--------------
10+
11+* Headers
12+
13+** Level 2 with an [[/url][embedded link]]
14+
15+*** Level 3 with /emphasis/
16+
17+**** Level 4
18+
19+***** Level 5
20+
21+* Level 1
22+
23+** Level 2 with /emphasis/
24+
25+*** Level 3
26+
27+with no blank line
28+
29+** Level 2
30+
31+with no blank line
32+
33+--------------
34+
35+* Paragraphs
36+
37+Here's a regular paragraph.
38+
39+In Markdown 1.0.0 and earlier. Version 8. This line turns into a
40+list item. Because a hard-wrapped line in the middle of a paragraph
41+looked like a list item.
42+
43+Here's one with a bullet. * criminey.
44+
45+There should be a hard line break
46+here.
47+
48+--------------
49+
50+* Block Quotes
51+
52+E-mail style:
53+
54+
55+#+BEGIN_QUOTE
56+
57+ This is a block quote. It is pretty short.
58+
59+
60+#+END_QUOTE
61+
62+
63+#+BEGIN_QUOTE
64+
65+ Code in a block quote:
66+
67+ #+BEGIN_EXAMPLE
68+ sub status {
69+ print "working";
70+ }
71+ #+END_EXAMPLE
72+ A list:
73+
74+
75+ 1. item one
76+ 2. item two
77+
78+ Nested block quotes:
79+
80+
81+#+BEGIN_QUOTE
82+
83+ nested
84+
85+
86+#+END_QUOTE
87+
88+
89+#+BEGIN_QUOTE
90+
91+ nested
92+
93+
94+#+END_QUOTE
95+
96+
97+#+END_QUOTE
98+
99+This should not be a block quote: 2 > 1.
100+
101+And a following paragraph.
102+
103+--------------
104+
105+* Code Blocks
106+
107+Code:
108+
109+#+BEGIN_EXAMPLE
110+ ---- (should be four hyphens)
111+
112+ sub status {
113+ print "working";
114+ }
115+
116+ this code block is indented by one tab
117+#+END_EXAMPLE
118+And:
119+
120+#+BEGIN_EXAMPLE
121+ this code block is indented by two tabs
122+
123+ These should not be escaped: \$ \\ \> \[ \{
124+#+END_EXAMPLE
125+--------------
126+
127+* Lists
128+
129+** Unordered
130+
131+Asterisks tight:
132+
133+
134+- asterisk 1
135+- asterisk 2
136+- asterisk 3
137+
138+Asterisks loose:
139+
140+
141+- asterisk 1
142+
143+- asterisk 2
144+
145+- asterisk 3
146+
147+
148+Pluses tight:
149+
150+
151+- Plus 1
152+- Plus 2
153+- Plus 3
154+
155+Pluses loose:
156+
157+
158+- Plus 1
159+
160+- Plus 2
161+
162+- Plus 3
163+
164+
165+Minuses tight:
166+
167+
168+- Minus 1
169+- Minus 2
170+- Minus 3
171+
172+Minuses loose:
173+
174+
175+- Minus 1
176+
177+- Minus 2
178+
179+- Minus 3
180+
181+
182+** Ordered
183+
184+Tight:
185+
186+
187+1. First
188+2. Second
189+3. Third
190+
191+and:
192+
193+
194+1. One
195+2. Two
196+3. Three
197+
198+Loose using tabs:
199+
200+
201+1. First
202+
203+2. Second
204+
205+3. Third
206+
207+
208+and using spaces:
209+
210+
211+1. One
212+
213+2. Two
214+
215+3. Three
216+
217+
218+Multiple paragraphs:
219+
220+
221+1. Item 1, graf one.
222+
223+ Item 1. graf two. The quick brown fox jumped over the lazy dog's
224+ back.
225+
226+2. Item 2.
227+
228+3. Item 3.
229+
230+
231+** Nested
232+
233+
234+- Tab
235+
236+ - Tab
237+
238+ - Tab
239+
240+
241+
242+Here's another:
243+
244+
245+1. First
246+2. Second:
247+
248+ - Fee
249+ - Fie
250+ - Foe
251+
252+3. Third
253+
254+Same thing but with paragraphs:
255+
256+
257+1. First
258+
259+2. Second:
260+
261+
262+ - Fee
263+ - Fie
264+ - Foe
265+
266+3. Third
267+
268+
269+** Tabs and spaces
270+
271+
272+- this is a list item indented with tabs
273+
274+- this is a list item indented with spaces
275+
276+
277+ - this is an example list item indented with tabs
278+
279+ - this is an example list item indented with spaces
280+
281+
282+
283+** Fancy list markers
284+
285+
286+(2) begins with 2
287+(3) and now 3
288+
289+ with a continuation
290+
291+
292+ iv. sublist with roman numerals, starting with 4
293+ v. more items
294+
295+ (A) a subsublist
296+ (B) a subsublist
297+
298+
299+
300+Nesting:
301+
302+
303+A. Upper Alpha
304+
305+ I. Upper Roman.
306+
307+ (6) Decimal start with 6
308+
309+ c) Lower alpha with paren
310+
311+
312+
313+
314+Autonumbering:
315+
316+
317+1. Autonumber.
318+2. More.
319+
320+ 1. Nested.
321+
322+
323+Should not be a list item:
324+
325+M.A. 2007
326+
327+B. Williams
328+
329+--------------
330+
331+* Definition Lists
332+
333+Tight using spaces:
334+
335+- apple :: red fruit
336+- orange :: orange fruit
337+- banana :: yellow fruit
338+
339+Tight using tabs:
340+
341+- apple :: red fruit
342+- orange :: orange fruit
343+- banana :: yellow fruit
344+
345+Loose:
346+
347+- apple :: red fruit
348+
349+- orange :: orange fruit
350+
351+- banana :: yellow fruit
352+
353+
354+Multiple blocks with italics:
355+
356+- /apple/ :: red fruit
357+
358+ contains seeds, crisp, pleasant to taste
359+
360+- /orange/ :: orange fruit
361+
362+ #+BEGIN_EXAMPLE
363+ { orange code block }
364+ #+END_EXAMPLE
365+
366+#+BEGIN_QUOTE
367+
368+ orange block quote
369+
370+
371+#+END_QUOTE
372+
373+
374+Multiple definitions, tight:
375+
376+- apple :: red fruit
377+ computer
378+- orange :: orange fruit
379+ bank
380+
381+Multiple definitions, loose:
382+
383+- apple :: red fruit
384+
385+ computer
386+
387+- orange :: orange fruit
388+
389+ bank
390+
391+
392+Blank line after term, indented marker, alternate markers:
393+
394+- apple :: red fruit
395+
396+ computer
397+
398+- orange :: orange fruit
399+
400+
401+ 1. sublist
402+ 2. sublist
403+
404+
405+* HTML Blocks
406+
407+Simple block on one line:
408+
409+
410+#+BEGIN_HTML
411+
412+ <div>
413+
414+#+END_HTML
415+
416+foo
417+
418+#+BEGIN_HTML
419+
420+ </div>
421+
422+#+END_HTML
423+
424+And nested without indentation:
425+
426+
427+#+BEGIN_HTML
428+
429+ <div>
430+ <div>
431+ <div>
432+
433+#+END_HTML
434+
435+foo
436+
437+#+BEGIN_HTML
438+
439+ </div>
440+ </div>
441+ <div>
442+
443+#+END_HTML
444+
445+bar
446+
447+#+BEGIN_HTML
448+
449+ </div>
450+ </div>
451+
452+#+END_HTML
453+
454+Interpreted markdown in a table:
455+
456+
457+#+BEGIN_HTML
458+
459+ <table>
460+ <tr>
461+ <td>
462+
463+#+END_HTML
464+
465+This is /emphasized/
466+
467+#+BEGIN_HTML
468+
469+ </td>
470+ <td>
471+
472+#+END_HTML
473+
474+And this is *strong*
475+
476+#+BEGIN_HTML
477+
478+ </td>
479+ </tr>
480+ </table>
481+
482+ <script type="text/javascript">document.write('This *should not* be interpreted as markdown');</script>
483+
484+#+END_HTML
485+
486+Here's a simple block:
487+
488+
489+#+BEGIN_HTML
490+
491+ <div>
492+
493+
494+#+END_HTML
495+
496+foo
497+
498+#+BEGIN_HTML
499+
500+ </div>
501+
502+#+END_HTML
503+
504+This should be a code block, though:
505+
506+#+BEGIN_EXAMPLE
507+ <div>
508+ foo
509+ </div>
510+#+END_EXAMPLE
511+As should this:
512+
513+#+BEGIN_EXAMPLE
514+ <div>foo</div>
515+#+END_EXAMPLE
516+Now, nested:
517+
518+
519+#+BEGIN_HTML
520+
521+ <div>
522+ <div>
523+ <div>
524+
525+
526+#+END_HTML
527+
528+foo
529+
530+#+BEGIN_HTML
531+
532+ </div>
533+ </div>
534+ </div>
535+
536+#+END_HTML
537+
538+This should just be an HTML comment:
539+
540+
541+#+BEGIN_HTML
542+
543+ <!-- Comment -->
544+
545+#+END_HTML
546+
547+Multiline:
548+
549+
550+#+BEGIN_HTML
551+
552+ <!--
553+ Blah
554+ Blah
555+ -->
556+
557+ <!--
558+ This is another comment.
559+ -->
560+
561+#+END_HTML
562+
563+Code block:
564+
565+#+BEGIN_EXAMPLE
566+ <!-- Comment -->
567+#+END_EXAMPLE
568+Just plain comment, with trailing spaces on the line:
569+
570+
571+#+BEGIN_HTML
572+
573+ <!-- foo -->
574+
575+#+END_HTML
576+
577+Code:
578+
579+#+BEGIN_EXAMPLE
580+ <hr />
581+#+END_EXAMPLE
582+Hr's:
583+
584+
585+#+BEGIN_HTML
586+
587+ <hr>
588+
589+ <hr />
590+
591+ <hr />
592+
593+ <hr>
594+
595+ <hr />
596+
597+ <hr />
598+
599+ <hr class="foo" id="bar" />
600+
601+ <hr class="foo" id="bar" />
602+
603+ <hr class="foo" id="bar">
604+
605+#+END_HTML
606+
607+--------------
608+
609+* Inline Markup
610+
611+This is /emphasized/, and so /is this/.
612+
613+This is *strong*, and so *is this*.
614+
615+An /[[/url][emphasized link]]/.
616+
617+*/This is strong and em./*
618+
619+So is */this/* word.
620+
621+*/This is strong and em./*
622+
623+So is */this/* word.
624+
625+This is code: =>=, =$=, =\=, =\$=, =<html>=.
626+
627++This is /strikeout/.+
628+
629+Superscripts: a^{bc}d a^{/hello/} a^{hello there}.
630+
631+Subscripts: H_{2}O, H_{23}O, H_{many of them}O.
632+
633+These should not be superscripts or subscripts, because of the
634+unescaped spaces: a\^b c\^d, a~b c~d.
635+
636+--------------
637+
638+* Smart quotes, ellipses, dashes
639+
640+"Hello," said the spider. "'Shelob' is my name."
641+
642+'A', 'B', and 'C' are letters.
643+
644+'Oak,' 'elm,' and 'beech' are names of trees. So is 'pine.'
645+
646+'He said, "I want to go."' Were you alive in the 70's?
647+
648+Here is some quoted '=code=' and a
649+"[[http://example.com/?foo=1&bar=2][quoted link]]".
650+
651+Some dashes: one---two --- three---four --- five.
652+
653+Dashes between numbers: 5--7, 255--66, 1987--1999.
654+
655+Ellipses...and...and....
656+
657+--------------
658+
659+* LaTeX
660+
661+
662+- \cite[22-23]{smith.1899}
663+- $2+2=4$
664+- $x \in y$
665+- $\alpha \wedge \omega$
666+- $223$
667+- $p$-Tree
668+- Here's some display math:
669+ $$\frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}$$
670+- Here's one that has a line break in it:
671+ $\alpha + \omega \times x^2$.
672+
673+These shouldn't be math:
674+
675+
676+- To get the famous equation, write =$e = mc^2$=.
677+- $22,000 is a /lot/ of money. So is $34,000. (It worked if "lot"
678+ is emphasized.)
679+- Shoes ($20) and socks ($5).
680+- Escaped =$=: $73 /this should be emphasized/ 23$.
681+
682+Here's a LaTeX table:
683+
684+\begin{tabular}{|l|l|}\hline
685+Animal & Number \\ \hline
686+Dog & 2 \\
687+Cat & 1 \\ \hline
688+\end{tabular}
689+
690+--------------
691+
692+* Special Characters
693+
694+Here is some unicode:
695+
696+
697+- I hat: Î
698+- o umlaut: ö
699+- section: §
700+- set membership: ∈
701+- copyright: ©
702+
703+AT&T has an ampersand in their name.
704+
705+AT&T is another way to write it.
706+
707+This & that.
708+
709+4 < 5.
710+
711+6 > 5.
712+
713+Backslash: \
714+
715+Backtick: `
716+
717+Asterisk: *
718+
719+Underscore: \_
720+
721+Left brace: {
722+
723+Right brace: }
724+
725+Left bracket: [
726+
727+Right bracket: ]
728+
729+Left paren: (
730+
731+Right paren: )
732+
733+Greater-than: >
734+
735+Hash: #
736+
737+Period: .
738+
739+Bang: !
740+
741+Plus: +
742+
743+Minus: -
744+
745+--------------
746+
747+* Links
748+
749+** Explicit
750+
751+Just a [[/url/][URL]].
752+
753+[[/url/][URL and title]].
754+
755+[[/url/][URL and title]].
756+
757+[[/url/][URL and title]].
758+
759+[[/url/][URL and title]]
760+
761+[[/url/][URL and title]]
762+
763+[[/url/with_underscore][with\_underscore]]
764+
765+[[mailto:nobody@nowhere.net][Email link]]
766+
767+[[][Empty]].
768+
769+** Reference
770+
771+Foo [[/url/][bar]].
772+
773+Foo [[/url/][bar]].
774+
775+Foo [[/url/][bar]].
776+
777+With [[/url/][embedded [brackets]]].
778+
779+[[/url/][b]] by itself should be a link.
780+
781+Indented [[/url][once]].
782+
783+Indented [[/url][twice]].
784+
785+Indented [[/url][thrice]].
786+
787+This should [not][] be a link.
788+
789+#+BEGIN_EXAMPLE
790+ [not]: /url
791+#+END_EXAMPLE
792+Foo [[/url/][bar]].
793+
794+Foo [[/url/][biz]].
795+
796+** With ampersands
797+
798+Here's a
799+[[http://example.com/?foo=1&bar=2][link with an ampersand in the URL]].
800+
801+Here's a link with an amersand in the link text:
802+[[http://att.com/][AT&T]].
803+
804+Here's an [[/script?foo=1&bar=2][inline link]].
805+
806+Here's an [[/script?foo=1&bar=2][inline link in pointy braces]].
807+
808+** Autolinks
809+
810+With an ampersand: [[http://example.com/?foo=1&bar=2]]
811+
812+
813+- In a list?
814+- [[http://example.com/]]
815+- It should.
816+
817+An e-mail address:
818+[[mailto:nobody@nowhere.net][=nobody@nowhere.net=]]
819+
820+
821+#+BEGIN_QUOTE
822+
823+ Blockquoted: [[http://example.com/]]
824+
825+
826+#+END_QUOTE
827+
828+Auto-links should not occur here: =<http://example.com/>=
829+
830+#+BEGIN_EXAMPLE
831+ or here: <http://example.com/>
832+#+END_EXAMPLE
833+--------------
834+
835+* Images
836+
837+From "Voyage dans la Lune" by Georges Melies (1902):
838+
839+#+CAPTION: lalune
840+
841+[[lalune.jpg]]
842+Here is a movie [[movie.jpg]] icon.
843+
844+--------------
845+
846+* Footnotes
847+
848+Here is a footnote reference, [1] and another. [2] This should
849+/not/ be a footnote reference, because it contains a space.[\^my
850+note] Here is an inline note. [3]
851+
852+
853+#+BEGIN_QUOTE
854+
855+ Notes can go in quotes. [4]
856+
857+
858+#+END_QUOTE
859+
860+
861+1. And in list items. [5]
862+
863+This paragraph should not be part of the note, as it is not
864+indented.
865+
866+[1] Here is the footnote. It can go anywhere after the footnote
867+ reference. It need not be placed at the end of the document.
868+
869+[2] Here's the long note. This one contains multiple blocks.
870+
871+ Subsequent blocks are indented to show that they belong to the
872+ footnote (as with list items).
873+
874+ #+BEGIN_EXAMPLE
875+ { <code> }
876+ #+END_EXAMPLE
877+ If you want, you can indent every line, but you can also be lazy
878+ and just indent the first line of each block.
879+
880+[3] This is /easier/ to type. Inline notes may contain
881+ [[http://google.com][links]] and =]= verbatim characters, as well
882+ as [bracketed text].
883+
884+[4] In quote.
885+
886+[5] In list.