mirror of
https://github.com/gnosygnu/xowa.git
synced 2024-10-27 20:34:16 +00:00
Mw_parse: Add more comment support
This commit is contained in:
parent
75972fcff0
commit
3af333e563
@ -295,7 +295,7 @@ public class Xomw_prepro_wkr { // TS.UNSAFE:caching for repeated calls
|
||||
// comments.
|
||||
comments_list.Clear();
|
||||
comments_list.Add(new int[] {ws_bgn, ws_end});
|
||||
while (Bry_.Eq(src, ws_end + 1, ws_end + 5, Bry__comment_bgn)) {
|
||||
while (ws_end + 5 < src_len && Bry_.Eq(src, ws_end + 1, ws_end + 5, Bry__comment_bgn)) {
|
||||
int cur_char_pos = Bry_find_.Find_fwd(src, Bry__comment_end, ws_end + 4);
|
||||
if (cur_char_pos == Bry_find_.Not_found) {
|
||||
break;
|
||||
@ -358,8 +358,8 @@ public class Xomw_prepro_wkr { // TS.UNSAFE:caching for repeated calls
|
||||
i = end_pos + 1;
|
||||
inner = Bry_.Mid(src, bgn_pos, end_pos + 1);
|
||||
accum.Add_str_a7("<comment>").Add_bry_escape_html(inner).Add_str_a7("</comment>");
|
||||
continue;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
byte[] name = element.name;
|
||||
|
@ -34,8 +34,27 @@ public class Xomw_prepro_wkr__tst {
|
||||
@Test public void Comment() {
|
||||
fxt.Test__parse("a<!--b-->c", "<root>a<comment><!--b--></comment>c</root>");
|
||||
}
|
||||
@Test public void Comment__nl__ws() {
|
||||
fxt.Test__parse("xo\n <!--1--> \n <!--2--> \nz", "<root>xo\n<comment> <!--1--> \n</comment><comment> <!--2--> \n</comment>z</root>");
|
||||
@Test public void Comment__dangling() {
|
||||
fxt.Test__parse("a<!--b", "<root>a<comment><!--b</comment></root>");
|
||||
}
|
||||
@Test public void Comment__ws() { // NOTE: space is outside comment
|
||||
fxt.Test__parse("a <!--b--> c", "<root>a <comment><!--b--></comment> c</root>");
|
||||
}
|
||||
@Test public void Comment__many__ws() { // NOTE: space is outside comment
|
||||
fxt.Test__parse("a <!--1--> <!--2--> z", "<root>a <comment><!--1--></comment> <comment><!--2--></comment> z</root>");
|
||||
}
|
||||
@Test public void Comment__nl__ws() { // NOTE: space is inside comment if flanked by nl
|
||||
fxt.Test__parse(String_.Concat_lines_nl_skip_last
|
||||
( "a"
|
||||
, " <!--1--> "
|
||||
, " <!--2--> "
|
||||
, "z"
|
||||
), String_.Concat_lines_nl_skip_last
|
||||
( "<root>a"
|
||||
, "<comment> <!--1--> "
|
||||
, "</comment><comment> <!--2--> "
|
||||
, "</comment>z</root>"
|
||||
));
|
||||
}
|
||||
@Test public void Ext__pre() {
|
||||
fxt.Test__parse("a<pre id=\"1\">b</pre>c", "<root>a<ext><name>pre</name><attr> id="1"</attr><inner>b</inner><close></pre></close></ext>c</root>");
|
||||
|
Loading…
Reference in New Issue
Block a user