Skip to content

Commit 62f3888

Browse files
committed
Rename detect_indent_level to count_indents
1 parent a2f2cd3 commit 62f3888

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

parser.d

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
/** Detect indent level and return where the indent level stops in "i"
1+
/** Count the indent level and return where the indent level stops in "i"
22
* A tab is counted as one indent.
33
* Params:
44
* i = the index to start looking from. This is mutated
55
* by reference to indicate the index the last index
66
* was.
77
* spaces_per_indent = the number of spaces to treat as one indent
88
*/
9-
int detect_indent_level(ref int i, string input, int spaces_per_indent=4) {
9+
int count_indents(ref int i, string input, int spaces_per_indent=4) {
1010
int nspaces = 0;
1111
if (i == input.length || !(input[i] == ' ' || input[i] == '\t')) {
1212
return 0;
@@ -26,10 +26,10 @@ int detect_indent_level(ref int i, string input, int spaces_per_indent=4) {
2626
}
2727
unittest {
2828
int i;
29-
assert(detect_indent_level(i = 0, " - hi") == 1);
30-
assert(detect_indent_level(i = 0, "Foo") == 0);
31-
assert(detect_indent_level(i = 0, " - hi") == 2);
32-
assert(detect_indent_level(i = 0, "\t - hey") == 1);
29+
assert(count_indents(i = 0, " - hi") == 1);
30+
assert(count_indents(i = 0, "Foo") == 0);
31+
assert(count_indents(i = 0, " - hi") == 2);
32+
assert(count_indents(i = 0, "\t - hey") == 1);
3333
}
3434
void doNothing(T)(T _=null) {}
3535
/** A streaming parser for Markdown trees. Emits a stream of parsing events.
@@ -86,7 +86,7 @@ void parse(ParseEventHandler,
8686
i++;
8787
line_start_index = i;
8888
int new_indent_level =
89-
detect_indent_level(i, input, spaces_per_indent);
89+
count_indents(i, input, spaces_per_indent);
9090
line_content_start_index = i;
9191
const extraEndings = i == input.length ? 0 : 1;
9292
foreach (_;

0 commit comments

Comments
 (0)