vscode-colaview 0.4.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -109,6 +109,8 @@ export type MdBlock =
109
109
  | { kind: 'heading'; level: 1 | 2 | 3 | 4 | 5 | 6; text: string }
110
110
  | { kind: 'paragraph'; text: string }
111
111
  | { kind: 'code'; text: string; lang: string }
112
+ /** 块级公式:`$$ ... $$`,交给 WebView 的 KaTeX 渲染。 */
113
+ | { kind: 'math'; text: string }
112
114
  | { kind: 'quote'; text: string }
113
115
  | { kind: 'list'; ordered: boolean; items: MdListItem[] }
114
116
  | { kind: 'table'; header: string[]; aligns: string[]; rows: string[][] }
@@ -148,6 +150,25 @@ export function parseBlocksLines(lines: string[]): MdBlock[] {
148
150
  continue;
149
151
  }
150
152
 
153
+ // 块级公式:`$$` 独占一行开合,或 `$$…$$` 单行成块。
154
+ const mathInline = /^\s*\$\$(.+)\$\$\s*$/.exec(line);
155
+ if (mathInline !== null) {
156
+ out.push({ kind: 'math', text: mathInline[1] ?? '' });
157
+ index += 1;
158
+ continue;
159
+ }
160
+ if (/^\s*\$\$\s*$/.test(line)) {
161
+ const buffer: string[] = [];
162
+ index += 1;
163
+ while (index < lines.length && !/^\s*\$\$\s*$/.test(lines[index] ?? '')) {
164
+ buffer.push(lines[index] ?? '');
165
+ index += 1;
166
+ }
167
+ index += 1;
168
+ out.push({ kind: 'math', text: buffer.join('\n') });
169
+ continue;
170
+ }
171
+
151
172
  const heading = /^\s*(#{1,6})\s+(.*?)\s*#*\s*$/.exec(line);
152
173
  if (heading !== null) {
153
174
  const level = (heading[1] ?? '#').length as 1 | 2 | 3 | 4 | 5 | 6;
@@ -315,6 +336,7 @@ export function parseBlocks(markdown: string): MdBlock[] {
315
336
  export function blockPlainText(block: MdBlock): string {
316
337
  if (block.kind === 'heading' || block.kind === 'paragraph') return plainInline(block.text);
317
338
  if (block.kind === 'code') return block.text;
339
+ if (block.kind === 'math') return block.text;
318
340
  if (block.kind === 'quote') return block.text;
319
341
  if (block.kind === 'list') return block.items.map((item) => plainInline(item.text)).join('\n');
320
342
  if (block.kind === 'table') return [block.header, ...block.rows].map((row) => row.join(' | ')).join('\n');
@@ -371,6 +393,11 @@ export function renderBlocksHtml(blocks: readonly MdBlock[]): string {
371
393
  out.push(renderListBlock(block));
372
394
  continue;
373
395
  }
396
+ if (block.kind === 'math') {
397
+ // 语义 HTML 场景没有 KaTeX 运行时,保留 $$ 源码(webview / 放映端可再水合)。
398
+ out.push(`<div class="math-block">\n$$${escapeHtml(block.text)}$$\n</div>`);
399
+ continue;
400
+ }
374
401
  const th = block.header
375
402
  .map((cell, i) => `<th${block.aligns[i] ? ` style="text-align:${block.aligns[i]}"` : ''}>${renderInline(cell)}</th>`)
376
403
  .join('');
@@ -94,9 +94,23 @@ body {
94
94
  .ct-stage .cm-md-table-widget table { border-collapse: collapse; }
95
95
  /* 图形 widget:块级 HTML(内联 SVG)与图,都是一张图占一行。 */
96
96
  .ct-stage .cm-md-html-widget,
97
- .ct-stage .mermaid-svg { line-height: 1; }
97
+ .ct-stage .mermaid-svg {
98
+ line-height: 1;
99
+ text-align: center;
100
+ /* pele 令牌(与文档模式 index.html 的 .cm-md-mermaid 同一映射):
101
+ pele 的 SVG 里写 var(--pele-*),换主题不重画。 */
102
+ --pele-bg: var(--bg-color);
103
+ --pele-fg: var(--text-color);
104
+ --pele-muted: color-mix(in srgb, var(--text-color) 70%, var(--bg-color));
105
+ --pele-line: var(--text-color);
106
+ --pele-surface: color-mix(in srgb, var(--text-color) 18%, var(--bg-color));
107
+ --pele-surface-alt: color-mix(in srgb, var(--text-color) 28%, var(--bg-color));
108
+ --pele-border: color-mix(in srgb, var(--text-color) 45%, var(--bg-color));
109
+ --pele-accent: var(--link-color);
110
+ --pele-radius: 6px;
111
+ }
98
112
  .ct-stage .cm-md-html-widget svg,
99
- .ct-stage .mermaid-svg svg { max-width: 100%; height: auto; }
113
+ .ct-stage .mermaid-svg svg { max-width: 100%; height: auto; display: block; margin: 0 auto; }
100
114
  .ct-stage.presenting {
101
115
  display: flex;
102
116
  align-items: center;
@@ -216,6 +230,13 @@ function slidePageHtml(slide: Slide, index: number, total: number, active: boole
216
230
  continue;
217
231
  }
218
232
  if (block.kind === 'code') {
233
+ // mermaid 围栏不是代码:留一个占位容器,源码藏在 hidden pre 里,
234
+ // WebView 渲染完成后用 mermaid 的 SVG 替换(与上游 slides.css 的
235
+ // .mermaid-svg 约定一致)。
236
+ if (block.lang.toLowerCase() === 'mermaid') {
237
+ push(['cm-md-mermaid', 'mermaid-svg'], `<pre class="mermaid-src" hidden>${escapeHtml(block.text)}</pre>`);
238
+ continue;
239
+ }
219
240
  const lines = block.text.split('\n');
220
241
  lines.forEach((line, i) => {
221
242
  const cls = ['cm-md-codeblock'];
@@ -225,6 +246,11 @@ function slidePageHtml(slide: Slide, index: number, total: number, active: boole
225
246
  });
226
247
  continue;
227
248
  }
249
+ if (block.kind === 'math') {
250
+ // 块级公式:占位容器 + 源码,WebView 用 KaTeX 渲染替换。
251
+ push(['cm-md-math'], `<span class="math-src" hidden>${escapeHtml(block.text)}</span>`);
252
+ continue;
253
+ }
228
254
  if (block.kind === 'html') {
229
255
  push(['cm-md-html-widget'], block.text);
230
256
  continue;
@@ -363,15 +389,25 @@ const PRESENT_SCRIPT = `<script data-colaview-present>
363
389
  if (!page) return;
364
390
  var content = page.querySelector('.cm-content');
365
391
  if (!content) return;
366
- content.style.zoom = '1';
367
- var zoom = 1;
368
- for (var i = 0; i < 24; i += 1) {
369
- if (content.scrollHeight <= page.clientHeight + 1) break;
370
- zoom -= 0.04;
371
- if (zoom < 0.4) { zoom = 0.4; content.style.zoom = String(zoom); break; }
372
- content.style.zoom = String(zoom);
392
+ // 逐页 fit 走字号收缩(布局属性,会重排):zoom 会改动纸面的容器查询尺寸
393
+ // (cqw/cqh),在放映与打印里都靠不住——与 ColaMD-themes 的 fitPaper 一致。
394
+ content.style.fontSize = '';
395
+ var base = parseFloat(getComputedStyle(content).fontSize) || 0;
396
+ if (!base) return;
397
+ var floor = base * 0.5;
398
+ for (var i = 0; i < 8; i += 1) {
399
+ var room = page.clientHeight;
400
+ var need = content.scrollHeight;
401
+ if (!room || need <= room + 1) return;
402
+ var current = parseFloat(getComputedStyle(content).fontSize) || base;
403
+ var next = current * (room / need) * 0.98;
404
+ if (next < floor) { content.style.fontSize = floor.toFixed(2) + 'px'; return; }
405
+ content.style.fontSize = next.toFixed(2) + 'px';
373
406
  }
374
407
  }
408
+ window.__colaviewFitSlides = function () { pages.forEach(fitPage); return true; };
409
+ if (document.fonts && document.fonts.ready) document.fonts.ready.then(function () { window.__colaviewFitSlides(); });
410
+ window.addEventListener('load', function () { window.__colaviewFitSlides(); });
375
411
  function paint() {
376
412
  scaleToViewport();
377
413
  if (isSlides) {
@@ -473,11 +509,71 @@ export function renderSlidesDocument(input: StandaloneSlidesInput): string {
473
509
  `<!doctype html>\n<html lang="zh-CN">\n<head>\n` +
474
510
  `<meta charset="utf-8" />\n<meta name="viewport" content="width=device-width, initial-scale=1" />\n` +
475
511
  `<title>${escapeHtml(input.title)}</title>\n` +
512
+ // KaTeX 样式外链:水合脚本渲染公式时需要(离线时公式保留源码)。
513
+ `<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.16.11/dist/katex.min.css" />\n` +
476
514
  `<style data-colaview-deck>${css}</style>\n` +
477
- `</head>\n<body class="colaview-slides ${escapeAttr(input.bodyClass)}">\n${html}\n</body>\n</html>\n`
515
+ `</head>\n<body class="colaview-slides ${escapeAttr(input.bodyClass)}">\n${html}\n${SLIDES_HYDRATE_SCRIPT}\n</body>\n</html>\n`
478
516
  );
479
517
  }
480
518
 
519
+ /**
520
+ * 独立文档的水合脚本:从 CDN 引入 mermaid / KaTeX,把渲染层留下的
521
+ * `pre.mermaid-src` / `span.math-src` 占位容器替换成 SVG / 公式。
522
+ * 放映(系统浏览器在线)与幻灯片 PDF 导出(puppeteer 可访问网络)共用;
523
+ * CDN 不可用或渲染失败时保留源码。完成后挂 `window.__colaviewSlidesHydrated`,
524
+ * 导出端据此等待水合完成再打印。
525
+ */
526
+ const SLIDES_HYDRATE_SCRIPT = `<script>
527
+ function deckPele() {
528
+ return new Promise(function (resolve, reject) {
529
+ if (window.pele && window.pele.renderAsync) { resolve(window.pele); return; }
530
+ var el = document.createElement('script');
531
+ el.src = 'https://cdn.jsdelivr.net/npm/pele@1.13.0/dist/pele.global.js';
532
+ el.onload = function () { window.pele && window.pele.render ? resolve(window.pele) : reject(new Error("pele global missing")); };
533
+ el.onerror = function () { reject(new Error("pele CDN failed")); };
534
+ document.head.appendChild(el);
535
+ });
536
+ }
537
+ function deckMermaidFont() {
538
+ return 'PingFang SC, Hiragino Sans GB, Microsoft YaHei, Noto Sans CJK SC, sans-serif';
539
+ }
540
+ function deckMermaidFontMono() {
541
+ return 'SF Mono, Fira Code, Menlo, Consolas, monospace';
542
+ }
543
+ window.__colaviewSlidesHydrated = (async function () {
544
+ try {
545
+ var pele = await deckPele();
546
+ var nodes = document.querySelectorAll('pre.mermaid-src');
547
+ for (var i = 0; i < nodes.length; i++) {
548
+ var holder = nodes[i].parentElement;
549
+ if (!holder) continue;
550
+ try {
551
+ var result = pele.render(nodes[i].textContent || "", {
552
+ fontFamily: deckMermaidFont(),
553
+ fontFamilyMono: deckMermaidFontMono()
554
+ });
555
+ holder.innerHTML = result.svg;
556
+ nodes[i].remove();
557
+ } catch (err) { console.warn(String(err && err.message || err)); }
558
+ }
559
+ } catch (err) { console.warn(String(err && err.message || err)); }
560
+ try {
561
+ var katex = (await import('https://cdn.jsdelivr.net/npm/katex@0.16.11/dist/katex.min.mjs')).default;
562
+ var maths = document.querySelectorAll('span.math-src');
563
+ for (var j = 0; j < maths.length; j++) {
564
+ var target = maths[j].parentElement;
565
+ if (!target) continue;
566
+ try { katex.render(maths[j].textContent || '', target, { displayMode: true, throwOnError: false }); }
567
+ catch (err) { /* 保留源码 */ }
568
+ }
569
+ } catch (err) { /* CDN 不可用,保留源码 */ }
570
+ })();
571
+ // 水合改变每页内容高度:完成后重新逐页 fit(放映脚本在后面注入,此处判空)。
572
+ window.__colaviewSlidesHydrated.then(function () {
573
+ if (window.__colaviewFitSlides) window.__colaviewFitSlides();
574
+ });
575
+ </script>`;
576
+
481
577
  /** 把放映层(全屏交互 + HUD)打进一份独立文档。 */
482
578
  export function decoratePresentDocument(document: string): string {
483
579
  return document.replace('</head>', `${PRESENT_STYLE}\n</head>`).replace('</body>', `${PRESENT_SCRIPT}\n</body>`);
@@ -1,89 +1,89 @@
1
- /* ===== ColaMD Theme: 熊红 Bear =====
2
- Crisp white with confident red accent, Bear style.
3
-
4
- 契约:ColaMD 2.8(与 ColaMD-themes / DSH 插件同一套令牌)。
5
- 变量写在 :root;编辑器元素规则针对 #editor .cm-content + .cm-md-*。
6
- 基础版式(行高、字距、列宽、标题度量)由 WebView 的 DSH 对齐层
7
- 按 BASE_CSS 令牌兜底,这里只保留主题个性。 */
8
-
9
- /* ── 0. Webfont 镜像:主题栈引用的 Google Fonts(latin 子集,OFL)。
10
- 与 ColaMD-themes 2.8 契约一致:编辑器与 DSH 插件两侧同字体;
11
- 离线/断网自动回落主题字体栈;CJK 由系统字体承担,不镜像。 */
12
- @font-face {
13
- font-family: "JetBrains Mono"; font-style: normal; font-weight: 100 900; font-display: swap;
14
- src: url("https://fonts.gstatic.com/s/jetbrainsmono/v24/tDbV2o-flEEny0FZhsfKu5WU4xD7OwE.woff2") format("woff2");
15
- unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
16
- }
17
- @font-face {
18
- font-family: "Fira Code"; font-style: normal; font-weight: 100 900; font-display: swap;
19
- src: url("https://fonts.gstatic.com/s/firacode/v27/uU9NCBsR6Z2vfE9aq3bh3dSD.woff2") format("woff2");
20
- unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
21
- }
22
-
23
- :root {
24
- /* ── 1.1 Seed Palette ── */
25
- --seed-accent: #d43d2a;
26
- --seed-accent-light: color-mix(in srgb, #d43d2a 15%, transparent);
27
- --seed-accent-dark: color-mix(in srgb, #d43d2a 85%, #000);
28
- --seed-surface: #ffffff;
29
- --seed-panel: #f7f5f3;
30
- --seed-panel-alt: #2e2a28;
31
- --seed-ink: #262626;
32
- --seed-ink-muted: #767676;
33
- --seed-ink-dim: #8a8a8a;
34
- --seed-border: #eeecea;
35
- --seed-border-strong: #d43d2a;
36
-
37
- /* ── 1.2 Semantic Colors(活变量) ── */
38
- --bg-color: #ffffff;
39
- --text-color: #262626;
40
- --text-secondary: #767676;
41
- --text-muted: #8a8a8a;
42
- --border-color: #eeecea;
43
- --link-color: #d43d2a;
44
- --code-bg: rgba(212, 61, 42, 0.07);
45
- --code-block-bg: #2e2a28;
46
- --code-block-text: #efe9e4;
47
- --blockquote-border: #d43d2a;
48
- --table-header-bg: #f7f5f3;
49
- --selection-bg: rgba(212, 61, 42, 0.12);
50
- --highlight-bg: #ffe9a8;
51
-
52
- /* ── 1.3 Typography & Metrics(活变量,与 DSH 插件 BASE_CSS 同一消费方) ── */
53
- --font-body: -apple-system, "Segoe UI", "Noto Sans SC", "PingFang SC", sans-serif;
54
- --font-mono: "JetBrains Mono", "Fira Code", "SF Mono", Menlo, Consolas, monospace;
55
- --editor-font-size: 16px;
56
- --editor-column-width: 820px;
57
- --page-bg: #ffffff;
58
- --seed-emphasis: #d43d2a;
59
- }
60
-
61
- /* ═══════════════════════════════════════════════════════════
62
- SECTION 2 — 编辑器 DOM(#editor .cm-content + .cm-md-*)
63
- ═══════════════════════════════════════════════════════════ */
64
-
65
- #editor .cm-content .cm-md-hr {
66
- border-top-color: var(--seed-accent);
67
- opacity: 0.35;
68
- }
69
-
70
- /* ═══════════════════════════════════════════════════════════
71
- SECTION 3 — 导出 HTML(.colamd-document,只补配色与字体)
72
- 结构(页边距、标题层级、列表缩进)由导出外壳提供。
73
- ═══════════════════════════════════════════════════════════ */
74
-
75
- .colamd-document {
76
- font-family: var(--font-body);
77
- font-size: var(--editor-font-size);
78
- line-height: 1.78;
79
- background: var(--bg-color);
80
- color: var(--text-color);
81
- }
82
- .colamd-document strong {
83
- color: var(--seed-emphasis);
84
- }
85
- .colamd-document code {
86
- background: var(--code-bg);
87
- color: #d43d2a;
88
- font-family: var(--font-mono);
89
- }
1
+ /* ===== ColaMD Theme: 熊红 Bear =====
2
+ Crisp white with confident red accent, Bear style.
3
+
4
+ 契约:ColaMD 2.8(与 ColaMD-themes / DSH 插件同一套令牌)。
5
+ 变量写在 :root;编辑器元素规则针对 #editor .cm-content + .cm-md-*。
6
+ 基础版式(行高、字距、列宽、标题度量)由 WebView 的 DSH 对齐层
7
+ 按 BASE_CSS 令牌兜底,这里只保留主题个性。 */
8
+
9
+ /* ── 0. Webfont 镜像:主题栈引用的 Google Fonts(latin 子集,OFL)。
10
+ 与 ColaMD-themes 2.8 契约一致:编辑器与 DSH 插件两侧同字体;
11
+ 离线/断网自动回落主题字体栈;CJK 由系统字体承担,不镜像。 */
12
+ @font-face {
13
+ font-family: "JetBrains Mono"; font-style: normal; font-weight: 100 900; font-display: swap;
14
+ src: url("https://fonts.gstatic.com/s/jetbrainsmono/v24/tDbV2o-flEEny0FZhsfKu5WU4xD7OwE.woff2") format("woff2");
15
+ unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
16
+ }
17
+ @font-face {
18
+ font-family: "Fira Code"; font-style: normal; font-weight: 100 900; font-display: swap;
19
+ src: url("https://fonts.gstatic.com/s/firacode/v27/uU9NCBsR6Z2vfE9aq3bh3dSD.woff2") format("woff2");
20
+ unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
21
+ }
22
+
23
+ :root {
24
+ /* ── 1.1 Seed Palette ── */
25
+ --seed-accent: #d43d2a;
26
+ --seed-accent-light: color-mix(in srgb, #d43d2a 15%, transparent);
27
+ --seed-accent-dark: color-mix(in srgb, #d43d2a 85%, #000);
28
+ --seed-surface: #ffffff;
29
+ --seed-panel: #f7f5f3;
30
+ --seed-panel-alt: #2e2a28;
31
+ --seed-ink: #262626;
32
+ --seed-ink-muted: #767676;
33
+ --seed-ink-dim: #8a8a8a;
34
+ --seed-border: #eeecea;
35
+ --seed-border-strong: #d43d2a;
36
+
37
+ /* ── 1.2 Semantic Colors(活变量) ── */
38
+ --bg-color: #ffffff;
39
+ --text-color: #262626;
40
+ --text-secondary: #767676;
41
+ --text-muted: #8a8a8a;
42
+ --border-color: #eeecea;
43
+ --link-color: #d43d2a;
44
+ --code-bg: rgba(212, 61, 42, 0.07);
45
+ --code-block-bg: #2e2a28;
46
+ --code-block-text: #efe9e4;
47
+ --blockquote-border: #d43d2a;
48
+ --table-header-bg: #f7f5f3;
49
+ --selection-bg: rgba(212, 61, 42, 0.12);
50
+ --highlight-bg: #ffe9a8;
51
+
52
+ /* ── 1.3 Typography & Metrics(活变量,与 DSH 插件 BASE_CSS 同一消费方) ── */
53
+ --font-body: -apple-system, "Segoe UI", "Noto Sans SC", "PingFang SC", sans-serif;
54
+ --font-mono: "JetBrains Mono", "Fira Code", "SF Mono", Menlo, Consolas, monospace;
55
+ --editor-font-size: 16px;
56
+ --editor-column-width: 820px;
57
+ --page-bg: #ffffff;
58
+ --seed-emphasis: #d43d2a;
59
+ }
60
+
61
+ /* ═══════════════════════════════════════════════════════════
62
+ SECTION 2 — 编辑器 DOM(#editor .cm-content + .cm-md-*)
63
+ ═══════════════════════════════════════════════════════════ */
64
+
65
+ #editor .cm-content .cm-md-hr {
66
+ border-top-color: var(--seed-accent);
67
+ opacity: 0.35;
68
+ }
69
+
70
+ /* ═══════════════════════════════════════════════════════════
71
+ SECTION 3 — 导出 HTML(.colamd-document,只补配色与字体)
72
+ 结构(页边距、标题层级、列表缩进)由导出外壳提供。
73
+ ═══════════════════════════════════════════════════════════ */
74
+
75
+ .colamd-document {
76
+ font-family: var(--font-body);
77
+ font-size: var(--editor-font-size);
78
+ line-height: 1.78;
79
+ background: var(--bg-color);
80
+ color: var(--text-color);
81
+ }
82
+ .colamd-document strong {
83
+ color: var(--seed-emphasis);
84
+ }
85
+ .colamd-document code {
86
+ background: var(--code-bg);
87
+ color: #d43d2a;
88
+ font-family: var(--font-mono);
89
+ }
@@ -1,87 +1,87 @@
1
- /* ===== ColaMD Theme: 深色 Dark =====
2
- GitHub dark: soft black with blue links.
3
-
4
- 契约:ColaMD 2.8(与 ColaMD-themes / DSH 插件同一套令牌)。
5
- 变量写在 :root;编辑器元素规则针对 #editor .cm-content + .cm-md-*。
6
- 基础版式(行高、字距、列宽、标题度量)由 WebView 的 DSH 对齐层
7
- 按 BASE_CSS 令牌兜底,这里只保留主题个性。 */
8
-
9
- /* ── 0. Webfont 镜像:主题栈引用的 Google Fonts(latin 子集,OFL)。
10
- 与 ColaMD-themes 2.8 契约一致:编辑器与 DSH 插件两侧同字体;
11
- 离线/断网自动回落主题字体栈;CJK 由系统字体承担,不镜像。 */
12
- @font-face {
13
- font-family: "JetBrains Mono"; font-style: normal; font-weight: 100 900; font-display: swap;
14
- src: url("https://fonts.gstatic.com/s/jetbrainsmono/v24/tDbV2o-flEEny0FZhsfKu5WU4xD7OwE.woff2") format("woff2");
15
- unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
16
- }
17
- @font-face {
18
- font-family: "Fira Code"; font-style: normal; font-weight: 100 900; font-display: swap;
19
- src: url("https://fonts.gstatic.com/s/firacode/v27/uU9NCBsR6Z2vfE9aq3bh3dSD.woff2") format("woff2");
20
- unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
21
- }
22
-
23
- :root {
24
- /* ── 1.1 Seed Palette ── */
25
- --seed-accent: #58a6ff;
26
- --seed-accent-light: color-mix(in srgb, #58a6ff 15%, transparent);
27
- --seed-accent-dark: color-mix(in srgb, #58a6ff 85%, #000);
28
- --seed-surface: #0d1117;
29
- --seed-panel: #161b22;
30
- --seed-panel-alt: #161b22;
31
- --seed-ink: #e6edf3;
32
- --seed-ink-muted: #aab3bd;
33
- --seed-ink-dim: #8b949e;
34
- --seed-border: #272d34;
35
- --seed-border-strong: #58a6ff;
36
-
37
- /* ── 1.2 Semantic Colors(活变量) ── */
38
- --bg-color: #0d1117;
39
- --text-color: #e6edf3;
40
- --text-secondary: #aab3bd;
41
- --text-muted: #8b949e;
42
- --border-color: #272d34;
43
- --link-color: #58a6ff;
44
- --code-bg: rgba(110, 118, 129, 0.3);
45
- --code-block-bg: #161b22;
46
- --blockquote-border: #30363d;
47
- --table-header-bg: #161b22;
48
- --selection-bg: rgba(88, 166, 255, 0.2);
49
- --highlight-bg: rgba(210, 153, 34, 0.35);
50
-
51
- /* ── 1.3 Typography & Metrics(活变量,与 DSH 插件 BASE_CSS 同一消费方) ── */
52
- --font-body: -apple-system, "Segoe UI", "Noto Sans SC", "PingFang SC", sans-serif;
53
- --font-mono: "JetBrains Mono", "Fira Code", "SF Mono", Menlo, Consolas, monospace;
54
- --editor-font-size: 16px;
55
- --editor-column-width: 820px;
56
- --page-bg: #0d1117;
57
- --seed-emphasis: #e6edf3;
58
- }
59
-
60
- /* ═══════════════════════════════════════════════════════════
61
- SECTION 2 — 编辑器 DOM(#editor .cm-content + .cm-md-*)
62
- ═══════════════════════════════════════════════════════════ */
63
-
64
- #editor .cm-content .cm-md-inlinecode {
65
- color: #ff7b72;
66
- }
67
-
68
- /* ═══════════════════════════════════════════════════════════
69
- SECTION 3 — 导出 HTML(.colamd-document,只补配色与字体)
70
- 结构(页边距、标题层级、列表缩进)由导出外壳提供。
71
- ═══════════════════════════════════════════════════════════ */
72
-
73
- .colamd-document {
74
- font-family: var(--font-body);
75
- font-size: var(--editor-font-size);
76
- line-height: 1.78;
77
- background: var(--bg-color);
78
- color: var(--text-color);
79
- }
80
- .colamd-document strong {
81
- color: var(--seed-emphasis);
82
- }
83
- .colamd-document code {
84
- background: var(--code-bg);
85
- color: #ff7b72;
86
- font-family: var(--font-mono);
87
- }
1
+ /* ===== ColaMD Theme: 深色 Dark =====
2
+ GitHub dark: soft black with blue links.
3
+
4
+ 契约:ColaMD 2.8(与 ColaMD-themes / DSH 插件同一套令牌)。
5
+ 变量写在 :root;编辑器元素规则针对 #editor .cm-content + .cm-md-*。
6
+ 基础版式(行高、字距、列宽、标题度量)由 WebView 的 DSH 对齐层
7
+ 按 BASE_CSS 令牌兜底,这里只保留主题个性。 */
8
+
9
+ /* ── 0. Webfont 镜像:主题栈引用的 Google Fonts(latin 子集,OFL)。
10
+ 与 ColaMD-themes 2.8 契约一致:编辑器与 DSH 插件两侧同字体;
11
+ 离线/断网自动回落主题字体栈;CJK 由系统字体承担,不镜像。 */
12
+ @font-face {
13
+ font-family: "JetBrains Mono"; font-style: normal; font-weight: 100 900; font-display: swap;
14
+ src: url("https://fonts.gstatic.com/s/jetbrainsmono/v24/tDbV2o-flEEny0FZhsfKu5WU4xD7OwE.woff2") format("woff2");
15
+ unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
16
+ }
17
+ @font-face {
18
+ font-family: "Fira Code"; font-style: normal; font-weight: 100 900; font-display: swap;
19
+ src: url("https://fonts.gstatic.com/s/firacode/v27/uU9NCBsR6Z2vfE9aq3bh3dSD.woff2") format("woff2");
20
+ unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
21
+ }
22
+
23
+ :root {
24
+ /* ── 1.1 Seed Palette ── */
25
+ --seed-accent: #58a6ff;
26
+ --seed-accent-light: color-mix(in srgb, #58a6ff 15%, transparent);
27
+ --seed-accent-dark: color-mix(in srgb, #58a6ff 85%, #000);
28
+ --seed-surface: #0d1117;
29
+ --seed-panel: #161b22;
30
+ --seed-panel-alt: #161b22;
31
+ --seed-ink: #e6edf3;
32
+ --seed-ink-muted: #aab3bd;
33
+ --seed-ink-dim: #8b949e;
34
+ --seed-border: #272d34;
35
+ --seed-border-strong: #58a6ff;
36
+
37
+ /* ── 1.2 Semantic Colors(活变量) ── */
38
+ --bg-color: #0d1117;
39
+ --text-color: #e6edf3;
40
+ --text-secondary: #aab3bd;
41
+ --text-muted: #8b949e;
42
+ --border-color: #272d34;
43
+ --link-color: #58a6ff;
44
+ --code-bg: rgba(110, 118, 129, 0.3);
45
+ --code-block-bg: #161b22;
46
+ --blockquote-border: #30363d;
47
+ --table-header-bg: #161b22;
48
+ --selection-bg: rgba(88, 166, 255, 0.2);
49
+ --highlight-bg: rgba(210, 153, 34, 0.35);
50
+
51
+ /* ── 1.3 Typography & Metrics(活变量,与 DSH 插件 BASE_CSS 同一消费方) ── */
52
+ --font-body: -apple-system, "Segoe UI", "Noto Sans SC", "PingFang SC", sans-serif;
53
+ --font-mono: "JetBrains Mono", "Fira Code", "SF Mono", Menlo, Consolas, monospace;
54
+ --editor-font-size: 16px;
55
+ --editor-column-width: 820px;
56
+ --page-bg: #0d1117;
57
+ --seed-emphasis: #e6edf3;
58
+ }
59
+
60
+ /* ═══════════════════════════════════════════════════════════
61
+ SECTION 2 — 编辑器 DOM(#editor .cm-content + .cm-md-*)
62
+ ═══════════════════════════════════════════════════════════ */
63
+
64
+ #editor .cm-content .cm-md-inlinecode {
65
+ color: #ff7b72;
66
+ }
67
+
68
+ /* ═══════════════════════════════════════════════════════════
69
+ SECTION 3 — 导出 HTML(.colamd-document,只补配色与字体)
70
+ 结构(页边距、标题层级、列表缩进)由导出外壳提供。
71
+ ═══════════════════════════════════════════════════════════ */
72
+
73
+ .colamd-document {
74
+ font-family: var(--font-body);
75
+ font-size: var(--editor-font-size);
76
+ line-height: 1.78;
77
+ background: var(--bg-color);
78
+ color: var(--text-color);
79
+ }
80
+ .colamd-document strong {
81
+ color: var(--seed-emphasis);
82
+ }
83
+ .colamd-document code {
84
+ background: var(--code-bg);
85
+ color: #ff7b72;
86
+ font-family: var(--font-mono);
87
+ }