We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 68372ae commit de3ea99Copy full SHA for de3ea99
src/etc/indenter
@@ -1,16 +1,19 @@
1
-#!/usr/bin/perl
2
-use strict;
3
-use warnings;
+#!/usr/bin/env python
+import re
+import sys
4
5
-my $indent = 0;
6
-while (<>) {
7
- if (/^rust: ~">>/) {
8
- $indent += 1;
9
- }
+indent = 0
+more_re = re.compile(r"^rust: ~\">>")
+less_re = re.compile(r"^rust: ~\"<<")
+while True:
+ line = sys.stdin.readline()
10
+ if not line:
11
+ break
12
- printf "%03d %s%s", $indent, (" " x $indent), $_;
13
+ if more_re.match(line):
14
+ indent += 1
15
- if (/^rust: ~"<</) {
- $indent -= 1;
16
-}
+ print "%03d %s%s" % (indent, " " * indent, line.strip())
17
+
18
+ if less_re.match(line):
19
+ indent -= 1
0 commit comments