Skip to content

Commit

Permalink
blockid #81 #83
Browse files Browse the repository at this point in the history
-   feat #83 just add blockid when review new card.
-   fix #81 add multi blockids;
  • Loading branch information
Newdea authored Oct 10, 2024
1 parent 99a54d1 commit 6d8d92b
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 9 deletions.
6 changes: 6 additions & 0 deletions docs/docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
4 changes: 2 additions & 2 deletions src/Question.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
12 changes: 8 additions & 4 deletions src/dataStore/itemTrans.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 {
Expand Down
5 changes: 4 additions & 1 deletion src/generateParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ loose_line
}
annotation
= $("<!--SR:" (!"-->" .)+ "-->")
= $($("<!--SR:" (!"-->" .)+ "-->") / blockid)
nonempty_text_till_newline
= $non_newline+
Expand All @@ -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])
`;
}

0 comments on commit 6d8d92b

Please sign in to comment.