fix: Set fields to the values, ignore anki sent order
PHP automatically maintains the order properly. Maybe just to make sure it would be nice to somehow check the order but for now I'm leaving it like this
This commit is contained in:
parent
5586e80768
commit
b99d7ae971
|
@ -51,23 +51,22 @@ class Note
|
|||
'mod' => $note->mod,
|
||||
'profile' => $note->profile,
|
||||
'tags' => $note->tags,
|
||||
'fields' => $note->fields,
|
||||
'modelName' => $note->model,
|
||||
'cards' => $note->cardIds,
|
||||
] = $noteInfo;
|
||||
|
||||
$fields = array_map(fn($x) => $x['value'], $noteInfo['fields']);
|
||||
$note->fields = array_map(fn($x) => $x['value'], $noteInfo['fields']);
|
||||
|
||||
// Set VocabKanji field
|
||||
//$vocabKanji = explode('|', $fields['VocabKanji']);
|
||||
$note->terms = self::parseVocabDef($fields['VocabDef']);
|
||||
//$vocabKanji = explode('|', $note->fields['VocabKanji']);
|
||||
$note->terms = self::parseVocabDef($note->fields['VocabDef']);
|
||||
|
||||
// If not defined, find them from the highlighted parts in the sentence
|
||||
if (empty($note->terms)) {
|
||||
// 1. Get all spans in the text
|
||||
preg_match_all(
|
||||
self::HIGHLIGHT_PATTERN,
|
||||
$fields['SentKanji'],
|
||||
$note->fields['SentKanji'],
|
||||
$matches,
|
||||
PREG_SET_ORDER,
|
||||
);
|
||||
|
@ -86,7 +85,7 @@ class Note
|
|||
// Set to null whatever is null
|
||||
$readings = array_map(
|
||||
fn($x) => in_array($x, ['_', '_', '']) ? null : $x,
|
||||
explode('|', $fields['VocabFurigana']),
|
||||
explode('|', $note->fields['VocabFurigana']),
|
||||
);
|
||||
|
||||
// Set readings from furigana field
|
||||
|
|
Loading…
Reference in New Issue