feat: scan

This commit is contained in:
hashbro
2026-09-13 02:12:06 +08:00
parent d7bd4d1b03
commit 1746e7b485
13 changed files with 266 additions and 40 deletions
+8 -1
View File
@@ -272,6 +272,7 @@ class NoteContent
{
$lines = preg_split('/\n+/', $text) ?: [];
$title = '';
$firstLine = '';
$rest = [];
foreach ($lines as $line) {
$line = trim($line);
@@ -280,12 +281,18 @@ class NoteContent
}
if ($title === '') {
$title = mb_substr($line, 0, 80);
$firstLine = $line;
continue;
}
$rest[] = $line;
}
return [$title, trim(implode("\n", $rest))];
$body = trim(implode("\n", $rest));
if ($body === '') {
$body = $firstLine;
}
return [$title, $body];
}
}