mirror of
https://github.com/alexadam/save-as-ebook.git
synced 2025-09-10 17:34:47 +00:00
fix & & problem in title for chapters; Issue #10
This commit is contained in:
parent
bc64fd360c
commit
36c9b68e10
2 changed files with 10 additions and 7 deletions
|
@ -283,7 +283,6 @@ function getPageTitle(title) {
|
||||||
if (title.trim().length === 0) {
|
if (title.trim().length === 0) {
|
||||||
return 'ebook';
|
return 'ebook';
|
||||||
}
|
}
|
||||||
title = escapeAmp(title);
|
|
||||||
return title;
|
return title;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,10 +38,11 @@ function _buildEbook(allPages) {
|
||||||
var ebookFileName = 'eBook.epub';
|
var ebookFileName = 'eBook.epub';
|
||||||
|
|
||||||
if (ebookTitle) {
|
if (ebookTitle) {
|
||||||
ebookName = ebookTitle;
|
// ~TODO a pre-processing function to apply escapeAmp to all page.titles
|
||||||
ebookFileName = getEbookFileName(bookTitle) + '.epub';
|
ebookName = escapeAmp(ebookTitle);
|
||||||
|
ebookFileName = getEbookFileName(ebookTitle) + '.epub';
|
||||||
} else {
|
} else {
|
||||||
ebookName = allPages[0].title;
|
ebookName = escapeAmp(allPages[0].title);
|
||||||
ebookFileName = getEbookFileName(allPages[0].title) + '.epub';
|
ebookFileName = getEbookFileName(allPages[0].title) + '.epub';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,7 +73,8 @@ function _buildEbook(allPages) {
|
||||||
'<h1 class="frontmatter">Table of Contents</h1>' +
|
'<h1 class="frontmatter">Table of Contents</h1>' +
|
||||||
'<ol class="contents">' +
|
'<ol class="contents">' +
|
||||||
allPages.reduce(function(prev, page) {
|
allPages.reduce(function(prev, page) {
|
||||||
return prev + '\n' + '<li><a href="pages/' + page.url + '">' + page.title + '</a></li>';
|
var tmpPageTitle = escapeAmp(page.title);
|
||||||
|
return prev + '\n' + '<li><a href="pages/' + page.url + '">' + tmpPageTitle + '</a></li>';
|
||||||
}, '') +
|
}, '') +
|
||||||
'</ol>' +
|
'</ol>' +
|
||||||
'</nav>' +
|
'</nav>' +
|
||||||
|
@ -92,9 +94,10 @@ function _buildEbook(allPages) {
|
||||||
'</docTitle>' +
|
'</docTitle>' +
|
||||||
'<navMap>' +
|
'<navMap>' +
|
||||||
allPages.reduce(function(prev, page, index) {
|
allPages.reduce(function(prev, page, index) {
|
||||||
|
var tmpPageTitle = escapeAmp(page.title);
|
||||||
return prev + '\n' +
|
return prev + '\n' +
|
||||||
'<navPoint id="ebook' + index + '" playOrder="' + (index + 1) + '">' +
|
'<navPoint id="ebook' + index + '" playOrder="' + (index + 1) + '">' +
|
||||||
'<navLabel><text>' + page.title + '</text></navLabel>' +
|
'<navLabel><text>' + tmpPageTitle + '</text></navLabel>' +
|
||||||
'<content src="pages/' + page.url + '" />' +
|
'<content src="pages/' + page.url + '" />' +
|
||||||
'</navPoint>';
|
'</navPoint>';
|
||||||
}, '') +
|
}, '') +
|
||||||
|
@ -110,11 +113,12 @@ function _buildEbook(allPages) {
|
||||||
|
|
||||||
var pagesFolder = oebps.folder('pages');
|
var pagesFolder = oebps.folder('pages');
|
||||||
allPages.forEach(function(page) {
|
allPages.forEach(function(page) {
|
||||||
|
var tmpPageTitle = escapeAmp(page.title);
|
||||||
pagesFolder.file(page.url,
|
pagesFolder.file(page.url,
|
||||||
'<?xml version="1.0" encoding="utf-8"?>' +
|
'<?xml version="1.0" encoding="utf-8"?>' +
|
||||||
'<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops">' +
|
'<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops">' +
|
||||||
'<head>' +
|
'<head>' +
|
||||||
'<title>' + page.title + '</title>' +
|
'<title>' + tmpPageTitle+ '</title>' +
|
||||||
'<link href="../style/' + page.styleFileName + '" rel="stylesheet" type="text/css" />' +
|
'<link href="../style/' + page.styleFileName + '" rel="stylesheet" type="text/css" />' +
|
||||||
'</head><body>' +
|
'</head><body>' +
|
||||||
page.content +
|
page.content +
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue