st3v3nmw / obsidian-spaced-repetition

Fight the forgetting curve by reviewing flashcards & entire notes on Obsidian.md
https://www.stephenmwangi.com/obsidian-spaced-repetition/
MIT License
1.47k stars 183 forks source link

[FEAT] Custom Reading view #770

Open Stefanuk12 opened 11 months ago

Stefanuk12 commented 11 months ago

Is your feature request related to a problem? Please describe. When viewing your flashcards, it can look ugly within your notes - especially when it comes to Anki clozes.

Describe the solution you'd like A custom formatting when in Reading view that would bold, highlight, or something along those lines to indicate a flashcard. This may be customisable.

Additional context View documentation on how to achieve this here.

ronzulu commented 8 months ago

Hi @Stefanuk12

Nice idea!

So you mean instead of seeing something like:

Is binary classification a supervised or unsupervised learning algorithm:: supervised
<!--SR:!2023-11-09,5,250-->
When using a neural network for binary classification, what activation function is needed on the output layer:: Sigmoid
<!--SR:!2023-09-13,15,230-->
Can decision trees be used for binary classification problems:: yes
<!--SR:!2023-09-07,16,270-->

It could be:

image

If we implement this, I'd suggest:

image

Personally I don't use reading mode much, do you use it regularly?

Cheers Ronny

Stefanuk12 commented 8 months ago

Yeah exactly what I was thinking. Since I integrate my notes with my flashcards, this means I read over them in reading mode since that applies custom formatting for things like tables and certain plugins.

LukasMandok commented 3 months ago

Hi, I really like your addon a lot, and I think this feature could further improve it for my use case.

I mostly write notes, that I go over regularly as well. It would be awesome to integrate your flash cards directly into this, to hide away some specifics that I want to repeat. It does not have to be like those highlighted code blocks that are collapsed by default. The best way for me would be, that in read-mode flash cards like these:

question::answer

and

question ? answer

are replaced with a formatted:

question [button to click to show answer]

and in case you press the button or text:

question: answer

So basically like a spoiler-function that just hides the answer. I wouldn't mind as well, if it could be changed in settings to be either that or show the answer in bold next to the question without the :: ? and so on.

ronzulu commented 3 months ago

Unfortunately, reading view is not so easy to implement. I did try a few months ago, but came across the following difficulty:

The hook that obsidian provides registerMarkdownPostProcessor, only gives access to the HTML that can be modified by the plug-in prior to it being rendered.

However, modifying the HTML for this plug-in can only be done within context, i.e. with reference to the source markdown. This leaves the following options (none of which I've pursued):

  1. Post a question on the obsidian developer forum to find out if there is some (perhaps undocumented) mechanism regarding the registerMarkdownPostProcessor callback. Specifically is there some mechanism to relate the current HTML passed to the callback to the source markdown.
  2. Create an algorithm that attempts to perform this correlation. This is a hacky idea, and may not be robust. It would need to cope with other plug-ins earlier in the registerMarkdownPostProcessor callback sequence modifying the HTML.
  3. Some other clever idea.

I'm more than happy for anyone to check my thinking about this.

Cheers Ronny