diff options
author | blackbird <devnull@localhost> | 2007-01-08 23:09:09 +0100 |
---|---|---|
committer | blackbird <devnull@localhost> | 2007-01-08 23:09:09 +0100 |
commit | 48241d32886ca5f809cabe0ab7114fbc631ef374 (patch) | |
tree | 08ff4456d504111ca53325ae263f8b4724a17e61 /scripts/vim2pygments.py | |
parent | 61de5a234ccae793e7e086fed4b8b25634370764 (diff) | |
download | pygments-48241d32886ca5f809cabe0ab7114fbc631ef374.tar.gz |
[svn] fixed vim2pygments and the fruity file generated with it
Diffstat (limited to 'scripts/vim2pygments.py')
-rw-r--r-- | scripts/vim2pygments.py | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/scripts/vim2pygments.py b/scripts/vim2pygments.py index 09391beb..aa114abe 100644 --- a/scripts/vim2pygments.py +++ b/scripts/vim2pygments.py @@ -775,11 +775,10 @@ for token in TOKENS.itervalues(): def get_vim_color(color): if color.startswith('#'): - color = color[1:] - if len(color) == 6: + if len(color) == 7: return color else: - return '0'.join(color)[:5] + '0' + return '#%s0' % '0'.join(color)[1:] return COLORS.get(color.lower()) @@ -873,8 +872,8 @@ class StyleWriter(object): out.write(' %s Colorscheme\n' % self.name.title()) out.write(' %s\n\n' % ('~' * (len(self.name) + 12))) out.write(' Converted by %s\n' % SCRIPT_NAME) - out.write('"""\nfrom pykleur.style import Style\n') - out.write('from pykleur.token import %s\n\n' % ', '.join(TOKEN_TYPES)) + out.write('"""\nfrom pygments.style import Style\n') + out.write('from pygments.token import Token, %s\n\n' % ', '.join(TOKEN_TYPES)) out.write('class %sStyle(Style):\n\n' % self.name.title()) def write(self, out): @@ -882,7 +881,11 @@ class StyleWriter(object): default_token, tokens = find_colors(self.code) tokens = tokens.items() tokens.sort(lambda a, b: cmp(len(a[0]), len(a[1]))) - out.write(' default_style = %r\n styles = {\n' % default_token) + bg_color = [x[3:] for x in default_token.split() if x.startswith('bg:')] + if bg_color: + out.write(' background_color = %r\n' % bg_color[0]) + out.write(' styles = {\n') + out.write(' %-20s%r\n' % ('Token:', default_token)) for token, definition in tokens: if definition: out.write(' %-20s%r\n' % (token + ':', definition)) |