git.iko.soy/typeable/pandoc
on master help sign in
Merge branch 'punchagan-master'
commite8e491bdbf86b95e2ce2beac2a7062c57bfd9e5d authorJohn MacFarlane <jgm@berkeley.edu> dateSun 5 Dec 2010, 09:34 (16 years ago) parentc277d2985263ec
8 files changed+1257−1
pandoc.cabal+2−1 src/Text/Pandoc.hs+2 src/Text/Pandoc/Writers/Org.hs+291 src/pandoc.hs+2 templates/org.template+22 tests/RunTests.hs+1 tests/tables.org+51 tests/writer.org+886
pandoc.cabal+2−1
@@ -43,7 +43,7 @@ Data-Files:
4343 templates/rst.template, templates/plain.template,
4444 templates/mediawiki.template, templates/rtf.template,
4545 templates/s5.template, templates/slidy.template,
46− templates/textile.template
46+ templates/textile.template, templates/org.template
4747 -- data for ODT writer
4848 reference.odt,
4949 -- stylesheet for EPUB writer
@@ -202,6 +202,7 @@ Library
202202 Text.Pandoc.Writers.Man,
203203 Text.Pandoc.Writers.Markdown,
204204 Text.Pandoc.Writers.RST,
205+ Text.Pandoc.Writers.Org,
205206 Text.Pandoc.Writers.Textile,
206207 Text.Pandoc.Writers.MediaWiki,
207208 Text.Pandoc.Writers.RTF,
src/Text/Pandoc.hs+2
@@ -89,6 +89,7 @@ module Text.Pandoc
8989 , writeRTF
9090 , writeODT
9191 , writeEPUB
92+ , writeOrg
9293 -- * Writer options used in writers
9394 , WriterOptions (..)
9495 , HTMLSlideVariant (..)
@@ -121,6 +122,7 @@ import Text.Pandoc.Writers.Man
121122import Text.Pandoc.Writers.RTF
122123import Text.Pandoc.Writers.MediaWiki
123124import Text.Pandoc.Writers.Textile
125+import Text.Pandoc.Writers.Org
124126import Text.Pandoc.Templates
125127import Text.Pandoc.Parsing
126128import Text.Pandoc.Shared
src/Text/Pandoc/Writers/Org.hsnew file+291
@@ -0,0 +1,291 @@
1+{-
2+Copyright (C) 2006-2010 Puneeth Chaganti <punchagan@gmail.com>
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.Writers.Org
21+ Copyright : Copyright (C) 2006-2010 Puneeth Chaganti
22+ License : GNU GPL, version 2 or above
23+
24+ Maintainer : Puneeth Chaganti <punchagan@gmail.com>
25+ Stability : alpha
26+ Portability : portable
27+
28+Conversion of 'Pandoc' documents to reStructuredText.
29+
30+reStructuredText: <http://docutils.sourceforge.net/rst.html>
31+-}
32+module Text.Pandoc.Writers.Org ( writeOrg) where
33+import Text.Pandoc.Definition
34+import Text.Pandoc.Shared
35+import Text.Pandoc.Blocks
36+import Text.Pandoc.Templates (renderTemplate)
37+import Data.List ( intersect, intersperse, transpose )
38+import Text.PrettyPrint.HughesPJ hiding ( Str )
39+import Control.Monad.State
40+import Control.Applicative ( (<$>) )
41+
42+data WriterState =
43+ WriterState { stNotes :: [[Block]]
44+ , stLinks :: Bool
45+ , stImages :: Bool
46+ , stHasMath :: Bool
47+ , stOptions :: WriterOptions
48+ }
49+
50+-- | Convert Pandoc to Org.
51+writeOrg :: WriterOptions -> Pandoc -> String
52+writeOrg opts document =
53+ let st = WriterState { stNotes = [], stLinks = False,
54+ stImages = False, stHasMath = False,
55+ stOptions = opts }
56+ in evalState (pandocToOrg document) st
57+
58+-- | Return Org representation of document.
59+pandocToOrg :: Pandoc -> State WriterState String
60+pandocToOrg (Pandoc (Meta tit auth dat) blocks) = do
61+ opts <- liftM stOptions get
62+ title <- titleToOrg tit
63+ authors <- mapM inlineListToOrg auth
64+ date <- inlineListToOrg dat
65+ body <- blockListToOrg blocks
66+ notes <- liftM (reverse . stNotes) get >>= notesToOrg
67+ -- note that the notes may contain refs, so we do them first
68+ hasMath <- liftM stHasMath get
69+ let main = render $ foldl ($+$) empty $ [body, notes]
70+ let context = writerVariables opts ++
71+ [ ("body", main)
72+ , ("title", render title)
73+ , ("date", render date) ] ++
74+ [ ("math", "yes") | hasMath ] ++
75+ [ ("author", render a) | a <- authors ]
76+ if writerStandalone opts
77+ then return $ renderTemplate context $ writerTemplate opts
78+ else return main
79+
80+-- | Return Org representation of notes.
81+notesToOrg :: [[Block]] -> State WriterState Doc
82+notesToOrg notes =
83+ mapM (\(num, note) -> noteToOrg num note) (zip [1..] notes) >>=
84+ return . vcat
85+
86+-- | Return Org representation of a note.
87+noteToOrg :: Int -> [Block] -> State WriterState Doc
88+noteToOrg num note = do
89+ contents <- blockListToOrg note
90+ let marker = text "[" <> text (show num) <> text "] "
91+ return $ marker <> contents
92+
93+-- | Take list of inline elements and return wrapped doc.
94+wrappedOrg :: WriterOptions -> [Inline] -> State WriterState Doc
95+wrappedOrg opts inlines = do
96+ lineBreakDoc <- inlineToOrg LineBreak
97+ chunks <- mapM (wrapIfNeeded opts inlineListToOrg)
98+ (splitBy LineBreak inlines)
99+ return $ vcat $ intersperse lineBreakDoc chunks
100+
101+-- | Escape special characters for Org.
102+escapeString :: String -> String
103+escapeString = escapeStringUsing (backslashEscapes "^_")
104+
105+titleToOrg :: [Inline] -> State WriterState Doc
106+titleToOrg [] = return empty
107+titleToOrg lst = do
108+ contents <- inlineListToOrg lst
109+ let titleName = text "#+TITLE: "
110+ return $ titleName <> contents
111+
112+-- | Convert Pandoc block element to Org.
113+blockToOrg :: Block -- ^ Block element
114+ -> State WriterState Doc
115+blockToOrg Null = return empty
116+blockToOrg (Plain inlines) = do
117+ opts <- get >>= (return . stOptions)
118+ wrappedOrg opts inlines
119+blockToOrg (Para [Image txt (src,tit)]) = do
120+ capt <- inlineListToOrg txt
121+ img <- inlineToOrg (Image txt (src,tit))
122+ return $ text "#+CAPTION: " <> capt <> text "\n" $$ img
123+blockToOrg (Para inlines) = do
124+ opts <- get >>= (return . stOptions)
125+ contents <- wrappedOrg opts inlines
126+ return $ contents <> text "\n"
127+blockToOrg (RawHtml str) =
128+ return $ (text "\n#+BEGIN_HTML\n") $$ (nest 2 $ vcat $ map text (lines str))
129+ $$ (text "\n#+END_HTML\n")
130+blockToOrg HorizontalRule = return $ text "--------------\n"
131+blockToOrg (Header level inlines) = do
132+ contents <- inlineListToOrg inlines
133+ let headerStr = text $ if level > 999 then " " else replicate level '*'
134+ return $ headerStr <> text " " <> contents <> text "\n"
135+blockToOrg (CodeBlock (_,classes,_) str) = do
136+ opts <- stOptions <$> get
137+ let tabstop = writerTabStop opts
138+ let at = classes `intersect` ["asymptote", "C", "clojure", "css", "ditaa",
139+ "dot", "emacs-lisp", "gnuplot", "haskell", "js", "latex",
140+ "ledger", "lisp", "matlab", "mscgen", "ocaml", "octave",
141+ "oz", "perl", "plantuml", "python", "R", "ruby", "sass",
142+ "scheme", "screen", "sh", "sql", "sqlite"]
143+ let (beg, end) = if null at
144+ then ("#+BEGIN_EXAMPLE", "#+END_EXAMPLE")
145+ else ("#+BEGIN_SRC" ++ head at, "#+END_SRC")
146+ return $ text beg $+$ (nest tabstop $ vcat $ map text (lines str))
147+ $+$ text end
148+blockToOrg (BlockQuote blocks) = do
149+ contents <- blockListToOrg blocks
150+ return $ (text "\n#+BEGIN_QUOTE\n") $$ (nest 2 contents)
151+ $$ (text "\n#+END_QUOTE\n")
152+blockToOrg (Table caption' _ _ headers rows) = do
153+ caption'' <- inlineListToOrg caption'
154+ let caption = if null caption'
155+ then empty
156+ else (text "#+CAPTION: " <> caption'')
157+ headers' <- mapM blockListToOrg headers
158+ rawRows <- mapM (mapM blockListToOrg) rows
159+ let numChars = maximum . map (length . render)
160+ -- FIXME: width is not being used.
161+ let widthsInChars =
162+ map ((+2) . numChars) $ transpose (headers' : rawRows)
163+ -- FIXME: Org doesn't allow blocks with height more than 1.
164+ let hpipeBlocks blocks = hcatBlocks [beg, middle, end]
165+ where height = maximum (map heightOfBlock blocks)
166+ sep' = TextBlock 3 height (replicate height " | ")
167+ beg = TextBlock 2 height (replicate height "| ")
168+ end = TextBlock 2 height (replicate height " |")
169+ middle = hcatBlocks $ intersperse sep' blocks
170+ let makeRow = hpipeBlocks . zipWith docToBlock widthsInChars
171+ let head' = makeRow headers'
172+ rows' <- mapM (\row -> do cols <- mapM blockListToOrg row
173+ return $ makeRow cols) rows
174+ let border ch = char '|' <> char ch <>
175+ (hcat $ intersperse (char ch <> char '+' <> char ch) $
176+ map (\l -> text $ replicate l ch) widthsInChars) <>
177+ char ch <> char '|'
178+ let body = vcat $ map blockToDoc rows'
179+ let head'' = if all null headers
180+ then empty
181+ else blockToDoc head' $+$ border '-'
182+ return $ head'' $+$ body $$ caption $$ text ""
183+blockToOrg (BulletList items) = do
184+ contents <- mapM bulletListItemToOrg items
185+ -- ensure that sublists have preceding blank line
186+ return $ text "" $+$ vcat contents <> text "\n"
187+blockToOrg (OrderedList (start, style', delim) items) = do
188+ let markers = take (length items) $ orderedListMarkers
189+ (start, style', delim)
190+ let maxMarkerLength = maximum $ map length markers
191+ let markers' = map (\m -> let s = maxMarkerLength - length m
192+ in m ++ replicate s ' ') markers
193+ contents <- mapM (\(item, num) -> orderedListItemToOrg item num) $
194+ zip markers' items
195+ -- ensure that sublists have preceding blank line
196+ return $ text "" $+$ vcat contents <> text "\n"
197+blockToOrg (DefinitionList items) = do
198+ contents <- mapM definitionListItemToOrg items
199+ return $ (vcat contents) <> text "\n"
200+
201+-- | Convert bullet list item (list of blocks) to Org.
202+bulletListItemToOrg :: [Block] -> State WriterState Doc
203+bulletListItemToOrg items = do
204+ contents <- blockListToOrg items
205+ return $ (text "- ") <> contents
206+
207+-- | Convert ordered list item (a list of blocks) to Org.
208+orderedListItemToOrg :: String -- ^ marker for list item
209+ -> [Block] -- ^ list item (list of blocks)
210+ -> State WriterState Doc
211+orderedListItemToOrg marker items = do
212+ contents <- blockListToOrg items
213+ return $ (text marker <> char ' ') <> contents
214+
215+-- | Convert defintion list item (label, list of blocks) to Org.
216+definitionListItemToOrg :: ([Inline], [[Block]]) -> State WriterState Doc
217+definitionListItemToOrg (label, defs) = do
218+ label' <- inlineListToOrg label
219+ contents <- liftM vcat $ mapM blockListToOrg defs
220+ return $ (text "- ") <> label' <> (text " :: ") <> contents
221+
222+-- | Convert list of Pandoc block elements to Org.
223+blockListToOrg :: [Block] -- ^ List of block elements
224+ -> State WriterState Doc
225+blockListToOrg blocks = mapM blockToOrg blocks >>= return . vcat
226+
227+-- | Convert list of Pandoc inline elements to Org.
228+inlineListToOrg :: [Inline] -> State WriterState Doc
229+inlineListToOrg lst = mapM inlineToOrg lst >>= return . hcat
230+
231+-- | Convert Pandoc inline element to Org.
232+inlineToOrg :: Inline -> State WriterState Doc
233+inlineToOrg (Emph lst) = do
234+ contents <- inlineListToOrg lst
235+ return $ char '/' <> contents <> char '/'
236+inlineToOrg (Strong lst) = do
237+ contents <- inlineListToOrg lst
238+ return $ text "*" <> contents <> text "*"
239+inlineToOrg (Strikeout lst) = do
240+ contents <- inlineListToOrg lst
241+ return $ text "+" <> contents <> char '+'
242+inlineToOrg (Superscript lst) = do
243+ contents <- inlineListToOrg lst
244+ return $ text "^{" <> contents <> text "}"
245+inlineToOrg (Subscript lst) = do
246+ contents <- inlineListToOrg lst
247+ return $ text "_{" <> contents <> text "}"
248+inlineToOrg (SmallCaps lst) = inlineListToOrg lst
249+inlineToOrg (Quoted SingleQuote lst) = do
250+ contents <- inlineListToOrg lst
251+ return $ char '\'' <> contents <> char '\''
252+inlineToOrg (Quoted DoubleQuote lst) = do
253+ contents <- inlineListToOrg lst
254+ return $ char '\"' <> contents <> char '\"'
255+inlineToOrg (Cite _ lst) =
256+ inlineListToOrg lst
257+inlineToOrg EmDash = return $ text "---"
258+inlineToOrg EnDash = return $ text "--"
259+inlineToOrg Apostrophe = return $ char '\''
260+inlineToOrg Ellipses = return $ text "..."
261+inlineToOrg (Code str) = return $ text $ "=" ++ str ++ "="
262+inlineToOrg (Str str) = return $ text $ escapeString str
263+inlineToOrg (Math t str) = do
264+ modify $ \st -> st{ stHasMath = True }
265+ return $ if t == InlineMath
266+ then text $ "$" ++ str ++ "$"
267+ else text $ "$$" ++ str ++ "$$"
268+inlineToOrg (TeX str) = return $ text str
269+inlineToOrg (HtmlInline _) = return empty
270+inlineToOrg (LineBreak) = do
271+ return $ empty -- there's no line break in Org
272+inlineToOrg Space = return $ char ' '
273+inlineToOrg (Link txt (src, _)) = do
274+ case txt of
275+ [Code x] | x == src -> -- autolink
276+ do modify $ \s -> s{ stLinks = True }
277+ return $ text $ "[[" ++ x ++ "]]"
278+ _ -> do contents <- inlineListToOrg txt
279+ modify $ \s -> s{ stLinks = True }
280+ return $ text ("[[" ++ src ++ "][") <> contents <>
281+ (text "]]")
282+inlineToOrg (Image _ (source', _)) = do
283+ let source = unescapeURI source'
284+ modify $ \s -> s{ stImages = True }
285+ return $ text $ "[[" ++ source ++ "]]"
286+inlineToOrg (Note contents) = do
287+ -- add to notes in state
288+ notes <- get >>= (return . stNotes)
289+ modify $ \st -> st { stNotes = contents:notes }
290+ let ref = show $ (length notes) + 1
291+ return $ text " [" <> text ref <> text "]"
src/pandoc.hs+2
@@ -121,6 +121,7 @@ writers = [("native" , writeNative)
121121 ,("mediawiki" , writeMediaWiki)
122122 ,("textile" , writeTextile)
123123 ,("rtf" , writeRTF)
124+ ,("org" , writeOrg)
124125 ]
125126
126127isNonTextOutput :: String -> Bool
@@ -616,6 +617,7 @@ defaultWriterName x =
616617 ".db" -> "docbook"
617618 ".odt" -> "odt"
618619 ".epub" -> "epub"
620+ ".org" -> "org"
619621 ['.',y] | y `elem` ['1'..'9'] -> "man"
620622 _ -> "html"
621623
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.