git.iko.soy/typeable/pandoc
on master help sign in
Merge pull request #1068 from jaimeMF/mw-images-langs

MediaWiki reader: Accept image links in more languages

commitb9cc29e15ab219102f09e19d61889c256eb0b487 authorJohn MacFarlane <jgm@berkeley.edu> dateMon 24 Mar 2014, 10:39 (13 years ago) parent3fa38db303e42a
3 files changed+8−1
src/Text/Pandoc/Readers/MediaWiki.hs+5−1 tests/mediawiki-reader.native+1 tests/mediawiki-reader.wiki+2
src/Text/Pandoc/Readers/MediaWiki.hs+5−1
@@ -555,10 +555,14 @@ endline = () <$ try (newline <*
555555 notFollowedBy' header <*
556556 notFollowedBy anyListStart)
557557
558+imageIdentifiers :: [MWParser ()]
559+imageIdentifiers = [sym (identifier ++ ":") | identifier <- identifiers]
560+ where identifiers = ["File", "Image", "Archivo", "Datei", "Fichier"]
561+
558562image :: MWParser Inlines
559563image = try $ do
560564 sym "[["
561− sym "File:" <|> sym "Image:"
565+ choice imageIdentifiers
562566 fname <- many1 (noneOf "|]")
563567 _ <- many (try $ char '|' *> imageOption)
564568 caption <- (B.str fname <$ sym "]]")
tests/mediawiki-reader.native+1
@@ -88,6 +88,7 @@ Pandoc (Meta {unMeta = fromList []})
8888,Para [Image [Str "the",Space,Emph [Str "caption"],Space,Str "with",Space,Link [Str "external",Space,Str "link"] ("http://google.com","")] ("example.jpg","fig:the caption with external link")]
8989,Para [Image [Str "caption"] ("example.jpg","fig:caption")]
9090,Para [Image [Str "example.jpg"] ("example.jpg","fig:example.jpg")]
91+,Para [Image [Str "example_es.jpg"] ("example_es.jpg","fig:example_es.jpg")]
9192,Header 2 ("lists",[],[]) [Str "lists"]
9293,BulletList
9394 [[Plain [Str "Start",Space,Str "each",Space,Str "line"]]
tests/mediawiki-reader.wiki+2
@@ -173,6 +173,8 @@ http://johnmacfarlane.net/pandoc/
173173
174174[[File:example.jpg]]
175175
176+[[Archivo:example_es.jpg]]
177+
176178== lists ==
177179
178180* Start each line