1
0
mirror of https://github.com/gnosygnu/xowa.git synced 2024-10-27 20:34:16 +00:00

Parser: Treat empty class / alt keys as caption [#303]

This commit is contained in:
gnosygnu 2018-12-16 22:13:08 -05:00
parent 089661a0bc
commit 166963d767
2 changed files with 15 additions and 0 deletions

View File

@ -100,6 +100,16 @@ public class Xop_lnki_wkr implements Xop_ctx_wkr, Xop_arg_wkr {
if (end > bgn && Bry_.Eq(src, bgn, end, Xop_lnki_arg_parser.Bry_target)) if (end > bgn && Bry_.Eq(src, bgn, end, Xop_lnki_arg_parser.Bry_target))
arg_tid = Xop_lnki_arg_parser.Tid_target; arg_tid = Xop_lnki_arg_parser.Tid_target;
} }
// if just "class" or "alt", treat as caption; EX:[[A|alt]] -> caption=alt x> caption=A ISSUE#:303 DATE:2018-12-16
switch (arg_tid) {
case Xop_lnki_arg_parser.Tid_class:
case Xop_lnki_arg_parser.Tid_alt:
if (!arg.KeyTkn_exists()){
arg_tid = Xop_lnki_arg_parser.Tid_caption;
}
break;
}
switch (arg_tid) { switch (arg_tid) {
case Xop_lnki_arg_parser.Tid_none: lnki.Align_h_(Xop_lnki_type.Id_none); break; case Xop_lnki_arg_parser.Tid_none: lnki.Align_h_(Xop_lnki_type.Id_none); break;
case Xop_lnki_arg_parser.Tid_border: lnki.Border_(Bool_.Y_byte); break; case Xop_lnki_arg_parser.Tid_border: lnki.Border_(Bool_.Y_byte); break;

View File

@ -312,4 +312,9 @@ public class Xop_lnki_wkr__basic_tst {
fxt.Test_parse_page_all_str("[[Src]]" , "<a href=\"/wiki/Src\" class=\"xowa-visited\">Src</a>"); // show [[Src]] as visited since it exists in history fxt.Test_parse_page_all_str("[[Src]]" , "<a href=\"/wiki/Src\" class=\"xowa-visited\">Src</a>"); // show [[Src]] as visited since it exists in history
fxt.Test_parse_page_all_str("[[Other]]" , "<a href=\"/wiki/Other\">Other</a>"); // show other pages as not visited fxt.Test_parse_page_all_str("[[Other]]" , "<a href=\"/wiki/Other\">Other</a>"); // show other pages as not visited
} }
@Test public void Caption__outlier() {
fxt.Test_parse_page_all_str("[[A|class]]", "<a href=\"/wiki/A\">class</a>");
fxt.Test_parse_page_all_str("[[A|alt]]", "<a href=\"/wiki/A\">alt</a>");
fxt.Test_parse_page_all_str("[[A|alt|a|b]]", "<a href=\"/wiki/A\">alt|a|b</a>");
}
} }