Builds an unordered HTML list out of the list of matches, stopping at the first match
        that is smaller than current_level (e.g. h1 < h2).

        This method uses mutual recursion with _build_list_items and expects _build_list_items to
        delete matches as it processes them.

        This method uses string comparison when comparing levels, taking advantage of the fact that
        ordering single-digit ASCII numerical character is the same as ordering single-digit
        integers. By default, the current_level is '1' so that it can process all headers.

        For efficiency reasons, this method doesn't concatenate the lines; callers of this method
        should perform the join after the call.

def _build_list(self, matches, current_level='1'):
        """Builds an unordered HTML list out of the list of matches, stopping at the first match
        that is smaller than current_level (e.g. h1 < h2).

        This method uses mutual recursion with _build_list_items and expects _build_list_items to
        delete matches as it processes them.

        This method uses string comparison when comparing levels, taking advantage of the fact that
        ordering single-digit ASCII numerical character is the same as ordering single-digit
        integers. By default, the current_level is '1' so that it can process all headers.

        For efficiency reasons, this method doesn't concatenate the lines; callers of this method
        should perform the join after the call.
        """
        lines = ['<ul>']
        while matches and current_level <= matches[0][0]:
            # Build list items and indent each line by two spaces.
            lines.extend('  ' + line for line in self._build_list_items(matches))
        lines.append('</ul>')
        return lines