diff options
author | Tim Hatch <tim@timhatch.com> | 2014-10-03 23:08:55 -0700 |
---|---|---|
committer | Tim Hatch <tim@timhatch.com> | 2014-10-03 23:08:55 -0700 |
commit | 71b90a50f9f95ece57eba099acc0138add1085ae (patch) | |
tree | 0c3e5c98b320e13f0bcf4d4d0804994a1b0e0849 /pygments/util.py | |
parent | 24ee4c42972ee33e6321f79f1f5f72631cebb795 (diff) | |
download | pygments-71b90a50f9f95ece57eba099acc0138add1085ae.tar.gz |
Make format_lines take an indent level.
We need this because the vim keywords file uses functions to define these lists,
because of Jython.
Diffstat (limited to 'pygments/util.py')
-rw-r--r-- | pygments/util.py | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/pygments/util.py b/pygments/util.py index 65efe175..3a1c0947 100644 --- a/pygments/util.py +++ b/pygments/util.py @@ -256,23 +256,24 @@ def unirange(a, b): return u'(?:' + u'|'.join(buf) + u')' -def format_lines(var_name, seq, raw=False): +def format_lines(var_name, seq, raw=False, indent_level=0): """ Formats a sequence of strings for output. """ lines = [] - indent = ' ' * 4 - lines.append(var_name + ' = (') + base_indent = ' ' * indent_level * 4 + inner_indent = ' ' * (indent_level + 1) * 4 + lines.append(base_indent + var_name + ' = (') if raw: # These should be preformatted reprs of, say, tuples. for i in seq: - lines.append(indent + i + ',') + lines.append(inner_indent + i + ',') else: for i in seq: # Force use of single quotes r = repr(i + '"') - lines.append(indent + r[:-2] + r[-1] + ',') - lines.append(')') + lines.append(inner_indent + r[:-2] + r[-1] + ',') + lines.append(base_indent + ')') return '\n'.join(lines) # Python 2/3 compatibility |