]> git.lyx.org Git - features.git/commitdiff
One more isalpha issue. Original routine also removed too much, I think.
authorRichard Heck <rgheck@comcast.net>
Wed, 17 Nov 2010 21:36:03 +0000 (21:36 +0000)
committerRichard Heck <rgheck@comcast.net>
Wed, 17 Nov 2010 21:36:03 +0000 (21:36 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@36352 a592a061-630c-0410-9148-cb99ea01b6c8

src/Layout.cpp

index fd4709e35659bf8927e4974b014f3efc588b5a14..7f4925a8c3798d55518d18e7da37eabd4f942973 100644 (file)
@@ -996,14 +996,20 @@ string Layout::defaultCSSClass() const
        docstring::const_iterator it = name().begin();
        docstring::const_iterator en = name().end();
        for (; it != en; ++it) {
-               if (!isalpha(*it))
-                       continue;
-               if (islower(*it))
-                       d += *it;
-               else 
-                       d += lowercase(*it);
+               char_type const c = *it;
+               if (c >= 0x80 || !isalnum(c)) {
+                       if (d.empty())
+                               // make sure we don't start with an underscore,
+                               // as that sometimes causes problems.
+                               d = from_ascii("lyx_");
+                       else
+                               d += '_';
+               } else if (islower(c))
+                       d += c;
+               else
+                       // this is slow, so do it only if necessary
+                       d += lowercase(c);
        }
-       // are there other characters we need to remove?
        defaultcssclass_ = to_utf8(d);
        return defaultcssclass_;
 }