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.51k stars 184 forks source link

[BUG] Cloze Cards require blank lines before and after to create atomic card #450

Open timblaktu opened 2 years ago

timblaktu commented 2 years ago

Describe the bug The cloze cards generated by this plugin for my notes that include ==cloze highlights== include the entire multiline section (paragraph) of notes which is bounded by newlines above and below.

Therefore, to create an atomic/small/one-line cloze card from my inline notes, I have to put line breaks before and after the note for the line containing the ==highlighted cloze(s)==. (From my perspective, #147 is not really fixed, interpreting it literally.)

This "paragraph-only cloze" behavior imposes too much formatting on my notes, requiring my notes to have blank newlines in between all intended clozes, preventing things like a cloze in a middle list element. The situation does not seem to be improved by adding structural markdown formatting, like headings. It appears that the cloze parsing in this plugin assumes a "paragraph" style close by default. I believe this is backwards, because...

Cards for Spaced Repetition are supposed to be concise and short. Source notes used to generate the cards should be free to stay concise as well. It is for these reasons that I seek to use "highlight clozes" as my primary card type, simply annotating vital words and/or phrases in my notes with highlights, and using this plugin[^1] to review them as concise flashcards. I do not plan to use the Basic and Multiline Q & A style in my notes.

To Reproduce

  1. New install of plugin, turn on "Save scheduling comment on the same line..", all else defaults
  2. Put #flashcard tag in a file and add several lines with highlight clozes, including lists, intended to be separate cards, e.g.:
    Blah, Blah, Blah
    ==IPSEC== provides ==Authentication== 
    - only known, trusted ==peers== can connect
    - blah, blah, blah
  3. Spaced Repetition: Review flashcards from all notes
  4. Notice that the 3 cards generated all have the entire "paragraph" surrounding the lines with clozes, as shown below.

The problem here is that the generated cards all include the adjacent lines.

image

Expected behavior I expect each line to be processed as a separate cloze note (producing multiple cards, in Anki parlance).

In the above example, this means each generated card should not include the adjacent "Blah" lines.

Versions (please complete the following information):

** Other Context [^1]: I can do this with Obsidian_to_anki plugin using its "highlights-to-close" setting, and specifying a regex that matches single-line clozes. This actually works fine. I jumped the Obsidian_to_anki ship this morning, after spending an embarrassingly long time trying to get the Cloze Extra field to work using footnote syntax (intrigued by @dummifiedme's suggestion). In fact, that issue and finding this same user's comment elsewhere saying he'd switched to using SR plugin, is why I tried the switch myself.) Alas, I see this plugin doesn't yet support the clozes I envision either (and I see they made the same suggestion in this project)

timblaktu commented 2 years ago

The parsing implementation explains why I'm seeing this built-in "paragraph" behavior for cloze notes. Looking at the card parsing function, I see:

I can see that in this project's cloze tests, the only multiline cloze notes being tested are validating the very behavior I'm complaining about, that is, the tests are making sure that the boundary (the "separator") between cloze cards within a single cloze note, is expected to be an empty line, i.e. \n\n:

    expect(
        parse(
            "some text before\n\na deletion on\nsuch ==wow==\n\n" +
                "many text\nsuch surprise ==wow== more ==text==\nsome text after\n\nHmm",
            ...defaultArgs
        )
    ).toEqual([
        [CardType.Cloze, "a deletion on\nsuch ==wow==", 3],
        [CardType.Cloze, "many text\nsuch surprise ==wow== more ==text==\nsome text after", 6],
    ]);

As stated, I basically want support for "single-line clozes". As an Obsidian_to_anki user, I would be perfectly fine with simply changing clozes to always be single-line, but I understand that this paragraph cloze behavior is out in the wild now and probably shouldn't be changed. So, I'd propose that we let users select which cloze parsing behavior they want, adding an "Inline cloze" setting that would be used to extend the 2 parsing code blocks (for single-line and cloze cards), so that:

Also would be good to better document some of this behavior, so others don't call "features" like this "bugs" like I did. The doc on cloze cards should mention that they must be bounded by empty lines.

Nexcelite-Academy commented 1 month ago

Yes I do have this issue as well!