mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
v2.2.4.1
This commit is contained in:
@@ -19,7 +19,7 @@ package gplx.xowa; import gplx.*;
|
||||
import gplx.core.btries.*; import gplx.xowa.parsers.paras.*;
|
||||
public class Xop_comm_lxr implements Xop_lxr {
|
||||
public byte Lxr_tid() {return Xop_lxr_.Tid_comment;}
|
||||
public void Init_by_wiki(Xow_wiki wiki, Btrie_fast_mgr core_trie) {core_trie.Add(Bgn_ary, this);}
|
||||
public void Init_by_wiki(Xowe_wiki wiki, Btrie_fast_mgr core_trie) {core_trie.Add(Bgn_ary, this);}
|
||||
public void Init_by_lang(Xol_lang lang, 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) {
|
||||
int lhs_end = cur_pos;
|
||||
|
||||
@@ -23,7 +23,7 @@ public class Xop_cr_tkn extends Xop_tkn_itm_base {
|
||||
}
|
||||
class Xop_cr_lxr implements Xop_lxr {
|
||||
public byte Lxr_tid() {return Xop_lxr_.Tid_cr;}
|
||||
public void Init_by_wiki(Xow_wiki wiki, Btrie_fast_mgr core_trie) {
|
||||
public void Init_by_wiki(Xowe_wiki wiki, Btrie_fast_mgr core_trie) {
|
||||
core_trie.Add(Byte_ascii.CarriageReturn, this);
|
||||
}
|
||||
public void Init_by_lang(Xol_lang lang, Btrie_fast_mgr core_trie) {}
|
||||
|
||||
@@ -20,7 +20,7 @@ import gplx.core.btries.*; import gplx.xowa.parsers.paras.*;
|
||||
class Xop_eq_lxr implements Xop_lxr {
|
||||
public Xop_eq_lxr(boolean tmpl_mode) {this.tmpl_mode = tmpl_mode;} boolean tmpl_mode;
|
||||
public byte Lxr_tid() {return Xop_lxr_.Tid_eq;}
|
||||
public void Init_by_wiki(Xow_wiki wiki, Btrie_fast_mgr core_trie) {core_trie.Add(Byte_ascii.Eq, this);}
|
||||
public void Init_by_wiki(Xowe_wiki wiki, Btrie_fast_mgr core_trie) {core_trie.Add(Byte_ascii.Eq, this);}
|
||||
public void Init_by_lang(Xol_lang lang, 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) {
|
||||
cur_pos = Bry_finder.Find_fwd_while(src, cur_pos, src_len, Byte_ascii.Eq); // gobble up eq; "==" should produce 1 eq_tkn with len of 2, not 2 eq_tkn with len of 1; DATE:2014-04-17
|
||||
|
||||
@@ -19,7 +19,7 @@ package gplx.xowa; import gplx.*;
|
||||
import gplx.core.btries.*;
|
||||
public class Xop_hr_lxr implements Xop_lxr {
|
||||
public byte Lxr_tid() {return Xop_lxr_.Tid_hr;}
|
||||
public void Init_by_wiki(Xow_wiki wiki, Btrie_fast_mgr parse_trie) {parse_trie.Add(Hook_ary, this);} static final byte[] Hook_ary = new byte[] {Byte_ascii.NewLine, 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.NewLine, Byte_ascii.Dash, Byte_ascii.Dash, Byte_ascii.Dash, Byte_ascii.Dash};
|
||||
public void Init_by_lang(Xol_lang lang, 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) {
|
||||
int nl_adj = -1; // -1 to ignore nl at bgn for hr_len
|
||||
|
||||
@@ -19,7 +19,7 @@ package gplx.xowa; import gplx.*;
|
||||
import gplx.core.btries.*; import gplx.xowa.parsers.tblws.*;
|
||||
public class Xop_pipe_lxr implements Xop_lxr {
|
||||
public byte Lxr_tid() {return Xop_lxr_.Tid_pipe;}
|
||||
public void Init_by_wiki(Xow_wiki wiki, Btrie_fast_mgr core_trie) {core_trie.Add(Byte_ascii.Pipe, this);}
|
||||
public void Init_by_wiki(Xowe_wiki wiki, Btrie_fast_mgr core_trie) {core_trie.Add(Byte_ascii.Pipe, this);}
|
||||
public void Init_by_lang(Xol_lang lang, 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) {
|
||||
int cur_stack_tid = ctx.Cur_tkn_tid(), rv = -1;
|
||||
|
||||
@@ -35,7 +35,7 @@ public class Xop_space_tkn extends Xop_tkn_itm_base {
|
||||
}
|
||||
class Xop_space_lxr implements Xop_lxr {
|
||||
public byte Lxr_tid() {return Xop_lxr_.Tid_space;}
|
||||
public void Init_by_wiki(Xow_wiki wiki, Btrie_fast_mgr core_trie) {core_trie.Add(Byte_ascii.Space, this);}
|
||||
public void Init_by_wiki(Xowe_wiki wiki, Btrie_fast_mgr core_trie) {core_trie.Add(Byte_ascii.Space, this);}
|
||||
public void Init_by_lang(Xol_lang lang, 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) {
|
||||
cur_pos = Bry_finder.Find_fwd_while(src, cur_pos, src_len, Byte_ascii.Space);
|
||||
|
||||
@@ -24,7 +24,7 @@ public class Xop_tab_tkn extends Xop_tkn_itm_base {
|
||||
}
|
||||
class Xop_tab_lxr implements Xop_lxr {
|
||||
public byte Lxr_tid() {return Xop_lxr_.Tid_tab;}
|
||||
public void Init_by_wiki(Xow_wiki wiki, Btrie_fast_mgr core_trie) {
|
||||
public void Init_by_wiki(Xowe_wiki wiki, Btrie_fast_mgr core_trie) {
|
||||
core_trie.Add(Byte_ascii.Tab, this);
|
||||
core_trie.Add(Xop_tab_tkn.Bry_tab_ent, this);
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ import gplx.xowa.html.tocs.*;
|
||||
class Xop_under_lxr implements Xop_lxr {
|
||||
private Btrie_mgr words_trie_ci, words_trie_cs;
|
||||
public byte Lxr_tid() {return Xop_lxr_.Tid_under;}
|
||||
public void Init_by_wiki(Xow_wiki wiki, Btrie_fast_mgr core_trie) {}
|
||||
public void Init_by_wiki(Xowe_wiki wiki, Btrie_fast_mgr core_trie) {}
|
||||
public void Init_by_lang(Xol_lang lang, Btrie_fast_mgr core_trie) {
|
||||
Xol_kwd_mgr kwd_mgr = lang.Kwd_mgr();
|
||||
int under_kwds_len = under_kwds.length;
|
||||
@@ -56,7 +56,7 @@ class Xop_under_lxr implements Xop_lxr {
|
||||
if (kwd_case_match) // cs; add word directly to trie
|
||||
core_trie.Add(kwd_bry, word_lxr);
|
||||
else { // NOTE: next part is imprecise; XOWA parser is cs, but kwd is ci; for now, just add all upper and all lower
|
||||
lang.App().Usr_dlg().Warn_many("", "", "under keyword does not start with __; id=~{0} key=~{1} word=~{2}", kwd_id, String_.new_utf8_(kwd_grp.Key()), String_.new_utf8_(kwd_bry));
|
||||
Gfo_usr_dlg_._.Warn_many("", "", "under keyword does not start with __; id=~{0} key=~{1} word=~{2}", kwd_id, String_.new_utf8_(kwd_grp.Key()), String_.new_utf8_(kwd_bry));
|
||||
core_trie.Add(lang.Case_mgr().Case_build_lower(kwd_bry), word_lxr);
|
||||
core_trie.Add(lang.Case_mgr().Case_build_upper(kwd_bry), word_lxr);
|
||||
}
|
||||
@@ -93,7 +93,7 @@ class Xop_under_lxr implements Xop_lxr {
|
||||
return rv;
|
||||
}
|
||||
public static void 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, int kwd_id) {
|
||||
Xoa_page page = ctx.Cur_page();
|
||||
Xoae_page page = ctx.Cur_page();
|
||||
Xow_hdr_mgr hdr_mgr = page.Hdr_mgr();
|
||||
switch (kwd_id) {
|
||||
case Xol_kwd_grp_.Id_toc:
|
||||
@@ -115,7 +115,7 @@ class Xop_word_lxr implements Xop_lxr {
|
||||
private int kwd_id;
|
||||
public Xop_word_lxr(int kwd_id) {this.kwd_id = kwd_id;}
|
||||
public byte Lxr_tid() {return Xop_lxr_.Tid_word;}
|
||||
public void Init_by_wiki(Xow_wiki wiki, Btrie_fast_mgr core_trie) {}
|
||||
public void Init_by_wiki(Xowe_wiki wiki, Btrie_fast_mgr core_trie) {}
|
||||
public void Init_by_lang(Xol_lang lang, 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) {
|
||||
Xop_under_lxr.Make_tkn(ctx, tkn_mkr, root, src, src_len, bgn_pos, cur_pos, kwd_id); // for now, all word_lxrs only call the under_lxr; DATE:2014-02-14
|
||||
|
||||
@@ -140,20 +140,20 @@ public class Xop_under_lxr_tst {
|
||||
fxt.Init_para_n_();
|
||||
}
|
||||
@Test public void Hook_alt() { // PURPOSE: ja wikis use alternate __; DATE:2014-03-04
|
||||
Xow_wiki wiki = fxt.Wiki(); Xol_lang lang = wiki.Lang();
|
||||
Xowe_wiki wiki = fxt.Wiki(); Xol_lang lang = wiki.Lang();
|
||||
fxt.Init_lang_kwds(lang, Xol_kwd_grp_.Id_toc, true, "__TOC__");
|
||||
wiki.Parser().Init_by_lang(lang);
|
||||
fxt.Test_parse_page_all_str("a__TOC__b", "ab");
|
||||
}
|
||||
@Test public void Ascii_ci() { // PURPOSE: case-insensitive ascii; DATE:2014-07-10
|
||||
Xow_wiki wiki = fxt.Wiki(); Xol_lang lang = wiki.Lang();
|
||||
Xowe_wiki wiki = fxt.Wiki(); Xol_lang lang = wiki.Lang();
|
||||
fxt.Init_lang_kwds(lang, Xol_kwd_grp_.Id_toc, false, "__TOC__");
|
||||
wiki.Parser().Init_by_lang(lang);
|
||||
fxt.Test_parse_page_all_str("a__TOC__b", "ab");
|
||||
fxt.Test_parse_page_all_str("a__toc__b", "ab");
|
||||
}
|
||||
@Test public void Utf8_ci() { // PURPOSE: case-insensitive UTF8; DATE:2014-07-10
|
||||
Xow_wiki wiki = fxt.Wiki(); Xol_lang lang = wiki.Lang();
|
||||
Xowe_wiki wiki = fxt.Wiki(); Xol_lang lang = wiki.Lang();
|
||||
lang.Case_mgr_utf8_();
|
||||
fxt.Init_lang_kwds(lang, Xol_kwd_grp_.Id_toc, false, "__AÉI__");
|
||||
wiki.Parser().Init_by_lang(lang);
|
||||
@@ -161,21 +161,21 @@ public class Xop_under_lxr_tst {
|
||||
fxt.Test_parse_page_all_str("a__aéi__b", "ab");
|
||||
}
|
||||
@Test public void Utf8_ci_asymmetric() { // PURPOSE: case-insensitive UTF8; asymmetric; DATE:2014-07-10
|
||||
Xow_wiki wiki = fxt.Wiki(); Xol_lang lang = wiki.Lang();
|
||||
Xowe_wiki wiki = fxt.Wiki(); Xol_lang lang = wiki.Lang();
|
||||
lang.Case_mgr_utf8_();
|
||||
fxt.Init_lang_kwds(lang, Xol_kwd_grp_.Id_toc, false, "__İÇİNDEKİLER__"); // __TOC__ for tr.w
|
||||
wiki.Parser().Init_by_lang(lang);
|
||||
fxt.Test_parse_page_all_str("a__İçindekiler__b", "ab");
|
||||
}
|
||||
@Test public void Cs() { // PURPOSE: cs (ascii / utf8 doesn't matter); DATE:2014-07-11
|
||||
Xow_wiki wiki = fxt.Wiki(); Xol_lang lang = wiki.Lang();
|
||||
Xowe_wiki wiki = fxt.Wiki(); Xol_lang lang = wiki.Lang();
|
||||
fxt.Init_lang_kwds(lang, Xol_kwd_grp_.Id_toc , Bool_.Y, "__TOC__");
|
||||
wiki.Parser().Init_by_lang(lang);
|
||||
fxt.Test_parse_page_all_str("a__TOC__b" , "ab"); // ci.pass
|
||||
fxt.Test_parse_page_all_str("a__toc__b" , "a__toc__b"); // ci.pass
|
||||
}
|
||||
@Test public void Ascii_cs_ci() { // PURPOSE: test simultaneous cs and ci; DATE:2014-07-11
|
||||
Xow_wiki wiki = fxt.Wiki(); Xol_lang lang = wiki.Lang();
|
||||
Xowe_wiki wiki = fxt.Wiki(); Xol_lang lang = wiki.Lang();
|
||||
fxt.Init_lang_kwds(lang, Xol_kwd_grp_.Id_toc , Bool_.N, "__TOC__");
|
||||
fxt.Init_lang_kwds(lang, Xol_kwd_grp_.Id_notoc , Bool_.Y, "__NOTOC__");
|
||||
wiki.Parser().Init_by_lang(lang);
|
||||
|
||||
Reference in New Issue
Block a user