git.iko.soy/typeable/pandoc
on master help sign in
fix autolink by promoting it in the parser list, fix table parabreak
593b4f6Paul Rivier
src/Text/Pandoc/Readers/Textile.hs+5−7
@@ -190,7 +190,6 @@ tableRow :: GenParser Char ParserState [TableCell]
190tableRow = try $ do
190tableRow = try $ do
191 char '|'
191 char '|'
192 cells <- endBy1 tableCell (char '|')
192 cells <- endBy1 tableCell (char '|')
193− -- TODO : don't eat the last newline
194 newline
193 newline
195 return cells
194 return cells
196
195
@@ -215,6 +214,7 @@ table :: GenParser Char ParserState Block
215table = try $ do
214table = try $ do
216 headers <- option [] tableHeaders
215 headers <- option [] tableHeaders
217 rows <- tableRows
216 rows <- tableRows
217+ blanklines
218 let nbOfCols = max (length headers) (length $ head rows)
218 let nbOfCols = max (length headers) (length $ head rows)
219 return $ Table []
219 return $ Table []
220 (replicate nbOfCols AlignDefault)
220 (replicate nbOfCols AlignDefault)
@@ -239,7 +239,8 @@ inlines = manyTill inline newline
239
239
240-- | Inline parsers tried in order
240-- | Inline parsers tried in order
241inlineParsers :: [GenParser Char ParserState Inline]
241inlineParsers :: [GenParser Char ParserState Inline]
242−inlineParsers = [ str
242+inlineParsers = [ autoLink
243+ , str
243 , whitespace
244 , whitespace
244 , endline
245 , endline
245 , code
246 , code
@@ -253,8 +254,6 @@ inlineParsers = [ str
253 , simpleInline (char '^') Superscript
254 , simpleInline (char '^') Superscript
254 , simpleInline (char '~') Subscript
255 , simpleInline (char '~') Subscript
255 , link
256 , link
256− , autoLink
257− , image
258 , image
257 , image
259 , symbol
258 , symbol
260 ]
259 ]
@@ -284,9 +283,10 @@ link = try $ do
284-- | Detect plain links to http or email.
283-- | Detect plain links to http or email.
285autoLink :: GenParser Char ParserState Inline
284autoLink :: GenParser Char ParserState Inline
286autoLink = do
285autoLink = do
287− (orig, src) <- uri -- (try uri <|> try emailAddress)
286+ (orig, src) <- (try uri <|> try emailAddress)
288 return $ Link [Str orig] (src, "")
287 return $ Link [Str orig] (src, "")
289
288
289+
290-- | image embedding
290-- | image embedding
291image :: GenParser Char ParserState Inline
291image :: GenParser Char ParserState Inline
292image = try $ do
292image = try $ do
@@ -326,7 +326,5 @@ simpleInline border construct = surrounded border inline >>=
326--
326--
327-- - Pandoc Meta Information (title, author, date)
327-- - Pandoc Meta Information (title, author, date)
328-- - footnotes
328-- - footnotes
329−-- - autolink is not called
330-- - should autolink be shared through Parsing.hs ?
329-- - should autolink be shared through Parsing.hs ?
331-- - Inserted inline handling in writers
330-- - 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 ""]})
65, Header 2 [Str "Explicit"]
65, Header 2 [Str "Explicit"]
66, Para [Str "Just",Space,Str "a",Space,Link [Str "url"] ("http://www.url.com","")]
66, Para [Str "Just",Space,Str "a",Space,Link [Str "url"] ("http://www.url.com","")]
67, Para [Link [Str "Email",Space,Str "link"] ("mailto:nobody@nowhere.net","")]
67, 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 "."]
69, Header 1 [Str "Tables"]
69, Header 1 [Str "Tables"]
70, Para [Str "Textile",Space,Str "allows",Space,Str "tables",Space,Str "with",Space,Str "and",Space,Str "without",Space,Str "headers",Space,Str ":"]
70, Para [Str "Textile",Space,Str "allows",Space,Str "tables",Space,Str "with",Space,Str "and",Space,Str "without",Space,Str "headers",Space,Str ":"]
71, Header 2 [Str "Without",Space,Str "headers"]
71, Header 2 [Str "Without",Space,Str "headers"]
@@ -84,23 +84,7 @@ Pandoc (Meta {docTitle = [Str ""], docAuthors = [[Str ""]], docDate = [Str ""]})
84 [ [ Plain [Str "bella"] ]
84 [ [ Plain [Str "bella"] ]
85 , [ Plain [Str "45"] ]
85 , [ Plain [Str "45"] ]
86 , [ Plain [Str "f"] ] ] ]
86 , [ Plain [Str "f"] ] ] ]
87−, Para [Str "And",Space,Str "some",Space,Str "text",Space,Str "..."]
87+, Para [Str "and",Space,Str "some",Space,Str "text",Space,Str "following",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 []
104, Header 2 [Str "With",Space,Str "headers"]
88, Header 2 [Str "With",Space,Str "headers"]
105, Table [] [AlignDefault,AlignDefault,AlignDefault] [0.0,0.0,0.0]
89, Table [] [AlignDefault,AlignDefault,AlignDefault] [0.0,0.0,0.0]
106 [ [ Plain [Str "name"] ]
90 [ [ Plain [Str "name"] ]
@@ -115,6 +99,5 @@ Pandoc (Meta {docTitle = [Str ""], docAuthors = [[Str ""]], docDate = [Str ""]})
115 [ [ Plain [Str "bella"] ]
99 [ [ Plain [Str "bella"] ]
116 , [ Plain [Str "45"] ]
100 , [ Plain [Str "45"] ]
117 , [ Plain [Str "f"] ] ] ]
101 , [ Plain [Str "f"] ] ] ]
118−, Para []
119, Header 1 [Str "Images"]
102, Header 1 [Str "Images"]
120, 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 "."] ]
103, 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
133| archie | 29 | m |
133| archie | 29 | m |
134| bella | 45 | f |
134| bella | 45 | f |
135
135
136−And some text ...
136+and some text following ...
137−
138−| name | age | sex |
139−| joan | 24 | f |
140−| archie| 29 | m |
141−| bella | 45 | f |
142−
143
137
144h2. With headers
138h2. With headers
145
139
@@ -149,6 +143,7 @@ h2. With headers
149| bella | 45 | f |
143| bella | 45 | f |
150
144
151
145
146+
152h1. Images
147h1. Images
153
148
154Textile inline image syntax, like
149Textile inline image syntax, like