git.iko.soy/typeable/pandoc
on master help sign in
Shored.camelCaseToHyphenated: handle ABCDef = abc-def.
commite4ccfeab8c55578fead30233394d531f31a429c3 authorJohn MacFarlane <jgm@berkeley.edu> dateMon 7 Oct 2019, 21:31 (7 years ago) parent8fb9a0d
1 file changed+8−2
src/Text/Pandoc/Shared.hs+8−2
src/Text/Pandoc/Shared.hs+8−2
@@ -242,8 +242,14 @@ stripFirstAndLast str =
242242-- | Change CamelCase word to hyphenated lowercase (e.g., camel-case).
243243camelCaseToHyphenated :: String -> String
244244camelCaseToHyphenated [] = ""
245−camelCaseToHyphenated (a:b:rest) | isLower a && isUpper b =
246− a:'-':toLower b:camelCaseToHyphenated rest
245+camelCaseToHyphenated (a:b:rest)
246+ | isLower a
247+ , isUpper b = a:'-':toLower b:camelCaseToHyphenated rest
248+-- handle ABCDef = abc-def
249+camelCaseToHyphenated (a:b:c:rest)
250+ | isUpper a
251+ , isUpper b
252+ , isLower c = toLower a:'-':toLower b:camelCaseToHyphenated (c:rest)
247253camelCaseToHyphenated (a:rest) = toLower a:camelCaseToHyphenated rest
248254
249255-- | Convert number < 4000 to uppercase roman numeral.