Skip to content

Commit 6658797

Browse files
authored
fix: cloze patterns settings upgrade (#1126)
1 parent 4f24409 commit 6658797

File tree

9 files changed

+33
-28
lines changed

9 files changed

+33
-28
lines changed

docs/docs/changelog.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,16 @@ All notable changes to this project will be documented in this file. Dates are d
44

55
Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
66

7+
#### [1.13.1](https://github.com/st3v3nmw/obsidian-spaced-repetition/compare/1.13.0...1.13.1)
8+
9+
- docs: update README links [`#1120`](https://github.com/st3v3nmw/obsidian-spaced-repetition/pull/1120)
10+
- fix: cloze patterns settings upgrade [`b765abc`](https://github.com/st3v3nmw/obsidian-spaced-repetition/commit/b765abc6de9377761098ebf6c4295fe3795bc04e)
11+
712
#### [1.13.0](https://github.com/st3v3nmw/obsidian-spaced-repetition/compare/1.12.9...1.13.0)
813

14+
> 13 October 2024
15+
16+
- chore: bump version to v1.13.0 [`#1119`](https://github.com/st3v3nmw/obsidian-spaced-repetition/pull/1119)
917
- docs: document custom cloze patterns [`#1118`](https://github.com/st3v3nmw/obsidian-spaced-repetition/pull/1118)
1018
- refactor: parser & cloze patterns [`#1117`](https://github.com/st3v3nmw/obsidian-spaced-repetition/pull/1117)
1119
- fix(ui): render markdown content for questions in nested lists [`#1114`](https://github.com/st3v3nmw/obsidian-spaced-repetition/pull/1114)

docs/docs/en/flashcards/cloze-cards.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -140,16 +140,21 @@ Brackets `[]` delineate where the sequence number and hint will be placed, along
140140

141141
Here are some examples of custom patterns:
142142

143-
| Explanation | Pattern in the Settings | Simplified Cloze Usage | Numbered Cloze Usage | Generalized Cloze Overlapping Usage |
144-
| ------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------- | ------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------- |
145-
| Anki-Like Pattern | `{{[123::]answer[::hint]}}` | `Brazilians speak {{Portuguese}}`<br><br>Or, with hint:<br>`Brazilians speak {{Portuguese::language}}` | `Brazilians speak {{1::Portuguese}}`<br><br>Or, with hint:<br>`Brazilians speak {{1::Portuguese::language}}` | `Brazilians speak {{a::Portuguese}}`<br><br>Or, with hint:<br>`Brazilians speak {{a::Portuguese::language}}` |
146-
| Highlighted pattern with hint and sequencer in footnotes. <br/><br/> **Note that you can use brackets as part of your pattern, but you need to escape them.** | `==answer==[^\\[hint\\]][\\[^123\\]]` | `Brazilians speak ==Portuguese==`<br><br>Or, with hint:<br>`Brazilians speak ==Portuguese==^[language]` | `Brazilians speak ==Portuguese==[^1]`<br><br>Or, with hint:<br>`Brazilians speak ==Portuguese==^[language][^1]` | `Brazilians speak ==Portuguese==[^a]`<br><br>Or, with hint:<br>`Brazilians speak ==Portuguese==^[language][^a]` |
143+
| Explanation | Pattern in the Settings | Simplified Cloze Usage | Numbered Cloze Usage | Generalized Cloze Overlapping Usage |
144+
| --------------------------------------------------------- | ------------------------------------- | ------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------- |
145+
| Anki-Like Pattern | `{{[123::]answer[::hint]}}` | `Brazilians speak {{Portuguese}}`<br><br>Or, with hint:<br>`Brazilians speak {{Portuguese::language}}` | `Brazilians speak {{1::Portuguese}}`<br><br>Or, with hint:<br>`Brazilians speak {{1::Portuguese::language}}` | `Brazilians speak {{a::Portuguese}}`<br><br>Or, with hint:<br>`Brazilians speak {{a::Portuguese::language}}` |
146+
| Highlighted pattern with hint and sequencer in footnotes. | `==answer==[^\\[hint\\]][\\[^123\\]]` | `Brazilians speak ==Portuguese==`<br><br>Or, with hint:<br>`Brazilians speak ==Portuguese==^[language]` | `Brazilians speak ==Portuguese==[^1]`<br><br>Or, with hint:<br>`Brazilians speak ==Portuguese==^[language][^1]` | `Brazilians speak ==Portuguese==[^a]`<br><br>Or, with hint:<br>`Brazilians speak ==Portuguese==^[language][^a]` |
147147

148148
!!! warning
149149

150-
Make sure that your custom cloze patterns do not conflict with other flashcard separators.
150+
Make sure that your custom cloze patterns do not conflict with other flashcard separators.<br/>
151151
For instance, the Anki-Like pattern `{{[123::]answer[::hint]}}` conflicts with the default single line flashcard separator `::`.
152152

153+
!!! warning
154+
155+
You can use brackets as part of your pattern, but you need to [escape](https://en.wikipedia.org/wiki/Escape_character) them with `\\`.<br/>
156+
For instance, in the pattern `==answer==[^\\[hint\\]][\\[^123\\]]`, the brackets _inside_ the outer brackets are escaped (`^\\[hint\\]` & `\\[^123\\]`).
157+
153158
In your settings, you can add multiple patterns at once, separating them with a new line:
154159

155160
```

docs/docs/en/resources.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333
This was introduced [here](https://github.com/st3v3nmw/obsidian-spaced-repetition/issues/15) by `@aviskase`.
3434

35-
### Brief summary
35+
#### Brief summary
3636

3737
Andy Matuschak uses [spaced repetition system for working on writing inbox](https://notes.andymatuschak.org/z7iCjRziX6V6unNWL81yc2dJicpRw2Cpp9MfQ).
3838

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"id": "obsidian-spaced-repetition",
33
"name": "Spaced Repetition",
4-
"version": "1.13.0",
4+
"version": "1.13.1",
55
"minAppVersion": "1.2.8",
66
"description": "Fight the forgetting curve by reviewing flashcards & entire notes.",
77
"author": "Stephen Mwangi",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "obsidian-spaced-repetition",
3-
"version": "1.13.0",
3+
"version": "1.13.1",
44
"description": "Fight the forgetting curve by reviewing flashcards & entire notes.",
55
"main": "main.js",
66
"scripts": {

src/lang/locale/ar.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ export default {
112112
"Randomly (once all cards in previous deck reviewed)",
113113
REVIEW_DECK_ORDER_RANDOM_DECK_AND_CARD: "Random card from random deck",
114114
DISABLE_CLOZE_CARDS: "؟cloze تعطيل بطاقات",
115-
CONVERT_HIGHLIGHTS_TO_CLOZES: "Convert ==hightlights== to clozes?",
115+
CONVERT_HIGHLIGHTS_TO_CLOZES: "Convert ==highlights== to clozes?",
116116
CONVERT_BOLD_TEXT_TO_CLOZES: "Convert **bolded text** to clozes?",
117117
CONVERT_CURLY_BRACKETS_TO_CLOZES: "Convert {{curly brackets}} to clozes?",
118118
CLOZE_PATTERNS: "Cloze Patterns",

src/lang/locale/en.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ export default {
115115
"Randomly (once all cards in previous deck reviewed)",
116116
REVIEW_DECK_ORDER_RANDOM_DECK_AND_CARD: "Random card from random deck",
117117
DISABLE_CLOZE_CARDS: "Disable cloze cards?",
118-
CONVERT_HIGHLIGHTS_TO_CLOZES: "Convert ==hightlights== to clozes?",
118+
CONVERT_HIGHLIGHTS_TO_CLOZES: "Convert ==highlights== to clozes?",
119119
CONVERT_BOLD_TEXT_TO_CLOZES: "Convert **bolded text** to clozes?",
120120
CONVERT_CURLY_BRACKETS_TO_CLOZES: "Convert {{curly brackets}} to clozes?",
121121
CLOZE_PATTERNS: "Cloze Patterns",

src/lang/locale/ko.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ export default {
116116
"Randomly (once all cards in previous deck reviewed)",
117117
REVIEW_DECK_ORDER_RANDOM_DECK_AND_CARD: "Random card from random deck",
118118
DISABLE_CLOZE_CARDS: "빈 칸 채우기 카드를 비활성화하시겠습니까?",
119-
CONVERT_HIGHLIGHTS_TO_CLOZES: "==hightlights== 를 빈 칸 채우기로 전환하시겠습니까?",
119+
CONVERT_HIGHLIGHTS_TO_CLOZES: "==highlights== 를 빈 칸 채우기로 전환하시겠습니까?",
120120
CONVERT_BOLD_TEXT_TO_CLOZES: "**bolded text** 를 빈 칸 채우기로 전환하시겠습니까?",
121121
CONVERT_CURLY_BRACKETS_TO_CLOZES: "{{curly brackets}} 를 빈 칸 채우기로 전환하시겠습니까?",
122122
CLOZE_PATTERNS: "빈 칸 채우기 패턴",

src/settings.ts

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -134,25 +134,17 @@ export function upgradeSettings(settings: SRSettings) {
134134
settings.randomizeCardOrder = null;
135135
}
136136

137-
if (
138-
settings.convertHighlightsToClozes &&
139-
!settings.clozePatterns.contains("==[123;;]answer[;;hint]==")
140-
) {
141-
settings.clozePatterns.push("==[123;;]answer[;;hint]==");
142-
}
137+
if (settings.clozePatterns == null) {
138+
settings.clozePatterns = [];
143139

144-
if (
145-
settings.convertBoldTextToClozes &&
146-
!settings.clozePatterns.contains("**[123;;]answer[;;hint]**")
147-
) {
148-
settings.clozePatterns.push("**[123;;]answer[;;hint]**");
149-
}
140+
if (settings.convertHighlightsToClozes)
141+
settings.clozePatterns.push("==[123;;]answer[;;hint]==");
150142

151-
if (
152-
settings.convertCurlyBracketsToClozes &&
153-
!settings.clozePatterns.contains("{{[123;;]answer[;;hint]}}")
154-
) {
155-
settings.clozePatterns.push("{{[123;;]answer[;;hint]}}");
143+
if (settings.convertBoldTextToClozes)
144+
settings.clozePatterns.push("**[123;;]answer[;;hint]**");
145+
146+
if (settings.convertCurlyBracketsToClozes)
147+
settings.clozePatterns.push("{{[123;;]answer[;;hint]}}");
156148
}
157149
}
158150

0 commit comments

Comments
 (0)