mirror of
https://github.com/gnosygnu/xowa.git
synced 2024-10-27 20:34:16 +00:00
Pages: Treat empty-string as non-null for from / to [#657]
This commit is contained in:
parent
57ad8e459a
commit
ca8afe657e
@ -43,8 +43,8 @@ public class Pp_pages_nde implements Xox_xnde, Mwh_atr_itm_owner1 {
|
|||||||
byte[] val_bry = xatr.Val_as_bry();
|
byte[] val_bry = xatr.Val_as_bry();
|
||||||
switch (xatr_id.Val()) {
|
switch (xatr_id.Val()) {
|
||||||
case Xatr_index_ttl: index_ttl_bry = val_bry; break;
|
case Xatr_index_ttl: index_ttl_bry = val_bry; break;
|
||||||
case Xatr_bgn_page: bgn_page_bry = val_bry; break;
|
case Xatr_bgn_page: bgn_page_bry = val_bry; break;
|
||||||
case Xatr_end_page: end_page_bry = val_bry; break;
|
case Xatr_end_page: end_page_bry = val_bry; break;
|
||||||
case Xatr_bgn_sect: if (Bry_.Len_gt_0(val_bry)) bgn_sect_bry = val_bry; break; // ignore empty-String; EX:fromsection=""; ISSUE#:650 DATE:2020-01-11
|
case Xatr_bgn_sect: if (Bry_.Len_gt_0(val_bry)) bgn_sect_bry = val_bry; break; // ignore empty-String; EX:fromsection=""; ISSUE#:650 DATE:2020-01-11
|
||||||
case Xatr_end_sect: if (Bry_.Len_gt_0(val_bry)) end_sect_bry = val_bry; break; // ignore empty-String; EX:tosection=""; ISSUE#:650 DATE:2020-01-11
|
case Xatr_end_sect: if (Bry_.Len_gt_0(val_bry)) end_sect_bry = val_bry; break; // ignore empty-String; EX:tosection=""; ISSUE#:650 DATE:2020-01-11
|
||||||
case Xatr_include: include = val_bry; break;
|
case Xatr_include: include = val_bry; break;
|
||||||
@ -58,13 +58,15 @@ public class Pp_pages_nde implements Xox_xnde, Mwh_atr_itm_owner1 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
public void Xtn_parse(Xowe_wiki wiki, Xop_ctx ctx, Xop_root_tkn root, byte[] src, Xop_xnde_tkn xnde) {
|
public void Xtn_parse(Xowe_wiki wiki, Xop_ctx ctx, Xop_root_tkn root, byte[] src, Xop_xnde_tkn xnde) {
|
||||||
// if (!wiki.Xtn_mgr().Xtn_proofread().Enabled()) return;
|
// TOMBSTONE: do not disable Enabled check; needs smarter way of checking for xtn enable / disable
|
||||||
|
// if (!wiki.Xtn_mgr().Xtn_proofread().Enabled()) return;
|
||||||
if (!Init_vars(wiki, ctx, src, xnde)) return;
|
if (!Init_vars(wiki, ctx, src, xnde)) return;
|
||||||
|
|
||||||
|
if (wiki.Parser_mgr().Lst__recursing()) return; // moved from Pp_index_parser; DATE:2014-05-21s
|
||||||
|
|
||||||
// set recursing flag
|
// set recursing flag
|
||||||
Xoae_page page = ctx.Page();
|
Xoae_page page = ctx.Page();
|
||||||
Bry_bfr full_bfr = wiki.Utl__bfr_mkr().Get_m001();
|
Bry_bfr full_bfr = wiki.Utl__bfr_mkr().Get_m001();
|
||||||
if (wiki.Parser_mgr().Lst__recursing()) return; // moved from Pp_index_parser; DATE:2014-05-21s
|
|
||||||
try {
|
try {
|
||||||
wiki.Parser_mgr().Lst__recursing_(true);
|
wiki.Parser_mgr().Lst__recursing_(true);
|
||||||
Hash_adp_bry lst_page_regy = ctx.Lst_page_regy(); if (lst_page_regy == null) lst_page_regy = Hash_adp_bry.cs(); // SEE:NOTE:page_regy; DATE:2014-01-01
|
Hash_adp_bry lst_page_regy = ctx.Lst_page_regy(); if (lst_page_regy == null) lst_page_regy = Hash_adp_bry.cs(); // SEE:NOTE:page_regy; DATE:2014-01-01
|
||||||
@ -229,7 +231,13 @@ public class Pp_pages_nde implements Xox_xnde, Mwh_atr_itm_owner1 {
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
private List_adp Get_ttls_from_xnde_args__rng(Gfo_number_parser num_parser, List_adp list) {
|
private List_adp Get_ttls_from_xnde_args__rng(Gfo_number_parser num_parser, List_adp list) {
|
||||||
if (Bry_.Len_eq_0(bgn_page_bry) && Bry_.Len_eq_0(end_page_bry)) return list; // from and to are blank; exit early
|
// exit if "from" and "to" are blank but include is specified; ISSUE#:657 DATE:2020-01-19
|
||||||
|
if ( Bry_.Len_eq_0(bgn_page_bry)
|
||||||
|
&& Bry_.Len_eq_0(end_page_bry)
|
||||||
|
&& Bry_.Len_gt_0(include)
|
||||||
|
)
|
||||||
|
return list;
|
||||||
|
|
||||||
bgn_page_int = 0; // NOTE: default to 0 (1st page)
|
bgn_page_int = 0; // NOTE: default to 0 (1st page)
|
||||||
if (Bry_.Len_gt_0(bgn_page_bry)) {
|
if (Bry_.Len_gt_0(bgn_page_bry)) {
|
||||||
num_parser.Parse(bgn_page_bry);
|
num_parser.Parse(bgn_page_bry);
|
||||||
|
@ -137,4 +137,32 @@ public class Pp_pages_nde_basic_tst {
|
|||||||
Tfds.Eq(1, fxt.Page().Html_data().Indicators().Count()); // only 1 indicator, not 2
|
Tfds.Eq(1, fxt.Page().Html_data().Indicators().Count()); // only 1 indicator, not 2
|
||||||
Tfds.Eq(true, fxt.Page().Html_data().Indicators().Has("a")); // indicator should be from wikitext, not <page>
|
Tfds.Eq(true, fxt.Page().Html_data().Indicators().Has("a")); // indicator should be from wikitext, not <page>
|
||||||
}
|
}
|
||||||
|
// FUTURE: handle null from / to; will probably require emulating MW; REF.MW: https://github.com/wikimedia/mediawiki-extensions-ProofreadPage/blob/master/includes/Parser/PagequalityTagParser.php
|
||||||
|
//@Test public void Fromto__null() {// PURPOSE:if from / to is null, assume all; ISSUE#:657 DATE:2020-01-19
|
||||||
|
// fxt.Init_page_create("Page:A/1", "A");
|
||||||
|
// fxt.Init_page_create("Page:A/2", "B");
|
||||||
|
// fxt.Init_page_create("Page:A/3", "C");
|
||||||
|
// fxt.Test_parse_page_wiki_str("<pages index='A'/>", String_.Concat_lines_nl
|
||||||
|
// ( "<p> A B C "
|
||||||
|
// , "</p>"
|
||||||
|
// ));
|
||||||
|
//}
|
||||||
|
@Test public void Fromto__empty() {// PURPOSE:if from / to is null, assume all; ISSUE#:657 DATE:2020-01-19
|
||||||
|
fxt.Init_page_create("Page:A/1", "A");
|
||||||
|
fxt.Init_page_create("Page:A/2", "B");
|
||||||
|
fxt.Init_page_create("Page:A/3", "C");
|
||||||
|
fxt.Test_parse_page_wiki_str("<pages index='A' from='' to='' />", String_.Concat_lines_nl
|
||||||
|
( "<p> A B C "
|
||||||
|
, "</p>"
|
||||||
|
));
|
||||||
|
}
|
||||||
|
@Test public void Fromto__empty__include() {// PURPOSE:if from / to is null, assume all; ISSUE#:657 DATE:2020-01-19
|
||||||
|
fxt.Init_page_create("Page:A/1", "A");
|
||||||
|
fxt.Init_page_create("Page:A/2", "B");
|
||||||
|
fxt.Init_page_create("Page:A/3", "C");
|
||||||
|
fxt.Test_parse_page_wiki_str("<pages index='A' from='' to='' include=2/>", String_.Concat_lines_nl
|
||||||
|
( "<p>B "
|
||||||
|
, "</p>"
|
||||||
|
));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user