diff --git a/src/main/java/de/tum/cit/aet/artemis/exercise/service/ExerciseWithSubmissionsExportService.java b/src/main/java/de/tum/cit/aet/artemis/exercise/service/ExerciseWithSubmissionsExportService.java
index 1ccd03d928fc..381591ecdb85 100644
--- a/src/main/java/de/tum/cit/aet/artemis/exercise/service/ExerciseWithSubmissionsExportService.java
+++ b/src/main/java/de/tum/cit/aet/artemis/exercise/service/ExerciseWithSubmissionsExportService.java
@@ -43,6 +43,8 @@ public abstract class ExerciseWithSubmissionsExportService {
private static final String EMBEDDED_FILE_MARKDOWN_SYNTAX_REGEX = "\\[.*] *\\(/api/files/markdown/.*\\)";
+ private static final String EMBEDDED_FILE_MARKDOWN_WITH_HOVERTEXT = "\\(/api/files/markdown/.* \".*\"\\)";
+
private static final String EMBEDDED_FILE_HTML_SYNTAX_REGEX = "";
private static final String API_MARKDOWN_FILE_PATH = "/api/files/markdown/";
@@ -129,7 +131,15 @@ private void copyFilesEmbeddedWithMarkdownSyntax(Exercise exercise, List
for (String embeddedFile : embeddedFilesWithMarkdownSyntax) {
// avoid matching other closing ] or () in the squared brackets by getting the index of the last ]
String lastPartOfMatchedString = embeddedFile.substring(embeddedFile.lastIndexOf("]") + 1);
- String filePath = lastPartOfMatchedString.substring(lastPartOfMatchedString.indexOf("(") + 1, lastPartOfMatchedString.indexOf(")"));
+ String filePath;
+
+ if (Pattern.compile(EMBEDDED_FILE_MARKDOWN_WITH_HOVERTEXT).matcher(lastPartOfMatchedString).matches()) {
+ filePath = lastPartOfMatchedString.substring(lastPartOfMatchedString.indexOf("(") + 1, lastPartOfMatchedString.indexOf(" "));
+ }
+ else {
+ filePath = lastPartOfMatchedString.substring(lastPartOfMatchedString.indexOf("(") + 1, lastPartOfMatchedString.indexOf(")"));
+ }
+
constructFilenameAndCopyFile(exercise, exportErrors, embeddedFilesDir, filePath);
}
}