Created
December 28, 2011 13:48
-
-
Save fumieval/1527996 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import curtana.lib.parser as P | |
def withcolor(color): | |
return lambda text: '\033[1;%dm%s\033[1;m' % (color, text) | |
def is_hashtag_char(c): | |
return c == "_" or c.isalnum() or 12353 <= ord(c) <= 12534 or 20124 <= ord(c) <= 40657 | |
SCREEN_NAME = P.StringA ** P.Char("@") * P.join ** +(P.alnum | P.Char("_")) | |
HASHTAG = P.StringA ** P.Char("#") * P.join ** +P.Sat(is_hashtag_char) | |
def arrangetext(): | |
return P.Null() | withcolor(35) ** HASHTAG | \ | |
P.StringA ** (P.Char("&") >> (P.String("gt;") >> P.Return(">") | |
| P.String("lt;") >> P.Return("<")) | |
| withcolor(36) ** SCREEN_NAME | |
| P.StringA ** P.Char(" ") * withcolor(35) ** HASHTAG | |
| P.AnyChar() | |
) * P.Delay(arrangetext) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment