Skip to content

Commit

Permalink
add more e2e test
Browse files Browse the repository at this point in the history
  • Loading branch information
TSFuSoon committed Jan 10, 2025
1 parent f3248e7 commit 10d54e2
Showing 1 changed file with 21 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,27 +105,27 @@ private boolean isHiddenFile(String entryName) {
private void processEntry(ZipEntry entry, Notebook notebook, ZipInputStream zipIn)
throws IOException {
if (!entry.getName().endsWith(".md")) {
return;
return;
}

Note currentParent = notebook.getHeadNote();
String[] pathParts = entry.getName().split("/");

boolean isIndexFile = pathParts[pathParts.length - 1].equals("__index.md");
int lastPartIndex = isIndexFile ? pathParts.length - 2 : pathParts.length - 1;

for (int i = 0; i < lastPartIndex; i++) {
String part = pathParts[i];
if (shouldSkipPart(part)) {
continue;
}
currentParent = processNotePart(currentParent, part, entry, zipIn, false);
String part = pathParts[i];
if (shouldSkipPart(part)) {
continue;
}
currentParent = processNotePart(currentParent, part, entry, zipIn, false);
}

if (!isIndexFile) {
String lastPart = pathParts[lastPartIndex];
String noteName = removeMarkdownExtension(lastPart);
processNotePart(currentParent, noteName, entry, zipIn, true);
String lastPart = pathParts[lastPartIndex];
String noteName = removeMarkdownExtension(lastPart);
processNotePart(currentParent, noteName, entry, zipIn, true);
}
}

Expand Down Expand Up @@ -164,21 +164,21 @@ private Note findExistingNote(Note parent, String noteName) {

private void addContentToNote(Note note, ZipInputStream zipIn) throws IOException {
String content = new String(zipIn.readAllBytes());

String[] parts = content.split("---", 3);
if (parts.length == 3) {
String frontmatter = parts[1].trim();

String markdownContent = parts[2].trim();
if (markdownContent.startsWith("# ")) {
int nextLineIndex = markdownContent.indexOf('\n');
if (nextLineIndex != -1) {
markdownContent = markdownContent.substring(nextLineIndex).trim();
}
String frontmatter = parts[1].trim();

String markdownContent = parts[2].trim();
if (markdownContent.startsWith("# ")) {
int nextLineIndex = markdownContent.indexOf('\n');
if (nextLineIndex != -1) {
markdownContent = markdownContent.substring(nextLineIndex).trim();
}
note.prependDescription(markdownContent);
}
note.prependDescription(markdownContent);
} else {
note.prependDescription(content);
note.prependDescription(content);
}
modelFactoryService.save(note);
}
Expand Down

0 comments on commit 10d54e2

Please sign in to comment.