fix: 修复分隔符预处理逻辑,保留内容分隔符

This commit is contained in:
2025-12-29 04:29:16 +08:00
parent 45368aa2f6
commit 152904a38c
3 changed files with 6 additions and 965 deletions

View File

@@ -61,18 +61,18 @@ class HandoverLogParser:
"""
logs = []
# 预处理:移除分隔符行(只保留内容分隔符,去掉单行的
# 分隔符应该是独立一行,且前后有内容的
# 预处理:移除单行分隔符(前后都是空行的分隔符
# 保留真正的内容分隔符(前后有内容的
lines = text.split('\n')
processed_lines = []
i = 0
while i < len(lines):
line = lines[i]
if line.strip() == self.SEPARATOR:
# 检查是否是单行分隔符(前后都是分隔符或空行
prev_is_sep = i > 0 and lines[i-1].strip() == self.SEPARATOR
next_is_sep = i < len(lines)-1 and lines[i+1].strip() == self.SEPARATOR
if not (prev_is_sep and next_is_sep):
# 检查是否是单行分隔符(前后都是空行或分隔符)
prev_empty = i == 0 or not lines[i-1].strip() or lines[i-1].strip() == self.SEPARATOR
next_empty = i == len(lines) - 1 or not lines[i+1].strip() or lines[i+1].strip() == self.SEPARATOR
if prev_empty and next_empty:
# 单行分隔符,跳过
i += 1
continue