$def with (table_of_contents, ocaid=None, cls='', attrs='')
$for chapter in table_of_contents.entries:
$ is_link = ocaid and chapter.pagenum and chapter.pagenum.isdigit() $ tag = 'a' if is_link else 'div' <$tag class="toc__main" $:cond(is_link, 'href="//archive.org/details/%s/page/%s"' % (ocaid, chapter.pagenum)) $:cond(is_link, 'data-ol-link-track="BookPage|TOCClick"') >
$ label = chapter.label $if label and not label.endswith('.'): $ label = label.strip() + '. '
$label $chapter.title
$if chapter.subtitle:
$chapter.subtitle
$if chapter.authors:
$:macros.BookByline(chapter.authors)
$if chapter.pagenum: $_('Page %s', chapter.pagenum) $if chapter.description:
$chapter.description