MoinMoinAttachmentConverter: Fix handling of attachments or inline images with
an alt text (text after the pipe symbol in the attachment link).
diff --git a/src/main/java/com/atlassian/uwc/converters/moinmoin/MoinMoinAttachmentConverter.java b/src/main/java/com/atlassian/uwc/converters/moinmoin/MoinMoinAttachmentConverter.java
index 0a3b3b7..817e6cf 100644
--- a/src/main/java/com/atlassian/uwc/converters/moinmoin/MoinMoinAttachmentConverter.java
+++ b/src/main/java/com/atlassian/uwc/converters/moinmoin/MoinMoinAttachmentConverter.java
@@ -126,8 +126,10 @@
Pattern attachment = Pattern.compile("([{\\[])"+
"\\1?" +
"(?:(?:attachment)|(?:inline)):"+
- "([^}\\]]+)" +
- "([}\\]])\\3?");
+ "([^}\\]\\|]+)" +
+ // Potentially the target is followed by | and an "alt" text
+ "(?:\\|([^}\\]]+))?" +
+ "([}\\]])\\4?");
Pattern pagedelim = Pattern.compile("\\/([^/]*)");
private String convertAttachments(String input, Page page) {
@@ -138,6 +140,7 @@
found = true;
String type = attachmentFinder.group(1);
String target = attachmentFinder.group(2);
+ String altText = attachmentFinder.group(3);
String replacement = "";
Matcher pagedelimfinder = pagedelim.matcher(target);
boolean haspagename = false;
@@ -148,6 +151,9 @@
haspagename = true;
}
if (type.startsWith("{")) { //inline
+ if (altText != null && !altText.isEmpty()) {
+ target = target + "|alt=" + altText + " title=" + altText;
+ }
replacement = "!" + target + "!";
}
else { //link