Permalink
Browse files

Don't override default bg/fg colours (fixes #3)

  • Loading branch information...
1 parent 32006e0 commit e9e69438c3911d2934dbf6d4c8cd9c3a09840f38 @alexkay committed Mar 24, 2013
Showing with 4 additions and 15 deletions.
  1. +2 −2 main.py
  2. +2 −13 tools.py
View
@@ -47,7 +47,7 @@ def index():
unquote(request.cookies.get('linenos', ''))) or ''
divstyles = request.form.get(
'divstyles', unquote(request.cookies.get('divstyles', '')))
- divstyles = update_styles(style, divstyles)
+ divstyles = divstyles or get_default_style()
html = hilite_me(code, lexer, {}, style, linenos, divstyles)
response = make_response(render_template('index.html', **locals()))
@@ -83,7 +83,7 @@ def convert(item):
style = request.values.get('style', '')
linenos = request.values.get('linenos', '')
- divstyles = update_styles(style, request.form.get('divstyles', ''))
+ divstyles = request.form.get('divstyles', get_default_style())
html = hilite_me(code, lexer, options, style, linenos, divstyles)
response = make_response(html)
View
@@ -38,19 +38,8 @@ def hilite_me(code, lexer, options, style, linenos, divstyles):
html = "<!-- HTML generated using hilite.me -->" + html
return html
-def update_styles(style, divstyles):
- common_styles = 'border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;'
- bw_styles = 'color:black;background:white;' + common_styles
- wb_styles = 'color:white;background:black;' + common_styles
- if not divstyles: divstyles = bw_styles
-
- if style in ('fruity', 'native'):
- if divstyles == bw_styles:
- divstyles = wb_styles
- else:
- if divstyles == wb_styles:
- divstyles = bw_styles
- return divstyles
+def get_default_style():
+ return 'border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;'
def insert_line_numbers(html):
match = re.search('(<pre[^>]*>)(.*)(</pre>)', html, re.DOTALL)

0 comments on commit e9e6943

Please sign in to comment.