mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
v2.11.2.1
This commit is contained in:
@@ -83,7 +83,7 @@ public class Xop_hdr_wkr__basic_tst {
|
||||
@Test public void Err_end_hdr_is_1() {fxt.Init_log_(Xop_hdr_log.Mismatched, Xop_hdr_log.Len_1).Test_parse_page_wiki_str("==a=" , "<h1>=a</h1>\n").tst_Log_check();}
|
||||
@Test public void Html_hdr_many() {
|
||||
fxt.Wtr_cfg().Toc__show_(Bool_.Y);
|
||||
fxt.Test_parse_page_wiki_str(String_.Concat_lines_nl_skip_last
|
||||
fxt.Test_parse_page_wiki_str__esc(String_.Concat_lines_nl_skip_last
|
||||
( "==a=="
|
||||
, "==a=="
|
||||
, "==a=="
|
||||
|
||||
@@ -25,6 +25,12 @@ public class Xop_lnki_align_h {
|
||||
, Bry_.new_a7("center")
|
||||
, Bry_.new_a7("right")
|
||||
};
|
||||
public static final Hash_adp_bry Hash = Hash_adp_bry.ci_a7()
|
||||
.Add_str_byte("tnone" , None)
|
||||
.Add_str_byte("tleft" , Left)
|
||||
.Add_str_byte("tcenter" , Center)
|
||||
.Add_str_byte("tright" , Right)
|
||||
;
|
||||
}
|
||||
class Xop_lnki_align_v {
|
||||
public static final byte None = 0, Top = 1, Middle = 2, Bottom = 4, Super = 8, Sub = 16, TextTop = 32, TextBottom = 64, Baseline = 127;
|
||||
|
||||
@@ -52,13 +52,13 @@ public class Xop_lnki_tkn extends Xop_tkn_itm_base {
|
||||
public boolean Xtn_sites_link() {return xtn_sites_link;} public void Xtn_sites_link_(boolean v) {xtn_sites_link = v;} private boolean xtn_sites_link;
|
||||
public Xoh_file_img_wkr Lnki_file_wkr() {return lnki_file_wkr;} public void Lnki_file_wkr_(Xoh_file_img_wkr v) {lnki_file_wkr = v;} private Xoh_file_img_wkr lnki_file_wkr;
|
||||
public byte[] Ttl_ary() {
|
||||
return ttl.ForceLiteralLink() || ns_id != Xow_ns_.Id_main // if [[:]] or non-main (Category, Template)
|
||||
return ttl.ForceLiteralLink() || ns_id != Xow_ns_.Tid__main // if [[:]] or non-main (Category, Template)
|
||||
? ttl.Full_txt() // use full_txt (no initial colon; capitalize first)
|
||||
: ttl.Raw(); // use raw (preserve case, white-spaces)
|
||||
}
|
||||
public boolean Caption_exists() {
|
||||
return !((caption_tkn == Xop_tkn_null.Null_tkn) // trg only; no caption: EX: [[a]] vs. [[a|b]] which has a trg of a and a caption of b
|
||||
|| (ns_id == Xow_ns_.Id_category // a Category only has a target; any caption is ignored; EX: [[Category:a|b], b is ignored
|
||||
|| (ns_id == Xow_ns_.Tid__category // a Category only has a target; any caption is ignored; EX: [[Category:a|b], b is ignored
|
||||
&& !ttl.ForceLiteralLink()));
|
||||
}
|
||||
public Xop_lnki_tkn Lnki_type_(byte v) {
|
||||
|
||||
@@ -53,17 +53,17 @@ public class Xop_lnki_wkr implements Xop_ctx_wkr, Xop_arg_wkr {
|
||||
root.Subs_del_after(lnki.Tkn_sub_idx() + 1); // all tkns should now be converted to args in owner; delete everything in root
|
||||
boolean lnki_is_file = false;
|
||||
switch (lnki.Ns_id()) {
|
||||
case Xow_ns_.Id_file:
|
||||
case Xow_ns_.Tid__file:
|
||||
if ( Xop_lnki_type.Id_is_thumbable(lnki.Lnki_type()) // thumbs produce <div> cancels pre
|
||||
|| lnki.Align_h() != Xop_lnki_align_h.Null // halign (left, right, none) also produces <div>; DATE:2014-02-17
|
||||
)
|
||||
ctx.Para().Process_block_lnki_div();
|
||||
lnki_is_file = true;
|
||||
break;
|
||||
case Xow_ns_.Id_media:
|
||||
case Xow_ns_.Tid__media:
|
||||
lnki_is_file = true;
|
||||
break;
|
||||
case Xow_ns_.Id_category:
|
||||
case Xow_ns_.Tid__category:
|
||||
if (!lnki.Ttl().ForceLiteralLink()) // NOTE: do not remove ws if literal; EX:[[Category:A]]\n[[Category:B]] should stay the same; DATE:2013-07-10
|
||||
ctx.Para().Process_lnki_category(ctx, root, src,cur_pos, src_len); // removes excessive ws between categories; EX: [[Category:A]]\n\s[[Category:B]] -> [[Category:A]][[Category:B]] (note that both categories will not be rendered directly in html, but go to the bottom of the page)
|
||||
break;
|
||||
@@ -120,7 +120,7 @@ public class Xop_lnki_wkr implements Xop_ctx_wkr, Xop_arg_wkr {
|
||||
case Xop_lnki_arg_parser.Tid_caption:
|
||||
Xop_tkn_itm cur_caption_tkn = lnki.Caption_tkn();
|
||||
if ( cur_caption_tkn == Xop_tkn_null.Null_tkn // lnki doesn't have caption; add arg as caption
|
||||
|| lnki.Ttl().Ns().Id_file_or_media()) { // or lnki is File; always take last
|
||||
|| lnki.Ttl().Ns().Id_is_file_or_media()) { // or lnki is File; always take last
|
||||
lnki.Caption_tkn_(arg);
|
||||
if (arg.Eq_tkn() != Xop_tkn_null.Null_tkn) { // equal tkn exists; add val tkns to key and then swap key with val
|
||||
Arg_itm_tkn key_tkn = arg.Key_tkn(), val_tkn = arg.Val_tkn();
|
||||
|
||||
@@ -75,7 +75,7 @@ public class Xop_lnki_wkr_ {
|
||||
if (!wiki.Cfg_parser().Lnki_cfg().Xwiki_repo_mgr().Has(xwiki_bry)) return ttl; // alias not in xwikis; EX: [[en_bad:File:A.png]]
|
||||
Xoa_ttl ttl_in_xwiki = Xoa_ttl.parse(wiki, ttl_in_xwiki_bry);
|
||||
if (ttl_in_xwiki == null) return ttl; // occurs if ttl is bad in xwiki; EX: [[en:<bad>]]
|
||||
return ttl_in_xwiki.Ns().Id_file() ? ttl_in_xwiki : ttl;
|
||||
return ttl_in_xwiki.Ns().Id_is_file() ? ttl_in_xwiki : ttl;
|
||||
}
|
||||
public static int Chk_for_tail(Xol_lang_itm lang, byte[] src, int cur_pos, int src_len, Xop_lnki_tkn lnki) {
|
||||
int bgn_pos = cur_pos;
|
||||
@@ -86,7 +86,7 @@ public class Xop_lnki_wkr_ {
|
||||
if (lnki_trail_bry == null) break; // no longer a lnki_trail char; stop
|
||||
cur_pos += lnki_trail_bry.length; // lnki_trail char; add
|
||||
}
|
||||
if (bgn_pos != cur_pos && lnki.Ns_id() == Xow_ns_.Id_main) { // only mark trail if Main ns (skip trail for Image)
|
||||
if (bgn_pos != cur_pos && lnki.Ns_id() == Xow_ns_.Tid__main) { // only mark trail if Main ns (skip trail for Image)
|
||||
lnki.Tail_bgn_(bgn_pos).Tail_end_(cur_pos);
|
||||
return cur_pos;
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ public class Xop_lnki_wkr__basic_tst {
|
||||
@Test public void Tail_upper() {fxt.Test_parse_page_wiki("[[a|b]]A" , fxt.tkn_lnki_(0, 7).Tail_bgn_(-1), fxt.tkn_txt_(7, 8));} // make sure trie is case-insensitive
|
||||
@Test public void Tail_image() {fxt.Test_parse_page_wiki("[[Image:a|b]]c", fxt.tkn_lnki_(0, 13).Tail_bgn_(-1).Tail_end_(-1), fxt.tkn_txt_(13, 14));} // NOTE: this occurs on some pages;
|
||||
@Test public void Image() {
|
||||
fxt.Test_parse_page_wiki("[[Image:a]]" , fxt.tkn_lnki_().Ns_id_(Xow_ns_.Id_file).Trg_tkn_(fxt.tkn_arg_val_(fxt.tkn_txt_(2, 7), fxt.tkn_colon_(7), fxt.tkn_txt_(8, 9))));
|
||||
fxt.Test_parse_page_wiki("[[Image:a]]" , fxt.tkn_lnki_().Ns_id_(Xow_ns_.Tid__file).Trg_tkn_(fxt.tkn_arg_val_(fxt.tkn_txt_(2, 7), fxt.tkn_colon_(7), fxt.tkn_txt_(8, 9))));
|
||||
fxt.Test_parse_page_wiki("[[Image:a|border]]" , fxt.tkn_lnki_().Border_(Bool_.Y_byte));
|
||||
fxt.Test_parse_page_wiki("[[Image:a|thumb]]" , fxt.tkn_lnki_().ImgType_(Xop_lnki_type.Id_thumb));
|
||||
fxt.Test_parse_page_wiki("[[Image:a|left]]" , fxt.tkn_lnki_().HAlign_(Xop_lnki_align_h.Left));
|
||||
@@ -61,7 +61,7 @@ public class Xop_lnki_wkr__basic_tst {
|
||||
fxt.Test_parse_page_wiki("[[Image:a|alt=b]]" , fxt.tkn_lnki_().Alt_tkn_(fxt.tkn_arg_nde_().Key_tkn_(fxt.tkn_arg_itm_(fxt.tkn_txt_(10, 13))).Val_tkn_(fxt.tkn_arg_itm_(fxt.tkn_txt_(14, 15)))));
|
||||
fxt.Test_parse_page_wiki("[[Image:a|link=a]]" , fxt.tkn_lnki_().Link_tkn_(fxt.tkn_arg_nde_().Key_tkn_(fxt.tkn_arg_itm_(fxt.tkn_txt_(10, 14))).Val_tkn_(fxt.tkn_arg_itm_(fxt.tkn_txt_(15, 16)))));
|
||||
fxt.Test_parse_page_wiki("[[Image:a|thumb|alt=b|c d]]"
|
||||
, fxt.tkn_lnki_().Ns_id_(Xow_ns_.Id_file)
|
||||
, fxt.tkn_lnki_().Ns_id_(Xow_ns_.Tid__file)
|
||||
.Trg_tkn_(fxt.tkn_arg_nde_().Val_tkn_(fxt.tkn_arg_itm_(fxt.tkn_txt_(2, 7), fxt.tkn_colon_(7), fxt.tkn_txt_(8, 9))))
|
||||
.Alt_tkn_(fxt.tkn_arg_nde_().Key_tkn_(fxt.tkn_arg_itm_(fxt.tkn_txt_(16, 19))).Val_tkn_(fxt.tkn_arg_itm_(fxt.tkn_txt_(20, 21))))
|
||||
.Caption_tkn_(fxt.tkn_arg_nde_(22, 25).Val_tkn_(fxt.tkn_arg_itm_(fxt.tkn_txt_(22, 23), fxt.tkn_space_(23, 24), fxt.tkn_txt_(24, 25)))))
|
||||
@@ -76,17 +76,17 @@ public class Xop_lnki_wkr__basic_tst {
|
||||
}
|
||||
@Test public void Recurse() {
|
||||
fxt.Test_parse_page_wiki("[[Image:a|b-[[c]]-d]]"
|
||||
, fxt.tkn_lnki_().Ns_id_(Xow_ns_.Id_file)
|
||||
, fxt.tkn_lnki_().Ns_id_(Xow_ns_.Tid__file)
|
||||
.Trg_tkn_(fxt.tkn_arg_nde_().Val_tkn_(fxt.tkn_arg_itm_(fxt.tkn_txt_(2, 7), fxt.tkn_colon_(7), fxt.tkn_txt_(8, 9))))
|
||||
.Caption_tkn_(fxt.tkn_arg_nde_(10, 19).Val_tkn_(fxt.tkn_arg_itm_(fxt.tkn_txt_(10, 12), fxt.tkn_lnki_(12, 17), fxt.tkn_txt_(17, 19))))
|
||||
);
|
||||
}
|
||||
@Test public void Outliers() {
|
||||
fxt.Test_parse_page_wiki("[[Image:a=b.svg|thumb|10px]]", fxt.tkn_lnki_().Ns_id_(Xow_ns_.Id_file).Trg_tkn_(fxt.tkn_arg_nde_().Val_tkn_(fxt.tkn_arg_itm_(fxt.tkn_txt_(2, 7), fxt.tkn_colon_(7), fxt.tkn_txt_(8, 9), fxt.tkn_eq_(9), fxt.tkn_txt_(10, 15)))));
|
||||
fxt.Test_parse_page_wiki("[[Category:a|b]]", fxt.tkn_lnki_().Ns_id_(Xow_ns_.Id_category));
|
||||
fxt.Test_parse_page_wiki("[[Image:a=b.svg|thumb|10px]]", fxt.tkn_lnki_().Ns_id_(Xow_ns_.Tid__file).Trg_tkn_(fxt.tkn_arg_nde_().Val_tkn_(fxt.tkn_arg_itm_(fxt.tkn_txt_(2, 7), fxt.tkn_colon_(7), fxt.tkn_txt_(8, 9), fxt.tkn_eq_(9), fxt.tkn_txt_(10, 15)))));
|
||||
fxt.Test_parse_page_wiki("[[Category:a|b]]", fxt.tkn_lnki_().Ns_id_(Xow_ns_.Tid__category));
|
||||
}
|
||||
@Test public void Exc_caption_has_eq() {
|
||||
fxt.Test_parse_page_wiki("[[Image:a.svg|thumb|a=b]]", fxt.tkn_lnki_().Ns_id_(Xow_ns_.Id_file)
|
||||
fxt.Test_parse_page_wiki("[[Image:a.svg|thumb|a=b]]", fxt.tkn_lnki_().Ns_id_(Xow_ns_.Tid__file)
|
||||
.Caption_tkn_(fxt.tkn_arg_nde_(20, 23).Val_tkn_(fxt.tkn_arg_itm_(fxt.tkn_txt_(20, 21), fxt.tkn_eq_(21), fxt.tkn_txt_(22, 23)))));
|
||||
}
|
||||
@Test public void Border_with_space_should_not_be_caption() {// happens with {{flag}}; EX: [[Image:Flag of Argentina.svg|22x20px|border |alt=|link=]]
|
||||
|
||||
@@ -20,9 +20,9 @@ import org.junit.*; import gplx.xowa.wikis.nss.*;
|
||||
public class Xop_lnki_wkr__subpage_tst {
|
||||
@Before public void init() {fxt.Reset(); fxt.Init_para_n_();} private Xop_fxt fxt = new Xop_fxt();
|
||||
@Test public void Disabled() { // PURPOSE: slash being interpreted as subpage; PAGE:en.w:[[/dev/null]]
|
||||
fxt.Wiki().Ns_mgr().Ids_get_or_null(Xow_ns_.Id_main).Subpages_enabled_(false);
|
||||
fxt.Wiki().Ns_mgr().Ids_get_or_null(Xow_ns_.Tid__main).Subpages_enabled_(false);
|
||||
fxt.Test_parse_page_all_str("[[/dev/null]]", "<a href=\"/wiki//dev/null\">/dev/null</a>");
|
||||
fxt.Wiki().Ns_mgr().Ids_get_or_null(Xow_ns_.Id_main).Subpages_enabled_(true);
|
||||
fxt.Wiki().Ns_mgr().Ids_get_or_null(Xow_ns_.Tid__main).Subpages_enabled_(true);
|
||||
}
|
||||
@Test public void False_match() {// PAGE:en.w:en.wiktionary.org/wiki/Wiktionary:Requests for cleanup/archive/2006
|
||||
fxt.Test_parse_page_wiki_str
|
||||
|
||||
@@ -37,9 +37,9 @@ public class Xopg_redlink_lnki_list {
|
||||
Xoa_ttl ttl = lnki.Ttl(); if (ttl == null) return; // occurs for invalid links
|
||||
Xow_ns ns = ttl.Ns();
|
||||
lnki.Html_uid_(++lnki_idx); // NOTE: set html_id in order html to print out "id='xowa_lnki_1'; want to print out id for consistency's sake, even if these links won't be check for redlinks; DATE:2015-05-07
|
||||
if ( ns.Id_file_or_media() // ignore files which will usually not be in local wiki (most are in commons), and whose html is built up separately
|
||||
|| (ns.Id_ctg() && !ttl.ForceLiteralLink()) // ignore ctgs which have their own html builder, unless it is literal; EX: [[:Category:A]]; DATE:2014-02-24
|
||||
|| ns.Id_special() // ignore special, especially Search; EX: Special:Search/Earth
|
||||
if ( ns.Id_is_file_or_media() // ignore files which will usually not be in local wiki (most are in commons), and whose html is built up separately
|
||||
|| (ns.Id_is_ctg() && !ttl.ForceLiteralLink()) // ignore ctgs which have their own html builder, unless it is literal; EX: [[:Category:A]]; DATE:2014-02-24
|
||||
|| ns.Id_is_special() // ignore special, especially Search; EX: Special:Search/Earth
|
||||
|| ttl.Anch_bgn() == Xoa_ttl.Anch_bgn_anchor_only // anchor only link; EX: [[#anchor]]
|
||||
|| ttl.Wik_itm() != null // xwiki lnki; EX: simplewiki links in homewiki; [[simplewiki:Earth]]
|
||||
)
|
||||
|
||||
@@ -32,7 +32,7 @@ public class Xop_under_lxr_tst {
|
||||
}
|
||||
@Test public void Notoc_basic() {
|
||||
fxt.Wtr_cfg().Toc__show_(Bool_.Y); // NOTE: must enable in order for TOC to show (and to make sure NOTOC suppresses)
|
||||
fxt.Test_parse_page_all_str(String_.Concat_lines_nl
|
||||
fxt.Test_parse_page_all_str__esc(String_.Concat_lines_nl
|
||||
( "__NOTOC__"
|
||||
, "==a=="
|
||||
, "==b=="
|
||||
|
||||
@@ -170,7 +170,7 @@ public class Arg_bldr {
|
||||
trim = false;
|
||||
switch (wkr_typ) {
|
||||
case Xop_arg_wkr_.Typ_prm : trim = arg_idx == 0; break;
|
||||
case Xop_arg_wkr_.Typ_tmpl: trim = key_exists || arg_idx == 0; break;
|
||||
case Xop_arg_wkr_.Typ_tmpl: trim = true; break; // NOTE: was "key_exists || arg_idx == 0;"; PAGE:s.w:Gothic_architecture; DATE:2015-11-07
|
||||
case Xop_arg_wkr_.Typ_lnki: trim = !cur_itm_is_key; break;
|
||||
}
|
||||
if (trim) {
|
||||
|
||||
@@ -66,7 +66,7 @@ public class Xot_defn_tmpl implements Xot_defn {
|
||||
Xoae_page page = ctx.Cur_page();
|
||||
if (!page.Tmpl_stack_add(full_name)) {
|
||||
bfr.Add_str_a7("<!-- template loop detected:" + gplx.langs.htmls.Html_utl.Escape_html_as_str(String_.new_u8(name)) + " -->");
|
||||
Xoa_app_.Usr_dlg().Warn_many("", "", "template loop detected: url=~{0} name=~{1}", ctx.Cur_page().Url().To_str(), name);
|
||||
Xoa_app_.Usr_dlg().Log_many("", "", "template loop detected: url=~{0} name=~{1}", ctx.Cur_page().Url().To_str(), name);
|
||||
return false;
|
||||
}
|
||||
boolean rv = true;
|
||||
|
||||
@@ -337,7 +337,7 @@ public class Xot_invk_tkn extends Xop_tkn_itm_base implements Xot_invk {
|
||||
private boolean Transclude(Xop_ctx ctx, Xowe_wiki wiki, Bry_bfr bfr, byte[] name_ary, Xot_invk caller, byte[] src) {
|
||||
Xoa_ttl page_ttl = Xoa_ttl.parse(wiki, name_ary); if (page_ttl == null) return false; // ttl not valid; EX: {{:[[abc]]}}
|
||||
byte[] transclude_src = null;
|
||||
if (page_ttl.Ns().Id_tmpl()) { // ttl is template; check tmpl_regy first before going to data_mgr
|
||||
if (page_ttl.Ns().Id_is_tmpl()) { // ttl is template; check tmpl_regy first before going to data_mgr
|
||||
Xot_defn_tmpl tmpl = (Xot_defn_tmpl)wiki.Cache_mgr().Defn_cache().Get_by_key(page_ttl.Page_db());
|
||||
if (tmpl != null) transclude_src = tmpl.Data_raw();
|
||||
}
|
||||
@@ -385,21 +385,21 @@ public class Xot_invk_tkn extends Xop_tkn_itm_base implements Xot_invk {
|
||||
return rv;
|
||||
}
|
||||
public static void Print_not_found(Bry_bfr bfr, Xow_ns_mgr ns_mgr, byte[] name_ary) { // print missing as [[:Template:Missing]]; REF:MW: Parser.php|braceSubstitution|$text = "[[:$titleText]]"; EX:en.d:Kazakhstan; DATE:2014-03-25
|
||||
byte[] template_ns_name = ns_mgr.Ns_template().Name_bry();
|
||||
byte[] template_ns_name = ns_mgr.Ns_template().Name_db();
|
||||
bfr.Add(Xop_tkn_.Lnki_bgn).Add_byte(Byte_ascii.Colon).Add(template_ns_name).Add_byte(Byte_ascii.Colon).Add(name_ary).Add(Xop_tkn_.Lnki_end);
|
||||
}
|
||||
private boolean SubEval(Xop_ctx ctx, Xowe_wiki wiki, Bry_bfr bfr, byte[] name_ary, Xot_invk caller, byte[] src_for_tkn) {
|
||||
Xoa_ttl page_ttl = Xoa_ttl.parse(wiki, name_ary); if (page_ttl == null) return false; // ttl not valid; EX: {{:[[abc]]}}
|
||||
Xot_defn_tmpl transclude_tmpl = null;
|
||||
switch (page_ttl.Ns().Id()) {
|
||||
case Xow_ns_.Id_template: // ttl is template not in cache, or some other ns; do load
|
||||
case Xow_ns_.Tid__template: // ttl is template not in cache, or some other ns; do load
|
||||
Xot_defn_tmpl tmpl = (Xot_defn_tmpl)wiki.Cache_mgr().Defn_cache().Get_by_key(page_ttl.Page_db());
|
||||
if (tmpl != null) {
|
||||
if (tmpl.Root() == null) tmpl.Parse_tmpl(ctx);
|
||||
transclude_tmpl = tmpl;
|
||||
}
|
||||
break;
|
||||
case Xow_ns_.Id_special:
|
||||
case Xow_ns_.Tid__special:
|
||||
bfr.Add(Xop_tkn_.Lnki_bgn).Add_byte(Byte_ascii.Colon).Add(name_ary).Add(Xop_tkn_.Lnki_end);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ public class Xot_invk_wkr implements Xop_ctx_wkr, Xop_arg_wkr {
|
||||
int subst_bgn = finder.Subst_bgn(), subst_end = finder.Subst_end();
|
||||
invk.Tmpl_subst_props_(finder_typeId, subst_bgn, subst_end);
|
||||
if ((ctx.Parse_tid() == Xop_parser_.Parse_tid_tmpl && finder_typeId == Xot_defn_.Tid_subst) // NOTE: if subst, but in tmpl stage, do not actually subst; PAGE:en.w:Unreferenced; DATE:2013-01-31
|
||||
|| ctx.Cur_page().Ttl().Ns().Id_tmpl()) { // also, if on tmpl page, never evaluate (questionable, but seems to be needed)
|
||||
|| ctx.Cur_page().Ttl().Ns().Id_is_tmpl()) { // also, if on tmpl page, never evaluate (questionable, but seems to be needed)
|
||||
}
|
||||
else {
|
||||
key_tkn.Dat_rng_ary_(src, subst_end, txt_end); // redo txt_rng to ignore subst
|
||||
|
||||
@@ -209,7 +209,7 @@ public class Xot_invk_wkr_basic_tst {
|
||||
}
|
||||
@Test public void Missing_foreign() {
|
||||
Xow_ns ns = fxt.Wiki().Ns_mgr().Ns_template();
|
||||
byte[] old_ns = ns.Name_bry();
|
||||
byte[] old_ns = ns.Name_db();
|
||||
ns.Name_bry_(Bry_.new_a7("Template_foreign"));
|
||||
fxt.Test_parse_tmpl_str("{{Missing}}", "[[:Template_foreign:Missing]]");
|
||||
ns.Name_bry_(old_ns);
|
||||
@@ -233,7 +233,7 @@ public class Xot_invk_wkr_basic_tst {
|
||||
fxt.Init_defn_clear();
|
||||
fxt.Init_defn_add("test_1", "{{test_2|{{{1}}}}}");
|
||||
fxt.Init_defn_add("test_2", "{{{1}}}");
|
||||
fxt.Test_parse_tmpl_str("{{test_1| a }}", " a ");
|
||||
fxt.Test_parse_tmpl_str("{{test_1| a }}", " a"); // tmpl.trim_end: always trim end; DATE:2015-11-07
|
||||
fxt.Init_defn_clear();
|
||||
}
|
||||
@Test public void Ws_trimmed_key_1() { // PURPOSE: trim prm when passed as key;
|
||||
@@ -254,7 +254,7 @@ public class Xot_invk_wkr_basic_tst {
|
||||
fxt.Init_defn_clear();
|
||||
fxt.Init_defn_add("test_1", "{{test_2|1={{{1}}}{{{2}}}}}");
|
||||
fxt.Init_defn_add("test_2", "{{{1}}}");
|
||||
fxt.Test_parse_tmpl_str("{{test_1| a | b }}", "a b");
|
||||
fxt.Test_parse_tmpl_str("{{test_1| a | b }}", "a b"); // tmpl.trim_end: always trim end; DATE:2015-11-07
|
||||
fxt.Init_defn_clear();
|
||||
}
|
||||
@Test public void Ws_eval_prm() { // PURPOSE: skip ws in prm_idx; EX:it.w:Portale:Giochi_da_tavolo; it.w:Template:Alternate; DATE:2014-02-09
|
||||
@@ -316,7 +316,7 @@ public class Xot_invk_wkr_basic_tst {
|
||||
fxt.Init_defn_clear();
|
||||
}
|
||||
@Test public void Tmpl_aliases() { // PURPOSE: handled aliases for Template ns
|
||||
fxt.Wiki().Ns_mgr().Aliases_add(Xow_ns_.Id_template, "TemplateAlias");
|
||||
fxt.Wiki().Ns_mgr().Aliases_add(Xow_ns_.Tid__template, "TemplateAlias");
|
||||
fxt.Wiki().Ns_mgr().Init();
|
||||
fxt.Init_defn_clear();
|
||||
fxt.Init_defn_add("tmpl_key", "tmpl_val");
|
||||
@@ -324,7 +324,7 @@ public class Xot_invk_wkr_basic_tst {
|
||||
fxt.Init_defn_clear();
|
||||
}
|
||||
@Test public void Tmpl_aliases_2() { // PURPOSE: handled aliases for other ns; DATE:2013-02-08
|
||||
fxt.Wiki().Ns_mgr().Aliases_add(Xow_ns_.Id_project, "WP");
|
||||
fxt.Wiki().Ns_mgr().Aliases_add(Xow_ns_.Tid__project, "WP");
|
||||
fxt.Wiki().Ns_mgr().Init();
|
||||
fxt.Init_defn_clear();
|
||||
fxt.Init_page_create("Project:tmpl_key", "tmpl_val");
|
||||
|
||||
@@ -27,12 +27,15 @@ public class Xop_redirect_mgr {
|
||||
public Xoa_ttl Extract_redirect_loop(byte[] src) {
|
||||
Xoa_ttl rv = null;
|
||||
for (int i = 0; i < Redirect_max_allowed; i++) {
|
||||
rv = Extract_redirect(src, src.length);
|
||||
rv = Extract_redirect(src);
|
||||
if (rv != null) return rv;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public Xoa_ttl Extract_redirect(byte[] src) {return Extract_redirect(src, src.length);}
|
||||
public Xoa_ttl Extract_redirect(byte[] src) {
|
||||
if (src == null) return Redirect_null_ttl;
|
||||
return Extract_redirect(src, src.length);
|
||||
}
|
||||
public Xoa_ttl Extract_redirect(byte[] src, int src_len) { // NOTE: this proc is called by every page. be careful of changes; DATE:2014-07-05
|
||||
if (src_len == 0) return Redirect_null_ttl;
|
||||
int bgn = Bry_find_.Find_fwd_while_not_ws(src, 0, src_len);
|
||||
@@ -45,8 +48,8 @@ public class Xop_redirect_mgr {
|
||||
int ttl_bgn = Xop_redirect_mgr_.Get_ttl_bgn_or_neg1(src, kwd_end, src_len);
|
||||
if (ttl_bgn == Bry_find_.Not_found) return Redirect_null_ttl;
|
||||
ttl_bgn += Xop_tkn_.Lnki_bgn.length;
|
||||
int ttl_end = Bry_find_.Find_fwd(src, Xop_tkn_.Lnki_end, ttl_bgn);
|
||||
if (ttl_end == Bry_find_.Not_found) return Redirect_null_ttl;
|
||||
int ttl_end = Bry_find_.Find_fwd(src, Xop_tkn_.Lnki_end, ttl_bgn); if (ttl_end == Bry_find_.Not_found) return Redirect_null_ttl;
|
||||
int pipe_pos = Bry_find_.Find_fwd(src, Byte_ascii.Pipe, ttl_bgn); if (pipe_pos != Bry_find_.Not_found) ttl_end = pipe_pos; // if pipe exists, end ttl at pipe; PAGE:da.w:Middelaldercentret; DATE:2015-11-06
|
||||
byte[] redirect_bry = Bry_.Mid(src, ttl_bgn, ttl_end);
|
||||
redirect_bry = url_decoder.Decode(redirect_bry); // NOTE: url-decode links; PAGE: en.w:Watcher_(Buffy_the_Vampire_Slayer); DATE:2014-08-18
|
||||
return Xoa_ttl.parse(wiki, redirect_bry);
|
||||
@@ -73,7 +76,7 @@ public class Xop_redirect_mgr {
|
||||
if (i != 0) redirect_bfr.Add(Bry_redirect_dlm);
|
||||
byte[] redirect_ttl = (byte[])list.Get_at(i);
|
||||
redirect_bfr.Add(Xoh_consts.A_bgn) // '<a href="'
|
||||
.Add(Xoh_href_.Bry__wiki) // '/wiki/'
|
||||
.Add(Xoh_href_.Bry__wiki) // '/wiki/'
|
||||
.Add(redirect_ttl) // 'PageA'
|
||||
.Add(Bry_redirect_arg) // ?redirect=no
|
||||
.Add(Xoh_consts.A_bgn_lnki_0) // '" title="'
|
||||
|
||||
@@ -40,6 +40,9 @@ public class Xop_redirect_mgr_tst {
|
||||
@Test public void Frame_ttl() { // PURPOSE: redirect should set invk frame title to redirect_trg, not original; PAGE:en.w:Statutory_city DATE:2014-08-22
|
||||
fxt.Test_frame_ttl("Template:A", "#REDIRECT [[Template:B]]", "Template:B", "Template:B");
|
||||
}
|
||||
@Test public void State_collapsed() { // PURPOSE: state=collapsed broke redirects; PAGE:da.w:Middelaldercentret; DATE:2015-11-06
|
||||
fxt.Test_redirect("#REDIRECT [[Template:A|state=collapsed]]", "Template:A");
|
||||
}
|
||||
}
|
||||
class Xop_redirect_mgr_fxt {
|
||||
private Xop_fxt fxt = new Xop_fxt();
|
||||
@@ -62,7 +65,7 @@ class Xop_redirect_mgr_fxt {
|
||||
Xop_redirect_mgr redirect_mgr = fxt.Ctx().Wiki().Redirect_mgr();
|
||||
redirect_mgr.Clear();
|
||||
byte[] raw_bry = Bry_.new_u8(raw_str);
|
||||
Xoa_ttl actl_ttl = redirect_mgr.Extract_redirect(raw_bry, raw_bry.length);
|
||||
Xoa_ttl actl_ttl = redirect_mgr.Extract_redirect(raw_bry);
|
||||
byte[] actl_bry = actl_ttl == null ? Bry_.Empty : actl_ttl.Full_txt();
|
||||
Tfds.Eq(expd_str, String_.new_u8(actl_bry));
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ public class Xop_xnde_wkr__basic_tst {
|
||||
}
|
||||
@Test public void Lnki() {
|
||||
fxt.Test_parse_page_wiki("[[Image:a|b<br/>d]]"
|
||||
, fxt.tkn_lnki_().Ns_id_(Xow_ns_.Id_file).Trg_tkn_(fxt.tkn_arg_nde_().Val_tkn_(fxt.tkn_arg_itm_(fxt.tkn_txt_(2, 7), fxt.tkn_colon_(7), fxt.tkn_txt_(8, 9))))
|
||||
, fxt.tkn_lnki_().Ns_id_(Xow_ns_.Tid__file).Trg_tkn_(fxt.tkn_arg_nde_().Val_tkn_(fxt.tkn_arg_itm_(fxt.tkn_txt_(2, 7), fxt.tkn_colon_(7), fxt.tkn_txt_(8, 9))))
|
||||
.Caption_tkn_(fxt.tkn_arg_nde_(10, 17).Val_tkn_(fxt.tkn_arg_itm_(fxt.tkn_txt_(10, 11), fxt.tkn_xnde_(11, 16), fxt.tkn_txt_(16, 17))))
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user