Skip to content

Commit

Permalink
Don't override default bg/fg colours (fixes #3)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexkay committed Mar 24, 2013
1 parent 32006e0 commit e9e6943
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 15 deletions.
4 changes: 2 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()))
Expand Down Expand Up @@ -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)
Expand Down
15 changes: 2 additions & 13 deletions tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit e9e6943

Please sign in to comment.