Skip to content

Better epub import#1842

Open
CD-Z wants to merge 6 commits into
lnreader:masterfrom
CD-Z:better-epub-import
Open

Better epub import#1842
CD-Z wants to merge 6 commits into
lnreader:masterfrom
CD-Z:better-epub-import

Conversation

@CD-Z

@CD-Z CD-Z commented May 9, 2026

Copy link
Copy Markdown
Collaborator

Faster import
skip empty chapters / chapters with only title inside
added test
other small fixes

Not tested with lots of epubs

@Palloxin

This comment was marked as off-topic.

Comment thread src/services/epub/import.ts Outdated
};

const stripHtml = (value: string) => {
const bodyMatch = value.match(/<body[^>]*>([\s\S]*?)<\/body>/i);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/<body[^>]*>([^]*?)<\/body>/i

Comment thread src/services/epub/import.ts Outdated
const bodyMatch = value.match(/<body[^>]*>([\s\S]*?)<\/body>/i);
const bodyContent = bodyMatch ? bodyMatch[1] : value;
return bodyContent
.replace(/<script[^>]*>[\s\S]*?<\/script>/gi, ' ')

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

regex is faster if u replace every [\s\S] with [^]

Supposing ther egex used is javascript flavour

@CD-Z

CD-Z commented May 9, 2026

Copy link
Copy Markdown
Collaborator Author

This has nothing to do with the old pr. This is for import and the other was for export

@Palloxin

Copy link
Copy Markdown
Contributor
wyJsNRw0.mp4

dont forget

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants