模糊:标题完全相等(去空白、忽略大小写)
(sections: list[Section], title: str)
| 350 | |
| 351 | |
| 352 | def find_section_by_title(sections: list[Section], title: str) -> Optional[Section]: |
| 353 | """模糊:标题完全相等(去空白、忽略大小写)""" |
| 354 | norm = re.sub(r"\s+", " ", title.strip().lower()) |
| 355 | for s in flatten_sections(sections): |
| 356 | s_norm = re.sub(r"\s+", " ", (s.title or "").strip().lower()) |
| 357 | if s_norm == norm: |
| 358 | return s |
| 359 | return None |