mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-01-28 23:15:18 +01:00
Conversion pipeline: When detecting chapters/toc links from HTML normalize spaces and increase maximum TOC title length to 1000 characters from 100 characters. Fixes #9363 (Shortening text on generating TOC.)
This commit is contained in:
parent
2f4876f474
commit
428ed899fc
1 changed files with 3 additions and 1 deletions
|
|
@ -81,6 +81,7 @@ def detect_chapters(self):
|
|||
page_break_after = 'display: block; page-break-after: always'
|
||||
for item, elem in self.detected_chapters:
|
||||
text = xml2text(elem).strip()
|
||||
text = re.sub(r'\s+', ' ', text.strip())
|
||||
self.log('\tDetected chapter:', text[:50])
|
||||
if chapter_mark == 'none':
|
||||
continue
|
||||
|
|
@ -137,7 +138,8 @@ def elem_to_link(self, item, elem, counter):
|
|||
text = elem.get('title', '')
|
||||
if not text:
|
||||
text = elem.get('alt', '')
|
||||
text = text[:100].strip()
|
||||
text = re.sub(r'\s+', ' ', text.strip())
|
||||
text = text[:1000].strip()
|
||||
id = elem.get('id', 'calibre_toc_%d'%counter)
|
||||
elem.set('id', id)
|
||||
href = '#'.join((item.href, id))
|
||||
|
|
|
|||
Loading…
Reference in a new issue