refactor extract_section_content to improve section handling logic
This commit is contained in:
+7
-7
@@ -284,18 +284,18 @@ def extract_section_content(content: str, section_type: str) -> str:
|
||||
return ""
|
||||
|
||||
for line in lines:
|
||||
if pattern.match(line):
|
||||
in_section = True
|
||||
section_level = len(line) - len(line.lstrip('#'))
|
||||
continue
|
||||
|
||||
if in_section:
|
||||
if line.startswith('#'):
|
||||
current_level = len(line) - len(line.lstrip('#'))
|
||||
if current_level <= section_level:
|
||||
in_section = False
|
||||
continue
|
||||
section_content.append(line)
|
||||
else:
|
||||
section_content.append(line)
|
||||
else:
|
||||
section_content.append(line)
|
||||
elif pattern.match(line):
|
||||
in_section = True
|
||||
section_level = len(line) - len(line.lstrip('#'))
|
||||
|
||||
return '\n'.join(section_content)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user