mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
'v3.6.4.2'
This commit is contained in:
@@ -67,8 +67,18 @@ class Xoh_toc_wtr {
|
||||
switch (tag_id) {
|
||||
case Gfh_tag_.Id__eos: // eos; return;
|
||||
return;
|
||||
case Gfh_tag_.Id__i: // always print tag
|
||||
case Gfh_tag_.Id__b:
|
||||
case Gfh_tag_.Id__comment: // never print tag
|
||||
case Gfh_tag_.Id__img:
|
||||
case Gfh_tag_.Id__br: case Gfh_tag_.Id__hr: // always ignore in TOC text; EX: en.wikipedia.org/wiki/Magnetic_resonance_imaging; ====''T''<span style="display:inline-block; margin-bottom:-0.3em; vertical-align:-0.4em; line-height:1.2em; font-size:85%; text-align:left;">*<br />2</span>-weighted MRI====
|
||||
case Gfh_tag_.Id__h1: case Gfh_tag_.Id__h2: case Gfh_tag_.Id__h3: case Gfh_tag_.Id__h4: case Gfh_tag_.Id__h5: case Gfh_tag_.Id__h6:
|
||||
case Gfh_tag_.Id__ul: case Gfh_tag_.Id__ol: case Gfh_tag_.Id__dd: case Gfh_tag_.Id__dt: case Gfh_tag_.Id__li:
|
||||
case Gfh_tag_.Id__table: case Gfh_tag_.Id__tr: case Gfh_tag_.Id__td: case Gfh_tag_.Id__th: case Gfh_tag_.Id__thead: case Gfh_tag_.Id__tbody: case Gfh_tag_.Id__caption:
|
||||
// case Gfh_tag_.Id__ref: // NOTE: don't bother printing references; NOTE: should never show up
|
||||
print_tag = false;
|
||||
recurse = false;
|
||||
break;
|
||||
case Gfh_tag_.Id__b: // always print tag
|
||||
case Gfh_tag_.Id__i:
|
||||
print_tag = true;
|
||||
break;
|
||||
case Gfh_tag_.Id__small: // only print tag if not nested
|
||||
@@ -79,13 +89,6 @@ class Xoh_toc_wtr {
|
||||
print_tag = true;
|
||||
break;
|
||||
}
|
||||
case Gfh_tag_.Id__comment: // never print tag
|
||||
case Gfh_tag_.Id__img:
|
||||
case Gfh_tag_.Id__br:
|
||||
case Gfh_tag_.Id__hr:
|
||||
print_tag = false;
|
||||
recurse = false;
|
||||
break;
|
||||
case Gfh_tag_.Id__a: // a never prints tag; also, also, do not recurse if ref
|
||||
print_tag = false;
|
||||
byte[] href_val = lhs.Atrs__get_as_bry(Gfh_atr_.Bry__href);
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.htmls.tocs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*;
|
||||
import org.junit.*; import gplx.core.tests.*;
|
||||
public class Xoh_toc_wtr__anch__tst {
|
||||
@Before public void init() {fxt.Clear();} private final Xoh_toc_wtr_fxt fxt = new Xoh_toc_wtr_fxt();
|
||||
@Test public void Caption() {
|
||||
fxt.Test__convert("<a href=\"/wiki/A\">b</a>", "b");
|
||||
}
|
||||
@Test public void Ref() { // PURPOSE: ref contents should not print in TOC; DATE:2013-07-23
|
||||
fxt.Test__convert("a<sup id=\"cite_ref-0\" class=\"reference\"><a href=\"#cite_note-0\">[1]</a></sup>", "a");
|
||||
}
|
||||
@Test public void Category() { // PURPOSE: literal Category should show in in TOC; EX: de.w:1234; DATE:2014-01-21
|
||||
fxt.Test__convert("A<a href=\"/wiki/Category:B\">Category:B</a>", "ACategory:B");
|
||||
}
|
||||
@Test public void File() { // PURPOSE: file should not show in in TOC; EX: tr.w:D<>nya_Miraslari; DATE:2014-06-06
|
||||
fxt.Test__convert
|
||||
( "<a href=\"/wiki/File:A.png\" class=\"image\" xowa_title=\"A.png\"><img id=\"xoimg_0\" alt=\"\" src=\"file:///mem/wiki/repo/trg/orig/7/0/A.png\" width=\"0\" height=\"0\" /></a> b"
|
||||
, "b");
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.htmls.tocs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*;
|
||||
import org.junit.*; import gplx.core.tests.*;
|
||||
public class Xoh_toc_wtr_tst {
|
||||
public class Xoh_toc_wtr__keep__tst {
|
||||
@Before public void init() {fxt.Clear();} private final Xoh_toc_wtr_fxt fxt = new Xoh_toc_wtr_fxt();
|
||||
@Test public void Basic() {
|
||||
fxt.Test__convert("a b c", "a b c");
|
||||
@@ -25,39 +25,15 @@ public class Xoh_toc_wtr_tst {
|
||||
@Test public void Ws() {
|
||||
fxt.Test__convert(" a b ", "a b");
|
||||
}
|
||||
@Test public void Comment() {
|
||||
fxt.Test__convert("<!--a-->", "");
|
||||
}
|
||||
@Test public void Comment__many() {
|
||||
fxt.Test__convert("1<!--2-->3<!--4-->5", "135");
|
||||
}
|
||||
@Test public void Comment__dangling() {
|
||||
fxt.Test__convert("1<!--2-->3<!--4->5", "13<!--4->5");
|
||||
}
|
||||
@Test public void Apos__italic() {
|
||||
fxt.Test__convert("<i>a</i>", "<i>a</i>");
|
||||
}
|
||||
@Test public void Lnki__caption() {
|
||||
fxt.Test__convert("<a href=\"/wiki/A\">b</a>", "b");
|
||||
}
|
||||
@Test public void Lnki__caption__nest() {
|
||||
fxt.Test__convert("<a href=\"/wiki/A\">b<i>c</i>d</a>", "b<i>c</i>d");
|
||||
}
|
||||
@Test public void Xnde__small() {
|
||||
fxt.Test__convert("<small>a</small>", "a");
|
||||
}
|
||||
@Test public void Xnde__sup() {
|
||||
fxt.Test__convert("<sup>a</sup>", "a");
|
||||
}
|
||||
@Test public void Xnde__nest__xnde() { // <sup> removed but not <small>
|
||||
fxt.Test__convert("a <sup>b<small>c</small>d</sup> e", "a b<small>c</small>d e");
|
||||
}
|
||||
@Test public void Xnde__nest__lnki() { // <small> and <a> removed
|
||||
fxt.Test__convert("<small><a href=\"/wiki/A\">b</a></small>", "b");
|
||||
}
|
||||
@Test public void Amp__ncr() {
|
||||
fxt.Test__convert("[a]", "[a]");
|
||||
}
|
||||
@Test public void Italic() {
|
||||
fxt.Test__convert("<i>a</i>", "<i>a</i>");
|
||||
}
|
||||
@Test public void Caption() {
|
||||
fxt.Test__convert("<a href=\"/wiki/A\">b</a>", "b");
|
||||
}
|
||||
@Test public void Ref() { // PURPOSE: ref contents should not print in TOC; DATE:2013-07-23
|
||||
fxt.Test__convert("a<sup id=\"cite_ref-0\" class=\"reference\"><a href=\"#cite_note-0\">[1]</a></sup>", "a");
|
||||
}
|
||||
@@ -69,12 +45,6 @@ public class Xoh_toc_wtr_tst {
|
||||
( "<a href=\"/wiki/File:A.png\" class=\"image\" xowa_title=\"A.png\"><img id=\"xoimg_0\" alt=\"\" src=\"file:///mem/wiki/repo/trg/orig/7/0/A.png\" width=\"0\" height=\"0\" /></a> b"
|
||||
, "b");
|
||||
}
|
||||
@Test public void Xnde__nest__inline() { // PURPOSE: do not render inline xndes; EX: Magnetic_resonance_imaging
|
||||
fxt.Test__convert("a<span id='b'>b<br/></span>", "ab");
|
||||
}
|
||||
@Test public void Translate_w_comment() { // PURPOSE: <translate> is an xtn and parses its innerText separately; meanwhile, toc_mgr defaults to using the innerText to build toc; EX:Wikidata:Introduction; DATE:2013-07-16
|
||||
fxt.Test__convert("<translate><!--b-->ac</translate>", "ac");
|
||||
}
|
||||
}
|
||||
class Xoh_toc_wtr_fxt {
|
||||
private final Xoh_toc_wtr wtr = new Xoh_toc_wtr();
|
||||
@@ -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.htmls.tocs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*;
|
||||
import org.junit.*; import gplx.core.tests.*;
|
||||
public class Xoh_toc_wtr__nest__tst {
|
||||
@Before public void init() {fxt.Clear();} private final Xoh_toc_wtr_fxt fxt = new Xoh_toc_wtr_fxt();
|
||||
@Test public void Xnde__xnde() { // <sup> removed but not <small>
|
||||
fxt.Test__convert("a <sup>b<small>c</small>d</sup> e", "a b<small>c</small>d e");
|
||||
}
|
||||
@Test public void Xnde__inline() { // PURPOSE: do not render inline xndes; EX: Magnetic_resonance_imaging
|
||||
fxt.Test__convert("a<span id='b'>b<br/></span>", "ab");
|
||||
}
|
||||
@Test public void Xnde__lnki() { // <small> and <a> removed
|
||||
fxt.Test__convert("<small><a href=\"/wiki/A\">b</a></small>", "b");
|
||||
}
|
||||
@Test public void Lnki__xnde() {
|
||||
fxt.Test__convert("<a href=\"/wiki/A\">b<i>c</i>d</a>", "b<i>c</i>d");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.htmls.tocs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*;
|
||||
import org.junit.*; import gplx.core.tests.*;
|
||||
public class Xoh_toc_wtr__skip__tst {
|
||||
@Before public void init() {fxt.Clear();} private final Xoh_toc_wtr_fxt fxt = new Xoh_toc_wtr_fxt();
|
||||
@Test public void Comment() {
|
||||
fxt.Test__convert("<!--a-->", "");
|
||||
}
|
||||
@Test public void Comment__many() {
|
||||
fxt.Test__convert("1<!--2-->3<!--4-->5", "135");
|
||||
}
|
||||
@Test public void Comment__dangling() {
|
||||
fxt.Test__convert("1<!--2-->3<!--4->5", "13<!--4->5");
|
||||
}
|
||||
@Test public void Br() {
|
||||
fxt.Test__convert("a<br/>b", "ab");
|
||||
}
|
||||
@Test public void H2() {
|
||||
fxt.Test__convert("a<h2>b</h2>c", "ac");
|
||||
}
|
||||
@Test public void Li() {
|
||||
fxt.Test__convert("a<ul><li>b</li></ul>c", "ac");
|
||||
}
|
||||
@Test public void Table() {
|
||||
fxt.Test__convert("a<table><tr><td>b</td></tr></table>c", "ac");
|
||||
}
|
||||
@Test public void Xnde__small() {
|
||||
fxt.Test__convert("<small>a</small>", "a");
|
||||
}
|
||||
@Test public void Xnde__sup() {
|
||||
fxt.Test__convert("<sup>a</sup>", "a");
|
||||
}
|
||||
@Test public void Translate() { // PURPOSE: <translate> is an xtn and parses its innerText separately; meanwhile, toc_mgr defaults to using the innerText to build toc; EX:Wikidata:Introduction; DATE:2013-07-16
|
||||
fxt.Test__convert("<translate><!--b-->ac</translate>", "ac");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user