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:
@@ -22,14 +22,14 @@ public class Pfunc_tag_tst {
|
||||
@Test public void Val_apos() {fxt.Test_html_full_str("{{#tag:pre|a|id='b'}}" , "<pre id=\"b\">a</pre>");}
|
||||
@Test public void Val_quote() {fxt.Test_html_full_str("{{#tag:pre|a|id=\"b\"}}" , "<pre id=\"b\">a</pre>");}
|
||||
@Test public void Val_empty() {fxt.Test_html_full_str("{{#tag:pre|a|id=}}" , "<pre>a</pre>");} // PURPOSE: ignore atrs with no val; EX:{{#ref||group=}} PAGE:ru.w:Колчак,_Александр_Васильевич; DATE:2014-07-03
|
||||
@Test public void Val_multiple() {fxt.Test_html_full_str("{{#tag:pre|c|id='a'b'}}" , "<pre id=\"a.27b\">c</pre>");} // PURPOSE: multiple quotes should use 1st and nth; DATE:2018-12-24
|
||||
@Test public void Val_quote_w_apos() {fxt.Test_html_full_str("{{#tag:pre|c|id=\"a'b\"}}" , "<pre id=\"a.27b\">c</pre>");} // PURPOSE.fix: tag was not handling apos within quotes; PAGE:en.s:The_formative_period_in_Colby%27s_history DATE:2016-06-23
|
||||
@Test public void Val_multiple() {fxt.Test_html_full_str("{{#tag:pre|c|id='a'b'}}" , "<pre id=\"a'b\">c</pre>");} // PURPOSE: multiple quotes should use 1st and nth; DATE:2018-12-24 // ISSUE#:462; DATE:2019-05-12
|
||||
@Test public void Val_quote_w_apos() {fxt.Test_html_full_str("{{#tag:pre|c|id=\"a'b\"}}" , "<pre id=\"a'b\">c</pre>");} // PURPOSE.fix: tag was not handling apos within quotes; PAGE:en.s:The_formative_period_in_Colby%27s_history DATE:2016-06-23; // ISSUE#:462; DATE:2019-05-12
|
||||
@Test public void Val_mismatched() {fxt.Test_html_full_str("{{#tag:pre|c|id=\"a'}}" , "<pre id=\"a\">c</pre>");} // PURPOSE: emulate MW behavior; DATE:2018-12-24
|
||||
@Test public void Tmpl() {fxt.Test_html_full_str("{{#tag:pre|a|{{#switch:a|a=id}}=c}}" , "<pre id=\"c\">a</pre>");} // PURPOSE: args must be evaluated
|
||||
@Test public void Ws_all() {fxt.Test_html_full_str("{{#tag:pre|a| id = b }}" , "<pre id=\"b\">a</pre>");}
|
||||
@Test public void Ws_quoted() {fxt.Test_html_full_str("{{#tag:pre|a| id = ' b ' }}" , "<pre id=\"_b_\">a</pre>");}
|
||||
@Test public void Err_bad_key() {fxt.Test_html_full_str("{{#tag:pre|a|id=val|b}}" , "<pre id=\"val\">a</pre>");} // PURPOSE: b was failing b/c id was larger and key_end set to 4 (whereas b was len=1)
|
||||
@Test public void Html_is_escaped() {fxt.Test_html_full_str("{{#tag:pre|a|id='<br/>'}}" , "<pre id=\".3Cbr.2F.3E\">a</pre>");} // PURPOSE: escape html in atrs; PAGE:fr.w:France; DATE:2017-06-01
|
||||
@Test public void Err_bad_key() {fxt.Test_html_full_str("{{#tag:pre|a|id=val|b}}" , "<pre id=\"val\">a</pre>");} // PURPOSE: b was failing b/c id was larger and key_end set to 4 (whereas b was len=1)
|
||||
@Test public void Html_is_escaped() {fxt.Test_html_full_str("{{#tag:pre|a|id='<br/>'}}" , "<pre id=\".3Cbr/.3E\">a</pre>");} // PURPOSE: escape html in atrs; PAGE:fr.w:France; DATE:2017-06-01; // ISSUE#:462; DATE:2019-05-12
|
||||
@Test public void Nested_tmpl() { // PURPOSE: nested template must get re-evaluated; EX:de.wikipedia.org/wiki/Freiburg_im_Breisgau; DATE:2013-12-18;
|
||||
fxt.Init_page_create("Template:!", "|");
|
||||
fxt.Init_page_create("Template:A", "{{#ifeq:{{{1}}}|expd|pass|fail}}");
|
||||
|
||||
@@ -20,16 +20,16 @@ public class Pfunc_anchorencode_tst {
|
||||
private final Pfunc_anchorenchode_fxt fxt = new Pfunc_anchorenchode_fxt(Bool_.N);
|
||||
@Before public void init() {fxt.Reset();}
|
||||
@Test public void Text_apos() {
|
||||
fxt.Test("{{anchorencode:a 'b c}}", "a_.27b_c");
|
||||
fxt.Test("{{anchorencode:a 'b c}}", "a_'b_c");
|
||||
}
|
||||
@Test public void Apos_bold() {
|
||||
fxt.Test("{{anchorencode:a ''b'' c}}", "a_b_c");
|
||||
}
|
||||
@Test public void Html_ncr() {
|
||||
fxt.Test("{{anchorencode:a " b}}", "a_.22_b");
|
||||
fxt.Test("{{anchorencode:a " b}}", "a_"_b");
|
||||
}
|
||||
@Test public void Html_ref() {
|
||||
fxt.Test("{{anchorencode:a " b}}", "a_.22_b");
|
||||
fxt.Test("{{anchorencode:a " b}}", "a_"_b");
|
||||
}
|
||||
@Test public void Lnke() {
|
||||
fxt.Test("{{anchorencode:[irc://a b c]}}", "b_c");
|
||||
@@ -41,7 +41,7 @@ public class Pfunc_anchorencode_tst {
|
||||
fxt.Test("{{anchorencode:a [[b|c]] c}}", "a_c_c");
|
||||
}
|
||||
@Test public void Lnki_file() {
|
||||
fxt.Test("{{anchorencode:a [[Image:b|thumb|123px|c]] d}}", "a_thumb.7C123px.7Cc_d");
|
||||
fxt.Test("{{anchorencode:a [[Image:b|thumb|123px|c]] d}}", "a_thumb|123px|c_d");
|
||||
}
|
||||
@Test public void Lnki_trailing() {
|
||||
fxt.Test("{{anchorencode:a [[b]]c d}}", "a_bc_d");
|
||||
@@ -59,7 +59,7 @@ public class Pfunc_anchorencode_tst {
|
||||
fxt.Test("{{anchorencode:{{xowa_na}}}}", "Template:xowa_na");
|
||||
}
|
||||
@Test public void Tmpl_missing_colon() {
|
||||
fxt.Test("{{anchorencode:{{:a}}}}", "a"); // NOTE: changed from "Template:A" to "a"; DATE:2016-06-24
|
||||
fxt.Test("{{anchorencode:{{:xowa_na}}}}", "xowa_na"); // NOTE: changed from "Template:A" to "a"; DATE:2016-06-24
|
||||
}
|
||||
}
|
||||
class Pfunc_anchorenchode_fxt {
|
||||
@@ -73,6 +73,6 @@ class Pfunc_anchorenchode_fxt {
|
||||
}
|
||||
public void Test(String raw, String expd) {
|
||||
if (dbg) Console_adp__sys.Instance.Write_str(fxt.Make__test_string(raw, expd));
|
||||
fxt.Test__parse__tmpl_to_html(raw, expd);
|
||||
fxt.Test_str_full(raw, expd, fxt.Exec_parse_page_all_as_str(raw));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ public class Scrib_lib_mw__invoke_tst {
|
||||
}
|
||||
@Test public void CallParserFunction_tag() {
|
||||
fxt.Init_page("{{#invoke:Mod_0|Prc_0}}");
|
||||
fxt.Test_lib_proc_kv(lib, Scrib_lib_mw.Invk_callParserFunction, Scrib_kv_utl_.flat_many_(1, "current", 2, "#tag", 3, Scrib_kv_utl_.flat_many_("3", "id=1", "2", "text", "1", "pre")), "<pre 3=\"id.3D1\">2=text</pre>");// named: sort args; NOTE: keys should probably be stripped
|
||||
fxt.Test_lib_proc_kv(lib, Scrib_lib_mw.Invk_callParserFunction, Scrib_kv_utl_.flat_many_(1, "current", 2, "#tag", 3, Scrib_kv_utl_.flat_many_("3", "id=1", "2", "text", "1", "pre")), "<pre 3=\"id=1\">2=text</pre>");// named: sort args; NOTE: keys should probably be stripped; // ISSUE#:462; DATE:2019-05-12
|
||||
}
|
||||
@Test public void CallParserFunction__no_args() { // PURPOSE.fix: 0 args should not fail
|
||||
fxt.Init_page("{{#invoke:Mod_0|Prc_0}}");
|
||||
|
||||
Reference in New Issue
Block a user