(data)
| 18 | |
| 19 | |
| 20 | def beautify(data): |
| 21 | data = strutils.escape_special_areas(data, SPECIAL_AREAS, DELIMITERS) |
| 22 | |
| 23 | data = re.sub(r"\s*{\s*(?!};)", " {\n", data) |
| 24 | data = re.sub(r"\s*;\s*", ";\n", data) |
| 25 | data = re.sub(r"(?<!{)\s*}(;)?\s*", r"\n}\1\n", data) |
| 26 | |
| 27 | beautified = io.StringIO() |
| 28 | indent_level = 0 |
| 29 | |
| 30 | for line in data.splitlines(True): |
| 31 | if line.endswith("{\n"): |
| 32 | beautified.write(" " * 2 * indent_level + line) |
| 33 | indent_level += 1 |
| 34 | elif line.startswith("}"): |
| 35 | indent_level -= 1 |
| 36 | beautified.write(" " * 2 * indent_level + line) |
| 37 | else: |
| 38 | beautified.write(" " * 2 * indent_level + line) |
| 39 | |
| 40 | data = strutils.unescape_special_areas(beautified.getvalue()) |
| 41 | return data |
| 42 | |
| 43 | |
| 44 | class JavaScriptContentview(Contentview): |
searching dependent graphs…