mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 14:02:21 -04:00
Add a warning when there is a cloze in "back extra" and "text" is empty (#3912)
* Add a warning when there is a cloze in "back extra" and "text" is empty Fix #3909 * Disallow non-blank first field card * Fix Rust ninja check
This commit is contained in:
parent
e546c6d11f
commit
1fa99c97e4
2 changed files with 17 additions and 14 deletions
|
@ -219,6 +219,7 @@ Jakub Fidler <jakub.fidler@protonmail.com>
|
|||
Valerie Enfys <val@unidentified.systems>
|
||||
Julien Chol <https://github.com/chel-ou>
|
||||
ikkz <ylei.mk@gmail.com>
|
||||
rreemmii-dev <https://github.com/rreemmii-dev>
|
||||
|
||||
********************
|
||||
|
||||
|
|
|
@ -594,27 +594,29 @@ impl Collection {
|
|||
/// notetypes, check if there is a cloze in a non-cloze field or if there's
|
||||
/// no cloze at all. For other notetypes, just check if there's a cloze.
|
||||
pub fn note_fields_check(&mut self, note: &Note) -> Result<NoteFieldsState> {
|
||||
Ok(if let Some(text) = note.fields.first() {
|
||||
let field1 = if self.get_config_bool(BoolKey::NormalizeNoteText) {
|
||||
normalize_to_nfc(text)
|
||||
} else {
|
||||
text.into()
|
||||
};
|
||||
let stripped = strip_html_preserving_media_filenames(&field1);
|
||||
if stripped.trim().is_empty() {
|
||||
NoteFieldsState::Empty
|
||||
} else {
|
||||
let cloze_state = self.field_cloze_check(note)?;
|
||||
if cloze_state != NoteFieldsState::Normal {
|
||||
Ok({
|
||||
let cloze_state = self.field_cloze_check(note)?;
|
||||
if cloze_state == NoteFieldsState::FieldNotCloze {
|
||||
NoteFieldsState::FieldNotCloze
|
||||
} else if let Some(text) = note.fields.first() {
|
||||
let field1 = if self.get_config_bool(BoolKey::NormalizeNoteText) {
|
||||
normalize_to_nfc(text)
|
||||
} else {
|
||||
text.into()
|
||||
};
|
||||
let stripped = strip_html_preserving_media_filenames(&field1);
|
||||
if stripped.trim().is_empty() {
|
||||
NoteFieldsState::Empty
|
||||
} else if cloze_state != NoteFieldsState::Normal {
|
||||
cloze_state
|
||||
} else if self.is_duplicate(&stripped, note)? {
|
||||
NoteFieldsState::Duplicate
|
||||
} else {
|
||||
NoteFieldsState::Normal
|
||||
}
|
||||
} else {
|
||||
NoteFieldsState::Empty
|
||||
}
|
||||
} else {
|
||||
NoteFieldsState::Empty
|
||||
})
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue