aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2018-11-11 20:45:38 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2018-11-11 20:45:38 -0800
commit5bc38a741bdd5a0470b92c4cd62769bb8dd4ddf2 (patch)
tree2e53efa2c5b2092513597893101ada203e9a27fb /src/Text/Pandoc
parent16af096a68596538f5161463a286ad37605fbf6f (diff)
downloadpandoc-5bc38a741bdd5a0470b92c4cd62769bb8dd4ddf2.tar.gz
Exactly match GitHub's identifier generating algorithm.
See #5057.
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r--src/Text/Pandoc/Shared.hs9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/Text/Pandoc/Shared.hs b/src/Text/Pandoc/Shared.hs
index 0b29347a3..0bb9b20d7 100644
--- a/src/Text/Pandoc/Shared.hs
+++ b/src/Text/Pandoc/Shared.hs
@@ -116,7 +116,9 @@ import Control.Monad (MonadPlus (..), msum, unless)
import qualified Control.Monad.State.Strict as S
import qualified Data.ByteString.Lazy as BL
import qualified Data.Bifunctor as Bifunctor
-import Data.Char (isAlpha, isLower, isSpace, isUpper, toLower, isAlphaNum)
+import Data.Char (isAlpha, isLower, isSpace, isUpper, toLower, isAlphaNum,
+ generalCategory, GeneralCategory(NonSpacingMark,
+ SpacingCombiningMark, EnclosingMark, ConnectorPunctuation))
import Data.Data (Data, Typeable)
import Data.List (find, intercalate, intersperse, stripPrefix)
import qualified Data.Map as M
@@ -504,7 +506,10 @@ inlineListToIdentifier exts =
| otherwise = intercalate "-" . words . filterPunct . map toLower
filterPunct = filter (\c -> isSpace c || isAlphaNum c || isAllowedPunct c)
isAllowedPunct c
- | extensionEnabled Ext_gfm_auto_identifiers exts = c == '_' || c == '-'
+ | extensionEnabled Ext_gfm_auto_identifiers exts
+ = c == '-' || c == '_' ||
+ generalCategory c `elem` [NonSpacingMark, SpacingCombiningMark,
+ EnclosingMark, ConnectorPunctuation]
| otherwise = c == '_' || c == '-' || c == '.'
spaceToDash = map (\c -> if isSpace c then '-' else c)