@@ -58,6 +58,7 @@ void parse(ParseEventHandler,
5858 // BitType current_bits;
5959 // BitType[] stack;
6060 int line_content_start_index;
61+ int line_start_index;
6162 // Workwround for void not being a parameter type
6263 void emitBlockStart (string nodeContent) {
6364 static if (is (ReturnType! (handler.start) == void )) {
@@ -79,9 +80,11 @@ void parse(ParseEventHandler,
7980 case ' \n ' :
8081 // stack[0] & current_bits;
8182 // 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 ;
8385 emitBlockStart(nodeContent);
8486 i++ ;
87+ line_start_index = i;
8588 int new_indent_level =
8689 detect_indent_level(i, input, spaces_per_indent);
8790 line_content_start_index = i;
@@ -119,7 +122,7 @@ void parse(ParseEventHandler,
119122 }
120123 }
121124 if (line_content_start_index != input.length) {
122- emitBlockStart(input[line_content_start_index .. input.length]);
125+ emitBlockStart(input[line_start_index .. input.length]);
123126 }
124127 for (int i = 0 ; i < current_indent_level + 1 ; ++ i) {
125128 emitBlockEnd();
@@ -144,11 +147,31 @@ unittest {
144147 string result;
145148 parse! (ExampleParseEventHandler, s => result ~= s, s => result ~= s)
146149 (sample ~ (useTrailingNewline ? " \n " : " " ), 4 , " Title" );
150+ import std.stdio ;
151+ debug writeln(result);
147152 assert (result ==
148- ` STARTTitleSTART- abSTART- bENDENDSTARThelloSTARTworldENDSTARTfooENDENDEND `
153+ " STARTTitleSTART- abSTART\t - bENDENDSTARThelloSTART \t worldENDSTART \t fooENDENDEND "
149154 );
150155 }
151156}
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+ }
152175unittest {
153176 import std.stdio ;
154177 struct ExampleParseEventHandler {
167190 string result;
168191 parse! (ExampleParseEventHandler, s => result ~= s, s => result ~= s, true )
169192 (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>" );
171195}
172196struct ConvertToXMLEventHandler {
173197 string start (string text) {
0 commit comments