def _gen_toc(self, idx):
        """
        生成目录html
        :return:
        :rtype:
        """
        if not self._chapterization:
            return ''

        start, end = self._start_end_of_index(idx)
        chap_infos = '\n'.join(["            <li><a href=\"#ch{}\">{}</a></li>".format(
            chap._idx,
            chap._title) for chap in self._chapters[start:end]])
        toc = """
    <div id="toc">
        <h2>
            目录<br />
        </h2>
        <ul>
{}
        </ul>
    </div>
    <div class="pagebreak"></div>
        """ .format(chap_infos)
        return toc
def _gen_toc ( self , idx ) : if not self . _chapterization : return '' start , end = self . _start_end_of_index ( idx ) chap_infos = '\n' . join ( [ "            <li><a href=\"#ch{}\">{}</a></li>" . format ( chap . _idx , chap . _title ) for chap in self . _chapters [ start : end ] ] ) toc = """
    <div id="toc">
        <h2>
            目录<br />
        </h2>
        <ul>
{}
        </ul>
    </div>
    <div class="pagebreak"></div>
        """ . format ( chap_infos ) return toc
生成目录html
        :return:
        :rtype: