mirror of
https://github.com/gnosygnu/xowa.git
synced 2024-10-27 20:34:16 +00:00
Html_dump: Fix repeating links on many de.w pages
This commit is contained in:
parent
3923df5e19
commit
24aefd43e4
@ -20,7 +20,14 @@ public class Btrie_slim_mgr implements Btrie_mgr {
|
||||
public int Count() {return count;} private int count;
|
||||
public int Match_pos() {return match_pos;} private int match_pos;
|
||||
|
||||
public Object Match_at(Btrie_rv rv, byte[] src, int bgn_pos, int end_pos) {return bgn_pos < end_pos ? Match_at_w_b0(rv, src[bgn_pos], src, bgn_pos, end_pos) : null;} // handle out of bounds gracefully; EX: Match_bgn("abc", 3, 3) should return null not fail
|
||||
public Object Match_at(Btrie_rv rv, byte[] src, int bgn_pos, int end_pos) {
|
||||
if (bgn_pos < end_pos)
|
||||
return Match_at_w_b0(rv, src[bgn_pos], src, bgn_pos, end_pos);
|
||||
else { // handle out of bounds gracefully; EX: Match_bgn("abc", 3, 3) should (a) return null not fail; (b) return a pos of bgn_pos, not 0; DATE:2018-04-12
|
||||
rv.Init(bgn_pos, null);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
public Object Match_at_w_b0(Btrie_rv rv, byte b, byte[] src, int bgn_pos, int src_end) {
|
||||
Object rv_obj = null;
|
||||
int rv_pos = bgn_pos;
|
||||
|
@ -14,7 +14,7 @@ GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.core.btries; import gplx.*; import gplx.core.*;
|
||||
import org.junit.*;
|
||||
import org.junit.*; import gplx.core.tests.*;
|
||||
public class Btrie_slim_mgr_tst {
|
||||
@Before public void init() {
|
||||
} private Btrie_slim_mgr trie;
|
||||
@ -70,6 +70,12 @@ public class Btrie_slim_mgr_tst {
|
||||
trie.Del(Bry_.new_a7("abc"));
|
||||
tst_MatchAtCur("abc" , null);
|
||||
}
|
||||
@Test public void Match_none() {
|
||||
Btrie_slim_mgr_fxt fxt = new Btrie_slim_mgr_fxt();
|
||||
fxt.Init__add("k1", "v1");
|
||||
fxt.Exec__match("ak1", 1, 3, "v1", 3); // 3 to position after match
|
||||
fxt.Exec__match("ak2", 1, 1, null, 1); // 1 to position at current pos; used to be 0; de.w:Butter; DATE:2018-04-12
|
||||
}
|
||||
|
||||
private void run_Add(String k, int val) {trie.Add_obj(Bry_.new_a7(k), val);}
|
||||
private void tst_Match(String srcStr, byte b, int bgn_pos, int expd) {
|
||||
@ -88,3 +94,16 @@ public class Btrie_slim_mgr_tst {
|
||||
Tfds.Eq(expd, actl);
|
||||
}
|
||||
}
|
||||
class Btrie_slim_mgr_fxt {
|
||||
private final Btrie_slim_mgr trie = Btrie_slim_mgr.cs();
|
||||
public Btrie_slim_mgr_fxt Init__add(String key, String val) {
|
||||
trie.Add_str_str(key, val);
|
||||
return this;
|
||||
}
|
||||
public void Exec__match(String src, int bgn_pos, int end_pos, Object expd_val, int expd_pos) {
|
||||
Btrie_rv trv = new Btrie_rv();
|
||||
Object actl_val = trie.Match_at(trv, Bry_.new_u8(src), bgn_pos, end_pos);
|
||||
Gftest.Eq__obj_or_null(expd_val, actl_val);
|
||||
Gftest.Eq__int(expd_pos, trv.Pos());
|
||||
}
|
||||
}
|
||||
|
@ -51,5 +51,9 @@ public class Xoh_hzip_dict_ {
|
||||
, Key__pgbnr = "pgbnr"
|
||||
, Key__media = "media"
|
||||
;
|
||||
public static final int Hzip__none = 0, Hzip__v1 = 1, Hzip__plain = 2; // SERIALIZED
|
||||
public static final int // SERIALIZED
|
||||
Hzip__none = 0
|
||||
, Hzip__v1 = 1
|
||||
, Hzip__plain = 2 // used for page_sync
|
||||
;
|
||||
}
|
||||
|
@ -93,6 +93,12 @@ public class Xoh_img_hzip__dump__basic__tst {
|
||||
, "<a href='/wiki/File:A.png' class='image' title='abc' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|220|-1|-1|-1|-1' src='' width='0' height='0' class='cls1' alt='abc'></a>"
|
||||
);
|
||||
}
|
||||
@Test public void Manual_img_cls_empty() { // PURPOSE: handle empty class; EX: [[File:A.png|class=""]] de.w:Butter; DATE:2018-04-11
|
||||
fxt.Test__bicode
|
||||
( "~%!-A.png~)#Sabc~"
|
||||
, "<a href='/wiki/File:A.png' class='image' title='abc' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|220|-1|-1|-1|-1' src='' width='0' height='0' class='' alt='abc'></a>"
|
||||
);
|
||||
}
|
||||
@Test public void Imap() {
|
||||
fxt.Test__bicode
|
||||
( "~%}#P`uA.png~#:#S#+\""
|
||||
|
Loading…
Reference in New Issue
Block a user