File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -141,10 +141,15 @@ def get_top_level_sections(soup):
141
141
all but bibliography sections
142
142
"""
143
143
section_wrappers = soup .find_all ("article" , attrs = {"role" : "main" })
144
+ top_level_sections = []
144
145
145
146
# test case for partial files, not expected in production
146
147
if len (section_wrappers ) == 0 :
147
148
sections = soup .find_all ('section' )
149
+
150
+ for section in sections :
151
+ if section .find_parent ('section' ) is None :
152
+ top_level_sections .append (section )
148
153
elif len (section_wrappers ) != 1 :
149
154
article = soup .find ('article' , attrs = {"role" : "main" })
150
155
try :
@@ -156,16 +161,15 @@ def get_top_level_sections(soup):
156
161
return None , None
157
162
else :
158
163
main = section_wrappers [0 ]
159
- sections = []
160
164
161
165
for element in main .children :
162
166
if (
163
167
element .name == "section" and
164
168
element .get ('id' ) != "bibliography"
165
169
):
166
- sections .append (element )
170
+ top_level_sections .append (element )
167
171
168
- return sections
172
+ return top_level_sections
169
173
170
174
171
175
def get_main_section (soup ):
You can’t perform that action at this time.
0 commit comments