use the spread operator to fix a nasty bug for story 82748

This commit is contained in:
Daniel Jönsson 2020-08-10 09:45:04 +02:00
parent a0f896c66d
commit d5fa32303a

View file

@ -82,10 +82,7 @@ export function createChapter (ffc, ch, isNotesChapter) {
sections.reverse()
}
const tokenContent = '%%HTML_CONTENT_' + Math.random() + '%%'
return Promise.all([
render(
return render(
m('html', { xmlns: NS.XHTML, 'xmlns:epub': NS.OPS, lang: 'en', 'xml:lang': 'en' }, [
m('head', [
m('meta', { charset: 'utf-8' }),
@ -102,7 +99,7 @@ export function createChapter (ffc, ch, isNotesChapter) {
m('header', m('h1', title)),
m('hr.old')
]) : null,
tokenContent,
...sections,
(link || linkNotes || isNotesChapter) ? m('p.double', { style: 'text-align: center; clear: both;' },
link ? m('a.chaptercomments', { href: link + '#comment_list' }, 'Read chapter comments online') : null,
linkNotes ? m('a.chaptercomments', { href: linkNotes }, 'Read author\'s note') : null,
@ -111,13 +108,7 @@ export function createChapter (ffc, ch, isNotesChapter) {
!isNotesChapter && ffc.options.addChapterBars ? chapterBars(ffc.storyInfo.chapters, index) : null
]))
])
, { strict: true }),
render(sections)
]).then(([chapterPage, sectionsData]) => {
chapterPage = '<?xml version="1.0" encoding="utf-8"?>\n<!DOCTYPE html>\n' + chapterPage
chapterPage = chapterPage.replace(tokenContent, '\n' + sectionsData + '\n')
return chapterPage
})
, { strict: true }).then((chapterPage) => '<?xml version="1.0" encoding="utf-8"?>\n<!DOCTYPE html>\n' + chapterPage)
}
// some eReaders doesn't understand linear=no, so push those items to the end of the spine/book.