FB2 improvements

- Set title text-align more specifically on h1
- Don't throw when there's no cover
This commit is contained in:
John Factotum
2023-05-01 22:55:59 +08:00
parent d951497c30
commit 9068d70acc
+8 -4
View File
@@ -168,14 +168,16 @@ body > img, section > img {
display: block; display: block;
margin: auto; margin: auto;
} }
.title { .title h1 {
text-align: center; text-align: center;
} }
body > section > .title, body.notesBodyType > .title { body > section > .title, body.notesBodyType > .title {
margin: 3em 0; margin: 3em 0;
} }
body.notesBodyType > section .title h1 {
text-align: start;
}
body.notesBodyType > section .title { body.notesBodyType > section .title {
text-align: left;
margin: 1em 0; margin: 1em 0;
} }
p { p {
@@ -255,8 +257,10 @@ export const makeFB2 = async blob => {
{ annotation: ['div', SECTION] }).innerHTML : null, { annotation: ['div', SECTION] }).innerHTML : null,
subject: $$('title-info genre').map(getElementText), subject: $$('title-info genre').map(getElementText),
} }
book.getCover = () => fetch(getImageSrc($('coverpage image'))) if ($('coverpage image')) {
.then(res => res.blob()) const src = getImageSrc($('coverpage image'))
book.getCover = () => fetch(src).then(res => res.blob())
} else book.getCover = () => null
// get convert each body // get convert each body
const bodyData = Array.from(doc.querySelectorAll('body'), body => { const bodyData = Array.from(doc.querySelectorAll('body'), body => {