Compact json list output

This commit is contained in:
shortcutme 2017-06-03 00:53:59 +02:00
parent 0b7d1ad90d
commit 6167dda01d
No known key found for this signature in database
GPG key ID: 5B63BAE6CB9613AE

View file

@ -266,6 +266,15 @@ class SiteStorage(object):
content = re.sub("\{(\n[^,\[\{]{10,100}?)\}[, ]{0,2}\n", compact_dict, content, flags=re.DOTALL)
def compact_list(match):
if "\n" in match.group(0):
stripped_lines = re.sub("\n[ ]*", "", match.group(1))
return match.group(0).replace(match.group(1), stripped_lines)
else:
return match.group(0)
content = re.sub("\[([^\[\{]{2,300}?)\][, ]{0,2}\n", compact_list, content, flags=re.DOTALL)
# Remove end of line whitespace
content = re.sub("(?m)[ ]+$", "", content)