if ((tmpIndex2 < maxLength) && (contents.charAt(tmpIndex2) == ']')) {
suffix = contents.substring(tmpIndex + 1, tmpIndex2 + 1);
} else {
tmpIndex2 = tmpIndex;
}
CheckErrorResult errorResult = createCheckErrorResult(
analysis, currentIndex, tmpIndex2 + 1);
// Check if the situation is something like [[http://....] (replacement: [http://....])
boolean protocolFound = PageElementExternalLink.isPossibleProtocol(contents, currentIndex + 2);
if (protocolFound) {
errorResult.addReplacement(contents.substring(currentIndex + 1, tmpIndex2 + 1));
}
errorResult.addReplacement(contents.substring(currentIndex, tmpIndex + 1) + "]" + suffix);
if (suffix.length() > 0) {
errorResult.addReplacement(contents.substring(currentIndex, tmpIndex) + suffix + "]");
}
errors.add(errorResult);
errorReported = true;
finished = true;
} else if (tmpChar == '}') {
int lastChar = tmpIndex;
if ((lastChar + 1 < maxLength) && (contents.charAt(lastChar + 1) == '}')) {
lastChar++;
}
CheckErrorResult errorResult = createCheckErrorResult(
analysis, currentIndex, lastChar + 1);
errorResult.addReplacement(contents.substring(currentIndex, tmpIndex) + "]]");
errorResult.addReplacement("{{" + contents.substring(currentIndex + 2, tmpIndex) + "}}");
errors.add(errorResult);
errorReported = true;
finished = true;
}
tmpIndex++;
}
// Default
if (!errorReported) {
CheckErrorResult errorResult = createCheckErrorResult(
analysis, currentIndex, currentIndex + 2);
errorResult.addReplacement("", GT._("Delete"));
errors.add(errorResult);
}
}
currentIndex = contents.indexOf("[[", currentIndex + 2);
}
// Analyze each internal link to see if it contains a [
for (PageElementInternalLink link : analysis.getInternalLinks()) {
String text = link.getText();
if (text != null) {
text = cleanText(text);
if (text != null) {
if (errors == null) {
return true;
}
result = true;
CheckErrorResult errorResult = createCheckErrorResult(
analysis, link.getBeginIndex(), link.getEndIndex());
errorResult.addReplacement(PageElementInternalLink.createInternalLink(
link.getLink(), link.getAnchor(), text));
errors.add(errorResult);
}
}
}
// Analyze each image to see if it contains a [
for (PageElementImage image : analysis.getImages()) {
String text = image.getDescription();
String modifiedText = cleanText(text);
String alt = image.getAlternateDescription();
String modifiedAlt = cleanText(alt);
if ((modifiedText != null) || (modifiedAlt != null)) {
if (errors == null) {
return true;
}
result = true;
CheckErrorResult errorResult = createCheckErrorResult(
analysis, image.getBeginIndex(), image.getEndIndex());
errorResult.addReplacement(image.getDescriptionReplacement(
(modifiedText != null) ? modifiedText : text,
(modifiedAlt != null) ? modifiedAlt : alt));
errors.add(errorResult);
}
}
// Analyze each external link to see if it has a [ before
for (PageElementExternalLink link : analysis.getExternalLinks()) {
int begin = link.getBeginIndex();
if (link.hasSquare()) {
if ((begin > 0) && (contents.charAt(begin - 1) == '[')) {
int end = link.getEndIndex();
if ((end >= contents.length()) || (contents.charAt(end) != ']')) {
if (errors == null) {
return true;
}
result = true;
CheckErrorResult errorResult = createCheckErrorResult(
analysis, begin - 1, begin);
errorResult.addReplacement("[");
errors.add(errorResult);
}
}
}
}