Permalink
Browse files

hyphenate fix

  • Loading branch information...
nagaozen committed Jan 13, 2010
1 parent f7d1cf6 commit 6f57c64d3ac0760267208e36915edeb356264f1f
Showing with 7 additions and 2 deletions.
  1. +7 −2 README.md
View
@@ -220,9 +220,14 @@ Commands:
import sys
import unicodedata
- print unicodedata.normalize("NFKD", unicode(sys.stdin.read(), "ISO-8859-1")).encode("ASCII", "ignore").lower().replace(' ', '-')
+ def not_combining(char):
+ return unicodedata.category(char) != "Mn"
- print sys.stdin.read().replace(" ", "-").lower()
+ def strip_accents(text, encoding):
+ unicode_text = unicodedata.normalize('NFD', text.decode(encoding))
+ return filter(not_combining, unicode_text).encode(encoding)
+
+ print strip_accents(sys.stdin.read(), "UTF-8").lower().replace(' ', '-')
Input: **Current Selection**
Output: **Replace the current selection**
Applicability: **All documents**

0 comments on commit 6f57c64

Please sign in to comment.