主要内容: - 包含12个产业的完整教务系统前端代码 - 智能启动脚本 (start-industry.sh) - 可视化产业导航页面 (index.html) - 项目文档 (README.md) 优化内容: - 删除所有node_modules和.yoyo文件夹,从7.5GB减少到2.7GB - 添加.gitignore文件避免上传不必要的文件 - 自动依赖管理和智能启动系统 产业列表: 1. 文旅产业 (5150) 2. 智能制造 (5151) 3. 智能开发 (5152) 4. 财经商贸 (5153) 5. 视觉设计 (5154) 6. 交通物流 (5155) 7. 大健康 (5156) 8. 土木水利 (5157) 9. 食品产业 (5158) 10. 化工产业 (5159) 11. 能源产业 (5160) 12. 环保产业 (5161) 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
99 lines
2.8 KiB
Python
99 lines
2.8 KiB
Python
#!/usr/bin/env python3
|
||
# -*- coding: utf-8 -*-
|
||
|
||
import os
|
||
import re
|
||
|
||
def read_ehs_content():
|
||
"""
|
||
读取EHS项目文件并按章节拆分
|
||
"""
|
||
project_folder = "网页未导入数据/能源产业/学生完成的项目"
|
||
|
||
for file in os.listdir(project_folder):
|
||
if "EHS" in file and file.endswith(".md"):
|
||
file_path = os.path.join(project_folder, file)
|
||
with open(file_path, 'r', encoding='utf-8') as f:
|
||
content = f.read()
|
||
return content, file.replace(".md", "")
|
||
return None, None
|
||
|
||
def parse_sections(content):
|
||
"""
|
||
解析markdown内容,按一级标题拆分成多个板块
|
||
"""
|
||
# 按 # 一级标题拆分内容
|
||
sections = []
|
||
|
||
# 使用正则表达式找到所有一级标题
|
||
pattern = r'^# (.+?)$'
|
||
lines = content.split('\n')
|
||
|
||
current_section = None
|
||
current_content = []
|
||
|
||
for line in lines:
|
||
match = re.match(pattern, line)
|
||
if match:
|
||
# 保存前一个section
|
||
if current_section:
|
||
sections.append({
|
||
'title': current_section,
|
||
'content': '\n'.join(current_content).strip()
|
||
})
|
||
# 开始新的section
|
||
current_section = match.group(1).strip().replace('"', "'")
|
||
current_content = []
|
||
else:
|
||
if current_section: # 只有在有当前section时才添加内容
|
||
current_content.append(line)
|
||
|
||
# 保存最后一个section
|
||
if current_section:
|
||
sections.append({
|
||
'title': current_section,
|
||
'content': '\n'.join(current_content).strip()
|
||
})
|
||
|
||
return sections
|
||
|
||
def generate_sections_code():
|
||
"""
|
||
生成正确格式的sections数组
|
||
"""
|
||
content, title = read_ehs_content()
|
||
if not content:
|
||
print("未找到EHS项目文件")
|
||
return
|
||
|
||
sections = parse_sections(content)
|
||
|
||
# 生成JavaScript代码
|
||
js_code = ' sections: [\n'
|
||
|
||
for i, section in enumerate(sections):
|
||
# 转义特殊字符
|
||
content_escaped = section['content'].replace('\\', '\\\\').replace('`', '\\`').replace('${', '\\${')
|
||
|
||
js_code += ' {\n'
|
||
js_code += f' title: "{section["title"]}",\n'
|
||
js_code += f' content: `{content_escaped}`\n'
|
||
js_code += ' }'
|
||
|
||
if i < len(sections) - 1:
|
||
js_code += ','
|
||
js_code += '\n'
|
||
|
||
js_code += ' ]'
|
||
|
||
# 保存到文件
|
||
with open("ehs_sections_fix.js", 'w', encoding='utf-8') as f:
|
||
f.write(js_code)
|
||
|
||
print(f"✅ 已生成修复后的sections代码")
|
||
print(f"📊 共拆分为 {len(sections)} 个板块:")
|
||
for section in sections:
|
||
print(f" - {section['title']}")
|
||
|
||
if __name__ == "__main__":
|
||
generate_sections_code() |