CI / docs-check (push) Canceled after 0s
CI / backend-test (push) Canceled after 0s
CI / service-test (push) Canceled after 0s
CI / frontend-test (push) Canceled after 0s
CI / rust-core (push) Canceled after 0s
CI / docs-check (pull_request) Canceled after 0s
CI / backend-test (pull_request) Canceled after 0s
CI / service-test (pull_request) Canceled after 0s
CI / frontend-test (pull_request) Canceled after 0s
CI / rust-core (pull_request) Canceled after 0s
45 lines
2.3 KiB
Python
45 lines
2.3 KiB
Python
"""导出调色板是固定数据;任意主题 CSS 永远不会执行。"""
|
|
PALETTES = {
|
|
'ocean-blue': ('#edf5fa','#ffffff','#183a50','#46667a','#e6f1f8','#a6c5d9','#086b9c'),
|
|
'light': ('#f6f7f9','#ffffff','#1f2328','#57606a','#eaeef2','#d0d7de','#0969da'),
|
|
'dark': ('#010409','#0d1117','#e6edf3','#b1bac4','#21262d','#57606a','#79c0ff'),
|
|
'sepia': ('#eee5d2','#faf4e6','#463b2d','#6b5943','#eae0cd','#b5a58b','#80532a'),
|
|
'paper-moments': ('#f4ede0','#fffdf4','#514638','#79654f','#eee7d8','#b8a58f','#8c503b'),
|
|
'midnight-purple': ('#100c18','#191322','#eee7f8','#c0accf','#30253f','#705a85','#d3a7ff'),
|
|
}
|
|
|
|
def html_theme(theme_id, warnings):
|
|
if theme_id not in PALETTES:
|
|
warnings.append(f'HTML 不支持主题 {theme_id},已使用 light 导出配色')
|
|
theme_id = 'light'
|
|
names = ('page','surface','text','muted','code','border','accent')
|
|
return theme_id, ':root{' + ';'.join(f'--{k}:{v}' for k,v in zip(names,PALETTES[theme_id])) + '}'
|
|
|
|
def print_theme_warning(options, warnings, format_name):
|
|
if options.theme_id != 'light':
|
|
warnings.append(f'{format_name} 使用浅色打印样式,不支持主题 {options.theme_id};需要主题配色请导出 HTML')
|
|
|
|
# 语义类型、通用标题符号以及具有足够对比度的打印颜色。
|
|
CALLOUTS = {
|
|
'note': ('i','#0969da'), 'abstract': ('=','#7041a0'),
|
|
'info': ('i','#0969da'), 'todo': ('[ ]','#0969da'),
|
|
'tip': ('+','#176f41'), 'success': ('+','#176f41'),
|
|
'question': ('?','#805400'), 'warning': ('!','#805400'),
|
|
'failure': ('x','#b42318'), 'danger': ('!','#b42318'),
|
|
'bug': ('!','#b42318'), 'important': ('!','#7041a0'), 'example': ('*','#7041a0'), 'quote': ('>','#57606a'),
|
|
}
|
|
ALIASES = {'summary':'abstract','tldr':'abstract','hint':'tip',
|
|
'check':'success','done':'success','help':'question','faq':'question',
|
|
'caution':'warning','attention':'warning','fail':'failure','missing':'failure',
|
|
'error':'danger','cite':'quote'}
|
|
|
|
|
|
def pdf_palette(options, warnings):
|
|
if options.palette is not None:
|
|
return options.palette.model_dump()
|
|
theme_id = options.theme_id
|
|
if theme_id not in PALETTES:
|
|
warnings.append(f'PDF 不支持主题 {theme_id},已使用 light 导出配色')
|
|
theme_id = 'light'
|
|
return dict(zip(('page','surface','text','muted','code','border','accent'), PALETTES[theme_id]))
|