Shared: Export uniqueIdent, don't allow tilde in identifier.
git-svn-id: https://pandoc.googlecode.com/svn/trunk@1894 788f1e2b-df1e-0410-8736-df70ead52e1b
This commit is contained in:
parent
9562390d68
commit
26b41ce7ba
2 changed files with 5 additions and 3 deletions
3
README
3
README
|
@ -1044,8 +1044,7 @@ identifier. This identifier is based on the text of the header. To
|
|||
derive the identifier from the header text,
|
||||
|
||||
- Remove all formatting, links, etc.
|
||||
- Remove all punctuation, except underscores, hyphens, periods,
|
||||
and tildes.
|
||||
- Remove all punctuation, except underscores, hyphens, and periods.
|
||||
- Replace all spaces and newlines with hyphens.
|
||||
- Convert all alphabetic characters to lowercase.
|
||||
- Remove everything up to the first letter (identifiers may
|
||||
|
|
|
@ -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'
|
||||
|
|
Loading…
Add table
Reference in a new issue