diff --git a/CHANGELOG.md b/CHANGELOG.md index 1bed66b3..1cc39a66 120000 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1 +1 @@ -docs/changelog.md \ No newline at end of file +docs/changelog.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 651dc17d..9815d5bd 120000 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1 +1 @@ -docs/en/contributing.md \ No newline at end of file +docs/en/contributing.md diff --git a/src/NoteQuestionParser.ts b/src/NoteQuestionParser.ts index 6e75945e..f5f197c5 100644 --- a/src/NoteQuestionParser.ts +++ b/src/NoteQuestionParser.ts @@ -188,7 +188,7 @@ export class NoteQuestionParser { let frontmatterLineCount: number = null; if (filteredTagCacheList.length > 0) { // To simplify analysis, ensure that the supplied list is ordered by line number - tagCacheList.sort((a, b) => a.position.start.line - b.position.start.line); + filteredTagCacheList.sort((a, b) => a.position.start.line - b.position.start.line); // Treat the frontmatter slightly differently (all tags grouped together even if on separate lines) const [frontmatter, _] = extractFrontmatter(this.noteText); @@ -200,7 +200,7 @@ export class NoteQuestionParser { // Doesn't matter what line number we specify, as long as it's less than frontmatterLineCount if (frontmatterTagCacheList.length > 0) - frontmatterTopicPathList = this.createTopicPathList(tagCacheList, 0); + frontmatterTopicPathList = this.createTopicPathList(frontmatterTagCacheList, 0); } } // diff --git a/tests/unit/NoteQuestionParser.test.ts b/tests/unit/NoteQuestionParser.test.ts index ca00c23f..eb63a9be 100644 --- a/tests/unit/NoteQuestionParser.test.ts +++ b/tests/unit/NoteQuestionParser.test.ts @@ -111,6 +111,57 @@ A::B await parserWithDefaultSettings.createQuestionList(noteFile, folderTopicPath, true), ).toMatchObject(expected); }); + + test("SingleLineBasic: Multiple topics", async () => { + let noteText: string = `#flashcards/science #flashcards/poetry +A::B + `; + let noteFile: ISRFile = new UnitTestSRFile(noteText); + + let folderTopicPath: TopicPath = TopicPath.emptyPath; + let expected = [ + { + questionType: CardType.SingleLineBasic, + topicPathList: TopicPathList.fromPsv("#flashcards/science|#flashcards/poetry", 0), + questionText: { + original: `A::B`, + actualQuestion: "A::B", + }, + }, + ]; + expect( + await parserWithDefaultSettings.createQuestionList(noteFile, folderTopicPath, true), + ).toMatchObject(expected); + }); + + // https://github.com/st3v3nmw/obsidian-spaced-repetition/issues/908 + test("SingleLineBasic: Multiple tags in note (including non-flashcard ones)", async () => { + let noteText: string = `--- +created: 2024-03-11 10:41 +tags: + - flashcards + - data-structure +--- +#2024/03-11 + +**What is a Heap?** +? +In computer-science, a *heap* is a tree-based data-structure, that satisfies the *heap property*. A heap is a complete *binary-tree*! + `; + let noteFile: ISRFile = new UnitTestSRFile(noteText); + + let folderTopicPath: TopicPath = TopicPath.emptyPath; + let expected = [ + { + questionType: CardType.MultiLineBasic, + // Explicitly checking that #data-structure and #2024/03-11 are not included + topicPathList: TopicPathList.fromPsv("#flashcards", 0), + }, + ]; + expect( + await parserWithDefaultSettings.createQuestionList(noteFile, folderTopicPath, true), + ).toMatchObject(expected); + }); }); describe("Single question in the text (with block identifier)", () => {