Skip to content

Commit 03445c0

Browse files
committed
always end the mini run, even if we won't continue
1 parent 4f95a9f commit 03445c0

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

indigo/analysis/toc/base.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -624,14 +624,15 @@ def process_subprovision(self, subp, prefix, subs_to_add, mini_run):
624624
# e.g. (1)(a)–(c) rather than (1)(a)–(1)(c) (these can get quite long)
625625
subp.num = prefix + subp.num
626626
self.add_to_run(subp, mini_run)
627-
# keep drilling down if some descendants are different
628-
elif not subp.all_descendants_same:
627+
else:
628+
# end the mini run before maybe continuing
629629
if mini_run:
630-
# end the mini run before continuing
631630
subs_to_add.append(self.stringify_run(mini_run, no_type=True))
632631
mini_run = []
633-
for subsubp in subp.children:
634-
subs_to_add, mini_run = self.process_subprovision(subsubp, prefix + subp.num, subs_to_add, mini_run)
632+
# keep drilling down if some descendants are different
633+
if not subp.all_descendants_same:
634+
for subsubp in subp.children:
635+
subs_to_add, mini_run = self.process_subprovision(subsubp, prefix + subp.num, subs_to_add, mini_run)
635636

636637
return subs_to_add, mini_run
637638

indigo/tests/test_beautiful_provisions.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,16 @@ def test_one_subsection_missing(self):
100100
'section 1–55, section 56(2), section 57–63',
101101
commenceable_provisions=sections_1_to_63)
102102

103+
def test_subsection_2_with_paras_missing(self):
104+
section_26 = self.make_toc_elements('sec_', 'section', [26], basic_unit=True)
105+
paras_2 = self.make_toc_elements('sec_26__subsec_2__para_', 'paragraph', ['a', 'b', 'c'], basic_unit=False)
106+
subsecs = self.make_toc_elements('sec_26__subsec_', 'subsection', range(1, 4), basic_unit=False)
107+
subsecs[1].children = paras_2
108+
section_26[0].children = subsecs
109+
self.compare_beautiful_description(['sec_26', 'sec_26__subsec_1', 'sec_26__subsec_3'],
110+
'section 26(1), (3)',
111+
commenceable_provisions=section_26)
112+
103113
def test_one_subsection_missing_in_a_part(self):
104114
part_ii = self.make_toc_elements('part_', 'part', ['II'], basic_unit=False, with_brackets=False)
105115
sections_2_to_6 = self.make_toc_elements('part_II__sec_', 'section', range(2, 7), basic_unit=True)

0 commit comments

Comments
 (0)