From 911be09aeff8b2dc36bc41de1195e4da55b0ca66 Mon Sep 17 00:00:00 2001 From: gnosygnu Date: Fri, 3 Feb 2017 12:13:33 -0500 Subject: [PATCH] Mw_parse: Port over more code for thumb links (part 2) --- 100_core/src/gplx/Bry_.java | 7 +- 100_core/src/gplx/Bry_bfr.java | 6 +- 100_core/src/gplx/Keyval_hash.java | 3 +- 100_core/src/gplx/Ordered_hash_base.java | 1 - .../src/gplx/core/lists/Hash_adp_base.java | 1 + .../gplx/langs/htmls/entitys/Gfh_entity_.java | 2 +- 400_xowa/src/gplx/langs/htmls/Gfh_atr_.java | 1 + .../src/gplx/langs/phps/utls/Php_utl_.java | 23 +++ 400_xowa/src/gplx/xowa/mws/Xomw_linker.java | 110 +++++++++----- .../src/gplx/xowa/mws/Xomw_sanitizer.java | 8 + 400_xowa/src/gplx/xowa/mws/Xomw_xml.java | 85 +++++++++++ .../gplx/xowa/mws/htmls/Xomw_img_prms.java | 12 ++ .../Xomw_string_utils.java} | 67 ++++++++- .../Xomw_string_utils__tst.java} | 45 ++++-- .../src/gplx/xowa/mws/medias/Xomw_mto.java | 142 ++++++++++++++++++ .../gplx/xowa/mws/medias/Xomw_mto_params.java | 43 ++++++ .../xowa/mws/parsers/lnkis/Xomw_lnki_wkr.java | 32 ++-- .../mws/parsers/lnkis/Xomw_lnki_wkr__tst.java | 13 +- .../mws/parsers/tables/Xomw_table_wkr.java | 4 +- 19 files changed, 520 insertions(+), 85 deletions(-) create mode 100644 400_xowa/src/gplx/langs/phps/utls/Php_utl_.java create mode 100644 400_xowa/src/gplx/xowa/mws/Xomw_xml.java rename 400_xowa/src/gplx/xowa/mws/{utls/Xomw_string_utl.java => libs/Xomw_string_utils.java} (50%) rename 400_xowa/src/gplx/xowa/mws/{utls/Xomw_string_utl__tst.java => libs/Xomw_string_utils__tst.java} (54%) create mode 100644 400_xowa/src/gplx/xowa/mws/medias/Xomw_mto.java create mode 100644 400_xowa/src/gplx/xowa/mws/medias/Xomw_mto_params.java diff --git a/100_core/src/gplx/Bry_.java b/100_core/src/gplx/Bry_.java index df78d9751..938fd68c8 100644 --- a/100_core/src/gplx/Bry_.java +++ b/100_core/src/gplx/Bry_.java @@ -1106,9 +1106,9 @@ public class Bry_ { return Bry_.Replace(Bry_.Mid(src, bgn, end), Byte_ascii.Nl, Byte_ascii.Tab); } public static byte[] Escape_html(byte[] src) { - return Escape_html(null, src, 0, src.length); + return Escape_html(null, Bool_.N, src, 0, src.length); } - public static byte[] Escape_html(Bry_bfr bfr, byte[] src, int src_bgn, int src_end) { // uses PHP rules for htmlspecialchars; REF.PHP:http://php.net/manual/en/function.htmlspecialchars.php + public static byte[] Escape_html(Bry_bfr bfr, boolean ws, byte[] src, int src_bgn, int src_end) { // uses PHP rules for htmlspecialchars; REF.PHP:http://php.net/manual/en/function.htmlspecialchars.php boolean dirty = false; int cur = src_bgn; int prv = cur; @@ -1133,6 +1133,9 @@ public class Bry_ { case Byte_ascii.Apos: escaped = Gfh_entity_.Apos_num_bry; break; case Byte_ascii.Lt: escaped = Gfh_entity_.Lt_bry; break; case Byte_ascii.Gt: escaped = Gfh_entity_.Gt_bry; break; + case Byte_ascii.Nl: if (ws) escaped = Gfh_entity_.Nl_bry; break; + case Byte_ascii.Cr: if (ws) escaped = Gfh_entity_.Cr_bry; break; + case Byte_ascii.Tab: if (ws) escaped = Gfh_entity_.Tab_bry; break; } // not escaped; increment and continue diff --git a/100_core/src/gplx/Bry_bfr.java b/100_core/src/gplx/Bry_bfr.java index 4d2c59cc9..7a358282d 100644 --- a/100_core/src/gplx/Bry_bfr.java +++ b/100_core/src/gplx/Bry_bfr.java @@ -311,7 +311,11 @@ public class Bry_bfr { return Add_bry_escape_html(val, 0, val.length); } public Bry_bfr Add_bry_escape_html(byte[] val, int bgn, int end) { - Bry_.Escape_html(this, val, bgn, end); + Bry_.Escape_html(this, Bool_.N, val, bgn, end); + return this; + } + public Bry_bfr Add_bry_escape_xml(byte[] val, int bgn, int end) { + Bry_.Escape_html(this, Bool_.Y, val, bgn, end); return this; } public Bry_bfr Add_str_u8_w_nl(String s) {Add_str_u8(s); return Add_byte_nl();} diff --git a/100_core/src/gplx/Keyval_hash.java b/100_core/src/gplx/Keyval_hash.java index 275d4c831..1fc00fb66 100644 --- a/100_core/src/gplx/Keyval_hash.java +++ b/100_core/src/gplx/Keyval_hash.java @@ -17,8 +17,9 @@ along with this program. If not, see . */ package gplx; public class Keyval_hash { - private final Ordered_hash hash = Ordered_hash_.New(); + private final Ordered_hash hash = Ordered_hash_.New(); public int Count() {return hash.Count();} + public int Len() {return hash.Count();} public Keyval_hash Clear() {hash.Clear(); return this;} public boolean Has(String key) {return hash.Has(key);} public Keyval Get_at(int i) {return (Keyval)hash.Get_at(i);} diff --git a/100_core/src/gplx/Ordered_hash_base.java b/100_core/src/gplx/Ordered_hash_base.java index a787109cd..33cc4d3e6 100644 --- a/100_core/src/gplx/Ordered_hash_base.java +++ b/100_core/src/gplx/Ordered_hash_base.java @@ -98,7 +98,6 @@ public class Ordered_hash_base extends Hash_adp_base implements Ordered_hash, Gf else return Gfo_invk_.Rv_unhandled; return this; } static final String Invk_SetKeyOnly = "SetKeyOnly", Invk_Print = "Print"; - public int Len() {return ordered.Count();} @Override public int Count() {return ordered.Count();} public Ordered_hash_base() {} } diff --git a/100_core/src/gplx/core/lists/Hash_adp_base.java b/100_core/src/gplx/core/lists/Hash_adp_base.java index 0c0c87421..b1a3fa7ee 100644 --- a/100_core/src/gplx/core/lists/Hash_adp_base.java +++ b/100_core/src/gplx/core/lists/Hash_adp_base.java @@ -40,6 +40,7 @@ public abstract class Hash_adp_base implements Hash_adp { // private final java.util.HashMap hash = new java.util.HashMap(); private final java.util.Hashtable hash = new java.util.Hashtable(); + @gplx.Virtual public int Len() {return hash.size();} @gplx.Virtual public int Count() {return hash.size();} @gplx.Virtual public void Clear() {hash.clear();} @gplx.Virtual protected void Add_base(Object key, Object val) {hash.put(key, val);} diff --git a/100_core/src/gplx/langs/htmls/entitys/Gfh_entity_.java b/100_core/src/gplx/langs/htmls/entitys/Gfh_entity_.java index 83623b678..105ccca80 100644 --- a/100_core/src/gplx/langs/htmls/entitys/Gfh_entity_.java +++ b/100_core/src/gplx/langs/htmls/entitys/Gfh_entity_.java @@ -26,7 +26,7 @@ public class Gfh_entity_ { , Apos_num_bry = Bry_.new_a7("'") , Apos_key_bry = Bry_.new_a7("'") , Eq_bry = Bry_.new_a7("=") - , Nl_bry = Bry_.new_a7(Nl_str), Space_bry = Bry_.new_a7(" ") + , Nl_bry = Bry_.new_a7(Nl_str), Cr_bry = Bry_.new_a7(" "), Tab_bry = Bry_.new_a7(" "), Space_bry = Bry_.new_a7(" ") , Pipe_bry = Bry_.new_a7("|") , Colon_bry = Bry_.new_a7(":"), Underline_bry = Bry_.new_a7("_"), Asterisk_bry = Bry_.new_a7("*") , Brack_bgn_bry = Bry_.new_a7("["), Brack_end_bry = Bry_.new_a7("]") diff --git a/400_xowa/src/gplx/langs/htmls/Gfh_atr_.java b/400_xowa/src/gplx/langs/htmls/Gfh_atr_.java index 684039f26..55a78ab59 100644 --- a/400_xowa/src/gplx/langs/htmls/Gfh_atr_.java +++ b/400_xowa/src/gplx/langs/htmls/Gfh_atr_.java @@ -29,6 +29,7 @@ public class Gfh_atr_ { // , Bry__href = Bry_.new_a7("href") , Bry__rel = Bry_.new_a7("rel") + , Bry__target = Bry_.new_a7("target") // , Bry__alt = Bry_.new_a7("alt") , Bry__src = Bry_.new_a7("src") diff --git a/400_xowa/src/gplx/langs/phps/utls/Php_utl_.java b/400_xowa/src/gplx/langs/phps/utls/Php_utl_.java new file mode 100644 index 000000000..807d62c9b --- /dev/null +++ b/400_xowa/src/gplx/langs/phps/utls/Php_utl_.java @@ -0,0 +1,23 @@ +/* +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 . +*/ +package gplx.langs.phps.utls; import gplx.*; import gplx.langs.*; import gplx.langs.phps.*; +public class Php_utl_ { + public static boolean Empty(byte[] v) {return v == null || v.length == 0;} + public static boolean Empty(boolean v) {return v == false;} + public static boolean Is_set(byte[] v) {return v != null;} +} diff --git a/400_xowa/src/gplx/xowa/mws/Xomw_linker.java b/400_xowa/src/gplx/xowa/mws/Xomw_linker.java index 74a4356f0..39bb7472f 100644 --- a/400_xowa/src/gplx/xowa/mws/Xomw_linker.java +++ b/400_xowa/src/gplx/xowa/mws/Xomw_linker.java @@ -19,7 +19,8 @@ package gplx.xowa.mws; import gplx.*; import gplx.xowa.*; import gplx.core.btries.*; import gplx.langs.htmls.*; import gplx.xowa.mws.htmls.*; import gplx.xowa.mws.linkers.*; import gplx.xowa.mws.parsers.*; -import gplx.xowa.mws.filerepos.files.*; +import gplx.xowa.mws.filerepos.files.*; import gplx.xowa.mws.medias.*; +import gplx.langs.phps.utls.*; /* TODO.XO * P8: wfMessage * P7: titleFormatter->getPrefixedText @@ -34,6 +35,8 @@ public class Xomw_linker { private final byte[][] split_trail_rv = new byte[2][]; private Btrie_slim_mgr split_trail_trie; private final Xomw_atr_mgr tmp_attribs = new Xomw_atr_mgr(); + private final Xomw_img_prms params_list = new Xomw_img_prms(); + private final Xomw_mto_params mto_params = new Xomw_mto_params(); private static final byte[] Atr__class = Bry_.new_a7("class"), Atr__rel = Bry_.new_a7("rel"), Atr__href = Bry_.new_a7("href"), Rel__nofollow = Bry_.new_a7("nofollow"); public static final byte[] Align__frame__center = Bry_.new_a7("center") @@ -42,6 +45,8 @@ public class Xomw_linker { , Prefix__center = Bry_.new_a7("
") , Class__internal = Bry_.new_a7("internal") , Class__magnify = Bry_.new_a7("magnify") + , Img_class__thumbborder = Bry_.new_a7("thumbborder") + , Img_class__thumbimage = Bry_.new_a7("thumbimage") ; private final Xomw_link_renderer link_renderer; public Xomw_linker(Xomw_link_renderer link_renderer) { @@ -84,7 +89,7 @@ public class Xomw_linker { // @param int|null width_option Used by the parser to remember the user preference thumbnailsize // @since 1.20 // @return String HTML for an image, with links, wrappers, etc. - public void Make_image_link(Bry_bfr bfr, Xomw_parser parser, Xoa_ttl title, Xomw_file file, Xomw_img_prms frame_params, Xomw_mda_prms handler_params, Object time, Object query, Object widthOption) { + public void Make_image_link(Bry_bfr bfr, Xomw_parser parser, Xoa_ttl title, Xomw_file file, Xomw_img_prms frame_params, Xomw_mda_prms handler_params, Object time, byte[] query, Object widthOption) { // XO.MW.HOOK:ImageBeforeProduceHTML if (file != null && !file.Allow_inline_display()) { @@ -199,14 +204,14 @@ public class Xomw_linker { } else { // self::processResponsiveImages($file, $thumb, handler_params); -// $params = [ -// 'alt' => frame_params['alt'], -// 'title' => frame_params['title'], -// 'valign' => isset(frame_params['valign']) ? frame_params['valign'] : false, -// 'img-class' => frame_params['class'] ]; -// if (isset(frame_params['border'])) { -// $params['img-class'] .= ($params['img-class'] !== '' ? ' ' : '') . 'thumbborder'; -// } + params_list.Clear(); + params_list.alt = frame_params.alt; + params_list.title = frame_params.title; + params_list.valign = frame_params.valign; + params_list.img_cls = frame_params.cls; + if (frame_params.border != null) { + params_list.img_cls = Xomw_img_prms.Cls_add(params_list.img_cls, Img_class__thumbborder); + } // $params = self::getImageLinkMTOParams(frame_params, $query, $parser) + $params; // // $s = $thumb->toHtml($params); @@ -222,10 +227,43 @@ public class Xomw_linker { bfr.Add(postfix); Bry_.Replace_all_direct(bfr.Bfr(), Byte_ascii.Nl, Byte_ascii.Space, rv_bgn, bfr.Len()); } - public void Make_thumb_link2(Bry_bfr bfr, Xoa_ttl title, Object file, Xomw_img_prms frame_params, Object handler_params, Object time, Object query) { + // Get the link parameters for MediaTransformOutput::toHtml() from given + // frame parameters supplied by the Parser. + // @param array $frameParams The frame parameters + // @param String $query An optional query String to add to description page links + // @param Parser|null $parser + // @return array + // XO.MW:SYNC:1.29; DATE:2017-02-03 + public void Get_image_link_mto_params(Xomw_mto_params mto_params, Xomw_img_prms frame_params, byte[] query, Xomw_parser parser) { + if (Php_utl_.Is_set(frame_params.link_url) && frame_params.link_url != Bry_.Empty) { + mto_params.custom_url_link = frame_params.link_url; + if (Php_utl_.Is_set(frame_params.link_target)) { + mto_params.custom_target_link = frame_params.link_target; + } + if (parser != null) { +// extLinkAttrs = parser->getExternalLinkAttribs(frame_params['link-url']); +// foreach (extLinkAttrs as name => val) { +// // Currently could include 'rel' and 'target' +// mto_params['parser-extlink-' . name] = val; +// } + } + } + else if (Php_utl_.Is_set(frame_params.link_title) && frame_params.link_title != Bry_.Empty) { +// mto_params.custom_title_link = Title::newFromLinkTarget(Normalize_speecial_page(frame_params.link_title)); + } + else if (!Php_utl_.Empty(frame_params.no_link)) { + // No link + } + else { + mto_params.desc_link = true; + mto_params.desc_query = query; + } + } + + public void Make_thumb_link2(Bry_bfr bfr, Xoa_ttl title, Xomw_file file, Xomw_img_prms frame_params, Xomw_mda_prms handler_params, Object time, byte[] query) { boolean exists = false; // = $file && $file->exists(); -// $page = isset(handler_params['page']) ? handler_params['page'] : false; + int page = handler_params.page; if (frame_params.align == null) { frame_params.align = Align__frame__right; } @@ -239,17 +277,17 @@ public class Xomw_linker { frame_params.caption = Bry_.Empty; } -// if (empty(handler_params['width'])) { -// // Reduce width for upright images when parameter 'upright' is used -// handler_params['width'] = isset(frame_params['upright']) ? 130 : 180; -// } - boolean thumb = false; + if (handler_params.width == -1) { + // Reduce width for upright images when parameter 'upright' is used + handler_params.width = frame_params.upright != -1 ? 130 : 180; + } + Xomw_mto thumb = null; boolean no_scale = false; boolean manual_thumb = false; - int outer_width = 0; + int outer_width = 0; if (!exists) { -// outer_width = handler_params['width'] + 2; + outer_width = handler_params.width + 2; } else { if (frame_params.manual_thumb != null) { @@ -267,24 +305,25 @@ public class Xomw_linker { } else if (frame_params.framed != null) { // Use image dimensions, don't scale + thumb = new Xomw_mto(); // thumb = $file->getUnscaledThumb(handler_params); no_scale = true; } else { // Do not present an image bigger than the source, for bitmap-style images // This is a hack to maintain compatibility with arbitrary pre-1.10 behavior -// src_width = $file->getWidth($page); -// if (src_width && !$file->mustRender() && handler_params['width'] > src_width) { -// handler_params['width'] = src_width; -// } + int src_width = file.Get_width(page); + if (src_width != -1 && !file.Must_render() && handler_params.width > src_width) { + handler_params.width = src_width; + } // thumb = $file->transform(handler_params); } - if (thumb) { + if (thumb != null) { // outer_width = thumb->getWidth() + 2; } else { -// outer_width = handler_params['width'] + 2; + outer_width = handler_params.width + 2; } } @@ -299,7 +338,7 @@ public class Xomw_linker { && frame_params.link_title != null && frame_params.link_url != null && frame_params.no_link != null) { -// frame_params.link_url = url; + frame_params.link_url = url; } int rv_bgn = bfr.Len(); @@ -308,10 +347,10 @@ public class Xomw_linker { byte[] zoom_icon = Bry_.Empty; if (!exists) { -// $s .= self::makeBrokenImageLinkObj($title, frame_params['title'], '', '', '', $time == true); +// $s .= self::makeBrokenImageLinkObj($title, frame_params.title, '', '', '', $time == true); zoom_icon = Bry_.Empty; } - else if (!thumb) { + else if (thumb == null) { // $s .= wfMessage('thumbnail_error', '')->escaped(); zoom_icon = Bry_.Empty; } @@ -319,15 +358,12 @@ public class Xomw_linker { if (!no_scale && !manual_thumb) { // self::processResponsiveImages($file, thumb, handler_params); } -// $params = [ -// 'alt' => frame_params['alt'], -// 'title' => frame_params['title'], -// 'img-class' => (isset(frame_params['class']) && frame_params['class'] !== '' -// ? frame_params['class'] . ' ' -// : '') . 'thumbimage' -// ]; -// $params = self::getImageLinkMTOParams(frame_params, $query) + $params; -// $s .= thumb->toHtml($params); + mto_params.Clear(); + mto_params.alt = frame_params.alt; + mto_params.title = frame_params.title; + mto_params.img_cls = Xomw_img_prms.Cls_add(frame_params.cls, Img_class__thumbimage); + Get_image_link_mto_params(mto_params, frame_params, query, null); + thumb.To_html(bfr, tmp, mto_params); if (frame_params.framed != null) { zoom_icon = Bry_.Empty; } diff --git a/400_xowa/src/gplx/xowa/mws/Xomw_sanitizer.java b/400_xowa/src/gplx/xowa/mws/Xomw_sanitizer.java index 04b87f1da..26e6e8b97 100644 --- a/400_xowa/src/gplx/xowa/mws/Xomw_sanitizer.java +++ b/400_xowa/src/gplx/xowa/mws/Xomw_sanitizer.java @@ -224,6 +224,14 @@ public class Xomw_sanitizer { || (codepoint >= 0xe000 && codepoint <= 0xfffd) || (codepoint >= 0x10000 && codepoint <= 0x10ffff); } + // Encode an attribute value for HTML output. + // XO.MW:SYNC:1.29; DATE:2017-02-03 + public static void Encode_attribute(Bry_bfr bfr, byte[] text) { + // Whitespace is normalized during attribute decoding, + // so if we've been passed non-spaces we must encode them + // ahead of time or they won't be preserved. + bfr.Add_bry_escape_xml(text, 0, text.length); + } public static Hash_adp_bry html_entities; private static Hash_adp_bry Html_entities_new() { diff --git a/400_xowa/src/gplx/xowa/mws/Xomw_xml.java b/400_xowa/src/gplx/xowa/mws/Xomw_xml.java new file mode 100644 index 000000000..27a73a79b --- /dev/null +++ b/400_xowa/src/gplx/xowa/mws/Xomw_xml.java @@ -0,0 +1,85 @@ +/* +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 . +*/ +package gplx.xowa.mws; import gplx.*; import gplx.xowa.*; +public class Xomw_xml { + // Format an XML element with given attributes and, optionally, text content. + // Element and attribute names are assumed to be ready for literal inclusion. + // Strings are assumed to not contain XML-illegal characters; special + // characters (<, >, &) are escaped but illegals are not touched. + // ARGS: contents defaults to "" + // XO.MW:SYNC:1.29; DATE:2017-02-03 + public static void Element(Bry_bfr bfr, byte[] element, Ordered_hash attribs, byte[] contents, boolean allow_short_tag) { + bfr.Add_byte(Byte_ascii.Angle_bgn).Add(element); + if (attribs.Len() > 0) { + Expand_attributes(bfr, attribs); + } + if (contents == null) { + bfr.Add_byte(Byte_ascii.Angle_end); + } + else { + if (allow_short_tag && contents == Bry_.Empty) { + bfr.Add_str_a7(" />"); + } + else { + bfr.Add_byte(Byte_ascii.Angle_end); + bfr.Add_bry_escape_html(contents); + bfr.Add_byte(Byte_ascii.Angle_bgn).Add_byte(Byte_ascii.Slash).Add(element).Add_byte(Byte_ascii.Angle_end); + } + } + } + // Given an array of ('attributename' => 'value'), it generates the code + // to set the XML attributes : attributename="value". + // The values are passed to Sanitizer::encodeAttribute. + // Return null if no attributes given. + // @param array $attribs Array of attributes for an XML element + // XO.MW:SYNC:1.29; DATE:2017-02-03 + public static void Expand_attributes(Bry_bfr bfr, Ordered_hash attribs) { + int attribs_len = attribs.Len(); + for (int i = 0; i < attribs_len; i += 2) { + // XO.MW: $out .= " {$name}=\"" . Sanitizer::encodeAttribute( $val ) . '"'; + bfr.Add_byte_space(); + bfr.Add((byte[])attribs.Get_at(i)); + bfr.Add_byte_eq().Add_byte_quote(); + Xomw_sanitizer.Encode_attribute(bfr, (byte[])attribs.Get_at(i + 1)); + bfr.Add_byte_quote(); + } + } + + // This opens an XML element + // XO.MW:SYNC:1.29; DATE:2017-02-03 + public static void Open_element(Bry_bfr bfr, byte[] element, Ordered_hash attribs) { + bfr.Add_byte(Byte_ascii.Angle_bgn).Add(element); + Expand_attributes(bfr, attribs); + bfr.Add_byte(Byte_ascii.Angle_end); + } + + // Shortcut to close an XML element + // XO.MW:SYNC:1.29; DATE:2017-02-03 + public static void Close_element(Bry_bfr bfr, byte[] element) { + bfr.Add_byte(Byte_ascii.Angle_bgn).Add_byte(Byte_ascii.Slash).Add(element).Add_byte(Byte_ascii.Angle_end); + } + + // Same as Xml::element(), but does not escape contents. Handy when the + // content you have is already valid xml. + // XO.MW:SYNC:1.29; DATE:2017-02-03 + public static void Tags(Bry_bfr bfr, byte[] element, Ordered_hash attribs, byte[] contents) { + Open_element(bfr, element, attribs); + bfr.Add(contents); + bfr.Add_byte(Byte_ascii.Angle_bgn).Add_byte(Byte_ascii.Slash).Add(element).Add_byte(Byte_ascii.Angle_end); + } +} diff --git a/400_xowa/src/gplx/xowa/mws/htmls/Xomw_img_prms.java b/400_xowa/src/gplx/xowa/mws/htmls/Xomw_img_prms.java index d40122eca..79f48e4d6 100644 --- a/400_xowa/src/gplx/xowa/mws/htmls/Xomw_img_prms.java +++ b/400_xowa/src/gplx/xowa/mws/htmls/Xomw_img_prms.java @@ -28,8 +28,20 @@ public class Xomw_img_prms { public byte[] alt = null; public byte[] title = null; public byte[] cls = null; + public byte[] img_cls = null; public byte[] link_title = null; public byte[] link_url = null; + public byte[] link_target = null; public byte[] no_link = null; + public byte[] border = null; public double upright = -1; + public void Clear() { + align = valign = caption = frame = framed = frameless + = thumbnail = manual_thumb = alt = title = cls = img_cls + = link_title = link_url = link_target = no_link = null; + upright = -1; + } + public static byte[] Cls_add(byte[] lhs, byte[] rhs) { + return Bry_.Len_eq_0(lhs) ? rhs : Bry_.Add(lhs, Byte_ascii.Space_bry, rhs); + } } diff --git a/400_xowa/src/gplx/xowa/mws/utls/Xomw_string_utl.java b/400_xowa/src/gplx/xowa/mws/libs/Xomw_string_utils.java similarity index 50% rename from 400_xowa/src/gplx/xowa/mws/utls/Xomw_string_utl.java rename to 400_xowa/src/gplx/xowa/mws/libs/Xomw_string_utils.java index d557b0ee7..ca802d8a7 100644 --- a/400_xowa/src/gplx/xowa/mws/utls/Xomw_string_utl.java +++ b/400_xowa/src/gplx/xowa/mws/libs/Xomw_string_utils.java @@ -15,8 +15,71 @@ 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 . */ -package gplx.xowa.mws.utls; import gplx.*; import gplx.xowa.*; import gplx.xowa.mws.*; -public class Xomw_string_utl { +package gplx.xowa.mws.libs; import gplx.*; import gplx.xowa.*; import gplx.xowa.mws.*; +import gplx.core.btries.*; +public class Xomw_string_utils { + // Explode a String, but ignore any instances of the separator inside + // the given start and end delimiters, which may optionally nest. + // The delimiters are literal strings, not regular expressions. + // @param String bgn_delim Start delimiter + // @param String end_delim End delimiter + // @param String separator Separator String for the explode. + // @param String subject Subject String to explode. + // @param boolean nested True iff the delimiters are allowed to nest. + // @return ArrayIterator + // XO.MW: hard-coding (a) nested=true; (b) bgn="-{" end="}-" sep="|" + // XO.MW:SYNC:1.29; DATE:2017-02-03 + private static final byte Delimiter_explode__sep = 0, Delimiter_explode__bgn = 1, Delimiter_explode__end = 2; + private static final Btrie_slim_mgr delimiter_explode_trie = Btrie_slim_mgr.cs() + .Add_str_byte("|" , Delimiter_explode__sep) + .Add_str_byte("-{", Delimiter_explode__bgn) + .Add_str_byte("}-", Delimiter_explode__end) + ; + public static byte[][] Delimiter_explode(List_adp tmp, Btrie_rv trv, byte[] src) { + int src_bgn = 0; + int src_end = src.length; + + int depth = 0; + int cur = src_bgn; + int prv = cur; + while (true) { + // eos + if (cur == src_end) { + // add rest + tmp.Add(Bry_.Mid(src, prv, src_end)); + break; + } + + Object o = delimiter_explode_trie.Match_at(trv, src, cur, src_end); + + // regular char; continue; + if (o == null) { + cur++; + continue; + } + + // handle sep, bgn, end + byte tid = ((gplx.core.primitives.Byte_obj_val)o).Val(); + switch (tid) { + case Delimiter_explode__sep: + if (depth == 0) { + tmp.Add(Bry_.Mid(src, prv, cur)); + prv = cur + 1; + } + break; + case Delimiter_explode__bgn: + depth++; + break; + case Delimiter_explode__end: + depth--; + break; + } + cur = trv.Pos(); + } + return (byte[][])tmp.To_ary_and_clear(byte[].class); + } + // More or less "markup-safe" str_replace() + // Ignores any instances of the separator inside `<...>` public static void Replace_markup(byte[] src, int src_bgn, int src_end, byte[] find, byte[] repl) { // REF:/includes/libs/StringUtils.php|replaceMarkup // PORTED: avoiding multiple regex calls / String creations // $placeholder = "\x00"; diff --git a/400_xowa/src/gplx/xowa/mws/utls/Xomw_string_utl__tst.java b/400_xowa/src/gplx/xowa/mws/libs/Xomw_string_utils__tst.java similarity index 54% rename from 400_xowa/src/gplx/xowa/mws/utls/Xomw_string_utl__tst.java rename to 400_xowa/src/gplx/xowa/mws/libs/Xomw_string_utils__tst.java index 6912502ef..06f5d297a 100644 --- a/400_xowa/src/gplx/xowa/mws/utls/Xomw_string_utl__tst.java +++ b/400_xowa/src/gplx/xowa/mws/libs/Xomw_string_utils__tst.java @@ -15,33 +15,46 @@ 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 . */ -package gplx.xowa.mws.utls; import gplx.*; import gplx.xowa.*; import gplx.xowa.mws.*; +package gplx.xowa.mws.libs; import gplx.*; import gplx.xowa.*; import gplx.xowa.mws.*; import org.junit.*; import gplx.core.tests.*; -public class Xomw_string_utl__tst { - private final Xomw_string_utl__fxt fxt = new Xomw_string_utl__fxt(); - @Test public void Basic() { +public class Xomw_string_utils__tst { + private final Xomw_string_utils__fxt fxt = new Xomw_string_utils__fxt(); + @Test public void Delimiter_explode() { + // basic + fxt.Test__delimiter_explode("a|b|c" , "a", "b", "c"); + // empty + fxt.Test__delimiter_explode("|a||c|" , "", "a", "", "c", ""); + // nest_1 + fxt.Test__delimiter_explode("a|-{b|c}-|d" , "a", "-{b|c}-", "d"); + // nest_many + fxt.Test__delimiter_explode("a|-{b-{c|d}-e}-|f" , "a", "-{b-{c|d}-e}-", "f"); + } + @Test public void Replace_markup() { + // basic fxt.Test__replace_markup("a!!b" , "!!", "||", "a||b"); - } - @Test public void Missing() { + // missing fxt.Test__replace_markup("abcd" , "!!", "||", "abcd"); - } - @Test public void Eos() { + // eos fxt.Test__replace_markup("a!!" , "!!", "||", "a||"); - } - @Test public void Ignore() { + // ignore fxt.Test__replace_markup("a!!b!!c" , "!!", "||", "a||b||c"); - } - @Test public void Ignore__asym__lhs() { + // ignore asym_lhs fxt.Test__replace_markup("a!!b!!c" , "!!", "||", "a||b||c"); - } - @Test public void Ignore__asym__rhs() { + // ignore asym_lhs fxt.Test__replace_markup("a!!b!!>!!c" , "!!", "||", "a||b||>||c"); // NOTE: should probably be "!!>!!>", but unmatched ">" are escaped to ">" } } -class Xomw_string_utl__fxt { +class Xomw_string_utils__fxt { + public void Test__delimiter_explode(String src_str, String... expd) { + List_adp tmp = List_adp_.New(); + gplx.core.btries.Btrie_rv trv = new gplx.core.btries.Btrie_rv(); + + byte[][] actl = Xomw_string_utils.Delimiter_explode(tmp, trv, Bry_.new_u8(src_str)); + Gftest.Eq__ary(expd, actl, "src=~{0}", src_str); + } public void Test__replace_markup(String src_str, String find, String repl, String expd) { byte[] src_bry = Bry_.new_u8(src_str); - Xomw_string_utl.Replace_markup(src_bry, 0, src_bry.length, Bry_.new_a7(find), Bry_.new_a7(repl)); + Xomw_string_utils.Replace_markup(src_bry, 0, src_bry.length, Bry_.new_a7(find), Bry_.new_a7(repl)); Gftest.Eq__str(expd, src_bry); } } diff --git a/400_xowa/src/gplx/xowa/mws/medias/Xomw_mto.java b/400_xowa/src/gplx/xowa/mws/medias/Xomw_mto.java new file mode 100644 index 000000000..e48defb0c --- /dev/null +++ b/400_xowa/src/gplx/xowa/mws/medias/Xomw_mto.java @@ -0,0 +1,142 @@ +/* +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 . +*/ +package gplx.xowa.mws.medias; import gplx.*; import gplx.xowa.*; import gplx.xowa.mws.*; +import gplx.langs.htmls.*; +import gplx.langs.phps.utls.*; +public class Xomw_mto { + private int width = -1, height = -1; + private byte[] url = null; + private final Ordered_hash attribs = Ordered_hash_.New_bry(), link_attribs = Ordered_hash_.New_bry(); + + // Return HTML tag for the thumbnail, will include + // width and height attributes and a blank alt text (as required). + // + // @param array options Associative array of options. Boolean options + // should be indicated with a value of true for true, and false or + // absent for false. + // + // alt HTML alt attribute + // title HTML title attribute + // desc-link Boolean, show a description link + // file-link Boolean, show a file download link + // valign vertical-align property, if the output is an inline element + // img-class Class applied to the \ tag, if there is such a tag + // desc-query String, description link query params + // override-width Override width attribute. Should generally not set + // override-height Override height attribute. Should generally not set + // no-dimensions Boolean, skip width and height attributes (useful if + // set in CSS) + // custom-url-link Custom URL to link to + // custom-title-link Custom Title Object to link to + // custom target-link Value of the target attribute, for custom-target-link + // parser-extlink-* Attributes added by parser for external links: + // parser-extlink-rel: add rel="nofollow" + // parser-extlink-target: link target, but overridden by custom-target-link + // + // For images, desc-link and file-link are implemented as a click-through. For + // sounds and videos, they may be displayed in other ways. + // XO.MW:SYNC:1.29; DATE:2017-02-03 + public void To_html(Bry_bfr bfr, Bry_bfr tmp, Xomw_mto_params options) { + byte[] alt = options.alt; + +// byte[] query = options.desc_query; + + attribs.Clear(); + attribs.Add(Gfh_atr_.Bry__alt, alt); + attribs.Add(Gfh_atr_.Bry__src, url); + boolean link_attribs_is_null = false; + if (!Php_utl_.Empty(options.custom_url_link)) { + link_attribs.Clear(); + link_attribs.Add(Gfh_atr_.Bry__href, options.custom_url_link); + if (!Php_utl_.Empty(options.title)) { + link_attribs.Add(Gfh_atr_.Bry__title, options.title); + } + if (Php_utl_.Empty(options.custom_target_link)) { + link_attribs.Add(Gfh_atr_.Bry__target, options.custom_target_link); + } + else if (Php_utl_.Empty(options.parser_extlink_target)) { + link_attribs.Add(Gfh_atr_.Bry__target, options.parser_extlink_target); + } + if (Php_utl_.Empty(options.parser_extlink_rel)) { + link_attribs.Add(Gfh_atr_.Bry__rel, options.parser_extlink_rel); + } + } + else if (!Php_utl_.Empty(options.custom_title_link)) { +// byte[] title = options.custom_title_link; + link_attribs.Clear(); +// link_attribs.Add(Gfh_atr_.Bry__href, title.Get_link_url()); +// byte[] options_title = options.title; +// link_attribs.Add(Gfh_atr_.Bry__title, Php_utl_.Empty(options_title) ? title.Get_full_text : options_title; + } + else if (!Php_utl_.Empty(options.desc_link)) { +// link_attribs = $this->getDescLinkAttribs( +// empty(options['title']) ? null : options['title'], +// $query +// ); + } + else if (!Php_utl_.Empty(options.file_link)) { + link_attribs.Clear(); +// link_attribs.Add(Gfh_atr_.Bry__href, file.Get_url()); + } + else { + link_attribs_is_null = true; + if (!Php_utl_.Empty(options.title)) { + attribs.Add(Gfh_atr_.Bry__title, options.title); + } + } + + if (!Php_utl_.Empty(options.no_dimensions)) { + attribs.Add(Gfh_atr_.Bry__width, Int_.To_bry(width)); + attribs.Add(Gfh_atr_.Bry__height, Int_.To_bry(height)); + } + if (!Php_utl_.Empty(options.valign)) { + attribs.Add(Gfh_atr_.Bry__style, Bry_.Add(Bry__vertical_align, options.valign)); + } + if (!Php_utl_.Empty(options.img_cls)) { + attribs.Add(Gfh_atr_.Bry__class, options.img_cls); + } + if (Php_utl_.Is_set(options.override_height)) { + attribs.Add(Gfh_atr_.Bry__class, options.override_height); + } + if (Php_utl_.Is_set(options.override_width)) { + attribs.Add(Gfh_atr_.Bry__width, options.override_height); + } + + // Additional densities for responsive images, if specified. + // If any of these urls is the same as src url, it'll be excluded. +// $responsiveUrls = array_diff($this->responsiveUrls, [ $this->url ]); +// if (!Php_utl_.Empty($responsiveUrls)) { +// $attribs['srcset'] = Html::srcSet($responsiveUrls); +// } + + // XO.MW.HOOK:ThumbnailBeforeProduceHTML + Xomw_xml.Element(tmp, Gfh_tag_.Bry__img, attribs, Bry_.Empty, Bool_.Y); + Link_wrap(bfr, link_attribs_is_null ? null : link_attribs, tmp.To_bry_and_clear()); + } + // Wrap some XHTML text in an anchor tag with the given attributes + // XO.MW:SYNC:1.29; DATE:2017-02-03 + private void Link_wrap(Bry_bfr bfr, Ordered_hash link_attribs, byte[] contents) { + if (link_attribs != null) { + Xomw_xml.Tags(bfr, Gfh_tag_.Bry__a, link_attribs, contents); + } + else { + bfr.Add(contents); + } + } + private static final byte[] Bry__vertical_align = Bry_.new_a7("vertical-align: "); +} diff --git a/400_xowa/src/gplx/xowa/mws/medias/Xomw_mto_params.java b/400_xowa/src/gplx/xowa/mws/medias/Xomw_mto_params.java new file mode 100644 index 000000000..6b6b411e1 --- /dev/null +++ b/400_xowa/src/gplx/xowa/mws/medias/Xomw_mto_params.java @@ -0,0 +1,43 @@ +/* +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 . +*/ +package gplx.xowa.mws.medias; import gplx.*; import gplx.xowa.*; import gplx.xowa.mws.*; +public class Xomw_mto_params { + public boolean desc_link; + public byte[] alt = null; + public byte[] title = null; + public byte[] img_cls = null; + public byte[] file_link = null; + public byte[] valign = null; + public byte[] desc_query = null; + public byte[] override_width = null; + public byte[] override_height = null; + public byte[] no_dimensions = null; + public byte[] custom_url_link = null; + public byte[] custom_title_link = null; + public byte[] custom_target_link = null; + public byte[] parser_extlink_rel = null; + public byte[] parser_extlink_target = null; + public void Clear() { + desc_link = false; + alt = title = file_link = valign + = desc_query = override_width = override_height = no_dimensions + = custom_url_link = custom_title_link + = parser_extlink_rel = parser_extlink_target + = null; + } +} diff --git a/400_xowa/src/gplx/xowa/mws/parsers/lnkis/Xomw_lnki_wkr.java b/400_xowa/src/gplx/xowa/mws/parsers/lnkis/Xomw_lnki_wkr.java index 57696aaaa..f7a2e39de 100644 --- a/400_xowa/src/gplx/xowa/mws/parsers/lnkis/Xomw_lnki_wkr.java +++ b/400_xowa/src/gplx/xowa/mws/parsers/lnkis/Xomw_lnki_wkr.java @@ -21,7 +21,7 @@ import gplx.langs.phps.utls.*; import gplx.xowa.wikis.nss.*; import gplx.xowa.wikis.xwikis.*; import gplx.xowa.mws.parsers.*; import gplx.xowa.mws.parsers.quotes.*; import gplx.xowa.mws.htmls.*; import gplx.xowa.mws.linkers.*; -import gplx.xowa.mws.utls.*; +import gplx.xowa.mws.utls.*; import gplx.xowa.mws.libs.*; import gplx.xowa.mws.filerepos.files.*; import gplx.xowa.parsers.uniqs.*; /* TODO.XO @@ -50,6 +50,8 @@ public class Xomw_lnki_wkr {// THREAD.UNSAFE: caching for repeated calls private final Xomw_parser parser; private final Xomw_atr_mgr extra_atrs = new Xomw_atr_mgr(); private final Xomw_qry_mgr query = new Xomw_qry_mgr(); + private final Btrie_rv trv = new Btrie_rv(); + private final List_adp tmp_list = List_adp_.New(); public Xomw_lnki_wkr(Xomw_parser parser, Xomw_link_holders holders, Xomw_link_renderer link_renderer, Btrie_slim_mgr protocols_trie) { this.parser = parser; this.holders = holders; @@ -189,7 +191,9 @@ public class Xomw_lnki_wkr {// THREAD.UNSAFE: caching for repeated calls ttl_end = -1; if (ttl_end == -1) { // either (a) no valid title-chars ("[[<") or (b) title char, but has stray "]" ("[[a]b]]") // Invalid form; output directly - bfr.Add_mid(src, cur, src_end); + bfr.Add_mid(src, prv, lnki_bgn + 2); + bfr.Add_mid(src, cur, ttl_bgn); + prv = cur = ttl_bgn; continue; } // PORTED.END: if (preg_match($e1, $line, $m)) && else if (preg_match($e1_img, $line, $m)) @@ -265,8 +269,7 @@ public class Xomw_lnki_wkr {// THREAD.UNSAFE: caching for repeated calls nt = wiki.Ttl_parse(unstrip); if (nt == null) { bfr.Add_mid(src, prv, lnki_bgn + 2); // $s .= $prefix . '[[' . $line; - cur = lnki_bgn + 2; - prv = cur; + prv = cur = lnki_bgn + 2; continue; } @@ -431,7 +434,7 @@ public class Xomw_lnki_wkr {// THREAD.UNSAFE: caching for repeated calls } } } - public void Make_image(Bry_bfr bfr, Xoa_ttl title, byte[] options, boolean holders) { + public void Make_image(Bry_bfr bfr, Xoa_ttl title, byte[] link_args, boolean holders) { // Check if the options text is of the form "options|alt text" // Options are: // * thumbnail make a thumbnail with enlarge-icon and caption, alignment depends on lang @@ -459,9 +462,7 @@ public class Xomw_lnki_wkr {// THREAD.UNSAFE: caching for repeated calls // * text-bottom // Protect LanguageConverter markup when splitting into parts -// $parts = StringUtils::delimiterExplode( -// '-{', '}-', '|', $options, true /* allow nesting */ -// ); + byte[][] parts = Xomw_string_utils.Delimiter_explode(tmp_list, trv, link_args); // Give extensions a chance to select the file revision for us // $options = []; @@ -484,16 +485,19 @@ public class Xomw_lnki_wkr {// THREAD.UNSAFE: caching for repeated calls // Process the input parameters byte[] caption = Bry_.Empty; // XO.MW: $params = [ 'frame' => [], 'handler' => [], 'horizAlign' => [], 'vertAlign' => [] ]; + Xomw_prm_mgr param_map = new Xomw_prm_mgr(); + Xomw_prm_mgr param_mgr = new Xomw_prm_mgr(); Xomw_img_prms frame = new Xomw_img_prms(); Xomw_mda_prms handler = new Xomw_mda_prms(); boolean seen_format = false; -// foreach ($parts as $part) { - Xomw_prm_mgr param_map = new Xomw_prm_mgr(); - Xomw_prm_mgr param_mgr = new Xomw_prm_mgr(); - byte[] part = null; + int parts_len = parts.length; + for (int i = 0; i < parts_len; i++) { + + byte[] part = parts[i]; part = Bry_.Trim(part); - byte[] magic_name = null; // $mwArray->matchVariableStartToEnd($part); +// byte[] magic_name = $mwArray->matchVariableStartToEnd($part); + byte[] magic_name = null; boolean validated = false; Xomw_prm_itm prm_itm = param_map.Get_or_null(magic_name); @@ -582,7 +586,7 @@ public class Xomw_lnki_wkr {// THREAD.UNSAFE: caching for repeated calls if (!validated) { caption = part; } -// } + } // Process alignment parameters Xomw_prm_itm tmp = param_mgr.Get_or_null(Xomw_prm_mgr.Name__horiz_align); diff --git a/400_xowa/src/gplx/xowa/mws/parsers/lnkis/Xomw_lnki_wkr__tst.java b/400_xowa/src/gplx/xowa/mws/parsers/lnkis/Xomw_lnki_wkr__tst.java index 4b64446fa..961b36a15 100644 --- a/400_xowa/src/gplx/xowa/mws/parsers/lnkis/Xomw_lnki_wkr__tst.java +++ b/400_xowa/src/gplx/xowa/mws/parsers/lnkis/Xomw_lnki_wkr__tst.java @@ -20,16 +20,13 @@ import org.junit.*; public class Xomw_lnki_wkr__tst { private final Xomw_lnki_wkr__fxt fxt = new Xomw_lnki_wkr__fxt(); @Before public void init() {fxt.Clear();} -// @Test public void Basic() {fxt.Test__parse("[[A]]" , "");} @Test public void Text() {fxt.Test__parse("a [[A]] z" , "a z");} @Test public void Capt() {fxt.Test__parse("a [[A|a]] z" , "a z");} -// @Test public void Text() {fxt.Test__parse("a [[A]] z" , "a A z");} -// @Test public void Capt() {fxt.Test__parse("a [[A|a]] z" , "a a z");} -// @Test public void Text() {fxt.Test__parse("a [[A]] z" , "a z");} -// @Test public void Invalid__char() {fxt.Test__parse("[[]]" , "[[]]");} - @Test public void Html__self() {fxt.Test__to_html("[[Page_1]]" , "Page_1");} - @Test public void Html__text() {fxt.Test__to_html("[[A]]" , "A");} - @Test public void Html__capt() {fxt.Test__to_html("[[A|a]]" , "a");} + @Test public void Invalid__char() {fxt.Test__parse("a [[]] z" , "a [[]] z");} + @Test public void Html__self() {fxt.Test__to_html("[[Page_1]]" , "Page_1");} + @Test public void Html__text() {fxt.Test__to_html("[[A]]" , "A");} + @Test public void Html__capt() {fxt.Test__to_html("[[A|a]]" , "a");} +// @Test public void Html__file() {fxt.Test__to_html("[[File:A.png|thumb|abc]]" , "Page_1");} } class Xomw_lnki_wkr__fxt { private final Xomw_lnki_wkr wkr; diff --git a/400_xowa/src/gplx/xowa/mws/parsers/tables/Xomw_table_wkr.java b/400_xowa/src/gplx/xowa/mws/parsers/tables/Xomw_table_wkr.java index 0c93e4c9d..41bae2593 100644 --- a/400_xowa/src/gplx/xowa/mws/parsers/tables/Xomw_table_wkr.java +++ b/400_xowa/src/gplx/xowa/mws/parsers/tables/Xomw_table_wkr.java @@ -18,7 +18,7 @@ along with this program. If not, see . package gplx.xowa.mws.parsers.tables; import gplx.*; import gplx.xowa.*; import gplx.xowa.mws.*; import gplx.xowa.mws.parsers.*; import gplx.langs.phps.utls.*; import gplx.xowa.parsers.htmls.*; -import gplx.xowa.mws.utls.*; import gplx.xowa.parsers.uniqs.*; +import gplx.xowa.mws.libs.*; import gplx.xowa.parsers.uniqs.*; public class Xomw_table_wkr implements gplx.core.brys.Bry_split_wkr {// THREAD.UNSAFE: caching for repeated calls private final Bry_bfr tmp; private Bry_bfr bfr; @@ -190,7 +190,7 @@ public class Xomw_table_wkr implements gplx.core.brys.Bry_split_wkr {// THREAD.U // Implies both are valid for table headings. if (first_char == Byte_ascii.Bang) { - Xomw_string_utl.Replace_markup(line, 0, line.length, Wtxt__th2, Wtxt__td2); // $line = StringUtils::replaceMarkup('!!', '||', $line); + Xomw_string_utils.Replace_markup(line, 0, line.length, Wtxt__th2, Wtxt__td2); // $line = StringUtils::replaceMarkup('!!', '||', $line); } // Split up multiple cells on the same line.