fix: When definition doesn't conform don't error out, return null

This commit is contained in:
Dendy 2025-02-06 18:12:56 +09:00
parent 576816fa03
commit 28bcff1667
1 changed files with 5 additions and 0 deletions

View File

@ -67,7 +67,12 @@ class Term
$term->kanji = mb_substr($vocabDefLine, 0, $enStart); $term->kanji = mb_substr($vocabDefLine, 0, $enStart);
$def = mb_substr($vocabDefLine, $enStart + 1, null); $def = mb_substr($vocabDefLine, $enStart + 1, null);
$enStart = 0; $enStart = 0;
} else {
// Can't extract term from definition, it doesn't conform to the
// established pattern.
return null;
} }
// Convert 「this」 into [this] // Convert 「this」 into [this]
$term->kanji = mb_trim(strtr($term->kanji, [ $term->kanji = mb_trim(strtr($term->kanji, [
'「' => '[', '「' => '[',