aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc
diff options
context:
space:
mode:
authorfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b>2010-03-16 06:45:52 +0000
committerfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b>2010-03-16 06:45:52 +0000
commit26b41ce7ba2944f312a54b555baeba2351c1c025 (patch)
treee8b18b0a056d48d4f4de2a2d792775f43513984f /src/Text/Pandoc
parent9562390d6883110bd00d5b667761ec6b615eb5d7 (diff)
downloadpandoc-26b41ce7ba2944f312a54b555baeba2351c1c025.tar.gz
Shared: Export uniqueIdent, don't allow tilde in identifier.
git-svn-id: https://pandoc.googlecode.com/svn/trunk@1894 788f1e2b-df1e-0410-8736-df70ead52e1b
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r--src/Text/Pandoc/Shared.hs5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/Text/Pandoc/Shared.hs b/src/Text/Pandoc/Shared.hs
index 14086c20f..a27a2c907 100644
--- a/src/Text/Pandoc/Shared.hs
+++ b/src/Text/Pandoc/Shared.hs
@@ -97,6 +97,7 @@ module Text.Pandoc.Shared (
compactify,
Element (..),
hierarchicalize,
+ uniqueIdent,
isHeaderBlock,
-- * Writer options
HTMLMathMethod (..),
@@ -902,7 +903,7 @@ inlineListToIdentifier' [] = ""
inlineListToIdentifier' (x:xs) =
xAsText ++ inlineListToIdentifier' xs
where xAsText = case x of
- Str s -> filter (\c -> c `elem` "_-.~" || not (isPunctuation c)) $
+ Str s -> filter (\c -> c `elem` "_-." || not (isPunctuation c)) $
intercalate "-" $ words $ map toLower s
Emph lst -> inlineListToIdentifier' lst
Strikeout lst -> inlineListToIdentifier' lst
@@ -952,6 +953,8 @@ headerLtEq :: Int -> Block -> Bool
headerLtEq level (Header l _) = l <= level
headerLtEq _ _ = False
+-- | Generate a unique identifier from a list of inlines.
+-- Second argument is a list of already used identifiers.
uniqueIdent :: [Inline] -> [String] -> String
uniqueIdent title' usedIdents =
let baseIdent = inlineListToIdentifier title'