feat: scan
This commit is contained in:
@@ -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];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user