Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
*) Partly undoing last commit\n*) Fixed bug that caused attributes of cells in tables not to be recognized as such.
low012d40ccc5208a4
diff --git a/source/de/anomic/data/wikiCode.java b/source/de/anomic/data/wikiCode.javaindex 33e8d39b7..7e34669ee 100644--- a/source/de/anomic/data/wikiCode.java+++ b/source/de/anomic/data/wikiCode.java@@ -6,7 +6,7 @@// Frankfurt, Germany, 2004//// This file ist contributed by Alexander Schier-// last major change: 17.04.2006+// last major change: 08.05.2006//// This program is free software; you can redistribute it and/or modify// it under the terms of the GNU General Public License as published by@@ -188,11 +188,13 @@ public class wikiCode {//patterns that will be replaced. To add new codes or patterns, just put them at the end//of the list. Codes or patterns in this list can not be escaped with [= or <pre>public static String[] characters={- "\u005E","^",+ "\u005E","^", // Caret- "\u0060","`",-- "\u007E","~",+ "\u0060","`", // Accent Grave `+ "\u007B","{", // {+ "\u007C","|", // |+ "\u007D","}", // }+ "\u007E","~", // ~"\u0082","‚","\u0083","ƒ",@@ -328,18 +330,29 @@ public class wikiCode {*///[FB], changes by [MN]private String processTable(String result, plasmaSwitchboard switchboard){- String line="";- if ((result.startsWith("{|")) && (!table)) {+ //some variables that make it easier to change codes for the table+ String line = "";+ String tableStart = "{|"; // {|+ String newLine = "|-"; // |-+ String cellDivider = "||"; // ||+ String tableEnd = "|}"; // |}+ String attribDivider = "|"; // |+ int lenTableStart = tableStart.length();+ int lenCellDivider = cellDivider.length();+ int lenTableEnd = tableEnd.length();+ int lenAttribDivider = attribDivider.length();++ if ((result.startsWith(tableStart)) && (!table)) {table=true;newrowstart=true;line="<table";- if (result.trim().length()>2) {- line+=parseTableProperties(result.substring(2).trim());+ if (result.trim().length()>lenTableStart) {+ line+=parseTableProperties(result.substring(lenTableStart).trim());}line+=">";result=line;}- else if (result.startsWith("|-") && (table)) { // new row+ else if (result.startsWith(newLine) && (table)) { // new rowif (!newrowstart) {line+="\t</tr>\n";} else {@@ -348,36 +361,42 @@ public class wikiCode {line=line+"\t<tr>";result=line;}- else if ((result.startsWith("||")) && (table)) {+ else if ((result.startsWith(cellDivider)) && (table)) {line+="\t\t<td";- int cellEnd=(result.indexOf("||",2)>0)?(result.indexOf("||",2)):(result.length());- int propEnd = 0;+ int cellEnd=(result.indexOf(cellDivider,lenCellDivider)>0)?(result.indexOf(cellDivider,lenCellDivider)):(result.length());+ int propEnd = result.indexOf(attribDivider,lenCellDivider);+ int occImage = result.indexOf("[[Image:",lenCellDivider);+ int occEscape = result.indexOf("[=",lenCellDivider);//If resultOf("[[Image:") is less than propEnd, that means that there is no//property for this cell, only an image. Without this, YaCy could get confused//by a | in [[Image:picture.png|alt-text]] or [[Image:picture.png|alt-text]]- if(((propEnd = result.indexOf("|",2)) > 0)&&(!(result.indexOf("[[Image:",2) < propEnd))){- propEnd = result.indexOf("|",2);+ //Same for [= (part of [= =])+ if((propEnd > lenCellDivider)+ &&((occImage > propEnd)||( occImage < 0))+ &&((occEscape> propEnd)||( occEscape < 0))+ ){+ propEnd = result.indexOf(attribDivider,lenCellDivider)+lenAttribDivider;}else {propEnd = cellEnd;}// both point at same place => new lineif (propEnd==cellEnd) {- propEnd=1;+ propEnd=lenCellDivider;} else {- line+=parseTableProperties(result.substring(2,propEnd).trim());+ line+=parseTableProperties(result.substring(lenCellDivider,propEnd-lenAttribDivider).trim());}table=false; cellprocessing=true;- line+=">"+processTable(result.substring(propEnd+1,cellEnd).trim(), switchboard)+"</td>";+ line+=">"+processTable(result.substring(propEnd,cellEnd).trim(), switchboard)+"</td>";table=true; cellprocessing=false;if (cellEnd<result.length()) {line+="\n"+processTable(result.substring(cellEnd), switchboard);}result=line;}- else if (result.startsWith("|}") && (table)) { // Table end+ else if (result.startsWith(tableEnd) && (table)) { // Table endtable=false;- line+="\t</tr>\n</table>"+result.substring(2);+ line+="\t</tr>\n</table>"+result.substring(lenTableEnd);result=line;}return result;@@ -670,11 +689,11 @@ public class wikiCode {kl = kl.substring(6);// are there any arguments for the image?- if ((p = kl.indexOf("|")) > 0) {+ if ((p = kl.indexOf("|")) > 0) {kv = kl.substring(p + 1);kl = kl.substring(0, p);// if there are 2 arguments, write them into ALIGN and ALT- if ((p = kv.indexOf("|")) > 0) {+ if ((p = kv.indexOf("|")) > 0) {align = kv.substring(0, p);//checking validity of value for align. Only non browser specific//values get supported. Not supported: absmiddle, baseline, texttop@@ -710,7 +729,7 @@ public class wikiCode {// if it's no image, it might be an internal linkelse {- if ((p = kl.indexOf("|")) > 0) {+ if ((p = kl.indexOf("|")) > 0) {kv = kl.substring(p + 1);kl = kl.substring(0, p);} else {