Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Programming exercises: Fix image export in combination with tooltip text #10070

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "<img src=\"/api/files/markdown/.*\".*>";

private static final String API_MARKDOWN_FILE_PATH = "/api/files/markdown/";
Expand Down Expand Up @@ -129,7 +131,15 @@ private void copyFilesEmbeddedWithMarkdownSyntax(Exercise exercise, List<String>
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(")"));
}

badkeyy marked this conversation as resolved.
Show resolved Hide resolved
constructFilenameAndCopyFile(exercise, exportErrors, embeddedFilesDir, filePath);
}
}
Expand Down
Loading