Fix gfm_auto_identifiers
behavior with emojis.
Closes #5813. Note that we also now use emoji names for emojis when `ascii_identifiers` is enabled.
This commit is contained in:
parent
7c2dd0359b
commit
9e3e195dd4
3 changed files with 15 additions and 1 deletions
|
@ -2575,6 +2575,7 @@ Changes the algorithm used by `auto_identifiers` to conform to
|
||||||
GitHub's method. Spaces are converted to dashes (`-`),
|
GitHub's method. Spaces are converted to dashes (`-`),
|
||||||
uppercase characters to lowercase characters, and punctuation
|
uppercase characters to lowercase characters, and punctuation
|
||||||
characters other than `-` and `_` are removed.
|
characters other than `-` and `_` are removed.
|
||||||
|
Emojis are replaced by their names.
|
||||||
|
|
||||||
## Math Input
|
## Math Input
|
||||||
|
|
||||||
|
|
|
@ -463,8 +463,15 @@ isPara _ = False
|
||||||
-- letters, digits, and the characters _-.
|
-- letters, digits, and the characters _-.
|
||||||
inlineListToIdentifier :: Extensions -> [Inline] -> String
|
inlineListToIdentifier :: Extensions -> [Inline] -> String
|
||||||
inlineListToIdentifier exts =
|
inlineListToIdentifier exts =
|
||||||
dropNonLetter . filterAscii . toIdent . stringify
|
dropNonLetter . filterAscii . toIdent . stringify . walk unEmojify
|
||||||
where
|
where
|
||||||
|
unEmojify :: [Inline] -> [Inline]
|
||||||
|
unEmojify
|
||||||
|
| extensionEnabled Ext_gfm_auto_identifiers exts ||
|
||||||
|
extensionEnabled Ext_ascii_identifiers exts = walk unEmoji
|
||||||
|
| otherwise = id
|
||||||
|
unEmoji (Span ("",["emoji"],[("data-emoji",ename)]) _) = Str ename
|
||||||
|
unEmoji x = x
|
||||||
dropNonLetter
|
dropNonLetter
|
||||||
| extensionEnabled Ext_gfm_auto_identifiers exts = id
|
| extensionEnabled Ext_gfm_auto_identifiers exts = id
|
||||||
| otherwise = dropWhile (not . isAlpha)
|
| otherwise = dropWhile (not . isAlpha)
|
||||||
|
|
6
test/command/5813.md
Normal file
6
test/command/5813.md
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
```
|
||||||
|
% pandoc -f gfm
|
||||||
|
### Jekyll Plugins & Gems :gem:
|
||||||
|
^D
|
||||||
|
<h3 id="jekyll-plugins--gems-gem">Jekyll Plugins & Gems <span class="emoji" data-emoji="gem">💎</span></h3>
|
||||||
|
```
|
Loading…
Reference in a new issue