mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
Command-line: Fix curid argument not working 2
This commit is contained in:
@@ -1,37 +0,0 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
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.xowa.parsers.htmls; import gplx.*; import gplx.xowa.*; import gplx.xowa.parsers.*;
|
||||
import org.junit.*;
|
||||
public class Mwh_atr_mgr_tst {
|
||||
private final Mwh_atr_mgr_fxt fxt = new Mwh_atr_mgr_fxt();
|
||||
@Test public void Atr_utl_make() {
|
||||
// key="val"
|
||||
fxt.Test_atr_utl_make(Mwh_atr_itm_.Qte_tid__qute, Mwh_atr_itm_.Mask__valid__y, Mwh_atr_itm_.Mask__repeated__n, Mwh_atr_itm_.Mask__key_exists__y, Mwh_atr_itm_.Mask__val_made__n, 42);
|
||||
// key=val key=v<nowiki/>al
|
||||
fxt.Test_atr_utl_make(Mwh_atr_itm_.Qte_tid__none, Mwh_atr_itm_.Mask__valid__y, Mwh_atr_itm_.Mask__repeated__y, Mwh_atr_itm_.Mask__key_exists__y, Mwh_atr_itm_.Mask__val_made__y, 120);
|
||||
}
|
||||
}
|
||||
class Mwh_atr_mgr_fxt {
|
||||
public void Test_atr_utl_make(int qte_tid, boolean valid, boolean repeated, boolean key_exists, boolean val_made, int expd) {
|
||||
int atr_utl = Mwh_atr_itm_.Calc_atr_utl(qte_tid, valid, repeated, key_exists, val_made);
|
||||
Tfds.Eq_int(expd, atr_utl);
|
||||
Tfds.Eq_int(qte_tid, Mwh_atr_itm_.Calc_qte_tid(atr_utl));
|
||||
Tfds.Eq_bool(valid, (atr_utl & Mwh_atr_itm_.Mask__valid) == Mwh_atr_itm_.Mask__valid);
|
||||
Tfds.Eq_bool(repeated, (atr_utl & Mwh_atr_itm_.Mask__repeated) == Mwh_atr_itm_.Mask__repeated);
|
||||
Tfds.Eq_bool(key_exists, (atr_utl & Mwh_atr_itm_.Mask__key_exists) == Mwh_atr_itm_.Mask__key_exists);
|
||||
Tfds.Eq_bool(val_made, (atr_utl & Mwh_atr_itm_.Mask__val_made) == Mwh_atr_itm_.Mask__val_made);
|
||||
}
|
||||
}
|
||||
@@ -1,74 +0,0 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
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.xowa.parsers.htmls; import gplx.*; import gplx.xowa.*; import gplx.xowa.parsers.*;
|
||||
class Mwh_atr_parser_fxt {
|
||||
private final Bry_bfr expd_bfr = Bry_bfr_.New(), actl_bfr = Bry_bfr_.New();
|
||||
private final Mwh_atr_parser parser = new Mwh_atr_parser();
|
||||
private final Mwh_doc_wkr__atr_bldr wkr = new Mwh_doc_wkr__atr_bldr();
|
||||
public Mwh_atr_itm Make_pair(String key, String val) {return new Mwh_atr_itm(Bry_.Empty, Bool_.Y, Bool_.N, Bool_.Y, -1, -1, -1, -1, Bry_.new_u8(key) , -1, -1, Bry_.new_u8(val) , -1, -1);}
|
||||
public Mwh_atr_itm Make_name(String key) {return new Mwh_atr_itm(Bry_.Empty, Bool_.Y, Bool_.N, Bool_.N, -1, -1, -1, -1, Bry_.new_u8(key) , -1, -1, Bry_.new_u8(key) , -1, -1);}
|
||||
public Mwh_atr_itm Make_fail(int bgn, int end) {return new Mwh_atr_itm(Bry_.Empty, Bool_.N, Bool_.N, Bool_.N, bgn, end, -1, -1, null , -1, -1, null , -1, -1);}
|
||||
public void Test_val_as_int(String raw, int expd) {
|
||||
byte[] src = Bry_.new_u8(raw);
|
||||
Mwh_atr_itm itm = new Mwh_atr_itm(src, true, false, false, 0, src.length, -1, -1, null, 0, src.length, src, -1, -1);
|
||||
Tfds.Eq_int(expd, itm.Val_as_int_or(-1));
|
||||
}
|
||||
public void Test_parse(String raw, Mwh_atr_itm... expd) {
|
||||
Mwh_atr_itm[] actl = Exec_parse(raw);
|
||||
Test_print(expd, actl);
|
||||
}
|
||||
private Mwh_atr_itm[] Exec_parse(String raw) {
|
||||
byte[] bry = Bry_.new_u8(raw);
|
||||
parser.Parse(wkr, -1, -1, bry, 0, bry.length);
|
||||
return wkr.To_atr_ary();
|
||||
}
|
||||
public void Test_print(Mwh_atr_itm[] expd_ary, Mwh_atr_itm[] actl_ary) {
|
||||
int expd_len = expd_ary.length;
|
||||
int actl_len = actl_ary.length;
|
||||
int len = expd_len > actl_len ? expd_len : actl_len;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
To_bfr(expd_bfr, i < expd_len ? expd_ary[i] : null, actl_bfr, i < actl_len ? actl_ary[i] : null);
|
||||
}
|
||||
Tfds.Eq_str_lines(expd_bfr.To_str_and_clear(), actl_bfr.To_str_and_clear());
|
||||
}
|
||||
private void To_bfr(Bry_bfr expd_bfr, Mwh_atr_itm expd_itm, Bry_bfr actl_bfr, Mwh_atr_itm actl_itm) {
|
||||
To_bfr__main(expd_bfr, expd_itm);
|
||||
To_bfr__main(actl_bfr, actl_itm);
|
||||
To_bfr__head(expd_bfr, expd_itm);
|
||||
To_bfr__head(actl_bfr, actl_itm);
|
||||
if (expd_itm != null && expd_itm.Atr_bgn() != -1) {
|
||||
To_bfr__atr_rng(expd_bfr, expd_itm);
|
||||
To_bfr__atr_rng(actl_bfr, actl_itm);
|
||||
}
|
||||
}
|
||||
private void To_bfr__head(Bry_bfr bfr, Mwh_atr_itm itm) {
|
||||
if (itm == null) return;
|
||||
bfr.Add_str_a7("head:").Add_yn(itm.Valid()).Add_byte_semic().Add_yn(itm.Repeated()).Add_byte_semic().Add_yn(itm.Key_exists()).Add_byte_nl();
|
||||
}
|
||||
private void To_bfr__main(Bry_bfr bfr, Mwh_atr_itm itm) {
|
||||
if (itm == null) return;
|
||||
if (itm.Valid()) {
|
||||
bfr.Add_str_a7("key:").Add(itm.Key_bry()).Add_byte_nl();
|
||||
bfr.Add_str_a7("val:").Add(itm.Val_as_bry()).Add_byte_nl();
|
||||
}
|
||||
// else
|
||||
// To_bfr__atr_rng(bfr, itm);
|
||||
}
|
||||
private void To_bfr__atr_rng(Bry_bfr bfr, Mwh_atr_itm itm) {
|
||||
if (itm == null) return;
|
||||
bfr.Add_str_a7("rng:").Add_int_variable(itm.Atr_bgn()).Add_byte_semic().Add_int_variable(itm.Atr_end()).Add_byte_nl();
|
||||
}
|
||||
}
|
||||
@@ -1,76 +0,0 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
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.xowa.parsers.htmls; import gplx.*; import gplx.xowa.*; import gplx.xowa.parsers.*;
|
||||
import org.junit.*;
|
||||
public class Mwh_atr_parser_tst {
|
||||
private final Mwh_atr_parser_fxt fxt = new Mwh_atr_parser_fxt();
|
||||
@Test public void Pair__quote__double() {fxt.Test_parse("a=\"b\"" , fxt.Make_pair("a" , "b"));}
|
||||
@Test public void Pair__quote__single() {fxt.Test_parse("a='b'" , fxt.Make_pair("a" , "b"));}
|
||||
@Test public void Pair__quote__none() {fxt.Test_parse("a=b" , fxt.Make_pair("a" , "b"));}
|
||||
@Test public void Pair__quote__none__amp() {fxt.Test_parse("a=&bc" , fxt.Make_pair("a" , "&bc"));}
|
||||
@Test public void Pair__empty() {fxt.Test_parse("a=''" , fxt.Make_pair("a" , ""));}
|
||||
@Test public void Pair__key_w_underline() {fxt.Test_parse("a_b=c" , fxt.Make_pair("a_b" , "c"));}
|
||||
|
||||
@Test public void Name__quote__none() {fxt.Test_parse("b" , fxt.Make_name("b"));}
|
||||
@Test public void Name__ws() {fxt.Test_parse(" b " , fxt.Make_name("b"));} // PURPOSE:discovered while writing test for ref's "lower-alpha" DATE:2014-07-03
|
||||
@Test public void Name__mult() {fxt.Test_parse("a b1 c" , fxt.Make_name("a"), fxt.Make_name("b1"), fxt.Make_name("c"));}
|
||||
|
||||
@Test public void Fail__key_w_plus() {fxt.Test_parse("a+b" , fxt.Make_fail(0, 3));}
|
||||
@Test public void Fail__key_w_plus__many() {fxt.Test_parse("a+b c=d" , fxt.Make_fail(0, 3) , fxt.Make_pair("c", "d"));}
|
||||
@Test public void Fail__val_w_plus() {fxt.Test_parse("a=b+c" , fxt.Make_fail(0, 5));}
|
||||
@Test public void Fail__recover() {fxt.Test_parse("* a=b" , fxt.Make_fail(0, 1) , fxt.Make_pair("a", "b"));} // PURPOSE: * is invalid, but should not stop parsing of a=b
|
||||
@Test public void Fail__incomplete() {fxt.Test_parse("a= c=d" , fxt.Make_fail(0, 3) , fxt.Make_pair("c", "d"));} // PURPOSE: discard xatr if incomplete and followed by valid atr; PAGE:en.w:2013_in_American_television DATE:2014-09-25
|
||||
@Test public void Fail__incomplete_2() {fxt.Test_parse("a=c=d" , fxt.Make_fail(0, 5));} // PURPOSE: variation of above; per MW regex, missing space invalidates entire attribute; DATE:2014-09-25
|
||||
@Test public void Fail__incomplete_pair() {fxt.Test_parse("a= b=" , fxt.Make_fail(0, 3) , fxt.Make_fail(3, 5));} // PURPOSE: "b=" should be invalid not a kv of "b" = "b"; PAGE:en.s:Notes_by_the_Way/Chapter_2; DATE:2015-01-31
|
||||
|
||||
@Test public void Dangling_eos() {fxt.Test_parse("a='b' c='d" , fxt.Make_pair("a", "b") , fxt.Make_fail(5, 10));} // PURPOSE: handle dangling quote at eos; PAGE:en.w:Aubervilliers DATE:2014-06-25
|
||||
@Test public void Dangling_bos() {fxt.Test_parse("a='b c=d" , fxt.Make_fail(0, 4) , fxt.Make_pair("c", "d"));}// PURPOSE: handle dangling quote at bos; resume at next valid atr; PAGE:en.w:Aubervilliers DATE:2014-06-25
|
||||
|
||||
@Test public void Ws__ini() {fxt.Test_parse(" a='b'" , fxt.Make_pair("a", "b").Atr_rng(0, 6));}
|
||||
@Test public void Ws__end() {fxt.Test_parse(" a='b' c='d'" , fxt.Make_pair("a", "b").Atr_rng(0, 6), fxt.Make_pair("c", "d").Atr_rng(6, 12));}
|
||||
@Test public void Ws() {fxt.Test_parse("a = 'b'" , fxt.Make_pair("a", "b"));} // PURPOSE: fix wherein multiple space was causing "a=a"; PAGE:fr.s:La_Sculpture_dans_les_cimetières_de_Paris/Père-Lachaise; DATE:2014-01-18
|
||||
|
||||
@Test public void Many__quote__apos() {fxt.Test_parse("a='b' c='d' e='f'" , fxt.Make_pair("a", "b"), fxt.Make_pair("c", "d"), fxt.Make_pair("e", "f"));}
|
||||
@Test public void Many__naked() {fxt.Test_parse("a=b c=d e=f" , fxt.Make_pair("a", "b"), fxt.Make_pair("c", "d"), fxt.Make_pair("e", "f"));}
|
||||
@Test public void Many__naked__pair() {fxt.Test_parse("a b=c" , fxt.Make_name("a"), fxt.Make_pair("b", "c"));}
|
||||
|
||||
@Test public void Quote__ws__nl() {fxt.Test_parse("a='b\nc'" , fxt.Make_pair("a", "b c"));}
|
||||
@Test public void Quote__ws__mult() {fxt.Test_parse("a='b c'" , fxt.Make_pair("a", "b c"));}
|
||||
@Test public void Quote__ws__mult_mult() {fxt.Test_parse("a='b c d'" , fxt.Make_pair("a", "b c d"));} // PURPOSE: fix wherein 1st-gobble gobbled rest of spaces (was b cd)
|
||||
@Test public void Quote__apos() {fxt.Test_parse("a=\"b c'd\"" , fxt.Make_pair("a", "b c'd"));} // PURPOSE: fix wherein apos was gobbled up; PAGE:en.s:Alice's_Adventures_in_Wonderland; DATE:2013-11-22
|
||||
@Test public void Quote__apos_2() {fxt.Test_parse("a=\"b'c d\"" , fxt.Make_pair("a", "b'c d"));} // PURPOSE: fix wherein apos was causing "'b'c d"; PAGE:en.s:Grimm's_Household_Tales,_Volume_1; DATE:2013-12-22
|
||||
// @Test public void Quote__angle() {fxt.Test_parse("a='<'" , fxt.Make_fail(0, 5));} // PURPOSE: "<" inside quotes is always invalid
|
||||
@Test public void Quote__invalid() {fxt.Test_parse("a='b'c" , fxt.Make_fail(0, 6));}
|
||||
|
||||
@Test public void Nowiki__atr() {fxt.Test_parse("<nowiki>a=b</nowiki>" , fxt.Make_pair("a", "b").Atr_rng(8, 20));}
|
||||
@Test public void Nowiki__key() {fxt.Test_parse("a<nowiki>b</nowiki>c=d" , fxt.Make_pair("abc", "d").Atr_rng(0, 22));}
|
||||
@Test public void Nowiki__eql() {fxt.Test_parse("a<nowiki>=</nowiki>\"b\"" , fxt.Make_pair("a", "b").Atr_rng(0, 22));} // EX:fr.w:{{Portail|Transpédia|Californie}}
|
||||
@Test public void Nowiki__val__naked() {fxt.Test_parse("a=b<nowiki>c</nowiki>d" , fxt.Make_pair("a", "bcd").Atr_rng(0, 22));}
|
||||
@Test public void Nowiki__val__quote() {fxt.Test_parse("a=<nowiki>'b'</nowiki>" , fxt.Make_pair("a", "b").Atr_rng(0, 22));}
|
||||
@Test public void Nowiki__val__quote_2() {fxt.Test_parse("a=\"b<nowiki>c</nowiki>d<nowiki>e</nowiki>f\"", fxt.Make_pair("a", "bcdef"));}
|
||||
|
||||
@Test public void Val__as_int() {fxt.Test_val_as_int("-123" , -123);}
|
||||
|
||||
// @Test public void Embedded() { // PURPOSE: handle html inside attrib; PAGE:en.w:Economy_of_Greece DATE:2015-10-15
|
||||
// fxt.Test_parse("title='<sup id='cite_ref-a_1-0' class='reference'><a href='#cite_note-a-1'>[1]</a></sup> c'"
|
||||
// , fxt.Make_fail(0, 11) // "title='<sup" invalid b/c of "<"
|
||||
// , fxt.Make_pair("id", "cite_ref-a_1-0")
|
||||
// , fxt.Make_fail(31, 52) // "class='reference'><a" invalid b/c no ws after '
|
||||
// , fxt.Make_fail(53, 88) // "href='#cite_note-a-1'>[1]</a></sup>" invalid b/c no ws after '
|
||||
// , fxt.Make_fail(89, 91) // " c'" invalid b/c name (c) cannot have apos
|
||||
// );
|
||||
// }
|
||||
}
|
||||
@@ -1,73 +0,0 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
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.xowa.parsers.htmls; import gplx.*; import gplx.xowa.*; import gplx.xowa.parsers.*;
|
||||
class Mwh_doc_parser_fxt {
|
||||
private final Bry_bfr expd_bfr = Bry_bfr_.New(), actl_bfr = Bry_bfr_.New();
|
||||
private final Mwh_doc_parser parser = new Mwh_doc_parser();
|
||||
private final Mwh_doc_wkr__itm_bldr wkr = new Mwh_doc_wkr__itm_bldr();
|
||||
public Mwh_doc_itm Make_txt (String raw) {return new Mwh_doc_itm(Mwh_doc_itm.Itm_tid__txt , -1, Bry_.new_u8(raw));}
|
||||
public Mwh_doc_itm Make_txt (String raw, int nde_tid) {return new Mwh_doc_itm(Mwh_doc_itm.Itm_tid__txt , nde_tid, Bry_.new_u8(raw));}
|
||||
public Mwh_doc_itm Make_comment (String raw) {return new Mwh_doc_itm(Mwh_doc_itm.Itm_tid__comment , -1, Bry_.new_u8(raw));}
|
||||
public Mwh_doc_itm Make_entity (String raw) {return new Mwh_doc_itm(Mwh_doc_itm.Itm_tid__entity , -1, Bry_.new_u8(raw));}
|
||||
public Mwh_doc_itm Make_nde_head(String raw) {return new Mwh_doc_itm(Mwh_doc_itm.Itm_tid__nde_head , -1, Bry_.new_u8(raw));}
|
||||
public Mwh_doc_itm Make_nde_tail(String raw) {return new Mwh_doc_itm(Mwh_doc_itm.Itm_tid__nde_tail , -1, Bry_.new_u8(raw));}
|
||||
public void Test_parse(String raw, Mwh_doc_itm... expd) {
|
||||
Mwh_doc_itm[] actl = Exec_parse(raw);
|
||||
Test_print(expd, actl);
|
||||
}
|
||||
public Mwh_doc_itm[] Exec_parse(String raw) {
|
||||
byte[] bry = Bry_.new_u8(raw);
|
||||
parser.Parse(wkr, bry, 0, bry.length);
|
||||
return wkr.To_atr_ary();
|
||||
}
|
||||
public void Test_print(Mwh_doc_itm[] expd_ary, Mwh_doc_itm[] actl_ary) {
|
||||
int expd_len = expd_ary.length;
|
||||
int actl_len = actl_ary.length;
|
||||
int len = expd_len > actl_len ? expd_len : actl_len;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
To_bfr(expd_bfr, i < expd_len ? expd_ary[i] : null, actl_bfr, i < actl_len ? actl_ary[i] : null);
|
||||
}
|
||||
Tfds.Eq_str_lines(expd_bfr.To_str_and_clear(), actl_bfr.To_str_and_clear());
|
||||
}
|
||||
private void To_bfr(Bry_bfr expd_bfr, Mwh_doc_itm expd_itm, Bry_bfr actl_bfr, Mwh_doc_itm actl_itm) {
|
||||
To_bfr__main(expd_bfr, expd_itm); To_bfr__main(actl_bfr, actl_itm);
|
||||
if (expd_itm != null && expd_itm.Nde_tid() != -1) {
|
||||
To_bfr__nde_tid(expd_bfr, expd_itm); To_bfr__nde_tid(actl_bfr, actl_itm);
|
||||
}
|
||||
}
|
||||
private void To_bfr__main(Bry_bfr bfr, Mwh_doc_itm itm) {
|
||||
if (itm == null) return;
|
||||
bfr.Add_str_a7("itm_tid:").Add_int_variable(itm.Itm_tid()).Add_byte_nl();
|
||||
bfr.Add_str_a7("txt:").Add(itm.Itm_bry()).Add_byte_nl();
|
||||
}
|
||||
private void To_bfr__nde_tid(Bry_bfr bfr, Mwh_doc_itm itm) {
|
||||
if (itm == null) return;
|
||||
bfr.Add_str_a7("nde_tid:").Add_int_variable(itm.Nde_tid()).Add_byte_nl();
|
||||
}
|
||||
}
|
||||
class Mwh_doc_wkr__itm_bldr implements Mwh_doc_wkr {
|
||||
private final List_adp list = List_adp_.New();
|
||||
public Hash_adp_bry Nde_regy() {return nde_regy;} private final Hash_adp_bry nde_regy = Mwh_doc_wkr_.Nde_regy__mw();
|
||||
public void On_atr_each (Mwh_atr_parser mgr, byte[] src, int nde_tid, boolean valid, boolean repeated, boolean key_exists, byte[] key_bry, byte[] val_bry_manual, int[] itm_ary, int itm_idx) {}
|
||||
public void On_txt_end (Mwh_doc_parser mgr, byte[] src, int nde_tid, int itm_bgn, int itm_end) {list.Add(new Mwh_doc_itm(Mwh_doc_itm.Itm_tid__txt , nde_tid, Bry_.Mid(src, itm_bgn, itm_end)));}
|
||||
public void On_nde_head_bgn (Mwh_doc_parser mgr, byte[] src, int nde_tid, int key_bgn, int key_end) {}
|
||||
public void On_nde_head_end (Mwh_doc_parser mgr, byte[] src, int nde_tid, int itm_bgn, int itm_end, boolean inline) {list.Add(new Mwh_doc_itm(Mwh_doc_itm.Itm_tid__nde_head , nde_tid, Bry_.Mid(src, itm_bgn, itm_end)));}
|
||||
public void On_nde_tail_end (Mwh_doc_parser mgr, byte[] src, int nde_tid, int itm_bgn, int itm_end) {list.Add(new Mwh_doc_itm(Mwh_doc_itm.Itm_tid__nde_tail , nde_tid, Bry_.Mid(src, itm_bgn, itm_end)));}
|
||||
public void On_comment_end (Mwh_doc_parser mgr, byte[] src, int nde_tid, int itm_bgn, int itm_end) {list.Add(new Mwh_doc_itm(Mwh_doc_itm.Itm_tid__comment , nde_tid, Bry_.Mid(src, itm_bgn, itm_end)));}
|
||||
public void On_entity_end (Mwh_doc_parser mgr, byte[] src, int nde_tid, int itm_bgn, int itm_end) {list.Add(new Mwh_doc_itm(Mwh_doc_itm.Itm_tid__entity , nde_tid, Bry_.Mid(src, itm_bgn, itm_end)));}
|
||||
|
||||
public Mwh_doc_itm[] To_atr_ary() {return (Mwh_doc_itm[])list.To_ary_and_clear(Mwh_doc_itm.class);}
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
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.xowa.parsers.htmls; import gplx.*; import gplx.xowa.*; import gplx.xowa.parsers.*;
|
||||
import org.junit.*; import gplx.xowa.parsers.xndes.*;
|
||||
public class Mwh_doc_parser_tst {
|
||||
private final Mwh_doc_parser_fxt fxt = new Mwh_doc_parser_fxt();
|
||||
@Test public void Text__basic() {fxt.Test_parse("abc" , fxt.Make_txt("abc"));}
|
||||
@Test public void Comment() {fxt.Test_parse("a<!--b-->c" , fxt.Make_txt("a"), fxt.Make_comment("<!--b-->"), fxt.Make_txt("c"));}
|
||||
@Test public void Entity() {fxt.Test_parse("a b" , fxt.Make_txt("a"), fxt.Make_entity(" "), fxt.Make_txt("b"));}
|
||||
@Test public void Fail__inline_eos() {fxt.Test_parse("a<b/" , fxt.Make_txt("a<b/"));}
|
||||
@Test public void Fail__unknown() {fxt.Test_parse("a<bc/>d" , fxt.Make_txt("a<bc/>d"));}
|
||||
@Test public void Node__inline() {fxt.Test_parse("a<b/>c" , fxt.Make_txt("a"), fxt.Make_nde_head("<b/>") , fxt.Make_txt("c"));}
|
||||
@Test public void Node__pair() {fxt.Test_parse("a<b>c</b>d" , fxt.Make_txt("a"), fxt.Make_nde_head("<b>") , fxt.Make_txt("c"), fxt.Make_nde_tail("</b>"), fxt.Make_txt("d"));}
|
||||
@Test public void Atrs__pair() {
|
||||
fxt.Test_parse("<div id='1'>a</div>"
|
||||
, fxt.Make_nde_head("<div id='1'>")
|
||||
, fxt.Make_txt("a")
|
||||
, fxt.Make_nde_tail("</div>"));
|
||||
}
|
||||
@Test public void Atrs__inline() {
|
||||
fxt.Test_parse("a<div id='1'/>b"
|
||||
, fxt.Make_txt("a")
|
||||
, fxt.Make_nde_head("<div id='1'/>")
|
||||
, fxt.Make_txt("b"));
|
||||
}
|
||||
@Test public void Node__single_only() {
|
||||
fxt.Test_parse("<b>a<br>b</b>c"
|
||||
, fxt.Make_nde_head("<b>")
|
||||
, fxt.Make_txt("a", Xop_xnde_tag_.Tid__b)
|
||||
, fxt.Make_nde_head("<br>")
|
||||
, fxt.Make_txt("b", Xop_xnde_tag_.Tid__b) // <b> not <br>
|
||||
, fxt.Make_nde_tail("</b>")
|
||||
, fxt.Make_txt("c", Xop_xnde_tag_.Tid__null)
|
||||
);
|
||||
}
|
||||
@Test public void Node__pre() {
|
||||
fxt.Test_parse("<pre>a<div>b</pre>c"
|
||||
, fxt.Make_nde_head("<pre>")
|
||||
, fxt.Make_txt("a", Xop_xnde_tag_.Tid__pre)
|
||||
, fxt.Make_nde_head("<div>")
|
||||
, fxt.Make_txt("b", Xop_xnde_tag_.Tid__pre) // <pre> not <div>
|
||||
, fxt.Make_nde_tail("</pre>")
|
||||
, fxt.Make_txt("c", Xop_xnde_tag_.Tid__null)
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user