mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
'v3.6.3.4'
This commit is contained in:
@@ -176,13 +176,29 @@ public class Xot_invk_tkn extends Xop_tkn_itm_base implements Xot_invk {
|
||||
if (name_ary_len != 0 ) { // name_ary_len != 0 for direct template inclusions; PAGE:en.w:Human evolution and {{:Human evolution/Species chart}}; && ctx.Tmpl_whitelist().Has(name_ary)
|
||||
Xoa_ttl ttl = Xoa_ttl.parse(wiki, Bry_.Add(wiki.Ns_mgr().Ns_template().Name_db_w_colon(), name_ary));
|
||||
if (ttl == null) { // ttl is not valid; just output orig; REF.MW:Parser.php|braceSubstitution|if ( !$found ) $text = $frame->virtualBracketedImplode( '{{', '|', '}}', $titleWithSpaces, $args );
|
||||
byte[] missing_ttl
|
||||
= subst_found || template_prefix_found // if "subst:" or "Template:" found, use orig name; DATE:2014-03-31
|
||||
? name_ary_orig
|
||||
: name_ary
|
||||
;
|
||||
bfr.Add(Xop_curly_bgn_lxr.Hook).Add(missing_ttl).Add(Xop_curly_end_lxr.Hook);
|
||||
return false;
|
||||
if (subst_found || template_prefix_found) { // if "subst:" or "Template:" found, use orig name; DATE:2014-03-31
|
||||
bfr.Add(Xop_curly_bgn_lxr.Hook).Add(name_ary_orig).Add(Xop_curly_end_lxr.Hook);
|
||||
return false;
|
||||
}
|
||||
else { // output entire tmpl_src WITH args; used to output name only which broke pages; PAGE:en.w:Flag_of_Greenland; DATE:2016-06-21
|
||||
bfr.Add(Xop_curly_bgn_lxr.Hook);
|
||||
bfr.Add(name_ary);
|
||||
for (int i = 0; i < args_len; ++i) {
|
||||
Arg_nde_tkn nde = this.Args_get_by_idx(i);
|
||||
bfr.Add_byte(Byte_ascii.Pipe);
|
||||
bfr.Add_mid(src, nde.Src_bgn(), nde.Src_end());
|
||||
}
|
||||
bfr.Add(Xop_curly_end_lxr.Hook);
|
||||
return false;
|
||||
}
|
||||
// DELETE:v3.6.4
|
||||
// byte[] missing_ttl
|
||||
// = subst_found || template_prefix_found // if "subst:" or "Template:" found, use orig name; DATE:2014-03-31
|
||||
// ? name_ary_orig
|
||||
// : name_ary
|
||||
// ;
|
||||
// bfr.Add(Xop_curly_bgn_lxr.Hook).Add(missing_ttl).Add(Xop_curly_end_lxr.Hook);
|
||||
// return false;
|
||||
}
|
||||
else { // some templates produce null ttls; EX: "Citation needed{{subst"
|
||||
defn = wiki.Cache_mgr().Defn_cache().Get_by_key(ttl.Page_db());
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
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.tmpls; import gplx.*; import gplx.xowa.*; import gplx.xowa.parsers.*;
|
||||
import org.junit.*; import gplx.xowa.wikis.ttls.*; import gplx.xowa.wikis.nss.*;
|
||||
public class Xot_invk_wkr__missing__tst {
|
||||
@Before public void init() {fxt.Reset();} private final Xop_fxt fxt = new Xop_fxt();
|
||||
@Test public void Missing() {
|
||||
fxt.Init_defn_clear();
|
||||
fxt.Init_defn_add("test_template", "{{[[Template:{{{1}}}|{{{1}}}]]}}");
|
||||
fxt.Init_log_(Xop_ttl_log.Invalid_char).Test_parse_tmpl_str("{{test_template|a}}", "{{[[Template:a|a]]}}");
|
||||
fxt.Init_defn_clear();
|
||||
}
|
||||
@Test public void Missing__name_and_args() { // PURPOSE: missing title should return name + args; used to only return name; PAGE:en.w:Flag_of_Greenland; DATE:2016-06-21
|
||||
fxt.Init_defn_clear();
|
||||
fxt.Init_defn_add("test_template", "{{ {{{1}}} | a | b }}");
|
||||
fxt.Init_log_(Xop_ttl_log.Invalid_char).Test_parse_tmpl_str("{{test_template}}", "{{{{{1}}}| a | b }}"); // NOTE: this should include spaces (" {{{1}}} "), but for now, ignore
|
||||
fxt.Init_defn_clear();
|
||||
}
|
||||
@Test public void Missing_foreign() {
|
||||
Xow_ns ns = fxt.Wiki().Ns_mgr().Ns_template();
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -201,19 +201,6 @@ public class Xot_invk_wkr_basic_tst {
|
||||
fxt.Init_defn_add("temp_2", "{{{key1}}}");
|
||||
fxt.Test_parse_tmpl_str("{{temp_1}}", "val1");
|
||||
}
|
||||
@Test public void Missing() {
|
||||
fxt.Init_defn_clear();
|
||||
fxt.Init_defn_add("test_template", "{{[[Template:{{{1}}}|{{{1}}}]]}}");
|
||||
fxt.Init_log_(Xop_ttl_log.Invalid_char).Test_parse_tmpl_str("{{test_template|a}}", "{{[[Template:a|a]]}}");
|
||||
fxt.Init_defn_clear();
|
||||
}
|
||||
@Test public void Missing_foreign() {
|
||||
Xow_ns ns = fxt.Wiki().Ns_mgr().Ns_template();
|
||||
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);
|
||||
}
|
||||
@Test public void Xnde_xtn_preserved() { // PURPOSE: tmpl was dropping .Xtn ndes;
|
||||
fxt.Init_defn_clear();
|
||||
fxt.Init_defn_add("test_template", "{{{1}}}");
|
||||
|
||||
Reference in New Issue
Block a user