parameters: (lines, id_tag=True, back_links=False, exclude_h=None)
return_statement: return out_contents, headlines
docstring: Gets headlines from the markdown document and creates anchor tags.
  
      Keyword arguments:
          lines: a list of sublists where every sublist
              represents a line from a Markdown document.
          id_tag: if true, creates inserts a the <a id> tags (not req. by GitHub)
          back_links: if true, adds "back to top" links below each headline
          exclude_h: header levels to exclude. E.g., [2, 3]
              excludes level 2 and 3 headings.
  
      Returns a tuple of 2 lists:
          1st list:
              A modified version of the input list where
              <a id="some-header"></a> anchor tags where inserted
              above the header lines (if github is False).
  
          2nd list:
              A list of 3-value sublists, where the first value
              represents the heading, the second value the string
              that was inserted assigned to the IDs in the anchor tags,
              and the third value is an integer that represents the headline level.
              E.g.,
              [['some header lvl3', 'some-header-lvl3', 3], ...]
docstring_summary: Gets headlines from the markdown document and creates anchor tags.
docstring_tokens: Gets headlines from the markdown document and creates anchor tags .
function: def tagAndCollect(lines, id_tag=True, back_links=False, exclude_h=None):
      """
      Gets headlines from the markdown document and creates anchor tags.
  
      Keyword arguments:
          lines: a list of sublists where every sublist
              represents a line from a Markdown document.
          id_tag: if true, creates inserts a the <a id> tags (not req. by GitHub)
          back_links: if true, adds "back to top" links below each headline
          exclude_h: header levels to exclude. E.g., [2, 3]
              excludes level 2 and 3 headings.
  
      Returns a tuple of 2 lists:
          1st list:
              A modified version of the input list where
              <a id="some-header"></a> anchor tags where inserted
              above the header lines (if github is False).
  
          2nd list:
              A list of 3-value sublists, where the first value
              represents the heading, the second value the string
              that was inserted assigned to the IDs in the anchor tags,
              and the third value is an integer that represents the headline level.
              E.g.,
              [['some header lvl3', 'some-header-lvl3', 3], ...]
  
      """
      out_contents = []
      headlines = []
      for l in lines:
          saw_headline = False
  
          orig_len = len(l)
          l_stripped = l.lstrip()
  
          if l_stripped.startswith(('# ', '## ', '### ', '#### ', '##### ', '###### ')):
  
              # comply with new markdown standards
  
              # not a headline if '#' not followed by whitespace '##no-header':
              if not l.lstrip('#').startswith(' '):
                  continue
              # not a headline if more than 6 '#':
              if len(l) - len(l.lstrip('#')) > 6:
                  continue
              # headers can be indented by at most 3 spaces:
              if orig_len - len(l_stripped) > 3:
                  continue
  
              # ignore empty headers
              if not set(l) - {'#', ' '}:
                  continue
  
              saw_headline = True
              dashified = dashifyHeadline(l)
  
              if not exclude_h or not dashified[-1] in exclude_h:
                  if id_tag:
                      id_tag = '<a class="mk-toclify" id="%s"></a>'\
                                % (dashified[1])
                      out_contents.append(id_tag)
                  headlines.append(dashified)
  
          out_contents.append(l)
          if back_links and saw_headline:
              out_contents.append('[[back to top](#table-of-contents)]')
      return out_contents, headlines
function_tokens: def tagAndCollect ( lines , id_tag = True , back_links = False , exclude_h = None ) : out_contents = [ ] headlines = [ ] for l in lines : saw_headline = False orig_len = len ( l ) l_stripped = l . lstrip ( ) if l_stripped . startswith ( ( '# ' , '## ' , '### ' , '#### ' , '##### ' , '###### ' ) ) : # comply with new markdown standards # not a headline if '#' not followed by whitespace '##no-header': if not l . lstrip ( '#' ) . startswith ( ' ' ) : continue # not a headline if more than 6 '#': if len ( l ) - len ( l . lstrip ( '#' ) ) > 6 : continue # headers can be indented by at most 3 spaces: if orig_len - len ( l_stripped ) > 3 : continue # ignore empty headers if not set ( l ) - { '#' , ' ' } : continue saw_headline = True dashified = dashifyHeadline ( l ) if not exclude_h or not dashified [ - 1 ] in exclude_h : if id_tag : id_tag = '<a class="mk-toclify" id="%s"></a>' % ( dashified [ 1 ] ) out_contents . append ( id_tag ) headlines . append ( dashified ) out_contents . append ( l ) if back_links and saw_headline : out_contents . append ( '[[back to top](#table-of-contents)]' ) return out_contents , headlines