cmvr-visual/scripts/render_manuals.py
zhanghao 88cf14d794 feat: consolidate story studio and editable automatic production
Restructure backend and frontend modules; add story, library, and editor schema migrations.

Support editable automatic production, manual confirmation modes, account and user lifecycle management, compact container scrolling, consistent forms, and per-task result previews.

Update inference and TTS scheduling, deployment guidance, and regression coverage; remove obsolete standalone pages and temporary acceptance artifacts.
2026-11-14 14:07:26 +08:00

67 lines
6.6 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from pathlib import Path
import html,re
root=Path(__file__).resolve().parents[1]
out=root/'frontend/public/help';out.mkdir(parents=True,exist_ok=True)
def inline(value):
value=html.escape(value)
value=re.sub(r'`([^`]+)`',r'<code>\1</code>',value)
value=re.sub(r'\*\*([^*]+)\*\*',r'<strong>\1</strong>',value)
def link(m):
dest=m[2]
if dest in ['操作手册_20261111.md','../操作手册_20261111.md']:dest='manual.html'
if dest=='鲲鹏长视频制作指南_20261111.md':dest='kunpeng.html'
if dest=='锚定工作室操作手册_20261111.md':dest='story.html'
if dest=='图生图与视频人物替换操作手册_20261112.md':dest='editing.html'
if dest=='design/2026-11-12-production-workflow-design.md':dest='production.html'
if not (dest.startswith('https://') or dest in ['manual.html','kunpeng.html','story.html','editing.html','production.html']):return m[1]
return '<a href="'+dest+'">'+m[1]+'</a>'
return re.sub(r'\[([^]]+)\]\(([^)]+)\)',link,value)
css='''body{margin:0;background:#f4f7f9;color:#1e293b;font:16px/1.85 "Microsoft YaHei",system-ui,sans-serif}a{color:#09685b}header{background:#112b32;color:#edf7f4;padding:28px max(5vw,20px)}header a{color:#a9ecda;margin-right:22px}main{max-width:1320px;margin:auto;display:grid;grid-template-columns:245px minmax(0,1fr);gap:30px;padding:28px}aside{align-self:start;position:sticky;top:20px;font-size:13px;max-height:90vh;overflow:auto}aside a{display:block;margin:7px 0}article{min-width:0;background:white;padding:36px;border-radius:12px;box-shadow:0 5px 30px #1330360a}h1{font-size:30px;line-height:1.5}h2{font-size:23px;margin-top:38px;border-bottom:1px solid #dbe5e9;padding-bottom:12px;scroll-margin-top:15px}h3{font-size:19px;margin-top:28px}p,li{overflow-wrap:anywhere}li{margin-bottom:10px}code{font:14px/1.6 Consolas,monospace;background:#edf2f5;padding:2px 5px;border-radius:4px;overflow-wrap:anywhere}pre{background:#102731;color:#d9ece7;padding:20px;overflow:auto;border-radius:8px}pre code{background:none;color:inherit;padding:0}blockquote{border-left:4px solid #60ae9a;margin:20px 0;padding:12px 20px;background:#eff7f4}.table-scroll{overflow:auto}table{border-collapse:collapse;width:100%;font-size:14px}th,td{border:1px solid #dbe5e9;padding:10px 12px;text-align:left;min-width:95px;vertical-align:top}th{background:#edf4f3}footer{margin-top:35px;color:#64748b;font-size:13px}@media(max-width:800px){main{display:block;padding:14px}aside{position:static;max-height:none;margin-bottom:20px}article{padding:20px}h1{font-size:25px}body{font-size:15px}}@media print{header,aside{display:none}main{display:block;padding:0}article{box-shadow:none;padding:0}h2{break-after:avoid}table{font-size:10px}a{color:inherit}}'''
for source,target,title in [('操作手册_20261111.md','manual','操作手册'),('鲲鹏长视频制作指南_20261111.md','kunpeng','鲲鹏长视频制作指南'),('锚定工作室操作手册_20261111.md','story','锚定工作室操作手册'),('图生图与视频人物替换操作手册_20261112.md','editing','图生图与视频人物替换'),('design/2026-11-12-production-workflow-design.md','production','功能与生产流程完善方案')]:
text=(root/'docs'/source).read_text(encoding='utf-8')
(out/(target+'.md')).write_text(text,encoding='utf-8')
lines=text.splitlines();parts=[];toc=[];i=0;seq=0;list_type=None
def close_list():
global list_type
if list_type:parts.append('</'+list_type+'>');list_type=None
while i<len(lines):
s=lines[i]
if s.startswith('```'):
close_list();block=[];i+=1
while i<len(lines) and not lines[i].startswith('```'):block.append(lines[i]);i+=1
parts.append('<pre><code>'+html.escape('\n'.join(block))+'</code></pre>');i+=1;continue
if s.startswith('|') and i+1<len(lines) and re.match(r'^\|[\s:|\-]+$',lines[i+1]):
close_list();rows=[];j=i
while j<len(lines) and lines[j].startswith('|'):
if j!=i+1:rows.append([x.strip() for x in lines[j].strip('|').split('|')])
j+=1
parts.append('<div class="table-scroll"><table><thead><tr>'+''.join('<th>'+inline(c)+'</th>' for c in rows[0])+'</tr></thead><tbody>')
for row in rows[1:]:parts.append('<tr>'+''.join('<td>'+inline(c)+'</td>' for c in row)+'</tr>')
parts.append('</tbody></table></div>');i=j;continue
heading=re.match(r'^(#{1,4}) (.+)$',s)
if heading:
close_list();level=len(heading[1]);seq+=1;key=f'section-{seq}'
parts.append(f'<h{level} id="{key}">'+inline(heading[2])+f'</h{level}>')
if level==2:toc.append(f'<a href="#{key}">'+inline(heading[2])+'</a>')
elif s.startswith('> '):close_list();parts.append('<blockquote>'+inline(s[2:])+'</blockquote>')
else:
item=re.match(r'^(?:([-]) |(\d+)\. )(.+)$',s)
if item:
kind='ul' if item[1] else 'ol'
if list_type!=kind:close_list();parts.append('<'+kind+'>');list_type=kind
parts.append('<li>'+inline(item[3])+'</li>')
else:
close_list()
if s.strip():parts.append('<p>'+inline(s)+'</p>')
i+=1
close_list()
page='<!doctype html><html lang="zh-CN"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>'+title+' · CMVR Visual</title><style>'+css+'</style></head><body><header><strong>CMVR Visual · 使用帮助</strong><nav><a href="/studio">返回故事</a><a href="/tasks">查看任务</a><a href="manual.html">操作手册</a><a href="story.html">锚定工作室</a><a href="kunpeng.html">鲲鹏历史分镜</a><a href="'+target+'.md" download>下载Markdown</a><a href="/examples/kunpeng-storyboard.json" download>下载旧版100秒JSON</a><a href="/examples/kunpeng-storyboard-45s.json" download>下载旧版45秒JSON</a></nav></header><main><aside><strong>目录</strong>'+''.join(toc)+'</aside><article>'+''.join(parts)+'<footer>版本:2026-11-11 · 文档随本项目发布。浏览器可打印为PDF。</footer></article></main></body></html>'
page=page.replace('<a href="story.html">锚定工作室</a>', '<a href="story.html">锚定工作室</a><a href="editing.html">图生图 / 视频人物替换</a>')
page=page.replace('<a href="manual.html">操作手册</a>', '<a href="manual.html">操作手册</a><a href="production.html">功能与生产流程</a>')
page=page.replace('版本:2026-11-11', '版本:2026-11-13')
(out/(target+'.html')).write_text(page,encoding='utf-8')
print('Generated 5 HTML manuals with Markdown downloads')