txt: trim punctuations in parsed author names (#1707)

* txt: trim punctuations in parsed author names

* release: version 0.9.68
This commit is contained in:
Huang Xin
2025-07-30 02:50:21 +08:00
committed by GitHub
parent c581f8ab47
commit aa3cd2a0c5
3 changed files with 17 additions and 7 deletions
+11
View File
@@ -1,5 +1,16 @@
{
"releases": {
"0.9.68": {
"date": "2025-07-30",
"notes": [
"Reader: Files now open in a new window by default on Desktop",
"Translation: Skips translating content inside <pre>, <code>, and <math> tags",
"Performance: Improved multi-part downloading for large books",
"Sync: Resolved issue preventing some PDF files from syncing",
"CSS: Resolved issue with fixed font color in some EPUB files",
"TXT: Enhanced TXT parsing for better compatibility"
]
},
"0.9.67": {
"date": "2025-07-22",
"notes": [
@@ -66,12 +66,7 @@ const BookItem: React.FC<BookItemProps> = ({
mode === 'list' && 'min-w-20',
)}
>
<BookCover
mode={mode}
book={book}
coverFit={coverFit}
showSpine={book.format !== 'PDF' || !!book.metadata?.publisher}
/>
<BookCover mode={mode} book={book} coverFit={coverFit} showSpine={false} />
{bookSelected && (
<div className='absolute inset-0 bg-black opacity-30 transition-opacity duration-300'></div>
)}
+5 -1
View File
@@ -62,7 +62,11 @@ export class TxtToEpubConverter {
const authorMatch =
fileHeader.match(/[【\[]?作者[】\]]?[:\s]\s*(.+)\r?\n/) ||
fileHeader.match(/[【\[]?\s*(.+)\s+著\s*[】\]]?\r?\n/);
const author = authorMatch ? authorMatch[1]!.trim() : providedAuthor || '';
let matchedAuthor = authorMatch ? authorMatch[1]!.trim() : providedAuthor || '';
try {
matchedAuthor = matchedAuthor.replace(/^[\p{P}\p{S}]+|[\p{P}\p{S}]+$/gu, '');
} catch {}
const author = matchedAuthor || providedAuthor || '';
const language = providedLanguage || this.detectLanguage(fileHeader);
const identifier = await partialMD5(txtFile);
const metadata = { bookTitle, author, language, identifier };