1
0
mirror of https://github.com/gnosygnu/xowa.git synced 2026-03-02 03:49:30 +00:00

Parser: Change encoding of html id to encode fewer characters [#462]

This commit is contained in:
gnosygnu
2019-05-12 23:31:48 -04:00
parent ba35901865
commit c07e6e25b5
19 changed files with 110 additions and 65 deletions

View File

@@ -19,7 +19,7 @@ import gplx.xowa.parsers.amps.*; import gplx.core.primitives.*;
class Xoh_toc_wkr__txt {
private final Gfh_tag_rdr tag_rdr = Gfh_tag_rdr.New__html();
private final Bry_bfr anch_bfr = Bry_bfr_.New(), text_bfr = Bry_bfr_.New();
private final Gfo_url_encoder anch_encoder = Gfo_url_encoder_.New__id();
private final Gfo_url_encoder anch_encoder = Gfo_url_encoder_.New__html_id().Make();
private final Xop_amp_mgr amp_mgr = Xop_amp_mgr.Instance;
private final Hash_adp anch_hash = Hash_adp_bry.ci_u8(gplx.xowa.langs.cases.Xol_case_mgr_.U8());
private Xow_tidy_mgr_interface tidy_mgr;

View File

@@ -30,10 +30,10 @@ public class Xoh_toc_wkr__txt__basic__tst {
fxt.Test__both("", "", "");
}
@Test public void Amp__ncr() {
fxt.Test__both("[a]", ".5Ba.5D", "[a]");
fxt.Test__both("[a]", "[a]", "[a]");// ISSUE#:462; DATE:2019-05-12
}
@Test public void Encode() {
fxt.Test__both("a+b", "a.2Bb", "a+b");
fxt.Test__both("a+b", "a+b", "a+b");// ISSUE#:462; DATE:2019-05-12
}
@Test public void Comment() {
fxt.Test__text("a<!--b-->c", "ac");

View File

@@ -178,7 +178,7 @@ public class Xowe_hdr_bldr__tst {
, "==a+b=="
), fxt.toc_tbl_nl_y
( " <ul>"
, " <li class=\"toclevel-1 tocsection-1\"><a href=\"#a.2Bb\"><span class=\"tocnumber\">1</span> <span class=\"toctext\">a+b</span></a>"
, " <li class=\"toclevel-1 tocsection-1\"><a href=\"#a+b\"><span class=\"tocnumber\">1</span> <span class=\"toctext\">a+b</span></a>" // ISSUE#:462; DATE:2019-05-12
, " </li>"
, " </ul>"
));
@@ -403,11 +403,11 @@ public class Xowe_hdr_bldr__tst {
, String_.Concat_lines_nl
( fxt.toc_tbl_nl_n
( " <ul>"
, " <li class=\"toclevel-1 tocsection-1\"><a href=\"#.5Ba.5D\"><span class=\"tocnumber\">1</span> <span class=\"toctext\">&#91;a&#93;</span></a>"
, " <li class=\"toclevel-1 tocsection-1\"><a href=\"#[a]\"><span class=\"tocnumber\">1</span> <span class=\"toctext\">&#91;a&#93;</span></a>" // ISSUE#:462; DATE:2019-05-12
, " </li>"
, " </ul>"
)
, "<h2><span class='mw-headline' id='.5Ba.5D'>&#91;a&#93;</span></h2>"
, "<h2><span class='mw-headline' id='[a]'>&#91;a&#93;</span></h2>"// ISSUE#:462; DATE:2019-05-12
));
}
@Test public void Fix_large_before_small() { // PURPOSE.fix: "===a===\n===b===\n" followed by "==c==" causes improper formatting; DATE:2013-05-16
@@ -469,11 +469,11 @@ public class Xowe_hdr_bldr__tst {
, String_.Concat_lines_nl
( fxt.toc_tbl_nl_n
( " <ul>"
, " <li class=\"toclevel-1 tocsection-1\"><a href=\"#a.5B1.5D\"><span class=\"tocnumber\">1</span> <span class=\"toctext\">a<sup>[1]</sup></span></a>"
, " <li class=\"toclevel-1 tocsection-1\"><a href=\"#a[1]\"><span class=\"tocnumber\">1</span> <span class=\"toctext\">a<sup>[1]</sup></span></a>" // ISSUE#:462; DATE:2019-05-12
, " </li>"
, " </ul>"
)
, "<h2><span class='mw-headline' id='a.5B1.5D'>a<sup id=\"cite_ref-0\" class=\"reference\"><a href=\"#cite_note-0\">[1]</a></sup></span></h2>"
, "<h2><span class='mw-headline' id='a[1]'>a<sup id=\"cite_ref-0\" class=\"reference\"><a href=\"#cite_note-0\">[1]</a></sup></span></h2>"// ISSUE#:462; DATE:2019-05-12
));
}
@Test public void Category() { // PURPOSE: Category should not show in in TOC; DATE:2013-12-09
@@ -529,11 +529,11 @@ public class Xowe_hdr_bldr__tst {
, String_.Concat_lines_nl
( fxt.toc_tbl_nl_n
( " <ul>"
, " <li class=\"toclevel-1 tocsection-1\"><a href=\"#.5B.5B.5D.5D\"><span class=\"tocnumber\">1</span> <span class=\"toctext\">[[]]</span></a>"
, " <li class=\"toclevel-1 tocsection-1\"><a href=\"#[[]]\"><span class=\"tocnumber\">1</span> <span class=\"toctext\">[[]]</span></a>" // ISSUE#:462; DATE:2019-05-12
, " </li>"
, " </ul>"
)
, "<h2><span class='mw-headline' id='.5B.5B.5D.5D'>[[]]</span></h2>"
, "<h2><span class='mw-headline' id='[[]]'>[[]]</span></h2>" // ISSUE#:462; DATE:2019-05-12
));
}
@Test public void File_in_tbl() { // PURPOSE: two issues (a) don't show file if in tbl; (b) if v2, file inside tbl fails; PAGE:en.w:Holmes County,_Mississippi; DATE:2014-06-22

View File

@@ -29,13 +29,13 @@ public class Srch_html_page_bldr_tst {
@Test public void Rows() {
fxt.Test_rows(new Srch_rslt_row[] {fxt.Make_row(10, "A"), fxt.Make_row(20, "B")}, String_.Concat_lines_nl_skip_last
( ""
, " <tr id='w.7C1'>"
, " <tr id='w|1'>" // ISSUE#:462; DATE:2019-05-12
, " <td style='padding-right:5px; vertical-align:top; text-align:right;'>10"
, " </td>"
, " <td style='padding-left:5px; vertical-align:top;'><a href='/site/w/wiki/A' title='A'>A</a>"
, " </td>"
, " </tr>"
, " <tr id='w.7C2'>"
, " <tr id='w|2'>" // ISSUE#:462; DATE:2019-05-12
, " <td style='padding-right:5px; vertical-align:top; text-align:right;'>20"
, " </td>"
, " <td style='padding-left:5px; vertical-align:top;'><a href='/site/w/wiki/B' title='B'>B</a>"

View File

@@ -17,15 +17,15 @@ package gplx.xowa.addons.wikis.searchs.specials.htmls; import gplx.*; import gpl
import org.junit.*; import gplx.xowa.htmls.core.htmls.utls.*; import gplx.xowa.guis.cbks.js.*; import gplx.xowa.addons.wikis.searchs.searchers.rslts.*;
public class Srch_rslt_cbk_tst {
@Before public void init() {fxt.Clear();} private Srch_rslt_cbk_fxt fxt = new Srch_rslt_cbk_fxt();
@Test public void Basic() {
fxt.Test_add(fxt.Make_rslt(50, "L"), fxt.Make_args_append("xowa_insert_w" , "w.7CL")); // insert new
fxt.Test_add(fxt.Make_rslt(30, "N"), fxt.Make_args_append("xowa_insert_w" , "w.7CN")); // insert below last
fxt.Test_add(fxt.Make_rslt(70, "J"), fxt.Make_args_append("w.7CL" , "w.7CJ")); // insert above first
fxt.Test_add(fxt.Make_rslt(60, "K"), fxt.Make_args_append("w.7CL" , "w.7CK")); // insert above mid
fxt.Test_add(fxt.Make_rslt(40, "M"), fxt.Make_args_append("w.7CN" , "w.7CM")); // insert below mid
fxt.Test_add(fxt.Make_rslt(10, "P")); // insert noop
fxt.Test_add(fxt.Make_rslt(80, "I"), fxt.Make_args_append("w.7CJ" , "w.7CI") , fxt.Make_args_replace("w.7CN")); // insert displace all
fxt.Test_add(fxt.Make_rslt(61, "K1"), fxt.Make_args_append("w.7CK" , "w.7CK1"), fxt.Make_args_replace("w.7CM")); // insert displace mid
@Test public void Basic() {// ISSUE#:462; DATE:2019-05-12
fxt.Test_add(fxt.Make_rslt(50, "L"), fxt.Make_args_append("xowa_insert_w" , "w|L")); // insert new
fxt.Test_add(fxt.Make_rslt(30, "N"), fxt.Make_args_append("xowa_insert_w" , "w|N")); // insert below last
fxt.Test_add(fxt.Make_rslt(70, "J"), fxt.Make_args_append("w|L" , "w|J")); // insert above first
fxt.Test_add(fxt.Make_rslt(60, "K"), fxt.Make_args_append("w|L" , "w|K")); // insert above mid
fxt.Test_add(fxt.Make_rslt(40, "M"), fxt.Make_args_append("w|N" , "w|M")); // insert below mid
fxt.Test_add(fxt.Make_rslt(10, "P")); // insert noop
fxt.Test_add(fxt.Make_rslt(80, "I"), fxt.Make_args_append("w|J" , "w|I") , fxt.Make_args_replace("w|N")); // insert displace all
fxt.Test_add(fxt.Make_rslt(61, "K1"), fxt.Make_args_append("w|K" , "w|K1"), fxt.Make_args_replace("w|M")); // insert displace mid
}
}
class Srch_rslt_cbk_fxt {