aboutsummaryrefslogtreecommitdiff
path: root/src/Text
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2010-12-19 10:13:36 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2010-12-19 10:13:36 -0800
commit09aec9f3e36bdfce0cc2060b9032b8eba6d85b4c (patch)
tree097a3ff04cd93c689b734a9bbbb9275b19e111e5 /src/Text
parent6aa5010617bda83e86483f1bb809a61a74a3cf8a (diff)
downloadpandoc-09aec9f3e36bdfce0cc2060b9032b8eba6d85b4c.tar.gz
Shared: Use stringify to simplify inlineListToIdentifier.
Diffstat (limited to 'src/Text')
-rw-r--r--src/Text/Pandoc/Shared.hs39
1 files changed, 11 insertions, 28 deletions
diff --git a/src/Text/Pandoc/Shared.hs b/src/Text/Pandoc/Shared.hs
index 7de3fabb2..c57ecb989 100644
--- a/src/Text/Pandoc/Shared.hs
+++ b/src/Text/Pandoc/Shared.hs
@@ -399,6 +399,11 @@ stringify = queryWith go
go (Str x) = x
go (Code x) = x
go (Math _ x) = x
+ go EmDash = "--"
+ go EnDash = "-"
+ go Apostrophe = "'"
+ go Ellipses = "..."
+ go LineBreak = " "
go _ = ""
-- | Change final list item from @Para@ to @Plain@ if the list contains
@@ -432,34 +437,12 @@ data Element = Blk Block
-- letters, digits, and the characters _-.
inlineListToIdentifier :: [Inline] -> String
inlineListToIdentifier =
- dropWhile (not . isAlpha) . intercalate "-" . words . map toLower .
- filter (\c -> isLetter c || isDigit c || c `elem` "_-. ") .
- concatMap extractText
- where extractText x = case x of
- Str s -> map nbspToSp s
- Emph lst -> concatMap extractText lst
- Strikeout lst -> concatMap extractText lst
- Superscript lst -> concatMap extractText lst
- SmallCaps lst -> concatMap extractText lst
- Subscript lst -> concatMap extractText lst
- Strong lst -> concatMap extractText lst
- Quoted _ lst -> concatMap extractText lst
- Cite _ lst -> concatMap extractText lst
- Code s -> s
- Space -> " "
- EmDash -> "---"
- EnDash -> "--"
- Apostrophe -> ""
- Ellipses -> "..."
- LineBreak -> " "
- Math _ s -> s
- TeX _ -> ""
- HtmlInline _ -> ""
- Link lst _ -> concatMap extractText lst
- Image lst _ -> concatMap extractText lst
- Note _ -> ""
- nbspToSp '\160' = ' '
- nbspToSp x = x
+ dropWhile (not . isAlpha) . intercalate "-" . words .
+ map (nbspToSp . toLower) .
+ filter (\c -> isLetter c || isDigit c || c `elem` "_-. ") .
+ stringify
+ where nbspToSp '\160' = ' '
+ nbspToSp x = x
-- | Convert list of Pandoc blocks into (hierarchical) list of Elements
hierarchicalize :: [Block] -> [Element]