git.iko.soy/typeable/pandoc
on master help sign in
MediaWiki reader: Accept image links in more languages
303e42aJaime Marquínez Ferrándiz
src/Text/Pandoc/Readers/MediaWiki.hs+5−1
@@ -549,10 +549,14 @@ endline = () <$ try (newline <*
549 notFollowedBy' header <*
549 notFollowedBy' header <*
550 notFollowedBy anyListStart)
550 notFollowedBy anyListStart)
551
551
552+imageIdentifiers :: [MWParser ()]
553+imageIdentifiers = [sym (identifier ++ ":") | identifier <- identifiers]
554+ where identifiers = ["File", "Image", "Archivo", "Datei", "Fichier"]
555+
552image :: MWParser Inlines
556image :: MWParser Inlines
553image = try $ do
557image = try $ do
554 sym "[["
558 sym "[["
555− sym "File:" <|> sym "Image:"
559+ choice imageIdentifiers
556 fname <- many1 (noneOf "|]")
560 fname <- many1 (noneOf "|]")
557 _ <- many (try $ char '|' *> imageOption)
561 _ <- many (try $ char '|' *> imageOption)
558 caption <- (B.str fname <$ sym "]]")
562 caption <- (B.str fname <$ sym "]]")
tests/mediawiki-reader.native+1
@@ -88,6 +88,7 @@ Pandoc (Meta {unMeta = fromList []})
88,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")]
88,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")]
89,Para [Image [Str "caption"] ("example.jpg","fig:caption")]
89,Para [Image [Str "caption"] ("example.jpg","fig:caption")]
90,Para [Image [Str "example.jpg"] ("example.jpg","fig:example.jpg")]
90,Para [Image [Str "example.jpg"] ("example.jpg","fig:example.jpg")]
91+,Para [Image [Str "example_es.jpg"] ("example_es.jpg","fig:example_es.jpg")]
91,Header 2 ("lists",[],[]) [Str "lists"]
92,Header 2 ("lists",[],[]) [Str "lists"]
92,BulletList
93,BulletList
93 [[Plain [Str "Start",Space,Str "each",Space,Str "line"]]
94 [[Plain [Str "Start",Space,Str "each",Space,Str "line"]]
tests/mediawiki-reader.wiki+2
@@ -173,6 +173,8 @@ http://johnmacfarlane.net/pandoc/
173
173
174[[File:example.jpg]]
174[[File:example.jpg]]
175
175
176+[[Archivo:example_es.jpg]]
177+
176== lists ==
178== lists ==
177
179
178* Start each line
180* Start each line