Spaces:
Running
Running
1one2two commited on
Commit ·
860bc4d
1
Parent(s): 2025d11
feat: 調整 UI; 去除 AI 風格
Browse files534 unmodified lines53553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787834 unmodified lines91391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310 unmodified lines103410351036103710381039104010414 unmodified lines10461047104810491050105110521053105410551056105710581059106010611062534 unmodified lines["example.md", "template.pptx"],]# 視覺主題:以霧白、深 slate 與皇家藍,呈現簡潔的編輯工作室氛圍。APP_CSS = """:root {--bg: #f8fafc;--col: #1e293b;--studio-ink: var(--col);--studio-ink-soft: #475569;--studio-paper: var(--bg);--studio-card: #ffffff;--studio-line: #e2e8f0;--studio-accent: #2563eb;--studio-accent-dark: #1d4ed8;--studio-mint: #dbeafe;}body,.gradio-container {background: var(--studio-paper) !important;color: var(--studio-ink) !important;}.gradio-container {max-width: 1180px !important;margin: 0 auto !important;padding: 28px 24px 48px !important;font-family: Inter, "Noto Sans TC", "PingFang TC", system-ui, sans-serif !important;}.hero-shell {position: relative;overflow: hidden;min-height: 322px;padding: 48px 52px;border-radius: 28px;background: var(--studio-ink);color: #f8fafc;box-shadow: 0 24px 70px rgba(30, 41, 59, 0.14);}.hero-shell::after {content: "";position: absolute;top: -104px;right: -68px;width: 360px;height: 360px;border: 72px solid var(--studio-accent);border-radius: 50%;opacity: 0.92;}.hero-shell::before {content: "M↓ / P↑";position: absolute;right: 56px;bottom: 42px;z-index: 1;color: var(--studio-mint);font: 700 14px/1 ui-monospace, SFMono-Regular, Menlo, monospace;letter-spacing: 0.16em;}.hero-copy {position: relative;z-index: 2;max-width: 710px;}.eyebrow,.section-kicker {display: flex;align-items: center;gap: 10px;margin-bottom: 20px;font-size: 12px;font-weight: 800;letter-spacing: 0.16em;text-transform: uppercase;}.eyebrow { color: var(--studio-mint); }.eyebrow-dot {width: 8px;height: 8px;border-radius: 50%;background: var(--studio-accent);}.hero-shell h1 {max-width: 680px;margin: 0 !important;color: #f8fafc !important;font-size: clamp(42px, 6vw, 70px) !important;font-weight: 760 !important;line-height: 0.98 !important;letter-spacing: -0.055em !important;}.hero-shell h1 span { color: var(--studio-mint); }.hero-shell p {max-width: 610px;margin: 24px 0 0 !important;color: #cbd5e1 !important;font-size: 16px !important;line-height: 1.7 !important;}.hero-meta {display: flex;flex-wrap: wrap;gap: 10px;margin-top: 28px;}.hero-meta span {padding: 7px 12px;border: 1px solid rgba(255, 255, 255, 0.18);border-radius: 999px;color: #f1f5f9;font-size: 12px;}.workspace-row { margin-top: 22px; gap: 22px; }.workspace-card,.guide-card,.results-shell {border: 1px solid var(--studio-line) !important;border-radius: 22px !important;background: var(--studio-card) !important;box-shadow: 0 10px 32px rgba(30, 41, 59, 0.06) !important;}.workspace-card { padding: 28px !important; }.guide-card { padding: 28px !important; }.results-shell { margin-top: 22px; padding: 28px !important; }.section-heading {display: flex;align-items: flex-start;gap: 14px;margin-bottom: 20px;}.step-number {display: grid;flex: 0 0 38px;width: 38px;height: 38px;place-items: center;border-radius: 50%;background: var(--studio-ink);color: #fff;font: 700 12px/1 ui-monospace, SFMono-Regular, Menlo, monospace;}.section-heading h2,.results-heading h2 {margin: 0 !important;color: var(--studio-ink) !important;font-size: 22px !important;line-height: 1.2 !important;letter-spacing: -0.025em !important;}.section-heading p,.results-heading p {margin: 5px 0 0 !important;color: var(--studio-ink-soft) !important;font-size: 13px !important;}.input-mode label {border-radius: 999px !important;}.file-drop,.markdown-editor,.status-box {border-color: var(--studio-line) !important;border-radius: 15px !important;background: #fff !important;}.template-wrap { margin-top: 18px; }.convert-button {min-height: 52px !important;margin-top: 20px !important;border: 0 !important;border-radius: 14px !important;background: var(--studio-accent) !important;color: white !important;font-weight: 800 !important;letter-spacing: 0.02em !important;box-shadow: 0 8px 20px rgba(37, 99, 235, 0.24) !important;transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease !important;}.convert-button:hover {transform: translateY(-2px);background: var(--studio-accent-dark) !important;box-shadow: 0 12px 24px rgba(29, 78, 216, 0.28) !important;}.guide-title {margin: 0 0 22px;color: var(--studio-ink);font-size: 20px;letter-spacing: -0.02em;}.guide-list { display: grid; gap: 8px; }.guide-item {display: grid;grid-template-columns: 34px 1fr;gap: 12px;padding: 14px 0;border-bottom: 1px solid var(--studio-line);}.guide-item:last-child { border-bottom: 0; }.guide-icon {color: var(--studio-accent);font: 800 13px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace;}.guide-item strong {display: block;margin-bottom: 3px;color: var(--studio-ink);font-size: 14px;}.guide-item span {color: var(--studio-ink-soft);font-size: 12px;line-height: 1.55;}.format-note {margin-top: 20px;padding: 16px;border-radius: 14px;background: #f1f5f9;color: #475569;font-size: 12px;line-height: 1.65;}.format-note b { color: var(--studio-ink); }.results-heading {display: flex;align-items: flex-end;justify-content: space-between;margin-bottom: 18px;}.results-heading .section-kicker {margin: 0 0 6px;color: var(--studio-accent-dark);}.result-grid { gap: 14px; }.result-file {min-height: 128px;border-radius: 15px !important;background: #fff !important;}.preview-heading {display: flex;align-items: baseline;justify-content: space-between;gap: 16px;margin: 24px 0 12px;}.preview-heading h3 {margin: 0;color: var(--studio-ink);font-size: 17px;letter-spacing: -0.015em;}.preview-heading span {color: var(--studio-ink-soft);font-size: 12px;}.pdf-preview {overflow: hidden !important;border: 1px solid var(--studio-line) !important;border-radius: 16px !important;background: #f1f5f9 !important;}.pdf-preview img {background: white !important;object-fit: contain !important;}.status-box {margin-top: 0 !important;overflow: hidden !important;}/* Gradio 會在 Textbox 外再建立一層 form;兩層都需要相同圓角。 */.results-shell .form:has(.status-box),.status-box,.status-box > label,.status-box > .wrap {border-radius: 15px !important;}.results-shell .form:has(.status-box) {margin-top: 14px !important;overflow: hidden !important;}.status-box textarea {border-radius: 0 0 14px 14px !important;}.examples-shell {margin-top: 22px;padding: 24px 28px !important;border-top: 1px solid var(--studio-line) !important;}.examples-shell h3 {color: var(--studio-ink) !important;font-size: 16px !important;}.site-footer {display: flex;justify-content: space-between;gap: 18px;padding: 28px 4px 0;color: #64748b;font-size: 12px;}.site-footer a { color: var(--studio-accent-dark) !important; }@media (max-width: 720px) {.gradio-container { padding: 14px 12px 32px !important; }.hero-shell { min-height: 370px; padding: 34px 26px; border-radius: 22px; }.hero-shell::after { top: -110px; right: -150px; }.hero-shell::before { right: 24px; bottom: 25px; }.workspace-card, .guide-card, .results-shell { padding: 22px !important; }.results-heading, .preview-heading, .site-footer { align-items: flex-start; flex-direction: column; }}"""34 unmodified lines# 設定 Gradio 介面with gr.Blocks(title="Markdown → Slides") as iface:gr.HTML("""<header class="hero-shell"><div class="hero-copy"><div class="eyebrow"><span class="eyebrow-dot"></span>Markdown → Slides Studio</div><h1>把文字,變成<br><span>可編輯的簡報。</span></h1><p>貼上 Markdown 或上傳檔案,套用你的 PowerPoint 模板,一次取得可編輯的 PPTX 與方便分享的 PDF。</p><div class="hero-meta"><span>PPTX + PDF</span><span>自訂模板</span><span>HTTPS 圖片</span><span>中文支援</span></div></div></header>""")with gr.Row(elem_classes=["workspace-row"]):with gr.Column(scale=7, min_width=360, elem_classes=["workspace-card"]):gr.HTML("""<div class="section-heading"><span class="step-number">01</span><div><h2>加入 Markdown</h2><p>選擇上傳檔案,或直接在瀏覽器中編輯內容。</p></div></div>""")input_type = gr.Radio(["Upload Markdown File", "Enter Markdown Text"],label="輸入方式 · Input mode",value="Upload Markdown File",elem_classes=["input-mode"],)markdown_file = gr.File(label="Markdown 檔案",file_types=[".md", ".markdown"],visible=True,elem_classes=["file-drop"],)markdown_text = gr.Textbox(label="Markdown 內容",lines=12,placeholder="# 簡報標題\n\n## 第一個章節\n\n- 輸入重點內容\n- 加入圖片或表格",visible=False,elem_classes=["markdown-editor"],)gr.HTML("""<div class="section-heading template-wrap"><span class="step-number">02</span><div><h2>套用簡報模板</h2><p>選填;未上傳時會使用 Pandoc 預設版型。</p></div></div>""")template_file = gr.File(label="PowerPoint 模板 · Optional",file_types=[".pptx"],elem_classes=["file-drop"],)input_type.change(update_visibility,inputs=input_type,outputs=[markdown_file, markdown_text],)submit_button = gr.Button("製作簡報 →",variant="primary",elem_classes=["convert-button"],)with gr.Column(scale=4, min_width=280, elem_classes=["guide-card"]):gr.HTML("""<div class="section-kicker">Before you export</div><h2 class="guide-title">三件小事,讓轉換更順利</h2><div class="guide-list"><div class="guide-item"><div class="guide-icon">A.</div><div><strong>用標題建立投影片結構</strong><span>Markdown 標題會協助 Pandoc 判斷章節與投影片層級。</span></div></div><div class="guide-item"><div class="guide-icon">B.</div><div><strong>外部圖片請使用 HTTPS</strong><span>支援 PNG、JPEG、GIF、WebP;每張與整份文件皆有 100 MB 上限。</span></div></div><div class="guide-item"><div class="guide-icon">C.</div><div><strong>模板需保留標準版面名稱</strong><span>例如 Title Slide、Section Header、Title and Content、Blank。</span></div></div></div><div class="format-note"><b>模板提示</b><br>PowerPoint 檔案需為 .pptx,且版面配置名稱須符合 Pandoc 慣例。你也可以直接載入下方範例開始測試。</div>""")with gr.Column(elem_classes=["results-shell"]):gr.HTML("""<div class="results-heading"><div><div class="section-kicker">Ready to present</div><h2><span class="step-number" style="display:inline-grid;margin-right:10px">03</span>下載成果</h2></div><p>完成轉換後,檔案會出現在這裡。</p></div>""")with gr.Row(elem_classes=["result-grid"]):output_pptx = gr.File(label="PPTX · 可編輯簡報", elem_classes=["result-file"])output_pdf = gr.File(label="PDF · 分享版本", elem_classes=["result-file"])gr.HTML("""<div class="preview-heading"><h3>PDF 預覽</h3><span>點選頁面可放大檢視;最多顯示前 40 頁。</span></div>""")preview_pdf = gr.Gallery(10 unmodified lineserror_message = gr.Textbox(lines=3,label="轉換紀錄 · Status",placeholder="轉換訊息與錯誤提示會顯示於此。",elem_classes=["status-box"],)4 unmodified lines)with gr.Column(elem_classes=["examples-shell"]):gr.HTML("<h3>快速開始 · Try an example</h3>")gr.Examples(examples=examples,inputs=[markdown_file, template_file],label="範例檔案",)gr.HTML("""<footer class="site-footer"><span>Markdown → Slides Studio</span><span><a href="https://blog.toolman.xyz/article/306/" target="_blank">使用說明</a> · Markdown in, presentation out.</span></footer>""")534 unmodified lines53553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110134 unmodified lines11361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130310 unmodified lines131413151316131713181319132013214 unmodified lines132613271328132913301331133213331334133513361337133813391340134113421343534 unmodified lines["example.md", "template.pptx"],]# 視覺主題:簡報製作桌。保留霧白、深 slate 與皇家藍色票。APP_CSS = """:root {--bg: #f8fafc;--col: #1e293b;--muted: #475569;--paper: #ffffff;--rule: #e2e8f0;--action: #2563eb;--action-dark: #1d4ed8;--action-soft: #dbeafe;}body,.gradio-container {background: var(--bg) !important;color: var(--col) !important;}.gradio-container {max-width: 1240px !important;margin: 0 auto !important;padding: 0 28px 56px !important;font-family: Aptos, "Noto Sans TC", "PingFang TC", "Microsoft JhengHei",sans-serif !important;}.topbar {display: flex;min-height: 72px;align-items: center;justify-content: space-between;border-bottom: 1px solid var(--rule);}.wordmark {display: flex;align-items: center;gap: 11px;color: var(--col);font-size: 16px;}.wordmark-mark {display: grid;width: 28px;height: 28px;place-items: center;background: var(--col);color: var(--paper);font-weight: 800;}.wordmark strong {font-family: "Arial Narrow", "Aptos Display", "Noto Sans TC","PingFang TC", sans-serif;font-size: 18px;letter-spacing: -0.02em;}.topbar-note {display: flex;align-items: center;gap: 9px;color: var(--muted);font-size: 12px;}.topbar-note::before {content: "";width: 7px;height: 7px;border-radius: 50%;background: var(--action);}.hero-grid {display: grid;grid-template-columns: minmax(0, 0.88fr) minmax(440px, 1.12fr);gap: clamp(40px, 7vw, 88px);align-items: center;padding: clamp(54px, 8vw, 96px) 0;border-bottom: 1px solid var(--rule);}.hero-copy h1 {max-width: 620px;margin: 0 !important;color: var(--col) !important;font-family: "Arial Narrow", "Aptos Display", "Noto Sans TC","PingFang TC", sans-serif !important;font-size: clamp(52px, 7vw, 88px) !important;font-stretch: condensed;font-weight: 800 !important;line-height: 0.94 !important;letter-spacing: -0.055em !important;}.hero-copy p {max-width: 540px;margin: 28px 0 0 !important;color: var(--muted) !important;font-size: 18px !important;line-height: 1.7 !important;}.hero-footnote {max-width: 470px;margin-top: 28px;padding-left: 13px;border-left: 3px solid var(--action);color: var(--muted);font-size: 12px;line-height: 1.55;}.transform-visual {position: relative;display: grid;grid-template-columns: minmax(0, 0.82fr) 54px minmax(0, 1.18fr);align-items: center;}.source-sheet,.slide-canvas {position: relative;min-height: 306px;border: 1px solid var(--rule);background: var(--paper);}.source-sheet {z-index: 2;transform: rotate(-1.5deg);}.sheet-bar,.slide-bar {display: flex;min-height: 38px;align-items: center;justify-content: space-between;padding: 0 14px;border-bottom: 1px solid var(--rule);color: var(--muted);font-size: 11px;}.sheet-lines {padding: 23px 20px;font-family: "SFMono-Regular", Consolas, monospace;font-size: 11px;line-height: 1.9;}.sheet-lines p { margin: 0 !important; color: var(--muted) !important; }.sheet-lines b { color: var(--action); font-weight: 700; }.sheet-lines .dim { opacity: 0.58; }.transform-track {position: relative;z-index: 1;height: 2px;background: var(--action);}.transform-track::after {content: "";position: absolute;top: 50%;right: -1px;width: 9px;height: 9px;border-top: 2px solid var(--action);border-right: 2px solid var(--action);transform: translateY(-50%) rotate(45deg);}.slide-canvas {z-index: 2;min-height: 340px;border-top: 5px solid var(--action);box-shadow: 16px 18px 0 var(--action-soft);}.slide-content {display: flex;min-height: 296px;flex-direction: column;justify-content: center;padding: 28px 32px;}.slide-content h3 {max-width: 360px;margin: 0 0 22px !important;color: var(--col) !important;font-family: "Arial Narrow", "Aptos Display", "Noto Sans TC","PingFang TC", sans-serif;font-size: clamp(26px, 3vw, 39px) !important;line-height: 1.03 !important;letter-spacing: -0.04em !important;}.slide-content ul {margin: 0;padding-left: 18px;color: var(--muted);font-size: 12px;line-height: 1.8;}.section-title {display: grid;grid-template-columns: 64px minmax(0, 1fr);gap: 20px;padding: 42px 0 18px;}.section-index {padding-top: 6px;border-top: 3px solid var(--action);color: var(--action-dark);font-size: 13px;font-weight: 800;}.section-title h2 {margin: 0 !important;color: var(--col) !important;font-family: "Arial Narrow", "Aptos Display", "Noto Sans TC","PingFang TC", sans-serif !important;font-size: 32px !important;font-weight: 750 !important;letter-spacing: -0.035em !important;}.section-title p {max-width: 620px;margin: 5px 0 0 !important;color: var(--muted) !important;font-size: 13px !important;line-height: 1.55 !important;}.workbench-shell,.export-shell {overflow: hidden !important;gap: 0 !important;border: 1px solid var(--rule) !important;border-radius: 8px !important;background: var(--paper) !important;}.workbench-grid {gap: 0 !important;align-items: stretch !important;}.source-pane,.template-pane {padding: 28px !important;background: var(--paper) !important;}.source-pane {border-right: 1px solid var(--rule) !important;}.pane-heading {margin-bottom: 20px;}.pane-heading h3 {margin: 0 !important;color: var(--col) !important;font-size: 18px !important;letter-spacing: -0.02em !important;}.pane-heading p {max-width: 520px;margin: 5px 0 0 !important;color: var(--muted) !important;font-size: 12px !important;line-height: 1.55 !important;}.input-mode label {border-radius: 4px !important;}.file-drop,.markdown-editor,.status-box,.result-file {border-color: var(--rule) !important;border-radius: 5px !important;background: var(--paper) !important;}.requirement-list {margin: 22px 0 0;padding: 0;list-style: none;border-top: 1px solid var(--rule);}.requirement-list li {display: grid;grid-template-columns: 16px 1fr;gap: 10px;padding: 13px 0;border-bottom: 1px solid var(--rule);color: var(--muted);font-size: 12px;line-height: 1.5;}.requirement-list li::before {content: "✓";color: var(--action);font-weight: 800;}.template-note {margin-top: 18px;padding-left: 13px;border-left: 3px solid var(--action);color: var(--muted);font-size: 12px;line-height: 1.6;}.template-note strong { color: var(--col); }.convert-button {min-height: 58px !important;margin: 0 !important;border: 0 !important;border-top: 1px solid var(--action-dark) !important;border-radius: 0 !important;background: var(--action) !important;color: var(--paper) !important;font-size: 15px !important;font-weight: 800 !important;box-shadow: none !important;}.convert-button:hover {background: var(--action-dark) !important;}.convert-button:focus-visible,.gradio-container button:focus-visible,.gradio-container input:focus-visible,.gradio-container textarea:focus-visible,.gradio-container a:focus-visible {outline: 3px solid var(--action-soft) !important;outline-offset: 2px !important;}.export-shell {padding: 28px !important;}.result-grid {gap: 12px !important;}.result-file {min-height: 116px;}.preview-heading {display: flex;align-items: baseline;justify-content: space-between;gap: 16px;margin: 32px 0 12px;padding-top: 24px;border-top: 1px solid var(--rule);}.preview-heading h3 {margin: 0 !important;color: var(--col) !important;font-size: 17px !important;letter-spacing: -0.02em !important;}.preview-heading span {color: var(--muted);font-size: 12px;}.pdf-preview {overflow: hidden !important;border: 1px solid var(--rule) !important;border-radius: 5px !important;background: var(--bg) !important;}.pdf-preview img {background: var(--paper) !important;object-fit: contain !important;}.status-box {margin-top: 0 !important;overflow: hidden !important;}.export-shell .form:has(.status-box),.status-box,.status-box > label,.status-box > .wrap {border-radius: 5px !important;}.export-shell .form:has(.status-box) {overflow: hidden !important;margin-top: 14px !important;}.status-box textarea {border-radius: 0 0 4px 4px !important;}.examples-shell {margin-top: 34px;padding: 20px 0 0 !important;border-top: 1px solid var(--rule) !important;}.examples-shell h3 {margin: 0 0 12px !important;color: var(--col) !important;font-size: 15px !important;}.site-footer {display: flex;justify-content: space-between;gap: 18px;padding: 34px 0 0;color: #64748b;font-size: 12px;}.site-footer a {color: var(--action-dark) !important;text-underline-offset: 3px;}@media (max-width: 900px) {.hero-grid {grid-template-columns: 1fr;}.transform-visual {max-width: 680px;}}@media (max-width: 700px) {.source-pane {border-right: 0 !important;border-bottom: 1px solid var(--rule) !important;}}@media (max-width: 620px) {.gradio-container {padding: 0 14px 36px !important;}.topbar {min-height: 62px;}.topbar-note {max-width: 160px;justify-content: flex-end;text-align: right;}.hero-grid {gap: 42px;padding: 48px 0 58px;}.hero-copy h1 {font-size: 50px !important;}.transform-visual {grid-template-columns: 0.86fr 28px 1.14fr;}.source-sheet,.slide-canvas {min-height: 230px;}.slide-canvas {min-height: 250px;box-shadow: 8px 10px 0 var(--action-soft);}.sheet-lines {overflow: hidden;padding: 18px 12px;font-size: 9px;white-space: nowrap;}.slide-content {min-height: 206px;padding: 18px;}.slide-content h3 {font-size: 22px !important;}.slide-content ul {font-size: 10px;}.section-title {grid-template-columns: 44px minmax(0, 1fr);gap: 14px;}.section-title h2 {font-size: 27px !important;}.source-pane,.template-pane,.export-shell {padding: 20px !important;}.preview-heading,.site-footer {align-items: flex-start;flex-direction: column;}}@media (prefers-reduced-motion: reduce) {*,*::before,*::after {scroll-behavior: auto !important;transition-duration: 0.01ms !important;animation-duration: 0.01ms !important;}}"""34 unmodified lines# 設定 Gradio 介面with gr.Blocks(title="Markdown → Slides") as iface:gr.HTML("""<header class="topbar"><div class="wordmark"><span class="wordmark-mark">#</span><strong>md / ppt</strong></div><div class="topbar-note">PPTX、PDF 與中文內容皆可使用</div></header><section class="hero-grid"><div class="hero-copy"><h1>從大綱到<br>投影片,少一道工。</h1><p>把 Markdown 交給轉換器,保留清楚的內容層級,並一次取得可編輯的 PPTX 和方便分享的 PDF。</p><div class="hero-footnote">直接貼上內容,或上傳既有的 Markdown;需要品牌版型時再加入 PowerPoint 模板。</div></div><div class="transform-visual" aria-label="Markdown 轉換為投影片的示意圖"><div class="source-sheet"><div class="sheet-bar"><span>outline.md</span><span>18 行</span></div><div class="sheet-lines"><p><b>#</b> 第三季產品回顧</p><p class="dim">用數據整理這一季的進展</p><p> </p><p><b>##</b> 我們完成了什麼</p><p><b>-</b> 核心流程重新設計</p><p><b>-</b> 交付時間縮短 32%</p><p><b>-</b> 滿意度提升至 94%</p></div></div><div class="transform-track" aria-hidden="true"></div><div class="slide-canvas"><div class="slide-bar"><span>03 / 12</span><span>季度回顧</span></div><div class="slide-content"><h3>我們完成了什麼</h3><ul><li>核心流程重新設計</li><li>交付時間縮短 32%</li><li>滿意度提升至 94%</li></ul></div></div></div></section>""")gr.HTML("""<div class="section-title"><span class="section-index">01</span><div><h2>準備內容</h2><p>選擇內容來源並決定是否套用自訂版型。兩個欄位確認完成後即可開始轉換。</p></div></div>""")with gr.Column(elem_classes=["workbench-shell"]):with gr.Row(elem_classes=["workbench-grid"]):with gr.Column(scale=7, min_width=360, elem_classes=["source-pane"]):gr.HTML("""<div class="pane-heading"><h3>內容來源</h3><p>上傳檔案適合既有文件;直接輸入適合快速草擬。</p></div>""")input_type = gr.Radio([("上傳 Markdown", "Upload Markdown File"),("直接貼上文字", "Enter Markdown Text"),],label="輸入方式",value="Upload Markdown File",elem_classes=["input-mode"],)markdown_file = gr.File(label="Markdown 檔案",file_types=[".md", ".markdown"],visible=True,elem_classes=["file-drop"],)markdown_text = gr.Textbox(label="Markdown 內容",lines=13,placeholder=("# 簡報標題\n\n""## 第一個章節\n\n""- 輸入重點內容\n""- 加入圖片或表格"),visible=False,elem_classes=["markdown-editor"],)with gr.Column(scale=4, min_width=280, elem_classes=["template-pane"]):gr.HTML("""<div class="pane-heading"><h3>簡報版型</h3><p>這是選填項目。留白時會使用 Pandoc 的預設版型。</p></div>""")template_file = gr.File(label="PowerPoint 模板",file_types=[".pptx"],elem_classes=["file-drop"],)gr.HTML("""<ul class="requirement-list"><li>模板檔案必須是 PPTX 格式。</li><li>外部圖片需使用 HTTPS,支援 PNG、JPEG、GIF、WebP。</li><li>圖片每張與整份文件的上限皆為 100 MB。</li></ul><div class="template-note"><strong>版面名稱很重要。</strong>請保留 Title Slide、Section Header、Title and Content 或 Blank 等 Pandoc 標準名稱。</div>""")input_type.change(update_visibility,inputs=input_type,outputs=[markdown_file, markdown_text],)submit_button = gr.Button("產生 PPTX 與 PDF",variant="primary",elem_classes=["convert-button"],)gr.HTML("""<div class="section-title"><span class="section-index">02</span><div><h2>取得簡報</h2><p>轉換完成後下載可編輯版本,或先在頁面中確認 PDF。</p></div></div>""")with gr.Column(elem_classes=["export-shell"]):with gr.Row(elem_classes=["result-grid"]):output_pptx = gr.File(label="可編輯簡報(PPTX)",elem_classes=["result-file"],)output_pdf = gr.File(label="分享版本(PDF)",elem_classes=["result-file"],)gr.HTML("""<div class="preview-heading"><h3>檢查 PDF 頁面</h3><span>點選頁面可以放大;畫面最多顯示前 40 頁。</span></div>""")preview_pdf = gr.Gallery(10 unmodified lineserror_message = gr.Textbox(lines=3,label="轉換記錄",placeholder="完成狀態或需要處理的問題會顯示在這裡。",elem_classes=["status-box"],)4 unmodified lines)with gr.Column(elem_classes=["examples-shell"]):gr.HTML("<h3>還沒有內容?從範例開始</h3>")gr.Examples(examples=examples,inputs=[markdown_file, template_file],label="載入範例",)gr.HTML("""<footer class="site-footer"><span>md / ppt</span><span><a href="https://blog.toolman.xyz/article/306/"target="_blank">查看 Markdown 簡報寫法</a></span></footer>""")
main.py+585-304