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:
@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa; import gplx.*;
|
||||
import gplx.core.btries.*;
|
||||
class Xop_tblw_lxr implements Xop_lxr {
|
||||
public class Xop_tblw_lxr implements Xop_lxr {
|
||||
public byte Lxr_tid() {return Xop_lxr_.Tid_tblw;}
|
||||
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 rv = Handle_bang(wlxr_type, ctx, ctx.Tkn_mkr(), root, src, src_len, bgn_pos, cur_pos);
|
||||
|
||||
@@ -112,7 +112,7 @@ public class Xop_tblw_wkr implements Xop_ctx_wkr {
|
||||
if (prv_tkn != null && !prv_tkn.Tblw_xml()) { // note that this logic is same as Atrs_close; repeated here for "perf"
|
||||
switch (prv_tid) {
|
||||
case Xop_tkn_itm_.Tid_tblw_tb: case Xop_tkn_itm_.Tid_tblw_tr:
|
||||
Atrs_make(ctx, src, root, this, prv_tkn);
|
||||
Atrs_make(ctx, src, root, this, prv_tkn, Bool_.N);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -410,17 +410,29 @@ public class Xop_tblw_wkr implements Xop_ctx_wkr {
|
||||
}
|
||||
return cur_pos;
|
||||
}
|
||||
public static void Atrs_close(Xop_ctx ctx, byte[] src, Xop_root_tkn root) {
|
||||
public static void Atrs_close(Xop_ctx ctx, byte[] src, Xop_root_tkn root, boolean called_from_xnde) {
|
||||
Xop_tblw_tkn prv_tkn = ctx.Stack_get_tbl();
|
||||
if (prv_tkn == null || prv_tkn.Tblw_xml()) return; // no tblw or tblw_xnde (which does not have tblw atrs)
|
||||
switch (prv_tkn.Tkn_tid()) {
|
||||
case Xop_tkn_itm_.Tid_tblw_tb: case Xop_tkn_itm_.Tid_tblw_tr: // only tb and tr have tblw atrs (EX: "{|id=1\n"); td/th use pipes for atrs (EX: "|id=1|a"); tc has no atrs; te is never on stack
|
||||
Xop_tblw_wkr.Atrs_make(ctx, src, root, ctx.Tblw(), prv_tkn);
|
||||
Xop_tblw_wkr.Atrs_make(ctx, src, root, ctx.Tblw(), prv_tkn, called_from_xnde);
|
||||
break;
|
||||
}
|
||||
}
|
||||
public static boolean Atrs_make(Xop_ctx ctx, byte[] src, Xop_root_tkn root, Xop_tblw_wkr wkr, Xop_tblw_tkn prv_tblw) {
|
||||
if (prv_tblw.Atrs_bgn() != Xop_tblw_wkr.Atrs_null) return false; // atr_bgn/end is empty or already has explicit value; ignore;
|
||||
public static boolean Atrs_make(Xop_ctx ctx, byte[] src, Xop_root_tkn root, Xop_tblw_wkr wkr, Xop_tblw_tkn prv_tblw, boolean called_from_xnde) {
|
||||
if (prv_tblw.Atrs_bgn() != Xop_tblw_wkr.Atrs_null) { // atr_bgn/end is empty or already has explicit value; ignore;
|
||||
if (prv_tblw.Atrs_bgn() == Atrs_invalid_by_xnde) { // atr range marked invalid; ignore all tkns between prv_tblw and end of root; EX:"|-id=1<br/>"; PAGE:en.w:A DATE:2014-07-16
|
||||
for (int j = root.Subs_len() - 1; j > -1; --j) {
|
||||
Xop_tkn_itm sub = root.Subs_get(j);
|
||||
if (sub == prv_tblw)
|
||||
return false;
|
||||
else
|
||||
sub.Ignore_y_();
|
||||
}
|
||||
ctx.App().Usr_dlg().Warn_many("", "", "xnde.invalided attributes could not find previous tkn; page=~{0}", ctx.Page_url_str()); // should never happen; DATE:2014-07-16
|
||||
}
|
||||
return false;
|
||||
}
|
||||
int subs_bgn = prv_tblw.Tkn_sub_idx() + 1, subs_end = root.Subs_len() - 1;
|
||||
int subs_pos = subs_bgn;
|
||||
Xop_tkn_itm last_atr_tkn = null;
|
||||
@@ -441,7 +453,14 @@ public class Xop_tblw_wkr implements Xop_ctx_wkr {
|
||||
}
|
||||
}
|
||||
if (last_atr_tkn == null) { // no atrs found; mark tblw_tkn as Atrs_empty
|
||||
prv_tblw.Atrs_rng_set(Xop_tblw_wkr.Atrs_empty, Xop_tblw_wkr.Atrs_empty);
|
||||
int atr_rng_tid
|
||||
= called_from_xnde
|
||||
&& !prv_tblw.Tblw_xml()
|
||||
&& prv_tblw.Tkn_tid() == Xop_tkn_itm_.Tid_tblw_tr // called from xnde && current tid is Tblw_tr; EX:"|- <br/>" PAGE:en.w:A DATE:2014-07-16
|
||||
? Atrs_invalid_by_xnde // invalidate everything
|
||||
: Atrs_empty
|
||||
;
|
||||
prv_tblw.Atrs_rng_set(atr_rng_tid, atr_rng_tid);
|
||||
return false;
|
||||
}
|
||||
root.Subs_del_between(ctx, subs_bgn, subs_pos);
|
||||
@@ -514,7 +533,7 @@ public class Xop_tblw_wkr implements Xop_ctx_wkr {
|
||||
ctx.Subs_add(root, tkn);
|
||||
return cur_pos;
|
||||
}
|
||||
public static final int Atrs_null = -1, Atrs_empty = -2, Atrs_ignore_check = -1;
|
||||
public static final int Atrs_null = -1, Atrs_empty = -2, Atrs_invalid_by_xnde = -3, Atrs_ignore_check = -1;
|
||||
public static final byte Tblw_type_tb = 0, Tblw_type_te = 1, Tblw_type_tr = 2, Tblw_type_td = 3, Tblw_type_th = 4, Tblw_type_tc = 5, Tblw_type_td2 = 6, Tblw_type_th2 = 7;
|
||||
}
|
||||
/*
|
||||
|
||||
212
400_xowa/src_480_tblw/gplx/xowa/Xop_tblw_wkr__atrs_tst.java
Normal file
212
400_xowa/src_480_tblw/gplx/xowa/Xop_tblw_wkr__atrs_tst.java
Normal file
@@ -0,0 +1,212 @@
|
||||
/*
|
||||
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.*;
|
||||
import org.junit.*;
|
||||
public class Xop_tblw_wkr__atrs_tst {
|
||||
private Xop_fxt fxt = new Xop_fxt();
|
||||
@Test public void Tr() {
|
||||
fxt.Test_parse_page_wiki(String_.Concat_lines_nl_skip_last
|
||||
( "{|"
|
||||
, "|-style='a'"
|
||||
, "|b"
|
||||
, "|}"
|
||||
), fxt.tkn_tblw_tb_(0, 20).Subs_
|
||||
( fxt.tkn_tblw_tr_(2, 17).Atrs_rng_(5, 14).Subs_
|
||||
( fxt.tkn_tblw_td_(14, 17).Subs_(fxt.tkn_txt_(16, 17), fxt.tkn_para_blank_(18))
|
||||
))
|
||||
);
|
||||
}
|
||||
@Test public void Td() {
|
||||
fxt.Test_parse_page_wiki(String_.Concat_lines_nl_skip_last
|
||||
( "{|"
|
||||
, "|-"
|
||||
, "|style='a'|b"
|
||||
, "|}"
|
||||
), fxt.tkn_tblw_tb_(0, 21).Subs_
|
||||
( fxt.tkn_tblw_tr_(2, 18).Subs_
|
||||
( fxt.tkn_tblw_td_(5, 18).Atrs_rng_(7, 16).Subs_(fxt.tkn_txt_(17, 18), fxt.tkn_para_blank_(19))
|
||||
))
|
||||
);
|
||||
}
|
||||
@Test public void Td_mult() {
|
||||
fxt.Init_para_y_();
|
||||
fxt.Test_parse_page_wiki_str(String_.Concat_lines_nl_skip_last
|
||||
( "{|"
|
||||
, "|-"
|
||||
, "|"
|
||||
, " {|"
|
||||
, " |-"
|
||||
, " | id='1'|"
|
||||
, " | id='2'|a"
|
||||
, " | id='3'|"
|
||||
, " |}"
|
||||
, "|}"
|
||||
)
|
||||
, String_.Concat_lines_nl_skip_last
|
||||
( "<table>"
|
||||
, " <tr>"
|
||||
, " <td>"
|
||||
, " <table>"
|
||||
, " <tr>"
|
||||
, " <td id='1'>"
|
||||
, " </td>"
|
||||
, " <td id='2'>a"
|
||||
, " </td>"
|
||||
, " <td id='3'>"
|
||||
, " </td>"
|
||||
, " </tr>"
|
||||
, " </table>"
|
||||
, " </td>"
|
||||
, " </tr>"
|
||||
, "</table>"
|
||||
, ""
|
||||
)
|
||||
);
|
||||
fxt.Init_para_n_();
|
||||
}
|
||||
@Test public void Tc() { // PAGE:en.w:1920_Palm_Sunday_tornado_outbreak
|
||||
fxt.Init_para_y_();
|
||||
fxt.Test_parse_page_wiki_str(String_.Concat_lines_nl_skip_last
|
||||
( "{|id='1'"
|
||||
, "|+id='2'|a"
|
||||
, "|}"
|
||||
)
|
||||
, String_.Concat_lines_nl_skip_last
|
||||
( "<table id='1'>"
|
||||
, " <caption id='2'>a"
|
||||
, " </caption>"
|
||||
, "</table>"
|
||||
, ""
|
||||
)
|
||||
);
|
||||
fxt.Init_para_n_();
|
||||
}
|
||||
@Test public void Td_mixed() {
|
||||
fxt.Test_parse_page_wiki(String_.Concat_lines_nl_skip_last
|
||||
( "{|"
|
||||
, "|-"
|
||||
, "|style='a'|b||c"
|
||||
, "|}"
|
||||
), fxt.tkn_tblw_tb_(0, 24).Subs_
|
||||
( fxt.tkn_tblw_tr_(2, 21).Subs_
|
||||
( fxt.tkn_tblw_td_( 5, 18).Atrs_rng_(7, 16).Subs_(fxt.tkn_txt_(17, 18), fxt.tkn_para_blank_(19))
|
||||
, fxt.tkn_tblw_td_(18, 21).Subs_(fxt.tkn_txt_(20, 21), fxt.tkn_para_blank_(22))
|
||||
))
|
||||
);
|
||||
}
|
||||
@Test public void Th() {
|
||||
fxt.Test_parse_page_wiki(String_.Concat_lines_nl_skip_last
|
||||
( "{|"
|
||||
, "|-"
|
||||
, "!style='a'|b"
|
||||
, "|}"
|
||||
), fxt.tkn_tblw_tb_(0, 21).Subs_
|
||||
( fxt.tkn_tblw_tr_(2, 18).Subs_
|
||||
( fxt.tkn_tblw_th_(5, 18).Atrs_rng_(7, 16).Subs_(fxt.tkn_txt_(17, 18), fxt.tkn_para_blank_(19))
|
||||
))
|
||||
);
|
||||
}
|
||||
@Test public void Skip_hdr() {
|
||||
fxt.Test_parse_page_wiki(String_.Concat_lines_nl_skip_last
|
||||
( "{|"
|
||||
, "|+b"
|
||||
, "!style='a'|b"
|
||||
, "|}"
|
||||
), fxt.tkn_tblw_tb_(0, 22).Caption_count_(1).Subs_
|
||||
( fxt.tkn_tblw_tc_(2, 6).Subs_(fxt.tkn_txt_( 5, 6))
|
||||
, fxt.tkn_tblw_tr_(6, 19).Subs_
|
||||
( fxt.tkn_tblw_th_(6, 19).Atrs_rng_(8, 17).Subs_(fxt.tkn_txt_(18, 19), fxt.tkn_para_blank_(20))
|
||||
)
|
||||
));
|
||||
}
|
||||
@Test public void Td_bg_color() { // PURPOSE: atr_parser should treat # as valid character in unquoted val; PAGE:en.w:UTF8; |bgcolor=#eeeeee|<small>Indic</small><br/><small>0800*</small><br/>'''''224'''''
|
||||
fxt.Init_para_y_();
|
||||
fxt.Test_parse_page_wiki_str(String_.Concat_lines_nl_skip_last
|
||||
( "{|"
|
||||
, "|bgcolor=#eeeeee|a"
|
||||
, "|}"
|
||||
)
|
||||
, String_.Concat_lines_nl_skip_last
|
||||
( "<table>"
|
||||
, " <tr>"
|
||||
, " <td bgcolor=\"#eeeeee\">a"
|
||||
, " </td>"
|
||||
, " </tr>"
|
||||
, "</table>"
|
||||
, ""
|
||||
)
|
||||
);
|
||||
fxt.Init_para_n_();
|
||||
}
|
||||
@Test public void Xnde_tb() { // PURPOSE: xnde should close any open xatrs; PAGE:en.w:Western_Front_(World_War_I); stray > after == Dramatizations ==
|
||||
fxt.Test_parse_page_wiki_str(String_.Concat_lines_nl_skip_last
|
||||
( "{|id='1'<p></p>"
|
||||
, "|a"
|
||||
, "|}"), String_.Concat_lines_nl_skip_last
|
||||
( "<table id='1'><p></p>"
|
||||
, " <tr>"
|
||||
, " <td>a"
|
||||
, " </td>"
|
||||
, " </tr>"
|
||||
, "</table>"
|
||||
, ""
|
||||
));
|
||||
}
|
||||
@Test public void Xnde_tr() { // PURPOSE: xnde should disable all tkns; PAGE:en.w:A DATE:2014-07-16
|
||||
fxt.Test_parse_page_wiki_str(String_.Concat_lines_nl_skip_last
|
||||
( "{|"
|
||||
, "|-<b>c</b>id='d'<br/>" // note that id='d' should not show up since <b> invalidates entire line
|
||||
, "|a"
|
||||
, "|}"
|
||||
), String_.Concat_lines_nl_skip_last
|
||||
( "<table>"
|
||||
, " <tr>"
|
||||
, " <td>a"
|
||||
, " </td>"
|
||||
, " </tr>"
|
||||
, "</table>"
|
||||
));
|
||||
}
|
||||
@Test public void Xnde_mix_tblw_tblx() { // PURPOSE: issue with </tr> somehow rolling up everything after <td>; PAGE:en.w:20th_century; {{Decades and years}}
|
||||
fxt.Init_para_y_();
|
||||
fxt.Test_parse_page_wiki_str(String_.Concat_lines_nl_skip_last
|
||||
( "<table><tr><td>a"
|
||||
, "{|id=1"
|
||||
, "|-"
|
||||
, "|b"
|
||||
, "|}</td></tr></table>"
|
||||
)
|
||||
, String_.Concat_lines_nl_skip_last
|
||||
( "<table>"
|
||||
, " <tr>"
|
||||
, " <td>a"
|
||||
, " <table id=\"1\">"
|
||||
, " <tr>"
|
||||
, " <td>b"
|
||||
, " </td>"
|
||||
, " </tr>"
|
||||
, " </table>"
|
||||
, " </td>"
|
||||
, " </tr>"
|
||||
, "</table>"
|
||||
, ""
|
||||
)
|
||||
);
|
||||
fxt.Init_para_n_();
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa; import gplx.*;
|
||||
import org.junit.*;
|
||||
public class Xop_tblw_wkr_basic_tst {
|
||||
public class Xop_tblw_wkr__basic_tst {
|
||||
private Xop_fxt fxt = new Xop_fxt();
|
||||
@Test public void Td() { // Tb_tr_td_te
|
||||
fxt.Test_parse_page_wiki("{|\n|-\n|a\n|}"
|
||||
@@ -76,7 +76,7 @@ public class Xop_tblw_wkr_basic_tst {
|
||||
, fxt.tkn_tblw_th_(8, 11).Subs_(fxt.tkn_txt_(10, 11), fxt.tkn_para_blank_(12))
|
||||
)));
|
||||
}
|
||||
@Test public void Tb_td2() { // EX.WP: Hectare; {| class="wikitable" || style="border: 1px solid #FFFFFF;"
|
||||
@Test public void Tb_td2() { // PAGE:en.w:Hectare; {| class="wikitable" || style="border: 1px solid #FFFFFF;"
|
||||
fxt.Test_parse_page_wiki_str(String_.Concat_lines_nl_skip_last
|
||||
( "{|id='1' || class='a'"
|
||||
, "|-"
|
||||
@@ -92,239 +92,6 @@ public class Xop_tblw_wkr_basic_tst {
|
||||
, ""
|
||||
));
|
||||
}
|
||||
@Test public void Atrs_tr() { // Tb_tr_td_te
|
||||
fxt.Test_parse_page_wiki("{|\n|-style='a'\n|b\n|}"
|
||||
, fxt.tkn_tblw_tb_(0, 20).Subs_
|
||||
( fxt.tkn_tblw_tr_(2, 17).Atrs_rng_(5, 14).Subs_
|
||||
( fxt.tkn_tblw_td_(14, 17).Subs_(fxt.tkn_txt_(16, 17), fxt.tkn_para_blank_(18))
|
||||
))
|
||||
);
|
||||
}
|
||||
@Test public void Atrs_td() { // Tb_tr_td_te
|
||||
fxt.Test_parse_page_wiki("{|\n|-\n|style='a'|b\n|}"
|
||||
, fxt.tkn_tblw_tb_(0, 21).Subs_
|
||||
( fxt.tkn_tblw_tr_(2, 18).Subs_
|
||||
( fxt.tkn_tblw_td_(5, 18).Atrs_rng_(7, 16).Subs_(fxt.tkn_txt_(17, 18), fxt.tkn_para_blank_(19))
|
||||
))
|
||||
);
|
||||
}
|
||||
@Test public void Atrs_td_mult() {
|
||||
fxt.Init_para_y_();
|
||||
fxt.Test_parse_page_wiki_str(String_.Concat_lines_nl_skip_last
|
||||
( "{|"
|
||||
, "|-"
|
||||
, "|"
|
||||
, " {|"
|
||||
, " |-"
|
||||
, " | id='1'|"
|
||||
, " | id='2'|a"
|
||||
, " | id='3'|"
|
||||
, " |}"
|
||||
, "|}"
|
||||
)
|
||||
, String_.Concat_lines_nl_skip_last
|
||||
( "<table>"
|
||||
, " <tr>"
|
||||
, " <td>"
|
||||
, " <table>"
|
||||
, " <tr>"
|
||||
, " <td id='1'>"
|
||||
, " </td>"
|
||||
, " <td id='2'>a"
|
||||
, " </td>"
|
||||
, " <td id='3'>"
|
||||
, " </td>"
|
||||
, " </tr>"
|
||||
, " </table>"
|
||||
, " </td>"
|
||||
, " </tr>"
|
||||
, "</table>"
|
||||
, ""
|
||||
)
|
||||
);
|
||||
fxt.Init_para_n_();
|
||||
}
|
||||
@Test public void Atrs_tc() { // REF:WP:[[1920 Palm Sunday tornado outbreak]]
|
||||
fxt.Init_para_y_();
|
||||
fxt.Test_parse_page_wiki_str(String_.Concat_lines_nl_skip_last
|
||||
( "{|id='1'"
|
||||
, "|+id='2'|a"
|
||||
, "|}"
|
||||
)
|
||||
, String_.Concat_lines_nl_skip_last
|
||||
( "<table id='1'>"
|
||||
, " <caption id='2'>a"
|
||||
, " </caption>"
|
||||
, "</table>"
|
||||
, ""
|
||||
)
|
||||
);
|
||||
fxt.Init_para_n_();
|
||||
}
|
||||
@Test public void Atrs_td_mixed() { // Tb_tr_td_td2_te
|
||||
fxt.Test_parse_page_wiki("{|\n|-\n|style='a'|b||c\n|}"
|
||||
, fxt.tkn_tblw_tb_(0, 24).Subs_
|
||||
( fxt.tkn_tblw_tr_(2, 21).Subs_
|
||||
( fxt.tkn_tblw_td_( 5, 18).Atrs_rng_(7, 16).Subs_(fxt.tkn_txt_(17, 18), fxt.tkn_para_blank_(19))
|
||||
, fxt.tkn_tblw_td_(18, 21).Subs_(fxt.tkn_txt_(20, 21), fxt.tkn_para_blank_(22))
|
||||
))
|
||||
);
|
||||
}
|
||||
@Test public void Atrs_th() {
|
||||
fxt.Test_parse_page_wiki("{|\n|-\n!style='a'|b\n|}"
|
||||
, fxt.tkn_tblw_tb_(0, 21).Subs_
|
||||
( fxt.tkn_tblw_tr_(2, 18).Subs_
|
||||
( fxt.tkn_tblw_th_(5, 18).Atrs_rng_(7, 16).Subs_(fxt.tkn_txt_(17, 18), fxt.tkn_para_blank_(19))
|
||||
))
|
||||
);
|
||||
}
|
||||
@Test public void Atrs_th_cap() {
|
||||
fxt.Test_parse_page_wiki("{|\n|+b\n!style='a'|b\n|}"
|
||||
, fxt.tkn_tblw_tb_(0, 22).Caption_count_(1).Subs_
|
||||
( fxt.tkn_tblw_tc_(2, 6).Subs_(fxt.tkn_txt_( 5, 6))
|
||||
, fxt.tkn_tblw_tr_(6, 19).Subs_
|
||||
( fxt.tkn_tblw_th_(6, 19).Atrs_rng_(8, 17).Subs_(fxt.tkn_txt_(18, 19), fxt.tkn_para_blank_(20))
|
||||
)
|
||||
));
|
||||
}
|
||||
@Test public void Atrs_skip_hdr() {
|
||||
fxt.Test_parse_page_wiki("{|\n|+b\n!style='a'|b\n|}"
|
||||
, fxt.tkn_tblw_tb_(0, 22).Caption_count_(1).Subs_
|
||||
( fxt.tkn_tblw_tc_(2, 6).Subs_(fxt.tkn_txt_( 5, 6))
|
||||
, fxt.tkn_tblw_tr_(6, 19).Subs_
|
||||
( fxt.tkn_tblw_th_(6, 19).Atrs_rng_(8, 17).Subs_(fxt.tkn_txt_(18, 19), fxt.tkn_para_blank_(20))
|
||||
)
|
||||
));
|
||||
}
|
||||
@Test public void Atrs_td_bg_color() { // PURPOSE: atr_parser should treat # as valid character in unquoted val; EX.WP:UTF8; |bgcolor=#eeeeee|<small>Indic</small><br/><small>0800*</small><br/>'''''224'''''
|
||||
fxt.Init_para_y_();
|
||||
fxt.Test_parse_page_wiki_str(String_.Concat_lines_nl_skip_last
|
||||
( "{|"
|
||||
, "|bgcolor=#eeeeee|a"
|
||||
, "|}"
|
||||
)
|
||||
, String_.Concat_lines_nl_skip_last
|
||||
( "<table>"
|
||||
, " <tr>"
|
||||
, " <td bgcolor=\"#eeeeee\">a"
|
||||
, " </td>"
|
||||
, " </tr>"
|
||||
, "</table>"
|
||||
, ""
|
||||
)
|
||||
);
|
||||
fxt.Init_para_n_();
|
||||
}
|
||||
@Test public void AutoClose_td_when_new_tr() { // retain; needed for de.w:Main_Page; DATE:2013-12-09
|
||||
fxt.Test_parse_page_wiki_str(String_.Concat_lines_nl_skip_last
|
||||
( "{|"
|
||||
, "==a=="
|
||||
, "|}"
|
||||
)
|
||||
, String_.Concat_lines_nl_skip_last
|
||||
( "<table>"
|
||||
, ""
|
||||
, "<h2>a</h2>" // NOTE: malformed html matches MW
|
||||
, " <tr>"
|
||||
, " <td>"
|
||||
, " </td>"
|
||||
, " </tr>"
|
||||
, "</table>"
|
||||
, ""
|
||||
)
|
||||
);
|
||||
fxt.Test_parse_page_wiki("{|\n==b==\n|}"
|
||||
, fxt.tkn_tblw_tb_(0, 8).Subs_
|
||||
( fxt.tkn_hdr_(2, 8, 2).Subs_
|
||||
( fxt.tkn_txt_(5, 6)
|
||||
)
|
||||
, fxt.tkn_para_blank_(9)
|
||||
, fxt.tkn_tblw_tr_(8, 8).Subs_
|
||||
( fxt.tkn_tblw_td_( 8, 8))
|
||||
)
|
||||
);
|
||||
}
|
||||
@Test public void Atr_close() { // PURPOSE: issue with </tr> somehow rolling up everything after <td>; EX.WP: 20th century; {{Decades and years}}
|
||||
fxt.Init_para_y_();
|
||||
fxt.Test_parse_page_wiki_str(String_.Concat_lines_nl_skip_last
|
||||
( "<table><tr><td>a"
|
||||
, "{|id=1"
|
||||
, "|-"
|
||||
, "|b"
|
||||
, "|}</td></tr></table>"
|
||||
)
|
||||
, String_.Concat_lines_nl_skip_last
|
||||
( "<table>"
|
||||
, " <tr>"
|
||||
, " <td>a"
|
||||
, " <table id=\"1\">"
|
||||
, " <tr>"
|
||||
, " <td>b"
|
||||
, " </td>"
|
||||
, " </tr>"
|
||||
, " </table>"
|
||||
, " </td>"
|
||||
, " </tr>"
|
||||
, "</table>"
|
||||
, ""
|
||||
)
|
||||
);
|
||||
fxt.Init_para_n_();
|
||||
}
|
||||
@Test public void Err_row_empty() {
|
||||
fxt.Test_parse_page_wiki("{|\n|-\n|-\n|a\n|}"
|
||||
, fxt.tkn_tblw_tb_(0, 14).Subs_
|
||||
( fxt.tkn_tblw_tr_(2, 5)
|
||||
, fxt.tkn_tblw_tr_(5, 11).Subs_
|
||||
( fxt.tkn_tblw_td_(8, 11).Subs_(fxt.tkn_txt_(10, 11), fxt.tkn_para_blank_(12))
|
||||
))
|
||||
);
|
||||
}
|
||||
@Test public void Err_row_trailing() {
|
||||
fxt.Test_parse_page_wiki("{|\n|-\n|a\n|-\n|}"
|
||||
, fxt.tkn_tblw_tb_(0, 14).Subs_
|
||||
( fxt.tkn_tblw_tr_(2, 8).Subs_
|
||||
( fxt.tkn_tblw_td_(5, 8).Subs_(fxt.tkn_txt_(7, 8), fxt.tkn_para_blank_(9))
|
||||
))
|
||||
);
|
||||
}
|
||||
@Test public void Err_caption_after_tr() {
|
||||
fxt.Test_parse_page_wiki("{|\n|-\n|+a\n|}"
|
||||
, fxt.tkn_tblw_tb_(0, 12).Caption_count_(1).Subs_
|
||||
( fxt.tkn_tblw_tr_(2, 5)
|
||||
, fxt.tkn_tblw_tc_(5, 9).Subs_(fxt.tkn_txt_(8, 9), fxt.tkn_para_blank_(10)))
|
||||
);
|
||||
}
|
||||
@Test public void Err_caption_after_td() {
|
||||
fxt.Init_log_(Xop_tblw_log.Caption_after_td).Test_parse_page_wiki("{|\n|-\n|a\n|+b\n|}"
|
||||
, fxt.tkn_tblw_tb_(0, 15).Caption_count_(1).Subs_
|
||||
( fxt.tkn_tblw_tr_(2, 8).Subs_
|
||||
( fxt.tkn_tblw_td_(5, 8).Subs_(fxt.tkn_txt_(7, 8)))
|
||||
, fxt.tkn_tblw_tc_(8, 12).Subs_(fxt.tkn_txt_(11, 12), fxt.tkn_para_blank_(13)))
|
||||
);
|
||||
}
|
||||
@Test public void Err_caption_after_tc() {
|
||||
fxt.Init_log_(Xop_tblw_log.Caption_after_tc).Test_parse_page_wiki("{|\n|+a\n|+b\n|}"
|
||||
, fxt.tkn_tblw_tb_(0, 13).Caption_count_(2).Subs_
|
||||
( fxt.tkn_tblw_tc_(2, 6).Subs_(fxt.tkn_txt_( 5, 6))
|
||||
, fxt.tkn_tblw_tc_(6, 10).Subs_(fxt.tkn_txt_( 9, 10), fxt.tkn_para_blank_(11)))
|
||||
);
|
||||
}
|
||||
@Test public void Err_row_auto_opened() {
|
||||
fxt.Test_parse_page_wiki("{|\n|a\n|}"
|
||||
, fxt.tkn_tblw_tb_(0, 8).Subs_
|
||||
( fxt.tkn_tblw_tr_(2, 5).Subs_
|
||||
( fxt.tkn_tblw_td_(2, 5).Subs_(fxt.tkn_txt_(4, 5), fxt.tkn_para_blank_(6))
|
||||
)));
|
||||
}
|
||||
@Test public void Err_caption_auto_closed() {
|
||||
fxt.Test_parse_page_wiki("{|\n|+a\n|b\n|}"
|
||||
, fxt.tkn_tblw_tb_(0, 12).Caption_count_(1).Subs_
|
||||
( fxt.tkn_tblw_tc_(2, 6).Subs_(fxt.tkn_txt_(5, 6))
|
||||
, fxt.tkn_tblw_tr_(6, 9).Subs_
|
||||
( fxt.tkn_tblw_td_(6, 9).Subs_(fxt.tkn_txt_(8, 9),fxt.tkn_para_blank_(10))
|
||||
)));
|
||||
}
|
||||
@Test public void Td_lnki() {
|
||||
fxt.Test_parse_page_wiki("{|\n|-\n|[[a|b]]\n|}"
|
||||
, fxt.tkn_tblw_tb_(0, 17).Subs_
|
||||
@@ -332,24 +99,6 @@ public class Xop_tblw_wkr_basic_tst {
|
||||
( fxt.tkn_tblw_td_(5, 14).Subs_(fxt.tkn_lnki_(7, 14), fxt.tkn_para_blank_(15))))
|
||||
);
|
||||
}
|
||||
@Test public void Err_Atrs_dumped_into_text() { // PURPOSE: [[Prawn]] and {{Taxobox}} was dumping text
|
||||
fxt.Test_parse_page_wiki_str(String_.Concat_lines_nl_skip_last
|
||||
( "{|"
|
||||
, "|-"
|
||||
, "|-id='a'"
|
||||
, "|b"
|
||||
, "|}"
|
||||
) , String_.Concat_lines_nl_skip_last
|
||||
( "<table>"
|
||||
, " <tr id='a'>"
|
||||
, " <td>b"
|
||||
, " </td>"
|
||||
, " </tr>"
|
||||
, "</table>"
|
||||
, ""
|
||||
)
|
||||
);
|
||||
}
|
||||
@Test public void Tr_dupe_xnde() { // PURPOSE: redundant tr should not be dropped; see [[Jupiter]]
|
||||
fxt.Test_parse_page_wiki_str(String_.Concat_lines_nl_skip_last
|
||||
( "{|"
|
||||
@@ -581,20 +330,6 @@ public class Xop_tblw_wkr_basic_tst {
|
||||
);
|
||||
fxt.Init_para_n_();
|
||||
}
|
||||
@Test public void Atr_xnde() { // PURPOSE: xnde should close any open xatrs; EX.WP: Western Front (World War I); stray > after == Dramatizations ==
|
||||
fxt.Test_parse_page_wiki_str(String_.Concat_lines_nl_skip_last
|
||||
( "{|id='1'<p></p>"
|
||||
, "|a"
|
||||
, "|}"), String_.Concat_lines_nl_skip_last
|
||||
( "<table id='1'><p></p>"
|
||||
, " <tr>"
|
||||
, " <td>a"
|
||||
, " </td>"
|
||||
, " </tr>"
|
||||
, "</table>"
|
||||
, ""
|
||||
));
|
||||
}
|
||||
@Test public void No_wiki_3() {
|
||||
fxt.Test_parse_page_wiki_str(String_.Concat_lines_nl_skip_last
|
||||
( "{|"
|
||||
@@ -774,6 +509,33 @@ public class Xop_tblw_wkr_basic_tst {
|
||||
));
|
||||
fxt.Init_para_n_();
|
||||
}
|
||||
@Test public void AutoClose_td_when_new_tr() { // retain; needed for de.w:Main_Page; DATE:2013-12-09
|
||||
fxt.Test_parse_page_wiki_str(String_.Concat_lines_nl_skip_last
|
||||
( "{|"
|
||||
, "==a=="
|
||||
, "|}"
|
||||
)
|
||||
, String_.Concat_lines_nl_skip_last
|
||||
( "<table>"
|
||||
, ""
|
||||
, "<h2>a</h2>" // NOTE: malformed html matches MW
|
||||
, " <tr>"
|
||||
, " <td>"
|
||||
, " </td>"
|
||||
, " </tr>"
|
||||
, "</table>"
|
||||
, ""
|
||||
));
|
||||
fxt.Test_parse_page_wiki("{|\n==b==\n|}"
|
||||
, fxt.tkn_tblw_tb_(0, 8).Subs_
|
||||
( fxt.tkn_hdr_(2, 8, 2).Subs_
|
||||
( fxt.tkn_txt_(5, 6)
|
||||
)
|
||||
, fxt.tkn_para_blank_(9)
|
||||
, fxt.tkn_tblw_tr_(8, 8).Subs_
|
||||
( fxt.tkn_tblw_td_( 8, 8))
|
||||
));
|
||||
}
|
||||
@Test public void Auto_create_table() {// PURPOSE: <td> should create table; EX:w:Hatfield-McCoy_feud; DATE:20121226
|
||||
fxt.Test_parse_page_all_str(String_.Concat_lines_nl_skip_last
|
||||
( "<td>a"
|
||||
@@ -963,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; EX.WP: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: complicated, especially to handle 2nd |}
|
||||
// fxt.Test_parse_page_wiki_str(String_.Concat_lines_nl_skip_last
|
||||
// ( "{|"
|
||||
// , "|-id='a'"
|
||||
@@ -982,7 +744,7 @@ public class Xop_tblw_wkr_basic_tst {
|
||||
// , ""
|
||||
// ));
|
||||
// }
|
||||
// @Test public void Leading_ws() { // EX.WP:Corneal dystrophy (human)
|
||||
// @Test public void Leading_ws() { // PAGE:en.w:Corneal dystrophy (human)
|
||||
// fxt.Test_parse_page_wiki(String_.Concat_lines_nl_skip_last
|
||||
// ( " {|"
|
||||
// , " |-"
|
||||
@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa; import gplx.*;
|
||||
import org.junit.*;
|
||||
public class Xop_tblw_wkr_dangling_tst {
|
||||
public class Xop_tblw_wkr__dangling_tst {
|
||||
@Before public void init() {fxt.Reset(); fxt.Init_para_y_();} private Xop_fxt fxt = new Xop_fxt();
|
||||
@After public void term() {fxt.Init_para_n_();}
|
||||
@Test public void Dangling_tb_in_xnde() {// PURPOSE: dangling tblw incorrectly auto-closed by </xnde>; NOTE: this test is not correct; needs HTML tidy to close </div> earlier; EX:w:Atlanta_Olympics; DATE:2014-03-18
|
||||
@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa; import gplx.*;
|
||||
import org.junit.*;
|
||||
public class Xop_tblw_wkr_double_pipe_tst {
|
||||
public class Xop_tblw_wkr__double_pipe_tst {
|
||||
@Before public void init() {fxt.Reset(); fxt.Init_para_y_();} private Xop_fxt fxt = new Xop_fxt();
|
||||
@After public void term() {fxt.Init_para_n_();}
|
||||
@Test public void No_tblw() { // PURPOSE: if || has no tblw, treat as lnki; none; DATE:2014-05-06
|
||||
94
400_xowa/src_480_tblw/gplx/xowa/Xop_tblw_wkr__errs_tst.java
Normal file
94
400_xowa/src_480_tblw/gplx/xowa/Xop_tblw_wkr__errs_tst.java
Normal file
@@ -0,0 +1,94 @@
|
||||
/*
|
||||
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.*;
|
||||
import org.junit.*;
|
||||
public class Xop_tblw_wkr__errs_tst {
|
||||
private Xop_fxt fxt = new Xop_fxt();
|
||||
@Test public void Err_row_empty() {
|
||||
fxt.Test_parse_page_wiki("{|\n|-\n|-\n|a\n|}"
|
||||
, fxt.tkn_tblw_tb_(0, 14).Subs_
|
||||
( fxt.tkn_tblw_tr_(2, 5)
|
||||
, fxt.tkn_tblw_tr_(5, 11).Subs_
|
||||
( fxt.tkn_tblw_td_(8, 11).Subs_(fxt.tkn_txt_(10, 11), fxt.tkn_para_blank_(12))
|
||||
))
|
||||
);
|
||||
}
|
||||
@Test public void Err_row_trailing() {
|
||||
fxt.Test_parse_page_wiki("{|\n|-\n|a\n|-\n|}"
|
||||
, fxt.tkn_tblw_tb_(0, 14).Subs_
|
||||
( fxt.tkn_tblw_tr_(2, 8).Subs_
|
||||
( fxt.tkn_tblw_td_(5, 8).Subs_(fxt.tkn_txt_(7, 8), fxt.tkn_para_blank_(9))
|
||||
))
|
||||
);
|
||||
}
|
||||
@Test public void Err_caption_after_tr() {
|
||||
fxt.Test_parse_page_wiki("{|\n|-\n|+a\n|}"
|
||||
, fxt.tkn_tblw_tb_(0, 12).Caption_count_(1).Subs_
|
||||
( fxt.tkn_tblw_tr_(2, 5)
|
||||
, fxt.tkn_tblw_tc_(5, 9).Subs_(fxt.tkn_txt_(8, 9), fxt.tkn_para_blank_(10)))
|
||||
);
|
||||
}
|
||||
@Test public void Err_caption_after_td() {
|
||||
fxt.Init_log_(Xop_tblw_log.Caption_after_td).Test_parse_page_wiki("{|\n|-\n|a\n|+b\n|}"
|
||||
, fxt.tkn_tblw_tb_(0, 15).Caption_count_(1).Subs_
|
||||
( fxt.tkn_tblw_tr_(2, 8).Subs_
|
||||
( fxt.tkn_tblw_td_(5, 8).Subs_(fxt.tkn_txt_(7, 8)))
|
||||
, fxt.tkn_tblw_tc_(8, 12).Subs_(fxt.tkn_txt_(11, 12), fxt.tkn_para_blank_(13)))
|
||||
);
|
||||
}
|
||||
@Test public void Err_caption_after_tc() {
|
||||
fxt.Init_log_(Xop_tblw_log.Caption_after_tc).Test_parse_page_wiki("{|\n|+a\n|+b\n|}"
|
||||
, fxt.tkn_tblw_tb_(0, 13).Caption_count_(2).Subs_
|
||||
( fxt.tkn_tblw_tc_(2, 6).Subs_(fxt.tkn_txt_( 5, 6))
|
||||
, fxt.tkn_tblw_tc_(6, 10).Subs_(fxt.tkn_txt_( 9, 10), fxt.tkn_para_blank_(11)))
|
||||
);
|
||||
}
|
||||
@Test public void Err_row_auto_opened() {
|
||||
fxt.Test_parse_page_wiki("{|\n|a\n|}"
|
||||
, fxt.tkn_tblw_tb_(0, 8).Subs_
|
||||
( fxt.tkn_tblw_tr_(2, 5).Subs_
|
||||
( fxt.tkn_tblw_td_(2, 5).Subs_(fxt.tkn_txt_(4, 5), fxt.tkn_para_blank_(6))
|
||||
)));
|
||||
}
|
||||
@Test public void Err_caption_auto_closed() {
|
||||
fxt.Test_parse_page_wiki("{|\n|+a\n|b\n|}"
|
||||
, fxt.tkn_tblw_tb_(0, 12).Caption_count_(1).Subs_
|
||||
( fxt.tkn_tblw_tc_(2, 6).Subs_(fxt.tkn_txt_(5, 6))
|
||||
, fxt.tkn_tblw_tr_(6, 9).Subs_
|
||||
( fxt.tkn_tblw_td_(6, 9).Subs_(fxt.tkn_txt_(8, 9),fxt.tkn_para_blank_(10))
|
||||
)));
|
||||
}
|
||||
@Test public void Err_Atrs_dumped_into_text() { // PURPOSE: [[Prawn]] and {{Taxobox}} was dumping text
|
||||
fxt.Test_parse_page_wiki_str(String_.Concat_lines_nl_skip_last
|
||||
( "{|"
|
||||
, "|-"
|
||||
, "|-id='a'"
|
||||
, "|b"
|
||||
, "|}"
|
||||
) , String_.Concat_lines_nl_skip_last
|
||||
( "<table>"
|
||||
, " <tr id='a'>"
|
||||
, " <td>b"
|
||||
, " </td>"
|
||||
, " </tr>"
|
||||
, "</table>"
|
||||
, ""
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa; import gplx.*;
|
||||
import org.junit.*;
|
||||
public class Xop_tblw_wkr_nested_tst {
|
||||
public class Xop_tblw_wkr__nested_tst {
|
||||
private Xop_fxt fxt = new Xop_fxt();
|
||||
@Test public void Basic() {
|
||||
fxt.Test_parse_page_wiki(String_.Concat_lines_nl_skip_last
|
||||
@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa; import gplx.*;
|
||||
import org.junit.*;
|
||||
public class Xop_tblw_wkr_para_tst {
|
||||
public class Xop_tblw_wkr__para_tst {
|
||||
@Before public void init() {fxt.Reset(); fxt.Init_para_y_();} private Xop_fxt fxt = new Xop_fxt();
|
||||
@After public void term() {fxt.Init_para_n_();}
|
||||
@Test public void Para() { // PURPOSE: para causing strange breaks; SEE:[[John F. Kennedy]] and "two Supreme Court appointments"
|
||||
@@ -90,7 +90,7 @@ public class Xop_tblw_wkr_para_tst {
|
||||
)
|
||||
);
|
||||
}
|
||||
@Test public void Ws_leading() { // EX.WP: AGPLv3
|
||||
@Test public void Ws_leading() { // PAGE:en.w:AGPLv3
|
||||
fxt.Test_parse_page_wiki_str(String_.Concat_lines_nl_skip_last
|
||||
( "{|"
|
||||
, " !a"
|
||||
@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa; import gplx.*;
|
||||
import org.junit.*;
|
||||
public class Xop_tblw_wkr_tblx_tst {
|
||||
public class Xop_tblw_wkr__tblx_tst {
|
||||
@Before public void init() {fxt.Reset(); fxt.Init_para_y_();} private Xop_fxt fxt = new Xop_fxt();
|
||||
@After public void term() {fxt.Init_para_n_();}
|
||||
@Test public void Ignore_td() { // PURPOSE: do not parse pipe as td if in <table>; EX:ru.w:Сочи; DATE:2014-02-22
|
||||
@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa; import gplx.*;
|
||||
import org.junit.*;
|
||||
public class Xop_tblw_wkr_uncommon_tst {
|
||||
public class Xop_tblw_wkr__uncommon_tst {
|
||||
@Before public void init() {fxt.Reset(); fxt.Init_para_y_();} private Xop_fxt fxt = new Xop_fxt();
|
||||
@After public void term() {fxt.Init_para_n_();}
|
||||
@Test public void Tr_pops_entire_stack() { // PURPOSE: in strange cases, tr will pop entire stack; EX:en.w:Turks_in_Denmark; DATE:2014-03-02
|
||||
Reference in New Issue
Block a user