mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
v2.7.2.1
This commit is contained in:
28
400_xowa/src/gplx/xowa/parsers/amps/Xop_amp_lxr.java
Normal file
28
400_xowa/src/gplx/xowa/parsers/amps/Xop_amp_lxr.java
Normal file
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
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.parsers.amps; import gplx.*; import gplx.xowa.*; import gplx.xowa.parsers.*;
|
||||
import gplx.core.btries.*;
|
||||
public class Xop_amp_lxr implements Xop_lxr {
|
||||
public byte Lxr_tid() {return Xop_lxr_.Tid_amp;}
|
||||
public void Init_by_wiki(Xowe_wiki wiki, Btrie_fast_mgr core_trie) {core_trie.Add(Byte_ascii.Amp, this);}
|
||||
public void Init_by_lang(Xol_lang lang, Btrie_fast_mgr core_trie) {}
|
||||
public int Make_tkn(Xop_ctx ctx, Xop_tkn_mkr tkn_mkr, Xop_root_tkn root, byte[] src, int src_len, int bgn_pos, int cur_pos) {
|
||||
return ctx.Amp().Make_tkn(ctx, tkn_mkr, root, src, src_len, bgn_pos, cur_pos);
|
||||
}
|
||||
public static final Xop_amp_lxr _ = new Xop_amp_lxr();
|
||||
}
|
||||
121
400_xowa/src/gplx/xowa/parsers/amps/Xop_amp_mgr.java
Normal file
121
400_xowa/src/gplx/xowa/parsers/amps/Xop_amp_mgr.java
Normal file
@@ -0,0 +1,121 @@
|
||||
/*
|
||||
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.parsers.amps; import gplx.*; import gplx.xowa.*; import gplx.xowa.parsers.*;
|
||||
import gplx.core.btries.*;
|
||||
public class Xop_amp_mgr {
|
||||
private final Bry_bfr tmp_bfr = Bry_bfr.reset_(32);
|
||||
public Btrie_slim_mgr Amp_trie() {return amp_trie;} private final Btrie_slim_mgr amp_trie = Xop_amp_trie._;
|
||||
public int Rslt_pos() {return rslt_pos;} private int rslt_pos;
|
||||
public int Rslt_val() {return rslt_val;} private int rslt_val;
|
||||
public Xop_tkn_itm Parse_as_tkn(Xop_tkn_mkr tkn_mkr, byte[] src, int src_len, int amp_pos, int cur_pos) {
|
||||
rslt_pos = amp_pos + 1; // default to fail pos; after amp;
|
||||
Object o = amp_trie.Match_bgn(src, cur_pos, src_len);
|
||||
cur_pos = amp_trie.Match_pos();
|
||||
if (o == null) return null;
|
||||
Xop_amp_trie_itm itm = (Xop_amp_trie_itm)o;
|
||||
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 Exc_.new_unhandled(itm.Tid());
|
||||
}
|
||||
}
|
||||
public boolean Parse_as_int(boolean ncr_is_hex, byte[] src, int src_len, int amp_pos, int int_bgn) {
|
||||
rslt_pos = amp_pos + 1; // default to fail pos; after amp;
|
||||
rslt_val = -1; // clear any previous setting
|
||||
int cur_pos = int_bgn, int_end = -1;
|
||||
int semic_pos = Bry_finder.Find_fwd(src, Byte_ascii.Semic, cur_pos, src_len);
|
||||
if (semic_pos == Bry_finder.Not_found) return false;
|
||||
int_end = semic_pos - 1; // int_end = pos before semicolon
|
||||
int multiple = ncr_is_hex ? 16 : 10, val = 0, factor = 1, cur = 0;
|
||||
for (int i = int_end; i >= int_bgn; i--) {
|
||||
byte b = src[i];
|
||||
if (ncr_is_hex) {
|
||||
if (b >= 48 && b <= 57) cur = b - 48;
|
||||
else if (b >= 65 && b <= 70) cur = b - 55;
|
||||
else if (b >= 97 && b <= 102) cur = b - 87;
|
||||
else if((b >= 71 && b <= 90)
|
||||
|| (b >= 91 && b <= 122)) continue; // NOTE: wiki discards letters G-Z; PAGE:en.w:Miscellaneous_Symbols "{{Unicode|&#xx26D0;}}"; NOTE 2nd x is discarded
|
||||
else return false;
|
||||
}
|
||||
else {
|
||||
cur = b - Byte_ascii.Num_0;
|
||||
if (cur < 0 || cur > 10) return false;
|
||||
}
|
||||
val += cur * factor;
|
||||
if (val > gplx.intl.Utf8_.Codepoint_max) return false; // fail if value > largest_unicode_codepoint
|
||||
factor *= multiple;
|
||||
}
|
||||
rslt_val = val;
|
||||
rslt_pos = semic_pos + 1; // position after semic
|
||||
return true;
|
||||
}
|
||||
public byte[] Decode_as_bry(byte[] src) {
|
||||
if (src == null) return src;
|
||||
int src_len = src.length;
|
||||
boolean dirty = false;
|
||||
int pos = 0;
|
||||
while (pos < src_len) {
|
||||
byte b = src[pos];
|
||||
if (b == Byte_ascii.Amp) {
|
||||
int nxt_pos = pos + 1;
|
||||
if (nxt_pos < src_len) {
|
||||
byte nxt_b = src[nxt_pos];
|
||||
Object amp_obj = amp_trie.Match_bgn_w_byte(nxt_b, src, nxt_pos, src_len);
|
||||
if (amp_obj != null) {
|
||||
if (!dirty) {
|
||||
tmp_bfr.Add_mid(src, 0, pos);
|
||||
dirty = true;
|
||||
}
|
||||
Xop_amp_trie_itm amp_itm = (Xop_amp_trie_itm)amp_obj;
|
||||
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_u8_int(rslt_val);
|
||||
else
|
||||
tmp_bfr.Add_mid(src, pos, nxt_pos);
|
||||
pos = rslt_pos;
|
||||
break;
|
||||
default:
|
||||
throw Exc_.new_unhandled(amp_itm.Tid());
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (dirty)
|
||||
tmp_bfr.Add_byte(b);
|
||||
++pos;
|
||||
}
|
||||
return dirty ? tmp_bfr.Xto_bry_and_clear() : src;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
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.parsers.amps; import gplx.*; import gplx.xowa.*; import gplx.xowa.parsers.*;
|
||||
import org.junit.*;
|
||||
public class Xop_amp_mgr_decode_tst {
|
||||
@Before public void init() {fxt.Reset();} private Xop_amp_mgr_fxt fxt = new Xop_amp_mgr_fxt();
|
||||
@Test public void Text() {fxt.Test_decode_as_bry("a" , "a");}
|
||||
@Test public void Name() {fxt.Test_decode_as_bry("&" , "&");}
|
||||
@Test public void Name_w_text() {fxt.Test_decode_as_bry("a&b" , "a&b");}
|
||||
@Test public void Name_fail_semic_missing() {fxt.Test_decode_as_bry("a&b" , "a&b");}
|
||||
@Test public void Name_fail_amp_only() {fxt.Test_decode_as_bry("a&" , "a&");}
|
||||
@Test public void Num_fail() {fxt.Test_decode_as_bry("&#!;" , "&#!;");} // ! is not valid num
|
||||
@Test public void Hex_fail() {fxt.Test_decode_as_bry("&#x!;" , "&#x!;");} // ! is not valid hex
|
||||
@Test public void Num_basic() {fxt.Test_decode_as_bry("Σ" , "Σ");}
|
||||
@Test public void Num_zero_padded() {fxt.Test_decode_as_bry("Σ" , "Σ");}
|
||||
@Test public void Hex_upper() {fxt.Test_decode_as_bry("Σ" , "Σ");}
|
||||
@Test public void Hex_lower() {fxt.Test_decode_as_bry("Σ" , "Σ");}
|
||||
@Test public void Hex_zero_padded() {fxt.Test_decode_as_bry("Σ" , "Σ");}
|
||||
@Test public void Hex_upper_x() {fxt.Test_decode_as_bry("Σ" , "Σ");}
|
||||
@Test public void Num_fail_large_codepoint() {fxt.Test_decode_as_bry("�" , "�");}
|
||||
@Test public void Num_ignore_extra_x() {fxt.Test_decode_as_bry("&#xx26D0;" , Char_.XtoStr(Char_.XbyInt(9936)));} // 2nd x is ignored
|
||||
}
|
||||
class Xop_amp_mgr_fxt {
|
||||
private Xop_amp_mgr amp_mgr = new Xop_amp_mgr();
|
||||
public void Reset() {}
|
||||
public void Test_decode_as_bry(String raw, String expd) {
|
||||
Tfds.Eq(expd, String_.new_u8(amp_mgr.Decode_as_bry(Bry_.new_u8(raw))));
|
||||
}
|
||||
}
|
||||
27
400_xowa/src/gplx/xowa/parsers/amps/Xop_amp_tkn_num.java
Normal file
27
400_xowa/src/gplx/xowa/parsers/amps/Xop_amp_tkn_num.java
Normal 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.parsers.amps; import gplx.*; import gplx.xowa.*; import gplx.xowa.parsers.*;
|
||||
public class Xop_amp_tkn_num extends Xop_tkn_itm_base {
|
||||
public Xop_amp_tkn_num(int bgn, int end, int val, byte[] str_as_bry) {
|
||||
this.val = val; this.str_as_bry = str_as_bry;
|
||||
this.Tkn_ini_pos(false, bgn, end);
|
||||
}
|
||||
@Override public byte Tkn_tid() {return Xop_tkn_itm_.Tid_html_ncr;}
|
||||
public int Val() {return val;} private int val;
|
||||
public byte[] Str_as_bry() {return str_as_bry;} private byte[] str_as_bry;
|
||||
}
|
||||
31
400_xowa/src/gplx/xowa/parsers/amps/Xop_amp_tkn_txt.java
Normal file
31
400_xowa/src/gplx/xowa/parsers/amps/Xop_amp_tkn_txt.java
Normal file
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
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.parsers.amps; import gplx.*; import gplx.xowa.*; import gplx.xowa.parsers.*;
|
||||
public class Xop_amp_tkn_txt extends Xop_tkn_itm_base {
|
||||
private Xop_amp_trie_itm html_ref_itm;
|
||||
public Xop_amp_tkn_txt(int bgn, int end, Xop_amp_trie_itm html_ref_itm) {
|
||||
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 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);}
|
||||
}
|
||||
318
400_xowa/src/gplx/xowa/parsers/amps/Xop_amp_trie.java
Normal file
318
400_xowa/src/gplx/xowa/parsers/amps/Xop_amp_trie.java
Normal file
@@ -0,0 +1,318 @@
|
||||
/*
|
||||
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.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_a7("&xowa_lt;")
|
||||
, Bry_xowa_brack_bgn = Bry_.new_a7("&xowa_brack_bgn;")
|
||||
, Bry_xowa_brack_end = Bry_.new_a7("&xowa_brack_end;")
|
||||
, Bry_xowa_pipe = Bry_.new_a7("&xowa_pipe;")
|
||||
, Bry_xowa_apos = Bry_.new_a7("&xowa_apos;")
|
||||
, Bry_xowa_colon = Bry_.new_a7("&xowa_colon;")
|
||||
, Bry_xowa_underline = Bry_.new_a7("&xowa_underline;")
|
||||
, Bry_xowa_asterisk = Bry_.new_a7("&xowa_asterisk;")
|
||||
, Bry_xowa_space = Bry_.new_a7("&xowa_space;")
|
||||
, Bry_xowa_nl = Bry_.new_a7("&xowa_nl;")
|
||||
, Bry_xowa_dash = Bry_.new_a7("&xowa_dash;")
|
||||
;
|
||||
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_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_.Y, 45, Bry_xowa_dash);
|
||||
Reg_name(rv, Bool_.N, 39, "'");
|
||||
Reg_name(rv, Bool_.N, 193, "Á");
|
||||
Reg_name(rv, Bool_.N, 225, "á");
|
||||
Reg_name(rv, Bool_.N, 194, "Â");
|
||||
Reg_name(rv, Bool_.N, 226, "â");
|
||||
Reg_name(rv, Bool_.N, 180, "´");
|
||||
Reg_name(rv, Bool_.N, 198, "Æ");
|
||||
Reg_name(rv, Bool_.N, 230, "æ");
|
||||
Reg_name(rv, Bool_.N, 192, "À");
|
||||
Reg_name(rv, Bool_.N, 224, "à");
|
||||
Reg_name(rv, Bool_.N, 8501, "ℵ");
|
||||
Reg_name(rv, Bool_.N, 913, "Α");
|
||||
Reg_name(rv, Bool_.N, 945, "α");
|
||||
Reg_name(rv, Bool_.N, 38, "&");
|
||||
Reg_name(rv, Bool_.N, 8743, "∧");
|
||||
Reg_name(rv, Bool_.N, 8736, "∠");
|
||||
Reg_name(rv, Bool_.N, 197, "Å");
|
||||
Reg_name(rv, Bool_.N, 229, "å");
|
||||
Reg_name(rv, Bool_.N, 8776, "≈");
|
||||
Reg_name(rv, Bool_.N, 195, "Ã");
|
||||
Reg_name(rv, Bool_.N, 227, "ã");
|
||||
Reg_name(rv, Bool_.N, 196, "Ä");
|
||||
Reg_name(rv, Bool_.N, 228, "ä");
|
||||
Reg_name(rv, Bool_.N, 8222, "„");
|
||||
Reg_name(rv, Bool_.N, 914, "Β");
|
||||
Reg_name(rv, Bool_.N, 946, "β");
|
||||
Reg_name(rv, Bool_.N, 166, "¦");
|
||||
Reg_name(rv, Bool_.N, 8226, "•");
|
||||
Reg_name(rv, Bool_.N, 8745, "∩");
|
||||
Reg_name(rv, Bool_.N, 199, "Ç");
|
||||
Reg_name(rv, Bool_.N, 231, "ç");
|
||||
Reg_name(rv, Bool_.N, 184, "¸");
|
||||
Reg_name(rv, Bool_.N, 162, "¢");
|
||||
Reg_name(rv, Bool_.N, 935, "Χ");
|
||||
Reg_name(rv, Bool_.N, 967, "χ");
|
||||
Reg_name(rv, Bool_.N, 710, "ˆ");
|
||||
Reg_name(rv, Bool_.N, 9827, "♣");
|
||||
Reg_name(rv, Bool_.N, 8773, "≅");
|
||||
Reg_name(rv, Bool_.N, 169, "©");
|
||||
Reg_name(rv, Bool_.N, 8629, "↵");
|
||||
Reg_name(rv, Bool_.N, 8746, "∪");
|
||||
Reg_name(rv, Bool_.N, 164, "¤");
|
||||
Reg_name(rv, Bool_.N, 8224, "†");
|
||||
Reg_name(rv, Bool_.N, 8225, "‡");
|
||||
Reg_name(rv, Bool_.N, 8595, "↓");
|
||||
Reg_name(rv, Bool_.N, 8659, "⇓");
|
||||
Reg_name(rv, Bool_.N, 176, "°");
|
||||
Reg_name(rv, Bool_.N, 916, "Δ");
|
||||
Reg_name(rv, Bool_.N, 948, "δ");
|
||||
Reg_name(rv, Bool_.N, 9830, "♦");
|
||||
Reg_name(rv, Bool_.N, 247, "÷");
|
||||
Reg_name(rv, Bool_.N, 201, "É");
|
||||
Reg_name(rv, Bool_.N, 233, "é");
|
||||
Reg_name(rv, Bool_.N, 202, "Ê");
|
||||
Reg_name(rv, Bool_.N, 234, "ê");
|
||||
Reg_name(rv, Bool_.N, 200, "È");
|
||||
Reg_name(rv, Bool_.N, 232, "è");
|
||||
Reg_name(rv, Bool_.N, 8709, "∅");
|
||||
Reg_name(rv, Bool_.N, 8195, " ");
|
||||
Reg_name(rv, Bool_.N, 8194, " ");
|
||||
Reg_name(rv, Bool_.N, 917, "Ε");
|
||||
Reg_name(rv, Bool_.N, 949, "ε");
|
||||
Reg_name(rv, Bool_.N, 8801, "≡");
|
||||
Reg_name(rv, Bool_.N, 919, "Η");
|
||||
Reg_name(rv, Bool_.N, 951, "η");
|
||||
Reg_name(rv, Bool_.N, 208, "Ð");
|
||||
Reg_name(rv, Bool_.N, 240, "ð");
|
||||
Reg_name(rv, Bool_.N, 203, "Ë");
|
||||
Reg_name(rv, Bool_.N, 235, "ë");
|
||||
Reg_name(rv, Bool_.N, 8364, "€");
|
||||
Reg_name(rv, Bool_.N, 8707, "∃");
|
||||
Reg_name(rv, Bool_.N, 402, "ƒ");
|
||||
Reg_name(rv, Bool_.N, 8704, "∀");
|
||||
Reg_name(rv, Bool_.N, 189, "½");
|
||||
Reg_name(rv, Bool_.N, 188, "¼");
|
||||
Reg_name(rv, Bool_.N, 190, "¾");
|
||||
Reg_name(rv, Bool_.N, 8260, "⁄");
|
||||
Reg_name(rv, Bool_.N, 915, "Γ");
|
||||
Reg_name(rv, Bool_.N, 947, "γ");
|
||||
Reg_name(rv, Bool_.N, 8805, "≥");
|
||||
Reg_name(rv, Bool_.N, 62, ">");
|
||||
Reg_name(rv, Bool_.N, 8596, "↔");
|
||||
Reg_name(rv, Bool_.N, 8660, "⇔");
|
||||
Reg_name(rv, Bool_.N, 9829, "♥");
|
||||
Reg_name(rv, Bool_.N, 8230, "…");
|
||||
Reg_name(rv, Bool_.N, 205, "Í");
|
||||
Reg_name(rv, Bool_.N, 237, "í");
|
||||
Reg_name(rv, Bool_.N, 206, "Î");
|
||||
Reg_name(rv, Bool_.N, 238, "î");
|
||||
Reg_name(rv, Bool_.N, 161, "¡");
|
||||
Reg_name(rv, Bool_.N, 204, "Ì");
|
||||
Reg_name(rv, Bool_.N, 236, "ì");
|
||||
Reg_name(rv, Bool_.N, 8465, "ℑ");
|
||||
Reg_name(rv, Bool_.N, 8734, "∞");
|
||||
Reg_name(rv, Bool_.N, 8747, "∫");
|
||||
Reg_name(rv, Bool_.N, 921, "Ι");
|
||||
Reg_name(rv, Bool_.N, 953, "ι");
|
||||
Reg_name(rv, Bool_.N, 191, "¿");
|
||||
Reg_name(rv, Bool_.N, 8712, "∈");
|
||||
Reg_name(rv, Bool_.N, 207, "Ï");
|
||||
Reg_name(rv, Bool_.N, 239, "ï");
|
||||
Reg_name(rv, Bool_.N, 922, "Κ");
|
||||
Reg_name(rv, Bool_.N, 954, "κ");
|
||||
Reg_name(rv, Bool_.N, 923, "Λ");
|
||||
Reg_name(rv, Bool_.N, 955, "λ");
|
||||
Reg_name(rv, Bool_.N, 9001, "⟨");
|
||||
Reg_name(rv, Bool_.N, 171, "«");
|
||||
Reg_name(rv, Bool_.N, 8592, "←");
|
||||
Reg_name(rv, Bool_.N, 8656, "⇐");
|
||||
Reg_name(rv, Bool_.N, 8968, "⌈");
|
||||
Reg_name(rv, Bool_.N, 8220, "“");
|
||||
Reg_name(rv, Bool_.N, 8804, "≤");
|
||||
Reg_name(rv, Bool_.N, 8970, "⌊");
|
||||
Reg_name(rv, Bool_.N, 8727, "∗");
|
||||
Reg_name(rv, Bool_.N, 9674, "◊");
|
||||
Reg_name(rv, Bool_.N, 8206, "‎");
|
||||
Reg_name(rv, Bool_.N, 8249, "‹");
|
||||
Reg_name(rv, Bool_.N, 8216, "‘");
|
||||
Reg_name(rv, Bool_.N, 60, "<");
|
||||
Reg_name(rv, Bool_.N, 175, "¯");
|
||||
Reg_name(rv, Bool_.N, 8212, "—");
|
||||
Reg_name(rv, Bool_.N, 181, "µ");
|
||||
Reg_name(rv, Bool_.N, 183, "·");
|
||||
Reg_name(rv, Bool_.N, 8722, "−");
|
||||
Reg_name(rv, Bool_.N, 924, "Μ");
|
||||
Reg_name(rv, Bool_.N, 956, "μ");
|
||||
Reg_name(rv, Bool_.N, 8711, "∇");
|
||||
Reg_name(rv, Bool_.N, 160, " ");
|
||||
Reg_name(rv, Bool_.N, 8211, "–");
|
||||
Reg_name(rv, Bool_.N, 8800, "≠");
|
||||
Reg_name(rv, Bool_.N, 8715, "∋");
|
||||
Reg_name(rv, Bool_.N, 172, "¬");
|
||||
Reg_name(rv, Bool_.N, 8713, "∉");
|
||||
Reg_name(rv, Bool_.N, 8836, "⊄");
|
||||
Reg_name(rv, Bool_.N, 209, "Ñ");
|
||||
Reg_name(rv, Bool_.N, 241, "ñ");
|
||||
Reg_name(rv, Bool_.N, 925, "Ν");
|
||||
Reg_name(rv, Bool_.N, 957, "ν");
|
||||
Reg_name(rv, Bool_.N, 211, "Ó");
|
||||
Reg_name(rv, Bool_.N, 243, "ó");
|
||||
Reg_name(rv, Bool_.N, 212, "Ô");
|
||||
Reg_name(rv, Bool_.N, 244, "ô");
|
||||
Reg_name(rv, Bool_.N, 338, "Œ");
|
||||
Reg_name(rv, Bool_.N, 339, "œ");
|
||||
Reg_name(rv, Bool_.N, 210, "Ò");
|
||||
Reg_name(rv, Bool_.N, 242, "ò");
|
||||
Reg_name(rv, Bool_.N, 8254, "‾");
|
||||
Reg_name(rv, Bool_.N, 937, "Ω");
|
||||
Reg_name(rv, Bool_.N, 969, "ω");
|
||||
Reg_name(rv, Bool_.N, 927, "Ο");
|
||||
Reg_name(rv, Bool_.N, 959, "ο");
|
||||
Reg_name(rv, Bool_.N, 8853, "⊕");
|
||||
Reg_name(rv, Bool_.N, 8744, "∨");
|
||||
Reg_name(rv, Bool_.N, 170, "ª");
|
||||
Reg_name(rv, Bool_.N, 186, "º");
|
||||
Reg_name(rv, Bool_.N, 216, "Ø");
|
||||
Reg_name(rv, Bool_.N, 248, "ø");
|
||||
Reg_name(rv, Bool_.N, 213, "Õ");
|
||||
Reg_name(rv, Bool_.N, 245, "õ");
|
||||
Reg_name(rv, Bool_.N, 8855, "⊗");
|
||||
Reg_name(rv, Bool_.N, 214, "Ö");
|
||||
Reg_name(rv, Bool_.N, 246, "ö");
|
||||
Reg_name(rv, Bool_.N, 182, "¶");
|
||||
Reg_name(rv, Bool_.N, 8706, "∂");
|
||||
Reg_name(rv, Bool_.N, 8240, "‰");
|
||||
Reg_name(rv, Bool_.N, 8869, "⊥");
|
||||
Reg_name(rv, Bool_.N, 934, "Φ");
|
||||
Reg_name(rv, Bool_.N, 966, "φ");
|
||||
Reg_name(rv, Bool_.N, 928, "Π");
|
||||
Reg_name(rv, Bool_.N, 960, "π");
|
||||
Reg_name(rv, Bool_.N, 982, "ϖ");
|
||||
Reg_name(rv, Bool_.N, 177, "±");
|
||||
Reg_name(rv, Bool_.N, 163, "£");
|
||||
Reg_name(rv, Bool_.N, 8242, "′");
|
||||
Reg_name(rv, Bool_.N, 8243, "″");
|
||||
Reg_name(rv, Bool_.N, 8719, "∏");
|
||||
Reg_name(rv, Bool_.N, 8733, "∝");
|
||||
Reg_name(rv, Bool_.N, 936, "Ψ");
|
||||
Reg_name(rv, Bool_.N, 968, "ψ");
|
||||
Reg_name(rv, Bool_.N, 34, """);
|
||||
Reg_name(rv, Bool_.N, 8730, "√");
|
||||
Reg_name(rv, Bool_.N, 9002, "⟩");
|
||||
Reg_name(rv, Bool_.N, 187, "»");
|
||||
Reg_name(rv, Bool_.N, 8594, "→");
|
||||
Reg_name(rv, Bool_.N, 8658, "⇒");
|
||||
Reg_name(rv, Bool_.N, 8969, "⌉");
|
||||
Reg_name(rv, Bool_.N, 8221, "”");
|
||||
Reg_name(rv, Bool_.N, 8476, "ℜ");
|
||||
Reg_name(rv, Bool_.N, 174, "®");
|
||||
Reg_name(rv, Bool_.N, 8971, "⌋");
|
||||
Reg_name(rv, Bool_.N, 929, "Ρ");
|
||||
Reg_name(rv, Bool_.N, 961, "ρ");
|
||||
Reg_name(rv, Bool_.N, 8207, "‏");
|
||||
Reg_name(rv, Bool_.N, 8250, "›");
|
||||
Reg_name(rv, Bool_.N, 8217, "’");
|
||||
Reg_name(rv, Bool_.N, 8218, "‚");
|
||||
Reg_name(rv, Bool_.N, 352, "Š");
|
||||
Reg_name(rv, Bool_.N, 353, "š");
|
||||
Reg_name(rv, Bool_.N, 8901, "⋅");
|
||||
Reg_name(rv, Bool_.N, 167, "§");
|
||||
Reg_name(rv, Bool_.N, 173, "­");
|
||||
Reg_name(rv, Bool_.N, 931, "Σ");
|
||||
Reg_name(rv, Bool_.N, 963, "σ");
|
||||
Reg_name(rv, Bool_.N, 962, "ς");
|
||||
Reg_name(rv, Bool_.N, 8764, "∼");
|
||||
Reg_name(rv, Bool_.N, 9824, "♠");
|
||||
Reg_name(rv, Bool_.N, 8834, "⊂");
|
||||
Reg_name(rv, Bool_.N, 8838, "⊆");
|
||||
Reg_name(rv, Bool_.N, 8721, "∑");
|
||||
Reg_name(rv, Bool_.N, 8835, "⊃");
|
||||
Reg_name(rv, Bool_.N, 185, "¹");
|
||||
Reg_name(rv, Bool_.N, 178, "²");
|
||||
Reg_name(rv, Bool_.N, 179, "³");
|
||||
Reg_name(rv, Bool_.N, 8839, "⊇");
|
||||
Reg_name(rv, Bool_.N, 223, "ß");
|
||||
Reg_name(rv, Bool_.N, 932, "Τ");
|
||||
Reg_name(rv, Bool_.N, 964, "τ");
|
||||
Reg_name(rv, Bool_.N, 8756, "∴");
|
||||
Reg_name(rv, Bool_.N, 920, "Θ");
|
||||
Reg_name(rv, Bool_.N, 952, "θ");
|
||||
Reg_name(rv, Bool_.N, 977, "ϑ");
|
||||
Reg_name(rv, Bool_.N, 8201, " ");
|
||||
Reg_name(rv, Bool_.N, 222, "Þ");
|
||||
Reg_name(rv, Bool_.N, 254, "þ");
|
||||
Reg_name(rv, Bool_.N, 732, "˜");
|
||||
Reg_name(rv, Bool_.N, 215, "×");
|
||||
Reg_name(rv, Bool_.N, 8482, "™");
|
||||
Reg_name(rv, Bool_.N, 218, "Ú");
|
||||
Reg_name(rv, Bool_.N, 250, "ú");
|
||||
Reg_name(rv, Bool_.N, 8593, "↑");
|
||||
Reg_name(rv, Bool_.N, 8657, "⇑");
|
||||
Reg_name(rv, Bool_.N, 219, "Û");
|
||||
Reg_name(rv, Bool_.N, 251, "û");
|
||||
Reg_name(rv, Bool_.N, 217, "Ù");
|
||||
Reg_name(rv, Bool_.N, 249, "ù");
|
||||
Reg_name(rv, Bool_.N, 168, "¨");
|
||||
Reg_name(rv, Bool_.N, 978, "ϒ");
|
||||
Reg_name(rv, Bool_.N, 933, "Υ");
|
||||
Reg_name(rv, Bool_.N, 965, "υ");
|
||||
Reg_name(rv, Bool_.N, 220, "Ü");
|
||||
Reg_name(rv, Bool_.N, 252, "ü");
|
||||
Reg_name(rv, Bool_.N, 8472, "℘");
|
||||
Reg_name(rv, Bool_.N, 926, "Ξ");
|
||||
Reg_name(rv, Bool_.N, 958, "ξ");
|
||||
Reg_name(rv, Bool_.N, 221, "Ý");
|
||||
Reg_name(rv, Bool_.N, 253, "ý");
|
||||
Reg_name(rv, Bool_.N, 165, "¥");
|
||||
Reg_name(rv, Bool_.N, 376, "Ÿ");
|
||||
Reg_name(rv, Bool_.N, 255, "ÿ");
|
||||
Reg_name(rv, Bool_.N, 918, "Ζ");
|
||||
Reg_name(rv, Bool_.N, 950, "ζ");
|
||||
Reg_name(rv, Bool_.N, 8205, "‍");
|
||||
Reg_name(rv, Bool_.N, 8204, "‌");
|
||||
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_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_a7(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 "& " will be valid;
|
||||
trie.Add_obj(key, itm);
|
||||
}
|
||||
private static void Reg_prefix(Btrie_slim_mgr trie, byte prefix_type, String prefix) {
|
||||
byte[] prefix_ary = Bry_.new_a7(prefix);
|
||||
Xop_amp_trie_itm itm = new Xop_amp_trie_itm(prefix_type, Xop_amp_trie_itm.Char_int_null, prefix_ary);
|
||||
trie.Add_obj(prefix_ary, itm);
|
||||
}
|
||||
}
|
||||
58
400_xowa/src/gplx/xowa/parsers/amps/Xop_amp_trie_itm.java
Normal file
58
400_xowa/src/gplx/xowa/parsers/amps/Xop_amp_trie_itm.java
Normal file
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
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.parsers.amps; import gplx.*; import gplx.xowa.*; import gplx.xowa.parsers.*;
|
||||
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;
|
||||
this.utf8_bry = gplx.intl.Utf16_.Encode_int_to_bry(char_int);
|
||||
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 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: " "
|
||||
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: "<" should be written as "<", not "<"
|
||||
break;
|
||||
default:
|
||||
bfr.Add(Xoh_lnki_title_fmtr.Escape_bgn); // &#
|
||||
bfr.Add_int_variable(char_int); // 160
|
||||
bfr.Add_byte(Byte_ascii.Semic); // ;
|
||||
break;
|
||||
}
|
||||
}
|
||||
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: "<" should be written as "<", 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 "["
|
||||
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;
|
||||
}
|
||||
32
400_xowa/src/gplx/xowa/parsers/amps/Xop_amp_wkr.java
Normal file
32
400_xowa/src/gplx/xowa/parsers/amps/Xop_amp_wkr.java
Normal file
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
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.parsers.amps; import gplx.*; import gplx.xowa.*; import gplx.xowa.parsers.*;
|
||||
public class Xop_amp_wkr implements Xop_ctx_wkr {
|
||||
public void Ctor_ctx(Xop_ctx ctx) {}
|
||||
public void Page_bgn(Xop_ctx ctx, Xop_root_tkn root) {}
|
||||
public void Page_end(Xop_ctx ctx, Xop_root_tkn root, byte[] src, int src_len) {}
|
||||
public int Make_tkn(Xop_ctx ctx, Xop_tkn_mkr tkn_mkr, Xop_root_tkn root, byte[] src, int src_len, int bgn, int cur_pos) {
|
||||
if (cur_pos == src_len) return ctx.Lxr_make_txt_(cur_pos); // NOTE: & is last char in page; strange and rare, but don't raise error
|
||||
Xop_amp_mgr amp_mgr = ctx.App().Parser_amp_mgr();
|
||||
Xop_tkn_itm amp_tkn = amp_mgr.Parse_as_tkn(tkn_mkr, src, src_len, bgn, cur_pos);
|
||||
int rv_pos = amp_mgr.Rslt_pos();
|
||||
if (amp_tkn == null) return ctx.Lxr_make_txt_(rv_pos);
|
||||
ctx.Subs_add(root, amp_tkn);
|
||||
return rv_pos;
|
||||
}
|
||||
}
|
||||
41
400_xowa/src/gplx/xowa/parsers/amps/Xop_amp_wkr_tst.java
Normal file
41
400_xowa/src/gplx/xowa/parsers/amps/Xop_amp_wkr_tst.java
Normal file
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
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.parsers.amps; import gplx.*; import gplx.xowa.*; import gplx.xowa.parsers.*;
|
||||
import org.junit.*;
|
||||
public class Xop_amp_wkr_tst {
|
||||
private Xop_fxt fxt = new Xop_fxt();
|
||||
@Test public void Name() {fxt.Test_parse_page_wiki("&" , fxt.tkn_html_ref_("&"));} // check for html_ref
|
||||
@Test public void Name_fail() {fxt.Test_parse_page_wiki("&nil;" , fxt.tkn_txt_(0, 5));} // check for text
|
||||
@Test public void Hex() {fxt.Test_parse_page_wiki("Σ" , fxt.tkn_html_ncr_(931));} // check for html_ncr; Σ: http://en.wikipedia.org/wiki/Numeric_character_reference
|
||||
@Test public void Num_fail_incomplete() {fxt.Test_parse_page_wiki("&#" , fxt.tkn_txt_());}
|
||||
@Test public void Convert_to_named() {fxt.Test_parse_page_wiki_str("&" , "&");} // note that & is printed, not &
|
||||
@Test public void Convert_to_named_amp() {fxt.Test_parse_page_wiki_str("&" , "&");} // PURPOSE: html_wtr was not handling & only
|
||||
@Test public void Convert_to_numeric() {fxt.Test_parse_page_wiki_str("á" , "á");} // testing that á is outputted, not á
|
||||
@Test public void Defect_bad_code_fails() { // PURPOSE: early rewrite of Xop_amp_mgr caused Xoh_html_wtr_escaper to fail with array out of bounds error; EX:w:Czech_Republic; DATE:2014-05-11
|
||||
fxt.Test_parse_page_wiki_str
|
||||
( "[[File:A.png|alt=<p> </p>]]" // basically checks amp parsing inside xnde inside lnki's alt (which uses different parsing code
|
||||
, "<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\" /></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><iframe></code>) b"
|
||||
, "a <code><iframe></code>) b" // < should not become <
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user