#NEWLINE# def create_toc( headlines , hyperlink = True , top_link = False , no_toc_header = False ) : #NEWLINE# #INDENT# "\n    Creates the table of contents from the headline list\n    that was returned by the tag_and_collect function.\n\n    Keyword Arguments:\n        headlines: list of lists\n            e.g., ['Some header lvl3', 'some-header-lvl3', 3]\n        hyperlink: Creates hyperlinks in Markdown format if True,\n            e.g., '- [Some header lvl1](#some-header-lvl1)'\n        top_link: if True, add a id tag for linking the table\n            of contents itself (for the back-to-top-links)\n        no_toc_header: suppresses TOC header if True.\n\n    Returns  a list of headlines for a table of contents\n    in Markdown format,\n    e.g., ['        - [Some header lvl3](#some-header-lvl3)', ...]\n\n    " #NEWLINE# processed = [ ] #NEWLINE# if ( not no_toc_header ) : #NEWLINE# #INDENT# if top_link : #NEWLINE# #INDENT# processed . append ( '<a class="mk-toclify" id="table-of-contents"></a>\n' ) #NEWLINE# #UNINDENT# processed . append ( '# Table of Contents' ) #NEWLINE# #UNINDENT# for line in headlines : #NEWLINE# #INDENT# if hyperlink : #NEWLINE# #INDENT# item = ( '%s- [%s](#%s)' % ( ( ( line [ 2 ] - 1 ) * '    ' ) , line [ 0 ] , line [ 1 ] ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# item = ( '%s- %s' % ( ( ( line [ 2 ] - 1 ) * '    ' ) , line [ 0 ] ) ) #NEWLINE# #UNINDENT# processed . append ( item ) #NEWLINE# #UNINDENT# processed . append ( '\n' ) #NEWLINE# return processed