From 46100154859748895ce060ff186c0d4cac8a72a4 Mon Sep 17 00:00:00 2001 From: debanjandhar12 <49021233+debanjandhar12@users.noreply.github.com> Date: Wed, 18 Aug 2021 19:21:05 +0530 Subject: [PATCH] Fixed several rendering bugs + Bumped version --- README.md | 2 -- manifest.json | 2 +- src/basicblock.ts | 3 ++- src/block.ts | 3 ++- src/clozeblock.ts | 3 ++- src/main.ts | 4 +++- src/replaceblock.ts | 3 ++- 7 files changed, 12 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 69590e2..7341767 100644 --- a/README.md +++ b/README.md @@ -4,8 +4,6 @@ This plugin allow you to make flashcards in [Obsidian](https://obsidian.md/) and This is similar to [Obsidian_to_Anki](https://github.com/Pseudonium/Obsidian_to_Anki) except this plugin uses a different and more powerful markup based syntax for making flashcards. -**NB: Please do not use this in your main vault or main anki account until 0.5.0 is released (by 15-06-21).** - ## Installation 1. Download `main.js` and `manifest.json` from [releases](https://github.com/debanjandhar12/Obsidian-Anki-Sync/releases) and put it in a new folder in your obsidian plugin folder. diff --git a/manifest.json b/manifest.json index 3d9fa20..7ecdfd8 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "ObsidianAnkiSync", "name": "Obsidian Anki Sync", - "version": "0.4.1", + "version": "0.9.0", "description": "Obsidian plugin to make flashcards and sync them to Anki.", "author": "debanjandhar12", "authorUrl": "https://github.com/debanjandhar12", diff --git a/src/basicblock.ts b/src/basicblock.ts index 3877e2d..d4cd9e7 100644 --- a/src/basicblock.ts +++ b/src/basicblock.ts @@ -95,7 +95,8 @@ export class BasicBlock extends Block { breaks: false, typographer: false, }); - + md.inline.ruler.disable(['sub','sup','ins']); + md.block.ruler.disable(['code']); anki = md.render(anki); return anki; diff --git a/src/block.ts b/src/block.ts index 532a185..ec1068d 100644 --- a/src/block.ts +++ b/src/block.ts @@ -39,11 +39,12 @@ export abstract class Block { let modified = this.original.replace(BlockStartCommentRegExp, function (match): string { return insertAttrib(match, 'oid', oid); }); + modified = modified.replaceAll("$", "$$$$"); // Bug Fix: https://stackoverflow.com/questions/9423722/string-replace-weird-behavior-when-using-dollar-sign-as-replacement // Read and modify the file with addition of id in obsidian let fileContent = await this.vault.read(this.file); fileContent = fileContent.replace(this.original, modified); - this.vault.modify(this.file, fileContent) + this.vault.modify(this.file, fileContent); } async getAnkiId(): Promise { diff --git a/src/clozeblock.ts b/src/clozeblock.ts index 9cc04b3..89763a9 100644 --- a/src/clozeblock.ts +++ b/src/clozeblock.ts @@ -79,7 +79,8 @@ export class ClozeBlock extends Block { breaks: false, typographer: false, }); - + md.inline.ruler.disable(['sub','sup','ins']); + md.block.ruler.disable(['code']); anki = md.render(anki); return anki; diff --git a/src/main.ts b/src/main.ts index 9b7da98..2d798f3 100644 --- a/src/main.ts +++ b/src/main.ts @@ -95,6 +95,7 @@ export default class MyPlugin extends Plugin { blockIds.push(await block.getAnkiId()); console.log("Recognized Block's AnkiId:", blockIds); // Get Anki Notes and their ids + await AnkiConnect.invoke("reloadCollection", {}); let q = await AnkiConnect.query(`tag:${this.app.vault.getName().replace(/\s/g, "_")} note:ObsidianAnkiSyncModel tag:ObsidianAnkiSync`) let ankiIds:number[] = q.map(i=>parseInt(i)); console.log("Anki Notes created by App:", ankiIds); @@ -108,7 +109,8 @@ export default class MyPlugin extends Plugin { } // -- Update Anki and show results -- - AnkiConnect.invoke("reloadCollection", {}); + await AnkiConnect.invoke("removeEmptyNotes", {}); + await AnkiConnect.invoke("reloadCollection", {}); new Notice(`Sync Completed! \nCreated Blocks:${created} Updated Blocks:${updated} Deleted Blocks:${deleted}`, 3000); console.log(`Sync Completed! Created Blocks:${created} Updated Blocks:${updated} Deleted Blocks:${deleted}`); } diff --git a/src/replaceblock.ts b/src/replaceblock.ts index 2141a77..672f215 100644 --- a/src/replaceblock.ts +++ b/src/replaceblock.ts @@ -100,7 +100,8 @@ export class ReplaceBlock extends Block { breaks: false, typographer: false, }); - + md.inline.ruler.disable(['sub','sup','ins']); + md.block.ruler.disable(['code']); anki = md.render(anki); return anki;