生成英文版摘要文件,用于发布到Medium、Dev.to等英文博客平台 :param weekly_no: 期号 :param pub_date: 发布日期 :param en_weekly_file: 英文周刊文件路径
(weekly_no, pub_date, en_weekly_file)
| 352 | write_summary_content(f, content_meta, md_body, weekly_no) |
| 353 | |
| 354 | def write_to_md_file_en(weekly_no, pub_date, en_weekly_file): |
| 355 | """ |
| 356 | 生成英文版摘要文件,用于发布到Medium、Dev.to等英文博客平台 |
| 357 | :param weekly_no: 期号 |
| 358 | :param pub_date: 发布日期 |
| 359 | :param en_weekly_file: 英文周刊文件路径 |
| 360 | """ |
| 361 | # 从英文版文件中读取真正的内容和元数据 |
| 362 | if os.path.exists(en_weekly_file): |
| 363 | en_content_meta = get_front_matter(en_weekly_file) |
| 364 | en_content_body = content_to_string(read_md(en_weekly_file)) |
| 365 | else: |
| 366 | print(f"Warning: English weekly file not found: {en_weekly_file}") |
| 367 | return None |
| 368 | |
| 369 | if en_content_meta: |
| 370 | en_content_meta['title'] = build_english_weekly_title(en_content_meta.get('title', ''), weekly_no) |
| 371 | en_content_meta['description'] = build_english_description(en_content_meta.get('description', '')) |
| 372 | |
| 373 | # 生成英文版摘要文件 |
| 374 | en_summary_dir = 'docs/en' |
| 375 | if not os.path.exists(en_summary_dir): |
| 376 | os.makedirs(en_summary_dir) |
| 377 | |
| 378 | en_summary_file = os.path.join(en_summary_dir, f"{pub_date}-weekly.md") |
| 379 | print("Writing English version summary...") |
| 380 | with open(en_summary_file, 'w', encoding='utf-8') as f: |
| 381 | write_summary_content(f, en_content_meta, en_content_body, weekly_no, is_english=True) |
| 382 | |
| 383 | return en_summary_file, en_content_meta |
| 384 | |
| 385 | def set_title(no): |
| 386 | """ |
no test coverage detected