From 6d8d92b1ca2dbb323ab5fdc60bb3efa033134c26 Mon Sep 17 00:00:00 2001 From: Newdea <9208450+Newdea@users.noreply.github.com> Date: Thu, 10 Oct 2024 22:13:22 +0800 Subject: [PATCH] blockid #81 #83 - feat #83 just add blockid when review new card. - fix #81 add multi blockids; --- docs/docs/changelog.md | 6 ++++++ manifest.json | 2 +- package.json | 2 +- src/Question.ts | 4 ++-- src/dataStore/itemTrans.ts | 12 ++++++++---- src/generateParser.ts | 5 ++++- 6 files changed, 22 insertions(+), 9 deletions(-) diff --git a/docs/docs/changelog.md b/docs/docs/changelog.md index 05f6d1d9..c2fbec29 100644 --- a/docs/docs/changelog.md +++ b/docs/docs/changelog.md @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file. Dates are d Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). + +## [1.12.5.12] + +- feat #83 just add blockid when review new card. +- fix #81 add multi blockids; + ## [1.12.5.11] - feat #78 fsrs v5 setting support enable_short_term and enable_fuzz (by @ishiko732). diff --git a/manifest.json b/manifest.json index 6101c63a..b37d703e 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "obsidian-spaced-repetition-recall", "name": "Spaced Repetition Recall", - "version": "1.12.5.11", + "version": "1.12.5.12", "minAppVersion": "1.2.8", "description": "Fight the forgetting curve by reviewing flashcards & entire notes.", "author": "Newdea", diff --git a/package.json b/package.json index 387a7903..d31060cb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "obsidian-spaced-repetition", - "version": "1.12.5.11", + "version": "1.12.5.12", "description": "Fight the forgetting curve by reviewing flashcards & entire notes.", "main": "main.js", "scripts": { diff --git a/src/Question.ts b/src/Question.ts index 4b491625..32376e84 100644 --- a/src/Question.ts +++ b/src/Question.ts @@ -252,9 +252,9 @@ export class Question { blockId = this.questionText.obsidianBlockId = this.questionText.genBlockId; } if (blockId) { - this.questionText.original += "\n"; - if (this.isCardCommentsOnSameLine(settings)) result += ` ${blockId}\n`; + if (!this.questionText.original.endsWith("```")) result += ` ${blockId}\n`; else result += `\n${blockId}\n`; + this.questionText.original += "\n"; } return result; diff --git a/src/dataStore/itemTrans.ts b/src/dataStore/itemTrans.ts index 8d605273..2a955c19 100644 --- a/src/dataStore/itemTrans.ts +++ b/src/dataStore/itemTrans.ts @@ -166,10 +166,10 @@ export class ItemTrans { let deckname = dtppath?.hasPath ? dtppath.path[0] : topicPath.path[0]; deckname = Tags.isDefaultDackName(deckname) ? deckname : "#" + deckname; store.updateCardItems(trackedFile, cardinfo, count, deckname, false); - updateCardObjs(question.cards, cardinfo, scheduling); + const update = updateCardObjs(question.cards, cardinfo, scheduling); // update question - if (question.questionText.genBlockId) { + if (question.questionText.genBlockId && update) { question.hasChanged = true; } else { question.hasChanged = false; @@ -182,14 +182,18 @@ function updateCardObjs(cards: Card[], cardinfo: CardInfo, scheduling: RegExpMat const schedInfoList: CardScheduleInfo[] = NoteCardScheduleParser.createInfoList_algo(scheduling); const carditemIds = cardinfo.itemIds; + let update = false; for (let i = 0; i < cards.length; i++) { const cardObj = cards[i]; const hasScheduleInfo: boolean = i < schedInfoList.length; const schedule: CardScheduleInfo = schedInfoList[i]; - cardObj.scheduleInfo = - hasScheduleInfo && !schedule.isDummyScheduleForNewCard() ? schedule : null; + const hassched = !schedule.isDummyScheduleForNewCard(); + cardObj.scheduleInfo = hasScheduleInfo && hassched ? schedule : null; cardObj.Id = carditemIds[i]; + + if (hassched) update = true; } + return update; } export function itemToShedNote(item: RepetitionItem, note: TFile): SchedNote { diff --git a/src/generateParser.ts b/src/generateParser.ts index a4dde177..3b5e2014 100644 --- a/src/generateParser.ts +++ b/src/generateParser.ts @@ -248,7 +248,7 @@ loose_line } annotation - = $("" .)+ "-->") + = $($("" .)+ "-->") / blockid) nonempty_text_till_newline = $non_newline+ @@ -271,6 +271,9 @@ nonemptyspace optional_whitespaces = whitespace_char* +blockid +=$([\\^][a-zA-Z0-9-]+) + whitespace_char = ([ \\f\\t\\v\\u0020\\u00a0\\u1680\\u2000-\\u200a\\u2028\\u2029\\u202f\\u205f\\u3000\\ufeff]) `; }