diff options
-rw-r--r-- | src/Text/Pandoc/Readers/MediaWiki.hs | 8 | ||||
-rw-r--r-- | tests/mediawiki-reader.native | 2 | ||||
-rw-r--r-- | tests/mediawiki-reader.wiki | 4 |
3 files changed, 10 insertions, 4 deletions
diff --git a/src/Text/Pandoc/Readers/MediaWiki.hs b/src/Text/Pandoc/Readers/MediaWiki.hs index 3c83f60f9..111e0355f 100644 --- a/src/Text/Pandoc/Readers/MediaWiki.hs +++ b/src/Text/Pandoc/Readers/MediaWiki.hs @@ -30,8 +30,6 @@ Conversion of mediawiki text to 'Pandoc' document. -} {- TODO: -_ support internal links http://www.mediawiki.org/wiki/Help:Links -_ support external links (partially implemented) _ support images http://www.mediawiki.org/wiki/Help:Images _ support tables http://www.mediawiki.org/wiki/Help:Tables - footnotes? @@ -51,7 +49,7 @@ import Text.Pandoc.Shared ( stripTrailingNewlines, safeRead ) import Data.Monoid (mconcat, mempty) import Control.Applicative ((<$>), (<*), (*>), (<$)) import Control.Monad -import Data.List (intersperse) +import Data.List (intersperse, intercalate ) import Text.HTML.TagSoup import Data.Sequence (viewl, ViewL(..), (<|)) @@ -379,6 +377,8 @@ endline = () <$ try (newline <* internalLink :: MWParser Inlines internalLink = try $ do string "[[" + let addUnderscores x = let (pref,suff) = break (=='#') x + in pref ++ intercalate "_" (words suff) pagename <- unwords . words <$> many (noneOf "|]") label <- option (B.text pagename) $ char '|' *> ( (mconcat <$> many1 (notFollowedBy (char ']') *> inline)) @@ -387,7 +387,7 @@ internalLink = try $ do <|> (return $ B.text $ drop 1 $ dropWhile (/=':') pagename) ) string "]]" linktrail <- B.text <$> many (char '\'' <|> letter) - return $ B.link pagename "wikilink" (label <> linktrail) + return $ B.link (addUnderscores pagename) "wikilink" (label <> linktrail) externalLink :: MWParser Inlines externalLink = try $ do diff --git a/tests/mediawiki-reader.native b/tests/mediawiki-reader.native index c38736cd4..2a573af9c 100644 --- a/tests/mediawiki-reader.native +++ b/tests/mediawiki-reader.native @@ -80,6 +80,8 @@ Pandoc (Meta {docTitle = [], docAuthors = [], docDate = []}) ,Para [Link [Str "Helpers"] ("Help","wikilink")] ,Para [Link [Str "Help"] ("Help","wikilink"),Str "ers"] ,Para [Link [Str "Contents"] ("Help:Contents","wikilink")] +,Para [Link [Str "#My",Space,Str "anchor"] ("#My_anchor","wikilink")] +,Para [Link [Str "and",Space,Str "text"] ("Page#with_anchor","wikilink")] ,Header 2 [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 34fe8ade5..12393f110 100644 --- a/tests/mediawiki-reader.wiki +++ b/tests/mediawiki-reader.wiki @@ -159,6 +159,10 @@ http://johnmacfarlane.net/pandoc/ [[Help:Contents|]] +[[#My anchor]] + +[[Page#with anchor|and text]] + == lists == * Start each line |