Skip to content

Commit fdfa9fc

Browse files
authored
Refine "blending" rules for MediaWiki links
The rules for "blending" characters outside a link into the link are described here: https://en.wikipedia.org/wiki/Help:Wikitext#Blend_link These pose a problem for CJK languages, which generally don't have spaces after links. However, it turns out that the blending behavior, as implemented on Wikipedia, is (contrary to the documentation) only for ASCII letters. This commit implements that restriction, which fixes the problem for CJK. (#8525)
1 parent 4746d0c commit fdfa9fc

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/Text/Pandoc/Readers/MediaWiki.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ module Text.Pandoc.Readers.MediaWiki ( readMediaWiki ) where
1919

2020
import Control.Monad
2121
import Control.Monad.Except (throwError)
22-
import Data.Char (isDigit, isSpace)
22+
import Data.Char (isAscii, isDigit, isLetter, isSpace)
2323
import qualified Data.Foldable as F
2424
import Data.List (intersperse)
2525
import Data.Maybe (fromMaybe, maybeToList)
@@ -664,7 +664,7 @@ internalLink = try $ do
664664
-- [[Help:Contents|] -> "Contents"
665665
<|> return (B.text $ T.drop 1 $ T.dropWhile (/=':') pagename) )
666666
sym "]]"
667-
linktrail <- B.text <$> manyChar letter
667+
linktrail <- B.text <$> manyChar (satisfy (\c -> isAscii c && isLetter c))
668668
let link = B.link (addUnderscores pagename) "wikilink" (label <> linktrail)
669669
if "Category:" `T.isPrefixOf` pagename
670670
then do

0 commit comments

Comments
 (0)