Infrastructure for internal ToC entries per article

This commit is contained in:
Kovid Goyal 2020-08-31 07:52:38 +05:30
parent 547cc40f8c
commit bc634e02bd
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 6 additions and 1 deletions

View File

@ -34,6 +34,7 @@ class Article(object):
self.url = url
self.author = author
self.toc_thumbnail = None
self.internal_toc_entries = ()
if author and not isinstance(author, unicode_type):
author = author.decode('utf-8', 'replace')
if summary and not isinstance(summary, unicode_type):

View File

@ -1522,10 +1522,14 @@ class BasicNewsRecipe(Recipe):
arelpath = '%sindex.html'%adir
for curl in self.canonicalize_internal_url(a.orig_url, is_link=False):
aumap[curl].add(arelpath)
parent.add_item(arelpath, None,
article_toc_entry = parent.add_item(arelpath, None,
a.title if a.title else _('Untitled article'),
play_order=po, author=auth,
description=desc, toc_thumbnail=tt)
for entry in a.internal_toc_entries:
self.play_order_counter += 1
po += 1
article_toc_entry.add_item(arelpath, entry['anchor'], entry['title'], play_order=po)
last = os.path.join(self.output_dir, ('%sindex.html'%adir).replace('/', os.sep))
for sp in a.sub_pages:
prefix = os.path.commonprefix([opf_path, sp])