-
Notifications
You must be signed in to change notification settings - Fork 198
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: Detecting inside codeblocks since last update #1072
Comments
Hi @dmantisk thanks for reporting that. There was no intention (AFAIK) to modify this behavior. Likely, there was no pre-existing test case for this condition when Added new option allowing for multiline cards with empty lines #1012 was implemented, and this change wasn't noticed. I know you have included info in the "To Reproduce" section, but it's easiest if you simply include a sample file. Best if you can attach a markdown file (rather than copy and paste). @alberti42 what are your thoughts? Cheers |
This file uses The contents of the file are a normal inline flashcard, one inside fenced codeblock, and one inside inline codeblock. I hope that helps |
Yes, I could reproduce the bugs, found the problem and found (I believe) the solution. In general, if you encounter similar problems in the future, the typical pattern for debugging this is to go in debug mode: You play some flashcards and then check on the console what is produced: In particular, you are interested in copying the content of grammar with right click into There you can test your flash card and understand why and what is not identified. |
I posted the solution with this commit. I checked it passes all tests. It would be good to add some more test cases. This will avoid getting back in this situation in the future if we modify the grammar. |
Thanks, I'm happy to write some additional test cases. |
…menu options (#1066) * Added options in the settings to hide icon and status bar. * - Enabled the possibility to disable file menu options without restarting Obsidian or reloading the plugin. - Changed the phrasing for the user from `Disable` to `Enable` to make it easier to understand and aligned with the other options. * Adjusted the translation in the different languages. * removing unnecessary logs * Fixed bug #1072
…menu options (#1066) * Added options in the settings to hide icon and status bar. * - Enabled the possibility to disable file menu options without restarting Obsidian or reloading the plugin. - Changed the phrasing for the user from `Disable` to `Enable` to make it easier to understand and aligned with the other options. * Adjusted the translation in the different languages. * removing unnecessary logs * Fixed bug #1072
This PR: 1. Adds test cases for parsing {{curly}} clozes 2. Fixes #1072 - Ignore 'cards' in ```block`` & `inline` codeblocks - Adds test cases for both 3. Fixes #1077 - When all the cloze options aren't being used, `cloze_rules` in `parser.ts` becomes empty which leads to the empty grammar rule `cloze_text` which prevents the grammar from being generated. This change adds a tombstone \0 to address this. - Adds test cases for this
This PR: 1. Adds test cases for parsing {{curly}} clozes 2. Fixes #1072 - Ignore 'cards' in ```block`` & `inline` codeblocks - Adds test cases for both 3. Fixes #1077 - When all the cloze options aren't being used, `cloze_rules` in `parser.ts` becomes empty which leads to the empty grammar rule `cloze_text` which prevents the grammar from being generated. This change adds a tombstone \0 to address this. - Adds test cases for this
I've added some extra test cases in #1081 & also updated the parser to prevent detection of cards in |
This PR: 1. Adds test cases for parsing {{curly}} clozes 2. Fixes #1072 - Ignore 'cards' in ```block`` & `inline` codeblocks - Adds test cases for both 3. Fixes #1077 - When all the cloze options aren't being used, `cloze_rules` in `parser.ts` becomes empty which leads to the empty grammar rule `cloze_text` which prevents the grammar from being generated. This change adds a tombstone \0 to address this. - Adds test cases for this
@st3v3nmw |
I don't understand your changes. Was there any reason to modify my suggestion? Did you see some cases where it failed? Why did you need the To be more specific, I am confused why you changed:
The syntax I think this is exactly what you want to happen. If you want to detect something like:
you advance character by character, and then if you find an inline code before Note that the order So, I would like to hear your thoughts why you did the changes on my code, before I go through detailed debugging of your grammar. |
Ok, I think I now understand the Instead, let me know your thoughts on the rest that I posted above. |
I also understood that my changes before did not fix the case of inline code in clozes. They only handled the multiline cards. Thanks spotting it the remaining problem. However, I am not sure your solution is the best. I will make a suggestion. |
@alberti42, thanks!
Yes, the failing cases were when it detected cloze cards inside inline code blocks when the respective cloze options (
Per your fix, it doesn't pick up cards inside the ``` codeblocks.
Yes, that was a hack to not detect clozes when the cloze options are all off. The errors being thrown looked like this because
Of course, a more elegant solution would be better 😄. In the meantime, I'll add a comment in the code.
I was trying to prevent it from picking up "cards" inside inline code. Like the examples above. I'll revert the change & figure out a better way to handle that.
I hadn't considered this case. I've added it to the test cases which is now failing due to my change 😭. |
This PR: 1. Adds test cases for parsing {{curly}} clozes 2. Fixes #1072 - Ignore 'cards' in ```block`` & `inline` codeblocks - Adds test cases for both 3. Fixes #1077 - When all the cloze options aren't being used, `cloze_rules` in `parser.ts` becomes empty which leads to the empty grammar rule `cloze_text` which prevents the grammar from being generated. This change adds a tombstone \0 to address this. - Adds test cases for this
… not properly hanlded by clozes - Fixed a new issue related to the case when the user provides empty markers for the inline and multiline cards. With the new version, the rule is disabled when the marker is empty.
I made a new version that hopefully fixes the problem you found and also fix a new problem, see the comment to the commit. Thank you for the explanation! When you posted it, I had already code the version in the commit above. So, I think it is worth you test it. I could not run anymore the tests. When I run:
it says that you now moved to
still works for me. |
I did not understand your comment:
In my view, if flashcard markers appear inside a codeblock, these should be ignored. However, I think we should definitly allow the user to have codeblocks in both the question and answer, but the content inside should not have any influence on what cards are shown, it is just a codeblock. |
I've added test cases for this.
# install dependencies
pnpm i
# run tests
pnpm run tests
# build
pnpm run build
Yes, this is what I meant. We're ignoring markers inside the codeblocks but allowing users to have codeblocks in their Qns & Answers. |
@alberti42, I've ran the tests with the new test cases and they all pass (#1081). I haven't modified the grammar so I think it's okay to make a release now. Thank you for the fixes & quick response. |
@dmantisk, please try the new release (v1.12.7) and let us know if it fixes the issue for you. |
I can confirm that the issue is fixed. Flashcard indicators inside both inline and fenced code blocks are no linger being picked up. |
…menu options (st3v3nmw#1066) * Added options in the settings to hide icon and status bar. * - Enabled the possibility to disable file menu options without restarting Obsidian or reloading the plugin. - Changed the phrasing for the user from `Disable` to `Enable` to make it easier to understand and aligned with the other options. * Adjusted the translation in the different languages. * removing unnecessary logs * Fixed bug st3v3nmw#1072
* fix: parsing code blocks & custom separators This PR: 1. Adds test cases for parsing {{curly}} clozes 2. Fixes st3v3nmw#1072 - Ignore 'cards' in ```block`` & `inline` codeblocks - Adds test cases for both 3. Fixes st3v3nmw#1077 - When all the cloze options aren't being used, `cloze_rules` in `parser.ts` becomes empty which leads to the empty grammar rule `cloze_text` which prevents the grammar from being generated. This change adds a tombstone \0 to address this. - Adds test cases for this * Fixed inline code in clozes * - Fixed issue raised at st3v3nmw#1072 (comment) where inline code was not properly hanlded by clozes - Fixed a new issue related to the case when the user provides empty markers for the inline and multiline cards. With the new version, the rule is disabled when the marker is empty. * add parser test case * add more parser test cases --------- Co-authored-by: Andrea Alberti <a.alberti82@gmail.com>
Describe the bug
After the last update the both the inline and multi line flashcard indicators are being detected.
Using default or custom indicators doesn't seem to matter.
Is this intended behavior?
If so I'll just switch the indicators to something else.
To Reproduce
Expected behavior
The indicators not being detected inside codeblocks
Screenshots
No response
OS of your device
Win10
Obsidian version
1.6.7
Plugin version
1.12.6
Installer version
1.6.5
Additional context
No response
Config file
No response
The text was updated successfully, but these errors were encountered: