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

'v3.6.4.1'

This commit is contained in:
gnosygnu
2016-06-26 01:10:38 -04:00
parent 8afc115176
commit b3c2d3bb5f
108 changed files with 1813 additions and 873 deletions

View File

@@ -26,9 +26,11 @@ public class Xoh_img_mgr {
}
public int Len() {return list.Count();}
public Xof_fsdb_itm Get_at(int i) {return (Xof_fsdb_itm)list.Get_at(i);}
public Xof_fsdb_itm Make_img() {
public Xof_fsdb_itm Make_img(boolean img_is_gallery) {
Xof_fsdb_itm itm = new Xof_fsdb_itm();
itm.Init_at_hdoc(++uid_nxt, Xof_html_elem.Tid_img);
itm.Init_at_hdoc(++uid_nxt, img_is_gallery ? Xof_html_elem.Tid_gallery : Xof_html_elem.Tid_img);
if (img_is_gallery)
itm.Html_gallery_mgr_h_(gplx.xowa.xtns.gallery.Gallery_xnde.Default); // TODO:set to <gallery heights=val>; PAGE:en.w:National_Gallery_of_Art; DATE:2016-06-25
list.Add(itm);
return itm;
}

View File

@@ -25,7 +25,7 @@ public class Xoh_page implements Xoa_page {
public Xoa_ttl Ttl() {return page_ttl;} private Xoa_ttl page_ttl;
// props
public boolean Exists() {return exists;} public Xoh_page Exists_n_() {exists = false; return this;} private boolean exists = true;
public boolean Exists() {return exists;} public Xoh_page Exists_n_() {exists = false; return this;} private boolean exists = true;
public int Page_id() {return page_id;} private int page_id;
public byte[] Body() {return body;} public void Body_(byte[] v) {this.body = v;} private byte[] body;
public int Body_zip_tid() {return body_zip_tid;} private int body_zip_tid;
@@ -40,12 +40,14 @@ public class Xoh_page implements Xoa_page {
public Ordered_hash Gallery_itms() {return gallery_itms;} private Ordered_hash gallery_itms = Ordered_hash_.New();
public Xopg_module_mgr Head_mgr() {return head_mgr;} private Xopg_module_mgr head_mgr = new Xopg_module_mgr();
public void Xtn_gallery_packed_exists_y_() {}
public boolean Xtn__timeline_exists() {return xtn__timeline_exists;} private boolean xtn__timeline_exists; public void Xtn__timeline_exists_y_() {xtn__timeline_exists = true;}
public boolean Xtn__gallery_exists() {return xtn__gallery_exists;} private boolean xtn__gallery_exists; public void Xtn__gallery_exists_y_() {xtn__gallery_exists = true;}
public Xopg_revision_data Revision_data() {return revision_data;} private Xopg_revision_data revision_data = new Xopg_revision_data();
public Xopg_html_data Html_data() {return html_data;} private Xopg_html_data html_data = new Xopg_html_data();
public byte[] Redirect_to_ttl() {return redirect_to_ttl;} private byte[] redirect_to_ttl; public void Redirect_to_ttl_(byte[] v) {this.redirect_to_ttl = v;}
// util
public Xopg_lnki_list Redlink_list() {return redlink_list;} private Xopg_lnki_list redlink_list;
public Xopg_lnki_list Redlink_list() {return redlink_list;} private Xopg_lnki_list redlink_list = new Xopg_lnki_list();
public Xoa_page__commons_mgr Commons_mgr() {return commons_mgr;} private final Xoa_page__commons_mgr commons_mgr = new Xoa_page__commons_mgr();
public int Exec_tid() {return exec_tid;} private int exec_tid = Xof_exec_tid.Tid_wiki_page;
public byte[] Html_head_xtn() {return html_head_xtn;} public void Html_head_xtn_(byte[] v) {html_head_xtn = v;} private byte[] html_head_xtn = Bry_.Empty; // drd:web_browser
@@ -53,7 +55,7 @@ public class Xoh_page implements Xoa_page {
public void Init(Xow_wiki wiki, Xoa_url page_url, Xoa_ttl page_ttl, int page_id) {
this.wiki = wiki; this.page_url = page_url; this.page_ttl = page_ttl; this.page_id = page_id;
this.Clear();
this.redlink_list = new Xopg_lnki_list(page_ttl.Ns().Id_is_module());
redlink_list.Disabled_(page_ttl.Ns().Id_is_module()); // never redlink in Module ns; particularly since Lua has multi-line comments for [[ ]]
}
public void Ctor_by_db(int head_flag, byte[] display_ttl, byte[] content_sub, byte[] sidebar_div, int zip_tid, int hzip_tid, byte[] body) {
head_mgr.Flag_(head_flag);
@@ -78,5 +80,6 @@ public class Xoh_page implements Xoa_page {
img_itms = Xohd_img_itm__base.Ary_empty;
head_mgr.Clear(); gallery_itms.Clear(); redlink_uids.Clear(); commons_mgr.Clear();
section_mgr.Clear(); img_mgr.Clear();
redlink_list.Clear();
}
}

View File

@@ -32,7 +32,7 @@ public class Bridge_cmd_mgr {
catch (Exception e) {throw Err_.new_exc(e, "bridge.cmds", "invalid json", "json", jdoc_bry);}
Json_nde msg = jdoc.Root_nde();
byte[] key_bry = msg.Get_bry(Key_cmd);
Bridge_cmd_itm cmd = (Bridge_cmd_itm)cmd_hash.Get_by_bry(key_bry); if (cmd == null) throw Err_.new_("bridge.cmds", "unknown cmd", "cmd", cmd);
Bridge_cmd_itm cmd = (Bridge_cmd_itm)cmd_hash.Get_by_bry(key_bry); if (cmd == null) throw Err_.new_("bridge.cmds", "unknown cmd", "key", key_bry);
try {return cmd.Exec(msg.Get(Key_data));}
catch (Exception e) {
Xoa_app_.Usr_dlg().Warn_many("", "", "exec json failed: ~{0}", "json", jdoc_bry);

View File

@@ -83,7 +83,8 @@ public class Xow_hdump_mgr__load {
wpg_head.Itm__popups().Bind_hover_area_ (hpg_head.Imap_exists());
wpg_head.Itm__gallery().Enabled_ (hpg_head.Gallery_packed_exists());
wpg_head.Itm__hiero().Enabled_ (hpg_head.Hiero_exists());
wpg_head.Itm__timeline().Enabled_ (true);
wpg_head.Itm__timeline().Enabled_ (hpg.Xtn__timeline_exists());
wpg_head.Itm__gallery_styles().Enabled_ (hpg.Xtn__gallery_exists());
// transfer images from Xoh_page to Xoae_page
Xoh_img_mgr src_imgs = hpg.Img_mgr();

View File

@@ -295,7 +295,7 @@ public class Xoh_html_wtr {
break;
}
case Xop_xnde_tag_.Tid__timeline: {
bfr.Add_str_a7("<pre class='xowa-timeline'>");
bfr.Add(gplx.xowa.htmls.core.wkrs.addons.timelines.Xoh_timeline_data.Hook_bry);
Xox_mgr_base.Xtn_write_escape(app, bfr, src, xnde.Tag_open_end(), xnde.Tag_close_bgn()); // NOTE: do not embed <timeline> tag inside pre, else timeline will render in black; EX:<pre><timeline>a</timeline></pre> will fail; DATE:2014-05-22
bfr.Add_str_a7("</pre>");
break;

View File

@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.xowa.htmls.core.htmls; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*;
import org.junit.*;
public class Xoh_html_wtr_tst {
private final Xop_fxt fxt = new Xop_fxt();
private final Xop_fxt fxt = new Xop_fxt();
@After public void term() {fxt.Init_para_n_(); fxt.Reset();}
@Test public void Hr_basic() {fxt.Test_parse_page_wiki_str("----" , "<hr/>");}
@Test public void Hr_extended() {fxt.Test_parse_page_wiki_str("--------" , "<hr/>");}

View File

@@ -18,10 +18,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.xowa.htmls.core.hzips; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*;
import gplx.core.primitives.*; import gplx.core.btries.*;
public class Xoh_hzip_dict_ {
public static final byte Escape = Byte_.By_int(27); // SERIALIZED: 27=escape byte
public static final byte[] Escape_bry = Bry_.New_by_ints(27); // SERIALIZED
public static final byte Escape = Byte_.By_int(27); // SERIALIZED: 27=escape byte
public static final byte[] Escape_bry = Bry_.New_by_ints(27); // SERIALIZED
public static final int
Tid__root = 0
Tid__timeline = -10
, Tid__gallery = -11
, Tid__root = 0
, Tid__escape = 1
, Tid__xnde = 2
, Tid__lnke = 3
@@ -32,8 +34,10 @@ public class Xoh_hzip_dict_ {
, Tid__gly = 8
, Tid__img_bare = 9
;
public static final String
Key__escape = "escape"
public static final String
Key__timeline = "timeline"
, Key__gallery = "gallery"
, Key__escape = "escape"
, Key__hdr = "hdr"
, Key__lnke = "lnke"
, Key__lnki = "lnki"

View File

@@ -20,26 +20,25 @@ import gplx.core.primitives.*; import gplx.core.brys.*; import gplx.core.btries.
import gplx.langs.htmls.docs.*; import gplx.xowa.htmls.core.hzips.*; import gplx.xowa.htmls.core.wkrs.*;
import gplx.xowa.wikis.ttls.*;
public class Xoh_hzip_mgr implements Xoh_hzip_wkr {
private final Xoh_hdoc_wkr hdoc_wkr = new Xoh_hdoc_wkr__hzip();
private final Xoh_hdoc_parser hdoc_parser;
private final Bry_rdr rdr = new Bry_rdr().Dflt_dlm_(Xoh_hzip_dict_.Escape);
private final Xoh_hdoc_wkr hdoc_wkr = new Xoh_hdoc_wkr__hzip();
private final Xoh_hdoc_parser hdoc_parser;
private final Bry_rdr rdr = new Bry_rdr().Dflt_dlm_(Xoh_hzip_dict_.Escape);
public Xoh_hzip_mgr() {this.hdoc_parser = new Xoh_hdoc_parser(hdoc_wkr);}
public int Tid() {return Xoh_hzip_dict_.Tid__lnke;}
public String Key() {return "root";}
public byte[] Hook() {return hook;} private byte[] hook;
public Xoh_hdoc_ctx Hctx() {return hctx;} private final Xoh_hdoc_ctx hctx = new Xoh_hdoc_ctx();
public Xoh_hdoc_ctx Hctx() {return hctx;} private final Xoh_hdoc_ctx hctx = new Xoh_hdoc_ctx();
public void Init_by_app(Xoa_app app) {hctx.Init_by_app(app);}
public byte[] Encode_as_bry(Xoh_hzip_bfr bfr, Xow_wiki wiki, Xoh_page hpg, byte[] src) {Encode(bfr, wiki, hpg, src); return bfr.To_bry_and_clear();}
public Gfo_poolable_itm Encode1(Xoh_hzip_bfr bfr, Xoh_hdoc_wkr hdoc_wkr, Xoh_hdoc_ctx hctx, Xoh_page hpg, boolean wkr_is_root, byte[] src, Object data_obj) {throw Err_.new_unimplemented();}
public void Encode(Xoh_hzip_bfr bfr, Xow_wiki wiki, Xoh_page hpg, byte[] src) {
hctx.Init_by_page(wiki, hpg.Url_bry_safe());
hctx.Init_by_page(wiki, hpg);
hdoc_parser.Parse(bfr, hpg, hctx, src);
}
public void Decode(Bry_bfr bfr, Xow_wiki wiki, Xoh_page hpg, byte[] src) {
byte[] page_url = hpg.Url_bry_safe(); int src_len = src.length;
hctx.Init_by_page(wiki, page_url);
rdr.Init_by_page(page_url, src, src_len);
Decode1(bfr, hdoc_wkr, hctx, hpg, rdr, src, 0, src_len, null);
hctx.Init_by_page(wiki, hpg);
rdr.Init_by_page(hpg.Url_bry_safe(), src, src.length);
Decode1(bfr, hdoc_wkr, hctx, hpg, rdr, src, 0, src.length, null);
}
public void Decode1(Bry_bfr bfr, Xoh_hdoc_wkr hdoc_wkr, Xoh_hdoc_ctx hctx, Xoh_page hpg, Bry_rdr rdr, byte[] src, int src_bgn, int src_end, Xoh_data_itm data_itm) {
int pos = src_bgn, txt_bgn = -1;

View File

@@ -19,9 +19,9 @@ package gplx.xowa.htmls.core.hzips; import gplx.*; import gplx.xowa.*; import gp
import gplx.core.brys.*; import gplx.core.threads.poolables.*;
import gplx.xowa.htmls.core.wkrs.*;
public interface Xoh_hzip_wkr extends gplx.core.threads.poolables.Gfo_poolable_itm {
int Tid();
String Key();
byte[] Hook();
int Tid();
String Key();
byte[] Hook();
Gfo_poolable_itm Encode1(Xoh_hzip_bfr bfr, Xoh_hdoc_wkr hdoc_wkr, Xoh_hdoc_ctx hctx, Xoh_page hpg, boolean wkr_is_root, byte[] src, Object data_obj);
void Decode1(Bry_bfr bfr, Xoh_hdoc_wkr hdoc_wkr, Xoh_hdoc_ctx hctx, Xoh_page hpg, Bry_rdr rdr, byte[] src, int src_bgn, int src_end, Xoh_data_itm data_itm);
}

View File

@@ -19,15 +19,17 @@ package gplx.xowa.htmls.core.hzips; import gplx.*; import gplx.xowa.*; import gp
import gplx.core.btries.*; import gplx.core.threads.poolables.*;
import gplx.xowa.htmls.core.wkrs.escapes.*;
import gplx.xowa.htmls.core.wkrs.hdrs.*; import gplx.xowa.htmls.core.wkrs.lnkes.*; import gplx.xowa.htmls.core.wkrs.lnkis.*; import gplx.xowa.htmls.core.wkrs.xndes.*;
import gplx.xowa.htmls.core.wkrs.imgs.*; import gplx.xowa.htmls.core.wkrs.thms.*; import gplx.xowa.htmls.core.wkrs.glys.*;
import gplx.xowa.htmls.core.wkrs.imgs.*; import gplx.xowa.htmls.core.wkrs.thms.*;
import gplx.xowa.htmls.core.wkrs.addons.timelines.*; import gplx.xowa.htmls.core.wkrs.addons.gallerys.*;
public class Xoh_pool_mgr__data {
private final Gfo_poolable_mgr pool__hdr, pool__lnke, pool__img, pool__img_bare;//, pool__gly;
private final Gfo_poolable_mgr pool__hdr, pool__lnke, pool__img, pool__img_bare, pool__timeline, pool__gallery;
public Xoh_pool_mgr__data() {
pool__hdr = New_pool(new Xoh_hdr_data());
pool__lnke = New_pool(new Xoh_lnke_data());
pool__img = New_pool(new Xoh_img_data());
pool__img_bare = New_pool(new Xoh_img_bare_data());
// pool__gly = New_pool(new Xoh_gly_grp_data());
pool__timeline = New_pool(new Xoh_timeline_data());
pool__gallery = New_pool(new Xoh_gallery_data());
}
public Xoh_data_itm Get_by_tid(int tid) {
Gfo_poolable_mgr pool = null;
@@ -36,7 +38,8 @@ public class Xoh_pool_mgr__data {
case Xoh_hzip_dict_.Tid__lnke: pool = pool__lnke; break;
case Xoh_hzip_dict_.Tid__img: pool = pool__img; break;
case Xoh_hzip_dict_.Tid__img_bare: pool = pool__img_bare; break;
// case Xoh_hzip_dict_.Tid__gly: pool = pool__gly; break;
case Xoh_hzip_dict_.Tid__timeline: pool = pool__timeline; break;
case Xoh_hzip_dict_.Tid__gallery: pool = pool__gallery; break;
default: return null;
}
return (Xoh_data_itm)pool.Get_fast();

View File

@@ -20,9 +20,10 @@ import gplx.core.btries.*; import gplx.core.threads.poolables.*;
import gplx.xowa.htmls.core.wkrs.escapes.*;
import gplx.xowa.htmls.core.wkrs.hdrs.*; import gplx.xowa.htmls.core.wkrs.lnkes.*; import gplx.xowa.htmls.core.wkrs.lnkis.*; import gplx.xowa.htmls.core.wkrs.xndes.*;
import gplx.xowa.htmls.core.wkrs.imgs.*; import gplx.xowa.htmls.core.wkrs.thms.*; import gplx.xowa.htmls.core.wkrs.glys.*;
import gplx.xowa.htmls.core.wkrs.addons.timelines.*; import gplx.xowa.htmls.core.wkrs.addons.gallerys.*;
public class Xoh_pool_mgr__hzip {
private final Btrie_slim_mgr trie = Btrie_slim_mgr.cs();
private Gfo_poolable_mgr mkr__escape, mkr__xnde, mkr__lnke, mkr__lnki, mkr__hdr, mkr__img, mkr__thm, mkr__gly, mkr__img_bare;
private final Btrie_slim_mgr trie = Btrie_slim_mgr.cs();
private Gfo_poolable_mgr mkr__escape, mkr__xnde, mkr__lnke, mkr__lnki, mkr__hdr, mkr__img, mkr__thm, mkr__gly, mkr__img_bare, mkr__gallery, mkr__timeline;
public Xoh_escape_hzip Mw__escape() {return (Xoh_escape_hzip) mkr__escape.Get_fast();}
public Xoh_xnde_hzip Mw__xnde() {return (Xoh_xnde_hzip) mkr__xnde.Get_fast();}
public Xoh_hdr_hzip Mw__hdr() {return (Xoh_hdr_hzip) mkr__hdr.Get_fast();}
@@ -32,6 +33,8 @@ public class Xoh_pool_mgr__hzip {
public Xoh_img_bare_hzip Mw__img_bare() {return (Xoh_img_bare_hzip) mkr__img_bare.Get_fast();}
public Xoh_thm_hzip Mw__thm() {return (Xoh_thm_hzip) mkr__thm.Get_fast();}
public Xoh_gly_hzip Mw__gly() {return (Xoh_gly_hzip) mkr__gly.Get_fast();}
public Xoh_gallery_hzip Mw__gallery() {return (Xoh_gallery_hzip) mkr__gallery.Get_fast();}
public Xoh_timeline_hzip Mw__timeline() {return (Xoh_timeline_hzip) mkr__timeline.Get_fast();}
public void Init() {
this.Reg_all(false, Hook__core, Hook__html, Hook__mw);
}
@@ -50,6 +53,8 @@ public class Xoh_pool_mgr__hzip {
mkr__thm = Reg(New_hook_len2(mode_is_b256, hook__mw , 5) , new Xoh_thm_hzip());
mkr__gly = Reg(New_hook_len2(mode_is_b256, hook__mw , 6) , new Xoh_gly_hzip());
mkr__img_bare = Reg(New_hook_len2(mode_is_b256, hook__mw , 7) , new Xoh_img_bare_hzip());
mkr__gallery = Reg(Xoh_gallery_data.Hook_bry , new Xoh_gallery_hzip());
mkr__timeline = Reg(Xoh_timeline_data.Hook_bry , new Xoh_timeline_hzip());
}
private Gfo_poolable_mgr Reg(byte[] hook, Gfo_poolable_itm proto) {
Gfo_poolable_mgr rv = Gfo_poolable_mgr_.New(1, 32, proto, Object_.Ary(hook));
@@ -63,5 +68,5 @@ public class Xoh_pool_mgr__hzip {
, Hook__html = 2
, Hook__mw = 27
;
public static final byte[] Hooks_ary = new byte[] {Hook__core, Hook__html, Hook__mw};
public static final byte[] Hooks_ary = new byte[] {Hook__core, Hook__html, Hook__mw};
}

View File

@@ -19,14 +19,17 @@ package gplx.xowa.htmls.core.hzips; import gplx.*; import gplx.xowa.*; import gp
import gplx.core.brys.*; import gplx.core.threads.poolables.*;
import gplx.xowa.htmls.core.wkrs.escapes.*;
import gplx.xowa.htmls.core.wkrs.hdrs.*; import gplx.xowa.htmls.core.wkrs.lnkes.*; import gplx.xowa.htmls.core.wkrs.lnkis.*; import gplx.xowa.htmls.core.wkrs.xndes.*;
import gplx.xowa.htmls.core.wkrs.imgs.*; import gplx.xowa.htmls.core.wkrs.thms.*; import gplx.xowa.htmls.core.wkrs.glys.*;
import gplx.xowa.htmls.core.wkrs.imgs.*; import gplx.xowa.htmls.core.wkrs.thms.*;
import gplx.xowa.htmls.core.wkrs.addons.timelines.*; import gplx.xowa.htmls.core.wkrs.addons.gallerys.*;
public class Xoh_pool_mgr__wtr {
private final Gfo_poolable_mgr pool__hdr, pool__lnke, pool__img, pool__img_bare;
private final Gfo_poolable_mgr pool__hdr, pool__lnke, pool__img, pool__img_bare, pool__timeline, pool__gallery;
public Xoh_pool_mgr__wtr() {
pool__hdr = New_pool(new Xoh_hdr_wtr());
pool__lnke = New_pool(new Xoh_lnke_wtr());
pool__img = New_pool(new Xoh_img_wtr());
pool__img_bare = New_pool(new Xoh_img_bare_wtr());
pool__timeline = New_pool(new Xoh_timeline_wtr());
pool__gallery = New_pool(new Xoh_gallery_wtr());
}
public Xoh_wtr_itm Get_by_tid(int tid) {
Gfo_poolable_mgr pool = null;
@@ -35,6 +38,8 @@ public class Xoh_pool_mgr__wtr {
case Xoh_hzip_dict_.Tid__lnke: pool = pool__lnke; break;
case Xoh_hzip_dict_.Tid__img: pool = pool__img; break;
case Xoh_hzip_dict_.Tid__img_bare: pool = pool__img_bare; break;
case Xoh_hzip_dict_.Tid__timeline: pool = pool__timeline; break;
case Xoh_hzip_dict_.Tid__gallery: pool = pool__gallery; break;
default: return null;
}
return (Xoh_wtr_itm)pool.Get_fast();

View File

@@ -20,7 +20,7 @@ import gplx.xowa.htmls.core.wkrs.lnkes.*;
public class Xoh_stat_itm {
public void Clear() {
a_rhs = lnki_text_n = lnki_text_y = lnke__free = lnke__auto = lnke__text = 0;
hdr_1 = hdr_2 = hdr_3 = hdr_4 = hdr_5 = hdr_6 = 0;
hdr_1 = hdr_2 = hdr_3 = hdr_4 = hdr_5 = hdr_6 = timeline = gallery = 0;
img_full = 0;
space = 0;
Bry_.Clear(escape_bry);
@@ -32,6 +32,8 @@ public class Xoh_stat_itm {
public int Lnke__auto() {return lnke__auto;} public void Lnke__auto__add() {++lnke__auto;} private int lnke__auto;
public int Lnke__text() {return lnke__text;} public void Lnke__text__add() {++lnke__text;} private int lnke__text;
public int Img_full() {return img_full;} public void Img_full_add() {++img_full;} private int img_full;
public int Timeline() {return timeline;} public void Timeline_add() {++timeline;} private int timeline;
public int Gallery() {return gallery;} public void Gallery_add() {++gallery;} private int gallery;
public int Hdr_1() {return hdr_1;} private int hdr_1;
public int Hdr_2() {return hdr_2;} private int hdr_2;
public int Hdr_3() {return hdr_3;} private int hdr_3;
@@ -39,7 +41,7 @@ public class Xoh_stat_itm {
public int Hdr_5() {return hdr_5;} private int hdr_5;
public int Hdr_6() {return hdr_6;} private int hdr_6;
public int Space() {return space;} public void Space_add(int v) {space += v;} private int space;
public byte[] Escape_bry() {return escape_bry;} public void Escape_add(byte v) {escape_bry[v] += 1;} private final byte[] escape_bry = new byte[256];
public byte[] Escape_bry() {return escape_bry;} public void Escape_add(byte v) {escape_bry[v] += 1;} private final byte[] escape_bry = new byte[256];
public void Hdr_add(int hdr_num) {
switch (hdr_num) {
case 1: ++hdr_1; break;

View File

@@ -39,7 +39,7 @@ public class Xoh_make_mgr {
this.wiki_domain = wiki_domain;
}
public byte[] Parse(byte[] src, Xoh_page hpg, Xow_wiki wiki) {
hctx.Init_by_page(wiki, hpg.Url_bry_safe());
hctx.Init_by_page(wiki, hpg);
hpg.Section_mgr().Add(0, 2, Bry_.Empty, Bry_.Empty).Content_bgn_(0); // +1 to skip \n
make_parser.Parse(bfr, hpg, hctx, src);
hpg.Section_mgr().Set_content(hpg.Section_mgr().Len() - 1, src, src.length);

View File

@@ -31,7 +31,7 @@ public class Xoh_page_chkr {
return this;
}
public Xoh_page_chkr Imgs__add(String wiki_abrv, String lnki_ttl, byte lnki_type, double lnki_upright, int lnki_w, int lnki_h, double lnki_time, int lnki_page) {
Xof_fsdb_itm fsdb_itm = expd_img_mgr.Make_img();
Xof_fsdb_itm fsdb_itm = expd_img_mgr.Make_img(false);
fsdb_itm.Init_at_lnki(Xof_exec_tid.Tid_wiki_page, Bry_.new_u8(wiki_abrv), Bry_.new_u8(lnki_ttl), lnki_type, lnki_upright, lnki_w, lnki_h, lnki_time, lnki_page, Xof_patch_upright_tid_.Tid_all);
return this;
}

View File

@@ -33,6 +33,7 @@ public class Xoh_hdoc_ctx {
public boolean Xwiki_mgr__missing(byte[] domain){return app.Xwiki_mgr__missing(domain);}
public Xou_cache_finder File__mgr() {return file__mgr;} private Xou_cache_finder file__mgr = Xou_cache_finder_.Noop;
public Xof_url_bldr File__url_bldr() {return file__url_bldr;} private final Xof_url_bldr file__url_bldr = new Xof_url_bldr();
public Xoa_page Page() {return page;} private Xoa_page page;
public byte[] Page__url() {return page__url;} private byte[] page__url;
public Xoh_pool_mgr__hzip Pool_mgr__hzip() {return pool_mgr__hzip;} private final Xoh_pool_mgr__hzip pool_mgr__hzip = new Xoh_pool_mgr__hzip();
public Xoh_pool_mgr__data Pool_mgr__data() {return pool_mgr__data;} private final Xoh_pool_mgr__data pool_mgr__data = new Xoh_pool_mgr__data();
@@ -53,13 +54,14 @@ public class Xoh_hdoc_ctx {
if (cache_mgr != null) file__mgr = Xou_cache_finder_.New_db(cache_mgr); // NOTE: this effectively only loads the cache db in app mode (and not in test mode)
pool_mgr__hzip.Init();
}
public void Init_by_page(Xow_wiki wiki, byte[] page_url) {
public void Init_by_page(Xow_wiki wiki, Xoa_page page) {
if (fsys__root == null) Init_by_app(wiki.App()); // LAZY INIT
this.wiki__url_parser = wiki.Utl__url_parser();
this.wiki__ttl_parser = wiki;
this.wiki__domain_bry = wiki.Domain_bry();
this.fsys__file__wiki = Bry_.Add(fsys__file, wiki__domain_bry, Byte_ascii.Slash_bry);
this.page__url = page_url;
this.page = page;
this.page__url = page.Url_bry_safe();
this.Clear();
}
private void Clear() {

View File

@@ -33,6 +33,7 @@ public class Xoh_hzip_fxt {
hpg.Init(wiki, Xoa_url.blank(), parser_fxt.Wiki().Ttl_parse(Xoa_page_.Main_page_bry), 1);
}
public Xow_wiki Wiki() {return wiki;}
public Xoa_page Page() {return hpg;}
public Xoh_hzip_fxt Init_mode_is_b256_(boolean v) {bfr.Mode_is_b256_(v); mode_is_b256 = v; return this;}
public Xoh_hzip_fxt Init_mode_diff_y_() {hzip_mgr.Hctx().Mode_is_diff_(Bool_.Y); return this;}
public void Clear() {hpg.Clear();}
@@ -85,7 +86,7 @@ public class Xoh_hzip_fxt {
Gfo_usr_dlg_.Test__show__term();
Tfds.Eq_str_lines(hzip, bfr.To_str_and_clear());
}
private void Test__decode__raw(String hzip, String html) {
public void Test__decode__raw(String hzip, String html) {
Gfo_usr_dlg_.Test__show__init();
hpg.Section_mgr().Clear();
hzip_mgr.Decode(bfr, parser_fxt.Wiki(), hpg, Bry_.new_u8(hzip));

View File

@@ -19,11 +19,11 @@ package gplx.xowa.htmls.core.wkrs; import gplx.*; import gplx.xowa.*; import gpl
import gplx.core.brys.*;
import gplx.langs.htmls.*; import gplx.langs.htmls.docs.*;
public abstract class Xoh_itm_parser_fxt {
private final Xoae_app app;
private final Xowe_wiki wiki;
private final Bry_err_wkr err_wkr = new Bry_err_wkr();
private final Xoae_app app;
private final Xowe_wiki wiki;
private final Bry_err_wkr err_wkr = new Bry_err_wkr();
protected byte[] src; protected int src_len;
protected final Xoh_hdoc_ctx hctx = new Xoh_hdoc_ctx();
protected final Xoh_hdoc_ctx hctx = new Xoh_hdoc_ctx();
public Xoh_itm_parser_fxt() {
this.app = Xoa_app_fxt.Make__app__edit();
this.wiki = Xoa_app_fxt.Make__wiki__edit(app);
@@ -40,7 +40,8 @@ public abstract class Xoh_itm_parser_fxt {
}
public void Exec_parse(String src_str) {
this.src = Bry_.new_u8(src_str); this.src_len = src.length;
hctx.Init_by_page(wiki, Xoa_page_.Main_page_bry);
Xoh_page hpg = new Xoh_page(); // NOTE: no need to pass url and ttl now
hctx.Init_by_page(wiki, hpg);
err_wkr.Init_by_page(Xoa_page_.Main_page_str, src);
Exec_parse_hook(err_wkr, hctx, 0, src_len);
}

View File

@@ -0,0 +1,43 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.htmls.core.wkrs.addons.gallerys; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*; import gplx.xowa.htmls.core.wkrs.addons.*;
import gplx.core.threads.poolables.*;
import gplx.langs.htmls.*; import gplx.langs.htmls.docs.*;
import gplx.xowa.htmls.core.hzips.*;
public class Xoh_gallery_data implements Xoh_data_itm {// NOTE: some galleries fail hzip; use Hook_bry to catch them; PAGE:en.d:a; DATE:2016-06-24
public int Tid() {return Xoh_hzip_dict_.Tid__gallery;}
public int Src_bgn() {return src_bgn;} private int src_bgn;
public int Src_end() {return src_end;} private int src_end;
public void Clear() {
this.src_bgn = this.src_end = -1;
}
public boolean Init_by_parse(Xoh_hdoc_wkr hdoc_wkr, Xoh_hdoc_ctx hctx, Gfh_tag_rdr tag_rdr, byte[] src, Gfh_tag gallery_lhs, Gfh_tag unused) {
this.Clear();
this.src_bgn = gallery_lhs.Src_bgn();
this.src_end = gallery_lhs.Src_end();
return true;
}
public void Init_by_decode(int src_bgn, int src_end) {
this.src_bgn = src_bgn;
this.src_end = src_end;
}
public static final byte[] Hook_bry = Bry_.new_a7(" class=\"gallery mw-gallery");
public void Pool__rls () {pool_mgr.Rls_fast(pool_idx);} private Gfo_poolable_mgr pool_mgr; private int pool_idx;
public Gfo_poolable_itm Pool__make (Gfo_poolable_mgr mgr, int idx, Object[] args) {Xoh_gallery_data rv = new Xoh_gallery_data(); rv.pool_mgr = mgr; rv.pool_idx = idx; return rv;}
}

View File

@@ -0,0 +1,50 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.htmls.core.wkrs.addons.gallerys; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*; import gplx.xowa.htmls.core.wkrs.addons.*;
import gplx.core.brys.*; import gplx.core.threads.poolables.*; import gplx.xowa.wikis.ttls.*;
import gplx.xowa.htmls.core.hzips.*;
public class Xoh_gallery_hzip implements Xoh_hzip_wkr, Gfo_poolable_itm {
public int Tid() {return Xoh_hzip_dict_.Tid__gallery;}
public String Key() {return Xoh_hzip_dict_.Key__gallery;}
public byte[] Hook() {return hook;} private byte[] hook;
public Gfo_poolable_itm Encode1(Xoh_hzip_bfr bfr, Xoh_hdoc_wkr hdoc_wkr, Xoh_hdoc_ctx hctx, Xoh_page hpg, boolean wkr_is_root, byte[] src, Object data_obj) {
Xoh_gallery_data data = (Xoh_gallery_data)data_obj;
bfr.Add_mid(src, data.Src_bgn(), data.Src_end());
hctx.Hzip__stat().Gallery_add();
return this;
}
public void Decode1(Bry_bfr bfr, Xoh_hdoc_wkr hdoc_wkr, Xoh_hdoc_ctx hctx, Xoh_page hpg, Bry_rdr rdr, byte[] src, int src_bgn, int src_end, Xoh_data_itm data_itm) {
int gallery_bgn = src_bgn;
int gallery_end = Bry_find_.Find_fwd(src, Byte_ascii.Gt, src_bgn, src_end);
if (gallery_end == -1) {
Gfo_log_.Instance.Warn("hzip.gallery.end_not_found", "page", hpg.Url_bry_safe(), "src_bgn", src_bgn);
gallery_end = gallery_bgn;
}
else
++gallery_end;
Xoh_gallery_data data = (Xoh_gallery_data)data_itm;
data.Init_by_decode(gallery_bgn, gallery_end);
rdr.Move_to(gallery_end);
}
public void Pool__rls () {pool_mgr.Rls_fast(pool_idx);} private Gfo_poolable_mgr pool_mgr; private int pool_idx;
public Gfo_poolable_itm Pool__make (Gfo_poolable_mgr mgr, int idx, Object[] args) {Xoh_gallery_hzip rv = new Xoh_gallery_hzip(); rv.pool_mgr = mgr; rv.pool_idx = idx; rv.hook = (byte[])args[0]; return rv;}
}

View File

@@ -0,0 +1,29 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.htmls.core.wkrs.addons.gallerys; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*; import gplx.xowa.htmls.core.wkrs.addons.*;
import org.junit.*; import gplx.core.tests.*; import gplx.xowa.htmls.core.makes.tests.*;
public class Xoh_gallery_hzip_tst {
private final Xoh_hzip_fxt fxt = new Xoh_hzip_fxt().Init_mode_diff_y_();
@Test public void Basic() {
fxt.Test__decode
( "<ul class=\"gallery mw-gallery-traditional style=\"max-width:489px; _width:489px;\">"
, "<ul class=\"gallery mw-gallery-traditional style=\"max-width:489px; _width:489px;\">"
);
Gftest.Eq__bool_y(fxt.Page().Xtn__gallery_exists());
}
}

View File

@@ -0,0 +1,42 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.htmls.core.wkrs.addons.gallerys; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*; import gplx.xowa.htmls.core.wkrs.addons.*;
import gplx.core.brys.*; import gplx.core.primitives.*; import gplx.core.brys.fmtrs.*; import gplx.core.threads.poolables.*; import gplx.core.brys.args.*;
import gplx.langs.htmls.*; import gplx.xowa.htmls.core.wkrs.bfr_args.*;
import gplx.xowa.htmls.sections.*; import gplx.xowa.htmls.core.hzips.*;
public class Xoh_gallery_wtr implements gplx.core.brys.Bfr_arg, Xoh_wtr_itm {
private Xoh_page hpg;
private byte[] src; private int src_bgn, src_end;
public void Init_by_parse(Bry_bfr bfr, Xoh_page hpg, Xoh_hdoc_ctx hctx, byte[] src, Xoh_gallery_data data) {
Init_by_decode(hpg, hctx, src, data);
this.Bfr_arg__add(bfr);
}
public boolean Init_by_decode(Xoh_page hpg, Xoh_hdoc_ctx hctx, byte[] src, Xoh_data_itm data_itm) {
this.hpg = hpg; this.src = src;
Xoh_gallery_data data = (Xoh_gallery_data)data_itm;
this.src_bgn = data.Src_bgn();
this.src_end = data.Src_end();
return true;
}
public void Bfr_arg__add(Bry_bfr bfr) {
hpg.Xtn__gallery_exists_y_();
bfr.Add_mid(src, src_bgn, src_end);
}
public void Pool__rls () {pool_mgr.Rls_fast(pool_idx);} private Gfo_poolable_mgr pool_mgr; private int pool_idx;
public Gfo_poolable_itm Pool__make (Gfo_poolable_mgr mgr, int idx, Object[] args) {Xoh_gallery_wtr rv = new Xoh_gallery_wtr(); rv.pool_mgr = mgr; rv.pool_idx = idx; return rv;}
}

View File

@@ -0,0 +1,43 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.htmls.core.wkrs.addons.timelines; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*; import gplx.xowa.htmls.core.wkrs.addons.*;
import gplx.core.threads.poolables.*;
import gplx.langs.htmls.*; import gplx.langs.htmls.docs.*;
import gplx.xowa.htmls.core.hzips.*;
public class Xoh_timeline_data implements Xoh_data_itm {
public int Tid() {return Xoh_hzip_dict_.Tid__timeline;}
public int Src_bgn() {return src_bgn;} private int src_bgn;
public int Src_end() {return src_end;} private int src_end;
public void Clear() {
this.src_bgn = this.src_end = -1;
}
public boolean Init_by_parse(Xoh_hdoc_wkr hdoc_wkr, Xoh_hdoc_ctx hctx, Gfh_tag_rdr tag_rdr, byte[] src, Gfh_tag timeline_lhs, Gfh_tag unused) {
this.Clear();
this.src_bgn = timeline_lhs.Src_bgn();
this.src_end = timeline_lhs.Src_end();
return true;
}
public void Init_by_decode(int src_bgn, int src_end) {
this.src_bgn = src_bgn;
this.src_end = src_end;
}
public static final byte[] Hook_bry = Bry_.new_a7("<pre class='xowa-timeline'>");
public void Pool__rls () {pool_mgr.Rls_fast(pool_idx);} private Gfo_poolable_mgr pool_mgr; private int pool_idx;
public Gfo_poolable_itm Pool__make (Gfo_poolable_mgr mgr, int idx, Object[] args) {Xoh_timeline_data rv = new Xoh_timeline_data(); rv.pool_mgr = mgr; rv.pool_idx = idx; return rv;}
}

View File

@@ -0,0 +1,50 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.htmls.core.wkrs.addons.timelines; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*; import gplx.xowa.htmls.core.wkrs.addons.*;
import gplx.core.brys.*; import gplx.core.threads.poolables.*; import gplx.xowa.wikis.ttls.*;
import gplx.xowa.htmls.core.hzips.*;
public class Xoh_timeline_hzip implements Xoh_hzip_wkr, Gfo_poolable_itm {
public int Tid() {return Xoh_hzip_dict_.Tid__timeline;}
public String Key() {return Xoh_hzip_dict_.Key__timeline;}
public byte[] Hook() {return hook;} private byte[] hook;
public Gfo_poolable_itm Encode1(Xoh_hzip_bfr bfr, Xoh_hdoc_wkr hdoc_wkr, Xoh_hdoc_ctx hctx, Xoh_page hpg, boolean wkr_is_root, byte[] src, Object data_obj) {
Xoh_timeline_data data = (Xoh_timeline_data)data_obj;
// just add the entire thing; not worth trying to compress "<pre class='xowa-timeline'>"
bfr.Add_mid(src, data.Src_bgn(), data.Src_end());
hctx.Hzip__stat().Timeline_add();
return this;
}
public void Decode1(Bry_bfr bfr, Xoh_hdoc_wkr hdoc_wkr, Xoh_hdoc_ctx hctx, Xoh_page hpg, Bry_rdr rdr, byte[] src, int src_bgn, int src_end, Xoh_data_itm data_itm) {
int timeline_bgn = src_bgn;
int timeline_end = Bry_find_.Find_fwd(src, Byte_ascii.Gt, src_bgn, src_end);
if (timeline_end == -1) {
Gfo_log_.Instance.Warn("hzip.timeline.end_not_found", "page", hpg.Url_bry_safe(), "src_bgn", src_bgn);
timeline_end = timeline_bgn;
}
else
++timeline_end;
Xoh_timeline_data data = (Xoh_timeline_data)data_itm;
data.Init_by_decode(timeline_bgn, timeline_end);
}
public void Pool__rls () {pool_mgr.Rls_fast(pool_idx);} private Gfo_poolable_mgr pool_mgr; private int pool_idx;
public Gfo_poolable_itm Pool__make (Gfo_poolable_mgr mgr, int idx, Object[] args) {Xoh_timeline_hzip rv = new Xoh_timeline_hzip(); rv.pool_mgr = mgr; rv.pool_idx = idx; rv.hook = (byte[])args[0]; return rv;}
}

View File

@@ -0,0 +1,26 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.htmls.core.wkrs.addons.timelines; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*; import gplx.xowa.htmls.core.wkrs.addons.*;
import org.junit.*; import gplx.core.tests.*; import gplx.xowa.htmls.core.makes.tests.*;
public class Xoh_timeline_hzip_tst {
private final Xoh_hzip_fxt fxt = new Xoh_hzip_fxt().Init_mode_diff_y_();
@Test public void Basic() { // EX: <timeline>code</timeline>
fxt.Test__decode__raw("<pre class='xowa-timeline'>abc</pre>", "<pre class='xowa-timeline'>abc</pre>");
Gftest.Eq__bool_y(fxt.Page().Xtn__timeline_exists());
}
}

View File

@@ -0,0 +1,43 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.htmls.core.wkrs.addons.timelines; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*; import gplx.xowa.htmls.core.wkrs.addons.*;
import gplx.core.brys.*; import gplx.core.primitives.*; import gplx.core.brys.fmtrs.*; import gplx.core.threads.poolables.*; import gplx.core.brys.args.*;
import gplx.langs.htmls.*; import gplx.xowa.htmls.core.wkrs.bfr_args.*;
import gplx.xowa.htmls.sections.*; import gplx.xowa.htmls.core.hzips.*;
public class Xoh_timeline_wtr implements gplx.core.brys.Bfr_arg, Xoh_wtr_itm {
private Xoh_page hpg;
private byte[] src; private int src_bgn, src_end;
public void Init_by_parse(Bry_bfr bfr, Xoh_page hpg, Xoh_hdoc_ctx hctx, byte[] src, Xoh_timeline_data data) {
Init_by_decode(hpg, hctx, src, data);
this.Bfr_arg__add(bfr);
}
public boolean Init_by_decode(Xoh_page hpg, Xoh_hdoc_ctx hctx, byte[] src, Xoh_data_itm data_itm) {
this.hpg = hpg;
this.src = src;
Xoh_timeline_data data = (Xoh_timeline_data)data_itm;
this.src_bgn = data.Src_bgn();
this.src_end = data.Src_end();
return true;
}
public void Bfr_arg__add(Bry_bfr bfr) {
hpg.Xtn__timeline_exists_y_();
bfr.Add_mid(src, src_bgn, src_end);
}
public void Pool__rls () {pool_mgr.Rls_fast(pool_idx);} private Gfo_poolable_mgr pool_mgr; private int pool_idx;
public Gfo_poolable_itm Pool__make (Gfo_poolable_mgr mgr, int idx, Object[] args) {Xoh_timeline_wtr rv = new Xoh_timeline_wtr(); rv.pool_mgr = mgr; rv.pool_idx = idx; return rv;}
}

View File

@@ -18,8 +18,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.xowa.htmls.core.wkrs.bfr_args; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*;
import gplx.core.brys.*;
public class Bfr_arg__hatr_id implements Bfr_arg_clearable {
private final byte[] atr_bgn;
private final byte[] bry; private int num;
private final byte[] atr_bgn;
private final byte[] bry; private int num;
public Bfr_arg__hatr_id(byte[] atr_key, byte[] bry) {this.bry = bry; this.atr_bgn = Bfr_arg__hatr_.Bld_atr_bgn(atr_key);}
public Bfr_arg__hatr_id Set(int num) {this.num = num; return this;}
public void Bfr_arg__clear() {num = -1;}

View File

@@ -20,7 +20,7 @@ import gplx.core.brys.*;
import gplx.langs.htmls.*; import gplx.langs.htmls.docs.*; import gplx.langs.htmls.styles.*; import gplx.langs.htmls.clses.*;
import gplx.xowa.htmls.core.hzips.*;
import gplx.xowa.xtns.gallery.*;
public class Xoh_gly_grp_data implements Gfh_class_parser_wkr, Gfh_style_wkr {
public class Xoh_gly_grp_data implements Gfh_class_parser_wkr, Gfh_style_wkr { // FUTURE:add gallerycaption
private final List_adp itms_list = List_adp_.New();
public int Src_bgn() {return src_bgn;} private int src_bgn;
public int Src_end() {return src_end;} private int src_end;
@@ -54,6 +54,11 @@ public class Xoh_gly_grp_data implements Gfh_class_parser_wkr, Gfh_style_wkr {
while (true) {
li_head = tag_rdr.Tag__peek_fwd_head();
if (li_head.Name_id() != Gfh_tag_.Id__li) break; // no more <li>; break;
// FUTURE: galleries with gallerycaption will cause gallery to write raw; instate code below, but would need to then serialize "gallerycaption"; PAGE:en.d:A DATE:2016-06-24
// if (li_head.Atrs__cls_has(Atr__cls__gallerycaption)) {// skip <li class='gallerycaption'>A</li>
// li_head = tag_rdr.Tag__move_fwd_head();
// li_head = tag_rdr.Tag__peek_fwd_head();
// }
if (!li_head.Atrs__cls_has(Atr__cls__gallerybox)) return false;
tag_rdr.Pos_(li_head.Src_end());
Xoh_gly_itm_data itm_parser = new Xoh_gly_itm_data();
@@ -131,6 +136,7 @@ public class Xoh_gly_grp_data implements Gfh_class_parser_wkr, Gfh_style_wkr {
}
public static final byte[] Atr__cls__gallery = Bry_.new_a7("gallery");
private static final byte[] Atr__cls__mw_gallery = Bry_.new_a7("mw-gallery-"), Atr__cls__gallerybox = Bry_.new_a7("gallerybox")
// , Atr__cls__gallerycaption = Bry_.new_a7("gallerycaption")
, Style__max_width = Bry_.new_a7("max-width"), Style___width = Bry_.new_a7("_width")
;
}

View File

@@ -19,11 +19,11 @@ package gplx.xowa.htmls.core.wkrs.glys; import gplx.*; import gplx.xowa.*; impor
import gplx.core.brys.*; import gplx.core.brys.fmtrs.*;
import gplx.langs.htmls.*; import gplx.xowa.htmls.core.wkrs.bfr_args.*;
class Xoh_gly_grp_wtr implements Bfr_arg {
private final Bfr_arg_clearable[] arg_ary;
private final Bfr_arg__hatr_id ul_id = Bfr_arg__hatr_id.New_id("xogly_li_");
private final Bfr_arg__hatr_gly_style ul_style = new Bfr_arg__hatr_gly_style(Gfh_atr_.Bry__style);
private final Bfr_arg_clearable[] arg_ary;
private final Bfr_arg__hatr_id ul_id = Bfr_arg__hatr_id.New_id("xogly_li_");
private final Bfr_arg__hatr_gly_style ul_style = new Bfr_arg__hatr_gly_style(Gfh_atr_.Bry__style);
private byte[] ul_cls, xtra_cls, xtra_atr_bry, ul_nl;
private final Xoh_gly_itm_list_wtr itm_list_wtr = new Xoh_gly_itm_list_wtr();
private final Xoh_gly_itm_list_wtr itm_list_wtr = new Xoh_gly_itm_list_wtr();
public Xoh_gly_grp_wtr() {
arg_ary = new Bfr_arg_clearable[] {ul_id};
}
@@ -36,7 +36,7 @@ class Xoh_gly_grp_wtr implements Bfr_arg {
this.xtra_atr_bry = xtra_atr_bry;
this.ul_nl = ary.length == 0 ? Bry_.Empty : Byte_ascii.Nl_bry; // TIDY: <ul></ul> should be on same line if 0 items
itm_list_wtr.Init(ary);
ul_style.Set_args(ul_style_max_w, ul_style_w, xtra_style_bry);
ul_style.Set_args(ul_style_max_w, ul_style_w, xtra_style_bry);
}
public void Clear() {
for (Bfr_arg_clearable arg : arg_ary)
@@ -50,7 +50,7 @@ class Xoh_gly_grp_wtr implements Bfr_arg {
public void Bfr_arg__add(Bry_bfr bfr) {
fmtr.Bld_bfr_many(bfr, ul_id, ul_cls, xtra_cls, ul_style, xtra_atr_bry, itm_list_wtr, ul_nl);
}
private static final Bry_fmtr fmtr = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last
private static final Bry_fmtr fmtr = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last
( "<ul~{id} class=\"gallery mw-gallery-~{cls}~{xtra_cls}\"~{style}~{xtra_atr}>~{itms}~{ul_nl}</ul>"
), "id", "cls", "xtra_cls", "style", "xtra_atr", "itms", "ul_nl");
}
@@ -58,10 +58,12 @@ class Xoh_gly_itm_list_wtr implements Bfr_arg {
private Xoh_gly_itm_wtr[] ary; private int ary_len;
public void Init(Xoh_gly_itm_wtr[] ary) {
this.ary = ary; this.ary_len = ary.length;
}
public void Bfr_arg__clear() {
for (int i = 0; i < ary_len; ++i)
ary[i].Clear();
ary = null;
}
public void Bfr_arg__clear() {ary = null;}
public boolean Bfr_arg__missing() {return ary == null;}
public void Bfr_arg__add(Bry_bfr bfr) {
for (int i = 0; i < ary_len; ++i) {
@@ -71,7 +73,7 @@ class Xoh_gly_itm_list_wtr implements Bfr_arg {
}
}
class Bfr_arg__hatr_gly_style implements Bfr_arg {
private final byte[] atr_bgn;
private final byte[] atr_bgn;
private int max_w, w;
private byte[] xtra_cls;
public Bfr_arg__hatr_gly_style(byte[] key) {
@@ -101,7 +103,7 @@ class Bfr_arg__hatr_gly_style implements Bfr_arg {
}
bfr.Add_byte_quote();
}
private static final byte[]
private static final byte[]
Style__frag_1 = Bry_.new_a7("max-width:")
, Style__frag_2 = Bry_.new_a7("_width:")
, Style__frag_3 = Bry_.new_a7("px;")

View File

@@ -84,13 +84,15 @@ public class Xoh_gly_hzip implements Xoh_hzip_wkr, Gfo_poolable_itm {
Xoh_data_itm img_data = hctx.Pool_mgr__data().Get_by_tid(Xoh_hzip_dict_.Tid__img);
Xoh_hzip_wkr img_hzip = hctx.Pool_mgr__hzip().Mw__img();
img_hzip.Decode1(bfr, hdoc_wkr, hctx, hpg, rdr, src, src_bgn, src_end, img_data);
itm_wtr.Init(true, uid, li_w, div_1_w, div_2_margin, capt_tid, capt_bry);
((gplx.xowa.htmls.core.wkrs.imgs.Xoh_img_data)img_data).Img_is_gallery_(true);
itm_wtr.Img_wtr().Init_by_decode(hpg, hctx, src, img_data);
itm_wtr.Init(hctx.Mode_is_diff(), itm_wtr.Img_wtr().Fsdb_itm().Html_uid(), li_w, div_1_w, div_2_margin, capt_tid, capt_bry);
img_data.Pool__rls();
img_hzip.Pool__rls();
}
grp_wtr.Init(hctx.Mode_is_diff(), uid, cls_bry, ul_style_max_w, ul_style_w, xtra_cls_bry, xtra_style_bry, xtra_atr_bry, itm_ary);
grp_wtr.Bfr_arg__add(bfr);
hpg.Xtn__gallery_exists_y_();
}
public void Pool__rls () {pool_mgr.Rls_fast(pool_idx);} private Gfo_poolable_mgr pool_mgr; private int pool_idx;
public Gfo_poolable_itm Pool__make (Gfo_poolable_mgr mgr, int idx, Object[] args) {Xoh_gly_hzip rv = new Xoh_gly_hzip(); rv.pool_mgr = mgr; rv.pool_idx = idx; rv.hook = (byte[])args[0]; return rv;}

View File

@@ -0,0 +1,157 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.htmls.core.wkrs.glys; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*;
import org.junit.*; import gplx.xowa.htmls.core.hzips.*;
public class Xoh_gly_hzip__basic__tst {
private final Xoh_hzip_fxt fxt = new Xoh_hzip_fxt().Init_mode_diff_y_();
@Test public void Basic() {
fxt.Test__bicode("~'!{,L#{\"g{\"b0!A1~!1A.png~9\"D\"D{\"g{\"b0!B1~!1B.png~9\"D\"Dabc", String_.Concat_lines_nl_skip_last
( "<ul class='gallery mw-gallery-traditional' style='max-width:978px; _width:978px;'>"
, "<li class='gallerybox' style='width:155px;'>"
, "<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></div>"
, "</div>"
, "<div class='gallerytext'>"
, "<p>A1</p>"
, "</div>"
, "</div>"
, "</li>"
, "<li class='gallerybox' style='width:155px;'>"
, "<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></div>"
, "</div>"
, "<div class='gallerytext'>"
, "<p>B1</p>"
, "</div>"
, "</div>"
, "</li>"
, "</ul>abc"));
}
@Test public void Clear_state() { // page # wasn't being cleared between gallery itms; PAGE:en.w:Almagest; DATE:2016-01-05
fxt.Test__bicode("~'!{,L#{\"g{\"b0!A1~!1A.png~{\"d\"D\"D!#{\"g{\"b0!B1~!1B.png~{\"d\"D\"D!$abc", String_.Concat_lines_nl_skip_last
( "<ul class='gallery mw-gallery-traditional' style='max-width:978px; _width:978px;'>"
, "<li class='gallerybox' style='width:155px;'>"
, "<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|2' src='' width='0' height='0' alt=''></a></div>"
, "</div>"
, "<div class='gallerytext'>"
, "<p>A1</p>"
, "</div>"
, "</div>"
, "</li>"
, "<li class='gallerybox' style='width:155px;'>"
, "<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|3' src='' width='0' height='0' alt=''></a></div>"
, "</div>"
, "<div class='gallerytext'>"
, "<p>B1</p>"
, "</div>"
, "</div>"
, "</li>"
, "</ul>abc"));
}
@Test public void Extra_cls() { // PURPOSE: handle extra cls; EX: <gallery class='abc'>
fxt.Test__bicode("~'1!cls1 cls2~\"{\"g{\"b0!A1~!1A.png~9\"D\"D", String_.Concat_lines_nl_skip_last
( "<ul class='gallery mw-gallery-traditional cls1 cls2'>"
, "<li class='gallerybox' style='width:155px;'>"
, "<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></div>"
, "</div>"
, "<div class='gallerytext'>"
, "<p>A1</p>"
, "</div>"
, "</div>"
, "</li>"
, "</ul>"));
}
// FUTURE: galleries with gallerycaption will cause gallery to write raw; instate code below, but would need to then serialize "gallerycaption"; PAGE:en.d:A DATE:2016-06-24
//@Test public void Caption() { // handle <li class='gallerycaption'>A</li>; PAGE:en.d:a; DATE:2016-06-24
// fxt.Test__bicode("~'!!\"{\"g{\"b0!A1~!1A.png~9\"D\"D", String_.Concat_lines_nl_skip_last
// ( "<ul class='gallery mw-gallery-traditional'>"
// , "<li class='gallerycaption'>A</li>"
// , "<li class='gallerybox' style='width:155px;'>"
// , "<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></div>"
// , "</div>"
// , "<div class='gallerytext'>"
// , "<p>A1</p>"
// , "</div>"
// , "</div>"
// , "</li>"
// , "</ul>"));
//}
@Test public void Extra_cls__gallery() { // handle redundant gallery; EX: <gallery class='gallery'>; PAGE:en.w:Butuan; DATE:2016-01-05
fxt.Test__bicode("~'1!gallery~\"{\"g{\"b0!A1~!1A.png~9\"D\"D", String_.Concat_lines_nl_skip_last
( "<ul class='gallery mw-gallery-traditional gallery'>"
, "<li class='gallerybox' style='width:155px;'>"
, "<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></div>"
, "</div>"
, "<div class='gallerytext'>"
, "<p>A1</p>"
, "</div>"
, "</div>"
, "</li>"
, "</ul>"));
}
@Test public void Xtra_atr() { // PURPOSE: handle extra atr; EX: <gallery id='abc'>
fxt.Test__bicode("~'A! id=\"abc\"\"{\"g{\"b0!A1~!1A.png~9\"D\"D", String_.Concat_lines_nl_skip_last
( "<ul class='gallery mw-gallery-traditional' id='abc'>"
, "<li class='gallerybox' style='width:155px;'>"
, "<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></div>"
, "</div>"
, "<div class='gallerytext'>"
, "<p>A1</p>"
, "</div>"
, "</div>"
, "</li>"
, "</ul>"));
}
@Test public void Tidy__br_at_end() { // PURPOSE: handle inconsistent tidy behavior where <p> is put on one line ("<p>a</p>") unless it ends with <br> ("<p>a<br>\n</p>")
fxt.Test__bicode(String_.Concat_lines_nl_skip_last
( "~'!!\"{\"g{\"b0!A1<br>"
, "~!1A.png~9\"D\"D"
), String_.Concat_lines_nl_skip_last
( "<ul class='gallery mw-gallery-traditional'>"
, "<li class='gallerybox' style='width:155px;'>"
, "<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></div>"
, "</div>"
, "<div class='gallerytext'>"
, "<p>A1<br>" // TIDY: <br> forces </p> to be on next line
, "</p>"
, "</div>"
, "</div>"
, "</li>"
, "</ul>"));
}
@Test public void Tidy__empty() { // PURPOSE: no items should place </ul> on same line
fxt.Test__bicode("~'!!!", String_.Concat_lines_nl_skip_last
( "<ul class='gallery mw-gallery-traditional'></ul>")); // TIDY: <ul></ul> should be on same line if 0 items
}
}

View File

@@ -0,0 +1,124 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.htmls.core.wkrs.glys; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*;
import org.junit.*; import gplx.xowa.htmls.core.hzips.*;
public class Xoh_gly_hzip__caption__tst {
private final Xoh_hzip_fxt fxt = new Xoh_hzip_fxt().Init_mode_diff_y_();
@Test public void Capt_is_empty() { // PURPOSE: handle empty caption
fxt.Test__bicode("~'!!#{\"g{\"b0#~!1A.png~9\"D\"D{\"g{\"b0#!1A.png9\"D\"D<p>abc</p>", String_.Concat_lines_nl_skip_last
( "<ul class='gallery mw-gallery-traditional'>"
, "<li class='gallerybox' style='width:155px;'>"
, "<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></div>"
, "</div>"
, "<div class='gallerytext'></div>"
, "</div>"
, "</li>"
, "<li class='gallerybox' style='width:155px;'>"
, "<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></div>"
, "</div>"
, "<div class='gallerytext'></div>"
, "</div>"
, "</li>"
, "</ul><p>abc</p>"));
}
@Test public void Capt_is_br() { // PURPOSE: handle captions which have <br>, not <p>; PAGE:s.w:Sociology; DATE:2015-12-20
fxt.Test__bicode(String_.Concat_lines_nl_skip_last
( "~'!!\"{\"g{\"b0\"<b><i>A1</i></b>"
, "~!1A.png~9\"D\"D"), String_.Concat_lines_nl_skip_last
( "<ul class='gallery mw-gallery-traditional'>"
, "<li class='gallerybox' style='width:155px;'>"
, "<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></div>"
, "</div>"
, "<div class='gallerytext'><br>"
, "<b><i>A1</i></b>"
, "</div>"
, "</div>"
, "</li>"
, "</ul>"));
}
@Test public void Capt_has_multiple_p() { // PURPOSE: handle captions with multiple <p>; PAGE:en.w:Wikipedia:Bot_requests/Archive_25; DATE:2016-01-12
fxt.Test__bicode(String_.Concat_lines_nl_skip_last
( "~'!!\"{\"g{\"b0!a<br>"
, "b</p>"
, "<p><br>"
, "~!1A.png~9\"D\"D"), String_.Concat_lines_nl_skip_last
( "<ul class='gallery mw-gallery-traditional'>"
, "<li class='gallerybox' style='width:155px;'>"
, "<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></div>"
, "</div>"
, "<div class='gallerytext'>"
, "<p>a<br>"
, "b</p>"
, "<p><br>"
, "</p>"
, "</div>"
, "</div>"
, "</li>"
, "</ul>"));
}
@Test public void Capt_has_complicated_nl_behavior() {// handle complicated captions which force <div> on different line PAGE:en.w:Tamago_kake_gohan; DATE:2016-01-05
fxt.Test__bicode(String_.Concat_lines_nl_skip_last
( "~'!!\"{\"g{\"b>\"<div class=\"center\"><a href=\"/wiki/B.png\" class=\"image\" xowa_title=\"B.png\"><img data-xowa-title=\"A.png\" data-xoimg=\"0|120|-1|-1|-1|-1\" src=\"\" width=\"0\" height=\"0\" alt=\"\"></a></div>"
, "abc~\"\\A.png~#9\"D\"D"
), String_.Concat_lines_nl_skip_last
( "<ul class='gallery mw-gallery-traditional'>"
, "<li class='gallerybox' style='width:155px;'>"
, "<div style='width:155px;'>"
, "<div class='thumb' style='width:150px;'>"
, "<div style='margin:29px auto;'><a href='/wiki/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></div>"
, "</div>"
, "<div class='gallerytext'><br>"
, "<div class='center'><a href='/wiki/B.png' class='image' xowa_title='B.png'><img data-xowa-title='A.png' data-xoimg='0|120|-1|-1|-1|-1' src='' width='0' height='0' alt=''></a></div>"
, "abc</div>" // NOTE: tidy forces </div> to be on same line instead of next
, "</div>"
, "</li>"
, "</ul>"
));
}
@Test public void Capt_has_hr() {// handle <hr> which causes <p> to end early; PAGE:de.v:Kurs:Photoshop_Einzell<6C>sungen/HighKey_mit_CS5; DATE:2016-06-24
fxt.Test__bicode(String_.Concat_lines_nl_skip_last
( "~'!!\"{\"g{\"b>%a</p>"
, "<hr>"
, "b"
, "~\"\\A.png~#9\"D\"D")
, String_.Concat_lines_nl_skip_last
( "<ul class='gallery mw-gallery-traditional'>"
, "<li class='gallerybox' style='width:155px;'>"
, "<div style='width:155px;'>"
, "<div class='thumb' style='width:150px;'>"
, "<div style='margin:29px auto;'><a href='/wiki/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></div>"
, "</div>"
, "<div class='gallerytext'>"
, "<p>a</p>" // NOTE: </p> placed before <hr>
, "<hr>"
, "b" // NOTE: no <p> for "b"
, "</div>"
, "</div>"
, "</li>"
, "</ul>"
));
}
}

View File

@@ -0,0 +1,144 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.htmls.core.wkrs.glys; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*;
import org.junit.*; import gplx.xowa.htmls.core.hzips.*;
public class Xoh_gly_hzip__style__tst {
private final Xoh_hzip_fxt fxt = new Xoh_hzip_fxt().Init_mode_diff_y_();
@Test public void Style__no_max_width() { // PURPOSE: if no perrow=# then no "style='max-width:###; _width:###;'"
fxt.Test__bicode("~'!!\"{\"g{\"b0!A1~!1A.png~9\"D\"D", String_.Concat_lines_nl_skip_last
( "<ul class='gallery mw-gallery-traditional'>"
, "<li class='gallerybox' style='width:155px;'>"
, "<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></div>"
, "</div>"
, "<div class='gallerytext'>"
, "<p>A1</p>"
, "</div>"
, "</div>"
, "</li>"
, "</ul>"));
}
@Test public void Style__no_width() { // PURPOSE: if "_width" omitted, do not add back; EX: style="max-width:648px; margin:auto; background:transparent;"; PAGE:en.w:Wikipedia:Village_pump_(technical)/Archive_86 DATE:2016-01-12
fxt.Test__bicode("~'i{,L! color:blue;~\"{\"g{\"b0!A1~!1A.png~9\"D\"D", String_.Concat_lines_nl_skip_last
( "<ul class='gallery mw-gallery-traditional' style='max-width:978px; color:blue;'>"
, "<li class='gallerybox' style='width:155px;'>"
, "<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></div>"
, "</div>"
, "<div class='gallerytext'>"
, "<p>A1</p>"
, "</div>"
, "</div>"
, "</li>"
, "</ul>"));
}
@Test public void Style__max_width_duped() { // PURPOSE: if max-width duped, do not delete 2nd; EX: style="max-width:648px; color:blue; max-width:648px;"; PAGE:en.w:Wikipedia:Village_pump_(technical)/Archive_86 DATE:2016-01-12
fxt.Test__bicode("~'){(Z max-width:648px; color:blue;~\"{\"g{\"b0!A1~!1A.png~9\"D\"D", String_.Concat_lines_nl_skip_last
( "<ul class='gallery mw-gallery-traditional' style='max-width:652px; _width:652px; max-width:648px; color:blue;'>"
, "<li class='gallerybox' style='width:155px;'>"
, "<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></div>"
, "</div>"
, "<div class='gallerytext'>"
, "<p>A1</p>"
, "</div>"
, "</div>"
, "</li>"
, "</ul>"));
}
@Test public void Style__append() { // PURPOSE: handle appended style; EX: <gallery perrow=4 style='color:blue; float:left;'>
fxt.Test__bicode("~'){,L color:blue; float:left;~\"{\"g{\"b0!A1~!1A.png~9\"D\"D", String_.Concat_lines_nl_skip_last
( "<ul class='gallery mw-gallery-traditional' style='max-width:978px; _width:978px; color:blue; float:left;'>"
, "<li class='gallerybox' style='width:155px;'>"
, "<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></div>"
, "</div>"
, "<div class='gallerytext'>"
, "<p>A1</p>"
, "</div>"
, "</div>"
, "</li>"
, "</ul>"));
}
@Test public void Style__invalid_unclosed() { // handle broken styles; EX: <gallery style='center'>
fxt.Test__bicode("~'9!center~center~\"{\"g{\"bl!abc~!1A.png~9\"D\"D", String_.Concat_lines_nl_skip_last
( "<ul class='gallery mw-gallery-traditional center' style='center'>"
, "<li class='gallerybox' style='width:155px;'>"
, "<div style='width:155px;'>"
, "<div class='thumb' style='width:150px;'>"
, "<div style='margin:75px 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></div>"
, "</div>"
, "<div class='gallerytext'>"
, "<p>abc</p>"
, "</div>"
, "</div>"
, "</li>"
, "</ul>"
));
}
@Test public void Style__extra_colon() { // handle broken styles; EX: <gallery style='a:b:c:d;' PAGE:en.w:Bronze_Horseman DATE:2016-01-05
fxt.Test__bicode("~'9!center~color:red:float:right;~\"{\"g{\"bl!abc~!1A.png~9\"D\"D", String_.Concat_lines_nl_skip_last
( "<ul class='gallery mw-gallery-traditional center' style='color:red:float:right;'>"
, "<li class='gallerybox' style='width:155px;'>"
, "<div style='width:155px;'>"
, "<div class='thumb' style='width:150px;'>"
, "<div style='margin:75px 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></div>"
, "</div>"
, "<div class='gallerytext'>"
, "<p>abc</p>"
, "</div>"
, "</div>"
, "</li>"
, "</ul>"
));
}
@Test public void Style__replace() { // PURPOSE: handle replaced style; EX: <gallery style='color:blue; float:left;'>
fxt.Test__bicode("~')!color:blue; float:left;~\"{\"g{\"b0!A1~!1A.png~9\"D\"D", String_.Concat_lines_nl_skip_last
( "<ul class='gallery mw-gallery-traditional' style='color:blue; float:left;'>"
, "<li class='gallerybox' style='width:155px;'>"
, "<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></div>"
, "</div>"
, "<div class='gallerytext'>"
, "<p>A1</p>"
, "</div>"
, "</div>"
, "</li>"
, "</ul>"));
}
@Test public void Style__ws() { // PURPOSE: handle ws in style; EX: <gallery class="gallery mw-gallery-traditional" style="max-width:1115px; _width:1115px; color:blue;'>; PAGE:en.w:Anti-Serb_sentiment; DATE:2016-01-08
fxt.Test__bicode("~'){,L color:blue;~\"{\"g{\"b0!A1~!1A.png~9\"D\"D", String_.Concat_lines_nl_skip_last
( "<ul class='gallery mw-gallery-traditional' style='max-width:978px; _width:978px; color:blue;'>"
, "<li class='gallerybox' style='width:155px;'>"
, "<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></div>"
, "</div>"
, "<div class='gallerytext'>"
, "<p>A1</p>"
, "</div>"
, "</div>"
, "</li>"
, "</ul>"));
}
}

View File

@@ -1,341 +0,0 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.htmls.core.wkrs.glys; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*;
import org.junit.*; import gplx.xowa.htmls.core.hzips.*;
public class Xoh_gly_hzip_tst {
private final Xoh_hzip_fxt fxt = new Xoh_hzip_fxt().Init_mode_diff_y_();
@Test public void Basic() {
fxt.Test__bicode("~'!{,L#{\"g{\"b0!A1~!1A.png~9\"D\"D{\"g{\"b0!B1~!1B.png~9\"D\"Dabc", String_.Concat_lines_nl_skip_last
( "<ul class='gallery mw-gallery-traditional' style='max-width:978px; _width:978px;'>"
, "<li class='gallerybox' style='width:155px;'>"
, "<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></div>"
, "</div>"
, "<div class='gallerytext'>"
, "<p>A1</p>"
, "</div>"
, "</div>"
, "</li>"
, "<li class='gallerybox' style='width:155px;'>"
, "<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></div>"
, "</div>"
, "<div class='gallerytext'>"
, "<p>B1</p>"
, "</div>"
, "</div>"
, "</li>"
, "</ul>abc"));
}
@Test public void Clear_state() { // page # wasn't being cleared between gallery itms; PAGE:en.w:Almagest; DATE:2016-01-05
fxt.Test__bicode("~'!{,L#{\"g{\"b0!A1~!1A.png~{\"d\"D\"D!#{\"g{\"b0!B1~!1B.png~{\"d\"D\"D!$abc", String_.Concat_lines_nl_skip_last
( "<ul class='gallery mw-gallery-traditional' style='max-width:978px; _width:978px;'>"
, "<li class='gallerybox' style='width:155px;'>"
, "<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|2' src='' width='0' height='0' alt=''></a></div>"
, "</div>"
, "<div class='gallerytext'>"
, "<p>A1</p>"
, "</div>"
, "</div>"
, "</li>"
, "<li class='gallerybox' style='width:155px;'>"
, "<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|3' src='' width='0' height='0' alt=''></a></div>"
, "</div>"
, "<div class='gallerytext'>"
, "<p>B1</p>"
, "</div>"
, "</div>"
, "</li>"
, "</ul>abc"));
}
@Test public void Capt_is_empty() { // PURPOSE: handle empty caption
fxt.Test__bicode("~'!!#{\"g{\"b0#~!1A.png~9\"D\"D{\"g{\"b0#!1A.png9\"D\"D<p>abc</p>", String_.Concat_lines_nl_skip_last
( "<ul class='gallery mw-gallery-traditional'>"
, "<li class='gallerybox' style='width:155px;'>"
, "<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></div>"
, "</div>"
, "<div class='gallerytext'></div>"
, "</div>"
, "</li>"
, "<li class='gallerybox' style='width:155px;'>"
, "<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></div>"
, "</div>"
, "<div class='gallerytext'></div>"
, "</div>"
, "</li>"
, "</ul><p>abc</p>"));
}
@Test public void Capt_is_br() { // PURPOSE: handle captions which have <br>, not <p>; PAGE:s.w:Sociology; DATE:2015-12-20
fxt.Test__bicode(String_.Concat_lines_nl_skip_last
( "~'!!\"{\"g{\"b0\"<b><i>A1</i></b>"
, "~!1A.png~9\"D\"D"), String_.Concat_lines_nl_skip_last
( "<ul class='gallery mw-gallery-traditional'>"
, "<li class='gallerybox' style='width:155px;'>"
, "<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></div>"
, "</div>"
, "<div class='gallerytext'><br>"
, "<b><i>A1</i></b>"
, "</div>"
, "</div>"
, "</li>"
, "</ul>"));
}
@Test public void Capt_has_multiple_p() { // PURPOSE: handle captions with multiple <p>; PAGE:en.w:Wikipedia:Bot_requests/Archive_25; DATE:2016-01-12
fxt.Test__bicode(String_.Concat_lines_nl_skip_last
( "~'!!\"{\"g{\"b0!a<br>"
, "b</p>"
, "<p><br>"
, "~!1A.png~9\"D\"D"), String_.Concat_lines_nl_skip_last
( "<ul class='gallery mw-gallery-traditional'>"
, "<li class='gallerybox' style='width:155px;'>"
, "<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></div>"
, "</div>"
, "<div class='gallerytext'>"
, "<p>a<br>"
, "b</p>"
, "<p><br>"
, "</p>"
, "</div>"
, "</div>"
, "</li>"
, "</ul>"));
}
@Test public void Capt_has_complicated_nl_behavior() {// handle complicated captions which force <div> on different line PAGE:en.w:Tamago_kake_gohan; DATE:2016-01-05
fxt.Test__bicode(String_.Concat_lines_nl_skip_last
( "~'!!\"{\"g{\"b>\"<div class=\"center\"><a href=\"/wiki/B.png\" class=\"image\" xowa_title=\"B.png\"><img data-xowa-title=\"A.png\" data-xoimg=\"0|120|-1|-1|-1|-1\" src=\"\" width=\"0\" height=\"0\" alt=\"\"></a></div>"
, "abc~\"\\A.png~#9\"D\"D"
), String_.Concat_lines_nl_skip_last
( "<ul class='gallery mw-gallery-traditional'>"
, "<li class='gallerybox' style='width:155px;'>"
, "<div style='width:155px;'>"
, "<div class='thumb' style='width:150px;'>"
, "<div style='margin:29px auto;'><a href='/wiki/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></div>"
, "</div>"
, "<div class='gallerytext'><br>"
, "<div class='center'><a href='/wiki/B.png' class='image' xowa_title='B.png'><img data-xowa-title='A.png' data-xoimg='0|120|-1|-1|-1|-1' src='' width='0' height='0' alt=''></a></div>"
, "abc</div>" // NOTE: tidy forces </div> to be on same line instead of next
, "</div>"
, "</li>"
, "</ul>"
));
}
@Test public void Style__no_max_width() { // PURPOSE: if no perrow=# then no "style='max-width:###; _width:###;'"
fxt.Test__bicode("~'!!\"{\"g{\"b0!A1~!1A.png~9\"D\"D", String_.Concat_lines_nl_skip_last
( "<ul class='gallery mw-gallery-traditional'>"
, "<li class='gallerybox' style='width:155px;'>"
, "<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></div>"
, "</div>"
, "<div class='gallerytext'>"
, "<p>A1</p>"
, "</div>"
, "</div>"
, "</li>"
, "</ul>"));
}
@Test public void Style__no_width() { // PURPOSE: if "_width" omitted, do not add back; EX: style="max-width:648px; margin:auto; background:transparent;"; PAGE:en.w:Wikipedia:Village_pump_(technical)/Archive_86 DATE:2016-01-12
fxt.Test__bicode("~'i{,L! color:blue;~\"{\"g{\"b0!A1~!1A.png~9\"D\"D", String_.Concat_lines_nl_skip_last
( "<ul class='gallery mw-gallery-traditional' style='max-width:978px; color:blue;'>"
, "<li class='gallerybox' style='width:155px;'>"
, "<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></div>"
, "</div>"
, "<div class='gallerytext'>"
, "<p>A1</p>"
, "</div>"
, "</div>"
, "</li>"
, "</ul>"));
}
@Test public void Style__max_width_duped() { // PURPOSE: if max-width duped, do not delete 2nd; EX: style="max-width:648px; color:blue; max-width:648px;"; PAGE:en.w:Wikipedia:Village_pump_(technical)/Archive_86 DATE:2016-01-12
fxt.Test__bicode("~'){(Z max-width:648px; color:blue;~\"{\"g{\"b0!A1~!1A.png~9\"D\"D", String_.Concat_lines_nl_skip_last
( "<ul class='gallery mw-gallery-traditional' style='max-width:652px; _width:652px; max-width:648px; color:blue;'>"
, "<li class='gallerybox' style='width:155px;'>"
, "<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></div>"
, "</div>"
, "<div class='gallerytext'>"
, "<p>A1</p>"
, "</div>"
, "</div>"
, "</li>"
, "</ul>"));
}
@Test public void Style__append() { // PURPOSE: handle appended style; EX: <gallery perrow=4 style='color:blue; float:left;'>
fxt.Test__bicode("~'){,L color:blue; float:left;~\"{\"g{\"b0!A1~!1A.png~9\"D\"D", String_.Concat_lines_nl_skip_last
( "<ul class='gallery mw-gallery-traditional' style='max-width:978px; _width:978px; color:blue; float:left;'>"
, "<li class='gallerybox' style='width:155px;'>"
, "<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></div>"
, "</div>"
, "<div class='gallerytext'>"
, "<p>A1</p>"
, "</div>"
, "</div>"
, "</li>"
, "</ul>"));
}
@Test public void Style__invalid_unclosed() { // handle broken styles; EX: <gallery style='center'>
fxt.Test__bicode("~'9!center~center~\"{\"g{\"bl!abc~!1A.png~9\"D\"D", String_.Concat_lines_nl_skip_last
( "<ul class='gallery mw-gallery-traditional center' style='center'>"
, "<li class='gallerybox' style='width:155px;'>"
, "<div style='width:155px;'>"
, "<div class='thumb' style='width:150px;'>"
, "<div style='margin:75px 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></div>"
, "</div>"
, "<div class='gallerytext'>"
, "<p>abc</p>"
, "</div>"
, "</div>"
, "</li>"
, "</ul>"
));
}
@Test public void Style__extra_colon() { // handle broken styles; EX: <gallery style='a:b:c:d;' PAGE:en.w:Bronze_Horseman DATE:2016-01-05
fxt.Test__bicode("~'9!center~color:red:float:right;~\"{\"g{\"bl!abc~!1A.png~9\"D\"D", String_.Concat_lines_nl_skip_last
( "<ul class='gallery mw-gallery-traditional center' style='color:red:float:right;'>"
, "<li class='gallerybox' style='width:155px;'>"
, "<div style='width:155px;'>"
, "<div class='thumb' style='width:150px;'>"
, "<div style='margin:75px 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></div>"
, "</div>"
, "<div class='gallerytext'>"
, "<p>abc</p>"
, "</div>"
, "</div>"
, "</li>"
, "</ul>"
));
}
@Test public void Style__replace() { // PURPOSE: handle replaced style; EX: <gallery style='color:blue; float:left;'>
fxt.Test__bicode("~')!color:blue; float:left;~\"{\"g{\"b0!A1~!1A.png~9\"D\"D", String_.Concat_lines_nl_skip_last
( "<ul class='gallery mw-gallery-traditional' style='color:blue; float:left;'>"
, "<li class='gallerybox' style='width:155px;'>"
, "<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></div>"
, "</div>"
, "<div class='gallerytext'>"
, "<p>A1</p>"
, "</div>"
, "</div>"
, "</li>"
, "</ul>"));
}
@Test public void Style__ws() { // PURPOSE: handle ws in style; EX: <gallery class="gallery mw-gallery-traditional" style="max-width:1115px; _width:1115px; color:blue;'>; PAGE:en.w:Anti-Serb_sentiment; DATE:2016-01-08
fxt.Test__bicode("~'){,L color:blue;~\"{\"g{\"b0!A1~!1A.png~9\"D\"D", String_.Concat_lines_nl_skip_last
( "<ul class='gallery mw-gallery-traditional' style='max-width:978px; _width:978px; color:blue;'>"
, "<li class='gallerybox' style='width:155px;'>"
, "<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></div>"
, "</div>"
, "<div class='gallerytext'>"
, "<p>A1</p>"
, "</div>"
, "</div>"
, "</li>"
, "</ul>"));
}
@Test public void Extra_cls() { // PURPOSE: handle extra cls; EX: <gallery class='abc'>
fxt.Test__bicode("~'1!cls1 cls2~\"{\"g{\"b0!A1~!1A.png~9\"D\"D", String_.Concat_lines_nl_skip_last
( "<ul class='gallery mw-gallery-traditional cls1 cls2'>"
, "<li class='gallerybox' style='width:155px;'>"
, "<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></div>"
, "</div>"
, "<div class='gallerytext'>"
, "<p>A1</p>"
, "</div>"
, "</div>"
, "</li>"
, "</ul>"));
}
@Test public void Extra_cls__gallery() { // handle redundant gallery; EX: <gallery class='gallery'>; PAGE:en.w:Butuan; DATE:2016-01-05
fxt.Test__bicode("~'1!gallery~\"{\"g{\"b0!A1~!1A.png~9\"D\"D", String_.Concat_lines_nl_skip_last
( "<ul class='gallery mw-gallery-traditional gallery'>"
, "<li class='gallerybox' style='width:155px;'>"
, "<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></div>"
, "</div>"
, "<div class='gallerytext'>"
, "<p>A1</p>"
, "</div>"
, "</div>"
, "</li>"
, "</ul>"));
}
@Test public void Xtra_atr() { // PURPOSE: handle extra atr; EX: <gallery id='abc'>
fxt.Test__bicode("~'A! id=\"abc\"\"{\"g{\"b0!A1~!1A.png~9\"D\"D", String_.Concat_lines_nl_skip_last
( "<ul class='gallery mw-gallery-traditional' id='abc'>"
, "<li class='gallerybox' style='width:155px;'>"
, "<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></div>"
, "</div>"
, "<div class='gallerytext'>"
, "<p>A1</p>"
, "</div>"
, "</div>"
, "</li>"
, "</ul>"));
}
@Test public void Tidy__br_at_end() { // PURPOSE: handle inconsistent tidy behavior where <p> is put on one line ("<p>a</p>") unless it ends with <br> ("<p>a<br>\n</p>")
fxt.Test__bicode(String_.Concat_lines_nl_skip_last
( "~'!!\"{\"g{\"b0!A1<br>"
, "~!1A.png~9\"D\"D"
), String_.Concat_lines_nl_skip_last
( "<ul class='gallery mw-gallery-traditional'>"
, "<li class='gallerybox' style='width:155px;'>"
, "<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></div>"
, "</div>"
, "<div class='gallerytext'>"
, "<p>A1<br>" // TIDY: <br> forces </p> to be on next line
, "</p>"
, "</div>"
, "</div>"
, "</li>"
, "</ul>"));
}
@Test public void Tidy__empty() { // PURPOSE: no items should place </ul> on same line
fxt.Test__bicode("~'!!!", String_.Concat_lines_nl_skip_last
( "<ul class='gallery mw-gallery-traditional'></ul>")); // TIDY: <ul></ul> should be on same line if 0 items
}
}

View File

@@ -95,12 +95,14 @@ public class Xoh_gly_itm_data {
capt_end = div_tail.Src_bgn();
if (Bry_.Match(src, capt_end - 5, capt_end, Bry__p__rhs))
capt_end -= 5; // set capt_end to before </p>; 5 = "\n</p>";
else // no </p>; occurs when <hr> in middle; PAGE:fr.w:Forfry DATE:2016-06-24
capt_tid = Capt_tid__p_wo_rhs;
}
tag_rdr.Pos_(capt_tail_end);
return true;
}
private static final byte[] Atr__cls__gallerytext = Bry_.new_a7("gallerytext"), Bry__p__rhs = Bry_.new_a7("</p>\n");
public static final byte Capt_tid__p = 0, Capt_tid__br = 1, Capt_tid__empty = 2, Capt_tid__null = 3;
public static final byte Capt_tid__p = 0, Capt_tid__br = 1, Capt_tid__empty = 2, Capt_tid__null = 3, Capt_tid__p_wo_rhs = 4;
private static final Btrie_slim_mgr Capt_tid__trie = Btrie_slim_mgr.ci_a7()
.Add_bry_byte(Gfh_tag_.P_lhs , Capt_tid__p)
.Add_bry_byte(Gfh_tag_.Br_lhs , Capt_tid__br)

View File

@@ -19,15 +19,15 @@ package gplx.xowa.htmls.core.wkrs.glys; import gplx.*; import gplx.xowa.*; impor
import gplx.core.brys.*; import gplx.core.brys.fmtrs.*;
import gplx.langs.htmls.*; import gplx.xowa.htmls.core.wkrs.bfr_args.*; import gplx.xowa.htmls.core.wkrs.imgs.*;
public class Xoh_gly_itm_wtr implements Bfr_arg {
private final Bfr_arg_clearable[] arg_ary;
private final Bfr_arg__hatr_id li_id = Bfr_arg__hatr_id.New_id("xogly_li_"), img_id = Bfr_arg__hatr_id.New_id(gplx.xowa.htmls.Xoh_img_mgr.Bry__html_uid)
, div_1_id = Bfr_arg__hatr_id.New_id("xogly_div1_"), div_2_id = Bfr_arg__hatr_id.New_id("xogly_div2_"), div_3_id = Bfr_arg__hatr_id.New_id("xogly_div3_");
private final Bfr_arg__itm_caption itm_caption_fmtr = new Bfr_arg__itm_caption();
private final Bfr_arg_clearable[] arg_ary;
private final Bfr_arg__hatr_id li_id = Bfr_arg__hatr_id.New_id("xogly_li_"), img_id = Bfr_arg__hatr_id.New_id(gplx.xowa.htmls.Xoh_img_mgr.Bry__html_uid)
, div_1_id = Bfr_arg__hatr_id.New_id("xowa_gallery_div1_"), div_2_id = Bfr_arg__hatr_id.New_id("xowa_gallery_div2_"), div_3_id = Bfr_arg__hatr_id.New_id("xowa_gallery_div3_");
private final Bfr_arg__itm_caption itm_caption_fmtr = new Bfr_arg__itm_caption();
private int li_w, div_1_w, div_2_margin;
public Xoh_gly_itm_wtr() {
arg_ary = new Bfr_arg_clearable[] {li_id, div_1_id, div_2_id, div_3_id, img_id};
}
public Xoh_img_wtr Img_wtr() {return img_wtr;} private final Xoh_img_wtr img_wtr = new Xoh_img_wtr();
public Xoh_img_wtr Img_wtr() {return img_wtr;} private final Xoh_img_wtr img_wtr = new Xoh_img_wtr();
public void Init(boolean mode_is_diff, int img_id, int li_w, int div_1_w, int div_2_margin, byte capt_tid, byte[] itm_caption) {
this.Clear();
this.li_w = li_w; this.div_1_w = div_1_w; this.div_2_margin = div_2_margin;
@@ -48,8 +48,8 @@ public class Xoh_gly_itm_wtr implements Bfr_arg {
public void Bfr_arg__add(Bry_bfr bfr) {
fmtr.Bld_bfr_many(bfr, li_id, div_1_id, div_2_id, div_3_id, li_w, div_1_w, div_2_margin, img_wtr, itm_caption_fmtr);
}
public static final Xoh_gly_itm_wtr[] Ary_empty = new Xoh_gly_itm_wtr[0];
private static final Bry_fmtr fmtr = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last
public static final Xoh_gly_itm_wtr[] Ary_empty = new Xoh_gly_itm_wtr[0];
private static final Bry_fmtr fmtr = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last
( ""
, "<li~{li_id} class=\"gallerybox\" style=\"width:~{li_w}px;\">"
, "<div~{div_1_id} style=\"width:~{li_w}px;\">"
@@ -70,9 +70,10 @@ class Bfr_arg__itm_caption implements Bfr_arg {
public void Bfr_arg__add(Bry_bfr bfr) {
if (Bfr_arg__missing()) return;
switch (capt_tid) {
case Xoh_gly_itm_data.Capt_tid__empty: return; // <div class='gallerytext'></div>
case Xoh_gly_itm_data.Capt_tid__p: bfr.Add_byte_nl().Add(Gfh_tag_.P_lhs); break; // <div class='gallerytext'><p>
case Xoh_gly_itm_data.Capt_tid__br: bfr.Add(Gfh_tag_.Br_lhs).Add_byte_nl(); break; // <div class='gallerytext'><br>
case Xoh_gly_itm_data.Capt_tid__empty: return; // <div class='gallerytext'></div>
case Xoh_gly_itm_data.Capt_tid__p: bfr.Add_byte_nl().Add(Gfh_tag_.P_lhs); break; // <div class='gallerytext'><p>
case Xoh_gly_itm_data.Capt_tid__br: bfr.Add(Gfh_tag_.Br_lhs).Add_byte_nl(); break; // <div class='gallerytext'><br>
case Xoh_gly_itm_data.Capt_tid__p_wo_rhs: bfr.Add_byte_nl().Add(Gfh_tag_.P_lhs); break; // <div class='gallerytext'><br>
}
bfr.Add(capt_bry);
int itm_caption_len = capt_bry.length;

View File

@@ -25,9 +25,9 @@ public class Xoh_gly_itm_wtr_tst {
fxt.Test__write(String_.Concat_lines_nl_skip_last
( ""
, "<li id='xogly_li_0' class='gallerybox' style='width:155px;'>"
, "<div id='xogly_div1_0' style='width:155px;'>"
, "<div id='xogly_div2_0' class='thumb' style='width:150px;'>"
, "<div id='xogly_div3_0' style='margin:5px auto;'><a href='/wiki/File:A.png' class='image' xowa_title='A.png'><img id='xoimg_0' data-xoimg='0|120|120|-1|-1|-1' width='0' height='0'></a></div>"
, "<div id='xowa_gallery_div1_0' style='width:155px;'>"
, "<div id='xowa_gallery_div2_0' class='thumb' style='width:150px;'>"
, "<div id='xowa_gallery_div3_0' style='margin:5px auto;'><a href='/wiki/File:A.png' class='image' xowa_title='A.png'><img id='xoimg_0' data-xoimg='0|120|120|-1|-1|-1' width='0' height='0'></a></div>"
, "</div>"
, "<div class='gallerytext'>"
, "<p>caption</p>"

View File

@@ -48,7 +48,7 @@ public class Xoh_hdr_wtr implements gplx.core.brys.Bfr_arg, Xoh_wtr_itm {
}
public void Pool__rls () {pool_mgr.Rls_fast(pool_idx);} private Gfo_poolable_mgr pool_mgr; private int pool_idx;
public Gfo_poolable_itm Pool__make (Gfo_poolable_mgr mgr, int idx, Object[] args) {Xoh_hdr_wtr rv = new Xoh_hdr_wtr(); rv.pool_mgr = mgr; rv.pool_idx = idx; return rv;}
private static final Bry_fmtr fmtr = Bry_fmtr.new_
private static final Bry_fmtr fmtr = Bry_fmtr.new_
( "<h~{lvl}><span class=\"mw-headline\" id=\"~{id}\">~{content}</span>~{capt_rhs}</h~{lvl}>"
, "lvl", "id", "content", "capt_rhs");
}

View File

@@ -31,8 +31,8 @@ public class Xoh_img_data implements Xoh_data_itm {
public int Anch_title_end() {return anch_title_end;} private int anch_title_end;
public boolean Anch_title_exists() {return anch_title_end != -1;}
public Bry_obj_ref Anch_page() {return anch_page;} private Bry_obj_ref anch_page = Bry_obj_ref.New_empty();
public Xoh_img_src_data Img_src() {return img_src;} private final Xoh_img_src_data img_src = new Xoh_img_src_data();
public Xoh_img_cls_data Img_cls() {return img_cls;} private final Xoh_img_cls_data img_cls = new Xoh_img_cls_data();
public Xoh_img_src_data Img_src() {return img_src;} private final Xoh_img_src_data img_src = new Xoh_img_src_data();
public Xoh_img_cls_data Img_cls() {return img_cls;} private final Xoh_img_cls_data img_cls = new Xoh_img_cls_data();
public Xoh_img_xoimg_data Img_xoimg() {return img_xoimg;} private Xoh_img_xoimg_data img_xoimg = new Xoh_img_xoimg_data();
public int Img_alt_bgn() {return img_alt_bgn;} private int img_alt_bgn;
public int Img_alt_end() {return img_alt_end;} private int img_alt_end;
@@ -43,8 +43,9 @@ public class Xoh_img_data implements Xoh_data_itm {
public boolean Img_is_vid() {return img_is_vid;} private boolean img_is_vid;
public boolean Img_wo_anch() {return img_wo_anch;} private boolean img_wo_anch;
public int Img_imap_idx() {return img_imap_idx;} private int img_imap_idx;
public boolean Img_is_gallery() {return img_is_gallery;} private boolean img_is_gallery; public void Img_is_gallery_(boolean v) {this.img_is_gallery = v;}
public void Clear() {
this.img_alt__diff_anch_title = anch_rel_is_nofollow = img_is_vid = img_wo_anch = false;
this.img_alt__diff_anch_title = anch_rel_is_nofollow = img_is_vid = img_wo_anch = img_is_gallery = false;
this.src_bgn = src_end = anch_title_bgn = anch_title_end = img_w = img_h = img_alt_bgn = img_alt_end = -1;
this.img_imap_idx = -1;
anch_href.Clear(); anch_cls.Clear();
@@ -125,7 +126,7 @@ public class Xoh_img_data implements Xoh_data_itm {
}
return rv;
}
public static final byte[]
public static final byte[]
Bry__cls__anch__image = Bry_.new_a7("image")
, Bry__cls__img__thumbimage = Bry_.new_a7("thumbimage")
, Bry__atr__xowa_title = Bry_.new_a7("xowa_title")

View File

@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.xowa.htmls.core.wkrs.imgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*;
import org.junit.*; import gplx.xowa.htmls.core.makes.tests.*;
public class Xoh_img_html__dump__tst {
private final Xoh_make_fxt fxt = new Xoh_make_fxt();
private final Xoh_make_fxt fxt = new Xoh_make_fxt();
@Before public void init() {fxt.Clear();}
@Test public void Basic() {
fxt.Test__html
@@ -28,4 +28,26 @@ public class Xoh_img_html__dump__tst {
@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'/>");
}
@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>");
}
@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>"
, "<div><a href=\"\" xowa_title=\"a_b.ogv\" class=\"xowa_media_play\" style=\"width:218px;max-width:220px;\" alt=\"Play sound\"></a></div>"
, " </div>"
)
);
}
private static void Make_ns_case_sensitive(Xow_wiki wiki, int ns_id) {
gplx.xowa.wikis.nss.Xow_ns_mgr ns_mgr = wiki.Ns_mgr();
gplx.xowa.wikis.nss.Xow_ns ns = ns_mgr.Ids_get_or_null(ns_id);
ns.Case_match_(gplx.xowa.wikis.nss.Xow_ns_case_.Tid__all);
ns_mgr.Init();
}
}

View File

@@ -115,21 +115,21 @@ public class Xoh_img_hzip implements Xoh_hzip_wkr, Gfo_poolable_itm {
public void Decode1(Bry_bfr bfr, Xoh_hdoc_wkr hdoc_wkr, Xoh_hdoc_ctx hctx, Xoh_page hpg, Bry_rdr rdr, byte[] src, int src_bgn, int src_end, Xoh_data_itm data_itm) {
Xoh_img_data data = (Xoh_img_data)data_itm; data.Clear();
int flag = rdr.Read_hzip_int(2); flag_bldr.Decode(flag);
boolean img_imap_exists = flag_bldr.Get_as_bool(Flag__img__imap_exists);
boolean img_wo_anch = flag_bldr.Get_as_bool(Flag__img__wo_anch);
boolean file__is_orig = flag_bldr.Get_as_bool(Flag__file__is_orig);
boolean file__repo_is_local = flag_bldr.Get_as_bool(Flag__file__repo_is_local);
boolean file__src_exists = flag_bldr.Get_as_bool(Flag__file__src_exists);
boolean img__cls_other_exists = flag_bldr.Get_as_bool(Flag__img__cls_other_exists);
boolean anch__ns_is_custom = flag_bldr.Get_as_bool(Flag__anch__ns_is_custom);
boolean anch__ns_id_needs_saving = flag_bldr.Get_as_bool(Flag__anch__ns_id_needs_saving);
int anch__cls_tid = flag_bldr.Get_as_int(Flag__anch__cls_tid);
boolean img__alt_diff_from_anch_title = flag_bldr.Get_as_bool(Flag__img__alt_diff_from_anch_title);
boolean anch_href_diff_file = flag_bldr.Get_as_bool(Flag__anch__href_diff_file);
boolean anch__title_missing = flag_bldr.Get_as_bool(Flag__anch__title_missing);
boolean img_is_vid = flag_bldr.Get_as_bool(Flag__img__is_vid);
int img_cls = flag_bldr.Get_as_int(Flag__img__cls_tid);
int anch__href_tid = flag_bldr.Get_as_int(Flag__anch__href_tid);
boolean img_imap_exists = flag_bldr.Get_as_bool(Flag__img__imap_exists);
boolean img_wo_anch = flag_bldr.Get_as_bool(Flag__img__wo_anch);
boolean file__is_orig = flag_bldr.Get_as_bool(Flag__file__is_orig);
boolean file__repo_is_local = flag_bldr.Get_as_bool(Flag__file__repo_is_local);
boolean file__src_exists = flag_bldr.Get_as_bool(Flag__file__src_exists);
boolean img__cls_other_exists = flag_bldr.Get_as_bool(Flag__img__cls_other_exists);
boolean anch__ns_is_custom = flag_bldr.Get_as_bool(Flag__anch__ns_is_custom);
boolean anch__ns_id_needs_saving = flag_bldr.Get_as_bool(Flag__anch__ns_id_needs_saving);
int anch__cls_tid = flag_bldr.Get_as_int(Flag__anch__cls_tid);
boolean img__alt_diff_from_anch_title = flag_bldr.Get_as_bool(Flag__img__alt_diff_from_anch_title);
boolean anch_href_diff_file = flag_bldr.Get_as_bool(Flag__anch__href_diff_file);
boolean anch__title_missing = flag_bldr.Get_as_bool(Flag__anch__title_missing);
boolean img_is_vid = flag_bldr.Get_as_bool(Flag__img__is_vid);
int img_cls = flag_bldr.Get_as_int(Flag__img__cls_tid);
int anch__href_tid = flag_bldr.Get_as_int(Flag__anch__href_tid);
byte[] page_db = rdr.Read_bry_to();
byte[] site_bry = null;
switch (anch__href_tid) {
@@ -149,7 +149,7 @@ public class Xoh_img_hzip implements Xoh_hzip_wkr, Gfo_poolable_itm {
if (anch__ns_id_needs_saving)
anch_href_ns = Xoh_lnki_dict_.Ns_decode(rdr);
byte[] ns_custom_bry = null;
if (anch__ns_is_custom) ns_custom_bry = rdr.Read_bry_to();
if (anch__ns_is_custom) ns_custom_bry = Xoa_ttl.Replace_spaces(rdr.Read_bry_to()); // NOTE: use unders not spaces; will be used directly below to generate href; else href="User talk:A"; PAGE:de.b:Wikibooks:Benutzersperrung/_InselFahrer DATE:2016-06-25
int img_w = -1, img_h = -1, file_time = -1, file_page = -1;
if (file__src_exists) {
img_w = rdr.Read_hzip_int(2) - Gfo_hzip_int_.Neg_1_adj;

View File

@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.htmls.core.wkrs.imgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*;
import org.junit.*; import gplx.xowa.htmls.core.hzips.*; import gplx.xowa.wikis.nss.*;
public class Xoh_img_hzip__dump__tst {
public class Xoh_img_hzip__dump__basic__tst {
private final Xoh_hzip_fxt fxt = new Xoh_hzip_fxt().Init_mode_diff_y_();
@Before public void Clear() {fxt.Clear();}
@Test public void Basic() { // [[File:A.png|border|class=other|220px|abc]]
@@ -83,80 +83,6 @@ public class Xoh_img_hzip__dump__tst {
);
ns_mgr.Ns_file().Name_bry_(Bry_.new_u8("File")); ns_mgr.Init_w_defaults();
}
@Test public void Link__cs() { // [[File:A.png|link=File:a.ogg|abc]]
fxt.Test__bicode
( "~%!Aa.ogg~A.png~)#Sabc~"
, "<a href='/wiki/File:a.ogg' class='image' title='abc' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|220|-1|-1|-1|-1' src='' width='0' height='0' alt='abc'></a>"
);
}
@Test public void Link__anchor() { // [[File:A.png|link=A#B_C|abc]]; PAGE:en.w:Arabic; DATE:2016-01-06
fxt.Test__bicode
( "~%#'A#B_C~D.png~#9!I!I"
, "<a href='/wiki/A#B_C' class='image' xowa_title='D.png'><img data-xowa-title='D.png' data-xoimg='0|40|40|-1|-1|-1' src='' width='0' height='0' alt=''></a>"
);
}
@Test public void Link__wm__n() { // [[File:A.png|link=http://a.org|abc]]
fxt.Test__bicode
( "~%!Dhttp://a.org~A.png~)#Sabc~"
, "<a href='http://a.org' rel='nofollow' class='image' title='abc' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|220|-1|-1|-1|-1' src='' width='0' height='0' alt='abc'></a>"
);
}
@Test public void Link__wm__y() { // [[File:A.png|link=http://en.wikitionary.org/wiki/Special:Search/A|abc]]
fxt.Test__bicode
( "~%\"men.wiktionary.org|Search/A~A.png~\")#Sabc~"
, "<a href='/site/en.wiktionary.org/wiki/Special:Search/A' class='image' title='abc' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|220|-1|-1|-1|-1' src='' width='0' height='0' alt='abc'></a>"
);
}
@Test public void Link__wm__n_2() { // [[File:A.png|link=creativecommons:by/2.5]]
fxt.Test__bicode
( "~%#(creativecommons.org|by/2.5/~CC-BY-icon-80x15.png~#)!q"
, "<a href='/site/creativecommons.org/wiki/by/2.5/' class='image' xowa_title='CC-BY-icon-80x15.png'><img data-xowa-title='CC-BY-icon-80x15.png' data-xoimg='0|80|-1|-1|-1|-1' src='' width='0' height='0' alt=''></a>"
);
}
@Test public void Link__media() { // [[File:A.png|link=file:///C:/A.ogg]]
fxt.Test__bicode
( "~%!D~A.ogg~)!,B~"
, "<a href='' class='image' title='B' xowa_title='A.ogg'><img data-xowa-title='A.ogg' data-xoimg='0|11|-1|-1|-1|-1' src='' width='0' height='0' alt='B'></a>"
);
}
@Test public void Link__encoding() { // [[File:A.svg|24px|text-top|link=wikt:𬖾|𬖾]]; PAGE:en.w:Pho; DATE:2016-01-04
fxt.Test__bicode
( "~%#Xen.wiktionary.org|%F0%AC%96%BE~A.png~#)!,abc~B~"
, "<a href='/site/en.wiktionary.org/wiki/%F0%AC%96%BE' class='image' title='abc' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|11|-1|-1|-1|-1' src='' width='0' height='0' alt='B'></a>"
);
}
@Test public void Link__invalid() { // handle invalid titles in link arg; EX:[[File:A.png|link=wikt:]]; PAGE:en.w:List_of_Saint_Petersburg_Metro_stations; DATE:2016-01-04
fxt.Test__bicode
( "~%\"mcommons.wikimedia.org|~A.png~1!Abc~"
, "<a href='/site/commons.wikimedia.org/wiki/Category:' class='image' title='Abc' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|-1|-1|-1|-1|-1' src='' width='0' height='0' alt='Abc'></a>"
);
}
@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'>"
);
}
@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>"
);
}
@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
fxt.Init__ns_alias__add("WP", Xow_ns_.Tid__project);
fxt.Test__bicode
( "~%/+MCB~A.png~'WP~)!q"
, "<a href='/wiki/WP:MCB' class='image' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|80|-1|-1|-1|-1' src='' width='0' height='0' alt=''></a>"
);
fxt.Init__ns_alias__del("WP");
}
@Test public void Link__xwiki_lc() { // [[File:A.png|link=wikt:Category:en:A]]; PAGE:en.w:Portal:Trucks/Wikimedia; DATE:2016-01-11
fxt.Test__bicode
( "~%#(en.wiktionary.org|en:A~A.png~1)!q"
, "<a href='/site/en.wiktionary.org/wiki/Category:en:A' class='image' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|80|-1|-1|-1|-1' src='' width='0' height='0' alt=''></a>"
);
}
@Test public void Missing() { // PURPOSE: bad dump shouldn't write corrupt data
fxt.Test__bicode
( "%|\"\\QA.png!!!!A"

View File

@@ -0,0 +1,105 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.htmls.core.wkrs.imgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*;
import org.junit.*; import gplx.xowa.htmls.core.hzips.*; import gplx.xowa.wikis.nss.*;
public class Xoh_img_hzip__dump__link__tst {
private final Xoh_hzip_fxt fxt = new Xoh_hzip_fxt().Init_mode_diff_y_();
@Before public void Clear() {fxt.Clear();}
@Test public void Link__cs() { // [[File:A.png|link=File:a.ogg|abc]]
fxt.Test__bicode
( "~%!Aa.ogg~A.png~)#Sabc~"
, "<a href='/wiki/File:a.ogg' class='image' title='abc' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|220|-1|-1|-1|-1' src='' width='0' height='0' alt='abc'></a>"
);
}
@Test public void Link__anchor() { // [[File:A.png|link=A#B_C|abc]]; PAGE:en.w:Arabic; DATE:2016-01-06
fxt.Test__bicode
( "~%#'A#B_C~D.png~#9!I!I"
, "<a href='/wiki/A#B_C' class='image' xowa_title='D.png'><img data-xowa-title='D.png' data-xoimg='0|40|40|-1|-1|-1' src='' width='0' height='0' alt=''></a>"
);
}
@Test public void Link__wm__n() { // [[File:A.png|link=http://a.org|abc]]
fxt.Test__bicode
( "~%!Dhttp://a.org~A.png~)#Sabc~"
, "<a href='http://a.org' rel='nofollow' class='image' title='abc' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|220|-1|-1|-1|-1' src='' width='0' height='0' alt='abc'></a>"
);
}
@Test public void Link__wm__y() { // [[File:A.png|link=http://en.wikitionary.org/wiki/Special:Search/A|abc]]
fxt.Test__bicode
( "~%\"men.wiktionary.org|Search/A~A.png~\")#Sabc~"
, "<a href='/site/en.wiktionary.org/wiki/Special:Search/A' class='image' title='abc' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|220|-1|-1|-1|-1' src='' width='0' height='0' alt='abc'></a>"
);
}
@Test public void Link__wm__n_2() { // [[File:A.png|link=creativecommons:by/2.5]]
fxt.Test__bicode
( "~%#(creativecommons.org|by/2.5/~CC-BY-icon-80x15.png~#)!q"
, "<a href='/site/creativecommons.org/wiki/by/2.5/' class='image' xowa_title='CC-BY-icon-80x15.png'><img data-xowa-title='CC-BY-icon-80x15.png' data-xoimg='0|80|-1|-1|-1|-1' src='' width='0' height='0' alt=''></a>"
);
}
@Test public void Link__media() { // [[File:A.png|link=file:///C:/A.ogg]]
fxt.Test__bicode
( "~%!D~A.ogg~)!,B~"
, "<a href='' class='image' title='B' xowa_title='A.ogg'><img data-xowa-title='A.ogg' data-xoimg='0|11|-1|-1|-1|-1' src='' width='0' height='0' alt='B'></a>"
);
}
@Test public void Link__encoding() { // [[File:A.svg|24px|text-top|link=wikt:𬖾|𬖾]]; PAGE:en.w:Pho; DATE:2016-01-04
fxt.Test__bicode
( "~%#Xen.wiktionary.org|%F0%AC%96%BE~A.png~#)!,abc~B~"
, "<a href='/site/en.wiktionary.org/wiki/%F0%AC%96%BE' class='image' title='abc' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|11|-1|-1|-1|-1' src='' width='0' height='0' alt='B'></a>"
);
}
@Test public void Link__invalid() { // handle invalid titles in link arg; EX:[[File:A.png|link=wikt:]]; PAGE:en.w:List_of_Saint_Petersburg_Metro_stations; DATE:2016-01-04
fxt.Test__bicode
( "~%\"mcommons.wikimedia.org|~A.png~1!Abc~"
, "<a href='/site/commons.wikimedia.org/wiki/Category:' class='image' title='Abc' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|-1|-1|-1|-1|-1' src='' width='0' height='0' alt='Abc'></a>"
);
}
@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'>"
);
}
@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>"
);
}
@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
fxt.Init__ns_alias__add("WP", Xow_ns_.Tid__project);
fxt.Test__bicode
( "~%/+MCB~A.png~'WP~)!q"
, "<a href='/wiki/WP:MCB' class='image' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|80|-1|-1|-1|-1' src='' width='0' height='0' alt=''></a>"
);
fxt.Init__ns_alias__del("WP");
}
@Test public void Link__xwiki_lc() { // [[File:A.png|link=wikt:Category:en:A]]; PAGE:en.w:Portal:Trucks/Wikimedia; DATE:2016-01-11
fxt.Test__bicode
( "~%#(en.wiktionary.org|en:A~A.png~1)!q"
, "<a href='/site/en.wiktionary.org/wiki/Category:en:A' class='image' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|80|-1|-1|-1|-1' src='' width='0' height='0' alt=''></a>"
);
}
@Test public void Link__xwiki_under() {// EX: [[File:A.png|link=User talk:B]]; PAGE:de.b:Wikibooks:Benutzersperrung/_InselFahrer DATE:2016-06-24
fxt.Test__bicode
( "~%/,meta.wikimedia.org|B~A.png~&User Talk~!", String_.Concat
( "<a href='/site/meta.wikimedia.org/wiki/User_Talk:B' 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=''>"
, "</a>"
));
}
}

View File

@@ -64,7 +64,7 @@ public class Xoh_img_wtr implements Bfr_arg, Xoh_wtr_itm {
this.Clear();
this.img_is_vid = data.Img_is_vid();
this.img_wo_anch = data.Img_wo_anch();
this.fsdb_itm = hpg.Img_mgr().Make_img();
this.fsdb_itm = hpg.Img_mgr().Make_img(data.Img_is_gallery());
byte[] file_ttl_bry = data.Img_src().File_ttl_bry();
byte[] lnki_ttl = Xoa_ttl.Replace_spaces(Gfo_url_encoder_.Href_quotes.Decode(file_ttl_bry)); // NOTE: must decode for fsdb.lnki_ttl as well as xowa_title; EX: A%C3%A9b -> A<>b
if (data.Img_xoimg().Val_dat_exists()) {

View File

@@ -23,11 +23,11 @@ public class Xoh_lnke_wtr implements gplx.core.brys.Bfr_arg, Xoh_wtr_itm {
private final Bfr_arg__bry anch_href = Bfr_arg__bry.New_empty(), anch_cls = Bfr_arg__bry.New_empty(), anch_content = Bfr_arg__bry.New_empty();
private final Bfr_arg__hatr_bry anch_title = new Bfr_arg__hatr_bry(Gfh_atr_.Bry__title);
public boolean Init_by_decode(Xoh_page hpg, Xoh_hdoc_ctx hctx, byte[] src, Xoh_data_itm data_itm) {
Bfr_arg_.Clear(anch_href, anch_cls,anch_content);
Bfr_arg_.Clear(anch_href, anch_cls, anch_content, anch_title);
Xoh_lnke_data data = (Xoh_lnke_data)data_itm;
anch_href.Set_by_mid(src, data.Href_bgn(), data.Href_end());
anch_cls.Set_by_val(Xoh_lnke_dict_.To_html_class(data.Lnke_tid()));
if (data.Title_exists()) anch_title.Set_by_mid(src, data.Title_bgn(), data.Title_end());
if (data.Title_exists()) anch_title.Set_by_mid(src, data.Title_bgn(), data.Title_end());
if (data.Auto_exists()) anch_content.Set_by_arg(Xoh_lnke_wtr_arg__autonum.Instance.Set_by_auto_id(data.Auto_id()));
else if (data.Capt_exists()) anch_content.Set_by_mid(src, data.Capt_bgn(), data.Capt_end());
else anch_content.Set_by_mid(src, data.Href_bgn(), data.Href_end());

View File

@@ -88,9 +88,10 @@ public class Xoh_lnki_data {
}
private void Parse_capt(Gfh_tag_rdr tag_rdr, Gfh_tag anch_head) {
this.capt_bgn = anch_head.Src_end(); // capt starts after <a>
Gfh_tag anch_tail = tag_rdr.Tag__move_fwd_tail(Gfh_tag_.Id__a); // </a>
Gfh_tag anch_tail = tag_rdr.Tag__move_fwd_tail(Gfh_tag_.Id__a); // </a>
this.capt_end = anch_tail.Src_bgn(); // get capt between "<a>" and "</a>
this.src_end = anch_tail.Src_end();
// skip ns in href / capt
if (href_ns_id != Xow_ns_.Tid__main) { // not main; try to remove template name;
int capt_bgn_wo_ns = capt_bgn + href_ns_name_len;
@@ -100,6 +101,7 @@ public class Xoh_lnki_data {
capt_has_ns = true;
}
}
// get text splits
this.text_tid = href_itm.Tid() == Xoh_anch_href_data.Tid__anch
? Xoh_anch_capt_itm.Tid__diff

View File

@@ -106,7 +106,9 @@ public class Xoh_lnki_hzip implements Xoh_hzip_wkr, Gfo_poolable_itm {
href_bry = Bry_.Empty;
}
else {
Xow_ns ns = hctx.Wiki__ttl_parser().Ns_mgr().Ids_get_or_null(ns_id); if (ns == null) rdr.Err_wkr().Fail("invalid ns_id", "ns_id", ns_id);
Xow_ns ns = hctx.Wiki__ttl_parser().Ns_mgr().Ids_get_or_null(ns_id);
if (ns == null)
rdr.Err_wkr().Fail("invalid ns_id", "ns_id", ns_id, "href_bry", href_bry); // add more args to troubleshoot random failure; DATE:2016-06-23
ns_bry = ns.Name_ui();
tmp_bfr.Add(ns.Name_db()).Add_byte_colon();
}
@@ -124,12 +126,14 @@ public class Xoh_lnki_hzip implements Xoh_hzip_wkr, Gfo_poolable_itm {
href_bry = tmp_bfr.To_bry_and_clear();
// generate stub for redlink
try {
Xoa_ttl ttl = hpg.Wiki().Ttl_parse(Gfo_url_encoder_.Href.Decode(href_bry));
Xopg_lnki_itm__hdump lnki_itm = new Xopg_lnki_itm__hdump(ttl);
hpg.Redlink_list().Add(lnki_itm);
html_uid = lnki_itm.Html_uid();
} catch (Exception e) {Gfo_log_.Instance.Warn("failed to add lnki to redlinks", "page", hpg.Url_bry_safe(), "href_bry", href_bry, "e", Err_.Message_gplx_log(e));}
if ( !hctx.Mode_is_diff()) { // PERF: don't do redlinks during hzip_diff
try {
Xoa_ttl ttl = hpg.Wiki().Ttl_parse(Gfo_url_encoder_.Href.Decode(href_bry));
Xopg_lnki_itm__hdump lnki_itm = new Xopg_lnki_itm__hdump(ttl);
hpg.Redlink_list().Add(lnki_itm);
html_uid = lnki_itm.Html_uid();
} catch (Exception e) {Gfo_log_.Instance.Warn("failed to add lnki to redlinks", "page", hpg.Url_bry_safe(), "href_bry", href_bry, "e", Err_.Message_gplx_log(e));}
}
break;
}
byte[] capt_bry = Xoh_lnki_hzip_.Bld_capt(tmp_bfr, href_type, text_type, capt_has_ns, capt_cs0_tid, ns_bry, src, text_0_bgn, text_0_end, src, text_1_bgn, text_1_end);

View File

@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.xowa.htmls.core.wkrs.lnkis; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*;
import org.junit.*;
public class Xoh_lnki_hzip__diff__tst {
private final Xoh_hzip_fxt fxt = new Xoh_hzip_fxt().Init_mode_diff_y_();
private final Xoh_hzip_fxt fxt = new Xoh_hzip_fxt().Init_mode_diff_y_();
@Test public void Diff__basic() { // EX: [[A|b]]
fxt.Test__bicode("~$\"A~b~" , "<a href='/wiki/A' title='A'>b</a>");
}

View File

@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.xowa.htmls.core.wkrs.lnkis; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*;
import org.junit.*;
public class Xoh_lnki_hzip__ns__tst {
private final Xoh_hzip_fxt fxt = new Xoh_hzip_fxt().Init_mode_diff_y_();
private final Xoh_hzip_fxt fxt = new Xoh_hzip_fxt().Init_mode_diff_y_();
@Test public void Ns__same() { // EX: [[Help:A]]
fxt.Test__bicode("~${#7/A~", "<a href='/wiki/Help:A' title='Help:A'>Help:A</a>");
}

View File

@@ -20,7 +20,7 @@ import gplx.core.brys.*; import gplx.core.btries.*;
import gplx.langs.htmls.*; import gplx.langs.htmls.docs.*; import gplx.langs.htmls.encoders.*;
import gplx.xowa.wikis.ttls.*; import gplx.xowa.wikis.nss.*;
public class Xoh_anch_href_data implements Xoh_itm_parser {
private final Bry_rdr rdr = new Bry_rdr().Dflt_dlm_(Byte_ascii.Slash);
private final Bry_rdr rdr = new Bry_rdr().Dflt_dlm_(Byte_ascii.Slash);
public void Fail_throws_err_(boolean v) {rdr.Fail_throws_err_(v);}// TEST
public Gfh_atr Atr() {return atr;} private Gfh_atr atr;
public byte Tid() {return tid;} private byte tid;
@@ -115,8 +115,8 @@ public class Xoh_anch_href_data implements Xoh_itm_parser {
if (ns.Id() != Xow_ns_.Tid__main) {
ttl_ns_id = ns.Id();
ttl_page_db = Bry_.Mid(ttl_full_txt, colon_pos + 1, ttl_full_len);
if (!Bry_.Match(ttl_full_txt, 0, colon_pos, ns.Name_ui()))
ttl_ns_custom = Bry_.Mid(ttl_full_txt, 0, colon_pos);
if (!Bry_.Match(ttl_full_txt, 0, colon_pos, ns.Name_ui())) // ns does not match expd name
ttl_ns_custom = Bry_.Mid(ttl_full_txt, 0, colon_pos); // mark as custom; NOTE: not using ttl_full_txt, b/c need to preserve underscores, else href="User_talk" -> "User talk"; PAGE:de.b:Wikibooks:Benutzersperrung/_InselFahrer DATE:2016-06-24
}
}
}
@@ -135,8 +135,8 @@ public class Xoh_anch_href_data implements Xoh_itm_parser {
, Tid__anch = 2 // EX: href="#A"
, Tid__inet = 3 // EX: href="https://a.org/A"
;
private static final byte[] Bry__site = Bry_.new_a7("site/"), Bry__wiki = Bry_.new_a7("wiki/");
private static final Btrie_slim_mgr trie = Btrie_slim_mgr.ci_a7()
private static final byte[] Bry__site = Bry_.new_a7("site/"), Bry__wiki = Bry_.new_a7("wiki/");
private static final Btrie_slim_mgr trie = Btrie_slim_mgr.ci_a7()
.Add_bry_byte(Bry__wiki, Tid__wiki)
.Add_bry_byte(Bry__site, Tid__site)
;

View File

@@ -58,9 +58,11 @@ public class Xoh_file_html_fmtr__base implements Xoh_file_img_wkr {
( "<img id=\"xoimg_~{uid}\" alt=\"~{img_alt}\"~{img_core}~{img_class} />"
, "uid", "img_core", "img_alt", "img_class"
);
public byte[] Html_thumb_part_img(Bry_bfr tmp_bfr, Xoh_wtr_ctx hctx, Xoae_page page, byte[] src, Xof_file_itm xfer_itm, int uid, byte[] a_href, byte[] img_src, byte[] img_alt) {
public byte[] Html_thumb_part_img(Bry_bfr tmp_bfr, Xoh_wtr_ctx hctx, Xoae_page page, byte[] src, Xof_file_itm xfer_itm, int uid, byte[] lnki_ttl, byte[] a_href, byte[] img_src, byte[] img_alt) {
byte[] a_title_atr = Gfh_atr_.Make(tmp_bfr, Gfh_atr_.Bry__title, xfer_itm.Lnki_ttl());
Html_full_img(tmp_bfr, hctx, page, src, xfer_itm, uid, a_href, Bool_.N, Xoh_lnki_consts.Tid_a_cls_image, Xoh_lnki_consts.Tid_a_rel_none, a_title_atr, Xoh_file_html_fmtr__base.Escape_xowa_title(xfer_itm.Lnki_ttl())
Html_full_img(tmp_bfr, hctx, page, src, xfer_itm, uid, a_href, Bool_.N, Xoh_lnki_consts.Tid_a_cls_image
, Xoh_lnki_consts.Tid_a_rel_none, a_title_atr
, Xoh_file_html_fmtr__base.Escape_xowa_title(lnki_ttl) // NOTE: must use lnki_ttl, not xfer_itm.Lnki_ttl(); 1st observes case-sensitivity; EX:"a.ogv"; PAGE:de.d:fappieren DATE:2016-06-23
, xfer_itm.Html_w(), xfer_itm.Html_h(), img_src, img_alt, Xoh_img_cls_.Tid__none, null);
return tmp_bfr.To_bry_and_clear();
}

View File

@@ -79,7 +79,7 @@ public class Xoh_file_wtr__basic {
)
) {
xfer_itm.Html_elem_tid_(Xof_html_elem.Tid_vid);
this.Write_file_video(bfr, ctx, hctx, src, lnki, uid, div_width, lnki_halign_bry, lnki_href, img_view_src, img_orig_src, img_alt, xfer_itm);
this.Write_file_video(bfr, ctx, hctx, src, lnki, uid, div_width, lnki_halign_bry, lnki_ttl, lnki_href, img_view_src, img_orig_src, img_alt, xfer_itm);
}
else if (orig_ext.Id_is_audio()) // audio
this.Write_file_audio(bfr, ctx, hctx, src, lnki, uid, div_width, lnki_halign_bry, lnki_href, img_orig_src, img_alt);
@@ -100,10 +100,10 @@ public class Xoh_file_wtr__basic {
else
bfr.Add(content);
}
private void Write_file_video(Bry_bfr bfr, Xop_ctx ctx, Xoh_wtr_ctx hctx, byte[] src, Xop_lnki_tkn lnki, int uid, int div_width, byte[] lnki_halign_bry, byte[] lnki_href, byte[] img_view_src, byte[] img_orig_src, byte[] alt, Xof_file_itm xfer_itm) {
private void Write_file_video(Bry_bfr bfr, Xop_ctx ctx, Xoh_wtr_ctx hctx, byte[] src, Xop_lnki_tkn lnki, int uid, int div_width, byte[] lnki_halign_bry, byte[] lnki_ttl, byte[] lnki_href, byte[] img_view_src, byte[] img_orig_src, byte[] alt, Xof_file_itm xfer_itm) {
xfer_itm.Html_elem_tid_(Xof_html_elem.Tid_vid);
boolean video_is_thumb = Xop_lnki_type.Id_defaults_to_thumb(lnki.Lnki_type());
byte[] content = Arg_content_video(ctx, hctx, src, lnki, xfer_itm, uid, video_is_thumb, lnki_href, img_view_src, img_orig_src, alt);
byte[] content = Arg_content_video(ctx, hctx, src, lnki, xfer_itm, uid, video_is_thumb, lnki_ttl, lnki_href, img_view_src, img_orig_src, alt);
if (video_is_thumb)
html_fmtr.Html_thumb_core(bfr, hctx.Mode_is_hdump(), uid, lnki_halign_bry, div_width, content);
else
@@ -178,7 +178,7 @@ public class Xoh_file_wtr__basic {
html_fmtr.Html_thumb_file_audio(scratch_bfr, Arg_caption_div(ctx, hctx, src, lnki, uid, img_orig_src, lnki_href), Arg_alt_html(ctx, hctx, src, lnki), Arg_play_btn(hctx.Mode_is_hdump(), uid, play_btn_width, Play_btn_max_width, img_orig_src, Xoh_file_html_fmtr__base.Escape_xowa_title(lnki.Ttl().Page_txt())), info_btn);
return scratch_bfr.To_bry_and_clear();
}
private byte[] Arg_content_video(Xop_ctx ctx, Xoh_wtr_ctx hctx, byte[] src, Xop_lnki_tkn lnki, Xof_file_itm xfer_itm, int uid, boolean lnki_thumb, byte[] a_href, byte[] view_src, byte[] orig_src, byte[] img_alt) {
private byte[] Arg_content_video(Xop_ctx ctx, Xoh_wtr_ctx hctx, byte[] src, Xop_lnki_tkn lnki, Xof_file_itm xfer_itm, int uid, boolean lnki_thumb, byte[] lnki_ttl, byte[] a_href, byte[] view_src, byte[] orig_src, byte[] img_alt) {
int thumb_w = xfer_itm.Html_w();
int play_btn_width = thumb_w; if (play_btn_width < 1) play_btn_width = wiki.Html_mgr().Img_thumb_width();
byte[] caption_html = Bry_.Empty, alt_html = Bry_.Empty;
@@ -186,8 +186,9 @@ public class Xoh_file_wtr__basic {
caption_html = Arg_caption_div(ctx, hctx, src, lnki, uid, orig_src, a_href);
alt_html = Arg_alt_html(ctx, hctx, src, lnki);
}
html_fmtr.Html_thumb_file_video(scratch_bfr, Arg_play_btn(hctx.Mode_is_hdump(), uid, play_btn_width, play_btn_width, orig_src, Xoh_file_html_fmtr__base.Escape_xowa_title(lnki.Ttl().Page_txt()))
, html_fmtr.Html_thumb_part_img(scratch_bfr, hctx, page, src, xfer_itm, uid, a_href, view_src, img_alt)
html_fmtr.Html_thumb_file_video(scratch_bfr
, Arg_play_btn(hctx.Mode_is_hdump(), uid, play_btn_width, play_btn_width, orig_src, Xoh_file_html_fmtr__base.Escape_xowa_title(lnki.Ttl().Page_txt()))
, html_fmtr.Html_thumb_part_img(scratch_bfr, hctx, page, src, xfer_itm, uid, lnki_ttl, a_href, view_src, img_alt)
, caption_html, alt_html);
return scratch_bfr.To_bry_and_clear();
}

View File

@@ -80,13 +80,10 @@ public class Xoh_tag_parser implements Gfh_doc_wkr {
break;
case Gfh_tag_.Id__ul:
if (cur.Atrs__cls_has(Xoh_gly_grp_data.Atr__cls__gallery)) {
// rv = Parse_by_data(hdoc_wkr, hctx, tag_rdr, src, cur, null, Xoh_hzip_dict_.Tid__gly);
// rv = Parse_by_data(hdoc_wkr, hctx, tag_rdr, src, cur, null, Xoh_hzip_dict_.Tid__gly); // COMMENTED: wrote gallery hzip code, but doesn't seem worth enabling for low number of galleries
if (wkr__gly.Parse1(hdoc_wkr, hctx, src, tag_rdr, cur)) return wkr__gly.Src_end();
}
break;
// case Gfh_tag_.Id__td:
// if (wkr__xnde.Parse(hdoc_wkr, hctx, tag_rdr, src, cur)) return wkr__xnde.Src_end();
// break;
}
if (rv == -1) {
rv = cur_end;

View File

@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.xowa.htmls.heads; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*;
import gplx.xowa.langs.*; import gplx.xowa.langs.msgs.*; import gplx.xowa.langs.numbers.*;
public class Xoh_head_itm__globals extends Xoh_head_itm__base {
private final Xoh_head_wtr tmp_wtr = new Xoh_head_wtr();
private final Xoh_head_wtr tmp_wtr = new Xoh_head_wtr();
@Override public byte[] Key() {return Xoh_head_itm_.Key__globals;}
@Override public int Flags() {return Flag__css_include | Flag__js_include | Flag__js_head_script | Flag__js_tail_script | Flag__js_head_global;}
@Override public void Write_css_include(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_head_wtr wtr) {
@@ -45,7 +45,7 @@ public class Xoh_head_itm__globals extends Xoh_head_itm__base {
wtr.Write_js_alias_var (Page__alias, Page__key);
wtr.Write_js_alias_kv (Page__alias, Key__wiki , page.Wiki().Domain_bry());
wtr.Write_js_alias_kv (Page__alias, Key__ttl , page.Ttl().Page_db());
} private static final byte[] Key__app_mode = Bry_.new_a7("xowa.app.mode"), Page__alias = Bry_.new_a7("x_p"), Page__key = Bry_.new_a7("xowa.page"), Key__wiki = Bry_.new_a7("wiki"), Key__ttl = Bry_.new_a7("ttl");
} private static final byte[] Key__app_mode = Bry_.new_a7("xowa.app.mode"), Page__alias = Bry_.new_a7("x_p"), Page__key = Bry_.new_a7("xowa.page"), Key__wiki = Bry_.new_a7("wiki"), Key__ttl = Bry_.new_a7("ttl");
@Override public void Write_js_head_global(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_head_wtr wtr) {
wtr.Write_js_global_ini_atr_val(Key_mode_is_gui , app.Mode().Tid_is_gui());
wtr.Write_js_global_ini_atr_val(Key_mode_is_http , app.Mode().Tid_is_http());
@@ -66,7 +66,7 @@ public class Xoh_head_itm__globals extends Xoh_head_itm__base {
wtr.Write_js_global_ini_atr_obj(Key_wgMonthNames , months_long);
wtr.Write_js_global_ini_atr_obj(Key_wgMonthNamesShort , months_short);
}
public static final byte[] // NOTE: most of these are for the table-sorter
public static final byte[] // NOTE: most of these are for the table-sorter
Key_mode_is_gui = Bry_.new_a7("mode_is_gui")
, Key_mode_is_http = Bry_.new_a7("mode_is_http")
, Key_http_port = Bry_.new_a7("http-port")
@@ -96,7 +96,7 @@ public class Xoh_head_itm__globals extends Xoh_head_itm__base {
tmp_wtr.Write_js_ary_end();
return tmp_wtr.Bfr().To_bry_and_clear();
}
private static final byte[]
private static final byte[]
Date_format_default = Bry_.new_a7("dmy")
, Num_format_digits = Bry_.new_a7("['', '']")
, Var_xowa_root_dir = Bry_.new_a7("xowa_root_dir")

View File

@@ -18,8 +18,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.xowa.htmls.heads; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*;
public class Xoh_head_itm__timeline extends Xoh_head_itm__base {
@Override public byte[] Key() {return Xoh_head_itm_.Key__timeline;}
@Override public int Flags() {return Flag__css_include;}
@Override public void Write_css_include(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_head_wtr wtr) {
@Override public int Flags() {return Flag__js_include;}
@Override public void Write_js_include(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_head_wtr wtr) {
if (Url_js == null) Url_js = app.Fsys_mgr().Bin_any_dir().GenSubFil_nest("xowa", "html", "res", "src", "xowa", "timeline", "timeline.js").To_http_file_bry();
wtr.Write_js_include(Url_js);
}

View File

@@ -68,7 +68,10 @@ public class Xoh_head_mgr implements gplx.core.brys.Bfr_arg {
itm__globals.Enabled_y_(); // for now, always mark this and rest as exists; DATE:2014-06-09
itm__collapsible.Enabled_y_();
itm__navframe.Enabled_y_();
itm__popups.Enabled_(app.Api_root().Html().Modules().Popups().Enabled());
boolean popups_enabled
= !app.Mode().Tid_is_http() // do not enable if http_server, else js errors when calling xowa_exec; DATE:2016-06-22
&& app.Api_root().Html().Modules().Popups().Enabled(); // check user_cfg
itm__popups.Enabled_(popups_enabled);
return this;
}
public void Clear() {

View File

@@ -206,7 +206,8 @@ public class Xoh_head_wtr {
bfr.Add_byte(quote_byte);
for (int i = 0; i < val_len; i++) {
byte b = val[i];
if (b == quote_byte) bfr.Add_byte_backslash(); // escape quote
if (b == quote_byte) bfr.Add_byte_backslash(); // escape quote
else if (b == Byte_ascii.Backslash) bfr.Add_byte_backslash(); // escape backslash
bfr.Add_byte(b);
}
bfr.Add_byte(quote_byte);

View File

@@ -16,11 +16,105 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.htmls.tocs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*;
import gplx.langs.htmls.*; import gplx.langs.htmls.docs.*;
class Xoh_toc_wtr {
private final Gfh_tag_rdr tag_rdr = Gfh_tag_rdr.New__html();
private byte[] page_name = Bry_.Empty;
private final Bry_bfr bfr = Bry_bfr_.New();
public void Clear() {
bfr.Clear();
}
public void Add(byte[] hdr_text) { // text within hdr; EX: <h2>Abc</h2> -> Abc
public void Page_name_(byte[] page_name) {this.page_name = page_name;}
public byte[] Convert(byte[] src) { // text within hdr; EX: <h2>Abc</h2> -> Abc
int end = src.length;
tag_rdr.Init(page_name, src, 0, end);
Convert_recurse(0, src, 0, end);
return bfr.To_bry_and_clear_and_trim();
}
private static void Add_wo_comment(Bry_bfr bfr, byte[] src, int bgn, int end) {
int pos = bgn;
while (true) {
int comm_bgn = Bry_find_.Find_fwd(src, Gfh_tag_.Comm_bgn, pos, end);
if (comm_bgn != -1) {
int tmp_pos = comm_bgn + Gfh_tag_.Comm_bgn_len;
int comm_end = Bry_find_.Find_fwd(src, Gfh_tag_.Comm_end, tmp_pos, end);
if (comm_end != -1) {
bfr.Add_mid(src, pos, comm_bgn);
pos = comm_end + Gfh_tag_.Comm_end_len;
continue;
}
}
bfr.Add_mid(src, pos, end);
break;
}
}
private void Convert_recurse(int depth, byte[] src, int pos, int end) {
tag_rdr.Src_rng_(pos, end);
while (pos < end) {
Gfh_tag lhs = tag_rdr.Tag__move_fwd_head();
int tag_id = lhs.Name_id();
// add any text before lhs;
int txt_end = lhs.Src_bgn();
switch (tag_id) {
case Gfh_tag_.Id__eos: txt_end = end; break; // eos; print everything until end
}
if (pos < txt_end) Add_wo_comment(bfr, src, pos, txt_end);
// set print_tag / recurse based on tag
boolean print_tag = false, recurse = true;
switch (tag_id) {
case Gfh_tag_.Id__eos: // eos; return;
return;
case Gfh_tag_.Id__i: // always print tag
case Gfh_tag_.Id__b:
print_tag = true;
break;
case Gfh_tag_.Id__small: // only print tag if not nested
case Gfh_tag_.Id__sup:
case Gfh_tag_.Id__any:
default: {
if (depth > 0)
print_tag = true;
break;
}
case Gfh_tag_.Id__comment: // never print tag
case Gfh_tag_.Id__img:
case Gfh_tag_.Id__br:
case Gfh_tag_.Id__hr:
print_tag = false;
recurse = false;
break;
case Gfh_tag_.Id__a: // a never prints tag; also, also, do not recurse if ref
print_tag = false;
byte[] href_val = lhs.Atrs__get_as_bry(Gfh_atr_.Bry__href);
if (Bry_.Has_at_bgn(href_val, gplx.xowa.xtns.cites.Ref_html_wtr_cfg.Note_href_bgn)) // do not print if href='#cite_note-...'; EX: <a href=\"#cite_note-0\">[1]</a>
recurse = false;
break;
}
// get lhs / rhs vars
int lhs_bgn = lhs.Src_bgn(), lhs_end = lhs.Src_end();
boolean lhs_is_pair = !lhs.Tag_is_inline();
int rhs_bgn = -1, rhs_end = -1, new_pos = lhs_end;
if (lhs_is_pair) { // get rhs unless inline
Gfh_tag rhs = tag_rdr.Tag__move_fwd_tail(tag_id);
rhs_bgn = rhs.Src_bgn(); rhs_end = rhs.Src_end();
new_pos = rhs_end;
}
// print "<tag></tag>"; also, recurse
if (print_tag) bfr.Add_mid(src, lhs_bgn, lhs_end);
if (recurse) {
Convert_recurse(depth + 1, src, lhs_end, rhs_bgn);
}
if (print_tag && lhs_is_pair)
bfr.Add_mid(src, rhs_bgn, rhs_end);
// set new_pos
pos = new_pos;
tag_rdr.Src_rng_(new_pos, end); // NOTE: must reinit pos and especially end
}
}
}

View File

@@ -16,54 +16,70 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.htmls.tocs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*;
import org.junit.*;
import org.junit.*; import gplx.core.tests.*;
public class Xoh_toc_wtr_tst {
@Before public void init() {fxt.Clear();} private final Xoh_toc_wtr_fxt fxt = new Xoh_toc_wtr_fxt();
@Test public void Basic() {
fxt.Test__convert("a b c", "a b c");
}
@Test public void Ws() {
fxt.Test__add(" a b ", "a b");
fxt.Test__convert(" a b ", "a b");
}
@Test public void Comment() {
fxt.Test__convert("<!--a-->", "");
}
@Test public void Comment__many() {
fxt.Test__convert("1<!--2-->3<!--4-->5", "135");
}
@Test public void Comment__dangling() {
fxt.Test__convert("1<!--2-->3<!--4->5", "13<!--4->5");
}
@Test public void Apos__italic() {
fxt.Test__add("<i>a</i>", "<i>a</i>");
}
@Test public void Xnde__small() {
fxt.Test__add("<small>a</small>", "a");
}
@Test public void Xnde__nest__xnde() { // <sup> removed but not <small>
fxt.Test__add("a <sup>b<small>c</small>d</sup> e", "a b<small>c</small>d e");
}
@Test public void Xnde__nest__lnki() { // <small> and <a> removed
fxt.Test__add("<small><a href=\"/wiki/A\">b</a></small>", "b");
}
@Test public void Xnde__nest__inline() { // PURPOSE: do not render inline xndes; EX: Magnetic_resonance_imaging
fxt.Test__add("a<span id='b'>b<br/></span>", "ab");
fxt.Test__convert("<i>a</i>", "<i>a</i>");
}
@Test public void Lnki__caption() {
fxt.Test__add("<a href=\"/wiki/A\">b</a>", "b");
fxt.Test__convert("<a href=\"/wiki/A\">b</a>", "b");
}
@Test public void Lnki__caption__nest() {
fxt.Test__add("<a href=\"/wiki/A\">b<i>c</i>d</a>", "b<i>c</i>d");
fxt.Test__convert("<a href=\"/wiki/A\">b<i>c</i>d</a>", "b<i>c</i>d");
}
@Test public void Xnde__small() {
fxt.Test__convert("<small>a</small>", "a");
}
@Test public void Xnde__sup() {
fxt.Test__convert("<sup>a</sup>", "a");
}
@Test public void Xnde__nest__xnde() { // <sup> removed but not <small>
fxt.Test__convert("a <sup>b<small>c</small>d</sup> e", "a b<small>c</small>d e");
}
@Test public void Xnde__nest__lnki() { // <small> and <a> removed
fxt.Test__convert("<small><a href=\"/wiki/A\">b</a></small>", "b");
}
@Test public void Amp__ncr() {
fxt.Test__add("&#91;a&#93;", "&#91;a&#93;");
fxt.Test__convert("&#91;a&#93;", "&#91;a&#93;");
}
@Test public void Ref() { // PURPOSE: ref contents should not print in TOC; DATE:2013-07-23
fxt.Test__add("a<sup id=\"cite_ref-0\" class=\"reference\"><a href=\"#cite_note-0\">[1]</a></sup>", "a");
fxt.Test__convert("a<sup id=\"cite_ref-0\" class=\"reference\"><a href=\"#cite_note-0\">[1]</a></sup>", "a");
}
@Test public void Category__literal() { // PURPOSE: literal Category should show in in TOC; EX: de.w:1234; DATE:2014-01-21
fxt.Test__add("A<a href=\"/wiki/Category:B\">Category:B</a>", "ACategory:B");
fxt.Test__convert("A<a href=\"/wiki/Category:B\">Category:B</a>", "ACategory:B");
}
@Test public void File() { // PURPOSE: file should show in in TOC; EX: tr.w:D<>nya_Miraslari; DATE:2014-06-06
fxt.Test__add
fxt.Test__convert
( "<a href=\"/wiki/File:A.png\" class=\"image\" xowa_title=\"A.png\"><img id=\"xoimg_0\" alt=\"\" src=\"file:///mem/wiki/repo/trg/orig/7/0/A.png\" width=\"0\" height=\"0\" /></a> b"
, " b");
, "b");
}
@Test public void Xnde__nest__inline() { // PURPOSE: do not render inline xndes; EX: Magnetic_resonance_imaging
fxt.Test__convert("a<span id='b'>b<br/></span>", "ab");
}
@Test public void Translate_w_comment() { // PURPOSE: <translate> is an xtn and parses its innerText separately; meanwhile, toc_mgr defaults to using the innerText to build toc; EX:Wikidata:Introduction; DATE:2013-07-16
fxt.Test__add("<translate><!--b-->ac</translate>", "ac");
fxt.Test__convert("<translate><!--b-->ac</translate>", "ac");
}
}
class Xoh_toc_wtr_fxt {
private final Xoh_toc_wtr wtr = new Xoh_toc_wtr();
public void Clear() {wtr.Clear();}
public void Test__add(String html, String expd_text) {
public void Test__convert(String html, String expd) {
Gftest.Eq__str(expd, wtr.Convert(Bry_.new_u8(html)));
}
}