1
0
mirror of https://github.com/gnosygnu/xowa.git synced 2024-09-28 22:40:50 +00:00

Htxt: Do not redlink interwiki links [#391]

This commit is contained in:
gnosygnu 2019-03-20 02:58:37 -04:00
parent ca8c4ce5a4
commit ab4cbbd3c1
2 changed files with 38 additions and 2 deletions

View File

@ -49,8 +49,8 @@ public class Xoh_hdoc_wkr__make implements Xoh_hdoc_wkr {
} }
public void On_lnki(gplx.xowa.htmls.core.wkrs.lnkis.Xoh_lnki_data data) { public void On_lnki(gplx.xowa.htmls.core.wkrs.lnkis.Xoh_lnki_data data) {
// <a> node // <a> node
// handle "#" // if not "/wiki/" link, just add html and exit; ISSUE#:391; DATE:2019-03-20
if (data.Href_itm().Tid() == Xoh_anch_href_data.Tid__anch) { if (data.Href_itm().Tid() != Xoh_anch_href_data.Tid__wiki) {
bfr.Add_mid(src, data.Src_bgn(), data.Src_end()); bfr.Add_mid(src, data.Src_bgn(), data.Src_end());
return; return;
} }

View File

@ -0,0 +1,36 @@
/*
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.htmls.core.wkrs.lnkis; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*;
import org.junit.*; import gplx.xowa.htmls.core.makes.tests.*; import gplx.xowa.parsers.lnkis.*;
public class Xoh_lnki_make__basic__tst {
private final Xoh_make_fxt fxt = new Xoh_make_fxt();
@Before public void Init() {fxt.Clear();}
@Test public void Wiki() {
fxt.Test__make("<a href='/wiki/Help:A' title='Help:A'>Help:A</a>", fxt.Page_chkr().Body_("<a id='xolnki_2' href='/wiki/Help:A' title='Help:A'>Help:A</a>"));
}
@Test public void Anch() {
String orig = "<a href='#a'>#a</a>";
fxt.Test__make(orig, fxt.Page_chkr().Body_(orig));
}
@Test public void Site() {
String orig = "<a href='/site/en.wiktionary.org/wiki/A' title='wikt:A'>wikt:A</a>";
fxt.Test__make(orig, fxt.Page_chkr().Body_(orig));
}
@Test public void Inet() {
String orig = "<a href='https://simple.wikisource.org/wiki/A' title='A'>b</a>";
fxt.Test__make(orig, fxt.Page_chkr().Body_(orig));
}
}