@bytechain.cn/colamd-themes 0.3.1 → 0.5.0
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.
- package/.claude/skills/colamd-themes-preview.skill.md +333 -0
- package/.claude/skills/colamd-themes.skill.md +10 -0
- package/.dsh/skills/colamd-themes/SKILL.md +14 -0
- package/.github/supported-topics.yml +17 -0
- package/.hermes/skills/tools/colamd-themes/SKILL.md +14 -0
- package/.openclaw/skills/colamd-themes/SKILL.md +1 -146
- package/.opencode/skills/colamd-themes/SKILL.md +17 -0
- package/.trae/rules/colamd-themes.md +0 -145
- package/CHANGELOG.md +318 -240
- package/DSH_SUPPORT_SUMMARY.md +87 -0
- package/README.md +414 -384
- package/README_CN.md +412 -384
- package/RELEASENOTE.md +541 -365
- package/bytechain.cn-colamd-themes-0.5.0.tgz +0 -0
- package/dist/cli.js +272 -32
- package/dist/cli.js.map +1 -1
- package/dist/color-utils.d.ts +1 -0
- package/dist/color-utils.js +25 -6
- package/dist/color-utils.js.map +1 -1
- package/dist/extractors/pdf-extractor.js +6 -1
- package/dist/extractors/pdf-extractor.js.map +1 -1
- package/dist/extractors/url-extractor.d.ts +0 -4
- package/dist/extractors/url-extractor.js +13 -126
- package/dist/extractors/url-extractor.js.map +1 -1
- package/dist/generator.d.ts +1 -1
- package/dist/generator.js +32 -11
- package/dist/generator.js.map +1 -1
- package/dist/models.d.ts +5 -4
- package/dist/models.js +2 -3
- package/dist/models.js.map +1 -1
- package/dist/renderer.d.ts +4 -2
- package/dist/renderer.js +68 -25
- package/dist/renderer.js.map +1 -1
- package/dist/templates/template.css +220 -498
- package/dist/templates/theme-paradigm.md +530 -658
- package/dist/templates/theme-template.hbs +256 -370
- package/dist/theme-store.js +19 -3
- package/dist/theme-store.js.map +1 -1
- package/dist/utils/document-paradigm.d.ts +12 -0
- package/dist/utils/document-paradigm.js +109 -0
- package/dist/utils/document-paradigm.js.map +1 -0
- package/dist/validators.d.ts +4 -1
- package/dist/validators.js +115 -1
- package/dist/validators.js.map +1 -1
- package/mcp-server/dist/index.d.ts +13 -0
- package/mcp-server/dist/index.d.ts.map +1 -0
- package/mcp-server/dist/index.js +0 -0
- package/mcp-server/dist/index.js.map +1 -0
- package/mcp-server/package-lock.json +1759 -0
- package/mcp-server/package.json +24 -0
- package/mcp-server/src/index.ts +0 -0
- package/mcp-server/tsconfig.json +19 -0
- package/package.json +54 -36
- package/skills/build-skills.sh +30 -5
- package/skills/colamd-themes/SKILL.md +180 -148
- package/src/cli.ts +474 -217
- package/src/color-systems.ts +289 -289
- package/src/color-utils.ts +137 -120
- package/src/contrast.ts +66 -66
- package/src/docx-style-paradigm.ts +811 -811
- package/src/export-cli.ts +356 -356
- package/src/extractors/base.ts +8 -8
- package/src/extractors/docx-extractor.ts +417 -417
- package/src/extractors/pdf-extractor.ts +533 -527
- package/src/extractors/url-extractor.ts +846 -981
- package/src/generator.ts +197 -169
- package/src/index.ts +29 -29
- package/src/models.ts +212 -212
- package/src/renderer.ts +332 -288
- package/src/templates/template.css +220 -498
- package/src/templates/theme-paradigm.md +530 -658
- package/src/templates/theme-template.hbs +256 -370
- package/src/theme-store.ts +185 -170
- package/src/types/pdf-parse.d.ts +12 -12
- package/src/utils/cli-utils.ts +84 -84
- package/src/utils/document-paradigm.ts +118 -0
- package/src/validators.ts +298 -176
- package/themes/academic-paper-pt.css +353 -1805
- package/themes/academic-paper.css +350 -1099
- package/themes/academic-style.css +342 -2430
- package/themes/colly.css +256 -370
- package/themes/elegant.css +288 -671
- package/themes/forest-ink.css +240 -664
- package/themes/guizang.css +250 -732
- package/themes/hermes-security.css +279 -0
- package/themes/meeting-minutes.css +256 -370
- package/themes/pixso-design.css +278 -1261
- package/themes/salvator-blog.css +256 -370
- package/themes/shimo-theme.css +256 -0
- package/themes/swiss-design.css +285 -746
- package/themes/template.css +220 -498
- package/themes/trae-blue.css +280 -737
- package/themes/word-contract.css +249 -0
- package/themes-preview/demo-content.md +187 -187
- package/tsconfig.json +18 -18
- package/src/mermaid-presets.ts +0 -142
- package/themes/swiss-design copy.css +0 -746
- package/themes-preview/colly-preview.html +0 -623
- package/themes-preview/meeting-minutes-preview.html +0 -625
- package/themes-preview/salvator-blog-preview.html +0 -623
|
@@ -1,527 +1,533 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* PDF 文档样式提取器 — v2.0
|
|
3
|
-
*
|
|
4
|
-
* 增强功能:
|
|
5
|
-
* 1. 基于文本结构启发式分析提取各级标题样式
|
|
6
|
-
* 2. 检测正文字体、字号、行间距特征
|
|
7
|
-
* 3. 识别表格、代码块等特殊元素
|
|
8
|
-
* 4. 集成 DocxStyleParadigm 标准参考值填充缺失字段
|
|
9
|
-
* 5. 自动验证 WCAG 对比度合规性
|
|
10
|
-
*
|
|
11
|
-
* 技术说明:
|
|
12
|
-
* pdf-parse 默认不提供字体元数据,因此采用多层启发式策略:
|
|
13
|
-
* - 层级1:文本结构分析(短行/大写/编号 = 标题候选)
|
|
14
|
-
* - 层级2:格式特征检测(等宽文本 = 代码块)
|
|
15
|
-
* - 层级3:DocxStyleParadigm 标准参考值 fallback
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
import { readFileSync } from "node:fs";
|
|
19
|
-
import { basename } from "node:path";
|
|
20
|
-
import type { Extractor } from "./base.js";
|
|
21
|
-
import {
|
|
22
|
-
makeThemeStyle,
|
|
23
|
-
type ThemeStyle,
|
|
24
|
-
type ColorPalette,
|
|
25
|
-
} from "../models.js";
|
|
26
|
-
import { normalizeThemeStyle } from "../color-utils.js";
|
|
27
|
-
import {
|
|
28
|
-
ACADEMIC_PAPER_DEFAULTS,
|
|
29
|
-
BUSINESS_REPORT_DEFAULTS,
|
|
30
|
-
TECHNICAL_DOC_DEFAULTS,
|
|
31
|
-
getRecommendedPreset,
|
|
32
|
-
validateDocumentStyle,
|
|
33
|
-
type DocumentStyleParadigm,
|
|
34
|
-
} from "../docx-style-paradigm.js";
|
|
35
|
-
|
|
36
|
-
/** PDF 解析结果数据类型 */
|
|
37
|
-
type PDFData = {
|
|
38
|
-
text: string;
|
|
39
|
-
numpages: number;
|
|
40
|
-
info: Record<string, unknown>;
|
|
41
|
-
metadata: Record<string, unknown>;
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
/** 从文本行中推断的字体信息 */
|
|
45
|
-
interface InferredFontInfo {
|
|
46
|
-
fontName: string;
|
|
47
|
-
fontSize: number;
|
|
48
|
-
isBold: boolean;
|
|
49
|
-
isHeading: boolean;
|
|
50
|
-
headingLevel: number | null;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/** 文本行分析结果 */
|
|
54
|
-
interface LineAnalysis {
|
|
55
|
-
text: string;
|
|
56
|
-
length: number;
|
|
57
|
-
isAllUppercase: boolean;
|
|
58
|
-
isShortLine: boolean;
|
|
59
|
-
hasNumbering: boolean;
|
|
60
|
-
hasBullet: boolean;
|
|
61
|
-
looksLikeHeading: boolean;
|
|
62
|
-
looksLikeCode: boolean;
|
|
63
|
-
indentLevel: number;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export class PdfExtractor implements Extractor {
|
|
67
|
-
canHandle(source: string): boolean {
|
|
68
|
-
return /\.pdf$/i.test(source);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
async extract(source: string): Promise<ThemeStyle> {
|
|
72
|
-
const name = basename(source).replace(/\.pdf$/i, "");
|
|
73
|
-
const theme = makeThemeStyle(name, "pdf", source);
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
this.
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
trimmed
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
if (line.
|
|
158
|
-
confidence +=
|
|
159
|
-
}
|
|
160
|
-
if (
|
|
161
|
-
confidence +=
|
|
162
|
-
}
|
|
163
|
-
if (
|
|
164
|
-
confidence +=
|
|
165
|
-
}
|
|
166
|
-
if (
|
|
167
|
-
confidence +=
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
if (
|
|
198
|
-
theme.seedTypography.
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
const
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
theme.typography.baseFontSize = "
|
|
226
|
-
theme.typography.baseLineHeight = 1.
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
l.text.
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
p.
|
|
312
|
-
|
|
313
|
-
theme.typography.
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
if (!p.
|
|
366
|
-
p.
|
|
367
|
-
}
|
|
368
|
-
if (!p.
|
|
369
|
-
p.
|
|
370
|
-
}
|
|
371
|
-
if (!p.
|
|
372
|
-
p.
|
|
373
|
-
}
|
|
374
|
-
if (!p.
|
|
375
|
-
p.
|
|
376
|
-
}
|
|
377
|
-
if (!p.
|
|
378
|
-
p.
|
|
379
|
-
}
|
|
380
|
-
if (!p.
|
|
381
|
-
p.
|
|
382
|
-
}
|
|
383
|
-
if (!p.
|
|
384
|
-
p.
|
|
385
|
-
}
|
|
386
|
-
if (!p.
|
|
387
|
-
p.
|
|
388
|
-
}
|
|
389
|
-
if (!p.
|
|
390
|
-
p.
|
|
391
|
-
}
|
|
392
|
-
if (!p.
|
|
393
|
-
p.
|
|
394
|
-
}
|
|
395
|
-
if (!p.
|
|
396
|
-
p.
|
|
397
|
-
}
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
if (!t.
|
|
406
|
-
t.
|
|
407
|
-
}
|
|
408
|
-
if (t.
|
|
409
|
-
t.
|
|
410
|
-
}
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
color: theme.palette.
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
1
|
+
/**
|
|
2
|
+
* PDF 文档样式提取器 — v2.0
|
|
3
|
+
*
|
|
4
|
+
* 增强功能:
|
|
5
|
+
* 1. 基于文本结构启发式分析提取各级标题样式
|
|
6
|
+
* 2. 检测正文字体、字号、行间距特征
|
|
7
|
+
* 3. 识别表格、代码块等特殊元素
|
|
8
|
+
* 4. 集成 DocxStyleParadigm 标准参考值填充缺失字段
|
|
9
|
+
* 5. 自动验证 WCAG 对比度合规性
|
|
10
|
+
*
|
|
11
|
+
* 技术说明:
|
|
12
|
+
* pdf-parse 默认不提供字体元数据,因此采用多层启发式策略:
|
|
13
|
+
* - 层级1:文本结构分析(短行/大写/编号 = 标题候选)
|
|
14
|
+
* - 层级2:格式特征检测(等宽文本 = 代码块)
|
|
15
|
+
* - 层级3:DocxStyleParadigm 标准参考值 fallback
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import { readFileSync, statSync } from "node:fs";
|
|
19
|
+
import { basename } from "node:path";
|
|
20
|
+
import type { Extractor } from "./base.js";
|
|
21
|
+
import {
|
|
22
|
+
makeThemeStyle,
|
|
23
|
+
type ThemeStyle,
|
|
24
|
+
type ColorPalette,
|
|
25
|
+
} from "../models.js";
|
|
26
|
+
import { normalizeThemeStyle } from "../color-utils.js";
|
|
27
|
+
import {
|
|
28
|
+
ACADEMIC_PAPER_DEFAULTS,
|
|
29
|
+
BUSINESS_REPORT_DEFAULTS,
|
|
30
|
+
TECHNICAL_DOC_DEFAULTS,
|
|
31
|
+
getRecommendedPreset,
|
|
32
|
+
validateDocumentStyle,
|
|
33
|
+
type DocumentStyleParadigm,
|
|
34
|
+
} from "../docx-style-paradigm.js";
|
|
35
|
+
|
|
36
|
+
/** PDF 解析结果数据类型 */
|
|
37
|
+
type PDFData = {
|
|
38
|
+
text: string;
|
|
39
|
+
numpages: number;
|
|
40
|
+
info: Record<string, unknown>;
|
|
41
|
+
metadata: Record<string, unknown>;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
/** 从文本行中推断的字体信息 */
|
|
45
|
+
interface InferredFontInfo {
|
|
46
|
+
fontName: string;
|
|
47
|
+
fontSize: number;
|
|
48
|
+
isBold: boolean;
|
|
49
|
+
isHeading: boolean;
|
|
50
|
+
headingLevel: number | null;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** 文本行分析结果 */
|
|
54
|
+
interface LineAnalysis {
|
|
55
|
+
text: string;
|
|
56
|
+
length: number;
|
|
57
|
+
isAllUppercase: boolean;
|
|
58
|
+
isShortLine: boolean;
|
|
59
|
+
hasNumbering: boolean;
|
|
60
|
+
hasBullet: boolean;
|
|
61
|
+
looksLikeHeading: boolean;
|
|
62
|
+
looksLikeCode: boolean;
|
|
63
|
+
indentLevel: number;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export class PdfExtractor implements Extractor {
|
|
67
|
+
canHandle(source: string): boolean {
|
|
68
|
+
return /\.pdf$/i.test(source);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
async extract(source: string): Promise<ThemeStyle> {
|
|
72
|
+
const name = basename(source).replace(/\.pdf$/i, "");
|
|
73
|
+
const theme = makeThemeStyle(name, "pdf", source);
|
|
74
|
+
|
|
75
|
+
const MAX_PDF_BYTES = 50 * 1024 * 1024;
|
|
76
|
+
const stats = statSync(source);
|
|
77
|
+
if (stats.size > MAX_PDF_BYTES) {
|
|
78
|
+
throw new Error(`PDF file too large (${(stats.size / 1024 / 1024).toFixed(1)} MB). Maximum allowed: 50 MB.`);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
try {
|
|
82
|
+
const pdfParse = (await import("pdf-parse")).default;
|
|
83
|
+
const buffer = readFileSync(source);
|
|
84
|
+
const data: PDFData = await pdfParse(buffer);
|
|
85
|
+
|
|
86
|
+
if (data.text) {
|
|
87
|
+
this.analyzeTextStructure(theme, data.text);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if (data.metadata) {
|
|
91
|
+
this.populateFromMetadata(theme, data.metadata);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if (data.info) {
|
|
95
|
+
this.detectDocumentType(theme, data.text, data.numpages);
|
|
96
|
+
}
|
|
97
|
+
} catch (err) {
|
|
98
|
+
if ((err as NodeJS.ErrnoException).code === "ERR_MODULE_NOT_FOUND") {
|
|
99
|
+
throw new Error("pdf-parse 未安装,请运行: npm install pdf-parse");
|
|
100
|
+
}
|
|
101
|
+
throw err;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
this.applyParadigmDefaults(theme);
|
|
105
|
+
normalizeThemeStyle(theme);
|
|
106
|
+
return theme;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* 分析 PDF 文本结构,推断文档元素样式
|
|
111
|
+
*/
|
|
112
|
+
private analyzeTextStructure(theme: ThemeStyle, text: string): void {
|
|
113
|
+
const lines = text.split("\n").filter((l) => l.trim().length > 0);
|
|
114
|
+
const analyzedLines = lines.map((line) => this.analyzeLine(line));
|
|
115
|
+
|
|
116
|
+
this.detectHeadings(theme, analyzedLines);
|
|
117
|
+
this.detectBodyText(theme, analyzedLines);
|
|
118
|
+
this.detectCodeBlocks(theme, analyzedLines);
|
|
119
|
+
this.detectTables(theme, analyzedLines);
|
|
120
|
+
this.inferColorPalette(theme, analyzedLines);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* 单行文本特征分析
|
|
125
|
+
*/
|
|
126
|
+
private analyzeLine(line: string): LineAnalysis {
|
|
127
|
+
const trimmed = line.trim();
|
|
128
|
+
return {
|
|
129
|
+
text: trimmed,
|
|
130
|
+
length: trimmed.length,
|
|
131
|
+
isAllUppercase:
|
|
132
|
+
trimmed.length > 3 &&
|
|
133
|
+
trimmed.length < 80 &&
|
|
134
|
+
/^[A-Z0-9\s\-:.,!?()]+$/.test(trimmed) &&
|
|
135
|
+
/[A-Z]/.test(trimmed) &&
|
|
136
|
+
trimmed.split("").filter((c) => /[a-z]/.test(c)).length === 0,
|
|
137
|
+
isShortLine: trimmed.length < 60,
|
|
138
|
+
hasNumbering: /^\s*(\d+[\.\)]\s*|[一二三四五六七八九十]+[\.\、]\s*|[IVX]+\.\s*)/.test(
|
|
139
|
+
trimmed
|
|
140
|
+
),
|
|
141
|
+
hasBullet: /^\s*[\-\•\*\·\◦\‣]\s*/.test(trimmed),
|
|
142
|
+
looksLikeHeading: false,
|
|
143
|
+
looksLikeCode: false,
|
|
144
|
+
indentLevel: line.search(/\S/),
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* 基于启发式规则检测标题层级
|
|
150
|
+
*/
|
|
151
|
+
private detectHeadings(theme: ThemeStyle, lines: LineAnalysis[]): void {
|
|
152
|
+
const headingCandidates: { level: number; confidence: number; line: LineAnalysis }[] = [];
|
|
153
|
+
|
|
154
|
+
for (const line of lines) {
|
|
155
|
+
let confidence = 0;
|
|
156
|
+
|
|
157
|
+
if (line.isAllUppercase && line.isShortLine) {
|
|
158
|
+
confidence += 4;
|
|
159
|
+
}
|
|
160
|
+
if (line.hasNumbering && line.isShortLine) {
|
|
161
|
+
confidence += 3;
|
|
162
|
+
}
|
|
163
|
+
if (line.indentLevel === 0 && line.isShortLine && line.length > 5) {
|
|
164
|
+
confidence += 2;
|
|
165
|
+
}
|
|
166
|
+
if (/^(摘要|ABSTRACT|目录|TABLE OF CONTENTS|引言|INTRODUCTION|结论|CONCLUSION|参考文献|REFERENCES)$/i.test(line.text)) {
|
|
167
|
+
confidence += 5;
|
|
168
|
+
}
|
|
169
|
+
if (/^第[一二三四五六七八九十]+[章节部分]|^Chapter\s+\d+/i.test(line.text)) {
|
|
170
|
+
confidence += 4;
|
|
171
|
+
}
|
|
172
|
+
if (line.length < 30 && line.length > 3 && /^[^\s]{2,}$/.test(line.text)) {
|
|
173
|
+
confidence += 1;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
if (confidence >= 4) {
|
|
177
|
+
line.looksLikeHeading = true;
|
|
178
|
+
let level = 2;
|
|
179
|
+
if (confidence >= 6 || /^(摘要|ABSTRACT|标题|TITLE)$/i.test(line.text)) {
|
|
180
|
+
level = 1;
|
|
181
|
+
} else if (confidence >= 5 || line.hasNumbering) {
|
|
182
|
+
level = 2;
|
|
183
|
+
} else if (line.indentLevel > 0) {
|
|
184
|
+
level = Math.min(4, 2 + Math.floor(line.indentLevel / 2));
|
|
185
|
+
}
|
|
186
|
+
headingCandidates.push({ level, confidence, line });
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
if (headingCandidates.length > 0) {
|
|
191
|
+
theme.palette.headingColor = theme.palette.headingColor || ACADEMIC_PAPER_DEFAULTS.headings.h1.color;
|
|
192
|
+
theme.typography.headingWeight = 700;
|
|
193
|
+
|
|
194
|
+
const h1Count = headingCandidates.filter((c) => c.level === 1).length;
|
|
195
|
+
const h2Count = headingCandidates.filter((c) => c.level === 2).length;
|
|
196
|
+
|
|
197
|
+
if (h1Count > 0) {
|
|
198
|
+
theme.seedTypography.fontScaleH1 = ACADEMIC_PAPER_DEFAULTS.headings.h1.fontSize / 16;
|
|
199
|
+
}
|
|
200
|
+
if (h2Count > 0) {
|
|
201
|
+
theme.seedTypography.fontScaleH2 = ACADEMIC_PAPER_DEFAULTS.headings.h2.fontSize / 16;
|
|
202
|
+
}
|
|
203
|
+
if (headingCandidates.some((c) => c.level >= 3)) {
|
|
204
|
+
theme.seedTypography.fontScaleH3 = ACADEMIC_PAPER_DEFAULTS.headings.h3.fontSize / 16;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* 推断正文样式特征
|
|
211
|
+
*/
|
|
212
|
+
private detectBodyText(theme: ThemeStyle, lines: LineAnalysis[]): void {
|
|
213
|
+
const bodyLines = lines.filter(
|
|
214
|
+
(l) => !l.looksLikeHeading && !l.looksLikeCode && l.length > 20
|
|
215
|
+
);
|
|
216
|
+
|
|
217
|
+
if (bodyLines.length === 0) return;
|
|
218
|
+
|
|
219
|
+
const avgLength =
|
|
220
|
+
bodyLines.reduce((sum, l) => sum + l.length, 0) / bodyLines.length;
|
|
221
|
+
const avgIndent =
|
|
222
|
+
bodyLines.reduce((sum, l) => sum + l.indentLevel, 0) / bodyLines.length;
|
|
223
|
+
|
|
224
|
+
if (avgLength > 60) {
|
|
225
|
+
theme.typography.baseFontSize = "16px";
|
|
226
|
+
theme.typography.baseLineHeight = 1.75;
|
|
227
|
+
} else if (avgLength > 40) {
|
|
228
|
+
theme.typography.baseFontSize = "15px";
|
|
229
|
+
theme.typography.baseLineHeight = 1.7;
|
|
230
|
+
} else {
|
|
231
|
+
theme.typography.baseFontSize = "14px";
|
|
232
|
+
theme.typography.baseLineHeight = 1.65;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
if (avgIndent >= 2) {
|
|
236
|
+
theme.typography.bodyFontFamily = ACADEMIC_PAPER_DEFAULTS.body.fontFamily;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
theme.seedTypography.lineHeightBody = theme.typography.baseLineHeight;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* 检测代码块区域(等宽文本特征)
|
|
244
|
+
*/
|
|
245
|
+
private detectCodeBlocks(theme: ThemeStyle, lines: LineAnalysis[]): void {
|
|
246
|
+
const codeIndicators = [
|
|
247
|
+
(l: LineAnalysis) =>
|
|
248
|
+
l.text.includes("function ") ||
|
|
249
|
+
l.text.includes("const ") ||
|
|
250
|
+
l.text.includes("let ") ||
|
|
251
|
+
l.text.includes("var "),
|
|
252
|
+
(l: LineAnalysis) =>
|
|
253
|
+
l.text.includes("{") && l.text.includes("}"),
|
|
254
|
+
(l: LineAnalysis) =>
|
|
255
|
+
/^(\s*(\/\/|#|\/\*|\*\/|\s*import\s+\s*export\s+))/.test(l.text),
|
|
256
|
+
(l: LineAnalysis) =>
|
|
257
|
+
l.text.match(/[;<>=\[\](){}]/g)?.length &&
|
|
258
|
+
l.text.match(/[;<>=\[\](){}]/g)!?.length > 3,
|
|
259
|
+
];
|
|
260
|
+
|
|
261
|
+
for (const line of lines) {
|
|
262
|
+
const isCode = codeIndicators.some((check) => check(line));
|
|
263
|
+
if (isCode) {
|
|
264
|
+
line.looksLikeCode = true;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
const codeLineCount = lines.filter((l) => l.looksLikeCode).length;
|
|
269
|
+
if (codeLineCount > 3) {
|
|
270
|
+
theme.palette.codeBlockBg = "#f5f5f5";
|
|
271
|
+
theme.palette.codeBlockText = "#333333";
|
|
272
|
+
theme.palette.codeBg = "#f9f9f9";
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* 检测表格结构(多列对齐文本)
|
|
278
|
+
*/
|
|
279
|
+
private detectTables(theme: ThemeStyle, lines: LineAnalysis[]): void {
|
|
280
|
+
const tablePatterns = [
|
|
281
|
+
/^\|.+\|.*\|$/,
|
|
282
|
+
/^\s*\|?\s*-{2,}\s*\|/,
|
|
283
|
+
/^\s+(\S+)\s{2,}(\S+)\s{2,}(\S+)/,
|
|
284
|
+
];
|
|
285
|
+
|
|
286
|
+
let tableLineCount = 0;
|
|
287
|
+
for (const line of lines) {
|
|
288
|
+
if (tablePatterns.some((p) => p.test(line.text))) {
|
|
289
|
+
tableLineCount++;
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
if (tableLineCount >= 3) {
|
|
294
|
+
theme.palette.tableHeaderBg = ACADEMIC_PAPER_DEFAULTS.table.headerBgColor;
|
|
295
|
+
theme.palette.borderColor = ACADEMIC_PAPER_DEFAULTS.table.borderColor;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* 基于文档特征推断配色方案
|
|
301
|
+
*/
|
|
302
|
+
private inferColorPalette(theme: ThemeStyle, lines: LineAnalysis[]): void {
|
|
303
|
+
const p = theme.palette;
|
|
304
|
+
|
|
305
|
+
const hasChinese = lines.some((l) => /[\u4e00-\u9fa5]/.test(l.text));
|
|
306
|
+
const longEnglishBlocks = lines.filter(
|
|
307
|
+
(l) => l.length > 100 && /^[a-zA-Z0-9\s\.,;\:'"()\[\]{}]+$/.test(l.text)
|
|
308
|
+
).length;
|
|
309
|
+
|
|
310
|
+
if (hasChinese) {
|
|
311
|
+
p.textColor = ACADEMIC_PAPER_DEFAULTS.body.color;
|
|
312
|
+
p.bgColor = ACADEMIC_PAPER_DEFAULTS.pageBackground;
|
|
313
|
+
theme.typography.bodyFontFamily = ACADEMIC_PAPER_DEFAULTS.body.fontFamily;
|
|
314
|
+
theme.typography.headingFontFamily = ACADEMIC_PAPER_DEFAULTS.headings.h1.fontFamily;
|
|
315
|
+
} else if (longEnglishBlocks > 5) {
|
|
316
|
+
p.textColor = BUSINESS_REPORT_DEFAULTS.body.color;
|
|
317
|
+
p.bgColor = BUSINESS_REPORT_DEFAULTS.pageBackground;
|
|
318
|
+
theme.typography.bodyFontFamily = BUSINESS_REPORT_DEFAULTS.body.fontFamily;
|
|
319
|
+
theme.typography.headingFontFamily = BUSINESS_REPORT_DEFAULTS.headings.h1.fontFamily;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
p.accentColor = hasChinese ? "#2b579a" : "#2563eb";
|
|
323
|
+
p.textMuted = hasChinese ? "#666666" : "#9ca3af";
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
/**
|
|
327
|
+
* 提取 PDF 元数据信息
|
|
328
|
+
*/
|
|
329
|
+
private populateFromMetadata(
|
|
330
|
+
theme: ThemeStyle,
|
|
331
|
+
metadata: Record<string, unknown>
|
|
332
|
+
): void {
|
|
333
|
+
if (metadata.Title && typeof metadata.Title === "string") {
|
|
334
|
+
theme.description = `主题提取自: ${metadata.Title}`;
|
|
335
|
+
}
|
|
336
|
+
if (metadata.Author && typeof metadata.Author === "string") {
|
|
337
|
+
theme.description = `${theme.description || ""} (作者: ${metadata.Author})`;
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
/**
|
|
342
|
+
* 基于内容特征判断文档类型并应用对应预设
|
|
343
|
+
*/
|
|
344
|
+
private detectDocumentType(
|
|
345
|
+
theme: ThemeStyle,
|
|
346
|
+
_text: string,
|
|
347
|
+
pageCount: number
|
|
348
|
+
): void {
|
|
349
|
+
if (pageCount <= 2) {
|
|
350
|
+
theme.description = `${theme.description} [单页文档]`;
|
|
351
|
+
} else if (pageCount > 20) {
|
|
352
|
+
theme.description = `${theme.description} [长篇文档 ${pageCount}页]`;
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
/**
|
|
357
|
+
* 应用 DocxStyleParadigm 标准参考值填充所有缺失字段
|
|
358
|
+
*/
|
|
359
|
+
private applyParadigmDefaults(theme: ThemeStyle): void {
|
|
360
|
+
const preset = getRecommendedPreset();
|
|
361
|
+
const p = theme.palette;
|
|
362
|
+
const t = theme.typography;
|
|
363
|
+
const st = theme.seedTypography;
|
|
364
|
+
|
|
365
|
+
if (!p.textColor || p.textColor === "#000000") {
|
|
366
|
+
p.textColor = preset.body.color;
|
|
367
|
+
}
|
|
368
|
+
if (!p.headingColor) {
|
|
369
|
+
p.headingColor = preset.headings.h1.color;
|
|
370
|
+
}
|
|
371
|
+
if (!p.bgColor || p.bgColor === "#ffffff") {
|
|
372
|
+
p.bgColor = preset.pageBackground;
|
|
373
|
+
}
|
|
374
|
+
if (!p.textMuted) {
|
|
375
|
+
p.textMuted = preset.mutedTextColor;
|
|
376
|
+
}
|
|
377
|
+
if (!p.accentColor || p.accentColor === "#0000ff") {
|
|
378
|
+
p.accentColor = preset.accentColor;
|
|
379
|
+
}
|
|
380
|
+
if (!p.tableHeaderBg) {
|
|
381
|
+
p.tableHeaderBg = preset.table.headerBgColor;
|
|
382
|
+
}
|
|
383
|
+
if (!p.codeBg) {
|
|
384
|
+
p.codeBg = preset.inlineCode.bgColor;
|
|
385
|
+
}
|
|
386
|
+
if (!p.codeBlockBg) {
|
|
387
|
+
p.codeBlockBg = preset.codeBlock.bgColor;
|
|
388
|
+
}
|
|
389
|
+
if (!p.codeBlockText) {
|
|
390
|
+
p.codeBlockText = preset.codeBlock.color;
|
|
391
|
+
}
|
|
392
|
+
if (!p.blockquoteBg) {
|
|
393
|
+
p.blockquoteBg = preset.blockquote.bgColor;
|
|
394
|
+
}
|
|
395
|
+
if (!p.blockquoteBorder) {
|
|
396
|
+
p.blockquoteBorder = preset.blockquote.borderLeftColor;
|
|
397
|
+
}
|
|
398
|
+
if (!p.selectionBg) {
|
|
399
|
+
p.selectionBg = preset.selectionBg;
|
|
400
|
+
}
|
|
401
|
+
if (!p.borderColor) {
|
|
402
|
+
p.borderColor = preset.table.borderColor;
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
if (!t.bodyFontFamily || t.bodyFontFamily === "Georgia, serif") {
|
|
406
|
+
t.bodyFontFamily = preset.body.fontFamily;
|
|
407
|
+
}
|
|
408
|
+
if (!t.headingFontFamily) {
|
|
409
|
+
t.headingFontFamily = preset.headings.h1.fontFamily;
|
|
410
|
+
}
|
|
411
|
+
if (!t.baseFontSize) {
|
|
412
|
+
t.baseFontSize = `${preset.body.fontSize}px`;
|
|
413
|
+
}
|
|
414
|
+
if (t.baseLineHeight < 1.5) {
|
|
415
|
+
t.baseLineHeight = preset.body.lineHeight;
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
st.fontBody = preset.body.fontFamily;
|
|
419
|
+
st.fontHeading = preset.headings.h1.fontFamily;
|
|
420
|
+
st.lineHeightBody = preset.body.lineHeight;
|
|
421
|
+
st.lineHeightHeading = preset.headings.h1.lineHeight;
|
|
422
|
+
|
|
423
|
+
const issues = validateDocumentStyle(this.themeToParadigm(theme));
|
|
424
|
+
for (const issue of issues) {
|
|
425
|
+
if (issue.level === "error") {
|
|
426
|
+
console.warn(`[PdfExtractor] ${issue.element}: ${issue.message}`);
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
/**
|
|
432
|
+
* 将 ThemeStyle 转换为 DocumentStyleParadigm 用于 WCAG 验证
|
|
433
|
+
*/
|
|
434
|
+
private themeToParadigm(theme: ThemeStyle): DocumentStyleParadigm {
|
|
435
|
+
return {
|
|
436
|
+
pageBackground: theme.palette.bgColor,
|
|
437
|
+
headings: {
|
|
438
|
+
h1: {
|
|
439
|
+
fontFamily: theme.seedTypography.fontHeading,
|
|
440
|
+
fontSize: 16 * theme.seedTypography.fontScaleH1,
|
|
441
|
+
fontWeight: theme.typography.headingWeight,
|
|
442
|
+
color: theme.palette.headingColor,
|
|
443
|
+
lineHeight: theme.seedTypography.lineHeightHeading,
|
|
444
|
+
},
|
|
445
|
+
h2: {
|
|
446
|
+
fontFamily: theme.seedTypography.fontHeading,
|
|
447
|
+
fontSize: 16 * theme.seedTypography.fontScaleH2,
|
|
448
|
+
fontWeight: Math.max(600, theme.typography.headingWeight - 100),
|
|
449
|
+
color: theme.palette.headingColor,
|
|
450
|
+
lineHeight: theme.seedTypography.lineHeightHeading,
|
|
451
|
+
},
|
|
452
|
+
h3: {
|
|
453
|
+
fontFamily: theme.seedTypography.fontHeading,
|
|
454
|
+
fontSize: 16 * theme.seedTypography.fontScaleH3,
|
|
455
|
+
fontWeight: 600,
|
|
456
|
+
color: theme.palette.headingColor,
|
|
457
|
+
lineHeight: theme.seedTypography.lineHeightHeading + 0.05,
|
|
458
|
+
},
|
|
459
|
+
h4: {
|
|
460
|
+
fontFamily: theme.seedTypography.fontHeading,
|
|
461
|
+
fontSize: 16 * theme.seedTypography.fontScaleH4,
|
|
462
|
+
fontWeight: 600,
|
|
463
|
+
color: theme.palette.textMuted,
|
|
464
|
+
lineHeight: theme.seedTypography.lineHeightHeading + 0.05,
|
|
465
|
+
},
|
|
466
|
+
h5: {
|
|
467
|
+
fontFamily: theme.seedTypography.fontHeading,
|
|
468
|
+
fontSize: 16 * theme.seedTypography.fontScaleH5,
|
|
469
|
+
fontWeight: 500,
|
|
470
|
+
color: theme.palette.textMuted,
|
|
471
|
+
lineHeight: theme.seedTypography.lineHeightBody - 0.25,
|
|
472
|
+
},
|
|
473
|
+
h6: {
|
|
474
|
+
fontFamily: theme.seedTypography.fontHeading,
|
|
475
|
+
fontSize: 16 * theme.seedTypography.fontScaleH6,
|
|
476
|
+
fontWeight: 500,
|
|
477
|
+
color: theme.palette.textMuted,
|
|
478
|
+
lineHeight: theme.seedTypography.lineHeightBody - 0.2,
|
|
479
|
+
},
|
|
480
|
+
},
|
|
481
|
+
body: {
|
|
482
|
+
fontFamily: theme.seedTypography.fontBody,
|
|
483
|
+
fontSize: parseInt(theme.typography.baseFontSize) || 16,
|
|
484
|
+
fontWeight: 400,
|
|
485
|
+
color: theme.palette.textColor,
|
|
486
|
+
lineHeight: theme.typography.baseLineHeight,
|
|
487
|
+
},
|
|
488
|
+
blockquote: {
|
|
489
|
+
fontFamily: theme.seedTypography.fontBody,
|
|
490
|
+
fontSize: Math.max(13, (parseInt(theme.typography.baseFontSize) || 16) - 2),
|
|
491
|
+
fontWeight: 400,
|
|
492
|
+
color: theme.palette.textMuted,
|
|
493
|
+
lineHeight: theme.typography.baseLineHeight - 0.15,
|
|
494
|
+
borderLeftColor: theme.palette.blockquoteBorder,
|
|
495
|
+
bgColor: theme.palette.blockquoteBg,
|
|
496
|
+
},
|
|
497
|
+
codeBlock: {
|
|
498
|
+
fontFamily: theme.typography.codeFontFamily,
|
|
499
|
+
fontSize: Math.max(12, (parseInt(theme.typography.baseFontSize) || 16) - 3),
|
|
500
|
+
fontWeight: 400,
|
|
501
|
+
color: theme.palette.codeBlockText || theme.palette.textColor,
|
|
502
|
+
lineHeight: theme.seedTypography.lineHeightCode,
|
|
503
|
+
bgColor: theme.palette.codeBlockBg,
|
|
504
|
+
},
|
|
505
|
+
inlineCode: {
|
|
506
|
+
fontSize: Math.max(12, (parseInt(theme.typography.baseFontSize) || 16) - 3),
|
|
507
|
+
color: theme.palette.accentColor,
|
|
508
|
+
bgColor: theme.palette.codeBg,
|
|
509
|
+
},
|
|
510
|
+
table: {
|
|
511
|
+
headerFontFamily: theme.seedTypography.fontHeading,
|
|
512
|
+
headerFontSize: Math.max(12, (parseInt(theme.typography.baseFontSize) || 16) - 3),
|
|
513
|
+
headerFontWeight: 700,
|
|
514
|
+
headerColor: "#ffffff",
|
|
515
|
+
headerBgColor: theme.palette.tableHeaderBg,
|
|
516
|
+
headerLineHeight: 1.4,
|
|
517
|
+
|
|
518
|
+
cellFontFamily: theme.seedTypography.fontBody,
|
|
519
|
+
cellFontSize: Math.max(11, (parseInt(theme.typography.baseFontSize) || 16) - 4),
|
|
520
|
+
cellColor: theme.palette.textColor,
|
|
521
|
+
cellBgColor: theme.palette.bgColor,
|
|
522
|
+
cellLineHeight: 1.5,
|
|
523
|
+
cellPadding: "8px 12px",
|
|
524
|
+
borderColor: theme.palette.borderColor,
|
|
525
|
+
borderWidth: "1px",
|
|
526
|
+
},
|
|
527
|
+
|
|
528
|
+
accentColor: theme.palette.accentColor,
|
|
529
|
+
mutedTextColor: theme.palette.textMuted,
|
|
530
|
+
selectionBg: theme.palette.selectionBg,
|
|
531
|
+
};
|
|
532
|
+
}
|
|
533
|
+
}
|