anolislib/processes/outliner.py
changeset 298 b6d93515d41e
parent 262 9cbda255bfdb
child 299 7db2a3fe1af2
     1.1 --- a/anolislib/processes/outliner.py	Sun Sep 28 11:03:12 2008 +0100
     1.2 +++ b/anolislib/processes/outliner.py	Sun Feb 22 23:36:54 2009 +0000
     1.3 @@ -27,6 +27,7 @@
     1.4  rank = {u"h1": -1, u"h2": -2, u"h3": -3, u"h4": -4, u"h5": -5, u"h6": -6,
     1.5          u"header": -1}
     1.6  
     1.7 +
     1.8  class section(list):
     1.9      """Represents the section of a document."""
    1.10  
    1.11 @@ -44,6 +45,7 @@
    1.12          for child in children:
    1.13              child.parent = self
    1.14  
    1.15 +
    1.16  class Outliner:
    1.17      """Build the outline of an HTML document."""
    1.18  
    1.19 @@ -176,20 +178,25 @@
    1.20                          # this new section. Let the element being entered be
    1.21                          # the new heading for the current section. Abort these
    1.22                          # substeps.
    1.23 -                        if rank[element.tag] < rank[candidate_section.header.tag]:
    1.24 +                        if rank[element.tag] < \
    1.25 +                           rank[candidate_section.header.tag]:
    1.26                              self.current_section = section()
    1.27                              candidate_section.append(self.current_section)
    1.28                              self.current_section.header = element
    1.29                              break
    1.30 -                        # Let new candidate section be the section that contains candidate section in the outline of current outlinee.
    1.31 +                        # Let new candidate section be the section that
    1.32 +                        # contains candidate section in the outline of current
    1.33 +                        # outlinee.
    1.34                          # Let candidate section be new candidate section.
    1.35                          candidate_section = candidate_section.parent
    1.36                          # Return to step 2.
    1.37 -                # Push the element being entered onto the stack. (This causes the algorithm to skip any descendants of the element.)
    1.38 +                # Push the element being entered onto the stack. (This causes
    1.39 +                # the algorithm to skip any descendants of the element.)
    1.40                  self.stack.append(element)
    1.41  
    1.42 -        # If the current outlinee is null, then there was no sectioning content element or sectioning root element in the DOM. There is no outline.
    1.43 +        # If the current outlinee is null, then there was no sectioning content
    1.44 +        # element or sectioning root element in the DOM. There is no outline.
    1.45          try:
    1.46              return self.outlines[self.current_outlinee]
    1.47          except KeyError:
    1.48 -            return None
    1.49 \ No newline at end of file
    1.50 +            return None