diff options
author | Manuel Giraud <manuel@ledu-giraud.fr> | 2019-06-07 12:18:16 +0200 |
---|---|---|
committer | Stas Boukarev <stassats@gmail.com> | 2019-06-07 13:18:16 +0300 |
commit | 0d3826475133271ee8c590937136c1bc41b8cbe0 (patch) | |
tree | de19840e3bafd4001d7fbf1fb66dc61774889b8e /util.lisp | |
parent | 4661aba0faba908e63d1c1dbec035c855e834faf (diff) | |
download | tl-who-0d3826475133271ee8c590937136c1bc41b8cbe0.tar.gz tl-who-0d3826475133271ee8c590937136c1bc41b8cbe0.tar.bz2 tl-who-0d3826475133271ee8c590937136c1bc41b8cbe0.zip |
downcase a tag only when it is in the same case (useful for some camel case XML tags).
Diffstat (limited to 'util.lisp')
-rw-r--r-- | util.lisp | 11 |
1 files changed, 11 insertions, 0 deletions
@@ -239,3 +239,14 @@ character set." (eql (first form) 'cl:declare)) do (push form declarations) finally (return (values (nreverse declarations) forms)))) + +(defun same-case-p (string) + "Test if all characters of a string are in the same case." + (or (every #'(lambda (c) (or (not (alpha-char-p c)) (lower-case-p c))) string) + (every #'(lambda (c) (or (not (alpha-char-p c)) (upper-case-p c))) string))) + +(defun maybe-downcase (symbol) + (let ((string (string symbol))) + (if (and *downcase-tokens-p* (same-case-p string)) + (string-downcase string) + string))) |