From 303e42a94f16e00ecb65fb9de2d282d050a626c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaime=20Marqui=CC=81nez=20Ferra=CC=81ndiz?= Date: Sun, 24 Nov 2013 12:51:41 +0100 Subject: [PATCH] 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) --- src/Text/Pandoc/Readers/MediaWiki.hs | 6 +++++- tests/mediawiki-reader.native | 1 + tests/mediawiki-reader.wiki | 2 ++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Text/Pandoc/Readers/MediaWiki.hs b/src/Text/Pandoc/Readers/MediaWiki.hs index 1c074e3de..7f99af528 100644 --- a/src/Text/Pandoc/Readers/MediaWiki.hs +++ b/src/Text/Pandoc/Readers/MediaWiki.hs @@ -549,10 +549,14 @@ endline = () <$ try (newline <* notFollowedBy' header <* notFollowedBy anyListStart) +imageIdentifiers :: [MWParser ()] +imageIdentifiers = [sym (identifier ++ ":") | identifier <- identifiers] + where identifiers = ["File", "Image", "Archivo", "Datei", "Fichier"] + image :: MWParser Inlines image = try $ do sym "[[" - sym "File:" <|> sym "Image:" + choice imageIdentifiers fname <- many1 (noneOf "|]") _ <- many (try $ char '|' *> imageOption) caption <- (B.str fname <$ sym "]]") diff --git a/tests/mediawiki-reader.native b/tests/mediawiki-reader.native index 238413445..87e4043f7 100644 --- a/tests/mediawiki-reader.native +++ b/tests/mediawiki-reader.native @@ -88,6 +88,7 @@ Pandoc (Meta {unMeta = fromList []}) ,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")] ,Para [Image [Str "caption"] ("example.jpg","fig:caption")] ,Para [Image [Str "example.jpg"] ("example.jpg","fig:example.jpg")] +,Para [Image [Str "example_es.jpg"] ("example_es.jpg","fig:example_es.jpg")] ,Header 2 ("lists",[],[]) [Str "lists"] ,BulletList [[Plain [Str "Start",Space,Str "each",Space,Str "line"]] diff --git a/tests/mediawiki-reader.wiki b/tests/mediawiki-reader.wiki index 26f4ef164..15f586bda 100644 --- a/tests/mediawiki-reader.wiki +++ b/tests/mediawiki-reader.wiki @@ -173,6 +173,8 @@ http://johnmacfarlane.net/pandoc/ [[File:example.jpg]] +[[Archivo:example_es.jpg]] + == lists == * Start each line