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> Valerie Enfys <val@unidentified.systems>
Julien Chol <https://github.com/chel-ou> Julien Chol <https://github.com/chel-ou>
ikkz <ylei.mk@gmail.com> 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 /// 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. /// 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> { pub fn note_fields_check(&mut self, note: &Note) -> Result<NoteFieldsState> {
Ok(if let Some(text) = note.fields.first() { Ok({
let field1 = if self.get_config_bool(BoolKey::NormalizeNoteText) { let cloze_state = self.field_cloze_check(note)?;
normalize_to_nfc(text) if cloze_state == NoteFieldsState::FieldNotCloze {
} else { NoteFieldsState::FieldNotCloze
text.into() } else if let Some(text) = note.fields.first() {
}; let field1 = if self.get_config_bool(BoolKey::NormalizeNoteText) {
let stripped = strip_html_preserving_media_filenames(&field1); normalize_to_nfc(text)
if stripped.trim().is_empty() { } else {
NoteFieldsState::Empty text.into()
} else { };
let cloze_state = self.field_cloze_check(note)?; let stripped = strip_html_preserving_media_filenames(&field1);
if cloze_state != NoteFieldsState::Normal { if stripped.trim().is_empty() {
NoteFieldsState::Empty
} else if cloze_state != NoteFieldsState::Normal {
cloze_state cloze_state
} else if self.is_duplicate(&stripped, note)? { } else if self.is_duplicate(&stripped, note)? {
NoteFieldsState::Duplicate NoteFieldsState::Duplicate
} else { } else {
NoteFieldsState::Normal NoteFieldsState::Normal
} }
} else {
NoteFieldsState::Empty
} }
} else {
NoteFieldsState::Empty
}) })
} }