Skip to content

Commit

Permalink
Refine "blending" rules for MediaWiki links
Browse files Browse the repository at this point in the history
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.  (jgm#8525)
  • Loading branch information
liruqi committed Mar 3, 2023
1 parent cbb8f9b commit b723f89
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Text/Pandoc/Readers/MediaWiki.hs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ module Text.Pandoc.Readers.MediaWiki ( readMediaWiki ) where

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

0 comments on commit b723f89

Please sign in to comment.