Only use monospace fonts in diff table if so specified
This commit is contained in:
parent
2714d3c03c
commit
3fcc105b78
|
@ -35,12 +35,13 @@ class Diff(object):
|
|||
Core diff class. In sore need of documentation.
|
||||
"""
|
||||
|
||||
def __init__(self, old_data, new_data, columns=None, fields=None, render_value=None):
|
||||
def __init__(self, old_data, new_data, columns=None, fields=None, render_value=None, monospace=False):
|
||||
self.old_data = old_data
|
||||
self.new_data = new_data
|
||||
self.columns = columns or ["field name", "old value", "new value"]
|
||||
self.fields = fields or self.make_fields()
|
||||
self.render_value = render_value or self.render_value_default
|
||||
self.monospace = monospace
|
||||
|
||||
def make_fields(self):
|
||||
return sorted(set(self.old_data) | set(self.new_data), key=lambda x: x.lower())
|
||||
|
|
|
@ -16,8 +16,8 @@ table.diff td {
|
|||
padding: 2px 5px;
|
||||
}
|
||||
|
||||
table.diff td.old-value,
|
||||
table.diff td.new-value{
|
||||
table.diff.monospace td.old-value,
|
||||
table.diff.monospace td.new-value{
|
||||
font-family: monospace;
|
||||
white-space: pre;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
## -*- coding: utf-8; -*-
|
||||
<table class="diff">
|
||||
<table class="diff${' monospace' if diff.monospace else ''}">
|
||||
<thead>
|
||||
<tr>
|
||||
% for column in diff.columns:
|
||||
|
|
Loading…
Reference in a new issue