mirror of
https://github.com/gnosygnu/xowa.git
synced 2024-10-27 20:34:16 +00:00
Section_edit: Support headers with covering behavior, dupes, xml, math, and templates
This commit is contained in:
parent
998937ca26
commit
780062ebb4
@ -77,6 +77,7 @@ class Gfs_parser_ {
|
|||||||
trie_add_quote(rv, new byte[] {Byte_ascii.Quote});
|
trie_add_quote(rv, new byte[] {Byte_ascii.Quote});
|
||||||
trie_add_quote(rv, Bry_.new_a7("<:[\"\n"), Bry_.new_a7("\n\"]:>"));
|
trie_add_quote(rv, Bry_.new_a7("<:[\"\n"), Bry_.new_a7("\n\"]:>"));
|
||||||
trie_add_quote(rv, Bry_.new_a7("<:['\n"), Bry_.new_a7("\n']:>"));
|
trie_add_quote(rv, Bry_.new_a7("<:['\n"), Bry_.new_a7("\n']:>"));
|
||||||
|
trie_add_quote(rv, Bry_.new_a7("<:{'"), Bry_.new_a7("'}:>"));
|
||||||
trie_add_comment(rv, new byte[] {Byte_ascii.Slash, Byte_ascii.Slash}, new byte[] {Byte_ascii.Nl});
|
trie_add_comment(rv, new byte[] {Byte_ascii.Slash, Byte_ascii.Slash}, new byte[] {Byte_ascii.Nl});
|
||||||
trie_add_comment(rv, new byte[] {Byte_ascii.Slash, Byte_ascii.Star}, new byte[] {Byte_ascii.Star, Byte_ascii.Slash});
|
trie_add_comment(rv, new byte[] {Byte_ascii.Slash, Byte_ascii.Star}, new byte[] {Byte_ascii.Star, Byte_ascii.Slash});
|
||||||
rv.Add(Byte_ascii.Semic, Gfs_lxr_semic.Instance);
|
rv.Add(Byte_ascii.Semic, Gfs_lxr_semic.Instance);
|
||||||
|
@ -32,7 +32,7 @@ public class Xoa_app_ {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
public static final String Name = "xowa";
|
public static final String Name = "xowa";
|
||||||
public static final String Version = "3.12.1.2";
|
public static final String Version = "3.12.1.3";
|
||||||
public static String Build_date = "2012-12-30 00:00:00";
|
public static String Build_date = "2012-12-30 00:00:00";
|
||||||
public static String Op_sys_str;
|
public static String Op_sys_str;
|
||||||
public static String User_agent = "";
|
public static String User_agent = "";
|
||||||
|
@ -20,7 +20,6 @@ import gplx.langs.gfs.*;
|
|||||||
class Xocfg_maint_parser {
|
class Xocfg_maint_parser {
|
||||||
public Xocfg_maint_nde[] Parse(String raw) {
|
public Xocfg_maint_nde[] Parse(String raw) {
|
||||||
GfoMsg root = Gfs_msg_bldr.Instance.ParseToMsg(raw);
|
GfoMsg root = Gfs_msg_bldr.Instance.ParseToMsg(raw);
|
||||||
root = root.Subs_getAt(0); // NOTE: ignore fake root
|
|
||||||
|
|
||||||
int len = root.Subs_count();
|
int len = root.Subs_count();
|
||||||
Xocfg_maint_nde[] rv = new Xocfg_maint_nde[len];
|
Xocfg_maint_nde[] rv = new Xocfg_maint_nde[len];
|
||||||
|
@ -20,12 +20,12 @@ import org.junit.*; import gplx.core.tests.*;
|
|||||||
public class Xocfg_maint_parser__tst {
|
public class Xocfg_maint_parser__tst {
|
||||||
private final Xocfg_maint_parser__fxt fxt = new Xocfg_maint_parser__fxt();
|
private final Xocfg_maint_parser__fxt fxt = new Xocfg_maint_parser__fxt();
|
||||||
@Test public void Parse_grp() {
|
@Test public void Parse_grp() {
|
||||||
fxt.Exec__parse("root {grp {key='key_1'; owner='owner_1'; name='name_1'; help='help_1'}}"
|
fxt.Exec__parse("grp {key='key_1'; owner='owner_1'; name='name_1'; help='help_1'}"
|
||||||
, fxt.Make__grp("key_1", "owner_1", "name_1", "help_1")
|
, fxt.Make__grp("key_1", "owner_1", "name_1", "help_1")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@Test public void Parse_itm() {
|
@Test public void Parse_itm() {
|
||||||
fxt.Exec__parse("root {itm {key='key_1'; owner='owner_1'; name='name_1'; help='help_1'; scope='scope_1'; db_type='db_type_1'; dflt='dflt_1'; gui_type='gui_type_1'; gui_args='gui_args_1'}}"
|
fxt.Exec__parse("itm {key='key_1'; owner='owner_1'; name='name_1'; help='help_1'; scope='scope_1'; db_type='db_type_1'; dflt='dflt_1'; gui_type='gui_type_1'; gui_args='gui_args_1'}"
|
||||||
, fxt.Make__itm("key_1", "owner_1", "name_1", "help_1", "scope_1", "db_type_1", "dflt_1", "gui_type_1", "gui_args_1")
|
, fxt.Make__itm("key_1", "owner_1", "name_1", "help_1", "scope_1", "db_type_1", "dflt_1", "gui_type_1", "gui_args_1")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -226,7 +226,7 @@ public class Xoh_page_wtr_wkr {
|
|||||||
data_raw = Gfs_php_converter.Xto_php(tmp_bfr, Bool_.N, data_raw);
|
data_raw = Gfs_php_converter.Xto_php(tmp_bfr, Bool_.N, data_raw);
|
||||||
int data_raw_len = data_raw.length;
|
int data_raw_len = data_raw.length;
|
||||||
if (mgr.Html_capable()) {
|
if (mgr.Html_capable()) {
|
||||||
data_raw = wiki.Parser_mgr().Hdr__section_editable__mgr().Extract_section(app, page.Url(), page.Ttl(), data_raw);
|
data_raw = wiki.Parser_mgr().Hdr__section_editable__mgr().Slice_section(page.Url(), page.Ttl(), data_raw);
|
||||||
data_raw_len = data_raw.length;
|
data_raw_len = data_raw.length;
|
||||||
Xoh_html_wtr_escaper.Escape(page.Wikie().Appe().Parser_amp_mgr(), bfr, data_raw, 0, data_raw_len, false, false); // NOTE: must escape; assume that browser will automatically escape (<) (which Mozilla does)
|
Xoh_html_wtr_escaper.Escape(page.Wikie().Appe().Parser_amp_mgr(), bfr, data_raw, 0, data_raw_len, false, false); // NOTE: must escape; assume that browser will automatically escape (<) (which Mozilla does)
|
||||||
}
|
}
|
||||||
|
@ -31,6 +31,7 @@ public class Xoh_hdr_html {
|
|||||||
|
|
||||||
// register hdr with TOC
|
// register hdr with TOC
|
||||||
byte[] hdr_text_bry = Bld_hdr_html(hdr_text_bfr, wtr, page, ctx, hctx, src, hdr);
|
byte[] hdr_text_bry = Bld_hdr_html(hdr_text_bfr, wtr, page, ctx, hctx, src, hdr);
|
||||||
|
hdr_text_bry = wiki.Parser_mgr().Uniq_mgr().Convert(hdr_text_bry); // need for math; DATE:2016-12-09
|
||||||
Xoh_toc_itm toc_itm = hdr_is_valid && hdr_text_bry.length > 0
|
Xoh_toc_itm toc_itm = hdr_is_valid && hdr_text_bry.length > 0
|
||||||
? page.Html_data().Toc_mgr().Add(hdr_num, hdr_text_bry)
|
? page.Html_data().Toc_mgr().Add(hdr_num, hdr_text_bry)
|
||||||
: invalid_toc_itm;
|
: invalid_toc_itm;
|
||||||
|
@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
package gplx.xowa.htmls.core.wkrs.hdrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*;
|
package gplx.xowa.htmls.core.wkrs.hdrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*;
|
||||||
import org.junit.*; import gplx.xowa.htmls.core.makes.tests.*;
|
import org.junit.*; import gplx.xowa.htmls.core.makes.tests.*;
|
||||||
public class Xoh_hdr_html_tst {
|
public class Xoh_hdr_html_tst {
|
||||||
private final Xoh_make_fxt fxt = new Xoh_make_fxt();
|
private final Xoh_make_fxt fxt = new Xoh_make_fxt();
|
||||||
@Test public void Basic() {
|
@Test public void Basic() {
|
||||||
fxt.Test__html(String_.Concat_lines_nl_skip_last
|
fxt.Test__html(String_.Concat_lines_nl_skip_last
|
||||||
( "z"
|
( "z"
|
||||||
@ -36,4 +36,14 @@ public class Xoh_hdr_html_tst {
|
|||||||
, "b"
|
, "b"
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
@Test public void Uniq() {
|
||||||
|
byte[] uniq = fxt.Parser_fxt().Wiki().Parser_mgr().Uniq_mgr().Add(Bry_.new_a7("bcd"));
|
||||||
|
fxt.Test__html(String_.Concat_lines_nl_skip_last
|
||||||
|
( "== a" + String_.new_u8(uniq) + "e =="
|
||||||
|
, "text"
|
||||||
|
), String_.Concat_lines_nl_skip_last
|
||||||
|
( "<h2><span class='mw-headline' id='abcde'> abcde </span></h2>"
|
||||||
|
, "text"
|
||||||
|
));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,13 +17,15 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
*/
|
*/
|
||||||
package gplx.xowa.parsers.hdrs.sections; import gplx.*; import gplx.xowa.*; import gplx.xowa.parsers.*; import gplx.xowa.parsers.hdrs.*;
|
package gplx.xowa.parsers.hdrs.sections; import gplx.*; import gplx.xowa.*; import gplx.xowa.parsers.*; import gplx.xowa.parsers.hdrs.*;
|
||||||
class Xop_section_itm {
|
class Xop_section_itm {
|
||||||
public Xop_section_itm(int idx, byte[] key, int src_bgn, int src_end) {
|
public Xop_section_itm(int idx, int num, byte[] key, int src_bgn, int src_end) {
|
||||||
this.idx = idx;
|
this.idx = idx;
|
||||||
|
this.num = num;
|
||||||
this.key = key;
|
this.key = key;
|
||||||
this.src_bgn = src_bgn;
|
this.src_bgn = src_bgn;
|
||||||
this.src_end = src_end;
|
this.src_end = src_end;
|
||||||
}
|
}
|
||||||
public int Idx() {return idx;} private final int idx;
|
public int Idx() {return idx;} private final int idx;
|
||||||
|
public int Num() {return num;} private final int num;
|
||||||
public byte[] Key() {return key;} private final byte[] key;
|
public byte[] Key() {return key;} private final byte[] key;
|
||||||
public int Src_bgn() {return src_bgn;} private final int src_bgn;
|
public int Src_bgn() {return src_bgn;} private final int src_bgn;
|
||||||
public int Src_end() {return src_end;} private final int src_end;
|
public int Src_end() {return src_end;} private final int src_end;
|
||||||
|
@ -17,19 +17,28 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
*/
|
*/
|
||||||
package gplx.xowa.parsers.hdrs.sections; import gplx.*; import gplx.xowa.*; import gplx.xowa.parsers.*; import gplx.xowa.parsers.hdrs.*;
|
package gplx.xowa.parsers.hdrs.sections; import gplx.*; import gplx.xowa.*; import gplx.xowa.parsers.*; import gplx.xowa.parsers.hdrs.*;
|
||||||
import gplx.xowa.parsers.mws.*; import gplx.xowa.parsers.mws.wkrs.*;
|
import gplx.xowa.parsers.mws.*; import gplx.xowa.parsers.mws.wkrs.*;
|
||||||
|
import gplx.xowa.addons.htmls.tocs.*; import gplx.xowa.htmls.core.htmls.tidy.*;
|
||||||
class Xop_section_list implements Xomw_hdr_cbk {
|
class Xop_section_list implements Xomw_hdr_cbk {
|
||||||
private final Xomw_hdr_wkr hdr_wkr = new Xomw_hdr_wkr();
|
private final Xomw_hdr_wkr hdr_wkr = new Xomw_hdr_wkr();
|
||||||
private final Ordered_hash hash = Ordered_hash_.New_bry();
|
private final Ordered_hash hash = Ordered_hash_.New_bry();
|
||||||
|
private final Xoh_toc_mgr toc_mgr = new Xoh_toc_mgr();
|
||||||
private byte[] src;
|
private byte[] src;
|
||||||
|
private Xowe_wiki wiki;
|
||||||
|
|
||||||
public Xop_section_list Parse(byte[] src) {
|
public Xop_section_list Parse(Xowe_wiki wiki, Xow_tidy_mgr_interface tidy_mgr, byte[] src) {
|
||||||
|
// clear
|
||||||
|
this.wiki = wiki;
|
||||||
this.src = src;
|
this.src = src;
|
||||||
hash.Clear();
|
hash.Clear();
|
||||||
|
toc_mgr.Clear();
|
||||||
|
toc_mgr.Init(tidy_mgr, Bry_.Empty, Bry_.Empty);
|
||||||
|
|
||||||
|
// parse
|
||||||
Xomw_parser_ctx pctx = new Xomw_parser_ctx();
|
Xomw_parser_ctx pctx = new Xomw_parser_ctx();
|
||||||
hdr_wkr.Parse(pctx, src, 0, src.length, this);
|
hdr_wkr.Parse(pctx, src, 0, src.length, this);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
public byte[] Extract_bry_or_null(byte[] key) {
|
public byte[] Slice_bry_or_null(byte[] key) {
|
||||||
// find section matching key
|
// find section matching key
|
||||||
Xop_section_itm itm = (Xop_section_itm)hash.Get_by(key);
|
Xop_section_itm itm = (Xop_section_itm)hash.Get_by(key);
|
||||||
if (itm == null) return null;
|
if (itm == null) return null;
|
||||||
@ -60,23 +69,41 @@ class Xop_section_list implements Xomw_hdr_cbk {
|
|||||||
return src_bgn;
|
return src_bgn;
|
||||||
}
|
}
|
||||||
private int Get_src_end(Xop_section_itm itm) {
|
private int Get_src_end(Xop_section_itm itm) {
|
||||||
int src_end = src.length;
|
int src_end = -1; // default to last
|
||||||
if (itm.Idx() != hash.Len() - 1) { // if not last, get next
|
int hash_len = hash.Len();
|
||||||
Xop_section_itm nxt = (Xop_section_itm)hash.Get_at(itm.Idx() + 1);
|
for (int i = itm.Idx() + 1; i < hash_len; i++) {
|
||||||
|
Xop_section_itm nxt = (Xop_section_itm)hash.Get_at(i);
|
||||||
|
if (nxt.Num() > itm.Num()) continue; // skip headers that are at lower level; EX: == H2 == should skip === H3 ===
|
||||||
src_end = nxt.Src_bgn();
|
src_end = nxt.Src_bgn();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
if (src_end == -1) src_end = src.length; // no headers found; default to EOS
|
||||||
src_end = Bry_find_.Find_bwd__skip_ws(src, src_end, itm.Src_bgn());
|
src_end = Bry_find_.Find_bwd__skip_ws(src, src_end, itm.Src_bgn());
|
||||||
return src_end;
|
return src_end;
|
||||||
}
|
}
|
||||||
public void On_hdr_seen(Xomw_parser_ctx pctx, Xomw_hdr_wkr wkr) {
|
public void On_hdr_seen(Xomw_parser_ctx pctx, Xomw_hdr_wkr wkr) {
|
||||||
|
// get key by taking everything between ==; EX: "== abc ==" -> " abc "
|
||||||
byte[] src = wkr.Src();
|
byte[] src = wkr.Src();
|
||||||
int hdr_txt_bgn = wkr.Hdr_lhs_end();
|
int hdr_txt_bgn = wkr.Hdr_lhs_end();
|
||||||
int hdr_txt_end = wkr.Hdr_rhs_bgn();
|
int hdr_txt_end = wkr.Hdr_rhs_bgn();
|
||||||
|
|
||||||
|
// trim ws
|
||||||
hdr_txt_bgn = Bry_find_.Find_fwd_while_ws(src, hdr_txt_bgn, hdr_txt_end);
|
hdr_txt_bgn = Bry_find_.Find_fwd_while_ws(src, hdr_txt_bgn, hdr_txt_end);
|
||||||
hdr_txt_end = Bry_find_.Find_bwd__skip_ws(src, hdr_txt_end, hdr_txt_bgn);
|
hdr_txt_end = Bry_find_.Find_bwd__skip_ws(src, hdr_txt_end, hdr_txt_bgn);
|
||||||
|
byte[] key = Bry_.Mid(wkr.Src(), hdr_txt_bgn, hdr_txt_end);
|
||||||
|
|
||||||
byte[] key = Bry_.Mid(wkr.Src(), hdr_txt_bgn, hdr_txt_end);
|
// handle nested templates; EX: "== {{A}} ==" note that calling Parse_text_to_html is expensive (called per header) but should be as long as its not nested
|
||||||
Xop_section_itm itm = new Xop_section_itm(hash.Count(), key, wkr.Hdr_bgn(), wkr.Hdr_end());
|
key = wiki.Parser_mgr().Main().Parse_text_to_html(wiki.Parser_mgr().Ctx(), key);
|
||||||
|
|
||||||
|
// handle math; EX: "== <math>\delta</math> =="
|
||||||
|
key = wiki.Parser_mgr().Uniq_mgr().Convert(key);
|
||||||
|
|
||||||
|
// convert key to toc_text to handle (a) XML ("<i>a</i>" -> "a"); (b) dupes ("text" -> "text_2")
|
||||||
|
int num = wkr.Hdr_num();
|
||||||
|
Xoh_toc_itm toc_itm = toc_mgr.Add(num, key);
|
||||||
|
key = toc_itm.Anch();
|
||||||
|
|
||||||
|
Xop_section_itm itm = new Xop_section_itm(hash.Count(), num, key, wkr.Hdr_bgn(), wkr.Hdr_end());
|
||||||
hash.Add(key, itm);
|
hash.Add(key, itm);
|
||||||
}
|
}
|
||||||
public void On_src_done(Xomw_parser_ctx pctx, Xomw_hdr_wkr wkr) {}
|
public void On_src_done(Xomw_parser_ctx pctx, Xomw_hdr_wkr wkr) {}
|
||||||
|
@ -30,7 +30,7 @@ public class Xop_section_list__merge__tst {
|
|||||||
, "== Hdr 3 =="
|
, "== Hdr 3 =="
|
||||||
, "Para 3"
|
, "Para 3"
|
||||||
);
|
);
|
||||||
fxt.Test__merge_bry_or_null("Hdr 2", String_.Concat_lines_nl_skip_last
|
fxt.Test__merge_bry_or_null("Hdr_2", String_.Concat_lines_nl_skip_last
|
||||||
( "== Hdr 2 =="
|
( "== Hdr 2 =="
|
||||||
, "Para 2a"
|
, "Para 2a"
|
||||||
), String_.Concat_lines_nl_skip_last
|
), String_.Concat_lines_nl_skip_last
|
||||||
@ -60,7 +60,7 @@ public class Xop_section_list__merge__tst {
|
|||||||
, "== Hdr 3 =="
|
, "== Hdr 3 =="
|
||||||
, "Para 3"
|
, "Para 3"
|
||||||
);
|
);
|
||||||
fxt.Test__merge_bry_or_null("Hdr 2", String_.Concat_lines_nl_skip_last
|
fxt.Test__merge_bry_or_null("Hdr_2", String_.Concat_lines_nl_skip_last
|
||||||
( "== Hdr 2 =="
|
( "== Hdr 2 =="
|
||||||
, "Para 2a"
|
, "Para 2a"
|
||||||
), String_.Concat_lines_nl_skip_last
|
), String_.Concat_lines_nl_skip_last
|
||||||
@ -87,7 +87,7 @@ public class Xop_section_list__merge__tst {
|
|||||||
, "== Hdr 2 =="
|
, "== Hdr 2 =="
|
||||||
, "Para 2"
|
, "Para 2"
|
||||||
);
|
);
|
||||||
fxt.Test__merge_bry_or_null("Hdr 1", String_.Concat_lines_nl_skip_last
|
fxt.Test__merge_bry_or_null("Hdr_1", String_.Concat_lines_nl_skip_last
|
||||||
( "== Hdr 1 =="
|
( "== Hdr 1 =="
|
||||||
, "Para 1a"
|
, "Para 1a"
|
||||||
), String_.Concat_lines_nl_skip_last
|
), String_.Concat_lines_nl_skip_last
|
||||||
@ -108,7 +108,7 @@ public class Xop_section_list__merge__tst {
|
|||||||
, "== Hdr 2 =="
|
, "== Hdr 2 =="
|
||||||
, "Para 2"
|
, "Para 2"
|
||||||
);
|
);
|
||||||
fxt.Test__merge_bry_or_null("Hdr 1", String_.Concat_lines_nl_skip_last
|
fxt.Test__merge_bry_or_null("Hdr_1", String_.Concat_lines_nl_skip_last
|
||||||
( "== Hdr 1 =="
|
( "== Hdr 1 =="
|
||||||
, "Para 1a"
|
, "Para 1a"
|
||||||
), String_.Concat_lines_nl_skip_last
|
), String_.Concat_lines_nl_skip_last
|
||||||
@ -129,7 +129,7 @@ public class Xop_section_list__merge__tst {
|
|||||||
, "== Hdr 2 =="
|
, "== Hdr 2 =="
|
||||||
, "Para 2"
|
, "Para 2"
|
||||||
);
|
);
|
||||||
fxt.Test__merge_bry_or_null("Hdr 2", String_.Concat_lines_nl_skip_last
|
fxt.Test__merge_bry_or_null("Hdr_2", String_.Concat_lines_nl_skip_last
|
||||||
( "== Hdr 2 =="
|
( "== Hdr 2 =="
|
||||||
, "Para 2a"
|
, "Para 2a"
|
||||||
), String_.Concat_lines_nl_skip_last
|
), String_.Concat_lines_nl_skip_last
|
||||||
|
@ -16,7 +16,7 @@ You should have received a copy of the GNU Affero General Public License
|
|||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package gplx.xowa.parsers.hdrs.sections; import gplx.*; import gplx.xowa.*; import gplx.xowa.parsers.*; import gplx.xowa.parsers.hdrs.*;
|
package gplx.xowa.parsers.hdrs.sections; import gplx.*; import gplx.xowa.*; import gplx.xowa.parsers.*; import gplx.xowa.parsers.hdrs.*;
|
||||||
import org.junit.*; import gplx.core.tests.*;
|
import org.junit.*; import gplx.core.tests.*; import gplx.xowa.htmls.core.htmls.tidy.*;
|
||||||
public class Xop_section_list__slice__tst {
|
public class Xop_section_list__slice__tst {
|
||||||
private final Xop_section_list__fxt fxt = new Xop_section_list__fxt();
|
private final Xop_section_list__fxt fxt = new Xop_section_list__fxt();
|
||||||
@Test public void Basic() {
|
@Test public void Basic() {
|
||||||
@ -30,28 +30,95 @@ public class Xop_section_list__slice__tst {
|
|||||||
, "== Hdr 3 =="
|
, "== Hdr 3 =="
|
||||||
, "Para 3"
|
, "Para 3"
|
||||||
);
|
);
|
||||||
fxt.Test__slice_bry_or_null("Hdr 1"
|
fxt.Test__slice_bry_or_null("Hdr_1"
|
||||||
, "== Hdr 1 =="
|
, "== Hdr 1 =="
|
||||||
, "Para 1"
|
, "Para 1"
|
||||||
);
|
);
|
||||||
fxt.Test__slice_bry_or_null("Hdr 2"
|
fxt.Test__slice_bry_or_null("Hdr_2"
|
||||||
, "== Hdr 2 =="
|
, "== Hdr 2 =="
|
||||||
, "Para 2"
|
, "Para 2"
|
||||||
);
|
);
|
||||||
fxt.Test__slice_bry_or_null("Hdr 3"
|
fxt.Test__slice_bry_or_null("Hdr_3"
|
||||||
, "== Hdr 3 =="
|
, "== Hdr 3 =="
|
||||||
, "Para 3"
|
, "Para 3"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@Test public void Covering() {
|
||||||
|
fxt.Exec__parse
|
||||||
|
( "== Hdr 1 =="
|
||||||
|
, "Para 1"
|
||||||
|
, ""
|
||||||
|
, "=== Hdr 1a ==="
|
||||||
|
, "Para 1a"
|
||||||
|
, ""
|
||||||
|
, "=== Hdr 1b ==="
|
||||||
|
, "Para 1b"
|
||||||
|
, ""
|
||||||
|
, "== Hdr 2 =="
|
||||||
|
, "Para 2"
|
||||||
|
);
|
||||||
|
fxt.Test__slice_bry_or_null("Hdr_1"
|
||||||
|
, "== Hdr 1 =="
|
||||||
|
, "Para 1"
|
||||||
|
, ""
|
||||||
|
, "=== Hdr 1a ==="
|
||||||
|
, "Para 1a"
|
||||||
|
, ""
|
||||||
|
, "=== Hdr 1b ==="
|
||||||
|
, "Para 1b"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
@Test public void Xml() {
|
||||||
|
fxt.Exec__parse
|
||||||
|
( "== <i>Hdr 1</i> =="
|
||||||
|
, "Para 1"
|
||||||
|
, ""
|
||||||
|
, "== Hdr 2 =="
|
||||||
|
, "Para 2"
|
||||||
|
);
|
||||||
|
fxt.Test__slice_bry_or_null("Hdr_1", String_.Concat_lines_nl_skip_last
|
||||||
|
( "== <i>Hdr 1</i> =="
|
||||||
|
, "Para 1"
|
||||||
|
));
|
||||||
|
}
|
||||||
|
@Test public void Math() {
|
||||||
|
fxt.Exec__parse
|
||||||
|
( "== <math>\\delta</math> =="
|
||||||
|
, "Para 1"
|
||||||
|
, ""
|
||||||
|
, "== Hdr 2 =="
|
||||||
|
, "Para 2"
|
||||||
|
);
|
||||||
|
fxt.Test__slice_bry_or_null(".5Cdelta", String_.Concat_lines_nl_skip_last
|
||||||
|
( "== <math>\\delta</math> =="
|
||||||
|
, "Para 1"
|
||||||
|
));
|
||||||
|
}
|
||||||
|
@Test public void Template() {
|
||||||
|
fxt.Init__template("mock", "''{{{1}}}''");
|
||||||
|
fxt.Exec__parse
|
||||||
|
( "== {{mock|a}} =="
|
||||||
|
, "Para 1"
|
||||||
|
, ""
|
||||||
|
, "== Hdr 2 =="
|
||||||
|
, "Para 2"
|
||||||
|
);
|
||||||
|
fxt.Test__slice_bry_or_null("a", String_.Concat_lines_nl_skip_last
|
||||||
|
( "== {{mock|a}} =="
|
||||||
|
, "Para 1"
|
||||||
|
));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
class Xop_section_list__fxt {
|
class Xop_section_list__fxt {
|
||||||
private final Xop_section_list list = new Xop_section_list();
|
private final Xop_section_list list = new Xop_section_list();
|
||||||
|
private final Xop_fxt parser_fxt = new Xop_fxt();
|
||||||
|
public void Init__template(String page, String text) {parser_fxt.Init_defn_add(page, text);}
|
||||||
public void Exec__parse(String... lines) {
|
public void Exec__parse(String... lines) {
|
||||||
list.Parse(Bry_.new_u8(String_.Concat_lines_nl_skip_last(lines)));
|
list.Parse(parser_fxt.Wiki(), Xow_tidy_mgr_interface_.Noop, Bry_.new_u8(String_.Concat_lines_nl_skip_last(lines)));
|
||||||
}
|
}
|
||||||
public void Test__slice_bry_or_null(String key, String... lines) {
|
public void Test__slice_bry_or_null(String key, String... lines) {
|
||||||
String expd = String_.Concat_lines_nl_skip_last(lines);
|
String expd = String_.Concat_lines_nl_skip_last(lines);
|
||||||
byte[] actl = list.Extract_bry_or_null(Bry_.new_u8(key));
|
byte[] actl = list.Slice_bry_or_null(Bry_.new_u8(key));
|
||||||
Gftest.Eq__ary__lines(expd, actl, key);
|
Gftest.Eq__ary__lines(expd, actl, key);
|
||||||
}
|
}
|
||||||
public void Test__merge_bry_or_null(String key, String edit, String expd) {
|
public void Test__merge_bry_or_null(String key, String edit, String expd) {
|
||||||
|
@ -17,18 +17,22 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
*/
|
*/
|
||||||
package gplx.xowa.parsers.hdrs.sections; import gplx.*; import gplx.xowa.*; import gplx.xowa.parsers.*; import gplx.xowa.parsers.hdrs.*;
|
package gplx.xowa.parsers.hdrs.sections; import gplx.*; import gplx.xowa.*; import gplx.xowa.parsers.*; import gplx.xowa.parsers.hdrs.*;
|
||||||
import gplx.langs.htmls.*;
|
import gplx.langs.htmls.*;
|
||||||
import gplx.xowa.parsers.mws.*; import gplx.xowa.parsers.mws.wkrs.*; import gplx.xowa.parsers.hdrs.*;
|
import gplx.xowa.parsers.mws.*; import gplx.xowa.parsers.mws.wkrs.*; import gplx.xowa.parsers.hdrs.*; import gplx.xowa.htmls.core.htmls.tidy.*;
|
||||||
public class Xop_section_mgr implements Gfo_invk {
|
public class Xop_section_mgr implements Gfo_invk {
|
||||||
public boolean Enabled() {return enabled;} private boolean enabled;
|
private Xoae_app app; private Xowe_wiki wiki;
|
||||||
|
private Xow_tidy_mgr_interface tidy_mgr;
|
||||||
private final Bry_fmt section_editable_fmt = Bry_fmt.Auto_nl_apos
|
private final Bry_fmt section_editable_fmt = Bry_fmt.Auto_nl_apos
|
||||||
( "<span class='mw-editsection'><span class='mw-editsection-bracket'>[</span><a href='/wiki/~{page_ttl}?action=edit§ion_key=~{section_key}' title='Edit section: ~{section_name}' class='xowa-hover-off'>edit</a><span class='mw-editsection-bracket'>]</span></span>"
|
( "<span class='mw-editsection'><span class='mw-editsection-bracket'>[</span><a href='/wiki/~{page_ttl}?action=edit§ion_key=~{section_key}' title='Edit section: ~{section_name}' class='xowa-hover-off'>edit</a><span class='mw-editsection-bracket'>]</span></span>"
|
||||||
);
|
);
|
||||||
private static final byte[] Qarg__section_key = Bry_.new_u8("section_key");
|
|
||||||
|
|
||||||
|
public boolean Enabled() {return enabled;} private boolean enabled;
|
||||||
public void Init_by_wiki(Xowe_wiki wiki) {
|
public void Init_by_wiki(Xowe_wiki wiki) {
|
||||||
enabled = wiki.App().Cfg().Bind_bool(wiki, gplx.xowa.htmls.core.wkrs.hdrs.Xoh_section_editable_.Cfg__section_editing__enabled, this); // SECTION_EDIT
|
this.app = wiki.Appe();
|
||||||
|
this.wiki = wiki;
|
||||||
|
this.enabled = wiki.App().Cfg().Bind_bool(wiki, gplx.xowa.htmls.core.wkrs.hdrs.Xoh_section_editable_.Cfg__section_editing__enabled, this); // SECTION_EDIT
|
||||||
|
this.tidy_mgr = wiki.Html_mgr().Tidy_mgr();
|
||||||
}
|
}
|
||||||
public byte[] Extract_section(Xoae_app app, Xoa_url url, Xoa_ttl ttl, byte[] src) {
|
public byte[] Slice_section(Xoa_url url, Xoa_ttl ttl, byte[] src) {
|
||||||
// return orig if section_editing not enabled
|
// return orig if section_editing not enabled
|
||||||
if (!enabled) return src;
|
if (!enabled) return src;
|
||||||
|
|
||||||
@ -37,8 +41,8 @@ public class Xop_section_mgr implements Gfo_invk {
|
|||||||
if (section_key == null) return src;
|
if (section_key == null) return src;
|
||||||
|
|
||||||
// parse wikitext into list of headers
|
// parse wikitext into list of headers
|
||||||
Xop_section_list section_list = new Xop_section_list().Parse(src);
|
Xop_section_list section_list = new Xop_section_list().Parse(wiki, tidy_mgr, src);
|
||||||
byte[] rv = section_list.Extract_bry_or_null(section_key);
|
byte[] rv = section_list.Slice_bry_or_null(section_key);
|
||||||
if (rv == null) {
|
if (rv == null) {
|
||||||
app.Gui_mgr().Kit().Ask_ok("", "", String_.Format("Section extraction failed!\nPlease do not edit this page else data will be lost!!\n\nwiki={0}\npage={1}\nsection={2}", url.Wiki_bry(), ttl.Full_db(), section_key));
|
app.Gui_mgr().Kit().Ask_ok("", "", String_.Format("Section extraction failed!\nPlease do not edit this page else data will be lost!!\n\nwiki={0}\npage={1}\nsection={2}", url.Wiki_bry(), ttl.Full_db(), section_key));
|
||||||
throw Err_.new_wo_type("section_key not found", "wiki", url.Wiki_bry(), "page", ttl.Full_db(), "section_key", section_key);
|
throw Err_.new_wo_type("section_key not found", "wiki", url.Wiki_bry(), "page", ttl.Full_db(), "section_key", section_key);
|
||||||
@ -54,23 +58,15 @@ public class Xop_section_mgr implements Gfo_invk {
|
|||||||
if (section_key == null) return edit;
|
if (section_key == null) return edit;
|
||||||
|
|
||||||
// parse orig
|
// parse orig
|
||||||
Xop_section_list section_list = new Xop_section_list().Parse(orig);
|
Xop_section_list section_list = new Xop_section_list().Parse(wiki, tidy_mgr, orig);
|
||||||
byte[] rv = section_list.Merge_bry_or_null(section_key, edit);
|
byte[] rv = section_list.Merge_bry_or_null(section_key, edit);
|
||||||
if (rv == null)
|
if (rv == null)
|
||||||
throw Err_.new_wo_type("could not merge section_key", "page", url.To_str(), "section_key", section_key);
|
throw Err_.new_wo_type("could not merge section_key", "page", url.To_str(), "section_key", section_key);
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
public void Write_html(Bry_bfr bfr, byte[] src, byte[] page_ttl, Xop_hdr_tkn hdr, byte[] name) {
|
public void Write_html(Bry_bfr bfr, byte[] src, byte[] page_ttl, Xop_hdr_tkn hdr, byte[] name) {
|
||||||
// make key by (a) taking 1st and nth sub; (b) skipping ws at both ends
|
name = wiki.Parser_mgr().Uniq_mgr().Convert(name); // need to swap out uniqs for Math; DATE:2016-12-09
|
||||||
Xop_tkn_itm[] subs = hdr.Subs();
|
section_editable_fmt.Bld_many(bfr, page_ttl, name, name);
|
||||||
if (subs.length == 0) return; // GUARD:should not happen, but avoid array-index error
|
|
||||||
int key_bgn = subs[0].Src_bgn();
|
|
||||||
int key_end = subs[hdr.Subs_len() - 1].Src_end();
|
|
||||||
key_bgn = Bry_find_.Find_fwd_while_ws(src, key_bgn, key_end);
|
|
||||||
key_end = Bry_find_.Find_bwd__skip_ws(src, key_end, key_bgn);
|
|
||||||
byte[] key = Bry_.Mid(src, key_bgn, key_end);
|
|
||||||
|
|
||||||
section_editable_fmt.Bld_many(bfr, page_ttl, key, name);
|
|
||||||
}
|
}
|
||||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||||
if (ctx.Match(k, gplx.xowa.htmls.core.wkrs.hdrs.Xoh_section_editable_.Cfg__section_editing__enabled)) enabled = m.ReadBool("v");
|
if (ctx.Match(k, gplx.xowa.htmls.core.wkrs.hdrs.Xoh_section_editable_.Cfg__section_editing__enabled)) enabled = m.ReadBool("v");
|
||||||
@ -80,4 +76,5 @@ public class Xop_section_mgr implements Gfo_invk {
|
|||||||
|
|
||||||
public static final byte[] Bry__meta = Bry_.new_a7("<!--xo_meta|section_edit|");
|
public static final byte[] Bry__meta = Bry_.new_a7("<!--xo_meta|section_edit|");
|
||||||
public static final int Len__meta = Bry__meta.length;
|
public static final int Len__meta = Bry__meta.length;
|
||||||
|
private static final byte[] Qarg__section_key = Bry_.new_u8("section_key");
|
||||||
}
|
}
|
||||||
|
@ -31,6 +31,35 @@ public class Xop_uniq_mgr { // REF.MW:/parser/StripState.php
|
|||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
public byte[] Get(byte[] key) {return (byte[])general_trie.Match_exact(key, 0, key.length);}
|
public byte[] Get(byte[] key) {return (byte[])general_trie.Match_exact(key, 0, key.length);}
|
||||||
|
public byte[] Convert(byte[] src) {
|
||||||
|
if (general_trie.Count() == 0) return src;
|
||||||
|
|
||||||
|
Bry_bfr dirty_bfr = null;
|
||||||
|
int cur = 0;
|
||||||
|
int len = src.length;
|
||||||
|
while (cur < len) {
|
||||||
|
// look for \u007fUNIQ
|
||||||
|
int uniq_bgn = Bry_find_.Find_fwd(src, Bry__uniq__add__bgn, cur);
|
||||||
|
if (uniq_bgn == Bry_find_.Not_found) break;
|
||||||
|
int uniq_end = Bry_find_.Find_fwd(src, Bry__uniq__add__end, uniq_bgn);
|
||||||
|
if (uniq_end == Bry_find_.Not_found) {
|
||||||
|
Gfo_usr_dlg_.Instance.Warn_many("", "", "uniq_mgr:unable to convert uniq; src=~{0}", src);
|
||||||
|
return src;
|
||||||
|
}
|
||||||
|
uniq_end += Bry__uniq__add__end.length;
|
||||||
|
|
||||||
|
// add to bfr
|
||||||
|
if (dirty_bfr == null) dirty_bfr = key_bfr;
|
||||||
|
dirty_bfr.Add_mid(src, 0, uniq_bgn);
|
||||||
|
dirty_bfr.Add((byte[])general_trie.Match_exact(src, uniq_bgn, uniq_end));
|
||||||
|
cur = uniq_end;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dirty_bfr != null) {
|
||||||
|
dirty_bfr.Add_mid(src, cur, len);
|
||||||
|
}
|
||||||
|
return dirty_bfr == null ? src : dirty_bfr.To_bry_and_clear();
|
||||||
|
}
|
||||||
public void Parse(Bry_bfr bfr) {
|
public void Parse(Bry_bfr bfr) {
|
||||||
if (general_trie.Count() == 0) return;
|
if (general_trie.Count() == 0) return;
|
||||||
byte[] rv = Parse(key_bfr, general_trie, bfr.To_bry_and_clear());
|
byte[] rv = Parse(key_bfr, general_trie, bfr.To_bry_and_clear());
|
||||||
|
74
400_xowa/src/gplx/xowa/parsers/uniqs/Xop_uniq_mgr__tst.java
Normal file
74
400_xowa/src/gplx/xowa/parsers/uniqs/Xop_uniq_mgr__tst.java
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
/*
|
||||||
|
XOWA: the XOWA Offline Wiki Application
|
||||||
|
Copyright (C) 2012 gnosygnu@gmail.com
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as
|
||||||
|
published by the Free Software Foundation, either version 3 of the
|
||||||
|
License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package gplx.xowa.parsers.uniqs; import gplx.*; import gplx.xowa.*; import gplx.xowa.parsers.*;
|
||||||
|
import org.junit.*; import gplx.core.tests.*;
|
||||||
|
public class Xop_uniq_mgr__tst {
|
||||||
|
private final Xop_uniq_mgr__fxt fxt = new Xop_uniq_mgr__fxt();
|
||||||
|
@Before public void init() {fxt.Init();}
|
||||||
|
@Test public void Test__random_bry() {
|
||||||
|
fxt.Init_random_int_ary(Int_.Ary(240563374, 22728940, 1451248133));
|
||||||
|
fxt.Test__uniq_bry_new("UNIQE56B4AE15AD0EC68");
|
||||||
|
|
||||||
|
fxt.Init_random_int_ary(Int_.Ary(1363621437, 426295411, 421041101));
|
||||||
|
fxt.Test__uniq_bry_new("UNIQ147363D968C07391");
|
||||||
|
}
|
||||||
|
@Test public void Add_and_get() {
|
||||||
|
String expd_key = "UNIQ-item-0--QINU";
|
||||||
|
fxt.Test__add("a", expd_key);
|
||||||
|
fxt.Test__get(expd_key, "a");
|
||||||
|
}
|
||||||
|
@Test public void Parse__basic() {
|
||||||
|
String expd_key = "UNIQ-item-0--QINU";
|
||||||
|
fxt.Test__add("_b_", expd_key);
|
||||||
|
fxt.Test__parse("a" + expd_key + "c", "a_b_c");
|
||||||
|
}
|
||||||
|
@Test public void Parse__recurse() {
|
||||||
|
String key_0 = "UNIQ-item-0--QINU";
|
||||||
|
String key_1 = "UNIQ-item-1--QINU";
|
||||||
|
String key_2 = "UNIQ-item-2--QINU";
|
||||||
|
fxt.Test__add("0", key_0);
|
||||||
|
fxt.Test__add("1-" + key_0 + "-1", key_1);
|
||||||
|
fxt.Test__add("2-" + key_1 + "-2", key_2);
|
||||||
|
fxt.Test__parse("3-" + key_2 + "-3", "3-2-1-0-1-2-3");
|
||||||
|
}
|
||||||
|
@Test public void Convert() {
|
||||||
|
String key = "UNIQ-item-0--QINU";
|
||||||
|
fxt.Test__add("2", key);
|
||||||
|
fxt.Test__convert("1" + key + "3", "123");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
class Xop_uniq_mgr__fxt {
|
||||||
|
private final Xop_uniq_mgr mgr = new Xop_uniq_mgr();
|
||||||
|
public Xop_uniq_mgr__fxt Init_random_int_ary(int... v) {mgr.Random_int_ary_(v); return this;}
|
||||||
|
public void Init() {mgr.Clear();}
|
||||||
|
public void Test__uniq_bry_new(String expd) {
|
||||||
|
Gftest.Eq__str(expd, String_.new_a7(mgr.Uniq_bry_new()), "unique_bry");
|
||||||
|
}
|
||||||
|
public void Test__add(String raw, String expd) {
|
||||||
|
Gftest.Eq__str(expd, String_.new_a7(mgr.Add(Bry_.new_a7(raw))), "add");
|
||||||
|
}
|
||||||
|
public void Test__get(String key, String expd) {
|
||||||
|
Gftest.Eq__str(expd, String_.new_a7(mgr.Get(Bry_.new_a7(key))), "get");
|
||||||
|
}
|
||||||
|
public void Test__parse(String raw, String expd) {
|
||||||
|
Gftest.Eq__str(expd, String_.new_a7(mgr.Parse(Bry_.new_a7(raw))), "parse");
|
||||||
|
}
|
||||||
|
public void Test__convert(String raw, String expd) {
|
||||||
|
Gftest.Eq__str(expd, String_.new_a7(mgr.Convert(Bry_.new_a7(raw))), "convert");
|
||||||
|
}
|
||||||
|
}
|
@ -1,66 +0,0 @@
|
|||||||
/*
|
|
||||||
XOWA: the XOWA Offline Wiki Application
|
|
||||||
Copyright (C) 2012 gnosygnu@gmail.com
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU Affero General Public License as
|
|
||||||
published by the Free Software Foundation, either version 3 of the
|
|
||||||
License, or (at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU Affero General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Affero General Public License
|
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
package gplx.xowa.parsers.uniqs; import gplx.*; import gplx.xowa.*; import gplx.xowa.parsers.*;
|
|
||||||
import org.junit.*;
|
|
||||||
public class Xop_uniq_mgr_tst {
|
|
||||||
private final Xop_uniq_mgr_fxt fxt = new Xop_uniq_mgr_fxt();
|
|
||||||
@Before public void init() {fxt.Init();}
|
|
||||||
@Test public void Test_random_bry() {
|
|
||||||
fxt.Init_random_int_ary(Int_.Ary(240563374, 22728940, 1451248133));
|
|
||||||
fxt.Test_uniq_bry_new("UNIQE56B4AE15AD0EC68");
|
|
||||||
|
|
||||||
fxt.Init_random_int_ary(Int_.Ary(1363621437, 426295411, 421041101));
|
|
||||||
fxt.Test_uniq_bry_new("UNIQ147363D968C07391");
|
|
||||||
}
|
|
||||||
@Test public void Add_and_get() {
|
|
||||||
String expd_key = "UNIQ-item-0--QINU";
|
|
||||||
fxt.Test_add("a", expd_key);
|
|
||||||
fxt.Test_get(expd_key, "a");
|
|
||||||
}
|
|
||||||
@Test public void Parse__basic() {
|
|
||||||
String expd_key = "UNIQ-item-0--QINU";
|
|
||||||
fxt.Test_add("_b_", expd_key);
|
|
||||||
fxt.Test_parse("a" + expd_key + "c", "a_b_c");
|
|
||||||
}
|
|
||||||
@Test public void Parse__recurse() {
|
|
||||||
String key_0 = "UNIQ-item-0--QINU";
|
|
||||||
String key_1 = "UNIQ-item-1--QINU";
|
|
||||||
String key_2 = "UNIQ-item-2--QINU";
|
|
||||||
fxt.Test_add("0", key_0);
|
|
||||||
fxt.Test_add("1-" + key_0 + "-1", key_1);
|
|
||||||
fxt.Test_add("2-" + key_1 + "-2", key_2);
|
|
||||||
fxt.Test_parse("3-" + key_2 + "-3", "3-2-1-0-1-2-3");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
class Xop_uniq_mgr_fxt {
|
|
||||||
private final Xop_uniq_mgr mgr = new Xop_uniq_mgr();
|
|
||||||
public Xop_uniq_mgr_fxt Init_random_int_ary(int... v) {mgr.Random_int_ary_(v); return this;}
|
|
||||||
public void Init() {mgr.Clear();}
|
|
||||||
public void Test_uniq_bry_new(String expd) {
|
|
||||||
Tfds.Eq_str(expd, String_.new_a7(mgr.Uniq_bry_new()), "unique_bry");
|
|
||||||
}
|
|
||||||
public void Test_add(String raw, String expd) {
|
|
||||||
Tfds.Eq_str(expd, String_.new_a7(mgr.Add(Bry_.new_a7(raw))), "add");
|
|
||||||
}
|
|
||||||
public void Test_get(String key, String expd) {
|
|
||||||
Tfds.Eq_str(expd, String_.new_a7(mgr.Get(Bry_.new_a7(key))), "get");
|
|
||||||
}
|
|
||||||
public void Test_parse(String raw, String expd) {
|
|
||||||
Tfds.Eq_str(expd, String_.new_a7(mgr.Parse(Bry_.new_a7(raw))), "get");
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user