Skip to content

Instantly share code, notes, and snippets.

@cbguder
Created May 7, 2009 13:08
Show Gist options
  • Save cbguder/108085 to your computer and use it in GitHub Desktop.
Save cbguder/108085 to your computer and use it in GitHub Desktop.
function turkishUpperCase(s) {
s = s.replace(/ı/g, 'I');
s = s.replace(/i/g, 'İ');
return s.toUpperCase();
}
function fixSmallCaps(selector) {
$$(selector).each(function(e) {
var text = e.innerHTML;
var upper = turkishUpperCase(text);
var newText = '';
var i = 0;
while(i < text.length) {
if(text.charAt(i) == upper.charAt(i)) {
newText += upper.charAt(i);
i++;
} else {
newText += '<span class="faux-small-caps">';
while(text.charAt(i) != upper.charAt(i)) {
newText += upper.charAt(i);
i++;
}
newText += '</span>';
}
}
e.update(newText);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment