File tree Expand file tree Collapse file tree 3 files changed +467
-3
lines changed Expand file tree Collapse file tree 3 files changed +467
-3
lines changed Original file line number Diff line number Diff line change @@ -141,10 +141,15 @@ def get_top_level_sections(soup):
141141 all but bibliography sections
142142 """
143143 section_wrappers = soup .find_all ("article" , attrs = {"role" : "main" })
144+ top_level_sections = []
144145
145146 # test case for partial files, not expected in production
146147 if len (section_wrappers ) == 0 :
147148 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 )
148153 elif len (section_wrappers ) != 1 :
149154 article = soup .find ('article' , attrs = {"role" : "main" })
150155 try :
@@ -156,16 +161,15 @@ def get_top_level_sections(soup):
156161 return None , None
157162 else :
158163 main = section_wrappers [0 ]
159- sections = []
160164
161165 for element in main .children :
162166 if (
163167 element .name == "section" and
164168 element .get ('id' ) != "bibliography"
165169 ):
166- sections .append (element )
170+ top_level_sections .append (element )
167171
168- return sections
172+ return top_level_sections
169173
170174
171175def get_main_section (soup ):
You can’t perform that action at this time.
0 commit comments