@abreen/tada 1.15.13 → 1.16.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.
- package/README.md +4 -0
- package/assets/material-symbols/celebration_24px.svg +1 -0
- package/assets/material-symbols/close_24px.svg +1 -0
- package/assets/material-symbols/contrast_24px.svg +1 -0
- package/assets/material-symbols/contrast_rtl_off_24px.svg +1 -0
- package/assets/material-symbols/info_24px.svg +1 -0
- package/assets/material-symbols/menu_24px.svg +1 -0
- package/assets/material-symbols/north_east_24px.svg +1 -0
- package/assets/material-symbols/search_24px.svg +1 -0
- package/assets/material-symbols/south_east_24px.svg +1 -0
- package/assets/material-symbols/tag_24px.svg +1 -0
- package/assets/material-symbols/warning_24px.svg +1 -0
- package/bin/validators.ts +2 -0
- package/build/bundle.ts +7 -12
- package/build/generate-fonts.ts +17 -0
- package/build/material-symbols.ts +107 -0
- package/build/site-variables.ts +2 -0
- package/build/types.d.ts +2 -0
- package/build/utils/markdown.ts +11 -43
- package/build/utils/render.ts +24 -8
- package/build/watch/assets.ts +3 -3
- package/fonts/libertinus-mono/LICENSE.txt +99 -0
- package/fonts/libertinus-mono/woff2/LibertinusMono-Regular.woff2 +0 -0
- package/fonts/source-serif-4/LICENSE.txt +91 -0
- package/fonts/source-serif-4/woff2/SourceSerif4-Italic-VariableFont_opsz,wght.woff2 +0 -0
- package/fonts/source-serif-4/woff2/SourceSerif4-VariableFont_opsz,wght.woff2 +0 -0
- package/package.json +2 -1
- package/schema/site.schema.json +10 -0
- package/src/_alerts.scss +1 -1
- package/src/_base.scss +2 -16
- package/src/anchor/index.ts +14 -10
- package/src/anchor/style.scss +10 -10
- package/src/appearance-picker/index.ts +214 -0
- package/src/appearance-picker/style.scss +130 -0
- package/src/code.scss +1 -0
- package/src/header/_base.scss +34 -6
- package/src/header/style.scss +8 -0
- package/src/index.ts +2 -0
- package/src/material-symbols.scss +11 -0
- package/src/navigate/lifecycle.ts +2 -0
- package/src/search/style.scss +0 -1
- package/src/slides/style.scss +1 -0
- package/src/style.scss +30 -28
- package/src/toc/style.scss +3 -1
- package/src/trace/style.scss +1 -0
- package/templates/_appearance-picker.html +18 -0
- package/templates/_theme.scss +43 -13
- package/templates/_top.html +38 -2
- package/templates/code.html +1 -0
- package/templates/default.html +1 -0
- package/templates/literate.html +1 -0
package/README.md
CHANGED
|
@@ -219,6 +219,8 @@ titlePostfix: " - CS 0"
|
|
|
219
219
|
symbol: CS 0
|
|
220
220
|
themeColor: hsl(351 70% 40%)
|
|
221
221
|
tintAmount: 0
|
|
222
|
+
defaultFont: serif
|
|
223
|
+
defaultContrast: high
|
|
222
224
|
features:
|
|
223
225
|
search: true
|
|
224
226
|
favicon: true
|
|
@@ -245,6 +247,8 @@ vars:
|
|
|
245
247
|
| `themeColor` | Theme color for the site (e.g., `"tomato"`, `"#c04040"`, `"hsl(195 70% 40%)"`) |
|
|
246
248
|
| `tintHue` | *Optional*, hue (0-360) for background and foreground tinting (default `20`) |
|
|
247
249
|
| `tintAmount` | *Optional*, percentage (0-100) of tint to apply (default `100`) |
|
|
250
|
+
| `defaultFont` | *Optional*, initial font pairing: `sans` or `serif` (default `sans`) |
|
|
251
|
+
| `defaultContrast` | *Optional*, initial neutral-palette contrast: `standard` or `high` (default `standard`) |
|
|
248
252
|
| `faviconSymbol` | *Optional*, the text to use instead of `symbol` in the favicon |
|
|
249
253
|
| `features.search` | Enable search UI and Pagefind index generation |
|
|
250
254
|
| `features.favicon` | Enable automatically generated favicons |
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24"><path d="m80-80 200-560 360 360L80-80Zm132-132 282-100-182-182-100 282Zm370-246-42-42 224-224q32-32 77-32t77 32l24 24-42 42-24-24q-14-14-35-14t-35 14L582-458ZM422-618l-42-42 24-24q14-14 14-34t-14-34l-26-26 42-42 26 26q32 32 32 76t-32 76l-24 24Zm80 80-42-42 144-144q14-14 14-35t-14-35l-64-64 42-42 64 64q32 32 32 77t-32 77L502-538Zm160 160-42-42 64-64q32-32 77-32t77 32l64 64-42 42-64-64q-14-14-35-14t-35 14l-64 64ZM212-212Z"/></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24"><path d="m256-200-56-56 224-224-224-224 56-56 224 224 224-224 56 56-224 224 224 224-56 56-224-224-224 224Z"/></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24"><path d="M480-80q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm40-83q119-15 199.5-104.5T800-480q0-123-80.5-212.5T520-797v634Z"/></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24"><path d="M819-28 701-146q-48 32-103.5 49T480-80q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-62 17-117.5T146-701L27-820l57-57L876-85l-57 57ZM480-160q45 0 85.5-12t76.5-33L480-367v207Zm335-100-59-59q21-35 32.5-75.5T800-480q0-133-93.5-226.5T480-800v205L260-815q48-31 103.5-48T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 61-17 116.5T815-260Z"/></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24"><path d="M440-280h80v-240h-80v240Zm40-320q17 0 28.5-11.5T520-640q0-17-11.5-28.5T480-680q-17 0-28.5 11.5T440-640q0 17 11.5 28.5T480-600Zm0 520q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-80q134 0 227-93t93-227q0-134-93-227t-227-93q-134 0-227 93t-93 227q0 134 93 227t227 93Zm0-320Z"/></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24"><path d="M120-240v-80h720v80H120Zm0-200v-80h720v80H120Zm0-200v-80h720v80H120Z"/></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24"><path d="m216-160-56-56 464-464H360v-80h400v400h-80v-264L216-160Z"/></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24"><path d="M784-120 532-372q-30 24-69 38t-83 14q-109 0-184.5-75.5T120-580q0-109 75.5-184.5T380-840q109 0 184.5 75.5T640-580q0 44-14 83t-38 69l252 252-56 56ZM380-400q75 0 127.5-52.5T560-580q0-75-52.5-127.5T380-760q-75 0-127.5 52.5T200-580q0 75 52.5 127.5T380-400Z"/></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24"><path d="M360-200v-80h264L160-744l56-56 464 464v-264h80v400H360Z"/></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24"><path d="m240-160 40-160H120l20-80h160l40-160H180l20-80h160l40-160h80l-40 160h160l40-160h80l-40 160h160l-20 80H660l-40 160h160l-20 80H600l-40 160h-80l40-160H360l-40 160h-80Zm140-240h160l40-160H420l-40 160Z"/></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24"><path d="m40-120 440-760 440 760H40Zm138-80h604L480-720 178-200Zm302-40q17 0 28.5-11.5T520-280q0-17-11.5-28.5T480-320q-17 0-28.5 11.5T440-280q0 17 11.5 28.5T480-240Zm-40-120h80v-200h-80v200Zm40-100Z"/></svg>
|
package/bin/validators.ts
CHANGED
package/build/bundle.ts
CHANGED
|
@@ -18,6 +18,7 @@ import type { PluginBuilder } from 'bun';
|
|
|
18
18
|
import type { SiteVariables } from './types';
|
|
19
19
|
import timezones from '../src/timezone/timezones.json' with { type: 'json' };
|
|
20
20
|
import pkg from '../package.json' with { type: 'json' };
|
|
21
|
+
import { renderMaterialSymbolVariables } from './material-symbols';
|
|
21
22
|
|
|
22
23
|
interface BunBuildPlugin {
|
|
23
24
|
name: string;
|
|
@@ -52,12 +53,6 @@ function renderThemeScss(siteVariables: SiteVariables): string {
|
|
|
52
53
|
const tintHue = siteVariables.tintHue ?? 20;
|
|
53
54
|
const tintAmount = siteVariables.tintAmount ?? 100;
|
|
54
55
|
|
|
55
|
-
const iconColor = `hsl(${tintHue}deg ${(8 * tintAmount) / 100}% 8%)`;
|
|
56
|
-
const iconColorHover = `hsl(${tintHue}deg ${(6 * tintAmount) / 100}% 45%)`;
|
|
57
|
-
const iconColorDark = `hsl(${tintHue}deg ${(20 * tintAmount) / 100}% 90%)`;
|
|
58
|
-
const iconColorHoverDark = `hsl(${tintHue}deg ${(6 * tintAmount) / 100}% 60%)`;
|
|
59
|
-
const iconColorTranslucentDark = `hsl(${tintHue}deg ${(85 * tintAmount) / 100}% 90%)`;
|
|
60
|
-
|
|
61
56
|
const linkHue = formatCssNumber(deriveLinkHue(tintHue));
|
|
62
57
|
const linkColor = `hsl(${linkHue}deg 44.4% 49.4%)`;
|
|
63
58
|
const linkColorHover = `hsl(${linkHue}deg 34% 60%)`;
|
|
@@ -66,16 +61,12 @@ function renderThemeScss(siteVariables: SiteVariables): string {
|
|
|
66
61
|
const traceLineActiveHue = formatCssNumber(deriveTraceLineActiveHue(tintHue));
|
|
67
62
|
const bgTraceLineActive = `hsl(${traceLineActiveHue}deg 100% 86%)`;
|
|
68
63
|
const bgTraceLineActiveDark = `hsl(${traceLineActiveHue}deg 90% 18%)`;
|
|
64
|
+
const materialSymbolVariables = renderMaterialSymbolVariables();
|
|
69
65
|
|
|
70
|
-
const
|
|
66
|
+
const renderedTemplate = _.template(template)({
|
|
71
67
|
...theme,
|
|
72
68
|
tintHue,
|
|
73
69
|
tintAmount,
|
|
74
|
-
iconColor,
|
|
75
|
-
iconColorHover,
|
|
76
|
-
iconColorDark,
|
|
77
|
-
iconColorHoverDark,
|
|
78
|
-
iconColorTranslucentDark,
|
|
79
70
|
linkColor,
|
|
80
71
|
linkColorHover,
|
|
81
72
|
linkColorDark,
|
|
@@ -83,6 +74,10 @@ function renderThemeScss(siteVariables: SiteVariables): string {
|
|
|
83
74
|
bgTraceLineActive,
|
|
84
75
|
bgTraceLineActiveDark,
|
|
85
76
|
});
|
|
77
|
+
const rendered = renderedTemplate.replace(
|
|
78
|
+
'/* TADA_MATERIAL_SYMBOL_VARIABLES */',
|
|
79
|
+
materialSymbolVariables,
|
|
80
|
+
);
|
|
86
81
|
|
|
87
82
|
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'tada-'));
|
|
88
83
|
const configDir = path.join(tmpDir, 'config');
|
package/build/generate-fonts.ts
CHANGED
|
@@ -6,6 +6,23 @@ import { makeLogger } from './log';
|
|
|
6
6
|
const log = makeLogger(import.meta.url);
|
|
7
7
|
const FONTS_DIR = path.join(getPackageDir(), 'fonts');
|
|
8
8
|
|
|
9
|
+
export const DEFAULT_FONT_PRELOAD_FILES = {
|
|
10
|
+
sans: [
|
|
11
|
+
'inter/InterVariable.woff2',
|
|
12
|
+
'google-sans-code/GoogleSansCodeVariable.woff2',
|
|
13
|
+
],
|
|
14
|
+
serif: [
|
|
15
|
+
'source-serif-4/SourceSerif4-VariableFont_opsz,wght.woff2',
|
|
16
|
+
'libertinus-mono/LibertinusMono-Regular.woff2',
|
|
17
|
+
],
|
|
18
|
+
} as const;
|
|
19
|
+
|
|
20
|
+
export function getDefaultFontPreloadFiles(
|
|
21
|
+
defaultFont: 'sans' | 'serif' | undefined,
|
|
22
|
+
): readonly string[] {
|
|
23
|
+
return DEFAULT_FONT_PRELOAD_FILES[defaultFont ?? 'sans'];
|
|
24
|
+
}
|
|
25
|
+
|
|
9
26
|
export function copyFonts(distDir: string): void {
|
|
10
27
|
log.info`Copying fonts`;
|
|
11
28
|
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { getPackageDir } from './utils/paths';
|
|
4
|
+
|
|
5
|
+
export const MATERIAL_SYMBOL_CONFIG = Object.freeze({
|
|
6
|
+
family: 'Material Symbols Outlined',
|
|
7
|
+
fill: 0,
|
|
8
|
+
weight: 400,
|
|
9
|
+
grade: 0,
|
|
10
|
+
opticalSize: 24,
|
|
11
|
+
viewBox: '0 -960 960 960',
|
|
12
|
+
source:
|
|
13
|
+
'https://github.com/google/material-design-icons/tree/master/symbols/web',
|
|
14
|
+
} as const);
|
|
15
|
+
|
|
16
|
+
export const MATERIAL_SYMBOLS = Object.freeze({
|
|
17
|
+
tada: Object.freeze({ cssVariable: '--icon-tada', symbol: 'celebration' }),
|
|
18
|
+
contrastStandard: Object.freeze({
|
|
19
|
+
cssVariable: '--icon-contrast-standard',
|
|
20
|
+
symbol: 'contrast_rtl_off',
|
|
21
|
+
}),
|
|
22
|
+
contrastHigh: Object.freeze({
|
|
23
|
+
cssVariable: '--icon-contrast-high',
|
|
24
|
+
symbol: 'contrast',
|
|
25
|
+
}),
|
|
26
|
+
info: Object.freeze({ cssVariable: '--icon-info', symbol: 'info' }),
|
|
27
|
+
warning: Object.freeze({ cssVariable: '--icon-warning', symbol: 'warning' }),
|
|
28
|
+
parent: Object.freeze({ cssVariable: '--icon-parent', symbol: 'south_east' }),
|
|
29
|
+
search: Object.freeze({ cssVariable: '--icon-search', symbol: 'search' }),
|
|
30
|
+
externalLink: Object.freeze({
|
|
31
|
+
cssVariable: '--icon-external-link',
|
|
32
|
+
symbol: 'north_east',
|
|
33
|
+
}),
|
|
34
|
+
headingAnchor: Object.freeze({
|
|
35
|
+
cssVariable: '--icon-heading-anchor',
|
|
36
|
+
symbol: 'tag',
|
|
37
|
+
}),
|
|
38
|
+
headerMenu: Object.freeze({
|
|
39
|
+
cssVariable: '--icon-header-menu',
|
|
40
|
+
symbol: 'menu',
|
|
41
|
+
}),
|
|
42
|
+
headerClose: Object.freeze({
|
|
43
|
+
cssVariable: '--icon-header-close',
|
|
44
|
+
symbol: 'close',
|
|
45
|
+
}),
|
|
46
|
+
} as const);
|
|
47
|
+
|
|
48
|
+
type MaterialSymbol = (typeof MATERIAL_SYMBOLS)[keyof typeof MATERIAL_SYMBOLS];
|
|
49
|
+
|
|
50
|
+
interface RenderMaterialSymbolOptions {
|
|
51
|
+
packageDir?: string;
|
|
52
|
+
readFile?: (filePath: string) => string;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function getAssetPath(packageDir: string, symbol: MaterialSymbol): string {
|
|
56
|
+
return path.join(
|
|
57
|
+
packageDir,
|
|
58
|
+
'assets/material-symbols',
|
|
59
|
+
`${symbol.symbol}_${MATERIAL_SYMBOL_CONFIG.opticalSize}px.svg`,
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function isConfiguredSvg(svg: string): boolean {
|
|
64
|
+
const svgTag = svg.match(/<svg\b[^>]*>/)?.[0];
|
|
65
|
+
if (!svgTag) {
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const hasAttribute = (name: string, value: string) =>
|
|
70
|
+
new RegExp(`\\b${name}=["']${value}["']`).test(svgTag);
|
|
71
|
+
|
|
72
|
+
return (
|
|
73
|
+
hasAttribute('width', String(MATERIAL_SYMBOL_CONFIG.opticalSize)) &&
|
|
74
|
+
hasAttribute('height', String(MATERIAL_SYMBOL_CONFIG.opticalSize)) &&
|
|
75
|
+
hasAttribute('viewBox', MATERIAL_SYMBOL_CONFIG.viewBox)
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export function renderMaterialSymbolVariables({
|
|
80
|
+
packageDir = getPackageDir(),
|
|
81
|
+
readFile = filePath => fs.readFileSync(filePath, 'utf8'),
|
|
82
|
+
}: RenderMaterialSymbolOptions = {}): string {
|
|
83
|
+
return Object.values(MATERIAL_SYMBOLS)
|
|
84
|
+
.map(symbol => {
|
|
85
|
+
const assetPath = getAssetPath(packageDir, symbol);
|
|
86
|
+
let svg: string;
|
|
87
|
+
|
|
88
|
+
try {
|
|
89
|
+
svg = readFile(assetPath);
|
|
90
|
+
} catch (error) {
|
|
91
|
+
throw new Error(
|
|
92
|
+
`Material Symbol "${symbol.symbol}" could not be read from ${assetPath}`,
|
|
93
|
+
{ cause: error },
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
if (!isConfiguredSvg(svg)) {
|
|
98
|
+
throw new Error(
|
|
99
|
+
`Material Symbol "${symbol.symbol}" does not match the configured ${MATERIAL_SYMBOL_CONFIG.opticalSize}px SVG format: ${assetPath}`,
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const dataUri = `data:image/svg+xml,${encodeURIComponent(svg.trim())}`;
|
|
104
|
+
return ` ${symbol.cssVariable}: url("${dataUri}");`;
|
|
105
|
+
})
|
|
106
|
+
.join('\n');
|
|
107
|
+
}
|
package/build/site-variables.ts
CHANGED
package/build/types.d.ts
CHANGED
|
@@ -16,6 +16,8 @@ export interface SiteVariables {
|
|
|
16
16
|
faviconFontWeight?: number;
|
|
17
17
|
internalDomains?: string[];
|
|
18
18
|
defaultTimeZone: string;
|
|
19
|
+
defaultFont?: 'sans' | 'serif';
|
|
20
|
+
defaultContrast?: 'standard' | 'high';
|
|
19
21
|
features: FeatureConfig;
|
|
20
22
|
extensionToShikiLanguage?: Record<
|
|
21
23
|
string,
|
package/build/utils/markdown.ts
CHANGED
|
@@ -49,22 +49,6 @@ function capitalize(str: string): string {
|
|
|
49
49
|
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
const MAX_FOOTNOTES = 35;
|
|
53
|
-
|
|
54
|
-
export function footnoteLabel(oneBasedIndex: number): string {
|
|
55
|
-
if (oneBasedIndex < 1 || oneBasedIndex > MAX_FOOTNOTES) {
|
|
56
|
-
throw new Error(
|
|
57
|
-
`Tada supports at most ${MAX_FOOTNOTES} footnotes per page ` +
|
|
58
|
-
`(9 digits + 26 capital letters), but footnote ${oneBasedIndex} ` +
|
|
59
|
-
`was requested. Reduce the number of footnotes on this page.`,
|
|
60
|
-
);
|
|
61
|
-
}
|
|
62
|
-
if (oneBasedIndex <= 9) {
|
|
63
|
-
return String(oneBasedIndex);
|
|
64
|
-
}
|
|
65
|
-
return String.fromCharCode('A'.charCodeAt(0) + (oneBasedIndex - 10));
|
|
66
|
-
}
|
|
67
|
-
|
|
68
52
|
export function createMarkdown(
|
|
69
53
|
siteVariables: SiteVariables,
|
|
70
54
|
options: CreateMarkdownOptions = {},
|
|
@@ -624,23 +608,22 @@ export function createMarkdown(
|
|
|
624
608
|
);
|
|
625
609
|
};
|
|
626
610
|
|
|
627
|
-
/*
|
|
628
|
-
* Customize markdown-it-footnote renderer.
|
|
629
|
-
*
|
|
630
|
-
* Footnotes are labeled with single characters from Inter's ss06
|
|
631
|
-
* stylistic set: 1-9 for the first nine footnotes, then A-Z. The
|
|
632
|
-
* default <ol> numbering is suppressed via CSS and we inject a
|
|
633
|
-
* marker span per item so the label sequence can mix digits and
|
|
634
|
-
* letters.
|
|
635
|
-
*/
|
|
611
|
+
/* Customize markdown-it-footnote renderer. */
|
|
636
612
|
markdown.renderer.rules.footnote_block_open = () =>
|
|
637
613
|
'<div class="footnotes"><p class="title">Footnotes</p><ol>';
|
|
638
614
|
|
|
639
615
|
markdown.renderer.rules.footnote_block_close = () => '</ol></div>';
|
|
640
616
|
|
|
641
|
-
markdown.renderer.rules.footnote_caption
|
|
642
|
-
|
|
643
|
-
|
|
617
|
+
const caption = markdown.renderer.rules.footnote_caption!;
|
|
618
|
+
markdown.renderer.rules.footnote_caption = (
|
|
619
|
+
tokens: Token[],
|
|
620
|
+
idx: number,
|
|
621
|
+
options: Options,
|
|
622
|
+
env: unknown,
|
|
623
|
+
self: Renderer,
|
|
624
|
+
) => {
|
|
625
|
+
const str = caption(tokens, idx, options, env, self);
|
|
626
|
+
return str.slice(1, str.length - 1);
|
|
644
627
|
};
|
|
645
628
|
|
|
646
629
|
const footnoteRef = markdown.renderer.rules.footnote_ref!;
|
|
@@ -651,26 +634,11 @@ export function createMarkdown(
|
|
|
651
634
|
env: unknown,
|
|
652
635
|
self: Renderer,
|
|
653
636
|
) =>
|
|
654
|
-
// Prepend a non-breaking space so the reference link cannot wrap
|
|
655
|
-
// away from the word it follows.
|
|
656
|
-
'\u00a0' +
|
|
657
637
|
footnoteRef(tokens, idx, options, env, self)
|
|
658
638
|
.replace('<sup class="footnote-ref">', '')
|
|
659
639
|
.replace('</sup>', '')
|
|
660
640
|
.replace('<a href="', '<a class="footnote-ref" href="');
|
|
661
641
|
|
|
662
|
-
markdown.renderer.rules.footnote_open = (tokens: Token[], idx: number) => {
|
|
663
|
-
const id = tokens[idx].meta!.id as number;
|
|
664
|
-
const label = footnoteLabel(id + 1);
|
|
665
|
-
const refid = id + 1;
|
|
666
|
-
return (
|
|
667
|
-
`<li id="fn${refid}" class="footnote-item">` +
|
|
668
|
-
`<span class="footnote-marker" aria-hidden="true">${label}</span> `
|
|
669
|
-
);
|
|
670
|
-
};
|
|
671
|
-
|
|
672
|
-
markdown.renderer.rules.footnote_close = () => '</li>\n';
|
|
673
|
-
|
|
674
642
|
const footnoteAnchor = markdown.renderer.rules.footnote_anchor!;
|
|
675
643
|
markdown.renderer.rules.footnote_anchor = (
|
|
676
644
|
tokens: Token[],
|
package/build/utils/render.ts
CHANGED
|
@@ -7,6 +7,7 @@ import { makeLogger } from '../log';
|
|
|
7
7
|
import { B } from '../colors';
|
|
8
8
|
import createTemplateGlobals from '../template-globals';
|
|
9
9
|
import { getExtensionToShikiLanguage } from '../site-variables';
|
|
10
|
+
import { getDefaultFontPreloadFiles } from '../generate-fonts';
|
|
10
11
|
import { config } from '../templates';
|
|
11
12
|
import { render } from '../templates';
|
|
12
13
|
import {
|
|
@@ -157,6 +158,7 @@ export function injectAssetTags(
|
|
|
157
158
|
html: string,
|
|
158
159
|
assetFiles: string[],
|
|
159
160
|
distDir: string,
|
|
161
|
+
siteVariables: SiteVariables,
|
|
160
162
|
): string {
|
|
161
163
|
const jsAssets = assetFiles.filter(f => f.endsWith('.js'));
|
|
162
164
|
const cssAssets = assetFiles.filter(f => f.endsWith('.css'));
|
|
@@ -182,10 +184,7 @@ export function injectAssetTags(
|
|
|
182
184
|
)
|
|
183
185
|
.join('');
|
|
184
186
|
|
|
185
|
-
const fontPreloadTags =
|
|
186
|
-
'inter/InterVariable.woff2',
|
|
187
|
-
'google-sans-code/GoogleSansCodeVariable.woff2',
|
|
188
|
-
]
|
|
187
|
+
const fontPreloadTags = getDefaultFontPreloadFiles(siteVariables.defaultFont)
|
|
189
188
|
.filter(f => fs.existsSync(path.join(distDir, f)))
|
|
190
189
|
.map(
|
|
191
190
|
f =>
|
|
@@ -210,12 +209,14 @@ export function preparePageTemplateHtml({
|
|
|
210
209
|
templateHtml,
|
|
211
210
|
assetFiles,
|
|
212
211
|
distDir,
|
|
212
|
+
siteVariables,
|
|
213
213
|
}: {
|
|
214
214
|
templateHtml: string;
|
|
215
215
|
assetFiles: string[];
|
|
216
216
|
distDir: string;
|
|
217
|
+
siteVariables: SiteVariables;
|
|
217
218
|
}): string {
|
|
218
|
-
let html = injectAssetTags(templateHtml, assetFiles, distDir);
|
|
219
|
+
let html = injectAssetTags(templateHtml, assetFiles, distDir, siteVariables);
|
|
219
220
|
if (templateHtml.includes('class="katex"')) {
|
|
220
221
|
html = injectKatexStylesheet(html);
|
|
221
222
|
}
|
|
@@ -289,7 +290,12 @@ export function renderPlainTextPageAsset({
|
|
|
289
290
|
) as string;
|
|
290
291
|
const finalized = finalizeHtmlPage({
|
|
291
292
|
filePath,
|
|
292
|
-
html: preparePageTemplateHtml({
|
|
293
|
+
html: preparePageTemplateHtml({
|
|
294
|
+
templateHtml,
|
|
295
|
+
assetFiles,
|
|
296
|
+
distDir,
|
|
297
|
+
siteVariables,
|
|
298
|
+
}),
|
|
293
299
|
siteVariables,
|
|
294
300
|
sourceUrlPath,
|
|
295
301
|
validInternalTargets,
|
|
@@ -362,7 +368,12 @@ export function renderCodePageAsset({
|
|
|
362
368
|
const templateHtml = render('code.html', templateParameters) as string;
|
|
363
369
|
const finalized = finalizeHtmlPage({
|
|
364
370
|
filePath,
|
|
365
|
-
html: preparePageTemplateHtml({
|
|
371
|
+
html: preparePageTemplateHtml({
|
|
372
|
+
templateHtml,
|
|
373
|
+
assetFiles,
|
|
374
|
+
distDir,
|
|
375
|
+
siteVariables,
|
|
376
|
+
}),
|
|
366
377
|
siteVariables,
|
|
367
378
|
sourceUrlPath,
|
|
368
379
|
validInternalTargets,
|
|
@@ -700,7 +711,12 @@ export function renderLiterateJavaPageAsset({
|
|
|
700
711
|
const templateHtml = render('literate.html', templateParameters) as string;
|
|
701
712
|
const finalized = finalizeHtmlPage({
|
|
702
713
|
filePath,
|
|
703
|
-
html: preparePageTemplateHtml({
|
|
714
|
+
html: preparePageTemplateHtml({
|
|
715
|
+
templateHtml,
|
|
716
|
+
assetFiles,
|
|
717
|
+
distDir,
|
|
718
|
+
siteVariables,
|
|
719
|
+
}),
|
|
704
720
|
siteVariables,
|
|
705
721
|
sourceUrlPath,
|
|
706
722
|
validInternalTargets,
|
package/build/watch/assets.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import { bundle, getBundleNaming } from '../bundle';
|
|
4
|
-
import { copyFonts } from '../generate-fonts';
|
|
4
|
+
import { copyFonts, DEFAULT_FONT_PRELOAD_FILES } from '../generate-fonts';
|
|
5
5
|
import { copyKatexAssets } from '../generate-katex-assets';
|
|
6
6
|
import { generateFavicons } from '../generate-favicon';
|
|
7
7
|
import { generateWebAppManifest } from '../generate-web-app-manifest';
|
|
@@ -72,8 +72,8 @@ export function copyExistingBuildAssets(
|
|
|
72
72
|
): void {
|
|
73
73
|
const relPaths = [
|
|
74
74
|
...assetFiles,
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
...DEFAULT_FONT_PRELOAD_FILES.sans,
|
|
76
|
+
...DEFAULT_FONT_PRELOAD_FILES.serif,
|
|
77
77
|
];
|
|
78
78
|
|
|
79
79
|
for (const relPath of relPaths) {
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
Copyright 2025 The Libertinus Keyboard Project Authors (https://github.com/googlefonts/libertinus)
|
|
2
|
+
Copyright 2025 The Libertinus Math Project Authors (https://github.com/googlefonts/libertinus)
|
|
3
|
+
Copyright 2025 The Libertinus Mono Project Authors (https://github.com/googlefonts/libertinus)
|
|
4
|
+
Copyright 2025 The Libertinus Sans Project Authors (https://github.com/googlefonts/libertinus)
|
|
5
|
+
Copyright 2025 The Libertinus Serif Project Authors (https://github.com/googlefonts/libertinus)
|
|
6
|
+
Copyright 2025 The Libertinus Serif Display Project Authors (https://github.com/googlefonts/libertinus)
|
|
7
|
+
Copyright 2025 The Libertinus Serif Initials Project Authors (https://github.com/googlefonts/libertinus)
|
|
8
|
+
|
|
9
|
+
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
|
10
|
+
This license is copied below, and is also available with a FAQ at:
|
|
11
|
+
https://openfontlicense.org
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
-----------------------------------------------------------
|
|
15
|
+
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
|
16
|
+
-----------------------------------------------------------
|
|
17
|
+
|
|
18
|
+
PREAMBLE
|
|
19
|
+
The goals of the Open Font License (OFL) are to stimulate worldwide
|
|
20
|
+
development of collaborative font projects, to support the font creation
|
|
21
|
+
efforts of academic and linguistic communities, and to provide a free and
|
|
22
|
+
open framework in which fonts may be shared and improved in partnership
|
|
23
|
+
with others.
|
|
24
|
+
|
|
25
|
+
The OFL allows the licensed fonts to be used, studied, modified and
|
|
26
|
+
redistributed freely as long as they are not sold by themselves. The
|
|
27
|
+
fonts, including any derivative works, can be bundled, embedded,
|
|
28
|
+
redistributed and/or sold with any software provided that any reserved
|
|
29
|
+
names are not used by derivative works. The fonts and derivatives,
|
|
30
|
+
however, cannot be released under any other type of license. The
|
|
31
|
+
requirement for fonts to remain under this license does not apply
|
|
32
|
+
to any document created using the fonts or their derivatives.
|
|
33
|
+
|
|
34
|
+
DEFINITIONS
|
|
35
|
+
"Font Software" refers to the set of files released by the Copyright
|
|
36
|
+
Holder(s) under this license and clearly marked as such. This may
|
|
37
|
+
include source files, build scripts and documentation.
|
|
38
|
+
|
|
39
|
+
"Reserved Font Name" refers to any names specified as such after the
|
|
40
|
+
copyright statement(s).
|
|
41
|
+
|
|
42
|
+
"Original Version" refers to the collection of Font Software components as
|
|
43
|
+
distributed by the Copyright Holder(s).
|
|
44
|
+
|
|
45
|
+
"Modified Version" refers to any derivative made by adding to, deleting,
|
|
46
|
+
or substituting -- in part or in whole -- any of the components of the
|
|
47
|
+
Original Version, by changing formats or by porting the Font Software to a
|
|
48
|
+
new environment.
|
|
49
|
+
|
|
50
|
+
"Author" refers to any designer, engineer, programmer, technical
|
|
51
|
+
writer or other person who contributed to the Font Software.
|
|
52
|
+
|
|
53
|
+
PERMISSION & CONDITIONS
|
|
54
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
55
|
+
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
|
56
|
+
redistribute, and sell modified and unmodified copies of the Font
|
|
57
|
+
Software, subject to the following conditions:
|
|
58
|
+
|
|
59
|
+
1) Neither the Font Software nor any of its individual components,
|
|
60
|
+
in Original or Modified Versions, may be sold by itself.
|
|
61
|
+
|
|
62
|
+
2) Original or Modified Versions of the Font Software may be bundled,
|
|
63
|
+
redistributed and/or sold with any software, provided that each copy
|
|
64
|
+
contains the above copyright notice and this license. These can be
|
|
65
|
+
included either as stand-alone text files, human-readable headers or
|
|
66
|
+
in the appropriate machine-readable metadata fields within text or
|
|
67
|
+
binary files as long as those fields can be easily viewed by the user.
|
|
68
|
+
|
|
69
|
+
3) No Modified Version of the Font Software may use the Reserved Font
|
|
70
|
+
Name(s) unless explicit written permission is granted by the corresponding
|
|
71
|
+
Copyright Holder. This restriction only applies to the primary font name as
|
|
72
|
+
presented to the users.
|
|
73
|
+
|
|
74
|
+
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
|
75
|
+
Software shall not be used to promote, endorse or advertise any
|
|
76
|
+
Modified Version, except to acknowledge the contribution(s) of the
|
|
77
|
+
Copyright Holder(s) and the Author(s) or with their explicit written
|
|
78
|
+
permission.
|
|
79
|
+
|
|
80
|
+
5) The Font Software, modified or unmodified, in part or in whole,
|
|
81
|
+
must be distributed entirely under this license, and must not be
|
|
82
|
+
distributed under any other license. The requirement for fonts to
|
|
83
|
+
remain under this license does not apply to any document created
|
|
84
|
+
using the Font Software.
|
|
85
|
+
|
|
86
|
+
TERMINATION
|
|
87
|
+
This license becomes null and void if any of the above conditions are
|
|
88
|
+
not met.
|
|
89
|
+
|
|
90
|
+
DISCLAIMER
|
|
91
|
+
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
92
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
|
93
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
|
94
|
+
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
|
95
|
+
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
96
|
+
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
|
97
|
+
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
98
|
+
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
|
99
|
+
OTHER DEALINGS IN THE FONT SOFTWARE.
|
|
Binary file
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
|
2
|
+
This license is copied below, and is also available with a FAQ at:
|
|
3
|
+
https://openfontlicense.org
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
-----------------------------------------------------------
|
|
7
|
+
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
|
8
|
+
-----------------------------------------------------------
|
|
9
|
+
|
|
10
|
+
PREAMBLE
|
|
11
|
+
The goals of the Open Font License (OFL) are to stimulate worldwide
|
|
12
|
+
development of collaborative font projects, to support the font creation
|
|
13
|
+
efforts of academic and linguistic communities, and to provide a free and
|
|
14
|
+
open framework in which fonts may be shared and improved in partnership
|
|
15
|
+
with others.
|
|
16
|
+
|
|
17
|
+
The OFL allows the licensed fonts to be used, studied, modified and
|
|
18
|
+
redistributed freely as long as they are not sold by themselves. The
|
|
19
|
+
fonts, including any derivative works, can be bundled, embedded,
|
|
20
|
+
redistributed and/or sold with any software provided that any reserved
|
|
21
|
+
names are not used by derivative works. The fonts and derivatives,
|
|
22
|
+
however, cannot be released under any other type of license. The
|
|
23
|
+
requirement for fonts to remain under this license does not apply
|
|
24
|
+
to any document created using the fonts or their derivatives.
|
|
25
|
+
|
|
26
|
+
DEFINITIONS
|
|
27
|
+
"Font Software" refers to the set of files released by the Copyright
|
|
28
|
+
Holder(s) under this license and clearly marked as such. This may
|
|
29
|
+
include source files, build scripts and documentation.
|
|
30
|
+
|
|
31
|
+
"Reserved Font Name" refers to any names specified as such after the
|
|
32
|
+
copyright statement(s).
|
|
33
|
+
|
|
34
|
+
"Original Version" refers to the collection of Font Software components as
|
|
35
|
+
distributed by the Copyright Holder(s).
|
|
36
|
+
|
|
37
|
+
"Modified Version" refers to any derivative made by adding to, deleting,
|
|
38
|
+
or substituting -- in part or in whole -- any of the components of the
|
|
39
|
+
Original Version, by changing formats or by porting the Font Software to a
|
|
40
|
+
new environment.
|
|
41
|
+
|
|
42
|
+
"Author" refers to any designer, engineer, programmer, technical
|
|
43
|
+
writer or other person who contributed to the Font Software.
|
|
44
|
+
|
|
45
|
+
PERMISSION & CONDITIONS
|
|
46
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
47
|
+
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
|
48
|
+
redistribute, and sell modified and unmodified copies of the Font
|
|
49
|
+
Software, subject to the following conditions:
|
|
50
|
+
|
|
51
|
+
1) Neither the Font Software nor any of its individual components,
|
|
52
|
+
in Original or Modified Versions, may be sold by itself.
|
|
53
|
+
|
|
54
|
+
2) Original or Modified Versions of the Font Software may be bundled,
|
|
55
|
+
redistributed and/or sold with any software, provided that each copy
|
|
56
|
+
contains the above copyright notice and this license. These can be
|
|
57
|
+
included either as stand-alone text files, human-readable headers or
|
|
58
|
+
in the appropriate machine-readable metadata fields within text or
|
|
59
|
+
binary files as long as those fields can be easily viewed by the user.
|
|
60
|
+
|
|
61
|
+
3) No Modified Version of the Font Software may use the Reserved Font
|
|
62
|
+
Name(s) unless explicit written permission is granted by the corresponding
|
|
63
|
+
Copyright Holder. This restriction only applies to the primary font name as
|
|
64
|
+
presented to the users.
|
|
65
|
+
|
|
66
|
+
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
|
67
|
+
Software shall not be used to promote, endorse or advertise any
|
|
68
|
+
Modified Version, except to acknowledge the contribution(s) of the
|
|
69
|
+
Copyright Holder(s) and the Author(s) or with their explicit written
|
|
70
|
+
permission.
|
|
71
|
+
|
|
72
|
+
5) The Font Software, modified or unmodified, in part or in whole,
|
|
73
|
+
must be distributed entirely under this license, and must not be
|
|
74
|
+
distributed under any other license. The requirement for fonts to
|
|
75
|
+
remain under this license does not apply to any document created
|
|
76
|
+
using the Font Software.
|
|
77
|
+
|
|
78
|
+
TERMINATION
|
|
79
|
+
This license becomes null and void if any of the above conditions are
|
|
80
|
+
not met.
|
|
81
|
+
|
|
82
|
+
DISCLAIMER
|
|
83
|
+
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
84
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
|
85
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
|
86
|
+
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
|
87
|
+
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
88
|
+
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
|
89
|
+
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
90
|
+
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
|
91
|
+
OTHER DEALINGS IN THE FONT SOFTWARE.
|
|
Binary file
|