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:
RREEMMII 2025-04-13 06:40:35 +02:00 committed by GitHub
parent e546c6d11f
commit 1fa99c97e4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 17 additions and 14 deletions

View file

@ -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>
********************

View file

@ -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
})
}