mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
v1.10.2.1
This commit is contained in:
@@ -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/>.
|
||||
*/
|
||||
package gplx.xowa; import gplx.*;
|
||||
import gplx.core.btries.*;
|
||||
import gplx.core.btries.*; import gplx.xowa.parsers.tblws.*;
|
||||
public class Xop_curly_bgn_lxr implements Xop_lxr {
|
||||
public byte Lxr_tid() {return Xop_lxr_.Tid_curly_bgn;}
|
||||
public void Init_by_wiki(Xow_wiki wiki, Btrie_fast_mgr core_trie) {core_trie.Add(Hook, this);} public static final byte[] Hook = new byte[] {Byte_ascii.Curly_bgn, Byte_ascii.Curly_bgn};
|
||||
|
||||
@@ -35,6 +35,6 @@ public class Xop_tkn_print_tst {
|
||||
Xot_fmtr_prm raw_fmtr = new Xot_fmtr_prm();
|
||||
defn.Root().Tmpl_fmt(ctx, raw_bry, raw_fmtr);
|
||||
raw_fmtr.Print(tst_Print_bb);
|
||||
Tfds.Eq(raw, tst_Print_bb.XtoStrAndClear());
|
||||
Tfds.Eq(raw, tst_Print_bb.Xto_str_and_clear());
|
||||
} private Bry_bfr tst_Print_bb = Bry_bfr.new_();
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ public class Xot_defn_tmpl implements Xot_defn {
|
||||
bfr.Add_mid(src, find_bgn_lhs, find_end);
|
||||
pos = find_end + Bry_onlyinclude_end_len;
|
||||
}
|
||||
return bfr.Mkr_rls().XtoAryAndClear();
|
||||
return bfr.Mkr_rls().Xto_bry_and_clear();
|
||||
}
|
||||
private static final byte[] Bry_onlyinclude_bgn = Bry_.new_ascii_("<onlyinclude>"), Bry_onlyinclude_end = Bry_.new_ascii_("</onlyinclude>");
|
||||
private static int Bry_onlyinclude_bgn_len = Bry_onlyinclude_bgn.length, Bry_onlyinclude_end_len = Bry_onlyinclude_end.length;
|
||||
|
||||
@@ -49,7 +49,7 @@ public class Xot_defn_tmpl_ {
|
||||
for (int i = 0; i < subs_len; i++)
|
||||
orig.Subs_get(i).Tmpl_evaluate(ctx, src, caller, arg_bfr);
|
||||
Arg_itm_tkn rv = tkn_mkr.ArgItm(-1, -1); // NOTE: was -1, 0; DATE:2013-04-10
|
||||
byte[] rv_ary = orig_arg.KeyTkn_exists() && val_tkn ? arg_bfr.XtoAryAndClearAndTrim() : arg_bfr.XtoAryAndClear(); // // NOTE: must trim if key_exists; DUPE:TRIM_IF_KEY; PAGE:en.w:Coord in Chernobyl disaster, Sahara
|
||||
byte[] rv_ary = orig_arg.KeyTkn_exists() && val_tkn ? arg_bfr.Xto_bry_and_clear_and_trim() : arg_bfr.Xto_bry_and_clear(); // // NOTE: must trim if key_exists; DUPE:TRIM_IF_KEY; PAGE:en.w:Coord in Chernobyl disaster, Sahara
|
||||
rv.Dat_ary_(rv_ary);
|
||||
return rv;
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ class Xot_defn_trace_fxt {
|
||||
Xop_root_tkn root = ctx.Tkn_mkr().Root(src);
|
||||
fxt.Parser().Parse_page_all_clear(root, ctx, ctx.Tkn_mkr(), src);
|
||||
ctx.Defn_trace().Print(src, tmp);
|
||||
String[] actl_ary = String_.Split(tmp.XtoStrAndClear(), (char)Byte_ascii.NewLine);
|
||||
String[] actl_ary = String_.Split(tmp.Xto_str_and_clear(), (char)Byte_ascii.NewLine);
|
||||
Tfds.Eq_ary(expd_ary, actl_ary);
|
||||
} private Bry_bfr tmp = Bry_bfr.new_();
|
||||
String[] XtoStr(Xot_defn_trace_itm_brief[] ary) {
|
||||
@@ -50,7 +50,7 @@ class Xot_defn_trace_fxt {
|
||||
for (int i = 0; i < rv.length; i++) {
|
||||
Xot_defn_trace_itm_brief itm = ary[i];
|
||||
sb.Add(String_.new_utf8_(itm.Name())).Add("|").Add(itm.Count());
|
||||
rv[i] = sb.XtoStrAndClear();
|
||||
rv[i] = sb.Xto_str_and_clear();
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ public class Xot_invk_tkn extends Xop_tkn_itm_base implements Xot_invk {
|
||||
if (defn_tid == Xot_defn_.Tid_subst)
|
||||
name_tkn_bfr.Add(Get_first_subst_itm(lang.Kwd_mgr()));
|
||||
name_tkn.Tmpl_evaluate(ctx, src, caller, name_tkn_bfr);
|
||||
name_ary = name_tkn_bfr.XtoAryAndClear();
|
||||
name_ary = name_tkn_bfr.Xto_bry_and_clear();
|
||||
}
|
||||
else // tmpl is static; note that dat_ary is still valid but rest of name may not be; EX: {{subst:name{{{1}}}}}
|
||||
name_ary = Bry_.Mid(src, name_key_tkn.Dat_bgn(), name_key_tkn.Dat_end());
|
||||
@@ -251,7 +251,7 @@ public class Xot_invk_tkn extends Xop_tkn_itm_base implements Xot_invk {
|
||||
Bry_bfr rslt_bfr = wiki.Utl_bry_bfr_mkr().Get_k004();
|
||||
try {
|
||||
Bld_key(invk_tmpl, name_ary, rslt_bfr);
|
||||
byte[] rslt_key = rslt_bfr.XtoAryAndClear();
|
||||
byte[] rslt_key = rslt_bfr.Xto_bry_and_clear();
|
||||
Object o = wiki.Cache_mgr().Tmpl_result_cache().Fetch(rslt_key);
|
||||
Xopg_tmpl_prepend_mgr prepend_mgr = ctx.Cur_page().Tmpl_prepend_mgr().Bgn(bfr);
|
||||
if (o != null) {
|
||||
@@ -263,11 +263,11 @@ public class Xot_invk_tkn extends Xop_tkn_itm_base implements Xot_invk {
|
||||
rv = defn_tmpl.Tmpl_evaluate(ctx, invk_tmpl, rslt_bfr);
|
||||
prepend_mgr.End(ctx, bfr, rslt_bfr.Bfr(), rslt_bfr.Len(), Bool_.Y);
|
||||
if (name_had_subst) { // current invk had "subst:"; parse incoming invk again to remove effects of subst; PAGE:pt.w:Argentina DATE:2014-09-24
|
||||
byte[] tmp_src = rslt_bfr.XtoAryAndClear();
|
||||
byte[] tmp_src = rslt_bfr.Xto_bry_and_clear();
|
||||
rslt_bfr.Add(wiki.Parser().Parse_text_to_wtxt(tmp_src)); // this could be cleaner / more optimized
|
||||
}
|
||||
if (Cache_enabled) {
|
||||
byte[] rslt_val = rslt_bfr.XtoAryAndClear();
|
||||
byte[] rslt_val = rslt_bfr.Xto_bry_and_clear();
|
||||
bfr.Add(rslt_val);
|
||||
HashAdp cache = wiki.Cache_mgr().Tmpl_result_cache();
|
||||
cache.Del(rslt_key);
|
||||
|
||||
@@ -49,7 +49,7 @@ public class Xot_prm_tkn extends Xop_tkn_itm_base {
|
||||
find_tkn.Subs_get(i).Tmpl_evaluate(ctx, src, caller, find_bfr);
|
||||
prm_idx = Bry_.Xto_int_or_trim(find_bfr.Bfr(), 0, find_bfr.Len(), -1); // parse as number first; NOTE: trim needed to transform "{{{ 1 }}}" to "1"; it.w:Portale:Giochi_da_tavolo; DATE:2014-02-09
|
||||
if (prm_idx == -1)
|
||||
prm_key = find_bfr.XtoAryAndClearAndTrim(); // not a number; parse as key; NOTE: must trim; PAGE:en.w:William Shakespeare; {{Relatebardtree}}
|
||||
prm_key = find_bfr.Xto_bry_and_clear_and_trim(); // not a number; parse as key; NOTE: must trim; PAGE:en.w:William Shakespeare; {{Relatebardtree}}
|
||||
}
|
||||
Arg_nde_tkn arg_nde = null;
|
||||
if (prm_idx == -1) { // prm is key; EX: "{{{key1}}}"
|
||||
|
||||
@@ -23,7 +23,7 @@ public class Xot_tmpl_wtr {
|
||||
rslt_bfr.Reset_if_gt(Io_mgr.Len_mb);
|
||||
Write_tkn(ctx, src, src.length, rslt_bfr, root);
|
||||
ctx.Tmpl_output_(null);
|
||||
return rslt_bfr.Mkr_rls().XtoAryAndClear();
|
||||
return rslt_bfr.Mkr_rls().Xto_bry_and_clear();
|
||||
}
|
||||
private void Write_tkn(Xop_ctx ctx, byte[] src, int src_len, Bry_bfr rslt_bfr, Xop_tkn_itm tkn) {
|
||||
switch (tkn.Tkn_tid()) {
|
||||
|
||||
Reference in New Issue
Block a user