@@ -58,6 +58,7 @@ void parse(ParseEventHandler,
58
58
// BitType current_bits;
59
59
// BitType[] stack;
60
60
int line_content_start_index;
61
+ int line_start_index;
61
62
// Workwround for void not being a parameter type
62
63
void emitBlockStart (string nodeContent) {
63
64
static if (is (ReturnType! (handler.start) == void )) {
@@ -79,9 +80,11 @@ void parse(ParseEventHandler,
79
80
case ' \n ' :
80
81
// stack[0] & current_bits;
81
82
// FIXME: Start and end based on "-"
82
- const nodeContent = input[line_content_start_index.. i];
83
+ const nodeContent = input[line_start_index.. i];
84
+ import std.stdio ;
83
85
emitBlockStart(nodeContent);
84
86
i++ ;
87
+ line_start_index = i;
85
88
int new_indent_level =
86
89
detect_indent_level(i, input, spaces_per_indent);
87
90
line_content_start_index = i;
@@ -119,7 +122,7 @@ void parse(ParseEventHandler,
119
122
}
120
123
}
121
124
if (line_content_start_index != input.length) {
122
- emitBlockStart(input[line_content_start_index .. input.length]);
125
+ emitBlockStart(input[line_start_index .. input.length]);
123
126
}
124
127
for (int i = 0 ; i < current_indent_level + 1 ; ++ i) {
125
128
emitBlockEnd();
@@ -144,11 +147,31 @@ unittest {
144
147
string result;
145
148
parse! (ExampleParseEventHandler, s => result ~= s, s => result ~= s)
146
149
(sample ~ (useTrailingNewline ? " \n " : " " ), 4 , " Title" );
150
+ import std.stdio ;
151
+ debug writeln(result);
147
152
assert (result ==
148
- ` STARTTitleSTART- abSTART- bENDENDSTARThelloSTARTworldENDSTARTfooENDENDEND `
153
+ " STARTTitleSTART- abSTART\t - bENDENDSTARThelloSTART \t worldENDSTART \t fooENDENDEND "
149
154
);
150
155
}
151
156
}
157
+ struct A {
158
+
159
+ }
160
+ private struct WithConstructor {
161
+ string [] member;
162
+ this (string [] arg, A a) {
163
+ member = arg;
164
+ }
165
+ void start (string text) {
166
+ }
167
+ void end () {
168
+ }
169
+ }
170
+ unittest {
171
+ A a;
172
+ parse! (WithConstructor)
173
+ (" Test" , 4 , " Title" , [" arg" ], a);
174
+ }
152
175
unittest {
153
176
import std.stdio ;
154
177
struct ExampleParseEventHandler {
167
190
string result;
168
191
parse! (ExampleParseEventHandler, s => result ~= s, s => result ~= s, true )
169
192
(sample, 1 , " Title" );
170
- result.writeln;
193
+ writeln(result);
194
+ assert (result == " <div>Title<div>a<div><div> b</div></div></div><div>c<div><div><div> d</div></div></div></div></div>" );
171
195
}
172
196
struct ConvertToXMLEventHandler {
173
197
string start (string text) {
0 commit comments