mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
v2.9.3.1
This commit is contained in:
@@ -16,9 +16,10 @@ 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.tblws; import gplx.*; import gplx.xowa.*; import gplx.xowa.parsers.*;
|
||||
import gplx.core.btries.*; import gplx.xowa.parsers.paras.*; import gplx.xowa.parsers.lnkis.*; import gplx.xowa.parsers.miscs.*;
|
||||
import gplx.core.btries.*; import gplx.xowa.langs.*;
|
||||
import gplx.xowa.parsers.paras.*; import gplx.xowa.parsers.lnkis.*; import gplx.xowa.parsers.miscs.*;
|
||||
public class Xop_tblw_lxr implements Xop_lxr {
|
||||
public byte Lxr_tid() {return Xop_lxr_.Tid_tblw;}
|
||||
public int Lxr_tid() {return Xop_lxr_.Tid_tblw;}
|
||||
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) {
|
||||
int rv = Handle_bang(wlxr_type, ctx, ctx.Tkn_mkr(), root, src, src_len, bgn_pos, cur_pos);
|
||||
if (rv != Continue) return rv;
|
||||
@@ -54,11 +55,11 @@ public class Xop_tblw_lxr implements Xop_lxr {
|
||||
}
|
||||
}
|
||||
if (wlxr_type == Xop_tblw_wkr.Tblw_type_th2) { // !!; extra check to make sure \n! exists; DATE:2014-10-19
|
||||
int prv_th_pos = Bry_finder.Find_bwd(src, Byte_ascii.Nl, bgn_pos); // search for previous \n
|
||||
boolean invalid = prv_th_pos == Bry_finder.Not_found; // no \n; invalid
|
||||
int prv_th_pos = Bry_find_.Find_bwd(src, Byte_ascii.Nl, bgn_pos); // search for previous \n
|
||||
boolean invalid = prv_th_pos == Bry_find_.Not_found; // no \n; invalid
|
||||
if (!invalid) {
|
||||
++prv_th_pos; // skip \n
|
||||
prv_th_pos = Bry_finder.Find_fwd_while_space_or_tab(src, prv_th_pos, src_len); // skip \s; needed for "\n\s!" which is still a tblw
|
||||
prv_th_pos = Bry_find_.Find_fwd_while_space_or_tab(src, prv_th_pos, src_len); // skip \s; needed for "\n\s!" which is still a tblw
|
||||
if (prv_th_pos == bgn_pos) // invalid: "\n" is directly in front of "!!"
|
||||
invalid = true;
|
||||
else
|
||||
@@ -129,6 +130,7 @@ public class Xop_tblw_lxr implements Xop_lxr {
|
||||
core_trie.Add(Hook_th2, new Xop_tblw_lxr(Xop_tblw_wkr.Tblw_type_th2));
|
||||
}
|
||||
public void Init_by_lang(Xol_lang lang, Btrie_fast_mgr core_trie) {}
|
||||
public void Term(Btrie_fast_mgr core_trie) {}
|
||||
public static final byte[] Hook_tb = Bry_.new_a7("\n{|"), Hook_te = Bry_.new_a7("\n|}"), Hook_tr = Bry_.new_a7("\n|-")
|
||||
, Hook_td = Bry_.new_a7("\n|"), Hook_th = Bry_.new_a7("\n!"), Hook_tc = Bry_.new_a7("\n|+")
|
||||
, Hook_td2 = Bry_.new_a7("||"), Hook_th2 = Bry_.new_a7("!!");
|
||||
|
||||
@@ -16,6 +16,7 @@ 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.tblws; import gplx.*; import gplx.xowa.*; import gplx.xowa.parsers.*;
|
||||
import gplx.core.tests.*;
|
||||
public class Xop_tblw_tb_tkn_chkr extends Xop_tkn_chkr_base {
|
||||
@Override public Class<?> TypeOf() {return Xop_tblw_tb_tkn.class;}
|
||||
@Override public byte Tkn_tid() {return Xop_tkn_itm_.Tid_tblw_tb;}
|
||||
|
||||
@@ -16,6 +16,7 @@ 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.tblws; import gplx.*; import gplx.xowa.*; import gplx.xowa.parsers.*;
|
||||
import gplx.core.tests.*;
|
||||
public class Xop_tblw_tc_tkn_chkr extends Xop_tkn_chkr_base {
|
||||
@Override public Class<?> TypeOf() {return Xop_tblw_tc_tkn.class;}
|
||||
@Override public byte Tkn_tid() {return Xop_tkn_itm_.Tid_tblw_tc;}
|
||||
|
||||
@@ -16,6 +16,7 @@ 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.tblws; import gplx.*; import gplx.xowa.*; import gplx.xowa.parsers.*;
|
||||
import gplx.core.tests.*;
|
||||
public class Xop_tblw_td_tkn_chkr extends Xop_tkn_chkr_base {
|
||||
@Override public Class<?> TypeOf() {return Xop_tblw_td_tkn.class;}
|
||||
@Override public byte Tkn_tid() {return Xop_tkn_itm_.Tid_tblw_td;}
|
||||
|
||||
@@ -16,6 +16,7 @@ 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.tblws; import gplx.*; import gplx.xowa.*; import gplx.xowa.parsers.*;
|
||||
import gplx.core.tests.*;
|
||||
public class Xop_tblw_th_tkn_chkr extends Xop_tkn_chkr_base {
|
||||
@Override public Class<?> TypeOf() {return Xop_tblw_th_tkn.class;}
|
||||
@Override public byte Tkn_tid() {return Xop_tkn_itm_.Tid_tblw_th;}
|
||||
|
||||
@@ -16,6 +16,7 @@ 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.tblws; import gplx.*; import gplx.xowa.*; import gplx.xowa.parsers.*;
|
||||
import gplx.core.tests.*;
|
||||
public class Xop_tblw_tr_tkn_chkr extends Xop_tkn_chkr_base {
|
||||
@Override public Class<?> TypeOf() {return Xop_tblw_tr_tkn.class;}
|
||||
@Override public byte Tkn_tid() {return Xop_tkn_itm_.Tid_tblw_tr;}
|
||||
|
||||
@@ -149,7 +149,7 @@ public class Xop_tblw_wkr implements Xop_ctx_wkr {
|
||||
if (ignore_prv) {
|
||||
ctx.Subs_add(root, tkn_mkr.Ignore(bgn_pos, cur_pos, Xop_ignore_tkn.Ignore_tid_htmlTidy_tblw));
|
||||
++tblw_te_ignore_count;
|
||||
cur_pos = Bry_finder.Find_fwd_until(src, cur_pos, src_len, Byte_ascii.Nl); // NOTE: minor hack; this tblw tkn will be ignored, so ignore any of its attributes as well; gobble up all chars till nl. see: if two consecutive tbs, ignore attributes on 2nd; en.wikibooks.org/wiki/Wikibooks:Featured books
|
||||
cur_pos = Bry_find_.Find_fwd_until(src, cur_pos, src_len, Byte_ascii.Nl); // NOTE: minor hack; this tblw tkn will be ignored, so ignore any of its attributes as well; gobble up all chars till nl. see: if two consecutive tbs, ignore attributes on 2nd; en.wikibooks.org/wiki/Wikibooks:Featured books
|
||||
return cur_pos;
|
||||
}
|
||||
if (auto_create) {
|
||||
@@ -481,7 +481,7 @@ public class Xop_tblw_wkr implements Xop_ctx_wkr {
|
||||
root.Subs_del_between(ctx, subs_bgn, subs_pos);
|
||||
int atrs_bgn = prv_tblw.Src_end(), atrs_end = last_atr_tkn.Src_end();
|
||||
if (prv_tblw.Tkn_tid() == Xop_tkn_itm_.Tid_tblw_tr) // NOTE: if "|-" gobble all trailing dashes; REF: Parser.php!doTableStuff; $line = preg_replace( '#^\|-+#', '', $line ); DATE:2013-06-21
|
||||
atrs_bgn = Bry_finder.Find_fwd_while(src, atrs_bgn, src.length, Byte_ascii.Dash);
|
||||
atrs_bgn = Bry_find_.Find_fwd_while(src, atrs_bgn, src.length, Byte_ascii.Dash);
|
||||
prv_tblw.Atrs_rng_set(atrs_bgn, atrs_end);
|
||||
if (ctx.Parse_tid() == Xop_parser_.Parse_tid_page_wiki && atrs_bgn != -1) {
|
||||
Xop_xatr_itm[] atrs = ctx.App().Xatr_parser().Parse(ctx.Msg_log(), src, atrs_bgn, atrs_end);
|
||||
|
||||
@@ -32,8 +32,8 @@ public class Xop_tblw_ws_itm {
|
||||
trie_itm(rv, Type_tr, Xop_tblw_lxr_ws.Hook_tr);
|
||||
trie_itm(rv, Type_th, Xop_tblw_lxr_ws.Hook_th);
|
||||
trie_itm(rv, Type_tc, Xop_tblw_lxr_ws.Hook_tc);
|
||||
trie_itm(rv, Type_td, Bry_.bytes_(Byte_ascii.Pipe));
|
||||
trie_itm(rv, Type_nl, Bry_.bytes_(Byte_ascii.Nl));
|
||||
trie_itm(rv, Type_td, Bry_.new_bytes(Byte_ascii.Pipe));
|
||||
trie_itm(rv, Type_nl, Bry_.new_bytes(Byte_ascii.Nl));
|
||||
trie_itm_xnde(rv, Xop_xnde_tag_.Tag_table);
|
||||
trie_itm_xnde(rv, Xop_xnde_tag_.Tag_tr);
|
||||
trie_itm_xnde(rv, Xop_xnde_tag_.Tag_td);
|
||||
|
||||
Reference in New Issue
Block a user