mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
Xtn.Math: Swap out math tags with UNIQ
This commit is contained in:
@@ -20,6 +20,7 @@ import gplx.core.primitives.*; import gplx.core.brys.fmtrs.*;
|
||||
import gplx.xowa.wikis.*; import gplx.core.envs.*;
|
||||
import gplx.xowa.files.*;
|
||||
import gplx.xowa.xtns.scribunto.*; import gplx.xowa.xtns.wbases.hwtrs.*; import gplx.xowa.xtns.pfuncs.ifs.*; import gplx.xowa.xtns.pfuncs.times.*; import gplx.xowa.xtns.pfuncs.ttls.*;
|
||||
import gplx.xowa.parsers.uniqs.*;
|
||||
public class Xow_parser_mgr {
|
||||
private final Xowe_wiki wiki; private final Xop_tkn_mkr tkn_mkr;
|
||||
public Xow_parser_mgr(Xowe_wiki wiki) {
|
||||
@@ -37,6 +38,7 @@ public class Xow_parser_mgr {
|
||||
public Pft_func_formatdate_bldr Date_fmt_bldr() {return date_fmt_bldr;} private final Pft_func_formatdate_bldr date_fmt_bldr = new Pft_func_formatdate_bldr();
|
||||
public Gfo_number_parser Pp_num_parser() {return pp_num_parser;} private final Gfo_number_parser pp_num_parser = new Gfo_number_parser().Ignore_space_at_end_y_();
|
||||
public int[] Rel2abs_ary() {return rel2abs_ary;} private final int[] rel2abs_ary = new int[Pfunc_rel2abs.Ttl_max];
|
||||
public Xop_uniq_mgr Uniq_mgr() {return uniq_mgr;} private final Xop_uniq_mgr uniq_mgr = new Xop_uniq_mgr();
|
||||
public boolean Lst__recursing() {return lst_recursing;} private boolean lst_recursing; public void Lst__recursing_(boolean v) {lst_recursing = v;}
|
||||
public Bry_bfr Wbase__time__bfr() {return wbase__time__bfr;} private final Bry_bfr wbase__time__bfr = Bry_bfr_.New();
|
||||
public Bry_fmtr Wbase__time__fmtr() {return wbase__time__fmtr;} private final Bry_fmtr wbase__time__fmtr = Bry_fmtr.new_();
|
||||
@@ -76,6 +78,7 @@ public class Xow_parser_mgr {
|
||||
if (!Env_.Mode_testing()) wiki.Init_assert();
|
||||
tmpl_stack_ary = Bry_.Ary_empty;
|
||||
tmpl_stack_ary_len = tmpl_stack_ary_max = 0;
|
||||
uniq_mgr.Clear();
|
||||
|
||||
scrib.When_page_changed(page); // notify scribunto about page changed
|
||||
ctx.Page_(page);
|
||||
|
||||
@@ -31,6 +31,11 @@ public class Xop_uniq_mgr { // REF.MW:/parser/StripState.php
|
||||
return key;
|
||||
}
|
||||
public byte[] Get(byte[] key) {return (byte[])general_trie.Match_exact(key, 0, key.length);}
|
||||
public void Parse(Bry_bfr bfr) {
|
||||
if (general_trie.Count() == 0) return;
|
||||
byte[] rv = Parse(key_bfr, general_trie, bfr.To_bry_and_clear());
|
||||
bfr.Add(rv);
|
||||
}
|
||||
public byte[] Parse(byte[] src) {return Parse(key_bfr, general_trie, src);}
|
||||
private byte[] Parse(Bry_bfr bfr, Btrie_slim_mgr trie, byte[] src) {
|
||||
int src_len = src.length;
|
||||
|
||||
@@ -184,6 +184,5 @@ public class Vnt_convert_lang {
|
||||
private static final Btrie_fast_mgr trie = Btrie_fast_mgr.cs()
|
||||
.Add_bry_byte(Bry__curly_bgn, Tid__curly_bgn)
|
||||
.Add_bry_byte(Bry__curly_end, Tid__curly_end);
|
||||
public static final byte[] Bry__armor_bgn = Bry_.new_a7("-{R|"), Bry__armor_end = Bry_.new_a7("}-");
|
||||
private static final int max_depth = 32;
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.parsers.xndes; import gplx.*; import gplx.xowa.*; import gplx.xowa.parsers.*;
|
||||
import org.junit.*; import gplx.xowa.wikis.nss.*;
|
||||
public class Xop_xnde_wkr__basic_tst {
|
||||
private final Xop_fxt fxt = new Xop_fxt();
|
||||
private final Xop_fxt fxt = new Xop_fxt();
|
||||
@After public void term() {fxt.Init_para_n_();}
|
||||
@Test public void Escape_lt() { // PURPOSE: some templates have unknown tags; PAGE:en.w:PHP
|
||||
fxt.Init_para_y_();
|
||||
@@ -103,9 +103,9 @@ public class Xop_xnde_wkr__basic_tst {
|
||||
}
|
||||
@Test public void CaseSensitivity_xtn_3() {// PURPOSE: xtn xnde must do case-insensitive match DATE:2013-12-02
|
||||
fxt.Test_parse_page_all_str
|
||||
( "<matH>a</math> b <math>c</matH>" // <matH> should match </math> not </matH>
|
||||
, "<span id='xowa_math_txt_0'>a</span> b <span id='xowa_math_txt_0'>c</span>"
|
||||
);
|
||||
( "<translatE>a</translate> b <translate>c</translatE>" // <translatE> should match </translate> not </translatE>
|
||||
, "a b c"
|
||||
);
|
||||
}
|
||||
@Test public void Whitelist() {
|
||||
fxt.Test_parse_page_all_str("<span onload='alert()'></span>", "<span></span>");
|
||||
@@ -122,11 +122,6 @@ public class Xop_xnde_wkr__basic_tst {
|
||||
@Test public void Script_in_syntaxhighlight() {
|
||||
fxt.Test_parse_page_all_str("<syntaxhighlight><script>alert('fail');</script></syntaxhighlight>", "<div class=\"mw-highlight\"><pre style=\"overflow:auto\"><script>alert('fail');</script></pre></div>");
|
||||
}
|
||||
@Test public void Script_in_math() {
|
||||
fxt.App().File_mgr().Math_mgr().Renderer_is_mathjax_(false);
|
||||
fxt.Test_parse_page_all_str("<math><script>alert('fail');</script></math>", "<img id='xowa_math_img_0' src='' width='' height=''/><span id='xowa_math_txt_0'><script>alert('fail');</script></span>");
|
||||
fxt.App().File_mgr().Math_mgr().Renderer_is_mathjax_(true);
|
||||
}
|
||||
@Test public void Html5_time() {// PURPOSE: HTML5; should output self (i.e.: must be whitelisted)
|
||||
fxt.Test_parse_page_wiki_str("<time class=\"dtstart\" datetime=\"2010-10-10\">10 October 2010</time>", "<time class=\"dtstart\" datetime=\"2010-10-10\">10 October 2010</time>");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user