diff options
author | John MacFarlane <fiddlosopher@gmail.com> | 2012-09-12 19:48:11 -0700 |
---|---|---|
committer | John MacFarlane <fiddlosopher@gmail.com> | 2012-09-12 19:48:11 -0700 |
commit | def768cd1f15ce1093d6da9ce263b0045db269e2 (patch) | |
tree | 36aacd588eb4bfe488c27b183951100104aa9c66 | |
parent | a76c6df826289f09293723e2ed56237684d5aca0 (diff) | |
download | pandoc-def768cd1f15ce1093d6da9ce263b0045db269e2.tar.gz |
Added tests for mediawiki lists.
-rw-r--r-- | src/Text/Pandoc/Readers/MediaWiki.hs | 5 | ||||
-rw-r--r-- | tests/mediawiki-reader.native | 60 | ||||
-rw-r--r-- | tests/mediawiki-reader.wiki | 45 |
3 files changed, 107 insertions, 3 deletions
diff --git a/src/Text/Pandoc/Readers/MediaWiki.hs b/src/Text/Pandoc/Readers/MediaWiki.hs index ed96d6ccd..3bf4a0cdb 100644 --- a/src/Text/Pandoc/Readers/MediaWiki.hs +++ b/src/Text/Pandoc/Readers/MediaWiki.hs @@ -44,7 +44,6 @@ _ raw mediawiki: _ templates or anything in {{}} (can be postprocessed) _ category links _ gallery tag? -_ tests for native lists -} module Text.Pandoc.Readers.MediaWiki ( readMediaWiki ) where @@ -308,7 +307,9 @@ url = do return $ B.link src "" (B.str orig) nowiki :: MWParser Inlines -nowiki = B.text <$> charsInTags "nowiki" +nowiki = B.text . fromEntities <$> try + (htmlTag (~== TagOpen "nowiki" []) *> + manyTill anyChar (htmlTag (~== TagClose "nowiki"))) strikeout :: MWParser Inlines strikeout = B.strikeout <$> (inlinesInTags "strike" <|> inlinesInTags "del") diff --git a/tests/mediawiki-reader.native b/tests/mediawiki-reader.native index 61dff0a6e..beb76c40c 100644 --- a/tests/mediawiki-reader.native +++ b/tests/mediawiki-reader.native @@ -71,4 +71,62 @@ Pandoc (Meta {docTitle = [], docAuthors = [], docDate = []}) ,Para [Str "Nother",Space,Str "paragraph."] ,Header 2 [Str "external",Space,Str "links"] ,Para [Link [Emph [Str "Google"],Space,Str "search",Space,Str "engine"] ("http://google.com","")] -,Para [Link [Str "http://johnmacfarlane.net/pandoc/"] ("http://johnmacfarlane.net/pandoc/","")]] +,Para [Link [Str "http://johnmacfarlane.net/pandoc/"] ("http://johnmacfarlane.net/pandoc/","")] +,Header 2 [Str "lists"] +,BulletList + [[Plain [Str "Start",Space,Str "each",Space,Str "line"]] + ,[Plain [Str "with",Space,Str "an",Space,Str "asterisk",Space,Str "(*)."] + ,BulletList + [[Plain [Str "More",Space,Str "asterisks",Space,Str "gives",Space,Str "deeper"] + ,BulletList + [[Plain [Str "and",Space,Str "deeper",Space,Str "levels."]]]]]] + ,[Plain [Str "Line",Space,Str "breaks",LineBreak,Str "don't",Space,Str "break",Space,Str "levels."] + ,BulletList + [[BulletList + [[Plain [Str "But",Space,Str "jumping",Space,Str "levels",Space,Str "creates",Space,Str "empty",Space,Str "space."]]]]]]] +,Para [Str "Any",Space,Str "other",Space,Str "start",Space,Str "ends",Space,Str "the",Space,Str "list."] +,OrderedList (1,DefaultStyle,DefaultDelim) + [[Plain [Str "Start",Space,Str "each",Space,Str "line"]] + ,[Plain [Str "with",Space,Str "a",Space,Str "number",Space,Str "sign",Space,Str "(#)."] + ,OrderedList (1,DefaultStyle,DefaultDelim) + [[Plain [Str "More",Space,Str "number",Space,Str "signs",Space,Str "gives",Space,Str "deeper"] + ,OrderedList (1,DefaultStyle,DefaultDelim) + [[Plain [Str "and",Space,Str "deeper"]] + ,[Plain [Str "levels."]]]]]] + ,[Plain [Str "Line",Space,Str "breaks",LineBreak,Str "don't",Space,Str "break",Space,Str "levels."] + ,OrderedList (1,DefaultStyle,DefaultDelim) + [[OrderedList (1,DefaultStyle,DefaultDelim) + [[Plain [Str "But",Space,Str "jumping",Space,Str "levels",Space,Str "creates",Space,Str "empty",Space,Str "space."]]]]]] + ,[Plain [Str "Blank",Space,Str "lines"]]] +,OrderedList (1,DefaultStyle,DefaultDelim) + [[Plain [Str "end",Space,Str "the",Space,Str "list",Space,Str "and",Space,Str "start",Space,Str "another."]]] +,Para [Str "Any",Space,Str "other",Space,Str "start",Space,Str "also",Space,Str "ends",Space,Str "the",Space,Str "list."] +,DefinitionList + [([Str "item",Space,Str "1"], + [[Plain [Str "definition",Space,Str "1"]]]) + ,([Str "item",Space,Str "2"], + [[Plain [Str "definition",Space,Str "2-1"]] + ,[Plain [Str "definition",Space,Str "2-2"]]])] +,OrderedList (1,DefaultStyle,DefaultDelim) + [[Plain [Str "one"]] + ,[Plain [Str "two"] + ,BulletList + [[Plain [Str "two",Space,Str "point",Space,Str "one"]] + ,[Plain [Str "two",Space,Str "point",Space,Str "two"]]]] + ,[Plain [Str "three"] + ,DefinitionList + [([Str "three",Space,Str "item",Space,Str "one"], + [[Plain [Str "three",Space,Str "def",Space,Str "one"]]])]] + ,[Plain [Str "four"] + ,DefinitionList + [([], + [[Plain [Str "four",Space,Str "def",Space,Str "one"]] + ,[Plain [Str "this",Space,Str "looks",Space,Str "like",Space,Str "a",Space,Str "continuation"]] + ,[Plain [Str "and",Space,Str "is",Space,Str "often",Space,Str "used"]] + ,[Plain [Str "instead",LineBreak,Str "of",Space,Str "<br/>"]]])]] + ,[Plain [Str "five"] + ,OrderedList (1,DefaultStyle,DefaultDelim) + [[Plain [Str "five",Space,Str "sub",Space,Str "1"] + ,OrderedList (1,DefaultStyle,DefaultDelim) + [[Plain [Str "five",Space,Str "sub",Space,Str "1",Space,Str "sub",Space,Str "1"]]]] + ,[Plain [Str "five",Space,Str "sub",Space,Str "2"]]]]]] diff --git a/tests/mediawiki-reader.wiki b/tests/mediawiki-reader.wiki index b1f6b06c4..5edaa2e16 100644 --- a/tests/mediawiki-reader.wiki +++ b/tests/mediawiki-reader.wiki @@ -143,4 +143,49 @@ Nother paragraph. http://johnmacfarlane.net/pandoc/ +== lists == + +* Start each line +* with an asterisk (*). +** More asterisks gives deeper +*** and deeper levels. +* Line breaks<br/>don't break levels. +*** But jumping levels creates empty space. +Any other start ends the list. + +# Start each line +# with a number sign (#). +## More number signs gives deeper +### and deeper +### levels. +# Line breaks<br/>don't break levels. +### But jumping levels creates empty space. +# Blank lines + +# end the list and start another. +Any other start also +ends the list. + +;item 1 +: definition 1 +;item 2 +: definition 2-1 +: definition 2-2 + +# one +# two +#* two point one +#* two point two +# three +#; three item one +#: three def one +# four +#: four def one +#: this looks like a continuation +#: and is often used +#: instead<br/>of <nowiki><br/></nowiki> +# five +## five sub 1 +### five sub 1 sub 1 +## five sub 2 |