mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
Html: Move get_elem_val to xo.elem
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.xowa.xtns.syntax_highlights; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
|
||||
import org.junit.*;
|
||||
public class Int_rng_mgr_tst {
|
||||
private final Int_rng_mgr_fxt fxt = new Int_rng_mgr_fxt();
|
||||
@Before public void init() {fxt.Clear();}
|
||||
@Test public void Val() {fxt.Test_parse_y("2") .Test_match_y(2) .Test_match_n(1, 3);}
|
||||
@Test public void Rng() {fxt.Test_parse_y("2-5") .Test_match_y(2, 3, 4, 5) .Test_match_n(0, 1, 6);}
|
||||
@Test public void Many() {fxt.Test_parse_y("1,3-5,7,9-10") .Test_match_y(1, 3, 4, 5, 7, 9, 10) .Test_match_n(0, 2, 6, 8, 11);}
|
||||
}
|
||||
class Int_rng_mgr_fxt {
|
||||
private Int_rng_mgr_base mgr;
|
||||
public void Clear() {
|
||||
if (mgr == null)
|
||||
mgr = new Int_rng_mgr_base();
|
||||
mgr.Clear();
|
||||
}
|
||||
public Int_rng_mgr_fxt Test_parse_y(String raw) {return Test_parse(raw, true);}
|
||||
public Int_rng_mgr_fxt Test_parse_n(String raw) {return Test_parse(raw, false);}
|
||||
public Int_rng_mgr_fxt Test_parse(String raw, boolean expd) {Tfds.Eq(expd, mgr.Parse(Bry_.new_a7(raw))); return this;}
|
||||
public Int_rng_mgr_fxt Test_match_y(int... v) {return Test_match(v, true);}
|
||||
public Int_rng_mgr_fxt Test_match_n(int... v) {return Test_match(v, false);}
|
||||
public Int_rng_mgr_fxt Test_match(int[] ary, boolean expd) {
|
||||
int len = ary.length;
|
||||
for (int i = 0; i < len; i++) {
|
||||
Tfds.Eq(expd, mgr.Match(ary[i]), Int_.To_str(ary[i]));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,172 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.xowa.xtns.syntax_highlights; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
|
||||
import org.junit.*;
|
||||
public class Synh_xtn_nde_tst {
|
||||
private final Xop_fxt fxt = new Xop_fxt();
|
||||
@Test public void Basic() {
|
||||
fxt.Test_parse_page_all_str("<syntaxHighlight>abc</syntaxHighlight>", "<div class=\"mw-highlight\"><pre style=\"overflow:auto\">abc</pre></div>");
|
||||
}
|
||||
@Test public void Text() {
|
||||
fxt.Test_parse_page_all_str("<syntaxHighlight lang=\"text\">abc</syntaxHighlight>", "<div class=\"mw-highlight\"><pre style=\"overflow:auto\">abc</pre></div>");
|
||||
}
|
||||
@Test public void Style_pre() {
|
||||
fxt.Test_parse_page_all_str("<syntaxHighlight style=\"color:red;\">abc</syntaxHighlight>", "<div class=\"mw-highlight\" style=\"color:red;\"><pre style=\"overflow:auto\">abc</pre></div>");
|
||||
}
|
||||
@Test public void Style_code() {
|
||||
fxt.Test_parse_page_all_str("<syntaxHighlight lang=\"text\" style=\"color:red;\">abc</syntaxHighlight>", "<div class=\"mw-highlight\" style=\"color:red;\"><pre style=\"overflow:auto\">abc</pre></div>");
|
||||
}
|
||||
@Test public void Trim_ws() {
|
||||
fxt.Test_parse_page_all_str(String_.Concat_lines_nl
|
||||
( "<syntaxHighlight>"
|
||||
, "abc"
|
||||
, "</syntaxHighlight>"
|
||||
), String_.Concat_lines_nl
|
||||
( "<div class=\"mw-highlight\"><pre style=\"overflow:auto\">"
|
||||
, "abc"
|
||||
, "</pre></div>"
|
||||
));
|
||||
}
|
||||
@Test public void Line() {
|
||||
fxt.Test_parse_page_all_str(String_.Concat_lines_nl
|
||||
( "<syntaxHighlight line>"
|
||||
, "a"
|
||||
, "b"
|
||||
, "</syntaxHighlight>"
|
||||
), String_.Concat_lines_nl
|
||||
( "<div class=\"mw-highlight\"><pre style=\"overflow:auto\">"
|
||||
, "<span style=\"-moz-user-select:none;\">1 </span><span>a</span>"
|
||||
, "<span style=\"-moz-user-select:none;\">2 </span><span>b</span>"
|
||||
, "</pre></div>"
|
||||
));
|
||||
}
|
||||
@Test public void Start() {
|
||||
fxt.Test_parse_page_all_str(String_.Concat_lines_nl
|
||||
( "<syntaxHighlight line start=3>"
|
||||
, "a"
|
||||
, "b"
|
||||
, "</syntaxHighlight>"
|
||||
), String_.Concat_lines_nl
|
||||
( "<div class=\"mw-highlight\"><pre style=\"overflow:auto\">"
|
||||
, "<span style=\"-moz-user-select:none;\">3 </span><span>a</span>"
|
||||
, "<span style=\"-moz-user-select:none;\">4 </span><span>b</span>"
|
||||
, "</pre></div>"
|
||||
));
|
||||
}
|
||||
@Test public void Highlight() {
|
||||
fxt.Test_parse_page_all_str(String_.Concat_lines_nl
|
||||
( "<syntaxHighlight line highlight='1,3'>"
|
||||
, "a"
|
||||
, "b"
|
||||
, "c"
|
||||
, "</syntaxHighlight>"
|
||||
), String_.Concat_lines_nl
|
||||
( "<div class=\"mw-highlight\"><pre style=\"overflow:auto\">"
|
||||
, "<span style=\"-moz-user-select:none;\">1 </span><span style=\"background-color: #FFFFCC;\">a</span>"
|
||||
, "<span style=\"-moz-user-select:none;\">2 </span><span>b</span>"
|
||||
, "<span style=\"-moz-user-select:none;\">3 </span><span style=\"background-color: #FFFFCC;\">c</span>"
|
||||
, "</pre></div>"
|
||||
));
|
||||
}
|
||||
@Test public void Enclose_none() {
|
||||
fxt.Test_parse_page_all_str(String_.Concat_lines_nl
|
||||
( "<syntaxHighlight enclose=none style='color:red'>"
|
||||
, "a"
|
||||
, "b"
|
||||
, "c"
|
||||
, "</syntaxHighlight>"
|
||||
), String_.Concat_lines_nl
|
||||
( "<code class=\"mw-highlight\" style=\"color:red\">"
|
||||
, "a"
|
||||
, "b"
|
||||
, "c"
|
||||
, "</code>"
|
||||
));
|
||||
}
|
||||
@Test public void Line_padded() {
|
||||
fxt.Test_parse_page_all_str(String_.Concat_lines_nl
|
||||
( "<syntaxHighlight line start=9>"
|
||||
, "a"
|
||||
, "b"
|
||||
, "</syntaxHighlight>"
|
||||
), String_.Concat_lines_nl
|
||||
( "<div class=\"mw-highlight\"><pre style=\"overflow:auto\">"
|
||||
, "<span style=\"-moz-user-select:none;\"> 9 </span><span>a</span>"
|
||||
, "<span style=\"-moz-user-select:none;\">10 </span><span>b</span>"
|
||||
, "</pre></div>"
|
||||
));
|
||||
}
|
||||
@Test public void EndTag_has_ws() { // PURPOSE: </syntaxhighlight > not being closed correctly; PAGE:en.w:Mergesort; updated; DATE:2014-06-24
|
||||
fxt.Init_para_y_();
|
||||
fxt.Test_parse_page_wiki_str(String_.Concat_lines_nl_skip_last
|
||||
( "a"
|
||||
, "<syntaxhighlight>"
|
||||
, "b"
|
||||
, "</syntaxhighlight >"
|
||||
, "c"
|
||||
, "<syntaxhighlight>"
|
||||
, "d"
|
||||
, "</syntaxhighlight>"
|
||||
), String_.Concat_lines_nl_skip_last
|
||||
( "<p>a"
|
||||
, "</p>"
|
||||
, "<div class=\"mw-highlight\"><pre style=\"overflow:auto\">"
|
||||
, "b"
|
||||
, "</pre></div>"
|
||||
, ""
|
||||
, "<p>c"
|
||||
, "</p>"
|
||||
, "<div class=\"mw-highlight\"><pre style=\"overflow:auto\">"
|
||||
, "d"
|
||||
, "</pre></div>"
|
||||
, ""
|
||||
));
|
||||
fxt.Init_para_n_();
|
||||
}
|
||||
@Test public void Trim_ws_from_end_tab() {// PURPOSE: trim ws between "abc" and "</syntaxhighlight"; PAGE:en.w:Comment_(computer_programming); DATE:2014-06-23
|
||||
fxt.Test_parse_page_all_str(String_.Concat_lines_nl
|
||||
( "<syntaxHighlight>"
|
||||
, "abc"
|
||||
, " </syntaxHighlight>" // trim ws here
|
||||
), String_.Concat_lines_nl
|
||||
( "<div class=\"mw-highlight\"><pre style=\"overflow:auto\">"
|
||||
, "abc"
|
||||
, "</pre></div>"
|
||||
));
|
||||
}
|
||||
@Test public void Pre() {// PURPOSE: handle pre; PAGE:en.w:Comment_(computer_programming); DATE:2014-06-23
|
||||
fxt.Init_para_y_();
|
||||
fxt.Test_parse_page_all_str(String_.Concat_lines_nl
|
||||
( "a"
|
||||
, ""
|
||||
, " <syntaxHighlight>"
|
||||
, " b"
|
||||
, " </syntaxHighlight>" // trim ws here
|
||||
, ""
|
||||
, "c"
|
||||
), String_.Concat_lines_nl
|
||||
( "<p>a"
|
||||
, "</p>"
|
||||
, " <div class=\"mw-highlight\"><pre style=\"overflow:auto\">"
|
||||
, " b"
|
||||
, "</pre></div>"
|
||||
, ""
|
||||
, "<p>c"
|
||||
, "</p>"
|
||||
));
|
||||
fxt.Init_para_n_();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user