mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
'v3.6.3.1'
This commit is contained in:
@@ -32,25 +32,25 @@ public class Xop_ctx {
|
||||
this.xnde_tag_regy = wiki.Mw_parser_mgr().Xnde_tag_regy();
|
||||
}
|
||||
// public boolean Scribunto; // CHART
|
||||
public Xoae_app App() {return app;} private final Xoae_app app;
|
||||
public Xowe_wiki Wiki() {return wiki;} private final Xowe_wiki wiki;
|
||||
public Xol_lang_itm Lang() {return lang;} private final Xol_lang_itm lang;
|
||||
public Xop_tkn_mkr Tkn_mkr() {return tkn_mkr;} private final Xop_tkn_mkr tkn_mkr;
|
||||
public Xoae_app App() {return app;} private final Xoae_app app;
|
||||
public Xowe_wiki Wiki() {return wiki;} private final Xowe_wiki wiki;
|
||||
public Xol_lang_itm Lang() {return lang;} private final Xol_lang_itm lang;
|
||||
public Xop_tkn_mkr Tkn_mkr() {return tkn_mkr;} private final Xop_tkn_mkr tkn_mkr;
|
||||
public Xoae_page Page() {return cur_page;} public void Page_(Xoae_page v) {cur_page = v;} private Xoae_page cur_page;
|
||||
public byte Parse_tid() {return parse_tid;} public Xop_ctx Parse_tid_(byte v) {parse_tid = v; xnde_names_tid = v; return this;} private byte parse_tid = Xop_parser_.Parse_tid_null;
|
||||
public byte Xnde_names_tid() {return xnde_names_tid;} public Xop_ctx Xnde_names_tid_(byte v) {xnde_names_tid = v; return this;} private byte xnde_names_tid = Xop_parser_.Parse_tid_null;
|
||||
public Xop_amp_wkr Amp() {return amp;} private final Xop_amp_wkr amp = new Xop_amp_wkr();
|
||||
public Xop_apos_wkr Apos() {return apos;} private final Xop_apos_wkr apos = new Xop_apos_wkr();
|
||||
public Xop_lnke_wkr Lnke() {return lnke;} private final Xop_lnke_wkr lnke = new Xop_lnke_wkr();
|
||||
public Xop_lnki_wkr Lnki() {return lnki;} private final Xop_lnki_wkr lnki = new Xop_lnki_wkr();
|
||||
public Xop_hdr_wkr Hdr() {return hdr;} private final Xop_hdr_wkr hdr = new Xop_hdr_wkr();
|
||||
public Xop_para_wkr Para() {return para;} private final Xop_para_wkr para = new Xop_para_wkr();
|
||||
public Xop_list_wkr List() {return list;} private final Xop_list_wkr list = new Xop_list_wkr();
|
||||
public Xop_tblw_wkr Tblw() {return tblw;} private final Xop_tblw_wkr tblw = new Xop_tblw_wkr();
|
||||
public Xop_xnde_wkr Xnde() {return xnde;} private final Xop_xnde_wkr xnde = new Xop_xnde_wkr();
|
||||
public Xot_invk_wkr Invk() {return invk;} private final Xot_invk_wkr invk = new Xot_invk_wkr();
|
||||
public Xop_curly_wkr Curly() {return curly;} private final Xop_curly_wkr curly = new Xop_curly_wkr();
|
||||
public Xop_xnde_tag_regy Xnde_tag_regy() {return xnde_tag_regy;} private final Xop_xnde_tag_regy xnde_tag_regy; // PERF:demeter
|
||||
public Xop_amp_wkr Amp() {return amp;} private final Xop_amp_wkr amp = new Xop_amp_wkr();
|
||||
public Xop_apos_wkr Apos() {return apos;} private final Xop_apos_wkr apos = new Xop_apos_wkr();
|
||||
public Xop_lnke_wkr Lnke() {return lnke;} private final Xop_lnke_wkr lnke = new Xop_lnke_wkr();
|
||||
public Xop_lnki_wkr Lnki() {return lnki;} private final Xop_lnki_wkr lnki = new Xop_lnki_wkr();
|
||||
public Xop_hdr_wkr Hdr() {return hdr;} private final Xop_hdr_wkr hdr = new Xop_hdr_wkr();
|
||||
public Xop_para_wkr Para() {return para;} private final Xop_para_wkr para = new Xop_para_wkr();
|
||||
public Xop_list_wkr List() {return list;} private final Xop_list_wkr list = new Xop_list_wkr();
|
||||
public Xop_tblw_wkr Tblw() {return tblw;} private final Xop_tblw_wkr tblw = new Xop_tblw_wkr();
|
||||
public Xop_xnde_wkr Xnde() {return xnde;} private final Xop_xnde_wkr xnde = new Xop_xnde_wkr();
|
||||
public Xot_invk_wkr Invk() {return invk;} private final Xot_invk_wkr invk = new Xot_invk_wkr();
|
||||
public Xop_curly_wkr Curly() {return curly;} private final Xop_curly_wkr curly = new Xop_curly_wkr();
|
||||
public Xop_xnde_tag_regy Xnde_tag_regy() {return xnde_tag_regy;} private final Xop_xnde_tag_regy xnde_tag_regy; // PERF:demeter
|
||||
|
||||
public boolean Tmpl_load_enabled() {return tmpl_load_enabled;} public void Tmpl_load_enabled_(boolean v) {tmpl_load_enabled = v;} private boolean tmpl_load_enabled = true;
|
||||
public int Tmpl_tkn_max() {return tmpl_tkn_max;} public void Tmpl_tkn_max_(int v) {tmpl_tkn_max = v;} private int tmpl_tkn_max = Int_.Max_value;
|
||||
@@ -307,7 +307,7 @@ public class Xop_ctx {
|
||||
public static Xop_ctx new_main_page(Xowe_wiki wiki) {return new_(wiki, Xoa_page_.Main_page_bry);} // HACK: use "Main_Page" to put in valid page title
|
||||
public static Xop_ctx new_(Xowe_wiki wiki, byte[] ttl_bry) {return new Xop_ctx(wiki, Xoae_page.New(wiki, wiki.Ttl_parse(ttl_bry)));}
|
||||
public static Xop_ctx new_sub_(Xowe_wiki wiki) {return new_sub_(wiki, wiki.Parser_mgr().Ctx().cur_page);}
|
||||
public static Xop_ctx new_sub_(Xowe_wiki wiki, Xoae_page page) { // TODO: new_sub_ should reuse ctx's page; callers who want new_page should call new_sub_page_; DATE:2014-04-10
|
||||
public static Xop_ctx new_sub_(Xowe_wiki wiki, Xoae_page page) { // TODO_OLD: new_sub_ should reuse ctx's page; callers who want new_page should call new_sub_page_; DATE:2014-04-10
|
||||
Xop_ctx rv = new Xop_ctx(wiki, page);
|
||||
new_copy(wiki.Parser_mgr().Ctx(), rv);
|
||||
return rv;
|
||||
|
||||
@@ -20,10 +20,10 @@ import gplx.core.btries.*;
|
||||
import gplx.xowa.langs.*;
|
||||
import gplx.xowa.parsers.apos.*; import gplx.xowa.parsers.amps.*; import gplx.xowa.parsers.lnkes.*; import gplx.xowa.parsers.hdrs.*; import gplx.xowa.parsers.lists.*; import gplx.xowa.parsers.tblws.*; import gplx.xowa.parsers.paras.*; import gplx.xowa.parsers.xndes.*; import gplx.xowa.parsers.lnkis.*; import gplx.xowa.parsers.tmpls.*; import gplx.xowa.parsers.miscs.*;
|
||||
public class Xop_lxr_mgr {
|
||||
private final Xop_lxr[] ary;
|
||||
private final List_adp page_lxr_list = List_adp_.new_();
|
||||
private final Xop_lxr[] ary;
|
||||
private final List_adp page_lxr_list = List_adp_.New();
|
||||
public Xop_lxr_mgr(Xop_lxr[] ary) {this.ary = ary;}
|
||||
public Btrie_fast_mgr Trie() {return trie;} private final Btrie_fast_mgr trie = Btrie_fast_mgr.cs();
|
||||
public Btrie_fast_mgr Trie() {return trie;} private final Btrie_fast_mgr trie = Btrie_fast_mgr.cs();
|
||||
public void Page__add(Xowe_wiki wiki, Xop_lxr... ary) {
|
||||
int len = ary.length;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
@@ -92,7 +92,7 @@ public class Xop_lxr_mgr {
|
||||
, Xop_xnde_lxr.Instance
|
||||
});
|
||||
}
|
||||
public static final Xop_lxr_mgr Popup_lxr_mgr // same as orig_page, except apos_lxr added
|
||||
public static final Xop_lxr_mgr Popup_lxr_mgr // same as orig_page, except apos_lxr added
|
||||
= new Xop_lxr_mgr(new Xop_lxr[]
|
||||
{ Xop_pipe_lxr.Instance, new Xop_eq_lxr(true), Xop_colon_lxr.Instance, Xop_space_lxr.Instance, Xop_tab_lxr.Instance, Xop_nl_lxr.Instance
|
||||
, Xop_curly_bgn_lxr.Instance, Xop_curly_end_lxr.Instance
|
||||
|
||||
@@ -45,8 +45,8 @@ public class Xop_parser__tst {
|
||||
}
|
||||
}
|
||||
class Xop_parser__fxt {
|
||||
private final Xop_fxt fxt = new Xop_fxt();
|
||||
private Bry_bfr bfr = Bry_bfr.reset_(255);
|
||||
private final Xop_fxt fxt = new Xop_fxt();
|
||||
private Bry_bfr bfr = Bry_bfr_.Reset(255);
|
||||
public void Clear() {
|
||||
fxt.Reset();
|
||||
}
|
||||
|
||||
@@ -18,9 +18,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.parsers.amps; import gplx.*; import gplx.xowa.*; import gplx.xowa.parsers.*;
|
||||
import gplx.core.btries.*;
|
||||
public class Xop_amp_mgr {
|
||||
private final Object thread_lock_1 = new Object(), thread_lock_2 = new Object();
|
||||
private final Bry_bfr tmp_bfr = Bry_bfr.reset_(32);
|
||||
public Btrie_slim_mgr Amp_trie() {return amp_trie;} private final Btrie_slim_mgr amp_trie = Xop_amp_trie.Instance;
|
||||
private final Object thread_lock_1 = new Object(), thread_lock_2 = new Object();
|
||||
private final Bry_bfr tmp_bfr = Bry_bfr_.Reset(32);
|
||||
public Btrie_slim_mgr Amp_trie() {return amp_trie;} private final Btrie_slim_mgr amp_trie = Xop_amp_trie.Instance;
|
||||
public int Rslt_pos() {return rslt_pos;} private int rslt_pos;
|
||||
public int Rslt_val() {return rslt_val;} private int rslt_val;
|
||||
public Xop_tkn_itm Parse_as_tkn(Xop_tkn_mkr tkn_mkr, byte[] src, int src_len, int amp_pos, int cur_pos) {
|
||||
@@ -125,5 +125,5 @@ public class Xop_amp_mgr {
|
||||
return dirty ? tmp_bfr.To_bry_and_clear() : src;
|
||||
}
|
||||
}
|
||||
public static final Xop_amp_mgr Instance = new Xop_amp_mgr(); Xop_amp_mgr() {}
|
||||
public static final Xop_amp_mgr Instance = new Xop_amp_mgr(); Xop_amp_mgr() {}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.parsers.apos; import gplx.*; import gplx.xowa.*; import gplx.xowa.parsers.*;
|
||||
public class Xop_apos_wkr implements Xop_ctx_wkr {
|
||||
public Xop_apos_dat Dat() {return dat;} private Xop_apos_dat dat = new Xop_apos_dat();
|
||||
private List_adp stack = List_adp_.new_(); private int bold_count, ital_count; private Xop_apos_tkn dual_tkn = null;
|
||||
private List_adp stack = List_adp_.New(); private int bold_count, ital_count; private Xop_apos_tkn dual_tkn = null;
|
||||
public void Ctor_ctx(Xop_ctx ctx) {}
|
||||
public void Page_bgn(Xop_ctx ctx, Xop_root_tkn root) {
|
||||
Reset();
|
||||
|
||||
@@ -20,15 +20,15 @@ import gplx.core.primitives.*;
|
||||
import gplx.xowa.parsers.xndes.*; // for brys: <nowiki>, <noinclude>, <includeonly>, <onlyinclude>
|
||||
public class Mwh_atr_parser { // REF.MW:Sanitizer.php|decodeTagAttributes;MW_ATTRIBS_REGEX
|
||||
private static final byte Area__invalid = 0, Area__atr_limbo = 1, Area__key = 2, Area__eql_limbo = 3, Area__val_limbo = 4, Area__val_quote = 5, Area__val_naked = 6;
|
||||
private final Hash_adp_bry repeated_atrs_hash = Hash_adp_bry.ci_a7(); // ASCII:xnde_atrs
|
||||
private final Mwh_atr_mgr atr_mgr = new Mwh_atr_mgr(16);
|
||||
private final Bry_bfr key_bfr = Bry_bfr.new_(), val_bfr = Bry_bfr.new_();
|
||||
private final Hash_adp_bry repeated_atrs_hash = Hash_adp_bry.ci_a7(); // ASCII:xnde_atrs
|
||||
private final Mwh_atr_mgr atr_mgr = new Mwh_atr_mgr(16);
|
||||
private final Bry_bfr key_bfr = Bry_bfr_.New(), val_bfr = Bry_bfr_.New();
|
||||
private byte area = Area__atr_limbo;
|
||||
private int atr_bgn = -1, key_bgn = -1, key_end = -1, eql_pos = -1, val_bgn = -1, val_end = -1;
|
||||
private byte qte_byte = Byte_ascii.Null;
|
||||
private boolean key_bfr_on = false, val_bfr_on = false, ws_is_before_val = false, qte_closed = false;
|
||||
private int nde_uid, nde_tid;
|
||||
public Bry_obj_ref Bry_obj() {return bry_ref;} private final Bry_obj_ref bry_ref = Bry_obj_ref.New_empty();
|
||||
public Bry_obj_ref Bry_obj() {return bry_ref;} private final Bry_obj_ref bry_ref = Bry_obj_ref.New_empty();
|
||||
public int Nde_end_tid() {return nde_end_tid;} private int nde_end_tid;
|
||||
public int Parse(Mwh_atr_wkr wkr, int nde_uid, int nde_tid, byte[] src, int src_bgn, int src_end) {
|
||||
this.nde_uid = nde_uid; this.nde_tid = nde_tid;
|
||||
@@ -471,7 +471,7 @@ public class Mwh_atr_parser { // REF.MW:Sanitizer.php|decodeTagAttributes;MW_ATT
|
||||
}
|
||||
return Bry_find_.Not_found;
|
||||
}
|
||||
private static final Hash_adp_bry xnde_hash = Hash_adp_bry.ci_a7()
|
||||
private static final Hash_adp_bry xnde_hash = Hash_adp_bry.ci_a7()
|
||||
.Add_bry_bry(Xop_xnde_tag_.Tag__nowiki.Name_bry())
|
||||
.Add_bry_bry(Xop_xnde_tag_.Tag__noinclude.Name_bry())
|
||||
.Add_bry_bry(Xop_xnde_tag_.Tag__includeonly.Name_bry())
|
||||
|
||||
@@ -17,9 +17,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
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();
|
||||
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);}
|
||||
|
||||
@@ -19,10 +19,10 @@ package gplx.xowa.parsers.htmls; import gplx.*; import gplx.xowa.*; import gplx.
|
||||
import gplx.core.primitives.*;
|
||||
import gplx.xowa.parsers.amps.*; import gplx.xowa.parsers.xndes.*;
|
||||
public class Mwh_doc_parser {
|
||||
private final Mwh_doc_mgr dom_mgr = new Mwh_doc_mgr(16);
|
||||
private final Mwh_atr_parser atr_parser = new Mwh_atr_parser();
|
||||
private final List_adp nde_stack = List_adp_.new_();
|
||||
private final Xop_amp_mgr amp_mgr = Xop_amp_mgr.Instance; private final Xop_tkn_mkr tkn_mkr = new Xop_tkn_mkr();
|
||||
private final Mwh_doc_mgr dom_mgr = new Mwh_doc_mgr(16);
|
||||
private final Mwh_atr_parser atr_parser = new Mwh_atr_parser();
|
||||
private final List_adp nde_stack = List_adp_.New();
|
||||
private final Xop_amp_mgr amp_mgr = Xop_amp_mgr.Instance; private final Xop_tkn_mkr tkn_mkr = new Xop_tkn_mkr();
|
||||
private byte[] src; private int src_end;
|
||||
private Mwh_doc_wkr wkr;
|
||||
private Hash_adp_bry nde_regy;
|
||||
@@ -240,5 +240,5 @@ public class Mwh_doc_parser {
|
||||
return pos;
|
||||
}
|
||||
public static final int Nde_end_tid__invalid = 0, Nde_end_tid__gt = 1, Nde_end_tid__ws = 2, Nde_end_tid__inline = 3, Nde_end_tid__slash = 4, Nde_end_tid__backslash = 5, Nde_end_tid__comment = 6;
|
||||
private static final byte[] Comment_bgn = Bry_.new_a7("--"), Comment_end = Bry_.new_a7("-->");
|
||||
private static final byte[] Comment_bgn = Bry_.new_a7("--"), Comment_end = Bry_.new_a7("-->");
|
||||
}
|
||||
|
||||
@@ -17,9 +17,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
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();
|
||||
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));}
|
||||
@@ -61,8 +61,8 @@ class Mwh_doc_parser_fxt {
|
||||
}
|
||||
}
|
||||
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();
|
||||
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) {}
|
||||
|
||||
@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.parsers.htmls; import gplx.*; import gplx.xowa.*; import gplx.xowa.parsers.*;
|
||||
public class Mwh_doc_wkr__atr_bldr implements Mwh_doc_wkr {
|
||||
private final List_adp list = List_adp_.new_();
|
||||
private final List_adp list = List_adp_.New();
|
||||
public Hash_adp_bry Nde_regy() {return null;}
|
||||
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[] data_ary, int itm_idx) {
|
||||
int atr_bgn = data_ary[itm_idx + Mwh_atr_mgr.Idx_atr_bgn];
|
||||
|
||||
@@ -28,7 +28,7 @@ public class Xop_colon_lxr implements Xop_lxr {
|
||||
int prv_pos = cur_pos -1 ;
|
||||
if ( ctx.Cur_tkn_tid() != Xop_tkn_itm_.Tid_lnki // ignore if inside link
|
||||
&& prv_pos > 0
|
||||
&& src[prv_pos] != Byte_ascii.Nl // only consider ":" which are not preceded by \n; DATE:2014-07-11 TODO: emulate Parser.php|findColonNoLinks which does much more logic to see if ";a:b" construct should apply
|
||||
&& src[prv_pos] != Byte_ascii.Nl // only consider ":" which are not preceded by \n; DATE:2014-07-11 TODO_OLD: emulate Parser.php|findColonNoLinks which does much more logic to see if ";a:b" construct should apply
|
||||
) {
|
||||
listCtx.Dd_chk_(false);
|
||||
return listCtx.MakeTkn_bgn(ctx, tkn_mkr, root, src, src_len, bgn_pos, cur_pos);
|
||||
@@ -37,5 +37,5 @@ public class Xop_colon_lxr implements Xop_lxr {
|
||||
ctx.Subs_add(root, tkn_mkr.Colon(bgn_pos, cur_pos));
|
||||
return cur_pos;
|
||||
}
|
||||
public static final Xop_colon_lxr Instance = new Xop_colon_lxr();
|
||||
public static final Xop_colon_lxr Instance = new Xop_colon_lxr();
|
||||
}
|
||||
|
||||
@@ -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.parsers.lnkes; import gplx.*; import gplx.xowa.*; import gplx.xowa.parsers.*;
|
||||
import gplx.core.net.*;
|
||||
import gplx.core.net.*; import gplx.core.net.qargs.*;
|
||||
public class Xop_lnke_tkn extends Xop_tkn_itm_base {//20111222
|
||||
public static final byte Lnke_typ_null = 0, Lnke_typ_brack = 1, Lnke_typ_text = 2, Lnke_typ_brack_dangling = 3;
|
||||
@Override public byte Tkn_tid() {return Xop_tkn_itm_.Tid_lnke;}
|
||||
|
||||
@@ -31,8 +31,8 @@ public class Xop_lnke_wkr implements Xop_ctx_wkr {
|
||||
bgn_tkn.Src_end_(bgn_tkn.Lnke_href_end()); // NOTE: endPos is lnke_end, not cur_pos or src_len; EX: "[irc://a b", lnk ends at a, not b; NOTE: still bgns at [
|
||||
ctx.Msg_log().Add_itm_none(Xop_lnke_log.Dangling, src, tkn.Src_bgn(), cur_pos);
|
||||
}
|
||||
public static final String Str_xowa_protocol = "xowa-cmd:";
|
||||
public static final byte[] Bry_xowa_protocol = Bry_.new_a7(Str_xowa_protocol);
|
||||
public static final String Str_xowa_protocol = "xowa-cmd:";
|
||||
public static final byte[] Bry_xowa_protocol = Bry_.new_a7(Str_xowa_protocol);
|
||||
public int MakeTkn_bgn(Xop_ctx ctx, Xop_tkn_mkr tkn_mkr, Xop_root_tkn root, byte[] src, int src_len, int bgn_pos, int cur_pos, byte[] protocol, byte proto_tid, byte lnke_type) {
|
||||
boolean lnke_type_brack = (lnke_type == Xop_lnke_tkn.Lnke_typ_brack);
|
||||
if ( !lnke_type_brack // lnke doesn't have "["; EX: "ttl:"
|
||||
@@ -238,7 +238,7 @@ public class Xop_lnke_wkr implements Xop_ctx_wkr {
|
||||
private static final byte Lnki_linkMode_init = 0, Lnki_linkMode_eq = 1, Lnki_linkMode_text = 2;
|
||||
private static final byte End_tid_null = 0, End_tid_eos = 1, End_tid_brack = 2, End_tid_space = 3, End_tid_nl = 4, End_tid_symbol = 5, End_tid_invalid = 6;
|
||||
public int MakeTkn_end(Xop_ctx ctx, Xop_tkn_mkr tkn_mkr, Xop_root_tkn root, byte[] src, int src_len, int bgn_pos, int cur_pos) {
|
||||
// Xop_tkn_itm last_tkn = ctx.Stack_get_last(); // BLOCK:invalid_ttl_check; // TODO: backout apos changes
|
||||
// Xop_tkn_itm last_tkn = ctx.Stack_get_last(); // BLOCK:invalid_ttl_check; // TODO_OLD: backout apos changes
|
||||
// if ( last_tkn != null
|
||||
// && last_tkn.Tkn_tid() == Xop_tkn_itm_.Tid_lnki) {
|
||||
// Xop_lnki_tkn lnki = (Xop_lnki_tkn)last_tkn;
|
||||
@@ -300,7 +300,7 @@ public class Xop_lnke_wkr implements Xop_ctx_wkr {
|
||||
ctx.Subs_add(root, tkn);
|
||||
tkn.Subs_add(tkn_mkr.Txt(txt_bgn, txt_end));
|
||||
return end_pos;
|
||||
} private static final byte[] Bry_quote = new byte[] {Byte_ascii.Quote};
|
||||
} private static final byte[] Bry_quote = new byte[] {Byte_ascii.Quote};
|
||||
}
|
||||
/*
|
||||
NOTE_1
|
||||
|
||||
@@ -54,7 +54,7 @@ public class Xop_link_parser {
|
||||
int proto_len = Gfo_protocol_itm.Bry_file.length; // "file:"
|
||||
if (proto_len + 1 < raw_len && raw[proto_len + 1] == Byte_ascii.Slash) { // next char is slash, assume xfer_itm refers to protocol; EX: file:///C/A.png
|
||||
int slash_pos = Bry_find_.Find_bwd(raw, Byte_ascii.Slash);
|
||||
if (slash_pos != Bry_find_.Not_found) // set xowa_title to file_name; TODO: call Xoa_url.build; note that this will fail sometimes when (a) xfer_itm is very long (File:ReallyLongName will be shortened to 128 chars) or (b) xfer_itm has invalid windows characters (EX:File:a"b"c.jpg)
|
||||
if (slash_pos != Bry_find_.Not_found) // set xowa_title to file_name; TODO_OLD: call Xoa_url.build; note that this will fail sometimes when (a) xfer_itm is very long (File:ReallyLongName will be shortened to 128 chars) or (b) xfer_itm has invalid windows characters (EX:File:a"b"c.jpg)
|
||||
html_xowa_ttl = Bry_.Mid(raw, slash_pos + Int_.Const_dlm_len, raw.length);
|
||||
}
|
||||
else // next char is not slash; assume xfer_itm refers to ns; EX:File:A.png
|
||||
|
||||
@@ -19,9 +19,9 @@ package gplx.xowa.parsers.lnkis; import gplx.*; import gplx.xowa.*; import gplx.
|
||||
import gplx.core.primitives.*; import gplx.core.btries.*; import gplx.core.envs.*;
|
||||
import gplx.xowa.langs.*; import gplx.xowa.langs.kwds.*; import gplx.xowa.langs.numbers.*;
|
||||
public class Xop_lnki_arg_parser {
|
||||
private final Btrie_fast_mgr key_trie = Btrie_fast_mgr.cs();
|
||||
private final Bry_bfr int_bfr = Bry_bfr.reset_(16);
|
||||
private final Btrie_bwd_mgr px_trie = Btrie_bwd_mgr.cs_(); private final Btrie_fast_mgr size_trie = Btrie_fast_mgr.cs();
|
||||
private final Btrie_fast_mgr key_trie = Btrie_fast_mgr.cs();
|
||||
private final Bry_bfr int_bfr = Bry_bfr_.Reset(16);
|
||||
private final Btrie_bwd_mgr px_trie = Btrie_bwd_mgr.cs_(); private final Btrie_fast_mgr size_trie = Btrie_fast_mgr.cs();
|
||||
private int lnki_w, lnki_h;
|
||||
public void Evt_lang_changed(Xol_lang_itm lang) {
|
||||
Bry_bfr tmp_bfr = int_bfr;
|
||||
@@ -144,7 +144,7 @@ public class Xop_lnki_arg_parser {
|
||||
px_trie.Add(word_bry, Byte_obj_val.new_(Tid_dim));
|
||||
}
|
||||
}
|
||||
public static final byte[] Bry_upright = Bry_.new_a7("upright"), Bry_thumbtime = Bry_.new_a7("thumbtime"), Bry_target = Bry_.new_a7("target");
|
||||
public static final byte[] Bry_upright = Bry_.new_a7("upright"), Bry_thumbtime = Bry_.new_a7("thumbtime"), Bry_target = Bry_.new_a7("target");
|
||||
public static final byte
|
||||
Tid_unknown = 0, Tid_thumb = 1, Tid_left = 2, Tid_right = 3, Tid_none = 4, Tid_center = 5, Tid_frame = 6, Tid_frameless = 7, Tid_upright = 8, Tid_border = 9
|
||||
, Tid_alt = 10, Tid_link = 11, Tid_baseline = 12, Tid_sub = 13, Tid_super = 14, Tid_top = 15, Tid_text_top = 16, Tid_middle = 17, Tid_bottom = 18, Tid_text_bottom = 19
|
||||
@@ -155,13 +155,13 @@ public class Xop_lnki_arg_parser {
|
||||
, Tid_class = 27
|
||||
, Tid_target = 28
|
||||
;
|
||||
private static final byte[] X_bry = Bry_.new_a7("x");
|
||||
private static final byte[] X_bry = Bry_.new_a7("x");
|
||||
private static final byte // NOTE: d0 - d9 must match 0 - 9; DATE:2015-07-18
|
||||
Key_dim_d0 = 0, Key_dim_d1 = 1, Key_dim_d2 = 2, Key_dim_d3 = 3, Key_dim_d4 = 4
|
||||
, Key_dim_d5 = 5, Key_dim_d6 = 6, Key_dim_d7 = 7, Key_dim_d8 = 8, Key_dim_d9 = 9
|
||||
, Key_dim_num = 10, Key_dim_x = 11, Key_dim_px = 12, Key_space = 13
|
||||
;
|
||||
private static final int[][] Keys_ids = new int[][]
|
||||
private static final int[][] Keys_ids = new int[][]
|
||||
{ new int[] {Xol_kwd_grp_.Id_img_thumbnail , Tid_thumb}
|
||||
, new int[] {Xol_kwd_grp_.Id_img_manualthumb , Tid_thumb} // RESEARCH: what is manualthumb? 'thumb=$1' vs 'thumb'
|
||||
, new int[] {Xol_kwd_grp_.Id_img_right , Tid_right}
|
||||
|
||||
@@ -52,7 +52,7 @@ public class Xop_lnki_type {
|
||||
return true;
|
||||
else if ( Bitmask_.Has_int(id, Id_frame) // [[File:A.png|frame]] -> 400,200 (frame is always default size)
|
||||
|| id == Id_null // [[File:A.png]] -> 400,200 (default to original size)
|
||||
|| Bitmask_.Has_int(id, Id_none) // TODO: deprecate; NOTE: still used by one test; DATE:2015-08-03
|
||||
|| Bitmask_.Has_int(id, Id_none) // TODO_OLD: deprecate; NOTE: still used by one test; DATE:2015-08-03
|
||||
)
|
||||
return false;
|
||||
else // should not happen
|
||||
@@ -65,7 +65,7 @@ public class Xop_lnki_type {
|
||||
)
|
||||
return true;
|
||||
else if ( id == Id_null // [[File:A.png|600px]] -> 600,400; uses orig file of 400,200, but <img> tag src_width / src_height set to 600,400
|
||||
|| Bitmask_.Has_int(id, Id_none) // TODO: deprecate; NOTE: leaving in b/c of above failed-deprecate; DATE:2015-08-03
|
||||
|| Bitmask_.Has_int(id, Id_none) // TODO_OLD: deprecate; NOTE: leaving in b/c of above failed-deprecate; DATE:2015-08-03
|
||||
)
|
||||
return false;
|
||||
else // should not happen;
|
||||
|
||||
@@ -22,7 +22,7 @@ import gplx.xowa.wikis.nss.*;
|
||||
import gplx.xowa.wikis.*; import gplx.xowa.xtns.pfuncs.ttls.*; import gplx.xowa.xtns.relatedSites.*;
|
||||
import gplx.xowa.parsers.tmpls.*; import gplx.xowa.parsers.lnkis.redlinks.*;
|
||||
public class Xop_lnki_wkr_ {
|
||||
private static final Int_obj_ref rel2abs_tid = Int_obj_ref.zero_();
|
||||
private static final Int_obj_ref rel2abs_tid = Int_obj_ref.New_zero();
|
||||
public static final int Invalidate_lnki_len = 128;
|
||||
public static int Invalidate_lnki(Xop_ctx ctx, byte[] src, Xop_root_tkn root, Xop_lnki_tkn lnki, int cur_pos) {
|
||||
lnki.Tkn_tid_to_txt(); // convert initial "[[" to text; note that this lnki has no pipes as pipe_lxr does similar check; EX: [[<invalid>]]; DATE:2014-03-26
|
||||
|
||||
@@ -19,7 +19,7 @@ package gplx.xowa.parsers.lnkis; import gplx.*; import gplx.xowa.*; import gplx.
|
||||
import org.junit.*;
|
||||
import gplx.xowa.langs.cases.*; import gplx.xowa.wikis.ttls.*;
|
||||
public class Xop_lnki_wkr__invalid_tst {
|
||||
@Before public void init() {fxt.Reset(); fxt.Init_para_n_();} private final Xop_fxt fxt = new Xop_fxt();
|
||||
@Before public void init() {fxt.Reset(); fxt.Init_para_n_();} private final Xop_fxt fxt = new Xop_fxt();
|
||||
@Test public void Ignore_invalid_url_encodings() { // PURPOSE: if url encoding is invalid, still render lnki as <a>; EX: fr.w:Bordetella;
|
||||
fxt.Test_parse_page_all_str("[[%GC]]", "<a href=\"/wiki/%25GC\">%GC</a>");
|
||||
}
|
||||
@@ -59,7 +59,7 @@ public class Xop_lnki_wkr__invalid_tst {
|
||||
@Test public void Nl_with_apos_shouldnt_fail() { // PURPOSE: apos, lnki and nl will cause parser to fail; DATE:2013-10-31
|
||||
fxt.Test_parse_page_all_str("''[[\n]]", "<i>[[</i>\n]]");
|
||||
}
|
||||
// @Test public void Brack_end_invalid() { // PURPOSE: invalidate if ]; DATE:2014-04-03; // TODO: backout apos changes
|
||||
// @Test public void Brack_end_invalid() { // PURPOSE: invalidate if ]; DATE:2014-04-03; // TODO_OLD: backout apos changes
|
||||
// fxt.Test_parse_page_all_str_and_chk("[[A] ]", "[[A] ]", Xop_lnki_log.Invalid_ttl);
|
||||
// }
|
||||
@Test public void Module() { // PURPOSE: handle lnki_wkr parsing Module text (shouldn't happen); apos, tblw, lnki, and nl will cause parser to fail; also handles scan-bwd; EX:Module:Taxobox; DATE:2013-11-10
|
||||
|
||||
@@ -16,12 +16,12 @@ 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.lnkis.cfgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.parsers.*; import gplx.xowa.parsers.lnkis.*;
|
||||
public class Xoc_lnki_cfg implements GfoInvkAble {
|
||||
public class Xoc_lnki_cfg implements Gfo_invk {
|
||||
public Xoc_lnki_cfg(Xowe_wiki wiki) {xwiki_repo_mgr = new Xoc_xwiki_repo_mgr(wiki);}
|
||||
public Xoc_xwiki_repo_mgr Xwiki_repo_mgr() {return xwiki_repo_mgr;} private Xoc_xwiki_repo_mgr xwiki_repo_mgr;
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_xwiki_repos)) return xwiki_repo_mgr;
|
||||
else return GfoInvkAble_.Rv_unhandled;
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
}
|
||||
private static final String Invk_xwiki_repos = "xwiki_repos";
|
||||
}
|
||||
|
||||
@@ -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.parsers.lnkis.cfgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.parsers.*; import gplx.xowa.parsers.lnkis.*;
|
||||
public class Xoc_xwiki_repo_mgr implements GfoInvkAble {
|
||||
public class Xoc_xwiki_repo_mgr implements Gfo_invk {
|
||||
private Ordered_hash hash = Ordered_hash_.New_bry();
|
||||
private Xowe_wiki wiki;
|
||||
public Xoc_xwiki_repo_mgr(Xowe_wiki wiki) {this.wiki = wiki;}
|
||||
@@ -34,7 +34,7 @@ public class Xoc_xwiki_repo_mgr implements GfoInvkAble {
|
||||
}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_add)) Add_or_mod(m.ReadBry("xwiki"));
|
||||
else return GfoInvkAble_.Rv_unhandled;
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
return this;
|
||||
}
|
||||
private static final String Invk_add = "add";
|
||||
|
||||
@@ -20,38 +20,38 @@ import gplx.core.primitives.*;
|
||||
import gplx.xowa.wikis.data.tbls.*;
|
||||
import gplx.xowa.langs.vnts.*; import gplx.xowa.guis.views.*; import gplx.xowa.wikis.pages.*; import gplx.xowa.htmls.core.makes.imgs.*;
|
||||
import gplx.xowa.parsers.tmpls.*;
|
||||
public class Xog_redlink_mgr implements GfoInvkAble {
|
||||
private Xog_win_itm win; private Xog_html_itm html_itm; private Xowe_wiki wiki; private Xoae_page page;
|
||||
private Xopg_redlink_lnki_list redlink_lnki_list; private List_adp lnki_list; private boolean log_enabled; private Gfo_usr_dlg usr_dlg; private int thread_id;
|
||||
public Xog_redlink_mgr(Xog_win_itm win, Xoae_page page, boolean log_enabled) {
|
||||
this.win = win; this.page = page; this.wiki = page.Wikie();
|
||||
public class Xog_redlink_mgr implements Gfo_invk {
|
||||
private Gfo_usr_dlg usr_dlg; private Xog_html_itm html_itm; private Xowe_wiki wiki; private Xoae_page page;
|
||||
private Xopg_redlink_lnki_list redlink_lnki_list; private List_adp lnki_list; private int thread_id;
|
||||
public Xog_redlink_mgr(Xoae_page page) {
|
||||
this.page = page; this.wiki = page.Wikie();
|
||||
this.html_itm = page.Tab_data().Tab().Html_itm(); // NOTE: caching locally b/c page.Tab() is sometimes null
|
||||
this.redlink_lnki_list = page.Redlink_lnki_list();
|
||||
this.lnki_list = redlink_lnki_list.Lnki_list();
|
||||
this.thread_id = redlink_lnki_list.Thread_id();
|
||||
this.log_enabled = log_enabled; this.usr_dlg = log_enabled ? Gfo_usr_dlg_.Instance : Gfo_usr_dlg_.Noop;
|
||||
this.usr_dlg = Gfo_usr_dlg_.Instance;
|
||||
}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_run)) Redlink();
|
||||
else return GfoInvkAble_.Rv_unhandled;
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
return this;
|
||||
} public static final String Invk_run = "run";
|
||||
public void Redlink() {
|
||||
synchronized (this) { // NOTE: attempt to eliminate random IndexBounds errors; DATE:2014-09-02
|
||||
if (redlink_lnki_list.Disabled()) return;
|
||||
List_adp work_list = List_adp_.new_();
|
||||
List_adp work_list = List_adp_.New();
|
||||
Ordered_hash page_hash = Ordered_hash_.New_bry();
|
||||
page_hash.Clear(); // NOTE: do not clear in Page_bgn, else will fail b/c of threading; EX: Open Page -> Preview -> Save; DATE:2013-11-17
|
||||
work_list.Clear();
|
||||
int len = lnki_list.Count();
|
||||
if (log_enabled) usr_dlg.Log_many("", "", "redlink.redlink_bgn: page=~{0} total_links=~{1}", String_.new_u8(page.Ttl().Raw()), len);
|
||||
usr_dlg.Log_many("", "", "redlink.redlink_bgn: page=~{0} total_links=~{1}", String_.new_u8(page.Ttl().Raw()), len);
|
||||
for (int i = 0; i < len; i++) { // make a copy of list else thread issues
|
||||
if (win.Usr_dlg().Canceled()) return;
|
||||
if (usr_dlg.Canceled()) return;
|
||||
if (redlink_lnki_list.Thread_id() != thread_id) return;
|
||||
work_list.Add(lnki_list.Get_at(i));
|
||||
}
|
||||
for (int i = 0; i < len; i++) {
|
||||
if (win.Usr_dlg().Canceled()) return;
|
||||
if (usr_dlg.Canceled()) return;
|
||||
if (redlink_lnki_list.Thread_id() != thread_id) return;
|
||||
Xop_lnki_tkn lnki = (Xop_lnki_tkn)work_list.Get_at(i);
|
||||
Xoa_ttl ttl = lnki.Ttl();
|
||||
@@ -62,14 +62,13 @@ public class Xog_redlink_mgr implements GfoInvkAble {
|
||||
}
|
||||
int page_len = page_hash.Count();
|
||||
for (int i = 0; i < page_len; i += Batch_size) {
|
||||
if (win.Usr_dlg().Canceled()) return;
|
||||
if (usr_dlg.Canceled()) return;
|
||||
if (redlink_lnki_list.Thread_id() != thread_id) return;
|
||||
int end = i + Batch_size;
|
||||
if (end > page_len) end = page_len;
|
||||
wiki.Db_mgr().Load_mgr().Load_by_ttls(win.Usr_dlg(), page_hash, Bool_.Y, i, end);
|
||||
wiki.Db_mgr().Load_mgr().Load_by_ttls(usr_dlg, page_hash, Bool_.Y, i, end);
|
||||
}
|
||||
int redlink_count = 0;
|
||||
Bry_bfr bfr = null;
|
||||
boolean variants_enabled = wiki.Lang().Vnt_mgr().Enabled();
|
||||
Xol_vnt_mgr vnt_mgr = wiki.Lang().Vnt_mgr();
|
||||
Xopg_redlink_idx_list redlink_mgr = page.Hdump_data().Redlink_mgr();
|
||||
@@ -90,11 +89,7 @@ public class Xog_redlink_mgr implements GfoInvkAble {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (log_enabled) {
|
||||
if (bfr == null) bfr = Bry_bfr.new_();
|
||||
bfr.Add_int_variable(lnki.Html_uid()).Add_byte_pipe().Add(Xop_tkn_.Lnki_bgn).Add(full_db).Add(Xop_tkn_.Lnki_end).Add_byte(Byte_ascii.Semic).Add_byte_space();
|
||||
}
|
||||
if (win.Usr_dlg().Canceled()) return;
|
||||
if (usr_dlg.Canceled()) return;
|
||||
if (redlink_lnki_list.Thread_id() != thread_id) return;
|
||||
int uid = lnki.Html_uid();
|
||||
gplx.xowa.files.gui.Js_img_mgr.Update_link_missing(html_itm, Xopg_redlink_lnki_list.Lnki_id_prefix + Int_.To_str(uid));
|
||||
@@ -102,11 +97,10 @@ public class Xog_redlink_mgr implements GfoInvkAble {
|
||||
++redlink_count;
|
||||
}
|
||||
}
|
||||
if (log_enabled)
|
||||
usr_dlg.Log_many("", "", "redlink.redlink_end: redlinks_run=~{0} links=~{1}", redlink_count, bfr == null ? String_.Empty : bfr.To_str_and_clear());
|
||||
usr_dlg.Log_many("", "", "redlink.redlink_end: redlinks_run=~{0}", redlink_count);
|
||||
}
|
||||
}
|
||||
public static final Xog_redlink_mgr Null = new Xog_redlink_mgr(); Xog_redlink_mgr() {}
|
||||
public static final Xog_redlink_mgr Null = new Xog_redlink_mgr(); Xog_redlink_mgr() {}
|
||||
private static final int Batch_size = 32;
|
||||
}
|
||||
class Xog_redlink_wkr {
|
||||
|
||||
@@ -23,8 +23,8 @@ public class Xopg_redlink_lnki_list {
|
||||
public Xopg_redlink_lnki_list(boolean ttl_is_module) { // never redlink in Module ns; particularly since Lua has multi-line comments for [[ ]]
|
||||
this.disabled = ttl_is_module;
|
||||
}
|
||||
public boolean Disabled() {return disabled;} private final boolean disabled;
|
||||
public List_adp Lnki_list() {return lnki_list;} private final List_adp lnki_list = List_adp_.new_();
|
||||
public boolean Disabled() {return disabled;} private final boolean disabled;
|
||||
public List_adp Lnki_list() {return lnki_list;} private final List_adp lnki_list = List_adp_.New();
|
||||
public int Thread_id() {return thread_id;} private int thread_id = 1;
|
||||
public void Clear() {
|
||||
if (disabled) return;
|
||||
@@ -47,5 +47,5 @@ public class Xopg_redlink_lnki_list {
|
||||
lnki_list.Add(lnki);
|
||||
}
|
||||
public static final String Lnki_id_prefix = "xolnki_";
|
||||
public static final int Lnki_id_prefix_len = String_.Len(Lnki_id_prefix);
|
||||
public static final int Lnki_id_prefix_len = String_.Len(Lnki_id_prefix);
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ package gplx.xowa.parsers.logs; import gplx.*; import gplx.xowa.*; import gplx.x
|
||||
import gplx.core.envs.*;
|
||||
import gplx.dbs.*;
|
||||
import gplx.xowa.parsers.xndes.*; import gplx.xowa.parsers.htmls.*;
|
||||
public class Xop_log_basic_wkr implements GfoInvkAble {
|
||||
public class Xop_log_basic_wkr implements Gfo_invk {
|
||||
private Xop_log_mgr log_mgr; private Xop_log_basic_tbl log_tbl;
|
||||
private boolean save_page_ttl, save_log_time, save_args_len, save_args_str;
|
||||
public boolean Save_src_str() {return save_src_str;} public Xop_log_basic_wkr Save_src_str_(boolean v) {save_src_str = v; return this;} private boolean save_src_str;
|
||||
@@ -53,17 +53,17 @@ public class Xop_log_basic_wkr implements GfoInvkAble {
|
||||
else if (ctx.Match(k, Invk_save_args_len_)) save_args_len = m.ReadYn("v");
|
||||
else if (ctx.Match(k, Invk_save_args_str_)) save_args_str = m.ReadYn("v");
|
||||
else if (ctx.Match(k, Invk_save_src_str_)) save_src_str = m.ReadYn("v");
|
||||
else return GfoInvkAble_.Rv_unhandled;
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
return this;
|
||||
}
|
||||
private static final String
|
||||
Invk_save_page_ttl_ = "save_page_ttl_", Invk_save_log_time_ = "save_log_time_"
|
||||
, Invk_save_args_len_ = "save_args_len_", Invk_save_args_str_ = "save_args_str_", Invk_save_src_str_ = "save_src_str_"
|
||||
;
|
||||
public static final Xop_log_basic_wkr Null = null;
|
||||
public static final Xop_log_basic_wkr Null = null;
|
||||
public static final int Null_page_id = -1, Null_log_bgn = -1, Null_log_time = -1, Null_args_len = -1, Null_src_len = -1;
|
||||
public static final String Null_page_ttl = "", Null_args_str = "", Null_src_str = "";
|
||||
public static final byte[] Null_log_msg = null;
|
||||
public static final byte[] Null_log_msg = null;
|
||||
public static final int
|
||||
Tid_gallery = 1
|
||||
, Tid_imageMap = 2
|
||||
|
||||
@@ -19,12 +19,12 @@ package gplx.xowa.parsers.logs; import gplx.*; import gplx.xowa.*; import gplx.x
|
||||
import gplx.core.envs.*;
|
||||
import gplx.dbs.*; import gplx.dbs.qrys.*; import gplx.dbs.engines.sqlite.*; import gplx.xowa.parsers.logs.*;
|
||||
import gplx.xowa.xtns.scribunto.*;
|
||||
public class Xop_log_invoke_wkr implements GfoInvkAble {
|
||||
public class Xop_log_invoke_wkr implements Gfo_invk {
|
||||
private Xop_log_mgr log_mgr;
|
||||
private Db_conn conn; private Db_stmt stmt;
|
||||
private boolean log_enabled = true;
|
||||
private Hash_adp_bry exclude_mod_names = Hash_adp_bry.cs();
|
||||
public Scrib_err_filter_mgr Err_filter_mgr() {return err_filter_mgr;} private final Scrib_err_filter_mgr err_filter_mgr = new Scrib_err_filter_mgr();
|
||||
public Scrib_err_filter_mgr Err_filter_mgr() {return err_filter_mgr;} private final Scrib_err_filter_mgr err_filter_mgr = new Scrib_err_filter_mgr();
|
||||
public Xop_log_invoke_wkr(Xop_log_mgr log_mgr, Db_conn conn) {
|
||||
this.log_mgr = log_mgr;
|
||||
this.conn = conn;
|
||||
@@ -53,7 +53,7 @@ public class Xop_log_invoke_wkr implements GfoInvkAble {
|
||||
if (ctx.Match(k, Invk_exclude_mod_names_add)) Exclude_mod_names_add(m.ReadStrAry("v", "|"));
|
||||
else if (ctx.Match(k, Invk_log_enabled_)) log_enabled = m.ReadYn("v");
|
||||
else if (ctx.Match(k, Invk_err_filter)) return err_filter_mgr;
|
||||
else return GfoInvkAble_.Rv_unhandled;
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
return this;
|
||||
}
|
||||
private static final String Invk_exclude_mod_names_add = "exclude_mod_names_add", Invk_log_enabled_ = "log_enabled_", Invk_err_filter = "err_filter";
|
||||
@@ -71,7 +71,7 @@ class Xop_log_invoke_tbl {
|
||||
.Exec_insert();
|
||||
}
|
||||
public static final String Tbl_name = "log_invoke_temp", Fld_invk_page_ttl = "invk_page_ttl", Fld_invk_mod_name = "invk_mod_name", Fld_invk_fnc_name = "invk_fnc_name", Fld_invk_eval_time = "invk_eval_time";
|
||||
private static final String Tbl_sql = String_.Concat_lines_nl
|
||||
private static final String Tbl_sql = String_.Concat_lines_nl
|
||||
( "CREATE TABLE IF NOT EXISTS log_invoke_temp"
|
||||
, "( invk_id integer NOT NULL PRIMARY KEY AUTOINCREMENT"
|
||||
, ", invk_page_ttl varchar(255) NOT NULL"
|
||||
|
||||
@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.parsers.logs; import gplx.*; import gplx.xowa.*; import gplx.xowa.parsers.*;
|
||||
import gplx.dbs.*; import gplx.xowa.bldrs.*;
|
||||
public class Xop_log_mgr implements GfoInvkAble {
|
||||
public class Xop_log_mgr implements Gfo_invk {
|
||||
private Db_conn conn;
|
||||
private Xoae_app app; private Xop_log_basic_tbl log_tbl;
|
||||
private int exec_count = 0, commit_interval = 1000;
|
||||
@@ -61,7 +61,7 @@ public class Xop_log_mgr implements GfoInvkAble {
|
||||
}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_commit_interval_)) commit_interval = m.ReadInt("v");
|
||||
else return GfoInvkAble_.Rv_unhandled;
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
return this;
|
||||
}
|
||||
private static final String Invk_commit_interval_ = "commit_interval_";
|
||||
|
||||
@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.parsers.logs; import gplx.*; import gplx.xowa.*; import gplx.xowa.parsers.*;
|
||||
import gplx.core.envs.*;
|
||||
import gplx.dbs.*; import gplx.dbs.qrys.*; import gplx.dbs.engines.sqlite.*;
|
||||
public class Xop_log_property_wkr implements GfoInvkAble {
|
||||
public class Xop_log_property_wkr implements Gfo_invk {
|
||||
private Xop_log_mgr log_mgr; private Db_conn conn; private Db_stmt stmt;
|
||||
private boolean log_enabled = true;
|
||||
private boolean include_all = true;
|
||||
@@ -51,7 +51,7 @@ public class Xop_log_property_wkr implements GfoInvkAble {
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_include_props_add)) Include_props_add(m.ReadStrAry("v", "|"));
|
||||
else if (ctx.Match(k, Invk_log_enabled_)) log_enabled = m.ReadYn("v");
|
||||
else return GfoInvkAble_.Rv_unhandled;
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
return this;
|
||||
} private static final String Invk_include_props_add = "include_props_add", Invk_log_enabled_ = "log_enabled_";
|
||||
}
|
||||
@@ -67,7 +67,7 @@ class Xob_log_property_temp_tbl {
|
||||
.Exec_insert();
|
||||
}
|
||||
public static final String Tbl_name = "log_property_temp", Fld_prop_page_ttl = "prop_page_ttl", Fld_prop_prop_name = "prop_prop_name", Fld_prop_eval_time = "prop_eval_time";
|
||||
private static final String Tbl_sql = String_.Concat_lines_nl
|
||||
private static final String Tbl_sql = String_.Concat_lines_nl
|
||||
( "CREATE TABLE IF NOT EXISTS log_property_temp"
|
||||
, "( prop_id integer NOT NULL PRIMARY KEY AUTOINCREMENT"
|
||||
, ", prop_page_ttl varchar(255) NOT NULL"
|
||||
|
||||
@@ -31,5 +31,5 @@ NOTE_1:tabs
|
||||
.. note that they all need to be ws in order to be trimmed out
|
||||
.. note that shrinking the src[] would be (a) memory-expensive (b) complexity-expensive (many functions assume a static src size)
|
||||
.. note that "\t\t\t\t\t" was the 1st attempt, but this resulted in exponential growth of "\t"s with each save (1 -> 5 -> 25 -> 125). "\t\s\s\s\s" is less worse with its linear growth (1 -> 5 -> 10)
|
||||
. TODO: swap out the "	" at point of file-read;
|
||||
. TODO_OLD: swap out the "	" at point of file-read;
|
||||
*/
|
||||
@@ -20,7 +20,7 @@ import gplx.core.btries.*; import gplx.xowa.langs.*;
|
||||
import gplx.xowa.parsers.xndes.*;
|
||||
public class Xop_hr_lxr implements Xop_lxr {
|
||||
public int Lxr_tid() {return Xop_lxr_.Tid_hr;}
|
||||
public void Init_by_wiki(Xowe_wiki wiki, Btrie_fast_mgr parse_trie) {parse_trie.Add(Hook_ary, this);} static final byte[] Hook_ary = new byte[] {Byte_ascii.Nl, Byte_ascii.Dash, Byte_ascii.Dash, Byte_ascii.Dash, Byte_ascii.Dash};
|
||||
public void Init_by_wiki(Xowe_wiki wiki, Btrie_fast_mgr parse_trie) {parse_trie.Add(Hook_ary, this);} static final byte[] Hook_ary = new byte[] {Byte_ascii.Nl, Byte_ascii.Dash, Byte_ascii.Dash, Byte_ascii.Dash, Byte_ascii.Dash};
|
||||
public void Init_by_lang(Xol_lang_itm lang, Btrie_fast_mgr core_trie) {}
|
||||
public void Term(Btrie_fast_mgr core_trie) {}
|
||||
public int Make_tkn(Xop_ctx ctx, Xop_tkn_mkr tkn_mkr, Xop_root_tkn root, byte[] src, int src_len, int bgn_pos, int cur_pos) {
|
||||
@@ -36,11 +36,11 @@ public class Xop_hr_lxr implements Xop_lxr {
|
||||
if (!bos)
|
||||
ctx.Para().Process_nl(ctx, root, src, bgn_pos, bgn_pos); // simulate \n in front of ----
|
||||
ctx.Para().Process_block__bgn_y__end_n(Xop_xnde_tag_.Tag__hr); // para=n; block=y
|
||||
int hr_len = cur_pos - bgn_pos + nl_adj; // TODO: syntax_check if > 4
|
||||
int hr_len = cur_pos - bgn_pos + nl_adj; // TODO_OLD: syntax_check if > 4
|
||||
ctx.Subs_add(root, tkn_mkr.Hr(bgn_pos, cur_pos, hr_len));
|
||||
ctx.Para().Process_block__bgn_n__end_y(Xop_xnde_tag_.Tag__hr); // block=n; para=y;
|
||||
return cur_pos;
|
||||
} private static final byte Hook_byt = Byte_ascii.Dash;
|
||||
public static final int Hr_len = 4;
|
||||
public static final Xop_hr_lxr Instance = new Xop_hr_lxr(); Xop_hr_lxr() {}
|
||||
public static final Xop_hr_lxr Instance = new Xop_hr_lxr(); Xop_hr_lxr() {}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ import gplx.core.btries.*;
|
||||
public class Xop_tab_tkn extends Xop_tkn_itm_base {
|
||||
public Xop_tab_tkn(int bgn, int end) {this.Tkn_ini_pos(false, bgn, end);}
|
||||
@Override public byte Tkn_tid() {return Xop_tkn_itm_.Tid_tab;}
|
||||
public static final byte[] Bry_tab_ent = Bry_.new_a7("	");
|
||||
public static final byte[] Bry_tab_ent = Bry_.new_a7("	");
|
||||
}
|
||||
/*
|
||||
NOTE_1:tabs
|
||||
@@ -33,5 +33,5 @@ NOTE_1:tabs
|
||||
.. note that they all need to be ws in order to be trimmed out
|
||||
.. note that shrinking the src[] would be (a) memory-expensive (b) complexity-expensive (many functions assume a static src size)
|
||||
.. note that "\t\t\t\t\t" was the 1st attempt, but this resulted in exponential growth of "\t"s with each save (1 -> 5 -> 25 -> 125). "\t\s\s\s\s" is less worse with its linear growth (1 -> 5 -> 10)
|
||||
. TODO: swap out the "	" at point of file-read;
|
||||
. TODO_OLD: swap out the "	" at point of file-read;
|
||||
*/
|
||||
@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.parsers.mws.wkrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.parsers.*; import gplx.xowa.parsers.mws.*;
|
||||
import org.junit.*;
|
||||
public class Xomw_hdr_wkr_tst {
|
||||
private final Xomw_hdr_wkr_fxt fxt = new Xomw_hdr_wkr_fxt();
|
||||
private final Xomw_hdr_wkr_fxt fxt = new Xomw_hdr_wkr_fxt();
|
||||
@Test public void Basic() {
|
||||
fxt.Test__parse("==A==" , "<h2>A</h2>");
|
||||
fxt.Test__parse("abc\n==A==\ndef" , "abc\n<h2>A</h2>\ndef");
|
||||
@@ -29,8 +29,8 @@ public class Xomw_hdr_wkr_tst {
|
||||
}
|
||||
}
|
||||
class Xomw_hdr_wkr_fxt {
|
||||
private final Xomw_hdr_wkr wkr = new Xomw_hdr_wkr();
|
||||
private final Bry_bfr bfr = Bry_bfr.new_(); private final Xomw_parser_ctx pctx = new Xomw_parser_ctx();
|
||||
private final Xomw_hdr_wkr wkr = new Xomw_hdr_wkr();
|
||||
private final Bry_bfr bfr = Bry_bfr_.New(); private final Xomw_parser_ctx pctx = new Xomw_parser_ctx();
|
||||
public void Test__parse(String src_str, String expd) {
|
||||
byte[] src_bry = Bry_.new_u8(src_str);
|
||||
wkr.Parse(bfr, pctx, src_bry, -1, src_bry.length);
|
||||
|
||||
@@ -41,7 +41,7 @@ public class Xop_tblw_lxr implements Xop_lxr {
|
||||
int lnki_pos = ctx.Stack_idx_typ(Xop_tkn_itm_.Tid_lnki);
|
||||
if (lnki_pos != Xop_ctx.Stack_not_found && wlxr_type == Xop_tblw_wkr.Tblw_type_td) {// lnki present;// NOTE: added Xop_tblw_wkr.Tblw_type_td b/c th should not apply when tkn_mkr.Pipe() is called below; DATE:2013-04-24
|
||||
Xop_tkn_itm lnki_tkn = ctx.Stack_pop_til(root, src, lnki_pos, false, bgn_pos, cur_pos, Xop_tkn_itm_.Tid_tblw_td); // pop any intervening nodes until lnki
|
||||
ctx.Stack_add(lnki_tkn); // push lnki back onto stack; TODO: combine these 2 lines into 1
|
||||
ctx.Stack_add(lnki_tkn); // push lnki back onto stack; TODO_OLD: combine these 2 lines into 1
|
||||
// NOTE: this is a "\n|" inside a [[ ]]; must create two tokens for lnki to build correctly;
|
||||
ctx.Subs_add(root, tkn_mkr.NewLine(bgn_pos, bgn_pos + 1, Xop_nl_tkn.Tid_char, 1));
|
||||
return Xop_pipe_lxr.Instance.Make_tkn(ctx, tkn_mkr, root, src, src_len, bgn_pos, cur_pos); // NOTE: need to call pipe_lxr in order to invalidate if lnki; DATE:2014-06-06
|
||||
@@ -118,7 +118,7 @@ public class Xop_tblw_lxr implements Xop_lxr {
|
||||
return Continue;
|
||||
}
|
||||
public Xop_tblw_lxr(byte wlxr_type) {this.wlxr_type = wlxr_type;} private byte wlxr_type;
|
||||
public static final Xop_tblw_lxr Instance = new Xop_tblw_lxr(); Xop_tblw_lxr() {}
|
||||
public static final Xop_tblw_lxr Instance = new Xop_tblw_lxr(); Xop_tblw_lxr() {}
|
||||
public void Init_by_wiki(Xowe_wiki wiki, Btrie_fast_mgr core_trie) {
|
||||
core_trie.Add(Hook_tb, new Xop_tblw_lxr(Xop_tblw_wkr.Tblw_type_tb));
|
||||
core_trie.Add(Hook_te, new Xop_tblw_lxr(Xop_tblw_wkr.Tblw_type_te));
|
||||
@@ -131,7 +131,7 @@ public class Xop_tblw_lxr implements Xop_lxr {
|
||||
}
|
||||
public void Init_by_lang(Xol_lang_itm lang, Btrie_fast_mgr core_trie) {}
|
||||
public void Term(Btrie_fast_mgr core_trie) {}
|
||||
public static final byte[] Hook_tb = Bry_.new_a7("\n{|"), Hook_te = Bry_.new_a7("\n|}"), Hook_tr = Bry_.new_a7("\n|-")
|
||||
public static final byte[] Hook_tb = Bry_.new_a7("\n{|"), Hook_te = Bry_.new_a7("\n|}"), Hook_tr = Bry_.new_a7("\n|-")
|
||||
, Hook_td = Bry_.new_a7("\n|"), Hook_th = Bry_.new_a7("\n!"), Hook_tc = Bry_.new_a7("\n|+")
|
||||
, Hook_td2 = Bry_.new_a7("||"), Hook_th2 = Bry_.new_a7("!!");
|
||||
}
|
||||
|
||||
@@ -281,7 +281,7 @@ public class Xop_tblw_wkr implements Xop_ctx_wkr {
|
||||
case Tblw_type_tc: // <caption>
|
||||
switch (prv_tid) {
|
||||
case Xop_tkn_itm_.Tid_tblw_tb: break; // noop; <table><caption>
|
||||
case Xop_tkn_itm_.Tid_tblw_tr: // fix; <tr><caption> -> <tr></tr><caption> TODO: caption should be ignored and placed in quarantine
|
||||
case Xop_tkn_itm_.Tid_tblw_tr: // fix; <tr><caption> -> <tr></tr><caption> TODO_OLD: caption should be ignored and placed in quarantine
|
||||
ctx.Stack_pop_til(root, src, ctx.Stack_idx_typ(Xop_tkn_itm_.Tid_tblw_tr), true, bgn_pos, bgn_pos, Xop_tkn_itm_.Tid_tblw_td);
|
||||
break;
|
||||
case Xop_tkn_itm_.Tid_tblw_td: // fix; <td><caption> -> <td></td><caption>
|
||||
|
||||
@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.parsers.tblws; import gplx.*; import gplx.xowa.*; import gplx.xowa.parsers.*;
|
||||
import org.junit.*;
|
||||
public class Xop_tblw_wkr__basic_tst {
|
||||
private final Xop_fxt fxt = new Xop_fxt();
|
||||
private final Xop_fxt fxt = new Xop_fxt();
|
||||
@Test public void Td() { // Tb_tr_td_te
|
||||
fxt.Test_parse_page_wiki("{|\n|-\n|a\n|}"
|
||||
, fxt.tkn_tblw_tb_(0, 11).Subs_
|
||||
@@ -725,7 +725,7 @@ public class Xop_tblw_wkr__basic_tst {
|
||||
));
|
||||
}
|
||||
}
|
||||
// @Test public void Tb_under_tr_is_ignored() { // PURPOSE: table directly under tr is ignored; PAGE:en.w:Category:Dessert stubs; TODO: complicated, especially to handle 2nd |}
|
||||
// @Test public void Tb_under_tr_is_ignored() { // PURPOSE: table directly under tr is ignored; PAGE:en.w:Category:Dessert stubs; TODO_OLD: complicated, especially to handle 2nd |}
|
||||
// fxt.Test_parse_page_wiki_str(String_.Concat_lines_nl_skip_last
|
||||
// ( "{|"
|
||||
// , "|-id='a'"
|
||||
|
||||
@@ -18,7 +18,7 @@ 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.*;
|
||||
public class Xop_tkn_print_tst {
|
||||
private final Xop_fxt fxt = new Xop_fxt();
|
||||
private final Xop_fxt fxt = new Xop_fxt();
|
||||
@Test public void Text() {tst_Print("a ''b'' c [[d]] e");}
|
||||
@Test public void Prm() {tst_Print("{{{1}}}");}
|
||||
@Test public void Prm_dflt() {tst_Print("{{{1|a}}}");}
|
||||
@@ -36,5 +36,5 @@ public class Xop_tkn_print_tst {
|
||||
defn.Root().Tmpl_fmt(ctx, raw_bry, raw_fmtr);
|
||||
raw_fmtr.Print(tst_Print_bb);
|
||||
Tfds.Eq(raw, tst_Print_bb.To_str_and_clear());
|
||||
} private Bry_bfr tst_Print_bb = Bry_bfr.new_();
|
||||
} private Bry_bfr tst_Print_bb = Bry_bfr_.New();
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ public class Xot_defn_tmpl_ {
|
||||
}
|
||||
private static Arg_itm_tkn Make_itm(boolean val_tkn, Xop_ctx ctx, Xop_tkn_mkr tkn_mkr, byte[] src, Arg_itm_tkn orig, Xot_invk caller, Arg_nde_tkn orig_arg) {
|
||||
int subs_len = orig.Subs_len();
|
||||
Bry_bfr arg_bfr = Bry_bfr.new_();
|
||||
Bry_bfr arg_bfr = Bry_bfr_.New();
|
||||
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
|
||||
|
||||
@@ -30,7 +30,7 @@ public class Xot_defn_trace_brief_tst {
|
||||
@Test public void Basic_a_b() {fxt.tst_("{{leaf_a}} {{leaf_b}}" , "0001 leaf_a", "0001 leaf_b");}
|
||||
}
|
||||
class Xot_defn_trace_fxt {
|
||||
private final Xop_fxt fxt = new Xop_fxt();
|
||||
private final Xop_fxt fxt = new Xop_fxt();
|
||||
public Xop_ctx Ctx() {return fxt.Ctx();}
|
||||
public void Init_defn_clear() {fxt.Init_defn_clear();}
|
||||
public void Init_defn_add(String name, String raw) {fxt.Init_defn_add(name, raw);}
|
||||
@@ -44,7 +44,7 @@ class Xot_defn_trace_fxt {
|
||||
ctx.Defn_trace().Print(src, tmp);
|
||||
String[] actl_ary = String_.Split(tmp.To_str_and_clear(), (char)Byte_ascii.Nl);
|
||||
Tfds.Eq_ary(expd_ary, actl_ary);
|
||||
} private Bry_bfr tmp = Bry_bfr.new_();
|
||||
} private Bry_bfr tmp = Bry_bfr_.New();
|
||||
String[] To_str(Xot_defn_trace_itm_brief[] ary) {
|
||||
String[] rv = new String[ary.length];
|
||||
for (int i = 0; i < rv.length; i++) {
|
||||
|
||||
@@ -107,7 +107,7 @@ public class Xot_defn_trace_dbg implements Xot_defn_trace {
|
||||
// Fmt(ctx, defn_tmpl.Src(), root, Ary_fmt_lbl , invk, true);
|
||||
Fmt(ctx, defn_tmpl.Data_raw(), root, Ary_eval_lbl, invk, false);
|
||||
}
|
||||
} private Bry_bfr bfr = Bry_bfr.new_(128); List_adp argKeys = List_adp_.new_(); Xot_fmtr_prm prm_fmtr = new Xot_fmtr_prm();
|
||||
} private Bry_bfr bfr = Bry_bfr_.New_w_size(128); List_adp argKeys = List_adp_.New(); Xot_fmtr_prm prm_fmtr = new Xot_fmtr_prm();
|
||||
private void Fmt(Xop_ctx ctx, byte[] src, Xop_tkn_itm root, byte[] lbl, Xot_invk caller, boolean newLineArgs) {
|
||||
bfr.Add_byte_repeat(Byte_ascii.Space, indent).Add(lbl);
|
||||
bfr.Add_byte_repeat(Byte_ascii.Space, indent);
|
||||
@@ -133,8 +133,8 @@ public class Xot_defn_trace_dbg implements Xot_defn_trace {
|
||||
}
|
||||
public void Clear() {bfr.Clear(); indent = 0; count = 0;}
|
||||
int indent = 0, count = 0;
|
||||
public static final Xot_defn_trace_dbg Instance = new Xot_defn_trace_dbg(); Xot_defn_trace_dbg() {}
|
||||
private static final byte[] Ary_invk_lbl = Bry_.new_a7("*invk\n"), Ary_lnk_lbl = Bry_.new_a7("*lnk: "), Ary_args_lbl = Bry_.new_a7("*args\n")
|
||||
public static final Xot_defn_trace_dbg Instance = new Xot_defn_trace_dbg(); Xot_defn_trace_dbg() {}
|
||||
private static final byte[] Ary_invk_lbl = Bry_.new_a7("*invk\n"), Ary_lnk_lbl = Bry_.new_a7("*lnk: "), Ary_args_lbl = Bry_.new_a7("*args\n")
|
||||
, Ary_result_lbl = Bry_.new_a7("*result\n")
|
||||
, Ary_eval_lbl = Bry_.new_a7("*eval\n")
|
||||
, Ary_source_lbl = Bry_.new_a7("*source\n");
|
||||
|
||||
@@ -43,7 +43,7 @@ class Xot_fmtr_prm implements Xot_fmtr {
|
||||
}
|
||||
else // invk mode
|
||||
self.Tmpl_evaluate(ctx, src, caller, trg);
|
||||
} static final byte[] Bry_bgn = new byte[] {Byte_ascii.Curly_bgn, Byte_ascii.Curly_bgn, Byte_ascii.Curly_bgn}, Bry_end = new byte[] {Byte_ascii.Curly_end, Byte_ascii.Curly_end, Byte_ascii.Curly_end};
|
||||
} static final byte[] Bry_bgn = new byte[] {Byte_ascii.Curly_bgn, Byte_ascii.Curly_bgn, Byte_ascii.Curly_bgn}, Bry_end = new byte[] {Byte_ascii.Curly_end, Byte_ascii.Curly_end, Byte_ascii.Curly_end};
|
||||
public void Reg_tmpl(Xop_ctx ctx, byte[] src, Xop_tkn_itm name_tkn, int args_len, Arg_nde_tkn[] args) {
|
||||
trg.Add(Xop_curly_bgn_lxr.Hook);
|
||||
++depth;
|
||||
@@ -70,6 +70,6 @@ class Xot_fmtr_prm implements Xot_fmtr {
|
||||
self_tkn.Val_tkn().Tmpl_fmt(ctx, src, this);
|
||||
}
|
||||
public void Print(Bry_bfr bb) {bb.Add_bfr_and_preserve(trg); trg.Clear(); depth = 0;}
|
||||
Bry_bfr trg = Bry_bfr.new_(); int depth = 0;
|
||||
public static final Xot_fmtr_prm Instance = new Xot_fmtr_prm();
|
||||
Bry_bfr trg = Bry_bfr_.New(); int depth = 0;
|
||||
public static final Xot_fmtr_prm Instance = new Xot_fmtr_prm();
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ package gplx.xowa.parsers.tmpls; import gplx.*; import gplx.xowa.*; import gplx.
|
||||
import gplx.core.primitives.*;
|
||||
import gplx.xowa.xtns.scribunto.*;
|
||||
public class Xot_invk_temp implements Xot_invk {
|
||||
private List_adp list = List_adp_.new_();
|
||||
private List_adp list = List_adp_.New();
|
||||
private Hash_adp_bry arg_key_hash;
|
||||
private Hash_adp arg_idx_hash; private Int_obj_ref arg_idx_ref;
|
||||
Xot_invk_temp() {}
|
||||
@@ -59,12 +59,12 @@ public class Xot_invk_temp implements Xot_invk {
|
||||
public void Args_add_by_idx(Arg_nde_tkn arg) {Arg_idx_hash_add(++args_add_by_idx, arg);} private int args_add_by_idx = -1; // NOTE: args_add_by_idx needs to be a separate variable; keeps track of args which don't have a key;
|
||||
private void Arg_idx_hash_add(int int_key, Arg_nde_tkn arg) {
|
||||
if (arg_idx_hash == null) {
|
||||
arg_idx_hash = Hash_adp_.new_();
|
||||
arg_idx_ref = Int_obj_ref.neg1_();
|
||||
arg_idx_hash = Hash_adp_.New();
|
||||
arg_idx_ref = Int_obj_ref.New_neg1();
|
||||
}
|
||||
arg_idx_hash.Add_if_dupe_use_nth(Int_obj_ref.new_(int_key), arg); // Add_if_dupe_use_nth to keep latest version; needed for {{A|1=a|1=b}} DATE:2014-07-23
|
||||
arg_idx_hash.Add_if_dupe_use_nth(Int_obj_ref.New(int_key), arg); // Add_if_dupe_use_nth to keep latest version; needed for {{A|1=a|1=b}} DATE:2014-07-23
|
||||
}
|
||||
public static final Xot_invk_temp Page_is_caller = new Xot_invk_temp(true); // SEE NOTE_2
|
||||
public static final Xot_invk_temp Page_is_caller = new Xot_invk_temp(true); // SEE NOTE_2
|
||||
}
|
||||
/*
|
||||
NOTE_1:
|
||||
|
||||
@@ -58,7 +58,7 @@ public class Xot_invk_tkn extends Xop_tkn_itm_base implements Xot_invk {
|
||||
boolean name_had_subst = false;
|
||||
if (defn == Xot_defn_.Null) { // tmpl_name is not exact match; may be dynamic, subst, transclusion, etc..
|
||||
if (name_key_tkn.Itm_static() == Bool_.N_byte) { // tmpl is dynamic; EX:{{{{{1}}}|a}}
|
||||
Bry_bfr name_tkn_bfr = Bry_bfr.new_(name_tkn.Src_end() - name_tkn.Src_bgn());
|
||||
Bry_bfr name_tkn_bfr = Bry_bfr_.New_w_size(name_tkn.Src_end() - name_tkn.Src_bgn());
|
||||
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);
|
||||
@@ -311,7 +311,7 @@ public class Xot_invk_tkn extends Xop_tkn_itm_base implements Xot_invk {
|
||||
defn_func.Eval_argx(ctx, src, caller, invk);
|
||||
if (defn_func_id == Xol_kwd_grp_.Id_invoke) // NOTE: if #invoke, set frame_ttl to argx, not name; EX:{{#invoke:A}}
|
||||
invk.Frame_ttl_(Bry_.Add(Xow_ns_.Bry__module_w_colon, Xoa_ttl.Replace_unders(defn_func.Argx_dat()))); // NOTE: always prepend "Module:" to frame_ttl; DATE:2014-06-13; NOTE: always use spaces; DATE:2014-08-14; always use canonical English "Module"; DATE:2015-11-09
|
||||
Bry_bfr bfr_func = Bry_bfr.new_();
|
||||
Bry_bfr bfr_func = Bry_bfr_.New();
|
||||
defn_func.Func_evaluate(bfr_func, ctx, caller, invk, src);
|
||||
if (caller.Rslt_is_redirect()) // do not prepend if page is redirect; EX:"#REDIRECT" x> "\n#REDIRECT" DATE:2014-07-11
|
||||
caller.Rslt_is_redirect_(false); // reset flag; needed for TEST; kludgy, but Rslt_is_redirect is intended for single use
|
||||
@@ -363,7 +363,7 @@ public class Xot_invk_tkn extends Xop_tkn_itm_base implements Xot_invk {
|
||||
private boolean Eval_sub(Xop_ctx ctx, Xot_defn_tmpl transclude_tmpl, Xot_invk caller, byte[] src, Bry_bfr doc) {
|
||||
boolean rv = false;
|
||||
Xot_invk tmp_tmpl = Xot_defn_tmpl_.CopyNew(ctx, transclude_tmpl, this, caller, src, transclude_tmpl.Name());
|
||||
Bry_bfr tmp_bfr = Bry_bfr.new_();
|
||||
Bry_bfr tmp_bfr = Bry_bfr_.New();
|
||||
Xopg_tmpl_prepend_mgr prepend_mgr = ctx.Page().Tmpl_prepend_mgr().Bgn(doc);
|
||||
rv = transclude_tmpl.Tmpl_evaluate(ctx, tmp_tmpl, tmp_bfr);
|
||||
prepend_mgr.End(ctx, doc, tmp_bfr.Bfr(), tmp_bfr.Len(), Bool_.Y);
|
||||
|
||||
@@ -44,7 +44,7 @@ public class Xot_prm_tkn extends Xop_tkn_itm_base {
|
||||
@Override public boolean Tmpl_evaluate(Xop_ctx ctx, byte[] src, Xot_invk caller, Bry_bfr bfr) {
|
||||
if (!find_tkn_static) {
|
||||
int subs_len = find_tkn.Subs_len();
|
||||
Bry_bfr find_bfr = Bry_bfr.new_();
|
||||
Bry_bfr find_bfr = Bry_bfr_.New();
|
||||
for (int i = 0; i < subs_len; i++)
|
||||
find_tkn.Subs_get(i).Tmpl_evaluate(ctx, src, caller, find_bfr);
|
||||
prm_idx = Bry_.To_int_or__trim_ws(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
|
||||
@@ -67,7 +67,7 @@ public class Xot_prm_tkn extends Xop_tkn_itm_base {
|
||||
if (arg_val.Itm_static() == Bool_.Y_byte)
|
||||
bfr.Add_mid(src, arg_val.Dat_bgn(), arg_val.Dat_end());
|
||||
else {// compile arg if dynamic; EX: [[MESSENGER]] "{{About|the NASA space mission||Messenger (disambiguation){{!}}Messenger}}"; {{!}} causes {{{2}}} to be dynamic and its dat_ary will be an empty-String ("")
|
||||
Bry_bfr arg_val_bfr = Bry_bfr.new_();
|
||||
Bry_bfr arg_val_bfr = Bry_bfr_.New();
|
||||
arg_val.Tmpl_evaluate(ctx, src, caller, arg_val_bfr);
|
||||
bfr.Add_bfr_and_clear(arg_val_bfr);
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ public class Xot_tmpl_wtr {
|
||||
switch (xnde_tag_id) {
|
||||
case Xop_xnde_tag_.Tid__onlyinclude: {
|
||||
// NOTE: originally "if (ctx.Parse_tid() == Xop_parser_.Parse_tid_page_tmpl) {" but if not needed; Xot_tmpl_wtr should not be called for tmpls and <oi> should not make it to page_wiki
|
||||
Bry_bfr tmp_bfr = Bry_bfr.new_();
|
||||
Bry_bfr tmp_bfr = Bry_bfr_.New();
|
||||
ctx.Only_include_evaluate_(true);
|
||||
xnde.Tmpl_evaluate(ctx, src, Xot_invk_temp.Page_is_caller, tmp_bfr);
|
||||
ctx.Only_include_evaluate_(false);
|
||||
@@ -110,5 +110,5 @@ public class Xot_tmpl_wtr {
|
||||
}
|
||||
}
|
||||
public static String Err_string = "";
|
||||
public static final Xot_tmpl_wtr Instance = new Xot_tmpl_wtr(); Xot_tmpl_wtr() {}
|
||||
public static final Xot_tmpl_wtr Instance = new Xot_tmpl_wtr(); Xot_tmpl_wtr() {}
|
||||
}
|
||||
|
||||
@@ -18,8 +18,8 @@ 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 gplx.core.btries.*;
|
||||
public class Xop_uniq_mgr { // REF.MW:/parser/StripState.php
|
||||
private final Btrie_slim_mgr general_trie = Btrie_slim_mgr.cs();
|
||||
private final Bry_bfr key_bfr = Bry_bfr.new_(32);
|
||||
private final Btrie_slim_mgr general_trie = Btrie_slim_mgr.cs();
|
||||
private final Bry_bfr key_bfr = Bry_bfr_.New_w_size(32);
|
||||
private int idx = -1;
|
||||
public void Clear() {idx = -1; general_trie.Clear();}
|
||||
public byte[] Add(byte[] val) { // "<b>" -> "\u007fUNIQ-item-1--QINU\u007f"
|
||||
@@ -46,7 +46,7 @@ public class Xop_uniq_mgr { // REF.MW:/parser/StripState.php
|
||||
else {
|
||||
byte[] val = (byte[])o;
|
||||
int new_pos = trie.Match_pos(); // NOTE: since trie is reused, must capture pos here
|
||||
val = Parse(Bry_bfr.new_(), trie, val);
|
||||
val = Parse(Bry_bfr_.New(), trie, val);
|
||||
// val = gplx.xowa.parsers.xndes.Xop_xnde_tkn.Hack_ctx.Wiki().Parser_mgr().Main().Parse_text_to_html(gplx.xowa.parsers.xndes.Xop_xnde_tkn.Hack_ctx, val); // CHART
|
||||
bfr.Add_mid(src, mark_bgn, pos);
|
||||
bfr.Add(val);
|
||||
@@ -68,7 +68,7 @@ public class Xop_uniq_mgr { // REF.MW:/parser/StripState.php
|
||||
}
|
||||
public void Random_int_ary_(int... v) {random_int_ary = v;} private int[] random_int_ary; // TEST:
|
||||
public byte[] Random_bry_new(int len) {
|
||||
Bry_bfr key_bfr = Bry_bfr.new_();
|
||||
Bry_bfr key_bfr = Bry_bfr_.New();
|
||||
RandomAdp random_gen = RandomAdp_.new_();
|
||||
for (int i = 0; i < len; i += 7) {
|
||||
int rand = random_int_ary == null ? random_gen.Next(Int_.Max_value) : random_int_ary[i / 7];
|
||||
@@ -79,7 +79,7 @@ public class Xop_uniq_mgr { // REF.MW:/parser/StripState.php
|
||||
key_bfr.Clear();
|
||||
return rv;
|
||||
}
|
||||
private final static byte[]
|
||||
private final static byte[]
|
||||
Bry__uniq__bgn = Bry_.new_a7("\u007fUNIQ")
|
||||
// , Bry__uniq__end = Bry_.new_a7("-QINU\u007f")
|
||||
, Bry__uniq__add__bgn = Bry_.new_a7("\u007fUNIQ-item-")
|
||||
|
||||
@@ -52,7 +52,7 @@ class Xop_rule_mgr implements TstRuleMgr {
|
||||
}
|
||||
public String Reg() {return typeKey;}
|
||||
Ordered_hash hash = Ordered_hash_.New();
|
||||
public static final Xop_rule_mgr Instance = new Xop_rule_mgr();
|
||||
public static final Xop_rule_mgr Instance = new Xop_rule_mgr();
|
||||
}
|
||||
class Xop_rule_dat {
|
||||
public String AtrKey() {return atrKey;} private String atrKey;
|
||||
@@ -78,7 +78,7 @@ public class TstObj_tst {
|
||||
}
|
||||
private static int Add(int[] ary) {int rv = 0; for (int i = 0; i < ary.length; i++) rv += ary[i]; return rv;}
|
||||
@gplx.Internal protected static void Eval(String raw, TstObj expdChk, TstObj actlChk, TstRuleMgr ruleMgr) {
|
||||
List_adp rslts = List_adp_.new_();
|
||||
List_adp rslts = List_adp_.New();
|
||||
Eval(rslts, ruleMgr, Ordered_hash_.New(), "", expdChk, actlChk);
|
||||
|
||||
String_bldr sb = String_bldr_.new_();
|
||||
@@ -204,13 +204,13 @@ class TstObj implements SrlMgr {
|
||||
public List_adp Subs() {return subs;} List_adp subs = List_adp_.Noop;
|
||||
public SrlMgr SrlMgr_new(Object o) {return Subs_new();}
|
||||
public TstObj Subs_new() {
|
||||
if (subs == List_adp_.Noop) subs = List_adp_.new_();
|
||||
if (subs == List_adp_.Noop) subs = List_adp_.New();
|
||||
TstObj rv = TstObj.new_();
|
||||
subs.Add(rv);
|
||||
return rv;
|
||||
}
|
||||
public static TstObj new_() {return new TstObj();} TstObj() {}
|
||||
public static final TstObj Null = new TstObj();
|
||||
public static final TstObj Null = new TstObj();
|
||||
}
|
||||
class TstAtr {
|
||||
public String TypeKey() {return typeKey;} public TstAtr TypeKey_(String v) {typeKey = v; return this;} private String typeKey;
|
||||
@@ -229,5 +229,5 @@ class TstRslt {
|
||||
public String Key() {return key;} public TstRslt Key_(String v) {key = v; return this;} private String key;
|
||||
public String ActlStr() {return actlStr;} public TstRslt ActlStr_(String v) {actlStr = v; return this;} private String actlStr;
|
||||
public String ExpdStr() {return expdStr;} public TstRslt ExpdStr_(String v) {expdStr = v; return this;} private String expdStr;
|
||||
public static final Object Ignore_null = new Object();
|
||||
public static final Object Ignore_null = new Object();
|
||||
}
|
||||
@@ -76,7 +76,7 @@ class Xop_redirect_mgr_fxt {
|
||||
Tfds.Eq(expd_str, String_.new_u8(actl_bry));
|
||||
}
|
||||
public void Test__redirected_html(String page_str, String expd_str) {
|
||||
List_adp list = List_adp_.new_();
|
||||
List_adp list = List_adp_.New();
|
||||
list.Add(Bry_.new_u8(page_str));
|
||||
byte[] actl_bry = Xop_redirect_mgr.Bld_redirect_msg(fxt.App(), fxt.Wiki(), list);
|
||||
Tfds.Eq_str(expd_str, String_.new_u8(actl_bry));
|
||||
|
||||
@@ -20,7 +20,7 @@ import gplx.core.btries.*; import gplx.xowa.parsers.amps.*; import gplx.core.log
|
||||
public class Xop_sanitizer {
|
||||
private Btrie_slim_mgr trie = Btrie_slim_mgr.cs(), amp_trie;
|
||||
private Xop_amp_mgr amp_mgr;
|
||||
private Bry_bfr tmp_bfr = Bry_bfr.reset_(255);
|
||||
private Bry_bfr tmp_bfr = Bry_bfr_.Reset(255);
|
||||
public Xop_sanitizer(Xop_amp_mgr amp_mgr, Gfo_msg_log msg_log) {
|
||||
this.amp_mgr = amp_mgr; this.amp_trie = amp_mgr.Amp_trie();
|
||||
trie_add("&" , Tid_amp);
|
||||
|
||||
@@ -20,9 +20,9 @@ import gplx.core.btries.*; import gplx.core.primitives.*; import gplx.dbs.*;
|
||||
import gplx.xowa.langs.vnts.*; import gplx.xowa.langs.vnts.converts.*;
|
||||
import gplx.xowa.parsers.htmls.*;
|
||||
public class Vnt_convert_lang {
|
||||
private final Xol_convert_mgr convert_mgr; private final Xol_vnt_regy vnt_regy;
|
||||
private final Vnt_convert_rule converter_rule; private final Vnt_html_doc_wkr html_convert_wkr; private final Mwh_doc_parser doc_parser = new Mwh_doc_parser();
|
||||
private final Bry_bfr bfr = Bry_bfr.new_(255), tmp_frame_bfr = Bry_bfr.new_(255), tmp_convert_bfr = Bry_bfr.new_(255);
|
||||
private final Xol_convert_mgr convert_mgr; private final Xol_vnt_regy vnt_regy;
|
||||
private final Vnt_convert_rule converter_rule; private final Vnt_html_doc_wkr html_convert_wkr; private final Mwh_doc_parser doc_parser = new Mwh_doc_parser();
|
||||
private final Bry_bfr bfr = Bry_bfr_.New_w_size(255), tmp_frame_bfr = Bry_bfr_.New_w_size(255), tmp_convert_bfr = Bry_bfr_.New_w_size(255);
|
||||
private byte[] src; private int src_len; private int pos;
|
||||
private Vnt_log_mgr log_mgr; private int tag_bgn, tag_end;
|
||||
public Vnt_convert_lang(Xol_convert_mgr convert_mgr, Xol_vnt_regy vnt_regy) {
|
||||
@@ -82,7 +82,7 @@ public class Vnt_convert_lang {
|
||||
}
|
||||
if (tag_bgn == -1) return false; // no "<" found;
|
||||
loop = true;
|
||||
cur = curly_bgn + 1; // TODO: resume at }-
|
||||
cur = curly_bgn + 1; // TODO_OLD: resume at }-
|
||||
while (loop) { // scan fwd for >
|
||||
byte b = src[cur];
|
||||
switch (b) {
|
||||
@@ -121,7 +121,7 @@ public class Vnt_convert_lang {
|
||||
}
|
||||
continue;
|
||||
}
|
||||
frame_bfr.Add(Parse_recursive(Bry_bfr.new_(16), vnt_itm, depth + 1)); // Recursively parse another rule
|
||||
frame_bfr.Add(Parse_recursive(Bry_bfr_.New_w_size(16), vnt_itm, depth + 1)); // Recursively parse another rule
|
||||
bgn_pos = pos;
|
||||
break;
|
||||
case Tid__curly_end:
|
||||
@@ -180,10 +180,10 @@ public class Vnt_convert_lang {
|
||||
}
|
||||
}
|
||||
private static final byte Tid__curly_bgn = 1, Tid__curly_end = 2;
|
||||
private static final byte[] Bry__curly_bgn = Bry_.new_a7("-{"), Bry__curly_end = Bry_.new_a7("}-");
|
||||
private static final Btrie_fast_mgr trie = Btrie_fast_mgr.cs()
|
||||
private static final byte[] Bry__curly_bgn = Bry_.new_a7("-{"), Bry__curly_end = Bry_.new_a7("}-");
|
||||
private static final Btrie_fast_mgr trie = Btrie_fast_mgr.cs()
|
||||
.Add_bry_byte(Bry__curly_bgn, Tid__curly_bgn)
|
||||
.Add_bry_byte(Bry__curly_end, Tid__curly_end);
|
||||
public static final byte[] Bry__armor_bgn = Bry_.new_a7("-{R|"), Bry__armor_end = Bry_.new_a7("}-");
|
||||
public static final byte[] Bry__armor_bgn = Bry_.new_a7("-{R|"), Bry__armor_end = Bry_.new_a7("}-");
|
||||
private static final int max_depth = 32;
|
||||
}
|
||||
|
||||
@@ -19,10 +19,10 @@ package gplx.xowa.parsers.vnts; import gplx.*; import gplx.xowa.*; import gplx.x
|
||||
import gplx.core.btries.*; import gplx.core.primitives.*;
|
||||
import gplx.xowa.langs.vnts.*;
|
||||
class Vnt_convert_rule { // REF.MW: /languages/LanguageConverter.php|ConverterRule
|
||||
private final Vnt_flag_parser flag_parser = new Vnt_flag_parser(); private final Vnt_flag_code_mgr flag_codes = new Vnt_flag_code_mgr(); private final Vnt_flag_lang_mgr flag_langs = new Vnt_flag_lang_mgr();
|
||||
private final Vnt_rule_parser rule_parser = new Vnt_rule_parser(); private final Vnt_rule_undi_mgr rule_undis = new Vnt_rule_undi_mgr(); private final Vnt_rule_bidi_mgr rule_bidis = new Vnt_rule_bidi_mgr();
|
||||
private final Bry_bfr tmp_bfr = Bry_bfr.new_();
|
||||
private final Ordered_hash cnv_marked_hash = Ordered_hash_.New_bry();
|
||||
private final Vnt_flag_parser flag_parser = new Vnt_flag_parser(); private final Vnt_flag_code_mgr flag_codes = new Vnt_flag_code_mgr(); private final Vnt_flag_lang_mgr flag_langs = new Vnt_flag_lang_mgr();
|
||||
private final Vnt_rule_parser rule_parser = new Vnt_rule_parser(); private final Vnt_rule_undi_mgr rule_undis = new Vnt_rule_undi_mgr(); private final Vnt_rule_bidi_mgr rule_bidis = new Vnt_rule_bidi_mgr();
|
||||
private final Bry_bfr tmp_bfr = Bry_bfr_.New();
|
||||
private final Ordered_hash cnv_marked_hash = Ordered_hash_.New_bry();
|
||||
private Vnt_convert_lang converter;
|
||||
private Xol_vnt_regy vnt_regy; private byte[] vnt_key;
|
||||
private Vnt_log_mgr log_mgr;
|
||||
@@ -30,7 +30,7 @@ class Vnt_convert_rule { // REF.MW: /languages/LanguageConverter.php|ConverterRu
|
||||
public byte[] Display() {return display;} private byte[] display;
|
||||
public byte[] Title() {return title;} private byte[] title;
|
||||
public byte Action() {return action;} private byte action;
|
||||
public Vnt_rule_undi_mgr Cnv_tbl() {return cnv_tbl;} private final Vnt_rule_undi_mgr cnv_tbl = new Vnt_rule_undi_mgr();
|
||||
public Vnt_rule_undi_mgr Cnv_tbl() {return cnv_tbl;} private final Vnt_rule_undi_mgr cnv_tbl = new Vnt_rule_undi_mgr();
|
||||
public Vnt_convert_rule(Vnt_convert_lang converter, Xol_vnt_regy vnt_regy, Vnt_log_mgr log_mgr) {
|
||||
this.converter = converter; this.log_mgr = log_mgr;
|
||||
this.vnt_regy = vnt_regy;
|
||||
@@ -181,7 +181,7 @@ class Vnt_convert_rule { // REF.MW: /languages/LanguageConverter.php|ConverterRu
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
private final static byte[]
|
||||
private final static byte[]
|
||||
Bry__error_bgn = Bry_.new_a7("<span class=\"error\">vnt error")
|
||||
, Bry__error_end = Bry_.new_a7("</span>")
|
||||
, Bry__undi_spr = Bry_.new_u8("⇒")
|
||||
|
||||
@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.parsers.vnts; import gplx.*; import gplx.xowa.*; import gplx.xowa.parsers.*;
|
||||
import org.junit.*; import gplx.xowa.langs.vnts.*;
|
||||
public class Vnt_flag_parser_tst {
|
||||
private final Vnt_flag_parser_fxt fxt = new Vnt_flag_parser_fxt();
|
||||
private final Vnt_flag_parser_fxt fxt = new Vnt_flag_parser_fxt();
|
||||
@Test public void Basic() {fxt.Test_parse("D" , "D");}
|
||||
@Test public void Multiple() {fxt.Test_parse("+;S;E" , "+;S;E");}
|
||||
@Test public void Ws() {fxt.Test_parse(" + ; S ; E " , "+;S;E");}
|
||||
@@ -42,10 +42,10 @@ public class Vnt_flag_parser_tst {
|
||||
@Test public void Lang__zap__codes() {fxt.Test_parse("+;S;zh-hans;" , "zh-hans");}
|
||||
}
|
||||
class Vnt_flag_parser_fxt {
|
||||
private final Vnt_flag_parser parser = new Vnt_flag_parser();
|
||||
private final Vnt_flag_code_mgr codes = new Vnt_flag_code_mgr(); private final Vnt_flag_lang_mgr langs = new Vnt_flag_lang_mgr();
|
||||
private final Xol_vnt_regy vnt_regy = Xol_vnt_regy_fxt.new_chinese();
|
||||
private final Bry_bfr bfr = Bry_bfr.new_();
|
||||
private final Vnt_flag_parser parser = new Vnt_flag_parser();
|
||||
private final Vnt_flag_code_mgr codes = new Vnt_flag_code_mgr(); private final Vnt_flag_lang_mgr langs = new Vnt_flag_lang_mgr();
|
||||
private final Xol_vnt_regy vnt_regy = Xol_vnt_regy_fxt.new_chinese();
|
||||
private final Bry_bfr bfr = Bry_bfr_.New();
|
||||
public void Test_parse(String raw, String expd) {
|
||||
byte[] src = Bry_.new_u8(raw);
|
||||
parser.Parse(codes, langs, vnt_regy, src, 0, src.length);
|
||||
|
||||
@@ -18,8 +18,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.parsers.vnts; import gplx.*; import gplx.xowa.*; import gplx.xowa.parsers.*;
|
||||
import gplx.dbs.*;
|
||||
public class Vnt_log_tbl implements Rls_able {
|
||||
private final String tbl_name = "log_vnt"; private final Dbmeta_fld_list flds = Dbmeta_fld_list.new_();
|
||||
private final String fld_uid, fld_page_id, fld_rule_idx
|
||||
private final String tbl_name = "log_vnt"; private final Dbmeta_fld_list flds = new Dbmeta_fld_list();
|
||||
private final String fld_uid, fld_page_id, fld_rule_idx
|
||||
, fld_flag_count, fld_lang_count, fld_undi_count, fld_bidi_count
|
||||
, fld_flag_add, fld_flag_del, fld_flag_aout, fld_flag_hide, fld_flag_raw, fld_flag_show, fld_flag_descrip, fld_flag_name, fld_flag_title, fld_flag_err
|
||||
, fld_vnt_0, fld_vnt_1, fld_vnt_2, fld_vnt_3, fld_vnt_4, fld_vnt_5, fld_vnt_6, fld_vnt_7, fld_vnt_8, fld_vnt_9
|
||||
@@ -59,7 +59,7 @@ public class Vnt_log_tbl implements Rls_able {
|
||||
this.fld_src_txt = flds.Add_text("src_txt");
|
||||
conn.Rls_reg(this);
|
||||
}
|
||||
public Db_conn Conn() {return conn;} private final Db_conn conn;
|
||||
public Db_conn Conn() {return conn;} private final Db_conn conn;
|
||||
public void Rls() {
|
||||
stmt_insert = Db_stmt_.Rls(stmt_insert);
|
||||
}
|
||||
|
||||
@@ -18,8 +18,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.parsers.vnts; import gplx.*; import gplx.xowa.*; import gplx.xowa.parsers.*;
|
||||
import gplx.xowa.langs.vnts.*;
|
||||
class Vnt_rule_parser_fxt {
|
||||
private final Vnt_rule_parser parser = new Vnt_rule_parser(); private final Vnt_rule_undi_mgr undis = new Vnt_rule_undi_mgr(); private final Vnt_rule_bidi_mgr bidis = new Vnt_rule_bidi_mgr();
|
||||
private final Bry_bfr bfr = Bry_bfr.new_(255);
|
||||
private final Vnt_rule_parser parser = new Vnt_rule_parser(); private final Vnt_rule_undi_mgr undis = new Vnt_rule_undi_mgr(); private final Vnt_rule_bidi_mgr bidis = new Vnt_rule_bidi_mgr();
|
||||
private final Bry_bfr bfr = Bry_bfr_.New_w_size(255);
|
||||
public Vnt_rule_parser_fxt() {
|
||||
Xol_vnt_regy vnt_regy = new Xol_vnt_regy();
|
||||
vnt_regy.Add(Bry_.new_a7("x1"), Bry_.new_a7("lang1"));
|
||||
|
||||
@@ -133,7 +133,7 @@ public class Xop_xatr_whitelist_mgr {
|
||||
grp_hash.Add_bry_obj(key, itms);
|
||||
}
|
||||
private void Ini_nde(int tag_tid, String... key_strs) {
|
||||
List_adp keys = List_adp_.new_();
|
||||
List_adp keys = List_adp_.New();
|
||||
int len = key_strs.length;
|
||||
for (int i = 0; i < len; i++) {
|
||||
byte[] key = Bry_.new_a7(key_strs[i]);
|
||||
@@ -253,7 +253,7 @@ public class Xop_xatr_whitelist_mgr {
|
||||
.Add_str_byte("image-set" , Style_image_set)
|
||||
.Add_str_byte("/*" , Style_comment)
|
||||
;
|
||||
private static final byte[] Val_role_presentation = Bry_.new_a7("presentation");
|
||||
private static final byte[] Val_role_presentation = Bry_.new_a7("presentation");
|
||||
}
|
||||
class Xop_xatr_whitelist_itm {
|
||||
public Xop_xatr_whitelist_itm(byte[] key, byte key_tid, boolean exact) {this.key = key; this.key_tid = key_tid; this.exact = exact;}
|
||||
|
||||
@@ -27,13 +27,13 @@ public class Xop_xnde_tag {
|
||||
this.xtn_end_tag = Bry_.Add(Xop_xnde_tag_.Bry__end_tag_bgn, name_bry); // always force endtag; needed for <noinclude>
|
||||
this.xtn_end_tag_tmp = new byte[xtn_end_tag.length]; Array_.Copy(xtn_end_tag, xtn_end_tag_tmp);
|
||||
}
|
||||
public int Id() {return id;} private final int id;
|
||||
public byte[] Name_bry() {return name_bry;} private final byte[] name_bry;
|
||||
public String Name_str() {return name_str;} private final String name_str;
|
||||
public int Name_len() {return name_len;} private final int name_len;
|
||||
public byte[] Xtn_bgn_tag() {return xtn_bgn_tag;} private final byte[] xtn_bgn_tag;
|
||||
public byte[] Xtn_end_tag() {return xtn_end_tag;} private final byte[] xtn_end_tag;
|
||||
public byte[] Xtn_end_tag_tmp() {return xtn_end_tag_tmp;} private final byte[] xtn_end_tag_tmp;
|
||||
public int Id() {return id;} private final int id;
|
||||
public byte[] Name_bry() {return name_bry;} private final byte[] name_bry;
|
||||
public String Name_str() {return name_str;} private final String name_str;
|
||||
public int Name_len() {return name_len;} private final int name_len;
|
||||
public byte[] Xtn_bgn_tag() {return xtn_bgn_tag;} private final byte[] xtn_bgn_tag;
|
||||
public byte[] Xtn_end_tag() {return xtn_end_tag;} private final byte[] xtn_end_tag;
|
||||
public byte[] Xtn_end_tag_tmp() {return xtn_end_tag_tmp;} private final byte[] xtn_end_tag_tmp;
|
||||
public boolean Xtn() {return xtn;} public Xop_xnde_tag Xtn_() {xtn = true; return this;} private boolean xtn;
|
||||
public boolean Xtn_mw() {return xtn_mw;} public Xop_xnde_tag Xtn_mw_() {xtn_mw = true; xtn = true; return this;} private boolean xtn_mw; // NOTE: Xtn_mw_() marks both xtn and xtn_mw as true
|
||||
public int Bgn_mode() {return bgn_nde_mode;} private int bgn_nde_mode = Xop_xnde_tag_.Bgn_mode__normal;
|
||||
@@ -64,7 +64,7 @@ public class Xop_xnde_tag {
|
||||
public Xop_xnde_tag Langs_(int lang_code, String name) {
|
||||
if (langs == null) {
|
||||
langs = Ordered_hash_.New();
|
||||
langs_key = Int_obj_ref.neg1_();
|
||||
langs_key = Int_obj_ref.New_neg1();
|
||||
}
|
||||
Xop_xnde_tag_lang lang_tag = new Xop_xnde_tag_lang(lang_code, name);
|
||||
langs.Add(lang_tag.Lang_code(), lang_tag);
|
||||
|
||||
@@ -19,7 +19,7 @@ package gplx.xowa.parsers.xndes; import gplx.*; import gplx.xowa.*; import gplx.
|
||||
import gplx.core.primitives.*;
|
||||
public class Xop_xnde_tag_lang {
|
||||
public Xop_xnde_tag_lang(int lang_code_int, String name_str) {
|
||||
lang_code = Int_obj_ref.new_(lang_code_int);
|
||||
lang_code = Int_obj_ref.New(lang_code_int);
|
||||
this.name_str = name_str;
|
||||
this.name_bry = Bry_.new_u8(name_str);
|
||||
this.xtnEndTag_tmp = Bry_.Add(Xop_xnde_tag_.Bry__end_tag_bgn, name_bry);
|
||||
@@ -28,5 +28,5 @@ public class Xop_xnde_tag_lang {
|
||||
public String Name_str() {return name_str;} private String name_str;
|
||||
public byte[] Name_bry() {return name_bry;} private byte[] name_bry;
|
||||
public byte[] Xtn_end_tag_tmp() {return xtnEndTag_tmp;} private byte[] xtnEndTag_tmp;
|
||||
public static final Xop_xnde_tag_lang Instance = new Xop_xnde_tag_lang(-1, String_.Empty);
|
||||
public static final Xop_xnde_tag_lang Instance = new Xop_xnde_tag_lang(-1, String_.Empty);
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ package gplx.xowa.parsers.xndes; import gplx.*; import gplx.xowa.*; import gplx.
|
||||
import gplx.core.btries.*;
|
||||
public class Xop_xnde_tag_regy {
|
||||
private boolean init_needed = true;
|
||||
private final Btrie_slim_mgr // NOTE:ci.utf8; he.s and <section> alias DATE:2014-07-18
|
||||
private final Btrie_slim_mgr // NOTE:ci.utf8; he.s and <section> alias DATE:2014-07-18
|
||||
trie_tmpl = Btrie_slim_mgr.ci_u8()
|
||||
, trie_wtxt_main = Btrie_slim_mgr.ci_u8()
|
||||
, trie_wtxt_tmpl = Btrie_slim_mgr.ci_u8();
|
||||
@@ -29,7 +29,7 @@ public class Xop_xnde_tag_regy {
|
||||
case Xop_parser_.Parse_tid_tmpl: return trie_tmpl;
|
||||
case Xop_parser_.Parse_tid_page_tmpl: return trie_wtxt_tmpl;
|
||||
case Xop_parser_.Parse_tid_page_wiki: return trie_wtxt_main;
|
||||
case Xop_parser_.Parse_tid_null: default: return trie_wtxt_tmpl; // TODO: should throw Err_.new_unhandled(i);
|
||||
case Xop_parser_.Parse_tid_null: default: return trie_wtxt_tmpl; // TODO_OLD: should throw Err_.new_unhandled(i);
|
||||
}
|
||||
}
|
||||
public void Init_by_meta(Hash_adp_bry xtn_hash) {Init_by_hash(xtn_hash);}
|
||||
@@ -59,7 +59,7 @@ public class Xop_xnde_tag_regy {
|
||||
return xtn_hash != null // xtn_hash is null during tests or when wiki is not in site_meta_db
|
||||
&& xnde.Xtn_mw() // only apply filter to xtn_xnde, not basic_xnde; EX: <dynamicpagelist> not <table>
|
||||
&& !xtn_hash.Has(xnde.Name_bry()) // xtn_xnde is not in xtn_hash
|
||||
&& !Int_.In(xnde.Id(), Xop_xnde_tag_.Tid__translate, Xop_xnde_tag_.Tid__languages) // always include <translate> and <languages>; TODO:filter out when extensions supported in site_cfg; DATE:2015-10-13
|
||||
&& !Int_.In(xnde.Id(), Xop_xnde_tag_.Tid__translate, Xop_xnde_tag_.Tid__languages) // always include <translate> and <languages>; TODO_OLD:filter out when extensions supported in site_cfg; DATE:2015-10-13
|
||||
; // skip; xtn is not defined in site_meta_db
|
||||
}
|
||||
private void Add_itm(Btrie_slim_mgr trie, Xop_xnde_tag xnde) {
|
||||
|
||||
@@ -30,6 +30,6 @@ public class Xop_xnde_tag_stack {
|
||||
xmlTags[i] = 0;
|
||||
xmlTagsStack.Clear();
|
||||
}
|
||||
List_adp xmlTagsStack = List_adp_.new_();
|
||||
List_adp xmlTagsStack = List_adp_.New();
|
||||
int[] xmlTags = new int[Xop_xnde_tag_.Tid__len];
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ public class Xop_xnde_wkr implements Xop_ctx_wkr {
|
||||
++tag_end_pos;
|
||||
break;
|
||||
case Byte_ascii.Dollar: // handles <br$2>;
|
||||
default: // allow all other symbols by defaults; TODO: need to filter out some like <br@>
|
||||
default: // allow all other symbols by defaults; TODO_OLD: need to filter out some like <br@>
|
||||
break;
|
||||
// letters / numbers after tag; tag is invalid; EX: "<spanA"
|
||||
case Byte_ascii.Ltr_A: case Byte_ascii.Ltr_B: case Byte_ascii.Ltr_C: case Byte_ascii.Ltr_D: case Byte_ascii.Ltr_E:
|
||||
|
||||
@@ -19,10 +19,10 @@ package gplx.xowa.parsers.xndes; import gplx.*; import gplx.xowa.*; import gplx.
|
||||
import gplx.core.primitives.*; import gplx.core.btries.*;
|
||||
import gplx.xowa.xtns.pfuncs.strings.*;
|
||||
class Xop_xnde_wkr_ {
|
||||
private static final Btrie_slim_mgr xtn_end_tag_trie = Btrie_slim_mgr.ci_a7(); // NOTE:ci.ascii:MW_const.en; listed XML node names are en
|
||||
private static final Btrie_slim_mgr xtn_end_tag_trie = Btrie_slim_mgr.ci_a7(); // NOTE:ci.ascii:MW_const.en; listed XML node names are en
|
||||
private static final int Find_xtn_end__tid__bgn = 0, Find_xtn_end__tid__end = 1, Find_xtn_end__tid__xtag = 2;
|
||||
private static final Int_obj_ref Find_xtn_end__key__bgn = Int_obj_ref.new_(Find_xtn_end__tid__bgn), Find_xtn_end__key__end = Int_obj_ref.new_(Find_xtn_end__tid__end), Find_xtn_end__key__xtag = Int_obj_ref.new_(Find_xtn_end__tid__xtag);
|
||||
private static final Bry_bfr Find_xtag_end__bfr = Bry_bfr.new_(32);
|
||||
private static final Int_obj_ref Find_xtn_end__key__bgn = Int_obj_ref.New(Find_xtn_end__tid__bgn), Find_xtn_end__key__end = Int_obj_ref.New(Find_xtn_end__tid__end), Find_xtn_end__key__xtag = Int_obj_ref.New(Find_xtn_end__tid__xtag);
|
||||
private static final Bry_bfr Find_xtag_end__bfr = Bry_bfr_.New_w_size(32);
|
||||
public static void AutoClose_handle_dangling_nde_in_caption(Xop_root_tkn root, Xop_tkn_itm owner) {
|
||||
int subs_bgn = -1, subs_len = owner.Subs_len();
|
||||
for (int i = 0; i < subs_len; i++) {
|
||||
|
||||
Reference in New Issue
Block a user