mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
v2.8.3.1
This commit is contained in:
@@ -19,9 +19,9 @@ package gplx.xowa; import gplx.*;
|
||||
import gplx.core.primitives.*; import gplx.core.btries.*;
|
||||
import gplx.xowa.langs.numbers.*;
|
||||
public class Xop_lnki_arg_parser {
|
||||
private final Btrie_fast_mgr key_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 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 lang) {
|
||||
Bry_bfr tmp_bfr = int_bfr;
|
||||
@@ -75,8 +75,8 @@ public class Xop_lnki_arg_parser {
|
||||
byte b = src[i];
|
||||
Object o = size_trie.Match_bgn_w_byte(b, src, i, itm_end);
|
||||
if (o == null) {
|
||||
this.lnki_w = 0; // NOTE: must null out width; EX: "123xTextpx"; PAGE:es.b:Alimentación_infantil; DATE:2015-07-10
|
||||
return Tid_caption; // letter or other invalid character; return caption
|
||||
this.lnki_w = Xop_lnki_tkn.Width_null; // NOTE: must null out width; EX: "123xTextpx"; PAGE:es.b:Alimentación_infantil; DATE:2015-07-10; NOTE: must be -1, not 0; DATE:2015-08-05
|
||||
return Tid_caption; // letter or other invalid character; return caption
|
||||
}
|
||||
Byte_obj_val v = (Byte_obj_val)o;
|
||||
switch (v.Val()) { // NOTE: d0 - d9 handle non-english numbers; EX:fa.w and ۲۰۰px; DATE:2015-07-18
|
||||
|
||||
@@ -30,7 +30,7 @@ public class Xop_lnki_type {
|
||||
return true;
|
||||
else if ( Enm_.HasInt(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)
|
||||
|| Enm_.HasInt(id, Id_none) // TODO: deprecate
|
||||
|| Enm_.HasInt(id, Id_none) // TODO: deprecate; NOTE: still used by one test; DATE:2015-08-03
|
||||
)
|
||||
return false;
|
||||
else // should not happen
|
||||
@@ -43,7 +43,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
|
||||
|| Enm_.HasInt(id, Id_none) // TODO: deprecate
|
||||
|| Enm_.HasInt(id, Id_none) // TODO: deprecate; NOTE: leaving in b/c of above failed-deprecate; DATE:2015-08-03
|
||||
)
|
||||
return false;
|
||||
else // should not happen;
|
||||
|
||||
@@ -65,45 +65,6 @@ public class Xop_lnki_wkr__basic_tst {
|
||||
.Caption_tkn_(fxt.tkn_arg_nde_(22, 25).Val_tkn_(fxt.tkn_arg_itm_(fxt.tkn_txt_(22, 23), fxt.tkn_space_(23, 24), fxt.tkn_txt_(24, 25)))))
|
||||
;
|
||||
}
|
||||
@Test public void Thumbtime() {
|
||||
fxt.Test_parse_page_wiki("[[File:A.ogv|thumbtime=123]]", fxt.tkn_lnki_().Thumbtime_(123));
|
||||
fxt.Test_parse_page_wiki("[[File:A.ogv|thumbtime=1:23]]", fxt.tkn_lnki_().Thumbtime_(83));
|
||||
fxt.Test_parse_page_wiki("[[File:A.ogv|thumbtime=1:01:01]]", fxt.tkn_lnki_().Thumbtime_(3661));
|
||||
fxt.Init_log_(Xop_lnki_log.Upright_val_is_invalid).Test_parse_page_wiki("[[File:A.ogv|thumbtime=a]]", fxt.tkn_lnki_().Thumbtime_(-1));
|
||||
}
|
||||
@Test public void Width_ws() {
|
||||
fxt.Test_parse_page_wiki("[[Image:a| 123 px]]" , fxt.tkn_lnki_().Width_(123));
|
||||
}
|
||||
@Test public void Height() {
|
||||
fxt.Test_parse_page_wiki("[[Image:a|x40px]]" , fxt.tkn_lnki_().Height_(40).Width_(-1));
|
||||
}
|
||||
@Test public void Size_double_px_ignored() {
|
||||
fxt.Test_parse_page_wiki("[[Image:a|40pxpx]]" , fxt.tkn_lnki_().Width_(40).Height_(-1));
|
||||
}
|
||||
@Test public void Size_px_px_ignored() {
|
||||
fxt.Test_parse_page_wiki("[[Image:a|40px20px]]" , fxt.tkn_lnki_().Width_(-1).Height_(-1));
|
||||
}
|
||||
@Test public void Size_double_px_ws_allowed() {
|
||||
fxt.Test_parse_page_wiki("[[Image:a|40pxpx ]]" , fxt.tkn_lnki_().Width_(40).Height_(-1));
|
||||
}
|
||||
@Test public void Size_double_px_ws_allowed_2() { // PURPOSE: handle ws between px's; EX:sv.w:Drottningholms_slott; DATE:2014-03-01
|
||||
fxt.Test_parse_page_wiki("[[Image:a|40px px]]" , fxt.tkn_lnki_().Width_(40).Height_(-1));
|
||||
}
|
||||
@Test public void Size_large_numbers() { // PURPOSE: perf code identified large sizes as caption; DATE:2014-02-15
|
||||
fxt.Test_parse_page_wiki("[[Image:a|1234567890x1234567890px]]" , fxt.tkn_lnki_().Width_(1234567890).Height_(1234567890));
|
||||
}
|
||||
@Test public void Size_dangling_xnde() { // PURPOSE: dangling xnde should not eat rest of lnki; PAGE:sr.w:Сићевачка_клисура DATE:2014-07-03
|
||||
fxt.Init_log_(Xop_xnde_log.Dangling_xnde).Test_parse_page_wiki("[[Image:a.png|<b>c|40px]]" , fxt.tkn_lnki_().Width_(40).Height_(-1));
|
||||
}
|
||||
@Test public void Size_ws_para() { // PURPOSE: <p> in arg_bldr causes parse to fail; EX: w:Supreme_Court_of_the_United_States; DATE:2014-04-05; updated test; DATE:2015-03-31
|
||||
fxt.Init_para_y_();
|
||||
fxt.Test_parse_page_all("[[File:A.png| \n 40px]]"
|
||||
, fxt.tkn_para_bgn_para_(0)
|
||||
, fxt.tkn_lnki_().Width_(40).Height_(-1)
|
||||
, fxt.tkn_para_end_para_(22));
|
||||
fxt.Init_para_n_();
|
||||
}
|
||||
|
||||
@Test public void Image_upright() {
|
||||
fxt.Test_parse_page_wiki("[[Image:a|upright=.123]]" , fxt.tkn_lnki_().Upright_(.123));
|
||||
fxt.Test_parse_page_wiki("[[Image:a|upright]]" , fxt.tkn_lnki_().Upright_(gplx.xowa.files.Xof_img_size.Upright_default_marker)); // no eq tokn
|
||||
|
||||
63
400_xowa/src_440_lnki/gplx/xowa/Xop_lnki_wkr__size_tst.java
Normal file
63
400_xowa/src_440_lnki/gplx/xowa/Xop_lnki_wkr__size_tst.java
Normal file
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
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_lnki_wkr__size_tst {
|
||||
@Before public void init() {fxt.Reset(); fxt.Init_para_n_();} private final Xop_fxt fxt = new Xop_fxt();
|
||||
@Test public void Width__w__ws() {
|
||||
fxt.Test_parse_page_wiki("[[Image:a| 123 px]]" , fxt.tkn_lnki_().Width_(123));
|
||||
}
|
||||
@Test public void Height() {
|
||||
fxt.Test_parse_page_wiki("[[Image:a|x40px]]" , fxt.tkn_lnki_().Height_(40).Width_(-1));
|
||||
}
|
||||
@Test public void Invalid_px__accept_double() {
|
||||
fxt.Test_parse_page_wiki("[[Image:a|40pxpx]]" , fxt.tkn_lnki_().Width_(40).Height_(-1));
|
||||
}
|
||||
@Test public void Invalid_px__accept_double__w_ws() {
|
||||
fxt.Test_parse_page_wiki("[[Image:a|40pxpx ]]" , fxt.tkn_lnki_().Width_(40).Height_(-1));
|
||||
}
|
||||
@Test public void Invalid_px__accept_double__w_ws_2() {// PURPOSE: handle ws between px's; EX:sv.w:Drottningholms_slott; DATE:2014-03-01
|
||||
fxt.Test_parse_page_wiki("[[Image:a|40px px]]" , fxt.tkn_lnki_().Width_(40).Height_(-1));
|
||||
}
|
||||
@Test public void Invalid_px__ignore_if_w() {
|
||||
fxt.Test_parse_page_wiki("[[Image:a|40px20px]]" , fxt.tkn_lnki_().Width_(-1).Height_(-1)); // -1 b/c "40px"
|
||||
}
|
||||
@Test public void Large_number() { // PURPOSE: perf code identified large sizes as caption; DATE:2014-02-15
|
||||
fxt.Test_parse_page_wiki("[[Image:a|1234567890x1234567890px]]" , fxt.tkn_lnki_().Width_(1234567890).Height_(1234567890));
|
||||
}
|
||||
@Test public void Large_number__discard_if_gt_int() { // PURPOSE: size larger than int should be discarded, not be Int_.MaxValue: PAGE:id.w:Baho; DATE:2014-06-10
|
||||
fxt.Test_html_wiki_frag("[[File:A.png|9999999999x30px]]", " width=\"0\" height=\"30\""); // width should not be Int_.MaxValue
|
||||
}
|
||||
@Test public void Dangling_xnde() { // PURPOSE: dangling xnde should not eat rest of lnki; PAGE:sr.w:Сићевачка_клисура DATE:2014-07-03
|
||||
fxt.Init_log_(Xop_xnde_log.Dangling_xnde).Test_parse_page_wiki("[[Image:a.png|<b>c|40px]]" , fxt.tkn_lnki_().Width_(40).Height_(-1));
|
||||
}
|
||||
@Test public void Ws_para() { // PURPOSE: <p> in arg_bldr causes parse to fail; EX: w:Supreme_Court_of_the_United_States; DATE:2014-04-05; updated test; DATE:2015-03-31
|
||||
fxt.Init_para_y_();
|
||||
fxt.Test_parse_page_all("[[File:A.png| \n 40px]]"
|
||||
, fxt.tkn_para_bgn_para_(0)
|
||||
, fxt.tkn_lnki_().Width_(40).Height_(-1)
|
||||
, fxt.tkn_para_end_para_(22));
|
||||
fxt.Init_para_n_();
|
||||
}
|
||||
@Test public void Invalid_size() { // PURPOSE: handle invalid sizes
|
||||
fxt.Test_parse_page_wiki("[[File:A.png|1234xSomeTextpx]]" , fxt.tkn_lnki_().Width_(-1).Height_(-1)); // PAGE:es.b:Alimentación_infantil; DATE:2015-07-10
|
||||
fxt.Test_parse_page_wiki("[[File:A.png|100 KBpx]]" , fxt.tkn_lnki_().Width_(-1).Height_(-1)); // PAGE:en.w:Bahamas; DATE:2015-08-05
|
||||
fxt.Test_parse_page_wiki("[[File:A.png|size100px]]" , fxt.tkn_lnki_().Width_(-1).Height_(-1)); // PAGE:en.w:Data_compression; DATE:2015-08-05
|
||||
fxt.Test_parse_page_wiki("[[File:A.png|20\n0px]]" , fxt.tkn_lnki_().Width_(-1).Height_(-1)); // PAGE:en.w:Double_bass; DATE:2015-08-05
|
||||
}
|
||||
}
|
||||
@@ -47,15 +47,9 @@ public class Xop_lnki_wkr__uncommon_tst {
|
||||
@Test public void Toc_fails() { // PURPOSE: null ref when writing hdr with lnki inside xnde; EX:pl.d:head_sth_off;DATE:2014-05-07
|
||||
fxt.Test_parse_page_all_str("== <i>[[A]]</i> ==", "<h2> <i><a href=\"/wiki/A\">A</a></i> </h2>\n");
|
||||
}
|
||||
@Test public void Large_size() { // PURPOSE: size larger than int should be discard, not be Int_.MaxValue: PAGE:id.w:Baho; DATE:2014-06-10
|
||||
fxt.Test_html_wiki_frag("[[File:A.png|9999999999x30px]]", " width=\"0\" height=\"30\""); // width should not be Int_.MaxValue
|
||||
}
|
||||
@Test public void Upright_is_large() { // PURPOSE: handle large upright which overflows int; PAGE:de.w:Feuerland DATE:2015-02-03
|
||||
fxt.Test_html_wiki_frag("[[File:A.png|upright=1.333333333333333333333333333333333333333333333333333333333333333333333]]", " width=\"0\" height=\"0\""); // failure would print out original lnki
|
||||
}
|
||||
@Test public void Mistaken_x_px() { // PURPOSE: 1234xTextpx interpreted as size; PAGE:es.b:Alimentación_infantil; DATE:2015-07-10
|
||||
fxt.Test_html_wiki_frag("[[File:A.png|1234xSomeTextpx]]", " width=\"0\" height=\"0\""); // width should be 0
|
||||
}
|
||||
@Test public void Persian() { // PURPOSE: handle il8n nums; EX:[[پرونده:Shahbazi 3.jpg|۲۰۰px]] -> 200px; PAGE:fa.w:فهرست_آثار_علیرضا_شاپور_شهبازی; DATE:2015-07-18
|
||||
Xol_lang lang = fxt.Wiki().Lang();
|
||||
fxt.App().Gfs_mgr().Run_str_for(lang, gplx.xowa.xtns.pfuncs.numbers.Pf_formatnum_fa_tst.Persian_numbers_gfs);
|
||||
|
||||
31
400_xowa/src_440_lnki/gplx/xowa/Xop_lnki_wkr__video_tst.java
Normal file
31
400_xowa/src_440_lnki/gplx/xowa/Xop_lnki_wkr__video_tst.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.*;
|
||||
import org.junit.*; import gplx.xowa.files.*;
|
||||
public class Xop_lnki_wkr__video_tst {
|
||||
@Before public void init() {fxt.Reset(); fxt.Init_para_n_();} private Xop_fxt fxt = new Xop_fxt();
|
||||
@Test public void Thumbtime() {
|
||||
fxt.Test_parse_page_wiki("[[File:A.ogv|thumbtime=123]]" , fxt.tkn_lnki_().Thumbtime_(123));
|
||||
fxt.Test_parse_page_wiki("[[File:A.ogv|thumbtime=1:23]]" , fxt.tkn_lnki_().Thumbtime_(83));
|
||||
fxt.Test_parse_page_wiki("[[File:A.ogv|thumbtime=1:01:01]]" , fxt.tkn_lnki_().Thumbtime_(3661));
|
||||
fxt.Init_log_(Xop_lnki_log.Upright_val_is_invalid).Test_parse_page_wiki("[[File:A.ogv|thumbtime=a]]", fxt.tkn_lnki_().Thumbtime_(-1));
|
||||
}
|
||||
@Test public void Size__null() { // NOTE: make sure that no size defaults to -1; needed for Xof_img_size logic of defaulting -1 to orig_w; DATE:2015-08-07
|
||||
fxt.Test_parse_page_wiki("[[File:A.ogv]]" , fxt.tkn_lnki_().Width_(Xof_img_size.Size__neg1));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user