diff options
author | Paul Rivier <paul.r.ml@gmail.com> | 2010-10-04 20:34:57 +0200 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2010-12-03 23:10:51 -0800 |
commit | 593b4f6c948f2b32c6fef170a37d725285c8e9c4 (patch) | |
tree | a5601b96dc4dbb71f07e8ad015a4cf4955f177f5 | |
parent | a7da0672dc9bc9e362f62a4de5ab14bffd0e86bc (diff) | |
download | pandoc-593b4f6c948f2b32c6fef170a37d725285c8e9c4.tar.gz |
fix autolink by promoting it in the parser list, fix table parabreak
-rw-r--r-- | src/Text/Pandoc/Readers/Textile.hs | 12 | ||||
-rw-r--r-- | tests/textile-reader.native | 21 | ||||
-rw-r--r-- | tests/textile-reader.textile | 9 |
3 files changed, 9 insertions, 33 deletions
diff --git a/src/Text/Pandoc/Readers/Textile.hs b/src/Text/Pandoc/Readers/Textile.hs index 5e4609c01..463ba14be 100644 --- a/src/Text/Pandoc/Readers/Textile.hs +++ b/src/Text/Pandoc/Readers/Textile.hs @@ -190,7 +190,6 @@ tableRow :: GenParser Char ParserState [TableCell] tableRow = try $ do char '|' cells <- endBy1 tableCell (char '|') - -- TODO : don't eat the last newline newline return cells @@ -215,6 +214,7 @@ table :: GenParser Char ParserState Block table = try $ do headers <- option [] tableHeaders rows <- tableRows + blanklines let nbOfCols = max (length headers) (length $ head rows) return $ Table [] (replicate nbOfCols AlignDefault) @@ -239,7 +239,8 @@ inlines = manyTill inline newline -- | Inline parsers tried in order inlineParsers :: [GenParser Char ParserState Inline] -inlineParsers = [ str +inlineParsers = [ autoLink + , str , whitespace , endline , code @@ -253,8 +254,6 @@ inlineParsers = [ str , simpleInline (char '^') Superscript , simpleInline (char '~') Subscript , link - , autoLink - , image , image , symbol ] @@ -284,9 +283,10 @@ link = try $ do -- | Detect plain links to http or email. autoLink :: GenParser Char ParserState Inline autoLink = do - (orig, src) <- uri -- (try uri <|> try emailAddress) + (orig, src) <- (try uri <|> try emailAddress) return $ Link [Str orig] (src, "") + -- | image embedding image :: GenParser Char ParserState Inline image = try $ do @@ -326,7 +326,5 @@ simpleInline border construct = surrounded border inline >>= -- -- - Pandoc Meta Information (title, author, date) -- - footnotes --- - autolink is not called -- - should autolink be shared through Parsing.hs ? -- - Inserted inline handling in writers --- - table parser is a bit too greedy and require a double newline after tables
\ No newline at end of file diff --git a/tests/textile-reader.native b/tests/textile-reader.native index 788a79e51..3daf704d2 100644 --- a/tests/textile-reader.native +++ b/tests/textile-reader.native @@ -65,7 +65,7 @@ Pandoc (Meta {docTitle = [Str ""], docAuthors = [[Str ""]], docDate = [Str ""]}) , Header 2 [Str "Explicit"] , Para [Str "Just",Space,Str "a",Space,Link [Str "url"] ("http://www.url.com","")] , Para [Link [Str "Email",Space,Str "link"] ("mailto:nobody@nowhere.net","")] -, 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."] +, 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 "."] , Header 1 [Str "Tables"] , Para [Str "Textile",Space,Str "allows",Space,Str "tables",Space,Str "with",Space,Str "and",Space,Str "without",Space,Str "headers",Space,Str ":"] , Header 2 [Str "Without",Space,Str "headers"] @@ -84,23 +84,7 @@ Pandoc (Meta {docTitle = [Str ""], docAuthors = [[Str ""]], docDate = [Str ""]}) [ [ Plain [Str "bella"] ] , [ Plain [Str "45"] ] , [ Plain [Str "f"] ] ] ] -, Para [Str "And",Space,Str "some",Space,Str "text",Space,Str "..."] -, Table [] [AlignDefault,AlignDefault,AlignDefault] [0.0,0.0,0.0] - [ - ] [ - [ [ Plain [Str "name"] ] - , [ Plain [Str "age"] ] - , [ Plain [Str "sex"] ] ], - [ [ Plain [Str "joan"] ] - , [ Plain [Str "24"] ] - , [ Plain [Str "f"] ] ], - [ [ Plain [Str "archie"] ] - , [ Plain [Str "29"] ] - , [ Plain [Str "m"] ] ], - [ [ Plain [Str "bella"] ] - , [ Plain [Str "45"] ] - , [ Plain [Str "f"] ] ] ] -, Para [] +, Para [Str "and",Space,Str "some",Space,Str "text",Space,Str "following",Space,Str "..."] , Header 2 [Str "With",Space,Str "headers"] , Table [] [AlignDefault,AlignDefault,AlignDefault] [0.0,0.0,0.0] [ [ Plain [Str "name"] ] @@ -115,6 +99,5 @@ Pandoc (Meta {docTitle = [Str ""], docAuthors = [[Str ""]], docDate = [Str ""]}) [ [ Plain [Str "bella"] ] , [ Plain [Str "45"] ] , [ Plain [Str "f"] ] ] ] -, Para [] , Header 1 [Str "Images"] , 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 "."] ] diff --git a/tests/textile-reader.textile b/tests/textile-reader.textile index b4c10b1b1..efb052305 100644 --- a/tests/textile-reader.textile +++ b/tests/textile-reader.textile @@ -133,13 +133,7 @@ h2. Without headers | archie | 29 | m | | bella | 45 | f | -And some text ... - -| name | age | sex | -| joan | 24 | f | -| archie| 29 | m | -| bella | 45 | f | - +and some text following ... h2. With headers @@ -149,6 +143,7 @@ h2. With headers | bella | 45 | f | + h1. Images Textile inline image syntax, like |