From 0d3826475133271ee8c590937136c1bc41b8cbe0 Mon Sep 17 00:00:00 2001 From: Manuel Giraud Date: Fri, 7 Jun 2019 12:18:16 +0200 Subject: downcase a tag only when it is in the same case (useful for some camel case XML tags). --- util.lisp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'util.lisp') diff --git a/util.lisp b/util.lisp index f2b0993..17743fd 100644 --- a/util.lisp +++ b/util.lisp @@ -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))) -- cgit v1.2.3