1
0
mirror of https://github.com/gnosygnu/xowa.git synced 2025-06-01 06:54:20 +00:00

v1.11.2.1

This commit is contained in:
gnosygnu 2014-11-09 23:35:57 -05:00
parent 8e372c8cd3
commit da8180ea44
69 changed files with 1072 additions and 566 deletions

View File

@ -32,72 +32,79 @@ public class Bry_ {
rv[i] = (byte)ary[i];
return rv;
}
public static byte[] new_ascii_(String s) {
public static byte[] new_ascii_(String str) {
try {
if (s == null) return null;
int s_len = s.length();
if (s_len == 0) return Bry_.Empty;
byte[] rv = new byte[s_len];
for (int i = 0; i < s_len; ++i) {
char c = s.charAt(i);
if (str == null) return null;
int str_len = str.length();
if (str_len == 0) return Bry_.Empty;
byte[] rv = new byte[str_len];
for (int i = 0; i < str_len; ++i) {
char c = str.charAt(i);
if (c > 128) c = '?';
rv[i] = (byte)c;
}
return rv;
}
catch (Exception e) {throw Err_.err_(e, "invalid ASCII sequence; s={0}", s);}
catch (Exception e) {throw Err_.err_(e, "invalid ASCII sequence; str={0}", str);}
}
public static byte[] new_ascii_safe_null_(String s) {return s == null ? null : new_ascii_(s);}
public static byte[] new_ascii_lang(String s) {
try {return s.getBytes("ASCII");}
catch (Exception e) {throw Err_.err_(e, "unsupported encoding");}
}
public static byte[] new_utf8_(String s) {
public static int new_utf8_len(String s, int s_len) {
int rv = 0;
for (int i = 0; i < s_len; ++i) {
char c = s.charAt(i);
int c_len = 0;
if ( c < 128) c_len = 1; // 1 << 7
else if ( c < 2048) c_len = 2; // 1 << 11
else if ( (c > 55295) // 0xD800
&& (c < 56320)) c_len = 4; // 0xDFFF
else c_len = 3; // 1 << 16
if (c_len == 4) ++i; // surrogate is 2 wide, not 1
rv += c_len;
}
return rv;
}
public static void new_utf8_write(String str, int str_len, byte[] bry, int bry_pos) {
for (int i = 0; i < str_len; ++i) {
char c = str.charAt(i);
if ( c < 128) {
bry[bry_pos++] = (byte)c;
}
else if ( c < 2048) {
bry[bry_pos++] = (byte)(0xC0 | (c >> 6));
bry[bry_pos++] = (byte)(0x80 | (c & 0x3F));
}
else if ( (c > 55295) // 0xD800
&& (c < 56320)) { // 0xDFFF
if (i >= str_len) throw Err_.new_fmt_("incomplete surrogate pair at end of String; char={0}", c);
char nxt_char = str.charAt(i + 1);
int v = 0x10000 + (c - 0xD800) * 0x400 + (nxt_char - 0xDC00);
bry[bry_pos++] = (byte)(0xF0 | (v >> 18));
bry[bry_pos++] = (byte)(0x80 | (v >> 12) & 0x3F);
bry[bry_pos++] = (byte)(0x80 | (v >> 6) & 0x3F);
bry[bry_pos++] = (byte)(0x80 | (v & 0x3F));
++i;
}
else {
bry[bry_pos++] = (byte)(0xE0 | (c >> 12));
bry[bry_pos++] = (byte)(0x80 | (c >> 6) & 0x3F);
bry[bry_pos++] = (byte)(0x80 | (c & 0x3F));
}
}
}
public static byte[] new_utf8__null(String str) {return str == null ? null : new_utf8_(str);}
public static byte[] new_utf8_(String str) {
try {
int s_len = s.length();
int b_pos = 0;
for (int i = 0; i < s_len; ++i) {
char c = s.charAt(i);
int c_len = 0;
if ( c < 128) c_len = 1; // 1 << 7
else if ( c < 2048) c_len = 2; // 1 << 11
else if ( (c > 55295) // 0xD800
&& (c < 56320)) c_len = 4; // 0xDFFF
else c_len = 3; // 1 << 16
if (c_len == 4) ++i; // surrogate is 2 wide, not 1
b_pos += c_len;
}
byte[] rv = new byte[b_pos];
b_pos = -1;
for (int i = 0; i < s_len; ++i) {
char c = s.charAt(i);
if ( c < 128) {
rv[++b_pos] = (byte)c;
}
else if ( c < 2048) {
rv[++b_pos] = (byte)(0xC0 | (c >> 6));
rv[++b_pos] = (byte)(0x80 | (c & 0x3F));
}
else if ( (c > 55295) // 0xD800
&& (c < 56320)) { // 0xDFFF
if (i >= s_len) throw Err_.new_fmt_("incomplete surrogate pair at end of String; char={0}", c);
char nxt_char = s.charAt(i + 1);
int v = 0x10000 + (c - 0xD800) * 0x400 + (nxt_char - 0xDC00);
rv[++b_pos] = (byte)(0xF0 | (v >> 18));
rv[++b_pos] = (byte)(0x80 | (v >> 12) & 0x3F);
rv[++b_pos] = (byte)(0x80 | (v >> 6) & 0x3F);
rv[++b_pos] = (byte)(0x80 | (v & 0x3F));
++i;
}
else {
rv[++b_pos] = (byte)(0xE0 | (c >> 12));
rv[++b_pos] = (byte)(0x80 | (c >> 6) & 0x3F);
rv[++b_pos] = (byte)(0x80 | (c & 0x3F));
}
}
int str_len = str.length();
int bry_len = new_utf8_len(str, str_len);
byte[] rv = new byte[bry_len];
new_utf8_write(str, str_len, rv, 0);
return rv;
}
catch (Exception e) {throw Err_.err_(e, "invalid UTF-8 sequence; s={0}", s);}
catch (Exception e) {throw Err_.err_(e, "invalid UTF-8 sequence; s={0}", str);}
}
public static byte[] new_utf8_lang(String s) {
try {return s.getBytes("UTF-8");}

View File

@ -248,7 +248,32 @@ public class Bry_bfr {
Add(val);
return this;
}
public Bry_bfr Add_str(String v) {return Add(Bry_.new_utf8_(v));}
public Bry_bfr Add_str(String v) {return Add_str_utf8(v);}
public Bry_bfr Add_str_utf8(String str) {
try {
int str_len = str.length();
int bry_len = Bry_.new_utf8_len(str, str_len);
if (bfr_len + bry_len > bfr_max) Resize((bfr_max + bry_len) * 2);
Bry_.new_utf8_write(str, str_len, bfr, bfr_len);
bfr_len += bry_len;
return this;
}
catch (Exception e) {throw Err_.err_(e, "invalid UTF-8 sequence; str={0}", str);}
}
public Bry_bfr Add_str_ascii(String str) {
try {
int bry_len = str.length();
if (bfr_len + bry_len > bfr_max) Resize((bfr_max + bry_len) * 2);
for (int i = 0; i < bry_len; ++i) {
char c = str.charAt(i);
if (c > 128) c = '?';
bfr[i + bfr_len] = (byte)c;
}
bfr_len += bry_len;
return this;
}
catch (Exception e) {throw Err_.err_(e, "invalid UTF-8 sequence; str={0}", str);}
}
public Bry_bfr Add_float(float f) {Add_str(Float_.Xto_str(f)); return this;}
public Bry_bfr Add_double(double v) {Add_str(Double_.Xto_str(v)); return this;}
public Bry_bfr Add_dte(DateAdp val) {return Add_dte_segs(val.Year(), val.Month(),val.Day(), val.Hour(), val.Minute(), val.Second(), val.Frac());}

View File

@ -24,7 +24,7 @@ public class Xoa_app_ {
boot_mgr.Run(args);
}
public static final String Name = "xowa";
public static final String Version = "1.11.1.1";
public static final String Version = "1.11.2.1";
public static String Build_date = "2012-12-30 00:00:00";
public static String Op_sys;
public static String User_agent = "";

View File

@ -40,7 +40,7 @@ public class Js_img_mgr {
String html_id = "xowa_file_img_" + uid;
html_itm.Html_img_update(html_id, html_src, html_w, html_h);
if (Xop_lnki_type.Id_is_thumbable(lnki_type)) { // thumb needs to set cls and width
html_itm.Html_atr_set(html_id, "class", gplx.xowa.html.Xow_html_mgr.Str_img_class_thumbimage);
html_itm.Html_atr_set(html_id, "class", gplx.xowa.html.lnkis.Xoh_lnki_consts.Str_img_cls_thumbimage);
html_itm.Html_atr_set("xowa_file_div_" + uid, "style", "width:" + html_w + "px;");
}
switch (elem_tid) {

View File

@ -24,21 +24,22 @@ public class Xodb_hdump_mgr__write_tst {
fxt.Expd_itms_xfers(fxt.Make_xfer("A.png", 0, 0, 0, Bool_.Y, Xof_ext_.Id_png));
fxt.Test_write_all
( "[[File:A.png|test_caption]]"
, "<a href=\"/wiki/File:A.png\" class=\"image\" xowa_title=\"A.png\"><img id=\"xowa_file_img_0\" alt=\"test_caption\" xowa_img='0' /></a>");
, "<a xtid='a_img_full' xatrs='1|0|0|test_caption'/>"
);
}
@Test public void Image_thumb() {
fxt.Expd_itms_xfers(fxt.Make_xfer("A.png", 0, 0, 0, Bool_.N, Xof_ext_.Id_png));
fxt.Test_write_all
( "[[File:A.png|thumb|test_caption]]", String_.Concat_lines_nl_skip_last
( "<div class=\"thumb tright\">"
, " <div id=\"xowa_file_div_0\" class=\"thumbinner\" xowa_img_style='0'>"
, " <a href=\"/wiki/File:A.png\" class=\"image\" xowa_title=\"A.png\"><img id=\"xowa_file_img_0\" alt=\"\" xowa_img='0' /></a>"
, " <div class=\"thumbcaption\"><xowa_mgnf id='0'/>"
, " test_caption"
, " </div>"
, " </div>"
, "</div>"
));
// fxt.Expd_itms_xfers(fxt.Make_xfer("A.png", 0, 0, 0, Bool_.N, Xof_ext_.Id_png));
// fxt.Test_write_all
// ( "[[File:A.png|thumb|test_caption]]", String_.Concat_lines_nl_skip_last
// ( "<div class=\"thumb tright\">"
// , " <div id=\"xowa_file_div_0\" class=\"thumbinner\" xowa_img_style='0'>"
// , " <a href=\"/wiki/File:A.png\" class=\"image\" xowa_title=\"A.png\"><img id=\"xowa_file_img_0\" alt=\"\" xowa_img='0' /></a>"
// , " <div class=\"thumbcaption\"><xowa_mgnf id='0'/>"
// , " test_caption"
// , " </div>"
// , " </div>"
// , "</div>"
// ));
}
@Test public void Audio_thumb() {
fxt.Expd_itms_xfers(fxt.Make_xfer("A.oga", 0, 220, -1, Bool_.N, Xof_ext_.Id_oga));

View File

@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.xowa.html; import gplx.*; import gplx.xowa.*;
import gplx.core.btries.*; import gplx.html.*; import gplx.xowa.wikis.*; import gplx.xowa.net.*;
import gplx.xowa.parsers.apos.*; import gplx.xowa.parsers.amps.*; import gplx.xowa.parsers.lnkes.*; import gplx.xowa.parsers.hdrs.*; import gplx.xowa.parsers.lists.*; import gplx.xowa.html.lnkis.*; import gplx.xowa.parsers.tblws.*; import gplx.xowa.parsers.paras.*;
import gplx.xowa.xtns.*; import gplx.xowa.xtns.dynamicPageList.*; import gplx.xowa.xtns.math.*; import gplx.xowa.langs.vnts.*; import gplx.xowa.xtns.cite.*;
import gplx.xowa.xtns.*; import gplx.xowa.xtns.dynamicPageList.*; import gplx.xowa.xtns.math.*; import gplx.xowa.langs.vnts.*; import gplx.xowa.xtns.cite.*; import gplx.xowa.html.hzips.*;
public class Xoh_html_wtr {
private Xow_wiki wiki; private Xoa_app app; private Xoa_page page; private Xop_xatr_whitelist_mgr whitelist_mgr;
public Xoh_html_wtr(Xow_wiki wiki, Xow_html_mgr html_mgr) {
@ -95,12 +95,14 @@ public class Xoh_html_wtr {
}
}
@gplx.Virtual public void Html_ncr(Xop_ctx ctx, Xoh_wtr_ctx hctx, Bry_bfr bfr, byte[] src, Xop_amp_tkn_num tkn) {
if (tkn.Val() < Byte_ascii.Max_7_bit) // NOTE: must "literalize"; <nowiki> converts wiki chars to ncrs, which must be "literalized: EX: <nowiki>[[A]]</nowiki> -> &#92;&#92;A&#93;&#93; which must be converted back to [[A]]
bfr.Add(tkn.Str_as_bry());
else
bfr.Add_byte(Byte_ascii.Amp).Add_byte(Byte_ascii.Hash).Add_int_variable(tkn.Val()).Add_byte(Byte_ascii.Semic); // NOTE: do not literalize, else browser may not display multi-char bytes properly; EX: &#160; gets added as &#160; not as {192,160}; DATE:2013-12-09
bfr.Add_byte(Byte_ascii.Amp).Add_byte(Byte_ascii.Hash).Add_int_variable(tkn.Val()).Add_byte(Byte_ascii.Semic); // NOTE: do not literalize, else browser may not display multi-char bytes properly; EX: &#160; gets added as &#160; not as {192,160}; DATE:2013-12-09
}
@gplx.Virtual public void Html_ref(Xop_ctx ctx, Xoh_wtr_ctx hctx, Bry_bfr bfr, byte[] src, Xop_amp_tkn_txt tkn) {
if (tkn.Itm_is_custom()) // used by <nowiki>; EX:<nowiki>&#60;</nowiki> -> &xowa_lt; DATE:2014-11-07
tkn.Print_literal(bfr);
else
tkn.Print_ncr(bfr);
}
@gplx.Virtual public void Html_ref(Xop_ctx ctx, Xoh_wtr_ctx hctx, Bry_bfr bfr, byte[] src, Xop_amp_tkn_txt tkn) {tkn.Print_to_html(bfr);}
private static final byte[] Bry_hdr_bgn = Bry_.new_ascii_("<span class='mw-headline' id='"), Bry_hdr_end = Bry_.new_ascii_("</span>");
@gplx.Virtual public void Hr(Xop_ctx ctx, Xoh_wtr_ctx hctx, Bry_bfr bfr, byte[] src, Xop_hr_tkn tkn) {bfr.Add(Tag_hr);}
@gplx.Virtual public void Hdr(Xop_ctx ctx, Xoh_wtr_ctx hctx, Bry_bfr bfr, byte[] src, Xop_hdr_tkn hdr) {
@ -126,6 +128,8 @@ public class Xoh_html_wtr {
if (hdr_len > 0) { // NOTE: need to check hdr_len b/c it could be dangling
if (hdr.Hdr_end_manual() > 0) bfr.Add_byte_repeat(Byte_ascii.Eq, hdr.Hdr_end_manual());
if (cfg.Toc_show()) {
if (hctx.Mode_is_hdump())
bfr.Add(Xow_hzip_itm__header.Hdr_end);
bfr.Add(Bry_hdr_end);
}
bfr.Add(Tag_hdr_end).Add_int(hdr_len, 1, 1).Add_byte(Tag__end).Add_byte_nl();// NOTE: do not need to check hdr_len b/c it is impossible for end to occur without bgn
@ -402,6 +406,7 @@ public class Xoh_html_wtr {
case Xop_xnde_tag_.Tid_rss:
case Xop_xnde_tag_.Tid_quiz:
case Xop_xnde_tag_.Tid_math:
case Xop_xnde_tag_.Tid_indicator:
case Xop_xnde_tag_.Tid_xowa_html:
Xox_xnde xtn = xnde.Xnde_xtn();
xtn.Xtn_write(bfr, app, ctx, this, hctx, xnde, src);
@ -605,7 +610,6 @@ public class Xoh_html_wtr {
, Tag_tblw_tc_bgn = Bry_.new_ascii_("<caption>"), Tag_tblw_tc_bgn_atr = Bry_.new_ascii_("<caption"), Tag_tblw_tc_end = Bry_.new_ascii_("</caption>")
, Ary_escape_bgn = Bry_.new_ascii_("&lt;"), Ary_escape_end = Bry_.new_ascii_("&gt;"), Ary_escape_end_bgn = Bry_.new_ascii_("&lt;/")
, Tag_para_bgn = Bry_.new_ascii_("<p>"), Tag_para_end = Bry_.new_ascii_("</p>"), Tag_para_mid = Bry_.new_ascii_("</p>\n\n<p>")
, Tag_image_end = Bry_.new_ascii_("</img>")
, Tag_pre_bgn = Bry_.new_ascii_("<pre>"), Tag_pre_end = Bry_.new_ascii_("</pre>")
;
public static final byte Tag__bgn = Byte_ascii.Lt, Tag__end = Byte_ascii.Gt;

View File

@ -55,19 +55,24 @@ public class Xoh_html_wtr_escaper {
Xop_amp_trie_itm itm = (Xop_amp_trie_itm)o;
int match_pos = amp_trie.Match_pos();
int itm_tid = itm.Tid();
if (itm_tid == Xop_amp_trie_itm.Tid_name) { // name
bfr.Add_mid(src, i, match_pos); // embed entire name
i = match_pos - 1;
}
else { // ncr: dec/hex
boolean pass = amp_mgr.Parse_as_int(itm_tid == Xop_amp_trie_itm.Tid_num_hex, src, end, i, match_pos);
int end_pos = amp_mgr.Rslt_pos();
if (pass) { // parse worked; embed entire ncr
bfr.Add_mid(src, i, end_pos);
i = end_pos - 1;
}
else // parse failed; escape and continue
bfr.Add(Html_entity_.Amp_bry);
switch (itm_tid) {
case Xop_amp_trie_itm.Tid_name_std:
case Xop_amp_trie_itm.Tid_name_xowa: // name
bfr.Add_mid(src, i, match_pos); // embed entire name
i = match_pos - 1;
break;
case Xop_amp_trie_itm.Tid_num_dec:
case Xop_amp_trie_itm.Tid_num_hex: // ncr: dec/hex
boolean pass = amp_mgr.Parse_as_int(itm_tid == Xop_amp_trie_itm.Tid_num_hex, src, end, i, match_pos);
int end_pos = amp_mgr.Rslt_pos();
if (pass) { // parse worked; embed entire ncr
bfr.Add_mid(src, i, end_pos);
i = end_pos - 1;
}
else // parse failed; escape and continue
bfr.Add(Html_entity_.Amp_bry);
break;
default: throw Err_.unhandled(itm_tid);
}
}
}

View File

@ -56,7 +56,7 @@ public class Xoh_html_wtr_tst {
@Test public void Apos_i() {fxt.Test_parse_page_wiki_str("''a''" , "<i>a</i>");}
@Test public void Apos_b() {fxt.Test_parse_page_wiki_str("'''a'''" , "<b>a</b>");}
@Test public void Apos_ib() {fxt.Test_parse_page_wiki_str("'''''a'''''" , "<i><b>a</b></i>");}
@Test public void Html_ent() {fxt.Test_parse_page_wiki_str("&#33;" , "!");}
@Test public void Html_ent() {fxt.Test_parse_page_wiki_str("&#33;" , "&#33;");} // PURPOSE:ncrs should be literal, not decoded (!); DATE:2014-11-06
@Test public void Html_ref() {fxt.Test_parse_page_wiki_str("&gt;" , "&gt;");}
@Test public void List_1_itm() {
fxt.Test_parse_page_wiki_str("*a", String_.Concat_lines_nl_skip_last

View File

@ -53,7 +53,7 @@ public class Xoh_page_wtr_mgr implements GfoInvkAble {
{ "app_root_dir", "app_version", "app_build_date", "xowa_mode_is_server"
, "page_id", "page_name", "page_title", "page_modified_on_msg"
, "html_css_common_path", "html_css_wiki_path", "xowa_head"
, "page_lang_ltr", "page_content_sub", "page_jumpto", "page_body_cls", "html_content_editable"
, "page_lang_ltr", "page_indicators", "page_content_sub", "page_jumpto", "page_body_cls", "html_content_editable"
, "page_data", "page_langs"
, "portal_div_personal", "portal_div_ns", "portal_div_view"
, "portal_div_logo", "portal_div_home", "portal_div_xtn"

View File

@ -72,7 +72,7 @@ public class Xoh_page_wtr_wkr implements Bry_fmtr_arg {
, Xoh_page_wtr_wkr_.Bld_page_name(tmp_bfr, page_ttl, page.Html_data().Display_ttl())
, page_modified_on_msg
, mgr.Css_common_bry(), mgr.Css_wiki_bry(), page.Html_data().Module_mgr().Init(app, wiki, page).Init_dflts()
, page.Lang().Dir_bry(), page_content_sub, wiki.Html_mgr().Portal_mgr().Div_jump_to(), page_body_class, html_content_editable
, page.Lang().Dir_bry(), page.Html_data().Indicators(), page_content_sub, wiki.Html_mgr().Portal_mgr().Div_jump_to(), page_body_class, html_content_editable
, page_data, wtr_page_lang
, portal_mgr.Div_personal_bry(), portal_mgr.Div_ns_bry(app.Utl_bry_bfr_mkr(), page_ttl, wiki.Ns_mgr()), portal_mgr.Div_view_bry(app.Utl_bry_bfr_mkr(), view_tid, page.Html_data().Xtn_search_text())
, portal_mgr.Div_logo_bry(), portal_mgr.Div_home_bry(), new Xopg_xtn_skin_fmtr_arg(page, Xopg_xtn_skin_itm_tid.Tid_sidebar), portal_mgr.Div_wikis_bry(app.Utl_bry_bfr_mkr()), portal_mgr.Sidebar_mgr().Html_bry()

View File

@ -72,6 +72,4 @@ public class Xow_html_mgr implements GfoInvkAble {
, Invk_portal = "portal", Invk_imgs = "imgs", Invk_ns_ctg = "ns_ctg"
, Invk_modules = "modules"
;
public static final String Str_img_class_thumbimage = "thumbimage";
public static final byte[] Bry_anchor_class_image = Bry_.new_ascii_(" class=\"image\""), Bry_anchor_class_blank = Bry_.Empty, Bry_anchor_rel_nofollow = Bry_.new_ascii_(" rel=\"nofollow\""), Bry_anchor_rel_blank = Bry_.Empty, Bry_img_cls_thumbimage = Bry_.new_ascii_(" class=\"thumbimage\""), Bry_img_cls_none = Bry_.Empty;
}

View File

@ -26,8 +26,9 @@ class Xow_hzip_dict {// SERIALIZED
, Tid_lnke_txt = 3
, Tid_lnke_brk_text_n = 4
, Tid_lnke_brk_text_y = 5
, Tid_hdr_lhs = 6
, Tid_hdr_rhs = 7
, Tid_img_full = 6
, Tid_hdr_lhs = 7
, Tid_hdr_rhs = 8
;
public static final byte[]
Bry_a_rhs = Bry_.ints_(Escape, Tid_a_rhs)
@ -36,6 +37,7 @@ class Xow_hzip_dict {// SERIALIZED
, Bry_lnke_txt = Bry_.ints_(Escape, Tid_lnke_txt)
, Bry_lnke_brk_text_n = Bry_.ints_(Escape, Tid_lnke_brk_text_n)
, Bry_lnke_brk_text_y = Bry_.ints_(Escape, Tid_lnke_brk_text_y)
, Bry_img_full = Bry_.ints_(Escape, Tid_img_full)
, Bry_hdr_lhs = Bry_.ints_(Escape, Tid_hdr_lhs)
, Bry_hdr_rhs = Bry_.ints_(Escape, Tid_hdr_rhs)
;

View File

@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.xowa.html.hzips; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*;
import org.junit.*; import gplx.xowa.html.*; import gplx.xowa.hdumps.srls.*;
public class Xow_hzip_itm__anchor_tst {
@Before public void init() {fxt.Clear();} private Xow_hzip_itm__anchor_fxt fxt = new Xow_hzip_itm__anchor_fxt();
@Before public void init() {fxt.Clear();} private Xow_hzip_mgr_fxt fxt = new Xow_hzip_mgr_fxt();
@Test public void Srl_lnki_text_n() {
byte[][] brys = Bry_.Ary(Xow_hzip_dict.Bry_lnki_text_n, Bry_.ints_(2), Bry_.new_ascii_("A"), Xow_hzip_dict.Escape_bry);
fxt.Test_save(brys, "<a xtid='a_lnki_text_n' href=\"/wiki/A\" id='xowa_lnki_0' title='A'>A</a>");
@ -72,10 +72,6 @@ public class Xow_hzip_itm__anchor_tst {
fxt.Test_save(brys, "<a xtid='a_lnke_brk_n' class=\"external autonumber\" rel=\"nofollow\" href=\"http://a.org\">[123]</a>");
fxt.Test_load(brys, "<a rel=\"nofollow\" class=\"external autonumber\" href=\"http://a.org\">[123]</a>");
}
// @Test public void Srl_hdr() {
// byte[][] brys = Bry_.Ary(Xow_hzip_dict.Bry_hdr_lhs, Bry_.new_ascii_("A</h2>"));
// fxt.Test_save(brys, "<h2><span class='mw-headline' id='A'>A</span></h2>");
// }
@Test public void Html_ttl() {
fxt.Test_html("[[A]]", "<a xtid='a_lnki_text_n' href=\"/wiki/A\" xowa_redlink='1'>A</a>");
}
@ -92,37 +88,3 @@ public class Xow_hzip_itm__anchor_tst {
fxt.Test_html("[http://a.org A]", "<a xtid='a_lnke_brk_y' href=\"http://a.org\" class=\"external text\" rel=\"nofollow\">A</a>");
}
}
class Xow_hzip_itm__anchor_fxt {
private Bry_bfr bfr = Bry_bfr.reset_(Io_mgr.Len_mb); private Xow_hzip_mgr hzip_mgr; private Xow_wiki wiki;
private Xow_hzip_stats stats = new Xow_hzip_stats();
public void Clear() {
if (hzip_mgr == null) {
Xoa_app app = Xoa_app_fxt.app_();
wiki = Xoa_app_fxt.wiki_tst_(app);
hzip_mgr = new Xow_hzip_mgr(Gfo_usr_dlg_._, wiki);
}
}
public void Test_save(byte[][] expd_brys, String html) {Test_save(html, expd_brys);}
public void Test_save(String html, byte[]... expd_brys) {
byte[] expd = Bry_.Add(expd_brys);
hzip_mgr.Save(bfr, stats, Bry_.Empty, Bry_.new_utf8_(html));
Tfds.Eq_ary(expd, bfr.Xto_bry_and_clear());
}
public void Test_load(byte[][] src_brys, String expd) {
byte[] src = Bry_.Add(src_brys);
hzip_mgr.Load(bfr, Bry_.Empty, src);
Tfds.Eq(expd, bfr.Xto_str_and_clear());
}
public void Test_html(String html, String expd) {
Xop_ctx ctx = wiki.Ctx(); Xop_parser parser = wiki.Parser(); Xop_tkn_mkr tkn_mkr = ctx.Tkn_mkr();
ctx.Para().Enabled_n_();
ctx.Cur_page().Lnki_redlinks_mgr().Clear();
byte[] html_bry = Bry_.new_utf8_(html);
Xop_root_tkn root = ctx.Tkn_mkr().Root(html_bry);
parser.Parse_page_all_clear(root, ctx, tkn_mkr, html_bry);
Xoh_wtr_ctx hctx = Xoh_wtr_ctx.Hdump;
Xoh_html_wtr html_wtr = wiki.Html_mgr().Html_wtr();
html_wtr.Write_all(bfr, ctx, hctx, html_bry, root);
Tfds.Eq(expd, bfr.Xto_str_and_clear());
}
}

View File

@ -0,0 +1,27 @@
/*
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.html.hzips; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*;
import org.junit.*; import gplx.xowa.html.*; import gplx.xowa.hdumps.srls.*;
public class Xow_hzip_itm__file_tst {
@Before public void init() {fxt.Clear();} private Xow_hzip_mgr_fxt fxt = new Xow_hzip_mgr_fxt();
@Test public void Srl_img_full() {
// byte[][] brys = Bry_.Ary(Xow_hzip_dict.Bry_img_full, Bry_.ints_(2), Bry_.new_ascii_("A"), Xow_hzip_dict.Escape_bry);
// fxt.Test_save(brys, "<a xtid='a_lnki_text_n' href=\"/wiki/A\" id='xowa_lnki_0' title='A'>A</a>");
// fxt.Test_load(brys, "<a href='/wiki/A' title='A'>A</a>");
}
}

View File

@ -20,7 +20,7 @@ import gplx.html.*; import gplx.xowa.apps.ttls.*; import gplx.xowa.hdumps.srls.*
public class Xow_hzip_itm__header {
private Xow_hzip_mgr hzip_mgr;
public Xow_hzip_itm__header(Xow_hzip_mgr hzip_mgr) {this.hzip_mgr = hzip_mgr;}
public int Save(Bry_bfr bfr, Xow_hzip_stats stats, byte[] src, int src_len, int bgn, int pos) {
public int Save(Bry_bfr bfr, Xow_hzip_stats stats, byte[] src, int src_len, int bgn, int pos) {// <h2><span class='mw-headline' id='A'>A<xo_hdr_end/></span></h2>
if (pos >= src_len) return Xow_hzip_mgr.Unhandled;
byte hdr_num_byte = src[pos];
switch (hdr_num_byte) {
@ -32,10 +32,24 @@ public class Xow_hzip_itm__header {
}
int span_lhs_bgn = pos + 2; // +2 to skip # and >; EX: "<h2>"
int span_lhs_end = Bry_finder.Find_fwd(src, Byte_ascii.Gt, span_lhs_bgn, src_len); if (span_lhs_end == Bry_finder.Not_found) return hzip_mgr.Warn_by_pos_add_dflt("h.span_end_missing", bgn, pos);
++span_lhs_end; // +1 to skip >
bfr.Add(Xow_hzip_dict.Bry_hdr_lhs);
bfr.Add_byte((byte)(hdr_num_byte - Byte_ascii.Num_0));
byte hdr_num = (byte)(hdr_num_byte - Byte_ascii.Num_0);
bfr.Add_byte(hdr_num);
int hdr_end = Bry_finder.Find_fwd(src, Hdr_end, span_lhs_end, src_len); if (hdr_end == Bry_finder.Not_found) return hzip_mgr.Warn_by_pos_add_dflt("h.capt_end_missing", bgn, span_lhs_end);
bfr.Add_mid(src, span_lhs_end, hdr_end);
hdr_end += Hdr_end.length;
bfr.Add(Xow_hzip_dict.Escape_bry);
stats.Hdr_add();
return span_lhs_end;
return hdr_end + 12; // +12 = "</span></h2>"
}
public int Load(Bry_bfr bfr, byte[] src, int src_len, int bgn) {
byte hdr_num = (byte)(src[bgn] + Byte_ascii.Num_0);
int capt_bgn = bgn + 1;
int capt_end = Bry_finder.Find_fwd(src, Xow_hzip_dict.Escape, capt_bgn, src_len); if (capt_end == Bry_finder.Not_found) return hzip_mgr.Warn_by_pos_add_dflt("hdr.capt_end_missing", bgn, capt_bgn);
bfr.Add_str("<h").Add_byte(hdr_num).Add_str("><span class='mw-headline' id='").Add_mid(src, capt_bgn, capt_end).Add_str("'>").Add_mid(src, capt_bgn, capt_end).Add_str("</span></h").Add_byte(hdr_num).Add_str(">");
return capt_end + 1;
}
public void Html(Bry_bfr bfr, boolean caption) {}
public static final byte[] Hdr_end = Bry_.new_ascii_("<!--xo_hdr_end-->");
}

View File

@ -0,0 +1,30 @@
/*
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.html.hzips; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*;
import org.junit.*; import gplx.xowa.html.*; import gplx.xowa.hdumps.srls.*;
public class Xow_hzip_itm__header_tst {
@Before public void init() {fxt.Clear();} private Xow_hzip_mgr_fxt fxt = new Xow_hzip_mgr_fxt();
@Test public void Srl_hdr() {
byte[][] brys = Bry_.Ary(Xow_hzip_dict.Bry_hdr_lhs, Bry_.ints_(2), Bry_.new_ascii_("A"), Xow_hzip_dict.Escape_bry);
fxt.Test_save(brys, "<h2><span class='mw-headline' id='A'>A<!--xo_hdr_end--></span></h2>");
fxt.Test_load(brys, "<h2><span class='mw-headline' id='A'>A</span></h2>");
}
@Test public void Html_hdr() {
fxt.Test_html("==A==", "<h2><span class='mw-headline' id='A'>A<!--xo_hdr_end--></span></h2>\n");
}
}

View File

@ -46,7 +46,7 @@ public class Xow_hzip_mgr {
switch (tid) {
case Tid_a_lhs: pos = itm__anchor.Save(bfr, stats, src, src_len, match_bgn, match_end); break;
case Tid_a_rhs: pos = itm__anchor.Save_a_rhs(bfr, stats, src, src_len, match_bgn, match_end); break;
// case Tid_h_lhs: pos = itm__header.Save(bfr, stats, src, src_len, match_bgn, match_end); break;
case Tid_h_lhs: pos = itm__header.Save(bfr, stats, src, src_len, match_bgn, match_end); break;
default: Warn_by_pos("save.tid.unknown", match_bgn, match_end); pos = match_end; continue;
}
if (pos == Unhandled) {
@ -76,6 +76,7 @@ public class Xow_hzip_mgr {
case Xow_hzip_dict.Tid_lnke_brk_text_n:
case Xow_hzip_dict.Tid_lnke_brk_text_y: pos = itm__anchor.Load_lnke(bfr, src, src_len, itm_pos, tid); break;
case Xow_hzip_dict.Tid_a_rhs: pos = itm_pos; bfr.Add_str("</a>"); break;
case Xow_hzip_dict.Tid_hdr_lhs: pos = itm__header.Load(bfr, src, src_len, itm_pos); break;
}
}
else {

View File

@ -0,0 +1,53 @@
/*
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.html.hzips; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*;
class Xow_hzip_mgr_fxt {
private Bry_bfr bfr = Bry_bfr.reset_(Io_mgr.Len_mb); private Xow_hzip_mgr hzip_mgr; private Xow_wiki wiki;
private Xow_hzip_stats stats = new Xow_hzip_stats();
public void Clear() {
if (hzip_mgr == null) {
Xoa_app app = Xoa_app_fxt.app_();
wiki = Xoa_app_fxt.wiki_tst_(app);
hzip_mgr = new Xow_hzip_mgr(Gfo_usr_dlg_._, wiki);
}
}
public void Test_save(byte[][] expd_brys, String html) {Test_save(html, expd_brys);}
public void Test_save(String html, byte[]... expd_brys) {
byte[] expd = Bry_.Add(expd_brys);
hzip_mgr.Save(bfr, stats, Bry_.Empty, Bry_.new_utf8_(html));
Tfds.Eq_ary(expd, bfr.Xto_bry_and_clear());
}
public void Test_load(byte[][] src_brys, String expd) {
byte[] src = Bry_.Add(src_brys);
hzip_mgr.Load(bfr, Bry_.Empty, src);
Tfds.Eq(expd, bfr.Xto_str_and_clear());
}
public void Test_html(String html, String expd) {
Xop_ctx ctx = wiki.Ctx(); Xop_parser parser = wiki.Parser(); Xop_tkn_mkr tkn_mkr = ctx.Tkn_mkr();
ctx.Para().Enabled_n_();
ctx.Cur_page().Lnki_redlinks_mgr().Clear();
byte[] html_bry = Bry_.new_utf8_(html);
Xop_root_tkn root = ctx.Tkn_mkr().Root(html_bry);
parser.Parse_page_all_clear(root, ctx, tkn_mkr, html_bry);
Xoh_wtr_ctx hctx = Xoh_wtr_ctx.Hdump;
Xoh_html_wtr html_wtr = wiki.Html_mgr().Html_wtr();
html_wtr.Cfg().Toc_show_(Bool_.Y); // needed for hdr to show <span class='mw-headline' id='A'>
html_wtr.Write_all(bfr, ctx, hctx, html_bry, root);
Tfds.Eq(expd, bfr.Xto_str_and_clear());
}
}

View File

@ -36,6 +36,7 @@ class Xow_hzip_xtid {
, Bry_lnke_txt = Bry_.new_ascii_("a_lnke_txt")
, Bry_lnke_brk_n = Bry_.new_ascii_("a_lnke_brk_n")
, Bry_lnke_brk_y = Bry_.new_ascii_("a_lnke_brk_y")
, Bry_img_full = Bry_.new_ascii_("a_img_full")
, Bry_hdr = Bry_.new_ascii_("hdr")
;
private static final Hash_adp_bry Xtids = Hash_adp_bry.cs_()
@ -44,6 +45,7 @@ class Xow_hzip_xtid {
.Add_bry_byte(Bry_lnke_txt , Xow_hzip_dict.Tid_lnke_txt)
.Add_bry_byte(Bry_lnke_brk_n , Xow_hzip_dict.Tid_lnke_brk_text_n)
.Add_bry_byte(Bry_lnke_brk_y , Xow_hzip_dict.Tid_lnke_brk_text_y)
.Add_bry_byte(Bry_img_full , Xow_hzip_dict.Tid_img_full)
.Add_bry_byte(Bry_hdr , Xow_hzip_dict.Tid_hdr_lhs)
;
}

View File

@ -24,14 +24,19 @@ public class Xoh_file_html_fmtr__base implements Xoh_file_img_wkr {
arg_img_core = New_arg_img_core();
}
@gplx.Internal @gplx.Virtual protected Xoh_arg_img_core New_arg_img_core() {return new Xoh_arg_img_core__basic();}
public void Html_full_media(Bry_bfr tmp_bfr, byte[] a_href, byte[] a_title, Bry_fmtr_arg html) {fmtr_full_media.Bld_bfr_many(tmp_bfr, a_href, a_title, html);}
private Bry_fmtr fmtr_full_media = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last
@gplx.Virtual public void Html_full_media(Bry_bfr tmp_bfr, byte[] a_href, byte[] a_title, Bry_fmtr_arg html) {fmtr_full_media.Bld_bfr_many(tmp_bfr, a_href, a_title, html);}
private final Bry_fmtr fmtr_full_media = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last
( "<a href=\"~{a_href}\" xowa_title=\"~{a_xowa_title}\">~{html}"
, "</a>"
), "a_href", "a_xowa_title", "html"
);
public void Html_full_img(Bry_bfr tmp_bfr, Xoh_wtr_ctx hctx, Xoa_page page, Xof_xfer_itm xfer_itm, int uid, byte[] a_href, byte[] a_class, byte[] a_rel, byte[] a_title, byte[] a_xowa_title, int img_w, int img_h, byte[] img_src, byte[] img_alt, byte[] img_class) {
fmtr_full_img.Bld_bfr_many(tmp_bfr, uid, a_href, a_class, a_rel, a_title, a_xowa_title, arg_img_core.Init(uid, img_src, img_w, img_h), img_alt, img_class);
@gplx.Virtual public void Html_full_img(Bry_bfr tmp_bfr, Xoh_wtr_ctx hctx, Xoa_page page, Xof_xfer_itm xfer_itm, int uid
, byte[] a_href, byte a_cls, byte a_rel, byte[] a_title, byte[] a_xowa_title
, int img_w, int img_h, byte[] img_src, byte[] img_alt, byte img_cls, byte[] img_cls_other
) {
fmtr_full_img.Bld_bfr_many(tmp_bfr, uid
, a_href, Xoh_lnki_consts.A_cls_to_bry(a_cls), Xoh_lnki_consts.A_rel_to_bry(a_rel), a_title, a_xowa_title
, arg_img_core.Init(uid, img_src, img_w, img_h), img_alt, Xoh_lnki_consts.Img_cls_to_bry(img_cls, img_cls_other));
}
private Bry_fmtr fmtr_full_img = Bry_fmtr.new_
( "<a href=\"~{a_href}\"~{a_class}~{a_rel}~{a_title} xowa_title=\"~{a_xowa_title}\">"

View File

@ -16,10 +16,25 @@ 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.html.lnkis; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*;
import gplx.html.*;
import gplx.xowa.files.*; import gplx.xowa.hdumps.htmls.*;
public class Xoh_file_html_fmtr__hdump extends Xoh_file_html_fmtr__base {
private Bry_bfr tmp_bfr = Bry_bfr.reset_(128);
@gplx.Internal @Override protected Xoh_arg_img_core New_arg_img_core() {return new Xoh_arg_img_core__hdump();}
// public override void Html_full_media(Bry_bfr tmp_bfr, byte[] a_href, byte[] a_title, Bry_fmtr_arg html) {
// fmtr_full_media.Bld_bfr_many(tmp_bfr, a_href, a_title, html);
// }
@Override public void Html_full_img(Bry_bfr tmp_bfr, Xoh_wtr_ctx hctx, Xoa_page page, Xof_xfer_itm xfer_itm, int uid
, byte[] a_href, byte a_cls, byte a_rel, byte[] a_title, byte[] a_xowa_title
, int img_w, int img_h, byte[] img_src, byte[] img_alt, byte img_cls, byte[] img_cls_other) {
tmp_bfr.Add_str_ascii("<a xtid='a_img_full' xatrs='");
tmp_bfr.Add_str_ascii(a_cls == Xoh_lnki_consts.Tid_a_cls_none ? "0|" : "1|"); // "" || "cls=image"
tmp_bfr.Add_str_ascii(a_rel == Xoh_lnki_consts.Tid_a_rel_none ? "0|" : "1|"); // "" || "rel=nofollow"
tmp_bfr.Add_int_variable(uid).Add_byte_pipe();
tmp_bfr.Add(Xoh_lnki_consts.Img_cls_to_bry(img_cls, img_cls_other)); // "" || "cls=thumbborder || thumbimage || other"
Html_utl.Escape_html_to_bfr(tmp_bfr, img_alt, 0, img_alt.length, Bool_.N, Bool_.N, Bool_.N, Bool_.N, Bool_.Y);
tmp_bfr.Add_str_ascii("'/>");
}
@Override public void Html_thumb_core(Bry_bfr bfr, int uid, byte[] div1_halign, int div2_width, byte[] div2_content) {
tmp_bfr.Add(Hdump_html_consts.Key_img_style);
tmp_bfr.Add_int_variable(uid);

View File

@ -18,5 +18,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.xowa.html.lnkis; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*;
import gplx.xowa.files.*;
public interface Xoh_file_img_wkr {
void Html_full_img(Bry_bfr tmp_bfr, Xoh_wtr_ctx hctx, Xoa_page page, Xof_xfer_itm xfer_itm, int uid, byte[] a_href, byte[] a_class, byte[] a_rel, byte[] a_title, byte[] a_xowa_title, int img_w, int img_h, byte[] img_src, byte[] img_alt, byte[] img_class);
void Html_full_img(Bry_bfr tmp_bfr, Xoh_wtr_ctx hctx, Xoa_page page, Xof_xfer_itm xfer_itm, int uid
, byte[] a_href, byte a_cls, byte a_rel, byte[] a_title, byte[] a_xowa_title
, int img_w, int img_h, byte[] img_src, byte[] img_alt, byte img_cls, byte[] img_cls_other
);
}

View File

@ -130,8 +130,10 @@ public class Xoh_file_wtr__basic {
case Xop_lnki_align_h.None: bfr.Add(Div_float_none) .Add_byte_nl(); div_align_exists = true; break;
}
Arg_nde_tkn lnki_link_tkn = lnki.Link_tkn();
byte img_cls_tid = lnki.Border() == Bool_.Y_byte ? Xoh_lnki_consts.Tid_img_cls_thumbborder : Xoh_lnki_consts.Tid_img_cls_none;
byte[] img_cls_other = lnki.Lnki_cls(); // PAGE:en.s:Page:Notes_on_Osteology_of_Baptanodon._With_a_Description_of_a_New_Species.pdf/3; DATE:2014-09-06
if (lnki_link_tkn == Arg_nde_tkn.Null) // full
lnki_file_wkr.Html_full_img(bfr, hctx, page, xfer_itm, uid, lnki_href, Xow_html_mgr.Bry_anchor_class_image, Xow_html_mgr.Bry_anchor_rel_blank, anchor_title, lnki_ttl, xfer_itm.Html_w(), xfer_itm.Html_h(), img_view_src, alt, Arg_img_cls(scratch_bfr, lnki));
lnki_file_wkr.Html_full_img(bfr, hctx, page, xfer_itm, uid, lnki_href, Xoh_lnki_consts.Tid_a_cls_image, Xoh_lnki_consts.Tid_a_rel_none, anchor_title, lnki_ttl, xfer_itm.Html_w(), xfer_itm.Html_h(), img_view_src, alt, img_cls_tid, img_cls_other);
else { // thumb
Arg_itm_tkn link_tkn = lnki_link_tkn.Val_tkn();
byte[] link_ref = link_tkn.Dat_to_bry(src);
@ -139,7 +141,7 @@ public class Xoh_file_wtr__basic {
link_ref = link_ref_new == null ? lnki_href: link_ref_new; // if parse fails, then assign to lnki_href; EX:link={{{1}}}
link_ref = ctx.App().Encoder_mgr().Href_quotes().Encode(link_ref); // must encode quotes; PAGE:en.w:List_of_cultural_heritage_sites_in_Punjab,_Pakistan; DATE:2014-07-16
lnki_ttl = Bry_.Coalesce(lnki_ttl, tmp_link_parser.Html_xowa_ttl());
lnki_file_wkr.Html_full_img(bfr, hctx, page, xfer_itm, uid, link_ref, tmp_link_parser.Html_anchor_cls(), tmp_link_parser.Html_anchor_rel(), anchor_title, lnki_ttl, xfer_itm.Html_w(), xfer_itm.Html_h(), img_view_src, alt, Arg_img_cls(scratch_bfr, lnki));
lnki_file_wkr.Html_full_img(bfr, hctx, page, xfer_itm, uid, link_ref, tmp_link_parser.Html_anchor_cls(), tmp_link_parser.Html_anchor_rel(), anchor_title, lnki_ttl, xfer_itm.Html_w(), xfer_itm.Html_h(), img_view_src, alt, img_cls_tid, img_cls_other);
}
if (div_align_exists) bfr.Add(Html_tag_.Div_rhs); // close div from above
}
@ -148,9 +150,9 @@ public class Xoh_file_wtr__basic {
}
private byte[] Arg_content_thumb(Xoh_file_img_wkr lnki_file_wkr, Xop_ctx ctx, Xoh_wtr_ctx hctx, byte[] src, Xop_lnki_tkn lnki, Xof_xfer_itm xfer_itm, int uid, byte[] lnki_href, byte[] view_src, byte[] img_orig_src, byte[] lnki_alt_text, byte[] lnki_ttl, byte[] anchor_title) {
byte[] lnki_alt_html = wiki.Html_mgr().Imgs_mgr().Alt_in_caption().Val() ? Arg_alt_html(ctx, src, lnki) : Bry_.Empty;
byte[] lnki_cls = xfer_itm.Html_pass() ? Xow_html_mgr.Bry_img_cls_thumbimage : Xow_html_mgr.Bry_img_cls_none;
byte img_cls_tid = xfer_itm.Html_pass() ? Xoh_lnki_consts.Tid_img_cls_thumbimage : Xoh_lnki_consts.Tid_img_cls_none;
Bry_bfr tmp_bfr = bfr_mkr.Get_k004();
lnki_file_wkr.Html_full_img(tmp_bfr, hctx, page, xfer_itm, uid, lnki_href, Xow_html_mgr.Bry_anchor_class_image, Xow_html_mgr.Bry_anchor_rel_blank, anchor_title, lnki_ttl, xfer_itm.Html_w(), xfer_itm.Html_h(), view_src, lnki_alt_text, lnki_cls);
lnki_file_wkr.Html_full_img(tmp_bfr, hctx, page, xfer_itm, uid, lnki_href, Xoh_lnki_consts.Tid_a_cls_image, Xoh_lnki_consts.Tid_a_rel_none, anchor_title, lnki_ttl, xfer_itm.Html_w(), xfer_itm.Html_h(), view_src, lnki_alt_text, img_cls_tid, Xoh_lnki_consts.Bry_none);
byte[] thumb = tmp_bfr.Xto_bry_and_clear();
html_fmtr.Html_thumb_file_image(tmp_bfr, thumb, Arg_caption_div(ctx, src, lnki, uid, img_orig_src, lnki_href), lnki_alt_html);
return tmp_bfr.Mkr_rls().Xto_bry_and_clear();
@ -223,27 +225,6 @@ public class Xoh_file_wtr__basic {
tmp_bfr.Add_byte(Byte_ascii.Quote);
return tmp_bfr.Xto_bry_and_clear();
}
private static byte[] Arg_img_cls(Bry_bfr tmp_bfr, Xop_lnki_tkn lnki) {
byte[] cls_border = lnki.Border() == Bool_.Y_byte ? Bry_cls_thumbborder : null;
byte[] cls_custom = lnki.Lnki_cls() == null ? null : lnki.Lnki_cls(); // PAGE:en.s:Page:Notes_on_Osteology_of_Baptanodon._With_a_Description_of_a_New_Species.pdf/3; DATE:2014-09-06
return cls_border == null && cls_custom == null
? Bry_.Empty
: Cls_coalesce(tmp_bfr, cls_border, cls_custom);
}
private static byte[] Cls_coalesce(Bry_bfr tmp_bfr, byte[]... cls_ary) {
tmp_bfr.Add(Bry_cls);
int written = 0;
int len = cls_ary.length;
for (int i = 0; i < len; ++i) {
byte[] cls_itm = cls_ary[i];
if (cls_itm == null) continue;
if (written != 0) tmp_bfr.Add_byte(Byte_ascii.Semic);
tmp_bfr.Add(cls_itm);
++written;
}
tmp_bfr.Add(Byte_ascii.Quote_bry);
return tmp_bfr.Xto_bry_and_clear();
}
public static final int Play_btn_max_width = 1024;
private static final byte[]
Div_center_bgn = Bry_.new_ascii_("<div class=\"center\">")
@ -251,7 +232,5 @@ public class Xoh_file_wtr__basic {
, Div_float_left = Bry_.new_ascii_("<div class=\"floatleft\">")
, Div_float_right = Bry_.new_ascii_("<div class=\"floatright\">")
, Atr_title = Bry_.new_ascii_(" title=\"")
, Bry_cls = Bry_.new_ascii_(" class=\"")
, Bry_cls_thumbborder = Bry_.new_ascii_("thumbborder")
;
}

View File

@ -111,7 +111,7 @@ public class Xoh_file_wtr_basic_tst {
@Test public void Cls_border_custom() {
fxt.Test_parse_page_wiki_str
( "[[File:A.png|border|class=abc]]"
, "<a href=\"/wiki/File:A.png\" class=\"image\" xowa_title=\"A.png\"><img id=\"xowa_file_img_0\" alt=\"\" src=\"file:///mem/wiki/repo/trg/orig/7/0/A.png\" width=\"0\" height=\"0\" class=\"thumbborder;abc\" /></a>");
, "<a href=\"/wiki/File:A.png\" class=\"image\" xowa_title=\"A.png\"><img id=\"xowa_file_img_0\" alt=\"\" src=\"file:///mem/wiki/repo/trg/orig/7/0/A.png\" width=\"0\" height=\"0\" class=\"thumbborder abc\" /></a>");
}
@Test public void Lnki_full_svg() {
fxt.Test_parse_page_wiki_str

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.html.lnkis; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*;
public class Xoh_lnki_consts {
public static final byte
Tid_a_cls_none = 0 , Tid_a_cls_image = 1
, Tid_a_rel_none = 0 , Tid_a_rel_nofollow = 1
, Tid_img_cls_none = 0 , Tid_img_cls_thumbimage = 2, Tid_img_cls_thumbborder = 3
;
public static final String Str_img_cls_thumbimage = "thumbimage";
private static final byte[]
Bry_anchor_class_image = Bry_.new_ascii_(" class=\"image\"")
, Bry_anchor_rel_nofollow = Bry_.new_ascii_(" rel=\"nofollow\"")
, Bry_img_cls_thumbborder = Bry_.new_ascii_(" class=\"thumbborder\"")
, Bry_img_cls_prefix = Bry_.new_ascii_(" class=\"")
;
public static final byte[] Bry_img_cls_thumbimage = Bry_.new_ascii_(" class=\"thumbimage\"");
public static final byte[] Bry_none = Bry_.Empty;
public static byte[] A_cls_to_bry(byte tid) {return tid == Tid_a_cls_none ? Bry_.Empty : Bry_anchor_class_image;}
public static byte[] A_rel_to_bry(byte tid) {return tid == Tid_a_rel_none ? Bry_.Empty : Bry_anchor_rel_nofollow;}
public static byte[] Img_cls_to_bry(byte tid, byte[] other) {
boolean other_is_empty = Bry_.Len_eq_0(other);
byte[] rv = null;
switch (tid) {
case Tid_img_cls_none: return other_is_empty ? Bry_.Empty : Bry_.Add(Bry_img_cls_prefix, other, Byte_ascii.Quote_bry);
case Tid_img_cls_thumbimage: rv = Bry_img_cls_thumbimage; break;
case Tid_img_cls_thumbborder: rv = Bry_img_cls_thumbborder; break;
default: throw Err_.unhandled(tid);
}
if (other_is_empty) return rv;
rv = Bry_.Copy(rv); // copy for replace below
rv[rv.length - 1] = Byte_ascii.Space; // replace " with space
return Bry_.Add(rv, other, Byte_ascii.Quote_bry); // add custom cls
}
}

View File

@ -0,0 +1,34 @@
/*
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.html.lnkis; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*;
import org.junit.*;
public class Xoh_lnki_consts_tst {
private Xoh_lnki_consts_fxt fxt = new Xoh_lnki_consts_fxt();
@Test public void Img_cls_to_bry() {
fxt.Test_img_cls_to_bry(Xoh_lnki_consts.Tid_img_cls_none , null , "");
fxt.Test_img_cls_to_bry(Xoh_lnki_consts.Tid_img_cls_none , "a" , " class=\"a\"");
fxt.Test_img_cls_to_bry(Xoh_lnki_consts.Tid_img_cls_thumbimage , null , " class=\"thumbimage\"");
fxt.Test_img_cls_to_bry(Xoh_lnki_consts.Tid_img_cls_thumbborder , null , " class=\"thumbborder\"");
fxt.Test_img_cls_to_bry(Xoh_lnki_consts.Tid_img_cls_thumbborder , "a" , " class=\"thumbborder a\"");
}
}
class Xoh_lnki_consts_fxt {
public void Test_img_cls_to_bry(byte tid, String other, String expd) {
Tfds.Eq(expd, String_.new_utf8_(Xoh_lnki_consts.Img_cls_to_bry(tid, Bry_.new_utf8__null(other))));
}
}

View File

@ -188,6 +188,7 @@ public class Xow_toc_mgr implements Bry_fmtr_arg {
}
public void Html(Xoa_page page, Xoh_wtr_ctx hctx, byte[] src, Bry_bfr bfr) {
if (!page.Hdr_mgr().Toc_enabled()) return; // REF.MW: Parser.php|formatHeadings
if (hctx.Mode_is_hdump()) return;
this.page = page;
byte[] bry_contents = page.Wiki().Msg_mgr().Val_by_id(Xol_msg_itm_.Id_toc);
bfmtr_main.Bld_bfr_many(bfr, Bry_fmtr_arg_.bry_(bry_contents), this);

View File

@ -359,11 +359,11 @@ public class Xow_toc_mgr_tst {
, String_.Concat_lines_nl
( fxt.toc_tbl_nl_n
( " <ul>"
, " <li class=\"toclevel-1 tocsection-1\"><a href=\"#.5Ba.5D\"><span class=\"tocnumber\">1</span> <span class=\"toctext\">[a]</span></a>"
, " <li class=\"toclevel-1 tocsection-1\"><a href=\"#.5Ba.5D\"><span class=\"tocnumber\">1</span> <span class=\"toctext\">&#91;a&#93;</span></a>"
, " </li>"
, " </ul>"
)
, "<h2><span class='mw-headline' id='.5Ba.5D'>[a]</span></h2>"
, "<h2><span class='mw-headline' id='.5Ba.5D'>&#91;a&#93;</span></h2>"
));
}
@Test public void Fix_large_before_small() { // PURPOSE.fix: "===a===\n===b===\n" followed by "==c==" causes improper formatting; DATE:2013-05-16

View File

@ -16,7 +16,7 @@ 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.pages; import gplx.*; import gplx.xowa.*;
import gplx.html.*; import gplx.xowa.html.modules.*; import gplx.xowa.pages.skins.*;
import gplx.html.*; import gplx.xowa.html.modules.*; import gplx.xowa.pages.skins.*; import gplx.xowa.xtns.indicators.*;
public class Xopg_html_data {
private OrderedHash ctg_hash;
public boolean Html_restricted() {return html_restricted;} private boolean html_restricted = true;
@ -41,6 +41,7 @@ public class Xopg_html_data {
public boolean Lang_convert_content() {return lang_convert_content;} public void Lang_convert_content_(boolean v) {lang_convert_content = v;} private boolean lang_convert_content = true;
public boolean Lang_convert_title() {return lang_convert_title;} public void Lang_convert_title_(boolean v) {lang_convert_title = v;} private boolean lang_convert_title = true;
public Xopg_xtn_skin_mgr Xtn_skin_mgr() {return xtn_skin_mgr;} private Xopg_xtn_skin_mgr xtn_skin_mgr = new Xopg_xtn_skin_mgr();
public Indicator_html_bldr Indicators() {return indicators;} public void Indicators_(Indicator_html_bldr v) {indicators = v;} private Indicator_html_bldr indicators;
public int Xtn_gallery_next_id() {return ++xtn_gallery_next_id;} private int xtn_gallery_next_id = -1;
public boolean Xtn_gallery_packed_exists() {return xtn_gallery_packed_exists;} public void Xtn_gallery_packed_exists_y_() {xtn_gallery_packed_exists = true;} private boolean xtn_gallery_packed_exists;
public boolean Xtn_imap_exists() {return xtn_imap_exists;} public void Xtn_imap_exists_y_() {xtn_imap_exists = true;} private boolean xtn_imap_exists;
@ -78,6 +79,7 @@ public class Xopg_html_data {
module_mgr.Clear();
custom_html = custom_html_end = custom_head_end = custom_name = null;
if (ctg_hash != null) ctg_hash.Clear();
indicators = null;
}
public byte[][] Ctgs_to_ary() {return ctg_hash == null ? Bry_.Ary_empty : (byte[][])ctg_hash.Xto_ary(byte[].class);}
public void Ctgs_add(Xoa_ttl ttl) {

View File

@ -28,14 +28,17 @@ public class Xop_amp_mgr {
cur_pos = amp_trie.Match_pos();
if (o == null) return null;
Xop_amp_trie_itm itm = (Xop_amp_trie_itm)o;
if (itm.Tid() == Xop_amp_trie_itm.Tid_name) {
rslt_pos = cur_pos;
return tkn_mkr.Amp_txt(amp_pos, cur_pos, itm);
}
else {
boolean ncr_is_hex = itm.Tid() == Xop_amp_trie_itm.Tid_num_hex;
boolean pass = Parse_as_int(ncr_is_hex, src, src_len, amp_pos, cur_pos);
return pass ? tkn_mkr.Amp_num(amp_pos, rslt_pos, rslt_val) : null;
switch (itm.Tid()) {
case Xop_amp_trie_itm.Tid_name_std:
case Xop_amp_trie_itm.Tid_name_xowa:
rslt_pos = cur_pos;
return tkn_mkr.Amp_txt(amp_pos, cur_pos, itm);
case Xop_amp_trie_itm.Tid_num_hex:
case Xop_amp_trie_itm.Tid_num_dec:
boolean ncr_is_hex = itm.Tid() == Xop_amp_trie_itm.Tid_num_hex;
boolean pass = Parse_as_int(ncr_is_hex, src, src_len, amp_pos, cur_pos);
return pass ? tkn_mkr.Amp_num(amp_pos, rslt_pos, rslt_val) : null;
default: throw Err_.unhandled(itm.Tid());
}
}
public byte[] Decode_as_bry(byte[] src) {
@ -56,18 +59,24 @@ public class Xop_amp_mgr {
dirty = true;
}
Xop_amp_trie_itm amp_itm = (Xop_amp_trie_itm)amp_obj;
if (amp_itm.Tid() == Xop_amp_trie_itm.Tid_name) {
tmp_bfr.Add(amp_itm.Utf8_bry());
pos = amp_trie.Match_pos();
}
else {
boolean ncr_is_hex = amp_itm.Tid() == Xop_amp_trie_itm.Tid_num_hex;
int int_bgn = amp_trie.Match_pos();
if (Parse_as_int(ncr_is_hex, src, src_len, pos, int_bgn))
tmp_bfr.Add_utf8_int(rslt_val);
else
tmp_bfr.Add_mid(src, pos, nxt_pos);
pos = rslt_pos;
switch (amp_itm.Tid()) {
case Xop_amp_trie_itm.Tid_name_std:
case Xop_amp_trie_itm.Tid_name_xowa:
tmp_bfr.Add(amp_itm.Utf8_bry());
pos = amp_trie.Match_pos();
break;
case Xop_amp_trie_itm.Tid_num_hex:
case Xop_amp_trie_itm.Tid_num_dec:
boolean ncr_is_hex = amp_itm.Tid() == Xop_amp_trie_itm.Tid_num_hex;
int int_bgn = amp_trie.Match_pos();
if (Parse_as_int(ncr_is_hex, src, src_len, pos, int_bgn))
tmp_bfr.Add_utf8_int(rslt_val);
else
tmp_bfr.Add_mid(src, pos, nxt_pos);
pos = rslt_pos;
break;
default:
throw Err_.unhandled(amp_itm.Tid());
}
continue;
}

View File

@ -22,8 +22,10 @@ public class Xop_amp_tkn_txt extends Xop_tkn_itm_base {
this.html_ref_itm = html_ref_itm;
this.Tkn_ini_pos(false, bgn, end);
}
@Override public byte Tkn_tid() {return Xop_tkn_itm_.Tid_html_ref;}
public int Char_int() {return html_ref_itm.Char_int();}
public byte[] Xml_name_bry() {return html_ref_itm.Xml_name_bry();}
public void Print_to_html(Bry_bfr bfr) {html_ref_itm.Print_to_html(bfr);}
@Override public byte Tkn_tid() {return Xop_tkn_itm_.Tid_html_ref;}
public int Char_int() {return html_ref_itm.Char_int();}
public byte[] Xml_name_bry() {return html_ref_itm.Xml_name_bry();}
public boolean Itm_is_custom() {return html_ref_itm.Tid() == Xop_amp_trie_itm.Tid_name_xowa;}
public void Print_ncr(Bry_bfr bfr) {html_ref_itm.Print_ncr(bfr);}
public void Print_literal(Bry_bfr bfr) {html_ref_itm.Print_literal(bfr);}
}

View File

@ -18,270 +18,293 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.xowa.parsers.amps; import gplx.*; import gplx.xowa.*; import gplx.xowa.parsers.*;
import gplx.core.btries.*;
public class Xop_amp_trie {
public static final byte[] // NOTE: top_define
Bry_xowa_lt = Bry_.new_ascii_("&xowa_lt;")
, Bry_xowa_brack_bgn = Bry_.new_ascii_("&xowa_brack_bgn;")
, Bry_xowa_brack_end = Bry_.new_ascii_("&xowa_brack_end;")
, Bry_xowa_pipe = Bry_.new_ascii_("&xowa_pipe;")
, Bry_xowa_apos = Bry_.new_ascii_("&xowa_apos;")
, Bry_xowa_colon = Bry_.new_ascii_("&xowa_colon;")
, Bry_xowa_underline = Bry_.new_ascii_("&xowa_underline;")
, Bry_xowa_asterisk = Bry_.new_ascii_("&xowa_asterisk;")
, Bry_xowa_space = Bry_.new_ascii_("&xowa_space;")
, Bry_xowa_nl = Bry_.new_ascii_("&xowa_nl;")
;
public static final Btrie_slim_mgr _ = new_(); Xop_amp_trie() {}
private static Btrie_slim_mgr new_() {// REF.MW: Sanitizer|$wgHtmlEntities; NOTE:added apos
Btrie_slim_mgr rv = Btrie_slim_mgr.cs_();
Reg_char(rv, 39, "&apos;");
Reg_char(rv, 193, "&Aacute;");
Reg_char(rv, 225, "&aacute;");
Reg_char(rv, 194, "&Acirc;");
Reg_char(rv, 226, "&acirc;");
Reg_char(rv, 180, "&acute;");
Reg_char(rv, 198, "&AElig;");
Reg_char(rv, 230, "&aelig;");
Reg_char(rv, 192, "&Agrave;");
Reg_char(rv, 224, "&agrave;");
Reg_char(rv, 8501, "&alefsym;");
Reg_char(rv, 913, "&Alpha;");
Reg_char(rv, 945, "&alpha;");
Reg_char(rv, 38, "&amp;");
Reg_char(rv, 8743, "&and;");
Reg_char(rv, 8736, "&ang;");
Reg_char(rv, 197, "&Aring;");
Reg_char(rv, 229, "&aring;");
Reg_char(rv, 8776, "&asymp;");
Reg_char(rv, 195, "&Atilde;");
Reg_char(rv, 227, "&atilde;");
Reg_char(rv, 196, "&Auml;");
Reg_char(rv, 228, "&auml;");
Reg_char(rv, 8222, "&bdquo;");
Reg_char(rv, 914, "&Beta;");
Reg_char(rv, 946, "&beta;");
Reg_char(rv, 166, "&brvbar;");
Reg_char(rv, 8226, "&bull;");
Reg_char(rv, 8745, "&cap;");
Reg_char(rv, 199, "&Ccedil;");
Reg_char(rv, 231, "&ccedil;");
Reg_char(rv, 184, "&cedil;");
Reg_char(rv, 162, "&cent;");
Reg_char(rv, 935, "&Chi;");
Reg_char(rv, 967, "&chi;");
Reg_char(rv, 710, "&circ;");
Reg_char(rv, 9827, "&clubs;");
Reg_char(rv, 8773, "&cong;");
Reg_char(rv, 169, "&copy;");
Reg_char(rv, 8629, "&crarr;");
Reg_char(rv, 8746, "&cup;");
Reg_char(rv, 164, "&curren;");
Reg_char(rv, 8224, "&dagger;");
Reg_char(rv, 8225, "&Dagger;");
Reg_char(rv, 8595, "&darr;");
Reg_char(rv, 8659, "&dArr;");
Reg_char(rv, 176, "&deg;");
Reg_char(rv, 916, "&Delta;");
Reg_char(rv, 948, "&delta;");
Reg_char(rv, 9830, "&diams;");
Reg_char(rv, 247, "&divide;");
Reg_char(rv, 201, "&Eacute;");
Reg_char(rv, 233, "&eacute;");
Reg_char(rv, 202, "&Ecirc;");
Reg_char(rv, 234, "&ecirc;");
Reg_char(rv, 200, "&Egrave;");
Reg_char(rv, 232, "&egrave;");
Reg_char(rv, 8709, "&empty;");
Reg_char(rv, 8195, "&emsp;");
Reg_char(rv, 8194, "&ensp;");
Reg_char(rv, 917, "&Epsilon;");
Reg_char(rv, 949, "&epsilon;");
Reg_char(rv, 8801, "&equiv;");
Reg_char(rv, 919, "&Eta;");
Reg_char(rv, 951, "&eta;");
Reg_char(rv, 208, "&ETH;");
Reg_char(rv, 240, "&eth;");
Reg_char(rv, 203, "&Euml;");
Reg_char(rv, 235, "&euml;");
Reg_char(rv, 8364, "&euro;");
Reg_char(rv, 8707, "&exist;");
Reg_char(rv, 402, "&fnof;");
Reg_char(rv, 8704, "&forall;");
Reg_char(rv, 189, "&frac12;");
Reg_char(rv, 188, "&frac14;");
Reg_char(rv, 190, "&frac34;");
Reg_char(rv, 8260, "&frasl;");
Reg_char(rv, 915, "&Gamma;");
Reg_char(rv, 947, "&gamma;");
Reg_char(rv, 8805, "&ge;");
Reg_char(rv, 62, "&gt;");
Reg_char(rv, 8596, "&harr;");
Reg_char(rv, 8660, "&hArr;");
Reg_char(rv, 9829, "&hearts;");
Reg_char(rv, 8230, "&hellip;");
Reg_char(rv, 205, "&Iacute;");
Reg_char(rv, 237, "&iacute;");
Reg_char(rv, 206, "&Icirc;");
Reg_char(rv, 238, "&icirc;");
Reg_char(rv, 161, "&iexcl;");
Reg_char(rv, 204, "&Igrave;");
Reg_char(rv, 236, "&igrave;");
Reg_char(rv, 8465, "&image;");
Reg_char(rv, 8734, "&infin;");
Reg_char(rv, 8747, "&int;");
Reg_char(rv, 921, "&Iota;");
Reg_char(rv, 953, "&iota;");
Reg_char(rv, 191, "&iquest;");
Reg_char(rv, 8712, "&isin;");
Reg_char(rv, 207, "&Iuml;");
Reg_char(rv, 239, "&iuml;");
Reg_char(rv, 922, "&Kappa;");
Reg_char(rv, 954, "&kappa;");
Reg_char(rv, 923, "&Lambda;");
Reg_char(rv, 955, "&lambda;");
Reg_char(rv, 9001, "&lang;");
Reg_char(rv, 171, "&laquo;");
Reg_char(rv, 8592, "&larr;");
Reg_char(rv, 8656, "&lArr;");
Reg_char(rv, 8968, "&lceil;");
Reg_char(rv, 8220, "&ldquo;");
Reg_char(rv, 8804, "&le;");
Reg_char(rv, 8970, "&lfloor;");
Reg_char(rv, 8727, "&lowast;");
Reg_char(rv, 9674, "&loz;");
Reg_char(rv, 8206, "&lrm;");
Reg_char(rv, 8249, "&lsaquo;");
Reg_char(rv, 8216, "&lsquo;");
Reg_char(rv, 60, "&lt;");
Reg_char(rv, 175, "&macr;");
Reg_char(rv, 8212, "&mdash;");
Reg_char(rv, 181, "&micro;");
Reg_char(rv, 183, "&middot;");
Reg_char(rv, 8722, "&minus;");
Reg_char(rv, 924, "&Mu;");
Reg_char(rv, 956, "&mu;");
Reg_char(rv, 8711, "&nabla;");
Reg_char(rv, 160, "&nbsp;");
Reg_char(rv, 8211, "&ndash;");
Reg_char(rv, 8800, "&ne;");
Reg_char(rv, 8715, "&ni;");
Reg_char(rv, 172, "&not;");
Reg_char(rv, 8713, "&notin;");
Reg_char(rv, 8836, "&nsub;");
Reg_char(rv, 209, "&Ntilde;");
Reg_char(rv, 241, "&ntilde;");
Reg_char(rv, 925, "&Nu;");
Reg_char(rv, 957, "&nu;");
Reg_char(rv, 211, "&Oacute;");
Reg_char(rv, 243, "&oacute;");
Reg_char(rv, 212, "&Ocirc;");
Reg_char(rv, 244, "&ocirc;");
Reg_char(rv, 338, "&OElig;");
Reg_char(rv, 339, "&oelig;");
Reg_char(rv, 210, "&Ograve;");
Reg_char(rv, 242, "&ograve;");
Reg_char(rv, 8254, "&oline;");
Reg_char(rv, 937, "&Omega;");
Reg_char(rv, 969, "&omega;");
Reg_char(rv, 927, "&Omicron;");
Reg_char(rv, 959, "&omicron;");
Reg_char(rv, 8853, "&oplus;");
Reg_char(rv, 8744, "&or;");
Reg_char(rv, 170, "&ordf;");
Reg_char(rv, 186, "&ordm;");
Reg_char(rv, 216, "&Oslash;");
Reg_char(rv, 248, "&oslash;");
Reg_char(rv, 213, "&Otilde;");
Reg_char(rv, 245, "&otilde;");
Reg_char(rv, 8855, "&otimes;");
Reg_char(rv, 214, "&Ouml;");
Reg_char(rv, 246, "&ouml;");
Reg_char(rv, 182, "&para;");
Reg_char(rv, 8706, "&part;");
Reg_char(rv, 8240, "&permil;");
Reg_char(rv, 8869, "&perp;");
Reg_char(rv, 934, "&Phi;");
Reg_char(rv, 966, "&phi;");
Reg_char(rv, 928, "&Pi;");
Reg_char(rv, 960, "&pi;");
Reg_char(rv, 982, "&piv;");
Reg_char(rv, 177, "&plusmn;");
Reg_char(rv, 163, "&pound;");
Reg_char(rv, 8242, "&prime;");
Reg_char(rv, 8243, "&Prime;");
Reg_char(rv, 8719, "&prod;");
Reg_char(rv, 8733, "&prop;");
Reg_char(rv, 936, "&Psi;");
Reg_char(rv, 968, "&psi;");
Reg_char(rv, 34, "&quot;");
Reg_char(rv, 8730, "&radic;");
Reg_char(rv, 9002, "&rang;");
Reg_char(rv, 187, "&raquo;");
Reg_char(rv, 8594, "&rarr;");
Reg_char(rv, 8658, "&rArr;");
Reg_char(rv, 8969, "&rceil;");
Reg_char(rv, 8221, "&rdquo;");
Reg_char(rv, 8476, "&real;");
Reg_char(rv, 174, "&reg;");
Reg_char(rv, 8971, "&rfloor;");
Reg_char(rv, 929, "&Rho;");
Reg_char(rv, 961, "&rho;");
Reg_char(rv, 8207, "&rlm;");
Reg_char(rv, 8250, "&rsaquo;");
Reg_char(rv, 8217, "&rsquo;");
Reg_char(rv, 8218, "&sbquo;");
Reg_char(rv, 352, "&Scaron;");
Reg_char(rv, 353, "&scaron;");
Reg_char(rv, 8901, "&sdot;");
Reg_char(rv, 167, "&sect;");
Reg_char(rv, 173, "&shy;");
Reg_char(rv, 931, "&Sigma;");
Reg_char(rv, 963, "&sigma;");
Reg_char(rv, 962, "&sigmaf;");
Reg_char(rv, 8764, "&sim;");
Reg_char(rv, 9824, "&spades;");
Reg_char(rv, 8834, "&sub;");
Reg_char(rv, 8838, "&sube;");
Reg_char(rv, 8721, "&sum;");
Reg_char(rv, 8835, "&sup;");
Reg_char(rv, 185, "&sup1;");
Reg_char(rv, 178, "&sup2;");
Reg_char(rv, 179, "&sup3;");
Reg_char(rv, 8839, "&supe;");
Reg_char(rv, 223, "&szlig;");
Reg_char(rv, 932, "&Tau;");
Reg_char(rv, 964, "&tau;");
Reg_char(rv, 8756, "&there4;");
Reg_char(rv, 920, "&Theta;");
Reg_char(rv, 952, "&theta;");
Reg_char(rv, 977, "&thetasym;");
Reg_char(rv, 8201, "&thinsp;");
Reg_char(rv, 222, "&THORN;");
Reg_char(rv, 254, "&thorn;");
Reg_char(rv, 732, "&tilde;");
Reg_char(rv, 215, "&times;");
Reg_char(rv, 8482, "&trade;");
Reg_char(rv, 218, "&Uacute;");
Reg_char(rv, 250, "&uacute;");
Reg_char(rv, 8593, "&uarr;");
Reg_char(rv, 8657, "&uArr;");
Reg_char(rv, 219, "&Ucirc;");
Reg_char(rv, 251, "&ucirc;");
Reg_char(rv, 217, "&Ugrave;");
Reg_char(rv, 249, "&ugrave;");
Reg_char(rv, 168, "&uml;");
Reg_char(rv, 978, "&upsih;");
Reg_char(rv, 933, "&Upsilon;");
Reg_char(rv, 965, "&upsilon;");
Reg_char(rv, 220, "&Uuml;");
Reg_char(rv, 252, "&uuml;");
Reg_char(rv, 8472, "&weierp;");
Reg_char(rv, 926, "&Xi;");
Reg_char(rv, 958, "&xi;");
Reg_char(rv, 221, "&Yacute;");
Reg_char(rv, 253, "&yacute;");
Reg_char(rv, 165, "&yen;");
Reg_char(rv, 376, "&Yuml;");
Reg_char(rv, 255, "&yuml;");
Reg_char(rv, 918, "&Zeta;");
Reg_char(rv, 950, "&zeta;");
Reg_char(rv, 8205, "&zwj;");
Reg_char(rv, 8204, "&zwnj;");
Reg_name(rv, Bool_.Y, 60, Bry_xowa_lt);
Reg_name(rv, Bool_.Y, 91, Bry_xowa_brack_bgn);
Reg_name(rv, Bool_.Y, 93, Bry_xowa_brack_end);
Reg_name(rv, Bool_.Y, 124, Bry_xowa_pipe);
Reg_name(rv, Bool_.Y, 39, Bry_xowa_apos);
Reg_name(rv, Bool_.Y, 58, Bry_xowa_colon);
Reg_name(rv, Bool_.Y, 95, Bry_xowa_underline);
Reg_name(rv, Bool_.Y, 42, Bry_xowa_asterisk);
Reg_name(rv, Bool_.Y, 32, Bry_xowa_space);
Reg_name(rv, Bool_.Y, 10, Bry_xowa_nl);
Reg_name(rv, Bool_.N, 39, "&apos;");
Reg_name(rv, Bool_.N, 193, "&Aacute;");
Reg_name(rv, Bool_.N, 225, "&aacute;");
Reg_name(rv, Bool_.N, 194, "&Acirc;");
Reg_name(rv, Bool_.N, 226, "&acirc;");
Reg_name(rv, Bool_.N, 180, "&acute;");
Reg_name(rv, Bool_.N, 198, "&AElig;");
Reg_name(rv, Bool_.N, 230, "&aelig;");
Reg_name(rv, Bool_.N, 192, "&Agrave;");
Reg_name(rv, Bool_.N, 224, "&agrave;");
Reg_name(rv, Bool_.N, 8501, "&alefsym;");
Reg_name(rv, Bool_.N, 913, "&Alpha;");
Reg_name(rv, Bool_.N, 945, "&alpha;");
Reg_name(rv, Bool_.N, 38, "&amp;");
Reg_name(rv, Bool_.N, 8743, "&and;");
Reg_name(rv, Bool_.N, 8736, "&ang;");
Reg_name(rv, Bool_.N, 197, "&Aring;");
Reg_name(rv, Bool_.N, 229, "&aring;");
Reg_name(rv, Bool_.N, 8776, "&asymp;");
Reg_name(rv, Bool_.N, 195, "&Atilde;");
Reg_name(rv, Bool_.N, 227, "&atilde;");
Reg_name(rv, Bool_.N, 196, "&Auml;");
Reg_name(rv, Bool_.N, 228, "&auml;");
Reg_name(rv, Bool_.N, 8222, "&bdquo;");
Reg_name(rv, Bool_.N, 914, "&Beta;");
Reg_name(rv, Bool_.N, 946, "&beta;");
Reg_name(rv, Bool_.N, 166, "&brvbar;");
Reg_name(rv, Bool_.N, 8226, "&bull;");
Reg_name(rv, Bool_.N, 8745, "&cap;");
Reg_name(rv, Bool_.N, 199, "&Ccedil;");
Reg_name(rv, Bool_.N, 231, "&ccedil;");
Reg_name(rv, Bool_.N, 184, "&cedil;");
Reg_name(rv, Bool_.N, 162, "&cent;");
Reg_name(rv, Bool_.N, 935, "&Chi;");
Reg_name(rv, Bool_.N, 967, "&chi;");
Reg_name(rv, Bool_.N, 710, "&circ;");
Reg_name(rv, Bool_.N, 9827, "&clubs;");
Reg_name(rv, Bool_.N, 8773, "&cong;");
Reg_name(rv, Bool_.N, 169, "&copy;");
Reg_name(rv, Bool_.N, 8629, "&crarr;");
Reg_name(rv, Bool_.N, 8746, "&cup;");
Reg_name(rv, Bool_.N, 164, "&curren;");
Reg_name(rv, Bool_.N, 8224, "&dagger;");
Reg_name(rv, Bool_.N, 8225, "&Dagger;");
Reg_name(rv, Bool_.N, 8595, "&darr;");
Reg_name(rv, Bool_.N, 8659, "&dArr;");
Reg_name(rv, Bool_.N, 176, "&deg;");
Reg_name(rv, Bool_.N, 916, "&Delta;");
Reg_name(rv, Bool_.N, 948, "&delta;");
Reg_name(rv, Bool_.N, 9830, "&diams;");
Reg_name(rv, Bool_.N, 247, "&divide;");
Reg_name(rv, Bool_.N, 201, "&Eacute;");
Reg_name(rv, Bool_.N, 233, "&eacute;");
Reg_name(rv, Bool_.N, 202, "&Ecirc;");
Reg_name(rv, Bool_.N, 234, "&ecirc;");
Reg_name(rv, Bool_.N, 200, "&Egrave;");
Reg_name(rv, Bool_.N, 232, "&egrave;");
Reg_name(rv, Bool_.N, 8709, "&empty;");
Reg_name(rv, Bool_.N, 8195, "&emsp;");
Reg_name(rv, Bool_.N, 8194, "&ensp;");
Reg_name(rv, Bool_.N, 917, "&Epsilon;");
Reg_name(rv, Bool_.N, 949, "&epsilon;");
Reg_name(rv, Bool_.N, 8801, "&equiv;");
Reg_name(rv, Bool_.N, 919, "&Eta;");
Reg_name(rv, Bool_.N, 951, "&eta;");
Reg_name(rv, Bool_.N, 208, "&ETH;");
Reg_name(rv, Bool_.N, 240, "&eth;");
Reg_name(rv, Bool_.N, 203, "&Euml;");
Reg_name(rv, Bool_.N, 235, "&euml;");
Reg_name(rv, Bool_.N, 8364, "&euro;");
Reg_name(rv, Bool_.N, 8707, "&exist;");
Reg_name(rv, Bool_.N, 402, "&fnof;");
Reg_name(rv, Bool_.N, 8704, "&forall;");
Reg_name(rv, Bool_.N, 189, "&frac12;");
Reg_name(rv, Bool_.N, 188, "&frac14;");
Reg_name(rv, Bool_.N, 190, "&frac34;");
Reg_name(rv, Bool_.N, 8260, "&frasl;");
Reg_name(rv, Bool_.N, 915, "&Gamma;");
Reg_name(rv, Bool_.N, 947, "&gamma;");
Reg_name(rv, Bool_.N, 8805, "&ge;");
Reg_name(rv, Bool_.N, 62, "&gt;");
Reg_name(rv, Bool_.N, 8596, "&harr;");
Reg_name(rv, Bool_.N, 8660, "&hArr;");
Reg_name(rv, Bool_.N, 9829, "&hearts;");
Reg_name(rv, Bool_.N, 8230, "&hellip;");
Reg_name(rv, Bool_.N, 205, "&Iacute;");
Reg_name(rv, Bool_.N, 237, "&iacute;");
Reg_name(rv, Bool_.N, 206, "&Icirc;");
Reg_name(rv, Bool_.N, 238, "&icirc;");
Reg_name(rv, Bool_.N, 161, "&iexcl;");
Reg_name(rv, Bool_.N, 204, "&Igrave;");
Reg_name(rv, Bool_.N, 236, "&igrave;");
Reg_name(rv, Bool_.N, 8465, "&image;");
Reg_name(rv, Bool_.N, 8734, "&infin;");
Reg_name(rv, Bool_.N, 8747, "&int;");
Reg_name(rv, Bool_.N, 921, "&Iota;");
Reg_name(rv, Bool_.N, 953, "&iota;");
Reg_name(rv, Bool_.N, 191, "&iquest;");
Reg_name(rv, Bool_.N, 8712, "&isin;");
Reg_name(rv, Bool_.N, 207, "&Iuml;");
Reg_name(rv, Bool_.N, 239, "&iuml;");
Reg_name(rv, Bool_.N, 922, "&Kappa;");
Reg_name(rv, Bool_.N, 954, "&kappa;");
Reg_name(rv, Bool_.N, 923, "&Lambda;");
Reg_name(rv, Bool_.N, 955, "&lambda;");
Reg_name(rv, Bool_.N, 9001, "&lang;");
Reg_name(rv, Bool_.N, 171, "&laquo;");
Reg_name(rv, Bool_.N, 8592, "&larr;");
Reg_name(rv, Bool_.N, 8656, "&lArr;");
Reg_name(rv, Bool_.N, 8968, "&lceil;");
Reg_name(rv, Bool_.N, 8220, "&ldquo;");
Reg_name(rv, Bool_.N, 8804, "&le;");
Reg_name(rv, Bool_.N, 8970, "&lfloor;");
Reg_name(rv, Bool_.N, 8727, "&lowast;");
Reg_name(rv, Bool_.N, 9674, "&loz;");
Reg_name(rv, Bool_.N, 8206, "&lrm;");
Reg_name(rv, Bool_.N, 8249, "&lsaquo;");
Reg_name(rv, Bool_.N, 8216, "&lsquo;");
Reg_name(rv, Bool_.N, 60, "&lt;");
Reg_name(rv, Bool_.N, 175, "&macr;");
Reg_name(rv, Bool_.N, 8212, "&mdash;");
Reg_name(rv, Bool_.N, 181, "&micro;");
Reg_name(rv, Bool_.N, 183, "&middot;");
Reg_name(rv, Bool_.N, 8722, "&minus;");
Reg_name(rv, Bool_.N, 924, "&Mu;");
Reg_name(rv, Bool_.N, 956, "&mu;");
Reg_name(rv, Bool_.N, 8711, "&nabla;");
Reg_name(rv, Bool_.N, 160, "&nbsp;");
Reg_name(rv, Bool_.N, 8211, "&ndash;");
Reg_name(rv, Bool_.N, 8800, "&ne;");
Reg_name(rv, Bool_.N, 8715, "&ni;");
Reg_name(rv, Bool_.N, 172, "&not;");
Reg_name(rv, Bool_.N, 8713, "&notin;");
Reg_name(rv, Bool_.N, 8836, "&nsub;");
Reg_name(rv, Bool_.N, 209, "&Ntilde;");
Reg_name(rv, Bool_.N, 241, "&ntilde;");
Reg_name(rv, Bool_.N, 925, "&Nu;");
Reg_name(rv, Bool_.N, 957, "&nu;");
Reg_name(rv, Bool_.N, 211, "&Oacute;");
Reg_name(rv, Bool_.N, 243, "&oacute;");
Reg_name(rv, Bool_.N, 212, "&Ocirc;");
Reg_name(rv, Bool_.N, 244, "&ocirc;");
Reg_name(rv, Bool_.N, 338, "&OElig;");
Reg_name(rv, Bool_.N, 339, "&oelig;");
Reg_name(rv, Bool_.N, 210, "&Ograve;");
Reg_name(rv, Bool_.N, 242, "&ograve;");
Reg_name(rv, Bool_.N, 8254, "&oline;");
Reg_name(rv, Bool_.N, 937, "&Omega;");
Reg_name(rv, Bool_.N, 969, "&omega;");
Reg_name(rv, Bool_.N, 927, "&Omicron;");
Reg_name(rv, Bool_.N, 959, "&omicron;");
Reg_name(rv, Bool_.N, 8853, "&oplus;");
Reg_name(rv, Bool_.N, 8744, "&or;");
Reg_name(rv, Bool_.N, 170, "&ordf;");
Reg_name(rv, Bool_.N, 186, "&ordm;");
Reg_name(rv, Bool_.N, 216, "&Oslash;");
Reg_name(rv, Bool_.N, 248, "&oslash;");
Reg_name(rv, Bool_.N, 213, "&Otilde;");
Reg_name(rv, Bool_.N, 245, "&otilde;");
Reg_name(rv, Bool_.N, 8855, "&otimes;");
Reg_name(rv, Bool_.N, 214, "&Ouml;");
Reg_name(rv, Bool_.N, 246, "&ouml;");
Reg_name(rv, Bool_.N, 182, "&para;");
Reg_name(rv, Bool_.N, 8706, "&part;");
Reg_name(rv, Bool_.N, 8240, "&permil;");
Reg_name(rv, Bool_.N, 8869, "&perp;");
Reg_name(rv, Bool_.N, 934, "&Phi;");
Reg_name(rv, Bool_.N, 966, "&phi;");
Reg_name(rv, Bool_.N, 928, "&Pi;");
Reg_name(rv, Bool_.N, 960, "&pi;");
Reg_name(rv, Bool_.N, 982, "&piv;");
Reg_name(rv, Bool_.N, 177, "&plusmn;");
Reg_name(rv, Bool_.N, 163, "&pound;");
Reg_name(rv, Bool_.N, 8242, "&prime;");
Reg_name(rv, Bool_.N, 8243, "&Prime;");
Reg_name(rv, Bool_.N, 8719, "&prod;");
Reg_name(rv, Bool_.N, 8733, "&prop;");
Reg_name(rv, Bool_.N, 936, "&Psi;");
Reg_name(rv, Bool_.N, 968, "&psi;");
Reg_name(rv, Bool_.N, 34, "&quot;");
Reg_name(rv, Bool_.N, 8730, "&radic;");
Reg_name(rv, Bool_.N, 9002, "&rang;");
Reg_name(rv, Bool_.N, 187, "&raquo;");
Reg_name(rv, Bool_.N, 8594, "&rarr;");
Reg_name(rv, Bool_.N, 8658, "&rArr;");
Reg_name(rv, Bool_.N, 8969, "&rceil;");
Reg_name(rv, Bool_.N, 8221, "&rdquo;");
Reg_name(rv, Bool_.N, 8476, "&real;");
Reg_name(rv, Bool_.N, 174, "&reg;");
Reg_name(rv, Bool_.N, 8971, "&rfloor;");
Reg_name(rv, Bool_.N, 929, "&Rho;");
Reg_name(rv, Bool_.N, 961, "&rho;");
Reg_name(rv, Bool_.N, 8207, "&rlm;");
Reg_name(rv, Bool_.N, 8250, "&rsaquo;");
Reg_name(rv, Bool_.N, 8217, "&rsquo;");
Reg_name(rv, Bool_.N, 8218, "&sbquo;");
Reg_name(rv, Bool_.N, 352, "&Scaron;");
Reg_name(rv, Bool_.N, 353, "&scaron;");
Reg_name(rv, Bool_.N, 8901, "&sdot;");
Reg_name(rv, Bool_.N, 167, "&sect;");
Reg_name(rv, Bool_.N, 173, "&shy;");
Reg_name(rv, Bool_.N, 931, "&Sigma;");
Reg_name(rv, Bool_.N, 963, "&sigma;");
Reg_name(rv, Bool_.N, 962, "&sigmaf;");
Reg_name(rv, Bool_.N, 8764, "&sim;");
Reg_name(rv, Bool_.N, 9824, "&spades;");
Reg_name(rv, Bool_.N, 8834, "&sub;");
Reg_name(rv, Bool_.N, 8838, "&sube;");
Reg_name(rv, Bool_.N, 8721, "&sum;");
Reg_name(rv, Bool_.N, 8835, "&sup;");
Reg_name(rv, Bool_.N, 185, "&sup1;");
Reg_name(rv, Bool_.N, 178, "&sup2;");
Reg_name(rv, Bool_.N, 179, "&sup3;");
Reg_name(rv, Bool_.N, 8839, "&supe;");
Reg_name(rv, Bool_.N, 223, "&szlig;");
Reg_name(rv, Bool_.N, 932, "&Tau;");
Reg_name(rv, Bool_.N, 964, "&tau;");
Reg_name(rv, Bool_.N, 8756, "&there4;");
Reg_name(rv, Bool_.N, 920, "&Theta;");
Reg_name(rv, Bool_.N, 952, "&theta;");
Reg_name(rv, Bool_.N, 977, "&thetasym;");
Reg_name(rv, Bool_.N, 8201, "&thinsp;");
Reg_name(rv, Bool_.N, 222, "&THORN;");
Reg_name(rv, Bool_.N, 254, "&thorn;");
Reg_name(rv, Bool_.N, 732, "&tilde;");
Reg_name(rv, Bool_.N, 215, "&times;");
Reg_name(rv, Bool_.N, 8482, "&trade;");
Reg_name(rv, Bool_.N, 218, "&Uacute;");
Reg_name(rv, Bool_.N, 250, "&uacute;");
Reg_name(rv, Bool_.N, 8593, "&uarr;");
Reg_name(rv, Bool_.N, 8657, "&uArr;");
Reg_name(rv, Bool_.N, 219, "&Ucirc;");
Reg_name(rv, Bool_.N, 251, "&ucirc;");
Reg_name(rv, Bool_.N, 217, "&Ugrave;");
Reg_name(rv, Bool_.N, 249, "&ugrave;");
Reg_name(rv, Bool_.N, 168, "&uml;");
Reg_name(rv, Bool_.N, 978, "&upsih;");
Reg_name(rv, Bool_.N, 933, "&Upsilon;");
Reg_name(rv, Bool_.N, 965, "&upsilon;");
Reg_name(rv, Bool_.N, 220, "&Uuml;");
Reg_name(rv, Bool_.N, 252, "&uuml;");
Reg_name(rv, Bool_.N, 8472, "&weierp;");
Reg_name(rv, Bool_.N, 926, "&Xi;");
Reg_name(rv, Bool_.N, 958, "&xi;");
Reg_name(rv, Bool_.N, 221, "&Yacute;");
Reg_name(rv, Bool_.N, 253, "&yacute;");
Reg_name(rv, Bool_.N, 165, "&yen;");
Reg_name(rv, Bool_.N, 376, "&Yuml;");
Reg_name(rv, Bool_.N, 255, "&yuml;");
Reg_name(rv, Bool_.N, 918, "&Zeta;");
Reg_name(rv, Bool_.N, 950, "&zeta;");
Reg_name(rv, Bool_.N, 8205, "&zwj;");
Reg_name(rv, Bool_.N, 8204, "&zwnj;");
Reg_prefix(rv, Xop_amp_trie_itm.Tid_num_hex, "#x");
Reg_prefix(rv, Xop_amp_trie_itm.Tid_num_hex, "#X");
Reg_prefix(rv, Xop_amp_trie_itm.Tid_num_dec, "#");
return rv;
}
private static void Reg_char(Btrie_slim_mgr trie, int char_int, String xml_name_str) {
byte[] xml_name_bry = Bry_.new_ascii_(xml_name_str);
Xop_amp_trie_itm itm = new Xop_amp_trie_itm(Xop_amp_trie_itm.Tid_name, char_int, xml_name_bry);
private static void Reg_name(Btrie_slim_mgr trie, boolean tid_is_xowa, int char_int, String xml_name_str) {Reg_name(trie, tid_is_xowa, char_int, Bry_.new_ascii_(xml_name_str));}
private static void Reg_name(Btrie_slim_mgr trie, boolean tid_is_xowa, int char_int, byte[] xml_name_bry) {
byte itm_tid = tid_is_xowa ? Xop_amp_trie_itm.Tid_name_xowa : Xop_amp_trie_itm.Tid_name_std;
Xop_amp_trie_itm itm = new Xop_amp_trie_itm(itm_tid, char_int, xml_name_bry);
byte[] key = Bry_.Mid(xml_name_bry, 1, xml_name_bry.length); // ignore & for purpose of trie; EX: "amp;"; NOTE: must keep trailing ";" else "&amp " will be valid;
trie.Add_obj(key, itm);
}

View File

@ -16,8 +16,8 @@ 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.parsers.amps; import gplx.*; import gplx.xowa.*; import gplx.xowa.parsers.*;
import gplx.xowa.html.lnkis.*;
public class Xop_amp_trie_itm {
import gplx.html.*; import gplx.xowa.html.lnkis.*;
public class Xop_amp_trie_itm {
public Xop_amp_trie_itm(byte tid, int char_int, byte[] xml_name_bry) {
this.tid = tid;
this.char_int = char_int;
@ -25,23 +25,34 @@ public class Xop_amp_trie_itm {
this.xml_name_bry = xml_name_bry;
this.key_name_len = xml_name_bry.length - 2; // 2 for & and ;
}
public byte Tid() {return tid;} private byte tid;
public int Char_int() {return char_int;} private int char_int; // val; EX: 160
public byte[] Utf8_bry() {return utf8_bry;} private byte[] utf8_bry; // EX: new byte[] {192, 160}; (C2, A0)
public byte[] Xml_name_bry() {return xml_name_bry;} private byte[] xml_name_bry; // EX: "&nbsp;"
public int Key_name_len() {return key_name_len;} private int key_name_len; // EX: "nbsp".Len
public void Print_to_html(Bry_bfr bfr) { // EX: "&#160;"
public byte Tid() {return tid;} private final byte tid;
public int Char_int() {return char_int;} private final int char_int; // val; EX: 160
public byte[] Utf8_bry() {return utf8_bry;} private final byte[] utf8_bry; // EX: new byte[] {192, 160}; (C2, A0)
public byte[] Xml_name_bry() {return xml_name_bry;} private final byte[] xml_name_bry; // EX: "&nbsp;"
public int Key_name_len() {return key_name_len;} private final int key_name_len; // EX: "nbsp".Len
public void Print_ncr(Bry_bfr bfr) {
switch (char_int) {
case Byte_ascii.Lt: case Byte_ascii.Gt: case Byte_ascii.Quote: case Byte_ascii.Amp:
bfr.Add(xml_name_bry); // NOTE: never write actual char; EX: "&lt;" should be written as "&lt;", not "<"
bfr.Add(xml_name_bry); // NOTE: never write actual char; EX: "&lt;" should be written as "&lt;", not "<"
break;
default:
bfr.Add(Xoh_lnki_title_fmtr.Escape_bgn); // &#
bfr.Add_int_variable(char_int); // 160
bfr.Add_byte(Byte_ascii.Semic); // ;
bfr.Add(Xoh_lnki_title_fmtr.Escape_bgn); // &#
bfr.Add_int_variable(char_int); // 160
bfr.Add_byte(Byte_ascii.Semic); // ;
break;
}
}
public static final byte Tid_name = 1, Tid_num_hex = 2, Tid_num_dec = 3;
public void Print_literal(Bry_bfr bfr) {
switch (char_int) {
case Byte_ascii.Lt: bfr.Add(Html_entity_.Lt_bry); break; // NOTE: never write actual char; EX: "&lt;" should be written as "&lt;", not "<"; MW does same; DATE:2014-11-07
case Byte_ascii.Gt: bfr.Add(Html_entity_.Gt_bry); break;
case Byte_ascii.Quote: bfr.Add(Html_entity_.Quote_bry); break;
case Byte_ascii.Amp: bfr.Add(Html_entity_.Amp_bry); break;
default:
bfr.Add(utf8_bry); // write literal; EX: "[" not "&#91;"
break;
}
}
public static final byte Tid_name_std = 1, Tid_name_xowa = 2, Tid_num_hex = 3, Tid_num_dec = 4;
public static final int Char_int_null = -1;
}

View File

@ -32,4 +32,10 @@ public class Xop_amp_wkr_tst {
, "<a href=\"/wiki/File:A.png\" class=\"image\" xowa_title=\"A.png\"><img id=\"xowa_file_img_0\" alt=\"&#10;\" src=\"file:///mem/wiki/repo/trg/orig/7/0/A.png\" width=\"0\" height=\"0\" /></a>"
);
}
@Test public void Ignore_ncr() { // PURPOSE: check that ncr is unescaped; PAGE:de.w:Cross-Site-Scripting; DATE:2014-07-23
fxt.Test_parse_page_all_str
( "a <code>&#60;iframe&#62;</code>) b"
, "a <code>&#60;iframe&#62;</code>) b" // &#60; should not become <
);
}
}

View File

@ -126,7 +126,7 @@ public class Xop_apos_wkr_tst {
fxt.Test_parse_page_all_str("A ''[[b!!]]'' c", "A <i><a href=\"/wiki/B!!\">b!!</a></i> c");
}
@Test public void Nowiki() { // PAGE:en.w:Wiki; DATE:2013-05-13
fxt.Test_parse_page_all_str("<nowiki>''a''</nowiki>", "&#39;&#39;a&#39;&#39;");
fxt.Test_parse_page_all_str("<nowiki>''a''</nowiki>", "''a''");
}
@Test public void Lnki_multi_line() { // PURPOSE: handle apos within multi-line lnki caption; DATE:2013-11-10
fxt.Test_parse_page_all_str(String_.Concat_lines_nl_skip_last

View File

@ -16,7 +16,7 @@ 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.parsers.tmpls; import gplx.*; import gplx.xowa.*; import gplx.xowa.parsers.*;
import gplx.core.btries.*; import gplx.html.*;
import gplx.core.btries.*; import gplx.html.*; import gplx.xowa.parsers.amps.*;
public class Nowiki_escape_itm {
public Nowiki_escape_itm(byte[] src, byte[] trg) {this.src = src; this.trg = trg; this.src_adj = src.length - 1;}
private int src_adj;
@ -47,19 +47,19 @@ public class Nowiki_escape_itm {
private static final Btrie_slim_mgr trie = trie_new();
private static Btrie_slim_mgr trie_new() {
Btrie_slim_mgr rv = Btrie_slim_mgr.cs_();
trie_new_itm(rv, Byte_ascii.Lt_bry , Html_entity_.Lt_bry);
trie_new_itm(rv, Byte_ascii.Brack_bgn_bry , Html_entity_.Brack_bgn_bry);
trie_new_itm(rv, Byte_ascii.Brack_end_bry , Html_entity_.Brack_end_bry); // PAGE:en.w: Tall_poppy_syndrome DATE:2014-07-23
trie_new_itm(rv, Byte_ascii.Pipe_bry , Html_entity_.Pipe_bry);
trie_new_itm(rv, Byte_ascii.Apos_bry , Html_entity_.Apos_key_bry); // NOTE: for backward compatibility, use &apos; note that amp_wkr will turn &apos; -> &#39 but &#39 -> '; DATE:2014-07-03
trie_new_itm(rv, Byte_ascii.Colon_bry , Html_entity_.Colon_bry);
trie_new_itm(rv, Byte_ascii.Underline_bry , Html_entity_.Underline_bry);
trie_new_itm(rv, Byte_ascii.Asterisk_bry , Html_entity_.Asterisk_bry);
trie_new_itm(rv, Byte_ascii.Space_bry , Html_entity_.Space_bry);
trie_new_itm(rv, Byte_ascii.NewLine_bry , Html_entity_.Nl_bry);
trie_new_itm(rv, Byte_ascii.Lt_bry , Xop_amp_trie.Bry_xowa_lt);
trie_new_itm(rv, Byte_ascii.Brack_bgn_bry , Xop_amp_trie.Bry_xowa_brack_bgn);
trie_new_itm(rv, Byte_ascii.Brack_end_bry , Xop_amp_trie.Bry_xowa_brack_end); // PAGE:en.w: Tall_poppy_syndrome DATE:2014-07-23
trie_new_itm(rv, Byte_ascii.Pipe_bry , Xop_amp_trie.Bry_xowa_pipe);
trie_new_itm(rv, Byte_ascii.Apos_bry , Xop_amp_trie.Bry_xowa_apos); // NOTE: for backward compatibility, use &apos; note that amp_wkr will turn &apos; -> &#39 but &#39 -> '; DATE:2014-07-03
trie_new_itm(rv, Byte_ascii.Colon_bry , Xop_amp_trie.Bry_xowa_colon);
trie_new_itm(rv, Byte_ascii.Underline_bry , Xop_amp_trie.Bry_xowa_underline);
trie_new_itm(rv, Byte_ascii.Asterisk_bry , Xop_amp_trie.Bry_xowa_asterisk);
trie_new_itm(rv, Byte_ascii.Space_bry , Xop_amp_trie.Bry_xowa_space);
trie_new_itm(rv, Byte_ascii.NewLine_bry , Xop_amp_trie.Bry_xowa_nl);
trie_new_itm(rv, Pre_bry , Pre_bry);
return rv;
}
}
private static void trie_new_itm(Btrie_slim_mgr rv, byte[] src, byte[] trg) {
Nowiki_escape_itm itm = new Nowiki_escape_itm(src, trg);
rv.Add_obj(src, itm);

View File

@ -169,12 +169,17 @@ public class Xow_xwiki_mgr implements GfoInvkAble {
} private static final String GRP_KEY = "xowa.wiki.xwikis";
public void Add_itm(Xow_xwiki_itm itm) {Add_itm(itm, null);}
private void Add_itm(Xow_xwiki_itm xwiki, Xoac_lang_itm lang) {
byte[] xwiki_key = xwiki.Key_bry();
if ( !hash.Has(xwiki.Key_bry()) // only register xwiki / lang pair once
&& lang != null) // null lang should not be registered
lang_mgr.Itms_reg(xwiki, lang);
hash.AddReplace(xwiki.Key_bry(), xwiki);
list.AddReplace(xwiki.Key_bry(), xwiki);
}
byte[] xwiki_domain = xwiki.Domain();
if (!domain_hash.Has(xwiki_domain)) { // domain is new
domain_hash.Add(xwiki_domain, xwiki_key);
list.AddReplace(xwiki_key, xwiki); // only add to list if domain is new; some wikis like commons will be added multiple times under different aliases (commons, c, commons.wikimedia.org); need to check domain and add only once DATE:2014-11-07
}
hash.AddReplace(xwiki_key, xwiki);
} private final Hash_adp_bry domain_hash = Hash_adp_bry.ci_ascii_();
public void Add_many(byte[] v) {srl.Load_by_bry(v);}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_count)) return list.Count();

View File

@ -38,6 +38,9 @@ public class Xow_xwiki_mgr_tst {
@Test public void Add_bulk_peers_tid() { // PURPOSE:wikt should generate wiki_tid of wiktionary, not wikipedia; PAGE:en.s:Main_Page DATE:2014-09-14
fxt.Init_wikt ().Test_add_bulk_peers("peer", fxt.xwiki_("wikt", "en.wiktionary.org", "http://en.wiktionary.org/wiki/~{0}"));
}
@Test public void Multiple_aliases_should_only_add_once() { // PURPOSE.FIX: multiple aliases for same domain should only be added once to Get_at's list; DATE:2014-11-07
fxt.Exec_add_bulk("a1|a.org\na2|a.org").Test_len(1);
}
}
class Xow_xwiki_mgr_fxt {
Xow_xwiki_mgr xwiki_mgr; Xoa_lang_mgr lang_mgr; String_bldr sb = String_bldr_.new_(); Xoa_app app; Xow_wiki wiki;
@ -109,6 +112,8 @@ class Xow_xwiki_mgr_fxt {
Tfds.Eq_str_lines(Xto_str(itms), Xto_str(Xto_ary(itms)));
return this;
}
public Xow_xwiki_mgr_fxt Exec_add_bulk(String raw) {xwiki_mgr.Add_bulk(Bry_.new_utf8_(raw)); return this;}
public Xow_xwiki_mgr_fxt Test_len(int expd) {Tfds.Eq(expd, xwiki_mgr.Len()); return this;}
Xow_xwiki_itm[] Xto_ary(Xow_xwiki_itm[] itms) {
int len = itms.length;
ListAdp rv = ListAdp_.new_();

View File

@ -17,7 +17,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.xtns; import gplx.*; import gplx.xowa.*;
import gplx.core.btries.*;
import gplx.xowa.xtns.cite.*; import gplx.xowa.xtns.imaps.*; import gplx.xowa.xtns.relatedSites.*; import gplx.xowa.xtns.insiders.*; import gplx.xowa.xtns.proofreadPage.*; import gplx.xowa.xtns.wdatas.*;
import gplx.xowa.xtns.cite.*; import gplx.xowa.xtns.imaps.*; import gplx.xowa.xtns.relatedSites.*; import gplx.xowa.xtns.proofreadPage.*; import gplx.xowa.xtns.wdatas.*;
import gplx.xowa.xtns.insiders.*; import gplx.xowa.xtns.indicators.*;
public class Xow_xtn_mgr implements GfoInvkAble {
private OrderedHash regy = OrderedHash_.new_bry_();
public int Count() {return regy.Count();}
@ -25,6 +26,7 @@ public class Xow_xtn_mgr implements GfoInvkAble {
public Imap_xtn_mgr Xtn_imap() {return xtn_imap;} private Imap_xtn_mgr xtn_imap;
public Sites_xtn_mgr Xtn_sites() {return xtn_sites;} private Sites_xtn_mgr xtn_sites;
public Insider_xtn_mgr Xtn_insider() {return xtn_insider;} private Insider_xtn_mgr xtn_insider;
public Indicator_xtn_mgr Xtn_indicator() {return xtn_indicator;} private Indicator_xtn_mgr xtn_indicator;
public Pp_xtn_mgr Xtn_proofread() {return xtn_proofread;} private Pp_xtn_mgr xtn_proofread;
public Wdata_xtn_mgr Xtn_wikibase() {return xtn_wikibase;} private Wdata_xtn_mgr xtn_wikibase;
public Xow_xtn_mgr Ctor_by_app(Xoa_app app) { // NOTE: needed for options
@ -32,6 +34,7 @@ public class Xow_xtn_mgr implements GfoInvkAble {
Add(app, new Imap_xtn_mgr());
Add(app, new Sites_xtn_mgr());
Add(app, new Insider_xtn_mgr());
Add(app, new Indicator_xtn_mgr());
Add(app, new Pp_xtn_mgr());
Add(app, new Wdata_xtn_mgr());
Add(app, new gplx.xowa.xtns.scribunto.Scrib_xtn_mgr());
@ -87,16 +90,18 @@ public class Xow_xtn_mgr implements GfoInvkAble {
case Tid_cite: xtn_cite = (Cite_xtn_mgr)mgr; break;
case Tid_sites: xtn_sites = (Sites_xtn_mgr)mgr; break;
case Tid_insider: xtn_insider = (Insider_xtn_mgr)mgr; break;
case Tid_indicator: xtn_indicator= (Indicator_xtn_mgr)mgr; break;
case Tid_imap: xtn_imap = (Imap_xtn_mgr)mgr; break;
case Tid_proofread: xtn_proofread = (Pp_xtn_mgr)mgr; break;
case Tid_wikibase: xtn_wikibase = (Wdata_xtn_mgr)mgr; break;
}
}
private static final byte Tid_cite = 0, Tid_sites = 1, Tid_insider = 2, Tid_imap = 3, Tid_proofread = 4, Tid_wikibase = 5;
private static final byte Tid_cite = 0, Tid_sites = 1, Tid_insider = 2, Tid_imap = 3, Tid_proofread = 4, Tid_wikibase = 5, Tid_indicator = 6;
private static final Btrie_slim_mgr xtn_tid_trie = Btrie_slim_mgr.cs_()
.Add_bry_bval(Cite_xtn_mgr.XTN_KEY , Tid_cite)
.Add_bry_bval(Sites_xtn_mgr.XTN_KEY , Tid_sites)
.Add_bry_bval(Insider_xtn_mgr.XTN_KEY , Tid_insider)
.Add_bry_bval(Indicator_xtn_mgr.XTN_KEY , Tid_indicator)
.Add_bry_bval(Imap_xtn_mgr.XTN_KEY , Tid_imap)
.Add_bry_bval(Pp_xtn_mgr.XTN_KEY , Tid_proofread)
.Add_bry_bval(Wdata_xtn_mgr.XTN_KEY , Tid_wikibase)

View File

@ -50,7 +50,7 @@ public class References_nde implements Xox_xnde, Xop_xnde_atr_parser {
public void Xtn_write(Bry_bfr bfr, Xoa_app app, Xop_ctx ctx, Xoh_html_wtr html_wtr, Xoh_wtr_ctx hctx, Xop_xnde_tkn xnde, byte[] src) {
html_wtr.Ref_wtr().Xnde_references(html_wtr, ctx, hctx, bfr, src, xnde);
}
public static final byte Xatr_id_group = 0;
private static final byte Xatr_id_group = 0;
public static boolean Enabled = true;
private static final Hash_adp_bry xatrs_hash = Hash_adp_bry.ci_ascii_()
.Add_str_obj("group", Byte_obj_val.new_(References_nde.Xatr_id_group));

View File

@ -32,11 +32,15 @@ public class Imap_map implements Xoh_file_img_wkr, Js_img_wkr {
@gplx.Internal protected Imap_itm_desc Desc() {return desc;} private Imap_itm_desc desc;
@gplx.Internal protected Imap_itm_shape[] Shapes() {return shapes;} private Imap_itm_shape[] shapes;
@gplx.Internal protected Imap_err[] Errs() {return errs;} private Imap_err[] errs;
private byte[] a_href, img_alt, img_cls;
public void Html_full_img(Bry_bfr tmp_bfr, Xoh_wtr_ctx hctx, Xoa_page page, Xof_xfer_itm xfer_itm, int uid, byte[] a_href, byte[] a_class, byte[] a_rel, byte[] a_title, byte[] a_xowa_title, int img_w, int img_h, byte[] img_src, byte[] img_alt, byte[] img_cls) {
private byte img_cls_tid;
private byte[] a_href, img_alt, img_cls_other;
public void Html_full_img(Bry_bfr tmp_bfr, Xoh_wtr_ctx hctx, Xoa_page page, Xof_xfer_itm xfer_itm, int uid
, byte[] a_href, byte a_cls, byte a_rel, byte[] a_title, byte[] a_xowa_title
, int img_w, int img_h, byte[] img_src, byte[] img_alt, byte img_cls, byte[] img_cls_other
) {
xfer_itm.Html_img_wkr_(this);
xfer_itm.Html_elem_tid_(Xof_html_elem.Tid_imap);
this.a_href = a_href; this.img_alt = img_alt; this.img_cls = img_cls;
this.a_href = a_href; this.img_alt = img_alt; this.img_cls_tid = img_cls; this.img_cls_other = img_cls_other;
Write_imap_div(tmp_bfr, page, hctx, uid, img_w, img_h, img_src, xfer_itm.Orig_w(), xfer_itm.Orig_h(), xfer_itm.Lnki_ttl());
}
public void Html_update(Xoa_page page, Xog_html_itm html_itm, int html_uid, int html_w, int html_h, String html_src, int orig_w, int orig_h, String orig_src, byte[] lnki_ttl) {
@ -48,7 +52,7 @@ public class Imap_map implements Xoh_file_img_wkr, Js_img_wkr {
private void Write_imap_div(Bry_bfr bfr, Xoa_page page, Xoh_wtr_ctx hctx, int html_uid, int html_w, int html_h, byte[] html_src, int orig_w, int orig_h, byte[] lnki_ttl) {
byte[] desc_style = Calc_desc_style(html_w, html_h);
map_fmtr_arg.Init(id, shapes, Calc_scale(orig_w, orig_h, html_w, html_h));
img_fmtr_arg.Init(page, hctx, xtn_mgr, this, html_uid, img_alt, html_src, html_w, html_h, img_cls, a_href, lnki_ttl);
img_fmtr_arg.Init(page, hctx, xtn_mgr, this, html_uid, img_alt, html_src, html_w, html_h, Xoh_lnki_consts.Img_cls_to_bry(img_cls_tid, img_cls_other), a_href, lnki_ttl);
Imap_html_fmtrs.All.Bld_bfr_many(bfr, html_uid, desc_style, map_fmtr_arg, img_fmtr_arg);
}
private byte[] Calc_desc_style(int html_w, int html_h) {

View File

@ -0,0 +1,51 @@
/*
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.xtns.indicators; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
public class Indicator_html_bldr implements Bry_fmtr_arg {
private Indicator_html_bldr_itm bldr_itm = new Indicator_html_bldr_itm();
private ListAdp list = ListAdp_.new_();
public void Add(Indicator_xnde xnde) {list.Add(xnde);}
public void XferAry(Bry_bfr bfr, int idx) {
bldr_itm.Init(list);
fmtr_grp.Bld_bfr_many(bfr, bldr_itm);
}
private static final Bry_fmtr
fmtr_grp = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last
( ""
, " <div class='mw-indicators'>~{itms}"
, " </div>"
), "itms")
;
}
class Indicator_html_bldr_itm implements Bry_fmtr_arg {
private ListAdp list;
public void Init(ListAdp list) {this.list = list;}
public void XferAry(Bry_bfr bfr, int idx) {
int list_len = list.Count();
for (int i = 0; i < list_len; ++i) {
Indicator_xnde xnde = (Indicator_xnde)list.FetchAt(i);
fmtr_itm.Bld_bfr(bfr, xnde.Name(), xnde.Html());
}
}
private static final Bry_fmtr
fmtr_itm = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last
( ""
, " <div class='mw-indicator-~{name}' class='mw-indicator'>~{html}</div>"
), "name", "html")
;
}

View File

@ -0,0 +1,55 @@
/*
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.xtns.indicators; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
import org.junit.*; import gplx.xowa.xtns.indicators.*;
public class Indicator_html_bldr_tst {
@Before public void init() {fxt.Clear();} private Indicator_html_bldr_fxt fxt = new Indicator_html_bldr_fxt();
@Test public void Basic() {
fxt.Init_indicator("a", "b");
fxt.Test_bld(String_.Concat_lines_nl_skip_last
( ""
, " <div class='mw-indicators'>"
, " <div class='mw-indicator-a' class='mw-indicator'>b</div>"
, " </div>"
));
}
}
class Indicator_html_bldr_fxt {
private Xoa_app app; private Xow_wiki wiki; private Xoa_page page;
private Indicator_xtn_mgr xtn_mgr;
public void Clear() {
this.app = Xoa_app_fxt.app_();
this.wiki = Xoa_app_fxt.wiki_tst_(app);
this.xtn_mgr = wiki.Xtn_mgr().Xtn_indicator();
xtn_mgr.Enabled_y_();
xtn_mgr.Xtn_init_by_wiki(wiki);
this.page = wiki.Ctx().Cur_page();
}
public void Init_indicator(String name, String html) {
Indicator_xnde xnde = new Indicator_xnde();
xnde.Init_for_test(Bry_.new_utf8_(name), Bry_.new_utf8_(html));
Indicator_html_bldr indicators = new Indicator_html_bldr();
indicators.Add(xnde);
page.Html_data().Indicators_(indicators);
}
public void Test_bld(String expd) {
Bry_bfr tmp_bfr = Bry_bfr.reset_(255);
page.Html_data().Indicators().XferAry(tmp_bfr, 0);
Tfds.Eq_str_lines(expd, tmp_bfr.Xto_str_and_clear());
}
}

View File

@ -0,0 +1,46 @@
/*
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.xtns.indicators; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
import gplx.xowa.html.*; import gplx.xowa.pages.skins.*;
public class Indicator_xnde implements Xox_xnde, Xop_xnde_atr_parser {
public byte[] Name() {return name;} private byte[] name;
public byte[] Html() {return html;} private byte[] html;
public void Init_for_test(byte[] name, byte[] html) {this.name = name; this.html = html;} // TEST
public void Xatr_parse(Xow_wiki wiki, byte[] src, Xop_xatr_itm xatr, Object xatr_key_obj) {
if (xatr_key_obj == null) return;
Byte_obj_val xatr_key = (Byte_obj_val)xatr_key_obj;
switch (xatr_key.Val()) {
case Xatr_name: name = xatr.Val_as_bry(src); break;
}
}
public void Xtn_parse(Xow_wiki wiki, Xop_ctx ctx, Xop_root_tkn root, byte[] src, Xop_xnde_tkn xnde) {
Xop_xatr_itm.Xatr_parse(wiki.App(), this, xatrs_hash, wiki, src, xnde);
html = wiki.Parser().Parse_text_to_html(ctx, Bry_.Mid(src, xnde.Tag_open_end(), xnde.Tag_close_bgn()));
Indicator_html_bldr html_bldr = ctx.Cur_page().Html_data().Indicators();
if (html_bldr == null) {
html_bldr = new Indicator_html_bldr();
ctx.Cur_page().Html_data().Indicators_(html_bldr);
}
html_bldr.Add(this);
}
public void Xtn_write(Bry_bfr bfr, Xoa_app app, Xop_ctx ctx, Xoh_html_wtr html_wtr, Xoh_wtr_ctx hctx, Xop_xnde_tkn xnde, byte[] src) {
}
private static final byte Xatr_name = 0;
private static final Hash_adp_bry xatrs_hash = Hash_adp_bry.ci_ascii_()
.Add_str_obj("name", Byte_obj_val.new_(Xatr_name));
}

View File

@ -0,0 +1,25 @@
/*
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.xtns.indicators; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
import org.junit.*;
public class Indicator_xnde_tst {
@Before public void init() {fxt.Reset();} private Xop_fxt fxt = new Xop_fxt();
@Test public void Basic() {
fxt.Test_parse_page_all_str("<indicator>test</indicator>", "");
}
}

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.xtns.indicators; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
import gplx.html.*; import gplx.xowa.wikis.*;
public class Indicator_xtn_mgr extends Xox_mgr_base {
public Indicator_xtn_mgr() {
}
@Override public boolean Enabled_default() {return false;}
@Override public byte[] Xtn_key() {return XTN_KEY;} public static final byte[] XTN_KEY = Bry_.new_ascii_("Indicator");
@Override public Xox_mgr Clone_new() {return new Indicator_xtn_mgr();}
}

View File

@ -16,7 +16,7 @@ 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.xtns.pfuncs.pages; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.pfuncs.*;
import gplx.xowa.html.*;
import gplx.xowa.html.*; import gplx.xowa.langs.cases.*;
public class Pfunc_displaytitle extends Pf_func_base {
@Override public int Id() {return Xol_kwd_grp_.Id_page_displaytitle;}
@Override public Pf_func New(int id, byte[] name) {return new Pfunc_displaytitle().Name_(name);}
@ -33,15 +33,19 @@ public class Pfunc_displaytitle extends Pf_func_base {
if (restrict) { // restrict only allows displayTitles which have text similar to the pageTitle; PAGE:de.b:Kochbuch/_Druckversion; DATE:2014-08-18
Xoa_page page = ctx.Cur_page();
wiki.Html_mgr().Html_wtr().Write_tkn(tmp_bfr, display_ttl_ctx, Xoh_wtr_ctx.Alt, display_ttl_root.Data_mid(), display_ttl_root, 0, display_ttl_root);
byte[] val_html_as_text_only = tmp_bfr.Xto_bry_and_clear();
gplx.xowa.langs.cases.Xol_case_mgr case_mgr = wiki.Lang().Case_mgr();
val_html_as_text_only = case_mgr.Case_build_lower(val_html_as_text_only);
byte[] page_ttl_lc = case_mgr.Case_build_lower(page.Ttl().Page_txt());
if (!Bry_.Eq(val_html_as_text_only, page_ttl_lc))
byte[] val_html_lc = tmp_bfr.Xto_bry_and_clear();
Xol_case_mgr case_mgr = wiki.Lang().Case_mgr();
val_html_lc = Standardize_displaytitle_text(case_mgr, val_html_lc);
byte[] page_ttl_lc = Standardize_displaytitle_text(case_mgr, page.Ttl().Page_db());
if (!Bry_.Eq(val_html_lc, page_ttl_lc))
val_html = null;
}
ctx.Cur_page().Html_data().Display_ttl_(val_html);
tmp_bfr.Mkr_rls();
}
private static byte[] Standardize_displaytitle_text(Xol_case_mgr case_mgr, byte[] val) {
byte[] rv = case_mgr.Case_build_lower(val); // lower-case
return Bry_.Replace(rv, Byte_ascii.Space, Byte_ascii.Underline); // force underline; PAGE:de.w:Mod_qos DATE:2014-11-06
}
public static final Pfunc_displaytitle _ = new Pfunc_displaytitle(); Pfunc_displaytitle() {}
}

View File

@ -19,11 +19,12 @@ package gplx.xowa.xtns.pfuncs.pages; import gplx.*; import gplx.xowa.*; import g
import org.junit.*;
public class Pfunc_displaytitle_tst {
@Before public void init() {fxt.Reset();} private Pfunc_displaytitle_fxt fxt = new Pfunc_displaytitle_fxt();
@Test public void Basic() {fxt.Init_restrict(Bool_.N).Test("{{DISPLAYTITLE:B A}}" , "B A");}
@Test public void Apos_italic() {fxt.Init_restrict(Bool_.N).Test("{{DISPLAYTITLE:''B A''}}" , "<i>B A</i>");}
@Test public void Restrict_skip() {fxt.Init_restrict(Bool_.Y).Test("{{DISPLAYTITLE:B A}}" , null);} // PURPOSE: skip if text does not match title; PAGE:de.b:Kochbuch/_Druckversion; DATE:2014-08-18
@Test public void Restrict_keep_ci() {fxt.Init_restrict(Bool_.Y).Test("{{DISPLAYTITLE:a B}}" , "a B");} // PURPOSE: keep b/c case-insensitiv match; DATE:2014-08-18
@Test public void Restrict_keep_tags() {fxt.Init_restrict(Bool_.Y).Test("{{DISPLAYTITLE:<b>a</b> <i>B</i>}}" , "<b>a</b> <i>B</i>");}// PURPOSE: keep b/c text match (tags ignored); DATE:2014-08-18
@Test public void Basic() {fxt.Init_restrict(Bool_.N).Test("{{DISPLAYTITLE:B A}}" , "B A");}
@Test public void Apos_italic() {fxt.Init_restrict(Bool_.N).Test("{{DISPLAYTITLE:''B A''}}" , "<i>B A</i>");}
@Test public void Restrict_skip() {fxt.Init_restrict(Bool_.Y).Test("{{DISPLAYTITLE:B A}}" , null);} // PURPOSE: skip if text does not match title; PAGE:de.b:Kochbuch/_Druckversion; DATE:2014-08-18
@Test public void Restrict_keep_ci() {fxt.Init_restrict(Bool_.Y).Test("{{DISPLAYTITLE:a B}}" , "a B");} // PURPOSE: keep b/c case-insensitive match; DATE:2014-08-18
@Test public void Restrict_keep_underscore() {fxt.Init_restrict(Bool_.Y).Test("{{DISPLAYTITLE:a_b}}" , "a_b");} // PURPOSE: keep b/c underscores should match spaces; PAGE:de.w:Mod_qos DATE:2014-11-06
@Test public void Restrict_keep_tags() {fxt.Init_restrict(Bool_.Y).Test("{{DISPLAYTITLE:<b>a</b> <i>B</i>}}" , "<b>a</b> <i>B</i>");}// PURPOSE: keep b/c text match (tags ignored); DATE:2014-08-18
@Test public void Strip_display() {
String expd_fail = "<span style='/* attempt to bypass $wgRestrictDisplayTitle */'>A b</span>";
fxt.Init_restrict(Bool_.Y);

View File

@ -258,11 +258,11 @@ public class Poem_nde_tst {
, "<p>"
, "a<br/>"
, "b<br/>"
, " <div class=\"poem\">"
, "&#32;<div class=\"poem\">"
, "<p>"
, "c<br/>" // NOTE: "<br/>" not "<br/><br/>"
, "d<br/>"
, " "
, "&#32;"
, "</p>"
, "</div>"
, "</p>"

View File

@ -350,7 +350,7 @@ public class Pp_pages_nde implements Xox_xnde, Xop_xnde_atr_parser {
lst_pfunc_wkr.Init_include(ttl.Full_db(), cur_sect_bgn, cur_sect_end).Exec(page_bfr, ctx);
prepend_mgr.End(ctx, full_bfr, page_bfr.Bfr(), page_bfr.Len(), Bool_.Y);
full_bfr.Add_bfr_and_clear(page_bfr);
full_bfr.Add(gplx.html.Html_entity_.Space_bry);
full_bfr.Add(gplx.html.Html_entity_.Space_bry); // $out.= "&#32;"; REF.MW:ProofreadPageRenderer.pn
}
page_bfr.Mkr_rls();
ctx.Tmpl_output_(null);

View File

@ -31,7 +31,7 @@ public class Pp_pages_nde_basic_tst {
@Test public void Basic() {
fxt.Init_page_create("Page:A/1", "abc");
fxt.Test_parse_page_wiki_str("<pages index=\"A\" from=1 to=1 />", String_.Concat_lines_nl
( "<p>abc "
( "<p>abc&#32;"
, "</p>"
, ""
));
@ -41,7 +41,7 @@ public class Pp_pages_nde_basic_tst {
fxt.Init_page_create("Page:A/2", "b");
fxt.Init_page_create("Page:A/3", "c");
fxt.Test_parse_page_wiki_str("<pages index=\"A\" from=1 to=3 />", String_.Concat_lines_nl
( "<p>a b c "
( "<p>a&#32;b&#32;c&#32;"
, "</p>"
, ""
));
@ -51,21 +51,21 @@ public class Pp_pages_nde_basic_tst {
fxt.Init_page_create("Page:A/2", "cd");
fxt.Init_page_create("Page:A/3", "e<section end=\"sect_2\"/>f");
fxt.Test_parse_page_wiki_str("<pages index=\"A\" from=1 to=3 fromsection='sect_0' tosection='sect_2' />", String_.Concat_lines_nl
( "<p>b cd e "
( "<p>b&#32;cd&#32;e&#32;"
, "</p>"
));
}
@Test public void Section__onlyinclude() {
fxt.Init_page_create("Page:A/1", "a<section begin='sect_0'/>b<section end='sect_0'/>c");
fxt.Test_parse_page_wiki_str("<pages index='A' from=1 to=1 onlysection='sect_0' />", String_.Concat_lines_nl
( "<p>b "
( "<p>b&#32;"
, "</p>"
));
}
@Test public void Section__onlyinclude_ignores_from_to() {
fxt.Init_page_create("Page:A/1", "<section begin='sect_a'/>a<section end='sect_a'/><section begin='sect_b'/>b<section end='sect_b'/><section begin='sect_c'/>c<section end='sect_c'/>");
fxt.Test_parse_page_wiki_str("<pages from=1 index='A' onlysection='sect_b' fromsection='sect_a' tosection='sect_c' />", String_.Concat_lines_nl
( "<p>b "
( "<p>b&#32;"
, "</p>"
));
}
@ -80,7 +80,7 @@ public class Pp_pages_nde_basic_tst {
, " </td>"
, " </tr>"
, "</table>"
, " <i>d</i> f "
, "&#32;<i>d</i>&#32;f&#32;"
));
}
@Test public void Err_page_ns_doesnt_exist() {
@ -92,7 +92,7 @@ public class Pp_pages_nde_basic_tst {
@Test public void Subpage() { // PURPOSE: [[/Page]] should be relative to current page; EX: Flatland and [[/First World]]; DATE:2013-04-29
fxt.Init_page_create("Page:A/1", "[[/Sub1|Sub 1]]");
fxt.Test_parse_page_wiki_str("<pages index=\"A\" from=1 to=1 />", String_.Concat_lines_nl
( "<p><a href=\"/wiki/Test_page/Sub1\">Sub 1</a> " // NOTE: / is relative to Page_name (in this case Test_page)
( "<p><a href=\"/wiki/Test_page/Sub1\">Sub 1</a>&#32;" // NOTE: / is relative to Page_name (in this case Test_page)
, "</p>"
));
}

View File

@ -50,7 +50,7 @@ public class Pp_pages_nde_hdr_tst {
fxt.Init_page_create("Page:A/1", "A/1");
// from specified; don't add toc
fxt.Test_parse_page_wiki_str("<pages index='A' from='1'/>", String_.Concat_lines_nl
( "<p>A/1 "
( "<p>A/1&#32;"
, "</p>"
));
}
@ -63,7 +63,7 @@ public class Pp_pages_nde_hdr_tst {
( "<p>value=toc;from=2;to=2;"
, "</p>"
, ""
, "<p>a2 "
, "<p>a2&#32;"
, "</p>"
));
}

View File

@ -39,13 +39,13 @@ public class Pp_pages_nde_index_tst {
, "<pages index=\"D\" from=1 to=1/>"
);
fxt.Test_parse_page_wiki_str(main_txt, String_.Concat_lines_nl
( "<p>abc "
( "<p>abc&#32;"
, "</p>"
, "text_0"
, "<p>d "
, "<p>d&#32;"
, "</p>"
, "text_1"
, "<p>d "
, "<p>d&#32;"
, "</p>"
));
}
@ -65,37 +65,37 @@ public class Pp_pages_nde_index_tst {
fxt.Init_page_create("Page:A_b/5", "A_b/5\n");
fxt.Test_parse_page_wiki_str("<pages index=\"A\" from='A b/2' to='A_b/4' />", String_.Concat_lines_nl
( "<p>A_b/2"
, " A_b/3"
, " A_b/4"
, " "
, "&#32;A_b/3"
, "&#32;A_b/4"
, "&#32;"
, "</p>"
));
fxt.Test_parse_page_wiki_str("<pages index=\"A\" from='A b/2' />", String_.Concat_lines_nl // to missing
( "<p>A_b/2"
, " A_b/3"
, " A_b/4"
, " A_b/5"
, " "
, "&#32;A_b/3"
, "&#32;A_b/4"
, "&#32;A_b/5"
, "&#32;"
, "</p>"
));
fxt.Test_parse_page_wiki_str("<pages index=\"A\" to='A b/4' />", String_.Concat_lines_nl // from missing
( "<p>A_b/1"
, " A_b/2"
, " A_b/3"
, " A_b/4"
, " "
, "&#32;A_b/2"
, "&#32;A_b/3"
, "&#32;A_b/4"
, "&#32;"
, "</p>"
));
}
@Test public void Index_amp_encoded() { // handle ampersand encoded strings; EX: en.s:Team_Work_Wins!; DATE:2014-01-19
fxt.Init_page_create("Index:\"A\"", "[[Page:\"A\"]]");
fxt.Init_page_create("Page:\"A\"", "a");
fxt.Test_parse_page_wiki_str("<pages index=\"&quot;A&quot;\" from='&quot;A&quot;' />", "<p>a \n</p>");
fxt.Test_parse_page_wiki_str("<pages index=\"&quot;A&quot;\" from='&quot;A&quot;' />", "<p>a&#32;\n</p>");
}
@Test public void Index_amp_encoded_num() {// handle num-encoded vals; EX: pl.s:Zarządzenie_Nr_11_Ministra_Finansów_z_dnia_21_lipca_2008_r._w_sprawie_ustanowienia_Dnia_Skarbowości; DATE:2014-05-07
fxt.Init_page_create("Index:\"A\"", "[[Page:\"A\"]]");
fxt.Init_page_create("Page:\"A\"", "a");
fxt.Test_parse_page_wiki_str("<pages index=\"&#34;A&#34;\" from='&#34;A&#34;' />", "<p>a \n</p>");
fxt.Test_parse_page_wiki_str("<pages index=\"&#34;A&#34;\" from='&#34;A&#34;' />", "<p>a&#32;\n</p>");
}
// @Test public void Index_all() { // PURPOSE: if from / to not specified, add all titles
// fxt.Init_page_create("Index:A", String_.Concat_lines_nl
@ -116,7 +116,7 @@ public class Pp_pages_nde_index_tst {
@Test public void Section_failed_when_xnde() { // PURPOSE: section failed to be retrieved if preceding xnde; DATE:2014-01-15
fxt.Init_page_create("Page:A/1", "<b>a</b><section begin=\"sect_0\"/>b<section end=\"sect_0\"/>");
fxt.Test_parse_page_wiki_str("<pages index=\"A\" from=1 to=1 fromsection='sect_0' tosection='sect_0' />", String_.Concat_lines_nl
( "<p>b "
( "<p>b&#32;"
, "</p>"
));
}
@ -129,8 +129,8 @@ public class Pp_pages_nde_index_tst {
fxt.Init_page_create("Page:A_b/2", "A_b/2\n");
fxt.Test_parse_page_wiki_str("<pages index=\"A\" from='A b/1' />", String_.Concat_lines_nl
( "<p>A_b/1"
, " A_b/2"
, " "
, "&#32;A_b/2"
, "&#32;"
, "</p>"
));
}
@ -145,8 +145,8 @@ public class Pp_pages_nde_index_tst {
fxt.Test_parse_page_wiki_str("<pages index=\"A\" from='A/1' header='y' />", String_.Concat_lines_nl
( "<p>0-1"
, "A/1"
, " A/2"
, " "
, "&#32;A/2"
, "&#32;"
, "</p>"
));
}
@ -156,25 +156,25 @@ public class Pp_pages_nde_index_tst {
fxt.Init_page_create("Page:A/3", "c");
fxt.Init_page_create("Page:A/4", "d");
fxt.Init_page_create("Page:A/5", "e");
fxt.Test_parse_page_wiki_str("<pages index=\"A\" include='1-2,4' />", "<p>a b d \n</p>\n"); // include
fxt.Test_parse_page_wiki_str("<pages index=\"A\" from=1 to=5 exclude='3' />", "<p>a b d e \n</p>\n"); // exclude
fxt.Test_parse_page_wiki_str("<pages index=\"A\" include=5 from=2 to=4 />", "<p>b c d e \n</p>\n"); // include should be sorted
fxt.Test_parse_page_wiki_str("<pages index=\"A\" from=1 to=5 step=2 />", "<p>a c e \n</p>\n"); // step
fxt.Test_parse_page_wiki_str("<pages index=\"A\" from=1 to=5 step=4 />", "<p>a e \n</p>\n"); // step
fxt.Test_parse_page_wiki_str("<pages index=\"A\" from=1 to=5 step=10 />", "<p>a \n</p>\n"); // step
fxt.Test_parse_page_wiki_str("<pages index=\"A\" from=3 to=3 />", "<p>c \n</p>\n"); // from = to
fxt.Test_parse_page_wiki_str("<pages index=\"A\" to=3/>", "<p> a b c \n</p>\n"); // from omitted
fxt.Test_parse_page_wiki_str("<pages index=\"A\" from=3/>", "<p>c d e \n</p>\n"); // to omitted
fxt.Test_parse_page_wiki_str("<pages index=\"A\" from='' to=3 />", "<p> a b c \n</p>\n"); // from is blank
fxt.Test_parse_page_wiki_str("<pages index=\"A\" from=3 to=''/>", "<p>c d e \n</p>\n"); // to is blank
fxt.Test_parse_page_wiki_str("<pages index=\"A\" from=3 to='4.' />", "<p>c d \n</p>\n"); // allow decimal-like number; PAGE:en.w:Haworth's/Chapter_XIX; DATE:2014-01-19
fxt.Test_parse_page_wiki_str("<pages index=\"A\" from=1 to=5 exclude=''3' />", "<p>a b c d e \n</p>\n"); // exclude is invalid; EX:fr.s:Sanguis_martyrum/Première_partie/I DATE:2014-01-18
fxt.Test_parse_page_wiki_str("<pages index=\"A\" exclude from=1 to=5 />", "<p>a b c d e \n</p>\n"); // exclude empty; ru.s:ПБЭ/Гуттен,_Ульрихон DATE:2014-02-22
fxt.Test_parse_page_wiki_str("<pages index=\"A\" include='1-2,4' />", "<p>a&#32;b&#32;d&#32;\n</p>\n"); // include
fxt.Test_parse_page_wiki_str("<pages index=\"A\" from=1 to=5 exclude='3' />", "<p>a&#32;b&#32;d&#32;e&#32;\n</p>\n"); // exclude
fxt.Test_parse_page_wiki_str("<pages index=\"A\" include=5 from=2 to=4 />", "<p>b&#32;c&#32;d&#32;e&#32;\n</p>\n"); // include should be sorted
fxt.Test_parse_page_wiki_str("<pages index=\"A\" from=1 to=5 step=2 />", "<p>a&#32;c&#32;e&#32;\n</p>\n"); // step
fxt.Test_parse_page_wiki_str("<pages index=\"A\" from=1 to=5 step=4 />", "<p>a&#32;e&#32;\n</p>\n"); // step
fxt.Test_parse_page_wiki_str("<pages index=\"A\" from=1 to=5 step=10 />", "<p>a&#32;\n</p>\n"); // step
fxt.Test_parse_page_wiki_str("<pages index=\"A\" from=3 to=3 />", "<p>c&#32;\n</p>\n"); // from = to
fxt.Test_parse_page_wiki_str("<pages index=\"A\" to=3/>", "<p>&#32;a&#32;b&#32;c&#32;\n</p>\n"); // from omitted
fxt.Test_parse_page_wiki_str("<pages index=\"A\" from=3/>", "<p>c&#32;d&#32;e&#32;\n</p>\n"); // to omitted
fxt.Test_parse_page_wiki_str("<pages index=\"A\" from='' to=3 />", "<p>&#32;a&#32;b&#32;c&#32;\n</p>\n"); // from is blank
fxt.Test_parse_page_wiki_str("<pages index=\"A\" from=3 to=''/>", "<p>c&#32;d&#32;e&#32;\n</p>\n"); // to is blank
fxt.Test_parse_page_wiki_str("<pages index=\"A\" from=3 to='4.' />", "<p>c&#32;d&#32;\n</p>\n"); // allow decimal-like number; PAGE:en.w:Haworth's/Chapter_XIX; DATE:2014-01-19
fxt.Test_parse_page_wiki_str("<pages index=\"A\" from=1 to=5 exclude=''3' />", "<p>a&#32;b&#32;c&#32;d&#32;e&#32;\n</p>\n");// exclude is invalid; EX:fr.s:Sanguis_martyrum/Première_partie/I DATE:2014-01-18
fxt.Test_parse_page_wiki_str("<pages index=\"A\" exclude from=1 to=5 />", "<p>a&#32;b&#32;c&#32;d&#32;e&#32;\n</p>\n"); // exclude empty; ru.s:ПБЭ/Гуттен,_Ульрихон DATE:2014-02-22
}
@Test public void Ref() { // PURPOSE: ref on page should show; DATE:2014-01-18
fxt.Init_page_create("Page:A/1", "a<ref>b</ref>c");
fxt.Test_parse_page_wiki_str("<pages index=\"A\" from=1 to=1 /><references/>", String_.Concat_lines_nl
( "<p>a<sup id=\"cite_ref-0\" class=\"reference\"><a href=\"#cite_note-0\">[1]</a></sup>c "
( "<p>a<sup id=\"cite_ref-0\" class=\"reference\"><a href=\"#cite_note-0\">[1]</a></sup>c&#32;"
, "</p>"
, "<ol class=\"references\">"
, "<li id=\"cite_note-0\"><span class=\"mw-cite-backlink\"><a href=\"#cite_ref-0\">^</a></span> <span class=\"reference-text\">b</span></li>"
@ -186,11 +186,11 @@ public class Pp_pages_nde_index_tst {
fxt.Init_page_create("Page:A/2", "* b");
fxt.Init_page_create("Page:A/3", "c");
fxt.Test_parse_page_wiki_str("<pages index=\"A\" from=1 to=3 />", String_.Concat_lines_nl
( "<p>a "
( "<p>a&#32;"
, "</p>"
, ""
, "<ul>"
, " <li> b c "
, " <li> b&#32;c&#32;"
, " </li>"
, "</ul>"
, ""
@ -208,7 +208,7 @@ public class Pp_pages_nde_index_tst {
( "no links"
));
fxt.Test_parse_page_wiki_str("<pages index='A' to=1 />", String_.Concat_lines_nl
( "<p>A/0 A/1 "
( "<p>A/0&#32;A/1&#32;"
, "</p>"
));
@ -218,7 +218,7 @@ public class Pp_pages_nde_index_tst {
( "[[Page:A/0]]"
));
fxt.Test_parse_page_wiki_str("<pages index='A' to=1 />", String_.Concat_lines_nl
( "<p>A/0 "
( "<p>A/0&#32;"
, "</p>"
));
@ -229,7 +229,7 @@ public class Pp_pages_nde_index_tst {
, "<pagelist/>"
));
fxt.Test_parse_page_wiki_str("<pages index='A' to=1 />", String_.Concat_lines_nl
( "<p>A/0 A/1 "
( "<p>A/0&#32;A/1&#32;"
, "</p>"
));
}

View File

@ -26,14 +26,14 @@ public class Pp_pages_nde_recursion_tst {
@Test public void Page() { // PURPOSE: handle recursive calls on page; EX: fr.s:Page:NRF_19.djvu/19; DATE:2014-01-01
fxt.Init_page_create("Page:A/1", "<pages index=\"A\" from=1 to=1 />abc"); // NOTE: recursive call to self
fxt.Test_parse_page_wiki_str("<pages index=\"A\" from=1 to=1 />", String_.Concat_lines_nl
( "<p>abc "
( "<p>abc&#32;"
, "</p>"
, ""
));
}
@Test public void Index() { // PURPOSE: handle recursive calls on index; EX: en.s:Poems_of_Italy:_selections_from_the_Odes_of_Giosue_Carducci/Before_the_Old_Castle_of_Verona; DATE:2014-01-19
fxt.Init_page_create("Index:A", "<pages index=A/>");
fxt.Test_parse_page_wiki_str("<pages index=\"A\" from=1 to=1 />", "<p> \n</p>");
fxt.Test_parse_page_wiki_str("<pages index=\"A\" from=1 to=1 />", "<p>&#32;\n</p>");
}
@Test public void MediaWiki_Proofreadpage_header_template() { // PURPOSE: handle recursive calls through Proofreadpage_header_template; EX: fr.s:L<EFBFBD>Enfer_(Barbusse); DATE:2014-05-21
fxt.Init_page_create("MediaWiki:Proofreadpage_header_template", "<pages index=\"A\" />"); // NOTE: this is just a simulation of fr.s, which calls Module:Header_template which in turn calls preprocess to results in recursion

View File

@ -88,8 +88,8 @@ public class Wdata_xwiki_link_wtr_tst {
, " <h4>grp1</h4>"
, " <table style='width: 100%;'>"
, " <tr>"
, " <td style='width: 10%; padding-bottom: 5px;'>French</td><td style='width: 20%; padding-bottom: 5px;'><li class='badge-goodarticle'><a hreflang=\"fr\" title=\"Q1 fr\" href=\"/site/fr.wikipedia.org/wiki/Q1 fr\">Q1 fr</a></li></td><td style='width: 3%; padding-bottom: 5px;'></td>"
, " <td style='width: 10%; padding-bottom: 5px;'>German</td><td style='width: 20%; padding-bottom: 5px;'><li class='badge-featuredarticle'><a hreflang=\"de\" title=\"Q1 de\" href=\"/site/de.wikipedia.org/wiki/Q1 de\">Q1 de</a></li></td><td style='width: 3%; padding-bottom: 5px;'></td>"
, " <td style='width: 10%; padding-bottom: 5px;'>French</td><td style='width: 20%; padding-bottom: 5px;'><li class='badge-goodarticle'><a hreflang=\"fr\" title=\"Q1 fr\" href=\"/site/fr.wikipedia.org/wiki/Q1 fr\">Q1 fr</a></li></td><td style='width: 3%; padding-bottom: 5px;'></td>"
, " </tr>"
, " </table>"
, " </div>"

View File

@ -16,13 +16,13 @@ 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; import gplx.*;
import gplx.xowa.wikis.xwikis.*; import gplx.xowa.html.*; import gplx.xowa.net.*;
import gplx.xowa.net.*; import gplx.xowa.wikis.xwikis.*; import gplx.xowa.html.*; import gplx.xowa.html.lnkis.*;
public class Xop_link_parser {
public byte[] Html_xowa_ttl() {return html_xowa_ttl;} private byte[] html_xowa_ttl;
public byte[] Html_anchor_cls() {return html_anchor_cls;} private byte[] html_anchor_cls;
public byte[] Html_anchor_rel() {return html_anchor_rel;} private byte[] html_anchor_rel;
public byte Html_anchor_cls() {return html_anchor_cls;} private byte html_anchor_cls;
public byte Html_anchor_rel() {return html_anchor_rel;} private byte html_anchor_rel;
public byte[] Parse(Bry_bfr tmp_bfr, Xoa_url tmp_url, Xow_wiki wiki, byte[] raw, byte[] or) {
html_xowa_ttl = null; html_anchor_cls = Xow_html_mgr.Bry_anchor_class_image; html_anchor_rel = Xow_html_mgr.Bry_anchor_rel_blank; // default member variables for html
html_xowa_ttl = null; html_anchor_cls = Xoh_lnki_consts.Tid_a_cls_image; html_anchor_rel = Xoh_lnki_consts.Tid_a_rel_none; // default member variables for html
Xoa_app app = wiki.App(); int raw_len = raw.length;
app.Url_parser().Parse(tmp_url, raw);
switch (tmp_url.Protocol_tid()) {
@ -40,8 +40,8 @@ public class Xop_link_parser {
tmp_bfr.Add(raw); // dump everything
}
raw = tmp_bfr.Xto_bry_and_clear();
html_anchor_cls = Xow_html_mgr.Bry_anchor_class_blank;
html_anchor_rel = Xow_html_mgr.Bry_anchor_rel_nofollow;
html_anchor_cls = Xoh_lnki_consts.Tid_a_cls_none;
html_anchor_rel = Xoh_lnki_consts.Tid_a_rel_nofollow;
break;
case Xoo_protocol_itm.Tid_file: // "file:///" or "File:A.png"
int proto_len = tmp_url.Protocol_bry().length;

View File

@ -210,7 +210,7 @@ public class Xoa_ttl { // PAGE:en.w:http://en.wikipedia.org/wiki/Help:Link; REF.
if (html_ent_obj != null) {
Xop_amp_trie_itm amp_itm = (Xop_amp_trie_itm)html_ent_obj;
match_pos = amp_trie.Match_pos();
if (amp_itm.Tid() == Xop_amp_trie_itm.Tid_name) {
if (amp_itm.Tid() == Xop_amp_trie_itm.Tid_name_std) {
switch (amp_itm.Char_int()) {
case 160: // NOTE: &nbsp must convert to space; EX:w:United States [[Image:Dust Bowl&nbsp;- Dallas, South Dakota 1936.jpg|220px|alt=]]
if (ltr_bgn != -1) add_ws = true; // apply same ws rules as Space, NewLine; needed for converting multiple ws into one; EX:" &nbsp; " -> " " x> " "; PAGEen.w:Greek_government-debt_crisis; DATE:2014-09-25

View File

@ -74,7 +74,8 @@ public class Xop_sanitizer {
Xop_amp_trie_itm itm = (Xop_amp_trie_itm)amp_obj;
byte itm_tid = itm.Tid();
switch (itm_tid) {
case Xop_amp_trie_itm.Tid_name:
case Xop_amp_trie_itm.Tid_name_std:
case Xop_amp_trie_itm.Tid_name_xowa:
bfr.Add(itm.Utf8_bry());
pos += itm.Key_name_len() + 1; // 1 for trailing ";"; EX: for "&nbsp; ", (a) pos is at "&", (b) "nbsp" is Key_name_len, (c) ";" needs + 1
break;

View File

@ -81,6 +81,7 @@ public class Xop_tkn_mkr {
public gplx.xowa.xtns.templateData.Xtn_templateData_nde Xnde_templateData() {return new gplx.xowa.xtns.templateData.Xtn_templateData_nde();}
public gplx.xowa.xtns.rss.Rss_xnde Xnde_rss() {return new gplx.xowa.xtns.rss.Rss_xnde();}
public gplx.xowa.xtns.quiz.Quiz_xnde Xnde_quiz() {return new gplx.xowa.xtns.quiz.Quiz_xnde();}
public gplx.xowa.xtns.indicators.Indicator_xnde Xnde_indicator() {return new gplx.xowa.xtns.indicators.Indicator_xnde();}
public gplx.xowa.xtns.xowa_cmds.Xox_xowa_html_cmd Xnde_xowa_html() {return new gplx.xowa.xtns.xowa_cmds.Xox_xowa_html_cmd();}
public gplx.xowa.xtns.listings.Listing_xnde Xnde_listing(int tag_id) {return new gplx.xowa.xtns.listings.Listing_xnde(tag_id);}
public gplx.xowa.xtns.scores.Score_xnde Xnde_score() {return new gplx.xowa.xtns.scores.Score_xnde();}

View File

@ -134,8 +134,9 @@ public class Xop_xnde_tag_ {
, Tid_xowa_tag_bgn = 109
, Tid_xowa_tag_end = 110
, Tid_quiz = 111
, Tid_indicator = 112
;
public static final int _MaxLen = 112;
public static final int _MaxLen = 113;
public static final Xop_xnde_tag[] Ary = new Xop_xnde_tag[_MaxLen];
private static Xop_xnde_tag new_(int id, String name) {
Xop_xnde_tag rv = new Xop_xnde_tag(id, name);
@ -196,7 +197,7 @@ public class Xop_xnde_tag_ {
, Tag_colgroup = new_(Tid_colgroup, "colgroup")
, Tag_col = new_(Tid_col, "col")
, Tag_a = new_(Tid_a, "a").Restricted_()
, Tag_img = new_(Tid_img, "img").Xtn_().Restricted_()
, Tag_img = new_(Tid_img, "img").Restricted_() // NOTE: was .Xtn() DATE:2014-11-06
, Tag_ruby = new_(Tid_ruby, "ruby").NoInline_()
, Tag_rt = new_(Tid_rt, "rt").NoInline_()
, Tag_rb = new_(Tid_rb, "rb").NoInline_()
@ -255,5 +256,6 @@ public class Xop_xnde_tag_ {
, Tag_xowa_tag_bgn = new_(Tid_xowa_tag_bgn, "xtag_bgn").Xtn_()
, Tag_xowa_tag_end = new_(Tid_xowa_tag_end, "xtag_end").Xtn_()
, Tag_quiz = new_(Tid_quiz, "quiz").Xtn_()
, Tag_indicator = new_(Tid_indicator, "indicator").Xtn_()
;
}

View File

@ -654,6 +654,7 @@ public class Xop_xnde_wkr implements Xop_ctx_wkr {
case Xop_xnde_tag_.Tid_templateData: xnde_xtn = tkn_mkr.Xnde_templateData(); break;
case Xop_xnde_tag_.Tid_rss: xnde_xtn = tkn_mkr.Xnde_rss(); break;
case Xop_xnde_tag_.Tid_quiz: xnde_xtn = tkn_mkr.Xnde_quiz(); break;
case Xop_xnde_tag_.Tid_indicator: xnde_xtn = tkn_mkr.Xnde_indicator(); break;
case Xop_xnde_tag_.Tid_xowa_html: xnde_xtn = tkn_mkr.Xnde_xowa_html(); break;
case Xop_xnde_tag_.Tid_listing_buy:
case Xop_xnde_tag_.Tid_listing_do:

View File

@ -184,4 +184,7 @@ public class Xop_xnde_wkr__err_misc_tst {
@Test public void Anchor_nested() {
fxt.Test_parse_page_all_str("b<a>c<a>d [[e]] f", "b&lt;a>c&lt;a>d <a href=\"/wiki/E\">e</a> f");
}
@Test public void Img_should_not_be_xtn() { // PURPOSE:<img> marked as .xtn; unclosed <img> was escaping rest of text; PAGE:de.w:Wikipedia:Technik/Archiv/2014 DATE:2014-11-06
fxt.Test_parse_page_all_str("<img>''a''", "&lt;img><i>a</i>");
}
}

BIN
xowa_source_v1.11.2.1.7z Executable file

Binary file not shown.