git.iko.soy/typeable/pandoc
on master help sign in
Shared: Export uniqueIdent, don't allow tilde in identifier.

git-svn-id: https://pandoc.googlecode.com/svn/trunk@1894 788f1e2b-df1e-0410-8736-df70ead52e1b

commit26b41ce7ba2944f312a54b555baeba2351c1c025 authorfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> dateTue 16 Mar 2010, 06:45 (17 years ago) parent9562390
2 files changed+5−3
README+1−2 src/Text/Pandoc/Shared.hs+4−1
README+1−2
@@ -1044,8 +1044,7 @@ identifier. This identifier is based on the text of the header. To
10441044derive the identifier from the header text,
10451045
10461046 - Remove all formatting, links, etc.
1047− - Remove all punctuation, except underscores, hyphens, periods,
1048− and tildes.
1047+ - Remove all punctuation, except underscores, hyphens, and periods.
10491048 - Replace all spaces and newlines with hyphens.
10501049 - Convert all alphabetic characters to lowercase.
10511050 - Remove everything up to the first letter (identifiers may
src/Text/Pandoc/Shared.hs+4−1
@@ -97,6 +97,7 @@ module Text.Pandoc.Shared (
9797 compactify,
9898 Element (..),
9999 hierarchicalize,
100+ uniqueIdent,
100101 isHeaderBlock,
101102 -- * Writer options
102103 HTMLMathMethod (..),
@@ -902,7 +903,7 @@ inlineListToIdentifier' [] = ""
902903inlineListToIdentifier' (x:xs) =
903904 xAsText ++ inlineListToIdentifier' xs
904905 where xAsText = case x of
905− Str s -> filter (\c -> c `elem` "_-.~" || not (isPunctuation c)) $
906+ Str s -> filter (\c -> c `elem` "_-." || not (isPunctuation c)) $
906907 intercalate "-" $ words $ map toLower s
907908 Emph lst -> inlineListToIdentifier' lst
908909 Strikeout lst -> inlineListToIdentifier' lst
@@ -952,6 +953,8 @@ headerLtEq :: Int -> Block -> Bool
952953headerLtEq level (Header l _) = l <= level
953954headerLtEq _ _ = False
954955
956+-- | Generate a unique identifier from a list of inlines.
957+-- Second argument is a list of already used identifiers.
955958uniqueIdent :: [Inline] -> [String] -> String
956959uniqueIdent title' usedIdents =
957960 let baseIdent = inlineListToIdentifier title'