Files
deep/merge.py
T
2026-05-07 16:51:15 +08:00

54 lines
2.9 KiB
Python

import re
with open('code_compression_intro_V2.html', 'r', encoding='utf-8') as f:
code_html = f.read()
with open('interrupt_realtime_wingsemi.html', 'r', encoding='utf-8') as f:
interrupt_html = f.read()
start_idx = interrupt_html.find('<!-- 2. 核心技术:指令集优化')
end_idx = interrupt_html.find('<script>')
if end_idx == -1: end_idx = len(interrupt_html)
interrupt_sections = interrupt_html[start_idx:end_idx].strip()
transition_html = '''
<!-- 模块过渡 -->
<section class="py-24 bg-[#0f172a] border-t border-gray-800 text-center relative overflow-hidden">
<div class="container mx-auto px-4 relative z-10">
<div class="inline-block px-4 py-1.5 rounded-full bg-secondary/20 border border-secondary/30 !text-secondary font-semibold text-xl mb-6 animate-fade-in">
第二项核心技术
</div>
<h1 class="text-4xl md:text-5xl font-bold !text-white mb-6 animate-fade-in">
中断实时性<span class="text-transparent bg-clip-text bg-gradient-to-r from-primary to-[#38bdf8]">增强技术</span>
</h1>
<p class="text-lg md:text-xl !text-gray-300 max-w-3xl mx-auto animate-fade-in mb-8 leading-relaxed">
通过自定义指令集优化压栈出栈,并行处理上下文切换,打破传统 RISC-V 中断响应瓶颈,实现微秒级确定性响应。
</p>
</div>
</section>
'''
code_html = code_html.replace('代码密度增强技术\n </h1>', '知识中心\n </h1>')
code_html = code_html.replace('超越行业标杆 ARM 的技术突破', '隼瞻科技 核心技术解析')
code_html = re.sub(r'针对 RISC-V 指令集特性深度优化.*代码密度表现。', '探索基于 RISC-V 架构的突破性创新,从超越行业标杆的<b>代码密度增强技术</b>,到实现微秒级响应的<b>中断实时性增强技术</b>,我们致力于从底层架构实现超凡性能优化。', code_html, flags=re.DOTALL)
# also replace the code compression section start to give it a title
code_html = code_html.replace('<!-- 背景痛点 -->', '''
<section class="py-12 bg-[#1e293b] text-center border-b border-gray-800">
<div class="inline-block px-4 py-1.5 rounded-full bg-primary/20 border border-primary/30 !text-primary font-semibold text-xl mb-6 animate-fade-in">
第一项核心技术
</div>
<h2 class="text-4xl font-bold !text-white animate-fade-in">代码密度增强技术</h2>
</section>
<!-- 背景痛点 -->''')
target = '</main>'
new_html = code_html.replace(target, transition_html + '\n' + interrupt_sections + '\n' + target)
with open('knowledge_center.html', 'w', encoding='utf-8') as f:
f.write(new_html)
print('Merge successful')