mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
Cite: Change Cite to follow MediaWiki behavior for super-scripting [#382]
This commit is contained in:
@@ -134,6 +134,24 @@ public class Bry_split_ {
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
public static byte[][] Split_ws(byte[] src) {// REF.PHP: preg_split('/\s+/', $text)
|
||||
int len = src.length;
|
||||
if (len == 0) return Bry_.Ary_empty;
|
||||
|
||||
List_adp list = List_adp_.New();
|
||||
int pos = 0;
|
||||
while (true) {
|
||||
int bgn = Bry_find_.Find_fwd_while_ws(src, pos, len);
|
||||
if (bgn == len) break; // EOS
|
||||
int end = Bry_find_.Find_fwd_until_ws(src, bgn + 1, len);
|
||||
if (end == -1) end = len;
|
||||
list.Add(Bry_.Mid(src, bgn, end));
|
||||
pos = end + 1;
|
||||
if (pos >= len) break;
|
||||
}
|
||||
return (byte[][])list.To_ary_and_clear(byte[].class);
|
||||
}
|
||||
|
||||
|
||||
public static final int Rv__ok = 0, Rv__extend = 1, Rv__cancel = 2;
|
||||
}
|
||||
|
||||
@@ -49,6 +49,11 @@ public class Bry_split__tst {
|
||||
fxt.Test__split_w_max("a" , Byte_ascii.Pipe, 2, "a", null); // max is more
|
||||
fxt.Test__split_w_max("|" , Byte_ascii.Pipe, 2, "", ""); // empty itms
|
||||
}
|
||||
@Test public void Split_ws() {
|
||||
fxt.Test__split_ws("a b", "a", "b");
|
||||
fxt.Test__split_ws(" a ", "a");
|
||||
fxt.Test__split_ws(" abc def ", "abc", "def");
|
||||
}
|
||||
}
|
||||
class Bry_split__fxt {
|
||||
private final Bry_split_wkr__example wkr = new Bry_split_wkr__example();
|
||||
@@ -64,6 +69,10 @@ class Bry_split__fxt {
|
||||
public void Test__split_w_max(String src, byte dlm, int max, String... expd) {
|
||||
Gftest.Eq__ary(expd, String_.Ary(Bry_split_.Split_w_max(Bry_.new_u8(src), dlm, max)));
|
||||
}
|
||||
public void Test__split_ws(String raw, String... expd) {
|
||||
byte[][] actl = Bry_split_.Split_ws(Bry_.new_u8(raw));
|
||||
Gftest.Eq__ary(Bry_.Ary(expd), actl, raw);
|
||||
}
|
||||
}
|
||||
class Bry_split_wkr__example implements gplx.core.brys.Bry_split_wkr {
|
||||
private final List_adp list = List_adp_.New();
|
||||
|
||||
Reference in New Issue
Block a user