mirror of
https://github.com/gnosygnu/xowa.git
synced 2024-10-27 20:34:16 +00:00
Mw_parse.Prepro: Support more heading edge cases
This commit is contained in:
parent
46274e9b6a
commit
40b520ecc6
@ -494,7 +494,9 @@ public class Xomw_prepro_wkr { // THREAD.UNSAFE: caching for repeated calls
|
||||
i++;
|
||||
}
|
||||
|
||||
int eq_end = Bry_find_.Find_fwd_while(src, i, i + 6, Byte_ascii.Eq); // PORTED:strspn( $src, '=', $i, 6 );
|
||||
// PORTED: $count = strspn( $text, '=', $i, 6 );
|
||||
int eq_end_max = i + 6; if (eq_end_max > src_len) eq_end_max = src_len;
|
||||
int eq_end = Bry_find_.Find_fwd_while(src, i, eq_end_max, Byte_ascii.Eq);
|
||||
int count = eq_end - i;
|
||||
if (count == 1 && find_equals) { // EX: "{{a|\n=b=\n"
|
||||
// DWIM: This looks kind of like a name/value separator.
|
||||
@ -529,10 +531,10 @@ public class Xomw_prepro_wkr { // THREAD.UNSAFE: caching for repeated calls
|
||||
// Comment found at line end
|
||||
// Search for equals signs before the comment
|
||||
search_bgn = part.visual_end;
|
||||
search_bgn -= Bry_find_.Find_bwd__while_space_or_tab(src, search_bgn, 0);
|
||||
search_bgn = Bry_find_.Find_bwd__while_space_or_tab(src, search_bgn, 0);
|
||||
}
|
||||
int count = piece.count;
|
||||
int eq_len = Bry_find_.Find_bwd_while(src, search_bgn, 0, Byte_ascii.Eq);
|
||||
int eq_len = search_bgn - Bry_find_.Find_bwd_while(src, search_bgn, 0, Byte_ascii.Eq) - 1;
|
||||
|
||||
byte[] element = Bry_.Empty;
|
||||
if (eq_len > 0) {
|
||||
|
@ -117,7 +117,7 @@ public class Xomw_prepro_wkr__tst {
|
||||
, "z</root>"
|
||||
));
|
||||
}
|
||||
@Test public void Heading__eq_1() { // COVERS: "DWIM: This looks kind of like a name/value separator."
|
||||
@Test public void Heading__dwim__y() { // COVERS: "DWIM: This looks kind of like a name/value separator."
|
||||
fxt.Test__parse(String_.Concat_lines_nl_skip_last
|
||||
( "a{{b|"
|
||||
, "=c="
|
||||
@ -128,7 +128,61 @@ public class Xomw_prepro_wkr__tst {
|
||||
, "</value></part></template>d</root>"
|
||||
));
|
||||
}
|
||||
|
||||
@Test public void Heading__dwim__n() { // COVERS: "DWIM: This looks kind of like a name/value separator."
|
||||
fxt.Test__parse(String_.Concat_lines_nl_skip_last
|
||||
( "a{{b|"
|
||||
, "==c=="
|
||||
, "}}d"
|
||||
), String_.Concat_lines_nl_skip_last
|
||||
( "<root>a<template><title>b</title><part><name index=\"1\" /><value>"
|
||||
, "<h level=\"2\" i=\"1\">==c==</h>"
|
||||
, "</value></part></template>d</root>"
|
||||
));
|
||||
}
|
||||
@Test public void Heading__comment() { // COVERS: "Comment found at line end"
|
||||
fxt.Test__parse(String_.Concat_lines_nl_skip_last
|
||||
( "a"
|
||||
, "==b== <!--c-->"
|
||||
, ""
|
||||
), String_.Concat_lines_nl_skip_last
|
||||
( "<root>a"
|
||||
, "<h level=\"2\" i=\"1\">==b== <comment><!--c--></comment></h>"
|
||||
, "</root>"
|
||||
));
|
||||
}
|
||||
@Test public void Heading__consecutive__5() { // COVERS: "This is just a single String of equals signs on its own line"
|
||||
fxt.Test__parse(String_.Concat_lines_nl_skip_last
|
||||
( "a"
|
||||
, "====="
|
||||
, ""
|
||||
), String_.Concat_lines_nl_skip_last
|
||||
( "<root>a"
|
||||
, "<h level=\"2\" i=\"1\">=====</h>"
|
||||
, "</root>"
|
||||
));
|
||||
}
|
||||
@Test public void Heading__consecutive__1() { // COVERS: "Single equals sign on its own line, count=0"
|
||||
fxt.Test__parse(String_.Concat_lines_nl_skip_last
|
||||
( "a"
|
||||
, "="
|
||||
, ""
|
||||
), String_.Concat_lines_nl_skip_last
|
||||
( "<root>a"
|
||||
, "="
|
||||
, "</root>"
|
||||
));
|
||||
}
|
||||
@Test public void Heading__unclosed() { // COVERS: "No match, no <h>, just pass down the inner src"
|
||||
fxt.Test__parse(String_.Concat_lines_nl_skip_last
|
||||
( "a"
|
||||
, "===b"
|
||||
, ""
|
||||
), String_.Concat_lines_nl_skip_last
|
||||
( "<root>a"
|
||||
, "===b"
|
||||
, "</root>"
|
||||
));
|
||||
}
|
||||
@Test public void Inclusion__n() {
|
||||
fxt.Init__for_inclusion_(Bool_.N);
|
||||
fxt.Test__parse("a<onlyinclude>b</onlyinclude>c", "<root>a<ignore><onlyinclude></ignore>b<ignore></onlyinclude></ignore>c</root>");
|
||||
|
Loading…
Reference in New Issue
Block a user