From 9068d70acc6acdbb3e2c50b49682b334a35b5221 Mon Sep 17 00:00:00 2001 From: John Factotum <50942278+johnfactotum@users.noreply.github.com> Date: Mon, 1 May 2023 22:54:49 +0800 Subject: [PATCH] FB2 improvements - Set title text-align more specifically on h1 - Don't throw when there's no cover --- fb2.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/fb2.js b/fb2.js index b85277b..45d2166 100644 --- a/fb2.js +++ b/fb2.js @@ -168,14 +168,16 @@ body > img, section > img { display: block; margin: auto; } -.title { +.title h1 { text-align: center; } body > section > .title, body.notesBodyType > .title { margin: 3em 0; } +body.notesBodyType > section .title h1 { + text-align: start; +} body.notesBodyType > section .title { - text-align: left; margin: 1em 0; } p { @@ -255,8 +257,10 @@ export const makeFB2 = async blob => { { annotation: ['div', SECTION] }).innerHTML : null, subject: $$('title-info genre').map(getElementText), } - book.getCover = () => fetch(getImageSrc($('coverpage image'))) - .then(res => res.blob()) + if ($('coverpage image')) { + const src = getImageSrc($('coverpage image')) + book.getCover = () => fetch(src).then(res => res.blob()) + } else book.getCover = () => null // get convert each body const bodyData = Array.from(doc.querySelectorAll('body'), body => {