diff options
| author | John MacFarlane <[email protected]> | 2024-06-17 13:41:31 -0700 |
|---|---|---|
| committer | John MacFarlane <[email protected]> | 2024-06-17 13:41:31 -0700 |
| commit | 97b3056f4ea2d9ddb8635c4a9ff1703e64013617 (patch) | |
| tree | e96c7550a48f25fb0ea6bb5850e312cb3384cf0d /src/Text | |
| parent | fde7908091661e731cff48e8823394aa1e7f873e (diff) | |
Make `gfm_auto_identifiers` work as advertised.
It is supposed to replace emojis with their aliases,
but previously this only worked when the emojis were
in a specially marked span.
Note that this change doesn't affect `commonmark` (or `gfm`)
because the relevant code is in commonmark-hs. This will also
need updating.
See #9876.
Diffstat (limited to 'src/Text')
| -rw-r--r-- | src/Text/Pandoc/Shared.hs | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/Text/Pandoc/Shared.hs b/src/Text/Pandoc/Shared.hs index a0165ecd7..a2a39ac43 100644 --- a/src/Text/Pandoc/Shared.hs +++ b/src/Text/Pandoc/Shared.hs @@ -98,6 +98,7 @@ import Data.Semigroup (Min (..)) import Data.Sequence (ViewL (..), ViewR (..), viewl, viewr) import qualified Data.Set as Set import qualified Data.Text as T +import qualified Text.Emoji as Emoji import System.Directory import System.FilePath (isPathSeparator, splitDirectories) import qualified System.FilePath.Posix as Posix @@ -464,7 +465,7 @@ isPara _ = False -- | Convert Pandoc inline list to plain text identifier. inlineListToIdentifier :: Extensions -> [Inline] -> T.Text inlineListToIdentifier exts = - textToIdentifier exts . stringify . walk unEmojify + textToIdentifier exts . stringify . unEmojify where unEmojify :: [Inline] -> [Inline] unEmojify @@ -472,7 +473,10 @@ inlineListToIdentifier exts = extensionEnabled Ext_ascii_identifiers exts = walk unEmoji | otherwise = id unEmoji (Span ("",["emoji"],[("data-emoji",ename)]) _) = Str ename + unEmoji (Str t) = Str (Emoji.replaceEmojis emojisToAliases t) unEmoji x = x + emojisToAliases t [] = t + emojisToAliases _ (a:_) = a -- | Convert string to plain text identifier. textToIdentifier :: Extensions -> T.Text -> T.Text |
