st3v3nmw / obsidian-spaced-repetition

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

[FEAT] #956

Open rikugo1 opened 6 months ago

rikugo1 commented 6 months ago

Issue When a card is included within a bullet point that is indented, the front side of the card is rendered as a code block, which prevents rendering of formatting and LaTeX. It also shows up with a "copy" button underneath, which I assume is intended for debugging when something isn't rendered as expected.

Solution Ideally, the plugin would recognize that the card begins after the bullet point, or at least ignore any initial whitespace.

Example

Screenshot 2024-05-14 at 6 11 28 AM
ronzulu commented 6 months ago

Hi @rikugo1 could you please post your actual markdown file.

(Attach the file, don't copy/paste the text)

Cheers Ronny

rikugo1 commented 6 months ago

Sure thing, thanks!

Calculus Fundamentals.md

dengrish commented 6 months ago

There is a related issue.

When a card has a bullet point that is indented followed by text that is not indented, that text is also shown as indented although it should not be. Here is an example:

Actual text formatting:

Not indented text

Text formatting as shown during review:

ronzulu commented 5 months ago

Hi @rikugo1

Thanks for posting the file. The reason why this issue is happening is because of an Obsidian characteristic:

https://help.obsidian.md/Editing+and+formatting/Basic+formatting+syntax#Code+blocks

[!QUOTE] You can also create a code block by indenting the text using Tab or 4 blank spaces.

I don't think that the plugin can simply strip the leading whitespace before having the Obsidian library render it. From memory, that caused issue in some use cases.

ronzulu commented 5 months ago

Hi @dengrish could you please post your actual markdown file.

(Attach the file, don't copy/paste the text)

Cheers Ronny

dengrish commented 5 months ago

test_note.md

A markdown file is attached. Thanks!

4Source commented 5 months ago

I did a bit of a research of this those problems there are not really related but that's not the case. Original issues is cause because of the initial spaced/tab the MarkdownRender interpreted it as code block. this is easy to fix just include a trim to the string and we should be fine. image But while testing this cause any problems for other supported flashcards I tested the code block and the result looks off image I have undone the change to check it was working before but it wasn't @ronzulu did you know, at some point the code block got rendered correctly or was this just me thinking it was working correctly. With working correctly I mean image the copy button is at same position as in obsidian note.

4Source commented 5 months ago

test_note.md

A markdown file is attached. Thanks!

I think this is a problem with the Obsidian MarkdownRenderer it is somehow ignoring the \n after - indented not sure we are passing wrong formatting or this is a bug of obsidian api.

4Source commented 5 months ago

I think this is a problem with the Obsidian MarkdownRenderer it is somehow ignoring the \n after - indented not sure we are passing wrong formatting or this is a bug of obsidian api.

Ok I checked this it is not a bug of the api it is the expected behavior if you switch to the reading mode in obsidian you can see the same behavior and the render does the same. Live preview: image Reading: image

But I have seen there is a related issue #909 maybe the issue of this is fixable by trick the renderer and make him think it is a list there indents are possible and make the list points invisible but not sure how easy this is and possible cause issues

ronzulu commented 5 months ago

Hi @4Source

I have undone the change to check it was working before but it wasn't @ronzulu did you know, at some point the code block got rendered correctly or was this just me thinking it was working correctly. With working correctly I mean

Not sure. I didn't change any of that code, so the behavior likely has been the same for 9+ months.

4Source commented 5 months ago

Ok but I think we should fix the copy button of the code block

polyipseity commented 4 months ago

Same issue. This might be fixable if flashcards in list item are treated specially and other cases are left unchanged.

4Source commented 4 months ago

Same issue. This might be fixable if flashcards in list item are treated specially and other cases are left unchanged.

The problem here is that the html is generated by function of obsidian the result is difficult to edit because the not indented line is in same list item as the above list item image

The only option I could imagine is to modify the input text for the render function add additional \n after a end of list this would result in here expected outcome. This brings its own difficulties, especially the exact detection of list endings without affecting other texts.

Question
?
not indented
- indented 
- indented2
<!-- new line here -->
should not be indented but is indented

image

But if someone expect the outcome is like in the reading view there is no option for them to achieve this if the text is internally modified. In my opinion we need a different solution.