git.iko.soy/typeable/pandoc
on master help sign in
MediaWiki reader: Accept image links in more languages

In some of the Wikipedia versions the local version of 'File' is used (for example 'Archivo' in Spanish)

commit303e42a94f16e00ecb65fb9de2d282d050a626c1 authorJaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@gmail.com> dateSun 24 Nov 2013, 12:51 (13 years ago) parente1a9a61
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
@@ -549,10 +549,14 @@ endline = () <$ try (newline <*
549549 notFollowedBy' header <*
550550 notFollowedBy anyListStart)
551551
552+imageIdentifiers :: [MWParser ()]
553+imageIdentifiers = [sym (identifier ++ ":") | identifier <- identifiers]
554+ where identifiers = ["File", "Image", "Archivo", "Datei", "Fichier"]
555+
552556image :: MWParser Inlines
553557image = try $ do
554558 sym "[["
555− sym "File:" <|> sym "Image:"
559+ choice imageIdentifiers
556560 fname <- many1 (noneOf "|]")
557561 _ <- many (try $ char '|' *> imageOption)
558562 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