|
|
@ -24,7 +24,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
// Contains contributions from Alexander Schier [AS]
|
|
|
|
// Contains contributions from Alexander Schier [AS]
|
|
|
|
// Franz Brausze [FB] and Marc Nause [MN]
|
|
|
|
// Franz Brausze [FB] and Marc Nause [MN]
|
|
|
|
|
|
|
|
|
|
|
|
package de.anomic.data.wiki;
|
|
|
|
package de.anomic.data.wiki;
|
|
|
|
|
|
|
|
|
|
|
|
import java.io.BufferedReader;
|
|
|
|
import java.io.BufferedReader;
|
|
|
@ -43,7 +42,9 @@ public class wikiCode extends abstractWikiParser implements wikiParser {
|
|
|
|
|
|
|
|
|
|
|
|
/* Table properties */
|
|
|
|
/* Table properties */
|
|
|
|
private static final String[] tps = {"rowspan", "colspan", "vspace", "hspace", "cellspacing", "cellpadding", "border"};
|
|
|
|
private static final String[] tps = {"rowspan", "colspan", "vspace", "hspace", "cellspacing", "cellpadding", "border"};
|
|
|
|
private static final HashMap/* <String,String[]> */<String, String[]> ps = new HashMap<String, String[]>();
|
|
|
|
private static final HashMap<String, String[]> ps = new HashMap<String, String[]>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static {
|
|
|
|
static {
|
|
|
|
Arrays.sort(tps);
|
|
|
|
Arrays.sort(tps);
|
|
|
|
String[] array;
|
|
|
|
String[] array;
|
|
|
@ -56,7 +57,6 @@ public class wikiCode extends abstractWikiParser implements wikiParser {
|
|
|
|
Arrays.sort(array = new String[]{"left", "right", "center"});
|
|
|
|
Arrays.sort(array = new String[]{"left", "right", "center"});
|
|
|
|
ps.put("align", array);
|
|
|
|
ps.put("align", array);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private String numListLevel = "";
|
|
|
|
private String numListLevel = "";
|
|
|
|
private String ListLevel = "";
|
|
|
|
private String ListLevel = "";
|
|
|
|
private String defListLevel = "";
|
|
|
|
private String defListLevel = "";
|
|
|
@ -83,8 +83,9 @@ public class wikiCode extends abstractWikiParser implements wikiParser {
|
|
|
|
final int length) throws IOException {
|
|
|
|
final int length) throws IOException {
|
|
|
|
final StringBuilder out = new StringBuilder(length);
|
|
|
|
final StringBuilder out = new StringBuilder(length);
|
|
|
|
String line;
|
|
|
|
String line;
|
|
|
|
while ((line = reader.readLine()) != null)
|
|
|
|
while ((line = reader.readLine()) != null) {
|
|
|
|
out.append(transformLine(line)).append(serverCore.CRLF_STRING);
|
|
|
|
out.append(transformLine(line)).append(serverCore.CRLF_STRING);
|
|
|
|
|
|
|
|
}
|
|
|
|
return out.insert(0, directory()).toString();
|
|
|
|
return out.insert(0, directory()).toString();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -115,8 +116,7 @@ public class wikiCode extends abstractWikiParser implements wikiParser {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
line += ">";
|
|
|
|
line += ">";
|
|
|
|
result = line;
|
|
|
|
result = line;
|
|
|
|
}
|
|
|
|
} else if (result.startsWith(newLine) && (table)) { // new row
|
|
|
|
else if (result.startsWith(newLine) && (table)) { // new row
|
|
|
|
|
|
|
|
if (!newrowstart) {
|
|
|
|
if (!newrowstart) {
|
|
|
|
line += "\t</tr>\n";
|
|
|
|
line += "\t</tr>\n";
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
@ -124,8 +124,7 @@ public class wikiCode extends abstractWikiParser implements wikiParser {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
line = line + "\t<tr>";
|
|
|
|
line = line + "\t<tr>";
|
|
|
|
result = line;
|
|
|
|
result = line;
|
|
|
|
}
|
|
|
|
} else if ((result.startsWith(cellDivider)) && (table)) {
|
|
|
|
else if ((result.startsWith(cellDivider)) && (table)) {
|
|
|
|
|
|
|
|
line += "\t\t<td";
|
|
|
|
line += "\t\t<td";
|
|
|
|
final int cellEnd = (result.indexOf(cellDivider, lenCellDivider) > 0) ? (result.indexOf(cellDivider, lenCellDivider)) : (result.length());
|
|
|
|
final int cellEnd = (result.indexOf(cellDivider, lenCellDivider) > 0) ? (result.indexOf(cellDivider, lenCellDivider)) : (result.length());
|
|
|
|
int propEnd = result.indexOf(attribDivider, lenCellDivider);
|
|
|
|
int propEnd = result.indexOf(attribDivider, lenCellDivider);
|
|
|
@ -135,35 +134,31 @@ public class wikiCode extends abstractWikiParser implements wikiParser {
|
|
|
|
//property for this cell, only an image. Without this, YaCy could get confused
|
|
|
|
//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]]
|
|
|
|
//by a | in [[Image:picture.png|alt-text]] or [[Image:picture.png|alt-text]]
|
|
|
|
//Same for [= (part of [= =])
|
|
|
|
//Same for [= (part of [= =])
|
|
|
|
if((propEnd > lenCellDivider)
|
|
|
|
if ((propEnd > lenCellDivider) && ((occImage > propEnd) || (occImage < 0)) && ((occEscape > propEnd) || (occEscape < 0))) {
|
|
|
|
&&((occImage > propEnd)||( occImage < 0))
|
|
|
|
|
|
|
|
&&((occEscape> propEnd)||( occEscape < 0))
|
|
|
|
|
|
|
|
){
|
|
|
|
|
|
|
|
propEnd = result.indexOf(attribDivider, lenCellDivider) + lenAttribDivider;
|
|
|
|
propEnd = result.indexOf(attribDivider, lenCellDivider) + lenAttribDivider;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
else {
|
|
|
|
|
|
|
|
propEnd = cellEnd;
|
|
|
|
propEnd = cellEnd;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// both point at same place => new line
|
|
|
|
// both point at same place => new line
|
|
|
|
if (propEnd == cellEnd) {
|
|
|
|
if (propEnd == cellEnd) {
|
|
|
|
propEnd = lenCellDivider;
|
|
|
|
propEnd = lenCellDivider;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
else {
|
|
|
|
|
|
|
|
line += parseTableProperties(result.substring(lenCellDivider, propEnd - lenAttribDivider).trim()).toString();
|
|
|
|
line += parseTableProperties(result.substring(lenCellDivider, propEnd - lenAttribDivider).trim()).toString();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// quick&dirty fix [MN]
|
|
|
|
// quick&dirty fix [MN]
|
|
|
|
if (propEnd > cellEnd) {
|
|
|
|
if (propEnd > cellEnd) {
|
|
|
|
propEnd = lenCellDivider;
|
|
|
|
propEnd = lenCellDivider;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
table=false; cellprocessing=true;
|
|
|
|
table = false;
|
|
|
|
|
|
|
|
cellprocessing = true;
|
|
|
|
line += ">" + processTable(result.substring(propEnd, cellEnd).trim()) + "</td>";
|
|
|
|
line += ">" + processTable(result.substring(propEnd, cellEnd).trim()) + "</td>";
|
|
|
|
table=true; cellprocessing=false;
|
|
|
|
table = true;
|
|
|
|
|
|
|
|
cellprocessing = false;
|
|
|
|
if (cellEnd < result.length()) {
|
|
|
|
if (cellEnd < result.length()) {
|
|
|
|
line += "\n" + processTable(result.substring(cellEnd));
|
|
|
|
line += "\n" + processTable(result.substring(cellEnd));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
result = line;
|
|
|
|
result = line;
|
|
|
|
}
|
|
|
|
} else if (result.startsWith(tableEnd) && (table)) { // Table end
|
|
|
|
else if (result.startsWith(tableEnd) && (table)) { // Table end
|
|
|
|
|
|
|
|
table = false;
|
|
|
|
table = false;
|
|
|
|
line += "\t</tr>\n</table>" + result.substring(lenTableEnd);
|
|
|
|
line += "\t</tr>\n</table>" + result.substring(lenTableEnd);
|
|
|
|
result = line;
|
|
|
|
result = line;
|
|
|
@ -191,13 +186,11 @@ public class wikiCode extends abstractWikiParser implements wikiParser {
|
|
|
|
addPair("nowrap", "nowrap", sb);
|
|
|
|
addPair("nowrap", "nowrap", sb);
|
|
|
|
} else if (i + 1 < numberofvalues) {
|
|
|
|
} else if (i + 1 < numberofvalues) {
|
|
|
|
value = values[++i].trim();
|
|
|
|
value = values[++i].trim();
|
|
|
|
if (
|
|
|
|
if ((key.equals("summary")) ||
|
|
|
|
(key.equals("summary")) ||
|
|
|
|
|
|
|
|
(key.equals("bgcolor") && value.matches("#{0,1}[0-9a-fA-F]{1,6}|[a-zA-Z]{3,}")) ||
|
|
|
|
(key.equals("bgcolor") && value.matches("#{0,1}[0-9a-fA-F]{1,6}|[a-zA-Z]{3,}")) ||
|
|
|
|
((key.equals("width") || key.equals("height")) && value.matches("\\d+%{0,1}")) ||
|
|
|
|
((key.equals("width") || key.equals("height")) && value.matches("\\d+%{0,1}")) ||
|
|
|
|
((posVals = ps.get(key)) != null && Arrays.binarySearch(posVals, value) >= 0) ||
|
|
|
|
((posVals = ps.get(key)) != null && Arrays.binarySearch(posVals, value) >= 0) ||
|
|
|
|
(Arrays.binarySearch(tps, key) >= 0 && value.matches("\\d+"))
|
|
|
|
(Arrays.binarySearch(tps, key) >= 0 && value.matches("\\d+"))) {
|
|
|
|
) {
|
|
|
|
|
|
|
|
addPair(key, value, sb);
|
|
|
|
addPair(key, value, sb);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -381,7 +374,9 @@ public class wikiCode extends abstractWikiParser implements wikiParser {
|
|
|
|
// internal links and images
|
|
|
|
// internal links and images
|
|
|
|
while ((p0 = result.indexOf("[[")) >= 0) {
|
|
|
|
while ((p0 = result.indexOf("[[")) >= 0) {
|
|
|
|
p1 = result.indexOf("]]", p0 + 2);
|
|
|
|
p1 = result.indexOf("]]", p0 + 2);
|
|
|
|
if (p1 <= p0) break;
|
|
|
|
if (p1 <= p0) {
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
kl = result.substring(p0 + 2, p1);
|
|
|
|
kl = result.substring(p0 + 2, p1);
|
|
|
|
|
|
|
|
|
|
|
|
// this is the part of the code that's responsible for images
|
|
|
|
// this is the part of the code that's responsible for images
|
|
|
@ -406,17 +401,17 @@ public class wikiCode extends abstractWikiParser implements wikiParser {
|
|
|
|
(align.equals("left")) ||
|
|
|
|
(align.equals("left")) ||
|
|
|
|
(align.equals("middle")) ||
|
|
|
|
(align.equals("middle")) ||
|
|
|
|
(align.equals("right")) ||
|
|
|
|
(align.equals("right")) ||
|
|
|
|
(align.equals("top")))
|
|
|
|
(align.equals("top"))) {
|
|
|
|
{
|
|
|
|
|
|
|
|
align = " align=\"" + align + "\"";
|
|
|
|
align = " align=\"" + align + "\"";
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
align = "";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else align = "";
|
|
|
|
|
|
|
|
alt = " alt=\"" + kv.substring(p + 6) + "\"";
|
|
|
|
alt = " alt=\"" + kv.substring(p + 6) + "\"";
|
|
|
|
}
|
|
|
|
} // if there is just one, put it into ALT
|
|
|
|
// if there is just one, put it into ALT
|
|
|
|
else {
|
|
|
|
else
|
|
|
|
|
|
|
|
alt = " alt=\"" + kv + "\"";
|
|
|
|
alt = " alt=\"" + kv + "\"";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// replace incomplete URLs and make them point to http://peerip:port/...
|
|
|
|
// replace incomplete URLs and make them point to http://peerip:port/...
|
|
|
|
// with this feature you can access an image in DATA/HTDOCS/share/yacy.gif
|
|
|
|
// with this feature you can access an image in DATA/HTDOCS/share/yacy.gif
|
|
|
@ -428,9 +423,7 @@ public class wikiCode extends abstractWikiParser implements wikiParser {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
result = result.substring(0, p0) + "<img src=\"" + kl + "\"" + align + alt + ">" + result.substring(p1 + 2);
|
|
|
|
result = result.substring(0, p0) + "<img src=\"" + kl + "\"" + align + alt + ">" + result.substring(p1 + 2);
|
|
|
|
}
|
|
|
|
} // end contrib [MN]
|
|
|
|
// end contrib [MN]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// if it's no image, it might be an internal link
|
|
|
|
// if it's no image, it might be an internal link
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
if ((p = kl.indexOf("|")) > 0) {
|
|
|
|
if ((p = kl.indexOf("|")) > 0) {
|
|
|
@ -446,13 +439,14 @@ public class wikiCode extends abstractWikiParser implements wikiParser {
|
|
|
|
// external links
|
|
|
|
// external links
|
|
|
|
while ((p0 = result.indexOf("[")) >= 0) {
|
|
|
|
while ((p0 = result.indexOf("[")) >= 0) {
|
|
|
|
p1 = result.indexOf("]", p0 + 1);
|
|
|
|
p1 = result.indexOf("]", p0 + 1);
|
|
|
|
if (p1 <= p0) break;
|
|
|
|
if (p1 <= p0) {
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
kl = result.substring(p0 + 1, p1);
|
|
|
|
kl = result.substring(p0 + 1, p1);
|
|
|
|
if ((p = kl.indexOf(" ")) > 0) {
|
|
|
|
if ((p = kl.indexOf(" ")) > 0) {
|
|
|
|
kv = kl.substring(p + 1);
|
|
|
|
kv = kl.substring(p + 1);
|
|
|
|
kl = kl.substring(0, p);
|
|
|
|
kl = kl.substring(0, p);
|
|
|
|
}
|
|
|
|
} // No text for the link? -> <a href="http://www.url.com/">http://www.url.com/</a>
|
|
|
|
// No text for the link? -> <a href="http://www.url.com/">http://www.url.com/</a>
|
|
|
|
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
kv = kl;
|
|
|
|
kv = kl;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -483,8 +477,7 @@ public class wikiCode extends abstractWikiParser implements wikiParser {
|
|
|
|
result = transformLine(result.substring(0, p0).replaceAll("!pre!", "!pre!!") + "!pre!txt!" + result.substring(p1 + 12).replaceAll("!pre!", "!pre!!"));
|
|
|
|
result = transformLine(result.substring(0, p0).replaceAll("!pre!", "!pre!!") + "!pre!txt!" + result.substring(p1 + 12).replaceAll("!pre!", "!pre!!"));
|
|
|
|
result = result.replaceAll("!pre!txt!", preformattedText);
|
|
|
|
result = result.replaceAll("!pre!txt!", preformattedText);
|
|
|
|
result = result.replaceAll("!pre!!", "!pre!");
|
|
|
|
result = result.replaceAll("!pre!!", "!pre!");
|
|
|
|
}
|
|
|
|
} //handles cases like <pre><pre> </pre></pre> <pre> </pre> that would cause an exception otherwise
|
|
|
|
//handles cases like <pre><pre> </pre></pre> <pre> </pre> that would cause an exception otherwise
|
|
|
|
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
preformatted = true;
|
|
|
|
preformatted = true;
|
|
|
|
final String temp1 = transformLine(result.substring(0, p0 - 1).replaceAll("!tmp!", "!tmp!!") + "!tmp!txt!");
|
|
|
|
final String temp1 = transformLine(result.substring(0, p0 - 1).replaceAll("!tmp!", "!tmp!!") + "!tmp!txt!");
|
|
|
@ -495,9 +488,7 @@ public class wikiCode extends abstractWikiParser implements wikiParser {
|
|
|
|
result = result.replaceAll("!tmp!!", "!tmp!");
|
|
|
|
result = result.replaceAll("!tmp!!", "!tmp!");
|
|
|
|
preformatted = false;
|
|
|
|
preformatted = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} //start <pre>
|
|
|
|
|
|
|
|
|
|
|
|
//start <pre>
|
|
|
|
|
|
|
|
else if (((p0 = result.indexOf("<pre>")) >= 0) && (!preformattedSpan) && (!escaped)) {
|
|
|
|
else if (((p0 = result.indexOf("<pre>")) >= 0) && (!preformattedSpan) && (!escaped)) {
|
|
|
|
preformatted = true; //prevent surplus line breaks
|
|
|
|
preformatted = true; //prevent surplus line breaks
|
|
|
|
String bq = ""; //gets filled with <blockquote>s as needed
|
|
|
|
String bq = ""; //gets filled with <blockquote>s as needed
|
|
|
@ -512,9 +503,7 @@ public class wikiCode extends abstractWikiParser implements wikiParser {
|
|
|
|
result = bq + result.replaceAll("!pre!txt!", preformattedText);
|
|
|
|
result = bq + result.replaceAll("!pre!txt!", preformattedText);
|
|
|
|
result = result.replaceAll("!pre!!", "!pre!");
|
|
|
|
result = result.replaceAll("!pre!!", "!pre!");
|
|
|
|
preformattedSpan = true;
|
|
|
|
preformattedSpan = true;
|
|
|
|
}
|
|
|
|
} //end </pre>
|
|
|
|
|
|
|
|
|
|
|
|
//end </pre>
|
|
|
|
|
|
|
|
else if (((p0 = result.indexOf("</pre>")) >= 0) && (preformattedSpan) && (!escaped)) {
|
|
|
|
else if (((p0 = result.indexOf("</pre>")) >= 0) && (preformattedSpan) && (!escaped)) {
|
|
|
|
preformattedSpan = false;
|
|
|
|
preformattedSpan = false;
|
|
|
|
String bq = ""; //gets filled with </blockquote>s as needed
|
|
|
|
String bq = ""; //gets filled with </blockquote>s as needed
|
|
|
@ -529,8 +518,7 @@ public class wikiCode extends abstractWikiParser implements wikiParser {
|
|
|
|
result = result.replaceAll("!pre!txt!", preformattedText) + bq;
|
|
|
|
result = result.replaceAll("!pre!txt!", preformattedText) + bq;
|
|
|
|
result = result.replaceAll("!pre!!", "!pre!");
|
|
|
|
result = result.replaceAll("!pre!!", "!pre!");
|
|
|
|
preformatted = false;
|
|
|
|
preformatted = false;
|
|
|
|
}
|
|
|
|
} //Getting rid of surplus </pre>
|
|
|
|
//Getting rid of surplus </pre>
|
|
|
|
|
|
|
|
else if (((p0 = result.indexOf("</pre>")) >= 0) && (!preformattedSpan) && (!escaped)) {
|
|
|
|
else if (((p0 = result.indexOf("</pre>")) >= 0) && (!preformattedSpan) && (!escaped)) {
|
|
|
|
while ((p0 = result.indexOf("</pre>")) >= 0) {
|
|
|
|
while ((p0 = result.indexOf("</pre>")) >= 0) {
|
|
|
|
result = result.substring(0, p0) + result.substring(p0 + 12);
|
|
|
|
result = result.substring(0, p0) + result.substring(p0 + 12);
|
|
|
@ -556,17 +544,25 @@ public class wikiCode extends abstractWikiParser implements wikiParser {
|
|
|
|
String anchorext = "";
|
|
|
|
String anchorext = "";
|
|
|
|
if ((s = dirElements.size()) > 2) {
|
|
|
|
if ((s = dirElements.size()) > 2) {
|
|
|
|
for (int i = 0; i < s; i++) {
|
|
|
|
for (int i = 0; i < s; i++) {
|
|
|
|
if (i >= dirElements.size()) break;
|
|
|
|
if (i >= dirElements.size()) {
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
element = dirElements.get(i);
|
|
|
|
element = dirElements.get(i);
|
|
|
|
//counting double headlines
|
|
|
|
//counting double headlines
|
|
|
|
doubles = 0;
|
|
|
|
doubles = 0;
|
|
|
|
for (int j = 0; j < i; j++) {
|
|
|
|
for (int j = 0; j < i; j++) {
|
|
|
|
if (j >= dirElements.size()) break;
|
|
|
|
if (j >= dirElements.size()) {
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
String d = dirElements.get(j);
|
|
|
|
String d = dirElements.get(j);
|
|
|
|
if (d == null || d.length() < 1) continue;
|
|
|
|
if (d == null || d.length() < 1) {
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
String a = d.substring(1).replaceAll(" ", "_").replaceAll("[^a-zA-Z0-9_]", "");
|
|
|
|
String a = d.substring(1).replaceAll(" ", "_").replaceAll("[^a-zA-Z0-9_]", "");
|
|
|
|
String b = element.substring(1).replaceAll(" ", "_").replaceAll("[^a-zA-Z0-9_]", "");
|
|
|
|
String b = element.substring(1).replaceAll(" ", "_").replaceAll("[^a-zA-Z0-9_]", "");
|
|
|
|
if (a.equals(b)) doubles++;
|
|
|
|
if (a.equals(b)) {
|
|
|
|
|
|
|
|
doubles++;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//if there are doubles, create anchorextension
|
|
|
|
//if there are doubles, create anchorextension
|
|
|
|
if (doubles > 0) {
|
|
|
|
if (doubles > 0) {
|
|
|
@ -582,8 +578,7 @@ public class wikiCode extends abstractWikiParser implements wikiParser {
|
|
|
|
final String temp = element.substring(1);
|
|
|
|
final String temp = element.substring(1);
|
|
|
|
element = level1 + "." + level2 + "." + level3 + " " + temp;
|
|
|
|
element = level1 + "." + level2 + "." + level3 + " " + temp;
|
|
|
|
directory = directory + " <a href=\"#" + temp.replaceAll(" ", "_").replaceAll("[^a-zA-Z0-9_]", "") + anchorext + "\" class=\"WikiTOC\">" + element + "</a><br />\n";
|
|
|
|
directory = directory + " <a href=\"#" + temp.replaceAll(" ", "_").replaceAll("[^a-zA-Z0-9_]", "") + anchorext + "\" class=\"WikiTOC\">" + element + "</a><br />\n";
|
|
|
|
}
|
|
|
|
} else if (element.startsWith("2")) {
|
|
|
|
else if (element.startsWith("2")){
|
|
|
|
|
|
|
|
if (level == 1) {
|
|
|
|
if (level == 1) {
|
|
|
|
level2 = 0;
|
|
|
|
level2 = 0;
|
|
|
|
level = 2;
|
|
|
|
level = 2;
|
|
|
@ -595,8 +590,7 @@ public class wikiCode extends abstractWikiParser implements wikiParser {
|
|
|
|
final String temp = element.substring(1);
|
|
|
|
final String temp = element.substring(1);
|
|
|
|
element = level1 + "." + level2 + " " + temp;
|
|
|
|
element = level1 + "." + level2 + " " + temp;
|
|
|
|
directory = directory + " <a href=\"#" + temp.replaceAll(" ", "_").replaceAll("[^a-zA-Z0-9_]", "") + anchorext + "\" class=\"WikiTOC\">" + element + "</a><br />\n";
|
|
|
|
directory = directory + " <a href=\"#" + temp.replaceAll(" ", "_").replaceAll("[^a-zA-Z0-9_]", "") + anchorext + "\" class=\"WikiTOC\">" + element + "</a><br />\n";
|
|
|
|
}
|
|
|
|
} else if (element.startsWith("1")) {
|
|
|
|
else if (element.startsWith("1")) {
|
|
|
|
|
|
|
|
if (level > 1) {
|
|
|
|
if (level > 1) {
|
|
|
|
level = 1;
|
|
|
|
level = 1;
|
|
|
|
level2 = 0;
|
|
|
|
level2 = 0;
|
|
|
@ -642,7 +636,9 @@ public class wikiCode extends abstractWikiParser implements wikiParser {
|
|
|
|
//counting double headlines
|
|
|
|
//counting double headlines
|
|
|
|
int doubles = 0;
|
|
|
|
int doubles = 0;
|
|
|
|
for (int i = 0; i < dirElements.size(); i++) {
|
|
|
|
for (int i = 0; i < dirElements.size(); i++) {
|
|
|
|
if (dirElements.get(i) == null) continue;
|
|
|
|
if (dirElements.get(i) == null) {
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
if (dirElements.size() > i && dirElements.get(i).substring(1).equals(direlem)) {
|
|
|
|
if (dirElements.size() > i && dirElements.get(i).substring(1).equals(direlem)) {
|
|
|
|
doubles++;
|
|
|
|
doubles++;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -655,11 +651,14 @@ public class wikiCode extends abstractWikiParser implements wikiParser {
|
|
|
|
input = input.substring(0, p0) + "<a name=\"" + anchor + "\"></a>" + repl1 +
|
|
|
|
input = input.substring(0, p0) + "<a name=\"" + anchor + "\"></a>" + repl1 +
|
|
|
|
direlem + repl2 + input.substring(p1 + l);
|
|
|
|
direlem + repl2 + input.substring(p1 + l);
|
|
|
|
//add headlines to list of headlines (so TOC can be created)
|
|
|
|
//add headlines to list of headlines (so TOC can be created)
|
|
|
|
if(pat.equals("====")) dirElements.add("3"+direlem);
|
|
|
|
if (pat.equals("====")) {
|
|
|
|
else if(pat.equals("===")) dirElements.add("2"+direlem);
|
|
|
|
dirElements.add("3" + direlem);
|
|
|
|
else if(pat.equals("==")) dirElements.add("1"+direlem);
|
|
|
|
} else if (pat.equals("===")) {
|
|
|
|
|
|
|
|
dirElements.add("2" + direlem);
|
|
|
|
|
|
|
|
} else if (pat.equals("==")) {
|
|
|
|
|
|
|
|
dirElements.add("1" + direlem);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
} else {
|
|
|
|
input = input.substring(0, p0) + repl1 +
|
|
|
|
input = input.substring(0, p0) + repl1 +
|
|
|
|
(/*direlem =*/input.substring(p0 + l, p1)) + repl2 +
|
|
|
|
(/*direlem =*/input.substring(p0 + l, p1)) + repl2 +
|
|
|
|
input.substring(p1 + l);
|
|
|
|
input.substring(p1 + l);
|
|
|
@ -693,8 +692,12 @@ public class wikiCode extends abstractWikiParser implements wikiParser {
|
|
|
|
result = processTable(result);
|
|
|
|
result = processTable(result);
|
|
|
|
|
|
|
|
|
|
|
|
// format lines
|
|
|
|
// format lines
|
|
|
|
if (result.startsWith(" ")) result = "<tt>" + result.substring(1) + "</tt>";
|
|
|
|
if (result.startsWith(" ")) {
|
|
|
|
if (result.startsWith("----")) result = "<hr />";
|
|
|
|
result = "<tt>" + result.substring(1) + "</tt>";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (result.startsWith("----")) {
|
|
|
|
|
|
|
|
result = "<hr />";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// citings contributed by [MN]
|
|
|
|
// citings contributed by [MN]
|
|
|
|
if (result.startsWith(":")) {
|
|
|
|
if (result.startsWith(":")) {
|
|
|
@ -726,8 +729,12 @@ public class wikiCode extends abstractWikiParser implements wikiParser {
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!preformatted) replacedHTML = false;
|
|
|
|
if (!preformatted) {
|
|
|
|
if ((result.endsWith("</li>"))||(defList)||(escape)||(preformatted)||(table)||(cellprocessing)) return result;
|
|
|
|
replacedHTML = false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((result.endsWith("</li>")) || (defList) || (escape) || (preformatted) || (table) || (cellprocessing)) {
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
|
|
|
}
|
|
|
|
return result + "<br />";
|
|
|
|
return result + "<br />";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|