Mw_parse.Tblw: Add more implementation of tblw

pull/620/head
gnosygnu 8 years ago
parent 3af333e563
commit 683481abbd

@ -28,6 +28,8 @@ public class Xomw_tblw_wkr {
private static final byte[] private static final byte[]
Bry__tblw_end = Bry_.new_a7("|}"), Bry__tr = Bry_.new_a7("|-"), Bry__th = Bry_.new_a7("|+") Bry__tblw_end = Bry_.new_a7("|}"), Bry__tr = Bry_.new_a7("|-"), Bry__th = Bry_.new_a7("|+")
, Bry__special_case = Bry_.new_a7("<table>\n<tr><td></td></tr>\n</table>") , Bry__special_case = Bry_.new_a7("<table>\n<tr><td></td></tr>\n</table>")
, Bry__tag__td = Bry_.new_a7("td"), Bry__tag__th = Bry_.new_a7("th"), Bry__tag__caption = Bry_.new_a7("caption")
, Bry__elem_end__tr = Bry_.new_a7("</tr>")
; ;
private static final int Len__special_case = Bry__special_case.length; private static final int Len__special_case = Bry__special_case.length;
public byte[] Do_table_stuff(byte[] src) { public byte[] Do_table_stuff(byte[] src) {
@ -63,17 +65,17 @@ public class Xomw_tblw_wkr {
if (is_indented_table) { if (is_indented_table) {
// if (preg_match('/^(:*)\s*\{\|(.*)$/', $line, $matches)) { // if (preg_match('/^(:*)\s*\{\|(.*)$/', $line, $matches)) {
// // First check if we are starting a new table // // First check if we are starting a new table
// $indent_level = strlen( $matches[1] ); // $indent_level = strlen(matches[1]);
// //
// $attributes = $this->mStripState->unstripBoth( $matches[2] ); // $attributes = $this->mStripState->unstripBoth(matches[2]);
// $attributes = Sanitizer::fixTagAttributes( $attributes, 'table' ); // $attributes = Sanitizer::fixTagAttributes(attributes, 'table');
// //
// line_orig = str_repeat('<dl><dd>', $indent_level) . "<table{$attributes}>"; // line_orig = str_repeat('<dl><dd>', $indent_level) . "<table{$attributes}>";
// array_push( $td_history, false ); td_history.Add(false);
// array_push( $last_tag_history, '' ); last_tag_history.Add(Bry_.Empty);
// array_push( $tr_history, false ); tr_history.Add(false);
// array_push( $tr_attributes, '' ); tr_attributes.Add(Bry_.Empty);
// array_push( $has_opened_tr, false ); has_opened_tr.Add(false);
} }
else if (td_history.Len() == 0) { else if (td_history.Len() == 0) {
// Don't do any of the following // Don't do any of the following
@ -106,102 +108,106 @@ public class Xomw_tblw_wkr {
// $line = preg_replace('#^\|-+#', '', $line); // $line = preg_replace('#^\|-+#', '', $line);
// //
// // Whats after the tag is now only attributes // // Whats after the tag is now only attributes
// $attributes = $this->mStripState->unstripBoth( $line ); // $attributes = $this->mStripState->unstripBoth(line);
// $attributes = Sanitizer::fixTagAttributes( $attributes, 'tr' ); // $attributes = Sanitizer::fixTagAttributes(attributes, 'tr');
// array_pop( $tr_attributes ); List_adp_.Pop(tr_attributes);
// array_push( $tr_attributes, $attributes ); // array_push(tr_attributes, $attributes);
//
// $line = ''; line = Bry_.Empty;
// $last_tag = array_pop( $last_tag_history ); byte[] last_tag = (byte[])List_adp_.Pop(last_tag_history);
// array_pop( $has_opened_tr ); List_adp_.Pop(has_opened_tr);
// array_push( $has_opened_tr, true ); has_opened_tr.Add(true);
//
// if ( array_pop( $tr_history ) ) { if ((boolean)List_adp_.Pop(tr_history)) {
// $line = '</tr>'; line = Bry__elem_end__tr;
// } }
//
// if ( array_pop( $td_history ) ) { if ((boolean)List_adp_.Pop(td_history)) {
// $line = "</{$last_tag}>{$line}"; line = tmp_bfr.Add_str_a7("</").Add(last_tag).Add_byte(Byte_ascii.Gt).Add(line).To_bry_and_clear();
// } }
//
// line_orig = $line; line_orig = line;
// array_push( $tr_history, false ); tr_history.Add(false);
// array_push( $td_history, false ); td_history.Add(false);
// array_push( $last_tag_history, '' ); last_tag_history.Add(Bry_.Empty);
} }
else if ( char_0 == Byte_ascii.Pipe else if ( char_0 == Byte_ascii.Pipe
|| char_0 == Byte_ascii.Bang || char_0 == Byte_ascii.Bang
|| Bry_.Eq(chars_2, Bry__th) || Bry_.Eq(chars_2, Bry__th)
) { ) {
// This might be cell elements, td, th or captions // This might be cell elements, td, th or captions
// if ( $first_two === '|+' ) { if (Bry_.Eq(chars_2, Bry__th)) {
// $first_character = '+'; char_0 = Byte_ascii.Pipe;
// $line = substr( $line, 2 ); line = Bry_.Mid(line, 2);
// } else { } else {
// $line = substr( $line, 1 ); line = Bry_.Mid(line, 1);
// } }
//
// // Implies both are valid for table headings. // Implies both are valid for table headings.
// if ( $first_character === '!' ) { if (char_0 == Byte_ascii.Nl) {
// $line = StringUtils::replaceMarkup('!!', '||', $line); // $line = StringUtils::replaceMarkup('!!', '||', $line);
// } }
//
// // Split up multiple cells on the same line. // Split up multiple cells on the same line.
// // FIXME : This can result in improper nesting of tags processed // FIXME : This can result in improper nesting of tags processed
// // by earlier parser steps. // by earlier parser steps.
// $cells = explode('||', $line); // $cells = explode('||', $line);
//
// line_orig = ''; line_orig = Bry_.Empty;
//
// // Loop through each table cell byte[] previous = null;
// foreach ( $cells as $cell ) { // Loop through each table cell
// $previous = ''; // foreach (cells as $cell) {
// if ( $first_character !== '+' ) { previous = Bry_.Empty;
// $tr_after = array_pop( $tr_attributes ); if (char_0 != Byte_ascii.Plus) {
// if ( !array_pop( $tr_history ) ) { byte[] tr_after = (byte[])List_adp_.Pop(tr_attributes);
// $previous = "<tr{$tr_after}>\n"; if (!(boolean)List_adp_.Pop(tr_history)) {
// } previous = tmp_bfr.Add_str_a7("<tr").Add(tr_after).Add_str_a7(">\n").To_bry_and_clear();
// array_push( $tr_history, true ); }
// array_push( $tr_attributes, '' ); tr_history.Add(true);
// array_pop( $has_opened_tr ); tr_attributes.Add(Bry_.Empty);
// array_push( $has_opened_tr, true ); List_adp_.Pop(has_opened_tr);
// } has_opened_tr.Add(true);
// }
// $last_tag = array_pop( $last_tag_history );
// byte[] last_tag = (byte[])List_adp_.Pop(last_tag_history);
// if ( array_pop( $td_history ) ) {
// $previous = "</{$last_tag}>\n{$previous}"; if ((boolean)List_adp_.Pop(td_history)) {
// } previous = tmp_bfr.Add_str_a7("</").Add(last_tag).Add_str_a7(">\n").Add(previous).To_bry_and_clear();
// }
// if ( $first_character === '|' ) {
// $last_tag = 'td'; if (char_0 == Byte_ascii.Pipe) {
// } elseif ( $first_character === '!' ) { last_tag = Bry__tag__td;
// $last_tag = 'th'; }
// } elseif ( $first_character === '+' ) { else if (char_0 == Byte_ascii.Bang) {
// $last_tag = 'caption'; last_tag = Bry__tag__th;
// } else { }
// $last_tag = ''; else if (char_0 == Byte_ascii.Plus) {
// } last_tag = Bry__tag__caption;
// }
// array_push( $last_tag_history, $last_tag ); else {
last_tag = Bry_.Empty;
}
last_tag_history.Add(last_tag);
// //
// // A cell could contain both parameters and data // // A cell could contain both parameters and data
// $cell_data = explode('|', $cell, 2); // $cell_data = explode('|', $cell, 2);
// //
// // Bug 553: Note that a '|' inside an invalid link should not // // Bug 553: Note that a '|' inside an invalid link should not
// // be mistaken as delimiting cell parameters // // be mistaken as delimiting cell parameters
// if ( strpos( $cell_data[0], '[[' ) !== false ) { // if (strpos(cell_data[0], '[[') !== false) {
// $cell = "{$previous}<{$last_tag}>{$cell}"; // $cell = "{$previous}<{$last_tag}>{$cell}";
// } elseif ( count( $cell_data ) == 1 ) { // } else if (count(cell_data) == 1) {
// $cell = "{$previous}<{$last_tag}>{$cell_data[0]}"; // $cell = "{$previous}<{$last_tag}>{$cell_data[0]}";
// } else { // } else {
// $attributes = $this->mStripState->unstripBoth( $cell_data[0] ); // $attributes = $this->mStripState->unstripBoth(cell_data[0]);
// $attributes = Sanitizer::fixTagAttributes( $attributes, $last_tag ); // $attributes = Sanitizer::fixTagAttributes(attributes, $last_tag);
// $cell = "{$previous}<{$last_tag}{$attributes}>{$cell_data[1]}"; // $cell = "{$previous}<{$last_tag}{$attributes}>{$cell_data[1]}";
// } // }
// //
// line_orig .= $cell; // line_orig = Bry_.Add(line_orig, $cell);
// array_push( $td_history, true ); td_history.Add(true);
// } // }
} }
bfr.Add(line_orig).Add_byte_nl(); bfr.Add(line_orig).Add_byte_nl();

Loading…
Cancel
Save