git.iko.soy/typeable/pandoc
on master help sign in
fix autolink by promoting it in the parser list, fix table parabreak
commit593b4f6c948f2b32c6fef170a37d725285c8e9c4 authorPaul Rivier <paul.r.ml@gmail.com> dateMon 4 Oct 2010, 20:34 (16 years ago) parenta7da067
3 files changed+9−33
src/Text/Pandoc/Readers/Textile.hs+5−7 tests/textile-reader.native+2−19 tests/textile-reader.textile+2−7
src/Text/Pandoc/Readers/Textile.hs+5−7
@@ -190,7 +190,6 @@ tableRow :: GenParser Char ParserState [TableCell]
190190tableRow = try $ do
191191 char '|'
192192 cells <- endBy1 tableCell (char '|')
193− -- TODO : don't eat the last newline
194193 newline
195194 return cells
196195
@@ -215,6 +214,7 @@ table :: GenParser Char ParserState Block
215214table = try $ do
216215 headers <- option [] tableHeaders
217216 rows <- tableRows
217+ blanklines
218218 let nbOfCols = max (length headers) (length $ head rows)
219219 return $ Table []
220220 (replicate nbOfCols AlignDefault)
@@ -239,7 +239,8 @@ inlines = manyTill inline newline
239239
240240-- | Inline parsers tried in order
241241inlineParsers :: [GenParser Char ParserState Inline]
242−inlineParsers = [ str
242+inlineParsers = [ autoLink
243+ , str
243244 , whitespace
244245 , endline
245246 , code
@@ -253,8 +254,6 @@ inlineParsers = [ str
253254 , simpleInline (char '^') Superscript
254255 , simpleInline (char '~') Subscript
255256 , link
256− , autoLink
257− , image
258257 , image
259258 , symbol
260259 ]
@@ -284,9 +283,10 @@ link = try $ do
284283-- | Detect plain links to http or email.
285284autoLink :: GenParser Char ParserState Inline
286285autoLink = do
287− (orig, src) <- uri -- (try uri <|> try emailAddress)
286+ (orig, src) <- (try uri <|> try emailAddress)
288287 return $ Link [Str orig] (src, "")
289288
289+
290290-- | image embedding
291291image :: GenParser Char ParserState Inline
292292image = try $ do
@@ -326,7 +326,5 @@ simpleInline border construct = surrounded border inline >>=
326326--
327327-- - Pandoc Meta Information (title, author, date)
328328-- - footnotes
329−-- - autolink is not called
330329-- - should autolink be shared through Parsing.hs ?
331330-- - Inserted inline handling in writers
332−-- - table parser is a bit too greedy and require a double newline after tables
tests/textile-reader.native+2−19
@@ -65,7 +65,7 @@ Pandoc (Meta {docTitle = [Str ""], docAuthors = [[Str ""]], docDate = [Str ""]})
6565, Header 2 [Str "Explicit"]
6666, Para [Str "Just",Space,Str "a",Space,Link [Str "url"] ("http://www.url.com","")]
6767, Para [Link [Str "Email",Space,Str "link"] ("mailto:nobody@nowhere.net","")]
68−, Para [Str "Automatic",Space,Str "linking",Space,Str "to",Space,Str "http",Str ":",Str "//www.example.com",Space,Str "and",Space,Str "foobar",Str "@",Str "example.com."]
68+, Para [Str "Automatic",Space,Str "linking",Space,Str "to",Space,Link [Str "http://www.example.com"] ("http://www.example.com",""),Space,Str "and",Space,Link [Str "foobar@example.com"] ("mailto:foobar@example.com",""),Str "."]
6969, Header 1 [Str "Tables"]
7070, Para [Str "Textile",Space,Str "allows",Space,Str "tables",Space,Str "with",Space,Str "and",Space,Str "without",Space,Str "headers",Space,Str ":"]
7171, Header 2 [Str "Without",Space,Str "headers"]
@@ -84,23 +84,7 @@ Pandoc (Meta {docTitle = [Str ""], docAuthors = [[Str ""]], docDate = [Str ""]})
8484 [ [ Plain [Str "bella"] ]
8585 , [ Plain [Str "45"] ]
8686 , [ Plain [Str "f"] ] ] ]
87−, Para [Str "And",Space,Str "some",Space,Str "text",Space,Str "..."]
88−, Table [] [AlignDefault,AlignDefault,AlignDefault] [0.0,0.0,0.0]
89− [
90− ] [
91− [ [ Plain [Str "name"] ]
92− , [ Plain [Str "age"] ]
93− , [ Plain [Str "sex"] ] ],
94− [ [ Plain [Str "joan"] ]
95− , [ Plain [Str "24"] ]
96− , [ Plain [Str "f"] ] ],
97− [ [ Plain [Str "archie"] ]
98− , [ Plain [Str "29"] ]
99− , [ Plain [Str "m"] ] ],
100− [ [ Plain [Str "bella"] ]
101− , [ Plain [Str "45"] ]
102− , [ Plain [Str "f"] ] ] ]
103−, Para []
87+, Para [Str "and",Space,Str "some",Space,Str "text",Space,Str "following",Space,Str "..."]
10488, Header 2 [Str "With",Space,Str "headers"]
10589, Table [] [AlignDefault,AlignDefault,AlignDefault] [0.0,0.0,0.0]
10690 [ [ Plain [Str "name"] ]
@@ -115,6 +99,5 @@ Pandoc (Meta {docTitle = [Str ""], docAuthors = [[Str ""]], docDate = [Str ""]})
11599 [ [ Plain [Str "bella"] ]
116100 , [ Plain [Str "45"] ]
117101 , [ Plain [Str "f"] ] ] ]
118−, Para []
119102, Header 1 [Str "Images"]
120103, Para [Str "Textile",Space,Str "inline",Space,Str "image",Space,Str "syntax,",Space,Str "like",Space,Str "here",Space,Image [Str "this is the alt text"] ("this_is_an_image.png","this is the alt text"),Space,Str "and",Space,Str "here",Space,Image [Str ""] ("this_is_an_image.png",""),Str "."] ]
tests/textile-reader.textile+2−7
@@ -133,13 +133,7 @@ h2. Without headers
133133| archie | 29 | m |
134134| bella | 45 | f |
135135
136−And some text ...
137−
138−| name | age | sex |
139−| joan | 24 | f |
140−| archie| 29 | m |
141−| bella | 45 | f |
142−
136+and some text following ...
143137
144138h2. With headers
145139
@@ -149,6 +143,7 @@ h2. With headers
149143| bella | 45 | f |
150144
151145
146+
152147h1. Images
153148
154149Textile inline image syntax, like