1.1 --- a/actions/SectionBreakout.py Sat Feb 26 21:45:56 2011 +0100
1.2 +++ b/actions/SectionBreakout.py Sun Sep 11 18:50:16 2011 +0200
1.3 @@ -33,7 +33,7 @@
1.4 # Acquire heading details from the page.
1.5
1.6 body = page.get_raw_body()
1.7 - heading_details = getHeadingDetails(body, level, level)
1.8 + heading_details = getSectionDetails(body, level, level)
1.9
1.10 d = {
1.11 "buttons_html" : buttons_html,
1.12 @@ -55,7 +55,8 @@
1.13 <td>''' % d
1.14
1.15 for heading, level, span in heading_details:
1.16 - html += "%s<br />" % heading
1.17 + if heading is not None:
1.18 + html += "%s<br />" % escape(heading)
1.19
1.20 html += '''
1.21 </td>
1.22 @@ -122,25 +123,36 @@
1.23 regions = []
1.24 current_region_start = None
1.25
1.26 - for heading, found_level, (start, end) in getHeadingDetails(page_body):
1.27 + for heading, found_level, (start, end) in getSectionDetails(page_body):
1.28
1.29 - # Upon finding a suitable heading, begin a new region to be broken
1.30 - # out.
1.31 + # Where a heading is provided, consider starting a section.
1.32 +
1.33 + if found_level is not None:
1.34
1.35 - if current_region_start is None and found_level >= level:
1.36 - current_region_start = heading, start
1.37 + # Upon finding a suitable heading, begin a new region to be broken
1.38 + # out.
1.39
1.40 - # Upon finding a higher-level heading, end any open region.
1.41 + if current_region_start is None and found_level >= level:
1.42 + current_region_start = heading, start
1.43 +
1.44 + # Upon finding a same-level or higher-level heading, end any open
1.45 + # region.
1.46
1.47 - elif current_region_start is not None and found_level <= level:
1.48 - regions.append(current_region_start + (start,))
1.49 + elif current_region_start is not None and found_level <= level:
1.50 + regions.append(current_region_start + (start,))
1.51
1.52 - # For headings at the requested level, open a new region.
1.53 + # For headings at the requested level, open a new region.
1.54
1.55 - if found_level == level:
1.56 - current_region_start = heading, start
1.57 - else:
1.58 - current_region_start = None
1.59 + if found_level == level:
1.60 + current_region_start = heading, start
1.61 + else:
1.62 + current_region_start = None
1.63 +
1.64 + # Where no heading is provided, end the section.
1.65 +
1.66 + elif current_region_start is not None:
1.67 + regions.append(current_region_start + (start,))
1.68 + current_region_start = None
1.69
1.70 # End any open region.
1.71