@@ -34,7 +34,7 @@ import Text.Pandoc.Entities (decodeEntities)
3434import Text.Regex ( mkRegex, matchRegex )
3535import Numeric ( showHex )
3636import Data.Char ( ord, toLower )
37−import Data.List ( isPrefixOf, partition )
37+import Data.List ( isPrefixOf, partition, intersperse )
3838import Control.Monad.State
3939import Text.XHtml.Strict
4040
@@ -169,22 +169,32 @@ obfuscateChar char =
169169obfuscateString :: String -> String
170170obfuscateString = (concatMap obfuscateChar) . decodeEntities
171171
172+-- | True if character is a punctuation character (unicode).
173+isPunctuation :: Char -> Bool
174+isPunctuation c =
175+ let c' = ord c in
176+ if (c `elem` "!\"'()*,-./:;<>?[\\]`{|}~") || (c' >= 0x2000 && c' <= 0x206F) ||
177+ (c' >= 0xE000 && c' <= 0xE0FF)
178+ then True
179+ else False
180+
172181-- | Convert Pandoc inline list to plain text identifier.
173182inlineListToIdentifier :: [Inline] -> String
174183inlineListToIdentifier [] = ""
175184inlineListToIdentifier (x:xs) =
176185 xAsText ++ inlineListToIdentifier xs
177186 where xAsText = case x of
178− Str s -> map toLower s
187+ Str s -> filter (\c -> (c == '-') || not (isPunctuation c)) $
188+ concat $ intersperse "-" $ words $ map toLower s
179189 Emph lst -> inlineListToIdentifier lst
180190 Strong lst -> inlineListToIdentifier lst
181191 Quoted _ lst -> inlineListToIdentifier lst
182192 Code s -> s
183193 Space -> "-"
184− EmDash -> "--"
194+ EmDash -> "-"
185195 EnDash -> "-"
186196 Apostrophe -> ""
187− Ellipses -> "..."
197+ Ellipses -> ""
188198 LineBreak -> "-"
189199 TeX _ -> ""
190200 HtmlInline _ -> ""