mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
v1.7.3.1
This commit is contained in:
@@ -36,7 +36,7 @@ public class Xop_xatr_itm {
|
||||
public byte Quote_byte() {return quote_byte;} private byte quote_byte;
|
||||
public byte[] Val_as_bry(byte[] src) {if (val_bry == null) val_bry = Bry_.Mid(src, val_bgn, val_end); return val_bry;} // NOTE: val_bry is cached
|
||||
public byte[] Val_as_bry__blank_to_null(byte[] src) {byte[] rv = Val_as_bry(src); return Bry_.Len_eq_0(rv) ? null : rv;}
|
||||
public int Val_as_int_or(byte[] src, int or) {return val_bry == null ? Bry_.X_to_int_or_lax(src, val_bgn, val_end, or) : Bry_.X_to_int_or(val_bry, or);}
|
||||
public int Val_as_int_or(byte[] src, int or) {return val_bry == null ? Bry_.Xto_int_or_lax(src, val_bgn, val_end, or) : Bry_.Xto_int_or(val_bry, or);}
|
||||
public boolean Val_as_bool_by_int(byte[] src) {return Val_as_int_or(src, 0) == 1;}
|
||||
public boolean Val_as_bool(byte[] src) {return Bry_.Eq(Bry_.Lower_ascii(Val_as_bry(src)), Bool_.True_bry);}
|
||||
public static Xop_xatr_itm[] Xatr_parse(Xoa_app app, Xop_xnde_atr_parser parser, Hash_adp_bry hash, Xow_wiki wiki, byte[] src, Xop_xnde_tkn xnde) {
|
||||
|
||||
@@ -56,4 +56,26 @@ public class Xop_xnde_tag {
|
||||
public boolean Xtn_auto_close() {return xtn_auto_close;} public Xop_xnde_tag Xtn_auto_close_() {xtn_auto_close = true; return this;} private boolean xtn_auto_close;
|
||||
public boolean Ignore_empty() {return ignore_empty;} public Xop_xnde_tag Ignore_empty_() {ignore_empty = true; return this;} private boolean ignore_empty;
|
||||
public boolean Xtn_skips_template_args() {return xtn_skips_template_args;} public Xop_xnde_tag Xtn_skips_template_args_() {xtn_skips_template_args = true; return this;} private boolean xtn_skips_template_args;
|
||||
public OrderedHash Langs() {return langs;} private OrderedHash langs; private Int_obj_ref langs_key;
|
||||
public Xop_xnde_tag Langs_(int lang_code, String name) {
|
||||
if (langs == null) {
|
||||
langs = OrderedHash_.new_();
|
||||
langs_key = Int_obj_ref.neg1_();
|
||||
}
|
||||
Xop_xnde_tag_lang lang_tag = new Xop_xnde_tag_lang(lang_code, name);
|
||||
langs.Add(lang_tag.Lang_code(), lang_tag);
|
||||
return this;
|
||||
}
|
||||
public Xop_xnde_tag_lang Langs_get(gplx.xowa.langs.cases.Xol_case_mgr case_mgr, int cur_lang, byte[] src, int bgn, int end) {
|
||||
if (langs == null) return Xop_xnde_tag_lang._; // no langs defined; always return true; EX:<b>
|
||||
if (Bry_.Eq(name_bry, src, bgn, end)) return Xop_xnde_tag_lang._; // canonical name (name_bry) is valid in all langs; EX: <section> and cur_lang=de
|
||||
synchronized (langs) {
|
||||
langs_key.Val_(cur_lang);
|
||||
}
|
||||
Xop_xnde_tag_lang lang = (Xop_xnde_tag_lang)langs.Fetch(langs_key);
|
||||
if (lang == null) return null; // cur tag is a lang tag, but no tag for this lang; EX: "<trecho>" and cur_lang=de
|
||||
return Bry_.Eq_ci_ascii(lang.Name_bry(), src, bgn, end)
|
||||
? lang
|
||||
: null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,8 +133,9 @@ public class Xop_xnde_tag_ {
|
||||
, Tid_xowa_html = 108
|
||||
, Tid_xowa_tag_bgn = 109
|
||||
, Tid_xowa_tag_end = 110
|
||||
, Tid_quiz = 111
|
||||
;
|
||||
public static final int _MaxLen = 111;
|
||||
public static final int _MaxLen = 112;
|
||||
public static final Xop_xnde_tag[] Ary = new Xop_xnde_tag[_MaxLen];
|
||||
private static Xop_xnde_tag new_(int id, String name) {
|
||||
Xop_xnde_tag rv = new Xop_xnde_tag(id, name);
|
||||
@@ -217,7 +218,7 @@ public class Xop_xnde_tag_ {
|
||||
, Tag_hiero = new_(Tid_hiero, "hiero").Xtn_()
|
||||
, Tag_inputBox = new_(Tid_inputBox, "inputBox").Xtn_()
|
||||
, Tag_pages = new_(Tid_pages, "pages").Xtn_()
|
||||
, Tag_section = new_(Tid_section, "section").Xtn_()
|
||||
, Tag_section = new_(Tid_section, "section").Xtn_().Langs_(Xol_lang_itm_.Id_de, "Abschnitt").Langs_(Xol_lang_itm_.Id_he, "קטע").Langs_(Xol_lang_itm_.Id_pt, "trecho") // DATE:2014-07-18
|
||||
, Tag_pagequality = new_(Tid_pagequality, "pagequality").Xtn_()
|
||||
, Tag_pagelist = new_(Tid_pagelist, "pagelist").Xtn_()
|
||||
, Tag_categoryList = new_(Tid_categoryList, "categoryList").Xtn_()
|
||||
@@ -253,5 +254,6 @@ public class Xop_xnde_tag_ {
|
||||
, Tag_xowa_html = new_(Tid_xowa_html, "xowa_html").Xtn_()
|
||||
, Tag_xowa_tag_bgn = new_(Tid_xowa_tag_bgn, "xtag_bgn").Xtn_()
|
||||
, Tag_xowa_tag_end = new_(Tid_xowa_tag_end, "xtag_end").Xtn_()
|
||||
, Tag_quiz = new_(Tid_quiz, "quiz").Xtn_()
|
||||
;
|
||||
}
|
||||
|
||||
31
400_xowa/src_490_xnde/gplx/xowa/Xop_xnde_tag_lang.java
Normal file
31
400_xowa/src_490_xnde/gplx/xowa/Xop_xnde_tag_lang.java
Normal file
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa; import gplx.*;
|
||||
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);
|
||||
this.name_str = name_str;
|
||||
this.name_bry = Bry_.new_utf8_(name_str);
|
||||
this.xtnEndTag_tmp = Bry_.Add(Xop_xnde_tag_.XtnEndTag_bgn, name_bry);
|
||||
}
|
||||
public Int_obj_ref Lang_code() {return lang_code;} private Int_obj_ref lang_code;
|
||||
public String Name_str() {return name_str;} private String name_str;
|
||||
public byte[] Name_bry() {return name_bry;} private byte[] name_bry;
|
||||
public byte[] XtnEndTag_tmp() {return xtnEndTag_tmp;} private byte[] xtnEndTag_tmp;
|
||||
public static final Xop_xnde_tag_lang _ = new Xop_xnde_tag_lang(-1, String_.Empty);
|
||||
}
|
||||
@@ -21,18 +21,18 @@ public class Xop_xnde_tag_regy {
|
||||
public Btrie_slim_mgr XndeNames(int i) {
|
||||
if (nild) {Init(); nild = false;}
|
||||
switch (i) {
|
||||
case Xop_parser_.Parse_tid_tmpl: return tagRegy_tmpl;
|
||||
case Xop_parser_.Parse_tid_page_tmpl: return tagRegy_wiki_tmpl;
|
||||
case Xop_parser_.Parse_tid_page_wiki: return tagRegy_wiki_main;
|
||||
default: return tagRegy_wiki_tmpl; //throw Err_.unhandled(i);
|
||||
case Xop_parser_.Parse_tid_tmpl: return tag_regy_tmpl;
|
||||
case Xop_parser_.Parse_tid_page_tmpl: return tag_regy_wiki_tmpl;
|
||||
case Xop_parser_.Parse_tid_page_wiki: return tag_regy_wiki_main;
|
||||
default: return tag_regy_wiki_tmpl; //throw Err_.unhandled(i);
|
||||
}
|
||||
} boolean nild = true;
|
||||
public void Init() {
|
||||
Init_reg(tagRegy_tmpl , FilterXtns(Xop_xnde_tag_.Ary, Xop_xnde_tag_.Tag_includeonly, Xop_xnde_tag_.Tag_noinclude, Xop_xnde_tag_.Tag_onlyinclude, Xop_xnde_tag_.Tag_nowiki));
|
||||
Init_reg(tagRegy_wiki_tmpl , FilterXtns(Xop_xnde_tag_.Ary, Xop_xnde_tag_.Tag_includeonly, Xop_xnde_tag_.Tag_noinclude, Xop_xnde_tag_.Tag_onlyinclude, Xop_xnde_tag_.Tag_nowiki));
|
||||
Init_reg(tagRegy_wiki_main , Xop_xnde_tag_.Ary);
|
||||
Init_reg(tag_regy_tmpl , FilterXtns(Xop_xnde_tag_.Ary, Xop_xnde_tag_.Tag_includeonly, Xop_xnde_tag_.Tag_noinclude, Xop_xnde_tag_.Tag_onlyinclude, Xop_xnde_tag_.Tag_nowiki));
|
||||
Init_reg(tag_regy_wiki_tmpl , FilterXtns(Xop_xnde_tag_.Ary, Xop_xnde_tag_.Tag_includeonly, Xop_xnde_tag_.Tag_noinclude, Xop_xnde_tag_.Tag_onlyinclude, Xop_xnde_tag_.Tag_nowiki));
|
||||
Init_reg(tag_regy_wiki_main , Xop_xnde_tag_.Ary);
|
||||
}
|
||||
Xop_xnde_tag[] FilterXtns(Xop_xnde_tag[] ary, Xop_xnde_tag... more) {
|
||||
private Xop_xnde_tag[] FilterXtns(Xop_xnde_tag[] ary, Xop_xnde_tag... more) {
|
||||
ListAdp rv = ListAdp_.new_();
|
||||
for (Xop_xnde_tag itm : ary)
|
||||
if (itm.Xtn()) rv.Add(itm);
|
||||
@@ -40,13 +40,22 @@ public class Xop_xnde_tag_regy {
|
||||
rv.Add(itm);
|
||||
return (Xop_xnde_tag[])rv.XtoAry(Xop_xnde_tag.class);
|
||||
}
|
||||
private void Init_reg(Btrie_slim_mgr tagRegy, Xop_xnde_tag... ary) {
|
||||
for (Xop_xnde_tag tag : ary)
|
||||
tagRegy.Add_obj(tag.Name_bry(), tag);
|
||||
private void Init_reg(Btrie_slim_mgr tag_regy, Xop_xnde_tag... ary) {
|
||||
for (Xop_xnde_tag tag : ary) {
|
||||
tag_regy.Add_obj(tag.Name_bry(), tag);
|
||||
OrderedHash langs = tag.Langs();
|
||||
if (langs != null) { // tag has langs; EX: <section>; DATE:2014-07-18
|
||||
int langs_len = langs.Count();
|
||||
for (int i = 0; i < langs_len; ++i) { // register each lang's tag; EX:"<Abschnitt>", "<trecho>"
|
||||
Xop_xnde_tag_lang lang = (Xop_xnde_tag_lang)langs.FetchAt(i);
|
||||
tag_regy.Add_obj(lang.Name_bry(), tag);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private Btrie_slim_mgr
|
||||
tagRegy_wiki_main = Btrie_slim_mgr.ci_ascii_() // NOTE:ci.ascii:MW_const.en; listed XML node names are en
|
||||
, tagRegy_wiki_tmpl = Btrie_slim_mgr.ci_ascii_()
|
||||
, tagRegy_tmpl = Btrie_slim_mgr.ci_ascii_()
|
||||
tag_regy_wiki_main = Btrie_slim_mgr.ci_utf_8_() // NOTE:ci.utf8; he.s and <section> alias DATE:2014-07-18
|
||||
, tag_regy_wiki_tmpl = Btrie_slim_mgr.ci_utf_8_()
|
||||
, tag_regy_tmpl = Btrie_slim_mgr.ci_utf_8_()
|
||||
;
|
||||
}
|
||||
|
||||
@@ -63,6 +63,7 @@ public class Xop_xnde_wkr implements Xop_ctx_wkr {
|
||||
Btrie_slim_mgr tag_trie = ctx.App().Xnde_tag_regy().XndeNames(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();
|
||||
int name_bgn = cur_pos, name_end = atrs_bgn_pos;
|
||||
int tag_end_pos = atrs_bgn_pos - 1;
|
||||
if (tag_obj != null) {
|
||||
if (atrs_bgn_pos >= src_len) return ctx.Lxr_make_txt_(atrs_bgn_pos); // truncated tag; EX: "<br"
|
||||
@@ -111,7 +112,7 @@ public class Xop_xnde_wkr implements Xop_ctx_wkr {
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (ctx_cur_tid_is_tblw_atr_owner) Xop_tblw_wkr.Atrs_close(ctx, src, root);
|
||||
if (ctx_cur_tid_is_tblw_atr_owner) Xop_tblw_wkr.Atrs_close(ctx, src, root, Bool_.N);
|
||||
return ctx.Lxr_make_txt_(cur_pos);
|
||||
}
|
||||
}
|
||||
@@ -208,11 +209,12 @@ public class Xop_xnde_wkr implements Xop_ctx_wkr {
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (ctx_cur_tid_is_tblw_atr_owner) Xop_tblw_wkr.Atrs_close(ctx, src, root); // < found inside tblw; close off tblw attributes; EX: |- id='abcd' <td>a</td> (which is valid wikitext; NOTE: must happen after <nowiki>
|
||||
if (ctx_cur_tid_is_tblw_atr_owner)
|
||||
Xop_tblw_wkr.Atrs_close(ctx, src, root, Bool_.Y); // < found inside tblw; close off tblw attributes; EX: |- id='abcd' <td>a</td> (which is valid wikitext; NOTE: must happen after <nowiki>
|
||||
if (tag_is_closing)
|
||||
return Make_xtag_end(ctx, tkn_mkr, root, src, src_len, bgn_pos, gt_pos, tag);
|
||||
else
|
||||
return Make_xtag_bgn(ctx, tkn_mkr, root, src, src_len, bgn_pos, gt_pos, tag, atrs_bgn_pos, src[tag_end_pos], force_xtn_for_nowiki, pre2_hack);
|
||||
return Make_xtag_bgn(ctx, tkn_mkr, root, src, src_len, bgn_pos, gt_pos, name_bgn, name_end, tag, atrs_bgn_pos, src[tag_end_pos], force_xtn_for_nowiki, pre2_hack);
|
||||
}
|
||||
private static Xop_tkn_itm Make_bry_tkn(Xop_tkn_mkr tkn_mkr, byte[] src, int bgn_pos, int cur_pos) {
|
||||
int len = cur_pos - bgn_pos;
|
||||
@@ -269,7 +271,7 @@ public class Xop_xnde_wkr implements Xop_ctx_wkr {
|
||||
return end_rhs;
|
||||
}
|
||||
private boolean pre2_pending = false;
|
||||
private int Make_xtag_bgn(Xop_ctx ctx, Xop_tkn_mkr tkn_mkr, Xop_root_tkn root, byte[] src, int src_len, int bgn_pos, int gtPos, Xop_xnde_tag tag, int tag_end_pos, byte tag_end_byte, boolean force_xtn_for_nowiki, boolean pre2_hack) {
|
||||
private int Make_xtag_bgn(Xop_ctx ctx, Xop_tkn_mkr tkn_mkr, Xop_root_tkn root, byte[] src, int src_len, int bgn_pos, int gtPos, int name_bgn, int name_end, Xop_xnde_tag tag, int tag_end_pos, byte tag_end_byte, boolean force_xtn_for_nowiki, boolean pre2_hack) {
|
||||
boolean inline = false;
|
||||
int open_tag_end = gtPos + Launcher_app_mgr.Adj_next_char, atrs_bgn = -1, atrs_end = -1;
|
||||
// calc (a) inline; (b) atrs
|
||||
@@ -304,7 +306,7 @@ public class Xop_xnde_wkr implements Xop_ctx_wkr {
|
||||
|| (force_xtn_for_nowiki && !inline)
|
||||
)
|
||||
) {
|
||||
return Make_xnde_xtn(ctx, tkn_mkr, root, src, src_len, tag, bgn_pos, gtPos + 1, atrs_bgn, atrs_end, atrs, inline, pre2_hack); // find end tag and do not parse anything inbetween
|
||||
return Make_xnde_xtn(ctx, tkn_mkr, root, src, src_len, tag, bgn_pos, gtPos + 1, name_bgn, name_end, atrs_bgn, atrs_end, atrs, inline, pre2_hack); // find end tag and do not parse anything inbetween
|
||||
}
|
||||
if (tag.Restricted()) {
|
||||
Xoa_page page = ctx.Cur_page();
|
||||
@@ -564,7 +566,7 @@ public class Xop_xnde_wkr implements Xop_ctx_wkr {
|
||||
}
|
||||
}
|
||||
private int Find_xtn_end_tag(Xop_ctx ctx, byte[] src, int src_len, int open_end, byte[] close_bry, int tag_bgn) {
|
||||
int tag_id = Bry_.X_to_int_or(src, tag_bgn, tag_bgn + 10, -1);
|
||||
int tag_id = Bry_.Xto_int_or(src, tag_bgn, tag_bgn + 10, -1);
|
||||
if (tag_id == -1) {ctx.App().Usr_dlg().Warn_many("", "", "parser.xtn: could not extract int: page=~{0}", ctx.Cur_page().Url().Xto_full_str_safe()); return Bry_finder.Not_found;}
|
||||
Bry_bfr tmp = ctx.Wiki().Utl_bry_bfr_mkr().Get_b128();
|
||||
tmp.Add(Pf_tag.Xtag_end_lhs).Add_int_pad_bgn(Byte_ascii.Num_0, 10, tag_id).Add(Pf_tag.Xtag_rhs);
|
||||
@@ -575,7 +577,7 @@ public class Xop_xnde_wkr implements Xop_ctx_wkr {
|
||||
if (rv == Bry_finder.Not_found) {ctx.App().Usr_dlg().Warn_many("", "", "parser.xtn: could not find <: page=~{0}", ctx.Cur_page().Url().Xto_full_str_safe()); return Bry_finder.Not_found;}
|
||||
return rv;
|
||||
}
|
||||
private int Make_xnde_xtn(Xop_ctx ctx, Xop_tkn_mkr tkn_mkr, Xop_root_tkn root, byte[] src, int src_len, Xop_xnde_tag tag, int open_bgn, int open_end, int atrs_bgn, int atrs_end, Xop_xatr_itm[] atrs, boolean inline, boolean pre2_hack) {
|
||||
private int Make_xnde_xtn(Xop_ctx ctx, Xop_tkn_mkr tkn_mkr, Xop_root_tkn root, byte[] src, int src_len, Xop_xnde_tag tag, int open_bgn, int open_end, int name_bgn, int name_end, int atrs_bgn, int atrs_end, Xop_xatr_itm[] atrs, boolean inline, boolean pre2_hack) {
|
||||
// NOTE: find end_tag that exactly matches bgnTag; must be case sensitive;
|
||||
int xnde_end = open_end;
|
||||
Xop_xnde_tkn xnde = null;
|
||||
@@ -585,6 +587,13 @@ public class Xop_xnde_wkr implements Xop_ctx_wkr {
|
||||
}
|
||||
else {
|
||||
byte[] close_bry = tag.XtnEndTag_tmp(); // get tmp bry (so as not to new)
|
||||
if (tag.Langs() != null) { // cur tag has langs; EX:<section>; DATE:2014-07-18
|
||||
Xop_xnde_tag_lang tag_lang = tag.Langs_get(ctx.Lang().Case_mgr(), ctx.Cur_page().Lang().Lang_id(), src, name_bgn, name_end);
|
||||
if (tag_lang == null) // tag does not match lang; EX:<trecho> and lang=de;
|
||||
return ctx.Lxr_make_txt_(open_end);
|
||||
if (tag_lang != Xop_xnde_tag_lang._) // tag matches; note Xop_xnde_tag_lang._ is a wildcard match; EX:<section>
|
||||
close_bry = tag_lang.XtnEndTag_tmp();
|
||||
}
|
||||
int src_offset = open_bgn - 1; // open bgn to start at <; -2 to ignore </ ; +1 to include <
|
||||
int close_ary_len = close_bry.length;
|
||||
for (int i = 2; i < close_ary_len; i++) // 2 to ignore </
|
||||
@@ -652,6 +661,7 @@ public class Xop_xnde_wkr implements Xop_ctx_wkr {
|
||||
case Xop_xnde_tag_.Tid_languages: xnde_xtn = tkn_mkr.Xnde_languages(); break;
|
||||
case Xop_xnde_tag_.Tid_templateData: xnde_xtn = tkn_mkr.Xnde_templateData(); break;
|
||||
case Xop_xnde_tag_.Tid_rss: xnde_xtn = tkn_mkr.Xnde_rss(); break;
|
||||
case Xop_xnde_tag_.Tid_quiz: xnde_xtn = tkn_mkr.Xnde_quiz(); break;
|
||||
case Xop_xnde_tag_.Tid_xowa_html: xnde_xtn = tkn_mkr.Xnde_xowa_html(); break;
|
||||
case Xop_xnde_tag_.Tid_listing_buy:
|
||||
case Xop_xnde_tag_.Tid_listing_do:
|
||||
|
||||
@@ -20,7 +20,7 @@ import org.junit.*;
|
||||
public class Xop_xnde_wkr__basic_tst {
|
||||
private Xop_fxt fxt = new Xop_fxt();
|
||||
@After public void term() {fxt.Init_para_n_();}
|
||||
@Test public void Escape_lt() { // PURPOSE: some templates have unknown tags; EX.WP:PHP
|
||||
@Test public void Escape_lt() { // PURPOSE: some templates have unknown tags; PAGE:en.w:PHP
|
||||
fxt.Init_para_y_();
|
||||
fxt.Test_parse_page_wiki_str("a<code><?</code>b", String_.Concat_lines_nl_skip_last
|
||||
( "<p>a<code><?</code>b"
|
||||
|
||||
@@ -40,7 +40,7 @@ public class Xop_xnde_wkr__err_misc_tst {
|
||||
));
|
||||
fxt.Init_para_n_();
|
||||
}
|
||||
@Test public void Div_should_not_pop_past_td() { // PURPOSE: extra </div> should not close <div> that is outside of <td>; EX.WP:Rome and Ankara
|
||||
@Test public void Div_should_not_pop_past_td() { // PURPOSE: extra </div> should not close <div> that is outside of <td>; PAGE:en.w:Rome and Ankara
|
||||
fxt.Init_para_y_();
|
||||
fxt.Test_parse_page_wiki_str(String_.Concat_lines_nl_skip_last
|
||||
( "<table>"
|
||||
@@ -112,7 +112,7 @@ public class Xop_xnde_wkr__err_misc_tst {
|
||||
));
|
||||
fxt.Init_para_n_();
|
||||
}
|
||||
@Test public void Xnde_pops() { // PURPOSE: somehow xnde pops upper nde; EX.WP: Greek government debt crisis; "History of government debt"
|
||||
@Test public void Xnde_pops() { // PURPOSE: somehow xnde pops upper nde; PAGE:en.w:Greek government debt crisis; "History of government debt"
|
||||
fxt.Test_parse_page_wiki_str(String_.Concat_lines_nl_skip_last
|
||||
( "<i>"
|
||||
, "{|"
|
||||
|
||||
@@ -20,10 +20,10 @@ import org.junit.*;
|
||||
public class Xop_xnde_wkr__include_uncommon_tst {
|
||||
private Xop_fxt fxt = new Xop_fxt();
|
||||
@Before public void init() {fxt.Reset();}
|
||||
@Test public void Ex_Tmpl_io_oi() { // PURPOSE: <includeonly> not parsing internals; EX.WP: [[Template:MONTHNAME]]
|
||||
@Test public void Ex_Tmpl_io_oi() { // PURPOSE: <includeonly> not parsing internals; PAGE:en.w:[[Template:MONTHNAME]]
|
||||
fxt.Test_parse_tmpl_str_test("<includeonly>{{#if:{{{1}}}|a|b}}</includeonly><noinclude>c</noinclude>", "{{test|1}}", "a");
|
||||
}
|
||||
@Test public void Ex_Tmpl_io_subst() { // PURPOSE: <includeonly> and @gplx.Internal protected subst; EX.WP: [[Template:Dubious]]
|
||||
@Test public void Ex_Tmpl_io_subst() { // PURPOSE: <includeonly> and @gplx.Internal protected subst; PAGE:en.w:[[Template:Dubious]]
|
||||
fxt.Init_defn_clear();
|
||||
fxt.Init_defn_add("mwo_print", "{{{1}}}");
|
||||
fxt.Init_defn_add("substcheck", "SUBST");
|
||||
@@ -43,7 +43,7 @@ public class Xop_xnde_wkr__include_uncommon_tst {
|
||||
, "SUBST\n");
|
||||
fxt.Init_defn_clear();
|
||||
}
|
||||
@Test public void Ex_Tmpl_noinclude_prm_1() { // PURPOSE: <noinclude> should not process @gplx.Internal protected tkns; EX.WP: [[Template:See]]
|
||||
@Test public void Ex_Tmpl_noinclude_prm_1() { // PURPOSE: <noinclude> should not process @gplx.Internal protected tkns; PAGE:en.w:[[Template:See]]
|
||||
fxt.Init_defn_clear();
|
||||
fxt.Init_defn_add("mwo_print", "{{{1}}}{{{2}}}");
|
||||
fxt.Test_parse_tmpl_str_test
|
||||
@@ -98,7 +98,7 @@ public class Xop_xnde_wkr__include_uncommon_tst {
|
||||
, "a<noinclude/a/>bcde"
|
||||
);
|
||||
}
|
||||
@Test public void Defect_onlyinclude_inside_template() { // PURPOSE: was eating up next template; EX.WP:Wikipedia:Featured_articles
|
||||
@Test public void Defect_onlyinclude_inside_template() { // PURPOSE: was eating up next template; PAGE:en.w:Wikipedia:Featured_articles
|
||||
fxt.Test_parse_page_all_str
|
||||
( "{{formatnum: <onlyinclude>1</onlyinclude>}} {{formatnum:2}}"
|
||||
, "1 2"
|
||||
@@ -154,7 +154,7 @@ public class Xop_xnde_wkr__include_uncommon_tst {
|
||||
// }
|
||||
|
||||
// @Test public void Wiki_includeonly_ignore() {fxt.Test_parse_wiki_text("[[a<includeonly>b</includeonly>c]]", "[[ac]]");} // FUTURE: ttl parses by idx, and ignores includeonly: WHEN: upon encountering; may need to redo in other parsers?
|
||||
@Test public void Defect_noinclude_inside_main() { // PURPOSE: <onlyinclude> inside main was not returning content; EX.WP:Wikipedia:Featured_articles
|
||||
@Test public void Defect_noinclude_inside_main() { // PURPOSE: <onlyinclude> inside main was not returning content; PAGE:en.w:Wikipedia:Featured_articles
|
||||
fxt.Init_defn_clear();
|
||||
fxt.Init_defn_add("Test_tmpl", "{{:Test_page}}");
|
||||
fxt.Data_create("Test_page", "a{{#expr:<onlyinclude>1</onlyinclude>}}c");
|
||||
|
||||
@@ -38,14 +38,14 @@ public class Xop_xnde_wkr__nowiki_tst {
|
||||
));
|
||||
fxt.Init_para_n_();
|
||||
}
|
||||
@Test public void H2() { // EX.WP:HTML
|
||||
@Test public void H2() { // PAGE:en.w:HTML
|
||||
fxt.Test_parse_page_all_str
|
||||
( "a<nowiki><h1>b<h6></nowiki>c"
|
||||
, String_.Concat_lines_nl_skip_last
|
||||
( "a<h1>b<h6>c"
|
||||
));
|
||||
}
|
||||
@Test public void Lnke() { // EX.WP: Doomsday argument; <nowiki>[0, 1]</nowiki>
|
||||
@Test public void Lnke() { // PAGE:en.w:Doomsday argument; <nowiki>[0, 1]</nowiki>
|
||||
fxt.Test_parse_page_wiki_str("a <nowiki>[0, 1]</nowiki> b", "a [0, 1] b"); // NOTE: not "0" + Byte_.XtoStr(160) + "1"; depend on browser to translate
|
||||
}
|
||||
@Test public void Xatrs_val_text() {
|
||||
|
||||
@@ -31,7 +31,7 @@ public class Xop_xnde_wkr__tblx_tst {
|
||||
, fxt.tkn_txt_ (35, 36)
|
||||
);
|
||||
}
|
||||
@Test public void Ws_bgn() { // PURPOSE: some templates return leading ws; EX.WP:UK
|
||||
@Test public void Ws_bgn() { // PURPOSE: some templates return leading ws; PAGE:en.w:UK
|
||||
fxt.Init_para_y_();
|
||||
fxt.Test_parse_page_wiki_str(String_.Concat_lines_nl_skip_last
|
||||
( " <table>"
|
||||
|
||||
@@ -45,10 +45,10 @@ public class Xop_xnde_wkr__text_block_tst {
|
||||
));
|
||||
fxt.Init_para_n_();
|
||||
}
|
||||
@Test public void Code_dangling() { // EX.WP: HTML; <code><i><code> and <code><center><code> tags. There are
|
||||
@Test public void Code_dangling() { // PAGE:en.w:HTML; <code><i><code> and <code><center><code> tags. There are
|
||||
fxt.Test_parse_page_wiki_str("a<code>b<code>c", "a<code>b</code>c");
|
||||
}
|
||||
@Test public void Code_do_not_escape() { // PURPOSE: <code> was mistakenly marked as escape, causing inner tags to be rendered incorrectly; EX.WP:UTF8
|
||||
@Test public void Code_do_not_escape() { // PURPOSE: <code> was mistakenly marked as escape, causing inner tags to be rendered incorrectly; PAGE:en.w:UTF8
|
||||
fxt.Test_parse_page_all_str
|
||||
( "<code><span style=\"color:red;\">0100100</span></code>"
|
||||
, "<code><span style=\"color:red;\">0100100</span></code>"
|
||||
@@ -61,7 +61,7 @@ public class Xop_xnde_wkr__text_block_tst {
|
||||
fxt.Test_parse_page_all_str("<pre>a	b</pre>" , "<pre>a	b</pre>"); // known ncr/hex
|
||||
fxt.Test_parse_page_all_str("<pre>a'b</pre>" , "<pre>a'b</pre>"); // known name; embed
|
||||
fxt.Test_parse_page_all_str("<pre>a&apox;b</pre>" , "<pre>a&apox;b</pre>"); // unknown name; escape
|
||||
fxt.Test_parse_page_all_str("<pre>&\"<></pre>" , "<pre>&"<></pre>"); // no ncr or name; escape; needed for <pre><img ...></pre>; EX.WP: Alt attribute
|
||||
fxt.Test_parse_page_all_str("<pre>&\"<></pre>" , "<pre>&"<></pre>"); // no ncr or name; escape; needed for <pre><img ...></pre>; PAGE:en.w:Alt attribute
|
||||
}
|
||||
@Test public void Pre_and_space() {// PURPOSE: make sure pre does not careate <p></p> around it; also, make sure " a" is preserved; DATE:2014-02-20
|
||||
fxt.Init_para_y_();
|
||||
|
||||
@@ -45,7 +45,7 @@ public class Xop_xnde_wkr__xatrs_tst {
|
||||
fxt.Test_parse_page_wiki_str("<input value='a<'></input>", "<input value='a<'></input>"); // NOTE: do not call parse_page_all_str which will call Page.Clear and reset Restricted
|
||||
fxt.Page().Html_data().Restricted_y_();
|
||||
}
|
||||
// @Test public void Unclosed() { // PURPOSE: unclosed atr should be treated as key, which should be ignored; EX.WP:Palace of Versailles
|
||||
// @Test public void Unclosed() { // PURPOSE: unclosed atr should be treated as key, which should be ignored; PAGE:en.w:Palace of Versailles
|
||||
// fxt.Test_parse_page_wiki_str(String_.Concat_lines_nl_skip_last
|
||||
// ( "<span id=\"1<>>a" // id="1<> -> key named 'id="1<>' which fails whitelist keys
|
||||
// , "</span>"
|
||||
|
||||
Reference in New Issue
Block a user