Functions to convert between the spacing and capitalization conventions of various environments
A Common Lisp library to make it easy to change the capitalization and spacing of a "sentence". This is used for converting between space & capitalization rules of various systems.
- Converts to and from lisp, english, underscores and camel-case
- Useful for converting database column names to lisp-symbols and english column header names
- Removes excess word separators along the way (:foo--bar => "Foo Bar")
- All conversion "->" functions accept lisp-trees of strings, symbols, and other lisp objects.
- all lisp objects (other than the tree structure which is flattened) are converted by symbol-munger::%coerce-to-string into strings.
- Each object part is treated as a separate word
(s &key (capitalize :each-word) (word-separators #\space) word-separators-to-replace stream in-place)
- Will recapitalize a string and replace word-separators with a standard one (in-place if desired and possible)
- If s is a lisp tree, then each part will be %coerce-to-string'ed and treated as a separate part of the phrase being normalized (ie: each part implicitly starts a new word)
- Will write to a stream if given it otherwise.
- Defaults to capitalizing each word but can be any of
- word-separators are used to distinguish new words for the purposes of capitalization
- The first of these will be used to replace word-separators-to-replace
- word-separators-to-replace helps normalize word separators so that spaces or underscores become the appropriate word-separator.
- If this contains :capitals it assumes capital letters indicate a new word separation
returns a string (new or the one passed in if in-place) unless :stream is provided"
Converts a common lisp symbol (or symbol-name) into an english phrase
:a-symbol-like-this becomes "A Symbol Like This"
english->lisp-symbol & english->keyword
Converts an english phrase into a common lisp symbol (the keyword variant just specifies the keyword package)
"A Symbol Like This" becomes :a-symbol-like-this
Many other similar functions