Parser: Move alt attribute earlier in tag [#553]

pull/620/head
gnosygnu 5 years ago
parent a082e3cf5d
commit b17cb05edf

@ -29,7 +29,7 @@ public class Xoh_gly_html__dump__tst {
, " <div style='width:155px;'>"
, " <div class='thumb' style='width:150px;'>"
, " <div style='margin:15px auto;'>"
, " <a href='/wiki/File:A.png' class='image' xowa_title='A.png'><img data-xowa-title=\"A.png\" data-xoimg='0|120|120|-1|-1|-1' src='' width='0' height='0' alt=''/></a>"
, " <a href='/wiki/File:A.png' class='image' xowa_title='A.png'><img data-xowa-title=\"A.png\" data-xoimg='0|120|120|-1|-1|-1' alt='' src='' width='0' height='0'/></a>"
, " </div>"
, " </div>"
, " <div class='gallerytext'><p>A1"
@ -42,7 +42,7 @@ public class Xoh_gly_html__dump__tst {
, " <div style='width:155px;'>"
, " <div class='thumb' style='width:150px;'>"
, " <div style='margin:15px auto;'>"
, " <a href='/wiki/File:B.png' class='image' xowa_title='B.png'><img data-xowa-title=\"B.png\" data-xoimg='0|120|120|-1|-1|-1' src='' width='0' height='0' alt=''/></a>"
, " <a href='/wiki/File:B.png' class='image' xowa_title='B.png'><img data-xowa-title=\"B.png\" data-xoimg='0|120|120|-1|-1|-1' alt='' src='' width='0' height='0'/></a>"
, " </div>"
, " </div>"
, " <div class='gallerytext'><p>B1"
@ -64,7 +64,7 @@ public class Xoh_gly_html__dump__tst {
, " <div style='width:235px;'>"
, " <div class='thumb' style='width:230px;'>"
, " <div style='margin:15px auto;'>"
, " <a href='/wiki/File:A.png' class='image' xowa_title='A.png'><img data-xowa-title=\"A.png\" data-xoimg='0|200|300|-1|-1|-1' src='' width='0' height='0' alt=''/></a>"
, " <a href='/wiki/File:A.png' class='image' xowa_title='A.png'><img data-xowa-title=\"A.png\" data-xoimg='0|200|300|-1|-1|-1' alt='' src='' width='0' height='0'/></a>"
, " </div>"
, " </div>"
, " <div class='gallerytext'><p>A1"
@ -86,7 +86,7 @@ public class Xoh_gly_html__dump__tst {
, " <div style='width:1302px;'>"
, " <div class='thumb' style='width:1300px;'>"
, " <div style='margin:0px auto;'>"
, " <a href='/wiki/File:A.png' class='image' xowa_title='A.png'><img data-xowa-title=\"A.png\" data-xoimg='0|1950|180|-1|-1|-1' src='' width='0' height='0' alt=''/></a>"
, " <a href='/wiki/File:A.png' class='image' xowa_title='A.png'><img data-xowa-title=\"A.png\" data-xoimg='0|1950|180|-1|-1|-1' alt='' src='' width='0' height='0'/></a>"
, " </div>"
, " </div>"
, " <div class='gallerytext'><p>A1"

@ -41,7 +41,7 @@ public class Xoh_img_bare_hzip__tst {
@Test public void Imap_map() {
fxt.Test__bicode
( "~%}*BhtA.png~#$m#T\"A.png~"
, "<img src=\"file:///mem/xowa/file/commons.wikimedia.org/thumb/7/0/A.png/330px.png\" width=\"330\" height=\"220\" class=\"thumbimage\" alt=\"\" usemap=\"#imagemap_1_1\">"
, "<img class=\"thumbimage\" alt=\"\" src=\"file:///mem/xowa/file/commons.wikimedia.org/thumb/7/0/A.png/330px.png\" width=\"330\" height=\"220\" usemap=\"#imageMap_1_1\"/>"
);
}
}

@ -21,21 +21,21 @@ public class Xoh_img_html__dump__tst {
@Test public void Basic() {
fxt.Test__html
( "[[File:A.png|220x110px|upright=.5|abc]]"
, "<a href='/wiki/File:A.png' class='image' title='abc' xowa_title='A.png'><img data-xowa-title=\"A.png\" data-xoimg='0|220|110|0.5|-1|-1' src='' width='0' height='0' alt='abc'/></a>");
, "<a href='/wiki/File:A.png' class='image' title='abc' xowa_title='A.png'><img data-xowa-title=\"A.png\" data-xoimg='0|220|110|0.5|-1|-1' alt='abc' src='' width='0' height='0'/></a>");
}
@Test public void Empty_link() {
fxt.Test__html("[[File:A.png|220x110px|link=|abc]]", "<img data-xowa-title=\"A.png\" data-xoimg='0|220|110|-1|-1|-1' src='' width='0' height='0' alt='abc'/>");
fxt.Test__html("[[File:A.png|220x110px|link=|abc]]", "<img data-xowa-title=\"A.png\" data-xoimg='0|220|110|-1|-1|-1' alt='abc' src='' width='0' height='0'/>");
}
@Test public void Lcase_img() {
Make_ns_case_sensitive(fxt.Parser_fxt().Wiki(), gplx.xowa.wikis.nss.Xow_ns_.Tid__file);
fxt.Test__html("[[File:a_b.png]]", "<a href=\"/wiki/File:a_b.png\" class=\"image\" xowa_title=\"a_b.png\"><img data-xowa-title=\"a_b.png\" data-xoimg=\"0|-1|-1|-1|-1|-1\" src=\"\" width=\"0\" height=\"0\" alt=\"\"/></a>");
fxt.Test__html("[[File:a_b.png]]", "<a href=\"/wiki/File:a_b.png\" class=\"image\" xowa_title=\"a_b.png\"><img data-xowa-title=\"a_b.png\" data-xoimg=\"0|-1|-1|-1|-1|-1\" alt=\"\" src=\"\" width=\"0\" height=\"0\"/></a>");
}
@Test public void Lcase_video() {
Make_ns_case_sensitive(fxt.Parser_fxt().Wiki(), gplx.xowa.wikis.nss.Xow_ns_.Tid__file);
fxt.Test__html("[[File:a b.ogv]]"
, String_.Concat_lines_nl_skip_last
( " <div class=\"xowa_media_div\">"
, " <div><a href=\"/wiki/File:a_b.ogv\" class=\"image\" title=\"A_b.ogv\" xowa_title=\"a_b.ogv\"><img data-xowa-title=\"a_b.ogv\" data-xoimg=\"0|-1|-1|-1|-1|-1\" src=\"\" width=\"0\" height=\"0\" alt=\"\"/></a>"
, " <div><a href=\"/wiki/File:a_b.ogv\" class=\"image\" title=\"A_b.ogv\" xowa_title=\"a_b.ogv\"><img data-xowa-title=\"a_b.ogv\" data-xoimg=\"0|-1|-1|-1|-1|-1\" alt=\"\" src=\"\" width=\"0\" height=\"0\"/></a>"
, " </div>"
, "<div><a href=\"\" xowa_title=\"a_b.ogv\" class=\"xowa_media_play\" style=\"width:218px;max-width:220px;\" alt=\"Play sound\"></a></div>"
, " </div>"

@ -102,7 +102,7 @@ public class Xoh_img_hzip__dump__basic__tst {
@Test public void Imap() {
fxt.Test__bicode
( "~%}#P`uA.png~#:#S#+\""
, "<img data-xowa-title='A.png' data-xoimg='1|220|180|-1|-1|-1' src='' width='0' height='0' alt='' usemap='#imagemap_1_1'>"
, "<img data-xowa-title='A.png' data-xoimg='1|220|180|-1|-1|-1' alt='' src='' width='0' height='0' usemap='#imageMap_1_1'/>"
);
}
@Test public void Existing_src_causes_npe() { // ISSUE#:400; DATE:2019-03-26

@ -75,13 +75,13 @@ public class Xoh_img_hzip__dump__link__tst {
@Test public void Link__empty() { // empty link should not create anchor; EX:[[File:A.png|link=|abc]]; PAGE:en.w:List_of_counties_in_New_York; DATE:2016-01-10
fxt.Test__bicode
( "~%|iVPA.png~#9#S\":abc~"
, "<img data-xowa-title='A.png' data-xoimg='0|220|110|-1|-1|-1' src='' width='0' height='0' alt='abc'>"
, "<img data-xowa-title='A.png' data-xoimg='0|220|110|-1|-1|-1' alt='abc' src='' width='0' height='0'/>"
);
}
@Test public void Link__empty__tidy() {// <a><font><img> should not trigger empty link code; PAGE:en.w:Wikipedia:Reference_Desk_archive_unanswered_2005 ; DATE:2016-01-13
fxt.Test__bicode
( "<a href=\"/wiki/Image:A.png\" class=\"image\" title=\"\" xowa_title=\"A.png\"><font style=\"color:red\">~%|iVPA.png~#!abc~</font></a>"
, "<a href='/wiki/Image:A.png' class='image' title='' xowa_title='A.png'><font style='color:red'><img data-xowa-title='A.png' data-xoimg='0|-1|-1|-1|-1|-1' src='' width='0' height='0' alt='abc'></font></a>"
, "<a href='/wiki/Image:A.png' class='image' title='' xowa_title='A.png'><font style='color:red'><img data-xowa-title='A.png' data-xoimg='0|-1|-1|-1|-1|-1' alt='abc' src='' width='0' height='0'/></font></a>"
);
}
@Test public void Link__ns_alias() { // [[File:A.png|link=WP:MCB]]; PAGE:en.w:Wikipedia:WikiProject_Molecular_and_Cell_Biology; DATE:2016-01-11

@ -52,7 +52,7 @@ public class Xoh_img_hzip__dump__orig__tst {
@Test public void Link__empty() { // [[File:A.png|link=|abc]]; PAGE:en.w:Lackawanna_Cut-Off; DATE:2016-08-19
fxt.Test__bicode
( "~%}([^KA.png~#\"M!babc~A.png~"
, "<img src='file:///mem/xowa/file/commons.wikimedia.org/thumb/7/0/A.png/128px.png' width='128' height='64' alt='abc'>"
, "<img alt='abc' src='file:///mem/xowa/file/commons.wikimedia.org/thumb/7/0/A.png/128px.png' width='128' height='64'/>"
);
}
@Test public void Encode_2() { // [[File:A*C.png|abc]]; PAGE:en.w:Fibonacci_number; DATE:2016-08-10

@ -142,7 +142,7 @@ public class Xoh_img_wtr implements Bfr_arg, Xoh_wtr_itm {
}
public void Bfr_arg__add(Bry_bfr bfr) {
if (img_wo_anch)
img_wo_anch_fmtr.Bld_bfr_many(bfr, img_id, img_xowa_title, img_xowa_image, img_src, img_w, img_h, img_cls, img_alt, img_imap_usemap);
img_wo_anch_fmtr.Bld_bfr_many(bfr, img_id, img_xowa_title, img_xowa_image, img_alt, img_src, img_w, img_h, img_cls, img_imap_usemap);
else {
if (img_is_vid) {
bfr.Add(Vid__bry__bgn);
@ -162,7 +162,7 @@ public class Xoh_img_wtr implements Bfr_arg, Xoh_wtr_itm {
( "<a~{anch_href}~{anch_rel}~{anch_cls}~{anch_title}~{anch_xowa_title}><img~{img_id}~{img_xowa_title}~{img_xowa_image}~{img_src}~{img_w}~{img_h}~{img_cls}~{img_alt}~{img_pgbnr_atrs}></a>"
, "anch_href", "anch_rel", "anch_cls", "anch_title", "anch_xowa_title", "img_id", "img_xowa_title", "img_xowa_image", "img_src", "img_w", "img_h", "img_cls", "img_alt", "img_pgbnr_atrs")
, img_wo_anch_fmtr = Bry_fmtr.new_
( "<img~{img_id}~{img_xowa_title}~{img_xowa_image}~{img_src}~{img_w}~{img_h}~{img_cls}~{img_alt}~{img_imap_usemap}>"
( "<img~{img_id}~{img_xowa_title}~{img_xowa_image}~{img_alt}~{img_src}~{img_w}~{img_h}~{img_cls}~{img_imap_usemap}/>"
, "img_id", "img_xowa_title", "img_xowa_image", "img_src", "img_w", "img_h", "img_cls", "img_alt", "img_imap_usemap")
;
private final Bry_fmt

@ -27,6 +27,6 @@ public class Xoh_lnki_html__hdump__tst {
}
@Test public void Anch() {fxt.Test__html("[[#a]]" , "<a href='#a'>#a</a>");}
@Test public void Alt_has_quotes() {
fxt.Test__html("[[File:A.png|alt=[[\"A\"]] B c]]", "<a href=\"/wiki/File:A.png\" class=\"image\" xowa_title=\"A.png\"><img data-xowa-title=\"A.png\" data-xoimg=\"0|-1|-1|-1|-1|-1\" src=\"\" width=\"0\" height=\"0\" alt=\"&quot;A&quot; B c\"/></a>");
fxt.Test__html("[[File:A.png|alt=[[\"A\"]] B c]]", "<a href=\"/wiki/File:A.png\" class=\"image\" xowa_title=\"A.png\"><img data-xowa-title=\"A.png\" data-xoimg=\"0|-1|-1|-1|-1|-1\" alt=\"&quot;A&quot; B c\" src=\"\" width=\"0\" height=\"0\"/></a>");
}
}

@ -54,7 +54,7 @@ public class Xoh_file_wtr__video__tst {
( " <div class=\"xowa_media_div\">"
, " <div>"
+ "<a href=\"/wiki/File:A.ogv\" class=\"image\" title=\"A.ogv\" xowa_title=\"A.ogv\">"
+ "<img src=\"file:///mem/wiki/repo/trg/thumb/d/0/A.ogv/220px-4.jpg\" width=\"220\" height=\"300\" alt=\"\"/>" // NOTE: src should probably be empty;
+ "<img data-xowa-title=\"A.ogv\" data-xoimg=\"0|-1|-1|-1|4|-1\" alt=\"\" src=\"\" width=\"0\" height=\"0\"/>" // NOTE: src should probably be empty;
+ "</a>"
, " </div>"
, "<div><a href=\"\" xowa_title=\"A.ogv\" class=\"xowa_media_play\" style=\"width:218px;max-width:220px;\" alt=\"Play sound\"></a></div>"

@ -21,7 +21,7 @@ public class Xoh_thm_html_tst {
fxt.Test__html("[[File:A.png|thumb|test_caption]]", String_.Concat_lines_nl_skip_last
( "<div class='thumb tright'>"
, " <div class='thumbinner' style='width:220px;'>"
, " <a href='/wiki/File:A.png' class='image' xowa_title='A.png'><img data-xowa-title=\"A.png\" data-xoimg='4|-1|-1|-1|-1|-1' src='' width='0' height='0' alt=''/></a>"
, " <a href='/wiki/File:A.png' class='image' xowa_title='A.png'><img data-xowa-title=\"A.png\" data-xoimg='4|-1|-1|-1|-1|-1' alt='' src='' width='0' height='0'/></a>"
, " <div class='thumbcaption'>"
, "<div class='magnify'><a href='/wiki/File:A.png' class='internal' title='Enlarge'></a></div>test_caption"
, " </div>"
@ -50,7 +50,7 @@ public class Xoh_thm_html_tst {
( "<div class=\"thumb tright\">"
, " <div class=\"thumbinner\" style=\"width:220px;\">"
, " <div class=\"xowa_media_div\">"
, " <div><a href=\"/wiki/File:A.ogv\" class=\"image\" title=\"A.ogv\" xowa_title=\"A.ogv\"><img data-xowa-title=\"A.ogv\" data-xoimg=\"4|-1|-1|-1|-1|-1\" src=\"\" width=\"0\" height=\"0\" alt=\"\"/></a>"
, " <div><a href=\"/wiki/File:A.ogv\" class=\"image\" title=\"A.ogv\" xowa_title=\"A.ogv\"><img data-xowa-title=\"A.ogv\" data-xoimg=\"4|-1|-1|-1|-1|-1\" alt=\"\" src=\"\" width=\"0\" height=\"0\"/></a>"
, " </div>"
, "<div><a href=\"\" xowa_title=\"A.ogv\" class=\"xowa_media_play\" style=\"width:218px;max-width:220px;\" alt=\"Play sound\"></a></div>"
, " </div>"

Loading…
Cancel
Save