fix(zhihu): 修复文章归档格式问题
PR Test / lint (pull_request) Successful in 1s

1. author 字段清理零宽度空格和换行符,修复 Obsidian 解析
2. 扩展 content_type 条件,answer/zhuanlan 使用文章模板
3. 读取 content.md 时去除 YAML frontmatter
4. generate_frontmatter 正确推断 platform 为 zhihu

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-16 18:19:42 +08:00
parent e288a16944
commit f358c52578
4 changed files with 241 additions and 91 deletions
+33
View File
@@ -101,6 +101,8 @@ class AnalyzeProcessor(BaseProcessor):
content_path = Path(input_data.content_file)
if content_path.exists():
text = content_path.read_text(encoding="utf-8")
# 去除 YAML frontmatter(如果存在)
text = self._strip_frontmatter(text)
content = {"text": text}
# Step 3: 调用 DeepAnalyzer
@@ -254,6 +256,37 @@ class AnalyzeProcessor(BaseProcessor):
return metadata
def _strip_frontmatter(self, text: str) -> str:
"""去除 Markdown 文件中的 YAML frontmatter
Args:
text: 可能包含 frontmatter 的文本
Returns:
去除 frontmatter 后的文本
"""
if not text:
return text
# 检查是否以 --- 开头
if not text.startswith('---'):
return text
# 找到第二个 ---
lines = text.split('\n')
end_index = -1
for i in range(1, len(lines)):
if lines[i].strip() == '---':
end_index = i
break
if end_index == -1:
return text
# 返回 frontmatter 之后的内容(跳过空行)
remaining = '\n'.join(lines[end_index + 1:])
return remaining.lstrip('\n')
def _write_analysis_report(
self,
output_path: Path,