mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
'v3.7.2.1'
This commit is contained in:
@@ -23,5 +23,5 @@ public class Xop_xnde_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 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) {return ctx.Xnde().Make_tkn(ctx, tkn_mkr, root, src, src_len, bgn_pos, cur_pos);}
|
||||
public static final Xop_xnde_lxr Instance = new Xop_xnde_lxr(); Xop_xnde_lxr() {}
|
||||
public static final Xop_xnde_lxr Instance = new Xop_xnde_lxr(); Xop_xnde_lxr() {}
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ public class Xop_xnde_wkr implements Xop_ctx_wkr {
|
||||
if (closing_tkn_tid == Xop_tkn_itm_.Tid_lnki_end) Xop_xnde_wkr_.AutoClose_handle_dangling_nde_in_caption(root, tkn); // PAGE:sr.w:Сићевачка_клисура; DATE:2014-07-03
|
||||
ctx.Msg_log().Add_itm_none(Xop_xnde_log.Dangling_xnde, src, xnde.Src_bgn(), xnde.Name_end()); // NOTE: xnde.Src_bgn to start at <; xnde.Name_end b/c xnde.Src_end is -1
|
||||
}
|
||||
private static final Btrie_rv trv = new Btrie_rv();
|
||||
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) {
|
||||
if (bgn_pos == Xop_parser_.Doc_bgn_bos) bgn_pos = 0; // do not allow -1 pos
|
||||
if (cur_pos == src_len) return ctx.Lxr_make_txt_(src_len); // "<" is EOS; don't raise error;
|
||||
@@ -58,8 +59,13 @@ public class Xop_xnde_wkr implements Xop_ctx_wkr {
|
||||
}
|
||||
// get node_name
|
||||
Btrie_slim_mgr tag_trie = ctx.Xnde_tag_regy().Get_trie(ctx.Xnde_names_tid());
|
||||
Object tag_obj = tag_trie.Match_bgn_w_byte(cur_byt, src, cur_pos, src_len); // NOTE:tag_obj can be null in wiki_tmpl mode; EX: "<ul" is not a valid tag in wiki_tmpl, but is valid in wiki_main
|
||||
int atrs_bgn_pos = tag_trie.Match_pos();
|
||||
Object tag_obj; int atrs_bgn_pos;
|
||||
synchronized (trv) {
|
||||
tag_trie.Match_at_w_b0(trv, cur_byt, src, cur_pos, src_len); // NOTE:tag_obj can be null in wiki_tmpl mode; EX: "<ul" is not a valid tag in wiki_tmpl, but is valid in wiki_main
|
||||
tag_obj = trv.Obj();
|
||||
atrs_bgn_pos = trv.Pos();
|
||||
}
|
||||
|
||||
int name_bgn = cur_pos, name_end = atrs_bgn_pos;
|
||||
int tag_end_pos = atrs_bgn_pos - 1;
|
||||
if (tag_obj != null) {
|
||||
|
||||
@@ -36,37 +36,39 @@ class Xop_xnde_wkr_ {
|
||||
root.Subs_move(owner, subs_bgn, subs_len); // move everything after "|" back to root
|
||||
}
|
||||
public static int Find_xtn_end(Xop_ctx ctx, byte[] src, int open_end, int src_end, byte[] open_bry, byte[] close_bry) {
|
||||
xtn_end_tag_trie.Clear();
|
||||
xtn_end_tag_trie.Add_obj(Pfunc_tag.Xtag_bgn_lhs, Find_xtn_end__key__xtag);
|
||||
xtn_end_tag_trie.Add_obj(open_bry, Find_xtn_end__key__bgn);
|
||||
xtn_end_tag_trie.Add_obj(close_bry, Find_xtn_end__key__end);
|
||||
int depth = 0;
|
||||
for (int i = open_end; i < src_end; ++i) {
|
||||
Object o = xtn_end_tag_trie.Match_bgn(src, i, src_end);
|
||||
if (o != null) {
|
||||
int tid = ((Int_obj_ref)o).Val();
|
||||
switch (tid) {
|
||||
case Find_xtn_end__tid__bgn: // handle nested refs; PAGE:en.w:UK; DATE:2015-12-26
|
||||
int angle_end_pos = Bry_find_.Find_fwd(src, Byte_ascii.Angle_end, i, src_end); if (angle_end_pos == Bry_find_.Not_found) {Xoa_app_.Usr_dlg().Warn_many("", "", "parser.xtn: could not find angle_end: page=~{0}", ctx.Page().Url().To_str()); return Bry_find_.Not_found;}
|
||||
if (src[angle_end_pos -1] == Byte_ascii.Slash) {}
|
||||
else
|
||||
++depth;
|
||||
break;
|
||||
case Find_xtn_end__tid__end: // xtn_end found; use it
|
||||
if (depth == 0)
|
||||
return i;
|
||||
else
|
||||
--depth;
|
||||
break;
|
||||
case Find_xtn_end__tid__xtag: // xtag found; skip over it; PAGE:it.s:La_Secchia_rapita/Canto_primo DATE:2015-12-03
|
||||
int xtag_end = Find_xtag_end(ctx, src, i, src_end);
|
||||
int angle_end = Bry_find_.Find_fwd(src, Byte_ascii.Angle_end, xtag_end, src_end);
|
||||
i = angle_end;
|
||||
break;
|
||||
synchronized (xtn_end_tag_trie) { // LOCK:static-obj; DATE:2016-07-06
|
||||
xtn_end_tag_trie.Clear();
|
||||
xtn_end_tag_trie.Add_obj(Pfunc_tag.Xtag_bgn_lhs, Find_xtn_end__key__xtag);
|
||||
xtn_end_tag_trie.Add_obj(open_bry, Find_xtn_end__key__bgn);
|
||||
xtn_end_tag_trie.Add_obj(close_bry, Find_xtn_end__key__end);
|
||||
int depth = 0;
|
||||
for (int i = open_end; i < src_end; ++i) {
|
||||
Object o = xtn_end_tag_trie.Match_bgn(src, i, src_end);
|
||||
if (o != null) {
|
||||
int tid = ((Int_obj_ref)o).Val();
|
||||
switch (tid) {
|
||||
case Find_xtn_end__tid__bgn: // handle nested refs; PAGE:en.w:UK; DATE:2015-12-26
|
||||
int angle_end_pos = Bry_find_.Find_fwd(src, Byte_ascii.Angle_end, i, src_end); if (angle_end_pos == Bry_find_.Not_found) {Xoa_app_.Usr_dlg().Warn_many("", "", "parser.xtn: could not find angle_end: page=~{0}", ctx.Page().Url().To_str()); return Bry_find_.Not_found;}
|
||||
if (src[angle_end_pos -1] == Byte_ascii.Slash) {}
|
||||
else
|
||||
++depth;
|
||||
break;
|
||||
case Find_xtn_end__tid__end: // xtn_end found; use it
|
||||
if (depth == 0)
|
||||
return i;
|
||||
else
|
||||
--depth;
|
||||
break;
|
||||
case Find_xtn_end__tid__xtag: // xtag found; skip over it; PAGE:it.s:La_Secchia_rapita/Canto_primo DATE:2015-12-03
|
||||
int xtag_end = Find_xtag_end(ctx, src, i, src_end);
|
||||
int angle_end = Bry_find_.Find_fwd(src, Byte_ascii.Angle_end, xtag_end, src_end);
|
||||
i = angle_end;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return Bry_find_.Not_found;
|
||||
}
|
||||
return Bry_find_.Not_found;
|
||||
}
|
||||
public static int Find_xtag_end(Xop_ctx ctx, byte[] src, int pos, int src_end) {
|
||||
int xtag_bgn = pos + Pfunc_tag.Xtag_bgn_lhs.length;
|
||||
|
||||
@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.parsers.xndes; import gplx.*; import gplx.xowa.*; import gplx.xowa.parsers.*;
|
||||
import org.junit.*;
|
||||
public class Xop_xnde_wkr__include_basic_tst {
|
||||
private final Xop_fxt fxt = new Xop_fxt();
|
||||
private final Xop_fxt fxt = new Xop_fxt();
|
||||
@Before public void init() {fxt.Reset();}
|
||||
@Test public void Tmpl_includeonly() {fxt.Test_parse_tmpl_str_test("a<includeonly>b</includeonly>c" , "{{test}}", "abc");}
|
||||
@Test public void Tmpl_noinclude() {fxt.Test_parse_tmpl_str_test("a<noinclude>b</noinclude>c" , "{{test}}", "ac");}
|
||||
|
||||
Reference in New Issue
Block a user