@kensio/colophon 1.0.0 → 2.2.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.
Files changed (44) hide show
  1. package/README.md +132 -4
  2. package/dist/config.d.ts +18 -1
  3. package/dist/config.d.ts.map +1 -1
  4. package/dist/config.js +39 -0
  5. package/dist/config.js.map +1 -1
  6. package/dist/content/index.d.ts.map +1 -1
  7. package/dist/content/index.js +4 -5
  8. package/dist/content/index.js.map +1 -1
  9. package/dist/generate.d.ts.map +1 -1
  10. package/dist/generate.js +9 -1
  11. package/dist/generate.js.map +1 -1
  12. package/dist/highlight.d.ts +75 -0
  13. package/dist/highlight.d.ts.map +1 -0
  14. package/dist/highlight.js +137 -0
  15. package/dist/highlight.js.map +1 -0
  16. package/dist/index.d.ts +5 -3
  17. package/dist/index.d.ts.map +1 -1
  18. package/dist/index.js +3 -2
  19. package/dist/index.js.map +1 -1
  20. package/dist/render.d.ts +4 -1
  21. package/dist/render.d.ts.map +1 -1
  22. package/dist/render.js +6 -3
  23. package/dist/render.js.map +1 -1
  24. package/dist/templates/banner.d.ts.map +1 -1
  25. package/dist/templates/banner.js +2 -12
  26. package/dist/templates/banner.js.map +1 -1
  27. package/dist/templates/card.d.ts.map +1 -1
  28. package/dist/templates/card.js +2 -12
  29. package/dist/templates/card.js.map +1 -1
  30. package/dist/templates/code.d.ts +12 -0
  31. package/dist/templates/code.d.ts.map +1 -0
  32. package/dist/templates/code.js +275 -0
  33. package/dist/templates/code.js.map +1 -0
  34. package/dist/templates/index.d.ts +2 -0
  35. package/dist/templates/index.d.ts.map +1 -1
  36. package/dist/templates/index.js +4 -0
  37. package/dist/templates/index.js.map +1 -1
  38. package/dist/templates/props.d.ts +7 -0
  39. package/dist/templates/props.d.ts.map +1 -0
  40. package/dist/templates/props.js +17 -0
  41. package/dist/templates/props.js.map +1 -0
  42. package/dist/types.d.ts +54 -2
  43. package/dist/types.d.ts.map +1 -1
  44. package/package.json +8 -4
package/README.md CHANGED
@@ -10,6 +10,8 @@ finished work.
10
10
 
11
11
  - **Frontmatter-driven** — general props read from a post, not a fixed schema.
12
12
  - **Templates** — a small registry of layouts; frontmatter picks one.
13
+ - **Syntax-highlighted code images** — the `code` template renders a snippet
14
+ from frontmatter with real VS Code theme colours.
13
15
  - **Configurable branding** — colours, gradient, fonts, footer and badge come
14
16
  from config, not from any one site's stylesheet.
15
17
  - **Multiple sizes from one input** — a 1:1 square plus a 1.91:1 landscape by
@@ -23,7 +25,8 @@ finished work.
23
25
  pnpm add @kensio/colophon
24
26
  ```
25
27
 
26
- `sharp` is a dependency and does the SVG → PNG rasterisation.
28
+ `sharp` is a dependency and does the SVG → PNG rasterisation; `shiki` provides
29
+ the grammars and themes for the `code` template.
27
30
 
28
31
  ## Quick start (CLI)
29
32
 
@@ -131,10 +134,95 @@ only want frontmatter discovery.
131
134
  | -------- | ---------------------------------------------------------------------------- |
132
135
  | `banner` | Left-aligned title with optional version, subtitle, corner badge and footer. |
133
136
  | `card` | Minimal centred title with an optional subtitle. |
137
+ | `code` | Syntax-highlighted snippet on a rounded panel over the background. |
134
138
 
135
139
  Register your own by passing `templates` in config — a template is `{ name,
136
- render(context) }` returning SVG foreground content. Anything you add merges
137
- over (and can override) the built-ins.
140
+ render(context) }` returning SVG foreground content, either directly or as a
141
+ promise. Anything you add merges over (and can override) the built-ins.
142
+
143
+ ### The `code` template
144
+
145
+ Put the snippet in frontmatter and name its language:
146
+
147
+ ```yaml
148
+ ---
149
+ title: eslint changed TypeScript files only
150
+ slug: eslint-changed-ts-files-only
151
+ meta_img_props:
152
+ template: code
153
+ language: bash
154
+ code: |
155
+ mapfile -t CHANGED_TS < <(
156
+ git diff origin/main --name-only \
157
+ | grep '\.ts'
158
+ )
159
+ ---
160
+ ```
161
+
162
+ | Prop | Notes |
163
+ | ---------- | ---------------------------------------------------------------- |
164
+ | `code` | The snippet. Trimmed, tabs expanded, common indentation removed. |
165
+ | `language` | Any [Shiki language]; unknown names fall back to plain text. |
166
+ | `title` | Optional heading above the panel. Omit for a bare code image. |
167
+ | `theme` | Optional per-post override of `config.code.theme`. |
168
+
169
+ [Shiki language]: https://shiki.style/languages
170
+
171
+ Pygments-style names carried over from an older pipeline (`text`, `console`,
172
+ `html+handlebars`, …) are mapped onto their Shiki equivalents, so existing
173
+ frontmatter usually needs no changes.
174
+
175
+ The font size is fitted to the snippet: Colophon measures the longest line and
176
+ the line count against a monospace grid and picks the largest size that fits on
177
+ both axes, within `minFontScale`/`maxFontScale`. Those bounds are fractions of
178
+ the image _width_, because that is what a feed scales a share image to — a
179
+ landscape image would otherwise render the same snippet at half the size of its
180
+ square counterpart. Code too long to fit at the floor is truncated with an
181
+ ellipsis rather than shrunk into unreadability, and the panel then shrinks onto
182
+ what's left so the code isn't marooned in a larger box.
183
+
184
+ That trade matters most on the landscape sizes, which have around half the
185
+ vertical room of the square: at the default floor an Open Graph image fits
186
+ roughly nine lines of about sixty characters. Snippets written to that budget
187
+ render identically at every size; longer ones keep their opening lines and lose
188
+ the tail. Lower `minFontScale` if you would rather show the whole snippet small.
189
+
190
+ Nothing in a finished image says the sample continued, so Colophon says it for
191
+ you — a snippet that had to lose lines is reported through `onWarning`:
192
+
193
+ ```
194
+ colophon: content/post/index.md: code snippet does not fit the 1200x630 image at
195
+ a legible size: 4 of 13 lines dropped. Shorten the sample, or lower
196
+ code.minFontScale to fit it in smaller.
197
+ ```
198
+
199
+ A snippet's leading indentation is dropped before any of this, so lifting a
200
+ sample out of a nested block costs you no width.
201
+
202
+ Styling comes from `config.code`:
203
+
204
+ ```ts
205
+ export default defineConfig({
206
+ colors: { brand: "#2563eb" },
207
+ footer: "example.com",
208
+ code: {
209
+ theme: "night-owl", // any bundled Shiki theme
210
+ fontFamily: '"JetBrains Mono", monospace',
211
+ charWidthRatio: 0.6, // glyph advance ÷ font size, for your monospace face
212
+ lineHeight: 1.55,
213
+ tabSize: 2,
214
+ cornerScale: 0.025,
215
+ maxFontScale: 0.075, // fractions of the image width
216
+ minFontScale: 0.025,
217
+ },
218
+ });
219
+ ```
220
+
221
+ `charWidthRatio` is how the layout knows where each token sits, so it must match
222
+ the font actually used — `0.6` suits most monospace faces (Source Code Pro,
223
+ Menlo, DejaVu Sans Mono); Consolas wants about `0.55`. Fonts must be installed
224
+ where `sharp` can see them; the default stack ends in the generic `monospace`
225
+ family so it always resolves to something.
138
226
 
139
227
  ## Configuration
140
228
 
@@ -147,8 +235,26 @@ All fields are optional; sensible defaults apply.
147
235
  | `fontFamily` | `Arial, Helvetica, sans-serif` | Uses fonts available to `sharp`/librsvg. |
148
236
  | `footer` | none | Footer text; omit the field for none. |
149
237
  | `badge` | none | Corner badge for `banner`; omit the field for none. |
238
+ | `code` | `github-dark`, monospace stack | Styling for the `code` template (see above). |
239
+ | `onWarning` | `console.warn` | Where compromises are reported (see below). |
150
240
  | `sizes` | `og` + `square` | Named output sizes (see below). |
151
- | `templates` | `banner`, `card` | Merged over the built-ins. |
241
+ | `templates` | `banner`, `card`, `code` | Merged over the built-ins. |
242
+
243
+ ### Warnings
244
+
245
+ Some inputs can't be honoured exactly — code too long to render legibly, so far.
246
+ Colophon renders anyway and reports the compromise through `onWarning`, which
247
+ defaults to `console.warn`. Pass your build's logger to route them, or a no-op
248
+ to silence them:
249
+
250
+ ```ts
251
+ export default defineConfig({
252
+ onWarning: () => {},
253
+ });
254
+ ```
255
+
256
+ `generate` prefixes each message with the content file it came from, so a build
257
+ over a whole tree still names the post to fix.
152
258
 
153
259
  ### Output sizes and filenames
154
260
 
@@ -213,8 +319,30 @@ updated PNGs so this gallery stays in sync.
213
319
  <sub><code>card</code> · 1200×630 · solid background, title only</sub>
214
320
  </td>
215
321
  </tr>
322
+ <tr>
323
+ <td>
324
+ <img src="docs/samples/code-square.png" alt="code template, square" width="100%" /><br />
325
+ <sub><code>code</code> · 1200×1200 · bash, <code>github-dark</code></sub>
326
+ </td>
327
+ <td>
328
+ <img src="docs/samples/code-wide.png" alt="code template, landscape" width="100%" /><br />
329
+ <sub><code>code</code> · 1200×630 · TypeScript, <code>night-owl</code></sub>
330
+ </td>
331
+ </tr>
216
332
  </table>
217
333
 
334
+ ## Upgrading from 1.x
335
+
336
+ Adding the `code` template made two small breaking changes:
337
+
338
+ - `Template.render` may now return `string | Promise<string>`, and `buildSvg`
339
+ is `async`. Custom templates that return a string still work unchanged; call
340
+ sites of `buildSvg` need an `await`. `renderMetaImages` and `generate` were
341
+ already async and are unaffected.
342
+ - `MetaImageProps.title` is optional, and `walkContent`/`extractProps` no
343
+ longer skip a file that declares props without a title — a `code` post
344
+ describes its image entirely through `code` and `language`.
345
+
218
346
  ## Development
219
347
 
220
348
  - `pnpm build` — compile to `dist/`.
package/dist/config.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { BrandColors, ColophonConfig, OutputSize, ResolvedConfig } from "./types.js";
1
+ import type { BrandColors, CodeStyle, ColophonConfig, OutputSize, ResolvedConfig } from "./types.js";
2
2
  /**
3
3
  * Named output-size presets covering the common social-image standards. Each
4
4
  * `name` becomes the filename suffix (e.g. `my-post-og.png`).
@@ -40,6 +40,23 @@ export declare const DEFAULT_SIZES: readonly OutputSize[];
40
40
  export declare const DEFAULT_FONT_FAMILY = "Arial, Helvetica, sans-serif";
41
41
  /** Neutral default palette, used when no `colors.brand` is supplied. */
42
42
  export declare const DEFAULT_COLORS: Required<BrandColors>;
43
+ /**
44
+ * Default monospace stack for the `code` template. It ends in the generic
45
+ * `monospace` family so it always resolves to something, whatever fonts the
46
+ * machine running the build happens to have.
47
+ */
48
+ export declare const DEFAULT_CODE_FONT_FAMILY = "\"JetBrains Mono\", \"Source Code Pro\", \"DejaVu Sans Mono\", Menlo, Consolas, monospace";
49
+ /**
50
+ * Default `code` template styling. `charWidthRatio` and `lineHeight` drive the
51
+ * monospace grid the snippet is laid out on; the font-size bounds are
52
+ * fractions of the image width so they hold at every output size.
53
+ *
54
+ * `minFontScale` of `0.025` is roughly 30px on a 1200px-wide image, which
55
+ * still reads when a feed shows that image at half size. A snippet too long to
56
+ * fit at that size is truncated rather than shrunk, so a long sample loses
57
+ * lines on the shorter landscape formats.
58
+ */
59
+ export declare const DEFAULT_CODE_STYLE: Required<CodeStyle>;
43
60
  /**
44
61
  * Identity helper that returns its argument typed as {@link ColophonConfig}.
45
62
  * Use it in a config module to get editor completion and type-checking.
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAEV,WAAW,EACX,cAAc,EACd,UAAU,EACV,cAAc,EACf,MAAM,YAAY,CAAC;AAEpB;;;;;;;;;GASG;AACH,eAAO,MAAM,YAAY;;iBACjB,IAAI,EAAE,IAAI;iBAAE,KAAK,EAAE,IAAI;iBAAE,MAAM,EAAE,GAAG;;;iBAChC,IAAI,EAAE,QAAQ;iBAAE,KAAK,EAAE,IAAI;iBAAE,MAAM,EAAE,IAAI;;;iBACxC,IAAI,EAAE,SAAS;iBAAE,KAAK,EAAE,IAAI;iBAAE,MAAM,EAAE,GAAG;;;iBACvC,IAAI,EAAE,WAAW;iBAAE,KAAK,EAAE,IAAI;iBAAE,MAAM,EAAE,IAAI;;CACZ,CAAC;AAEhD;;;GAGG;AACH,eAAO,MAAM,aAAa,EAAE,SAAS,UAAU,EAG9C,CAAC;AAEF,8EAA8E;AAC9E,eAAO,MAAM,mBAAmB,iCAAiC,CAAC;AAElE,wEAAwE;AACxE,eAAO,MAAM,cAAc,EAAE,QAAQ,CAAC,WAAW,CAKhD,CAAC;AAEF;;;GAGG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,cAAc,GAAG,cAAc,CAEnE;AAgDD;;GAEG;AACH,wBAAgB,aAAa,CAAC,MAAM,GAAE,cAAmB,GAAG,cAAc,CAYzE"}
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAEV,WAAW,EACX,SAAS,EACT,cAAc,EACd,UAAU,EACV,cAAc,EACf,MAAM,YAAY,CAAC;AAEpB;;;;;;;;;GASG;AACH,eAAO,MAAM,YAAY;;iBACjB,IAAI,EAAE,IAAI;iBAAE,KAAK,EAAE,IAAI;iBAAE,MAAM,EAAE,GAAG;;;iBAChC,IAAI,EAAE,QAAQ;iBAAE,KAAK,EAAE,IAAI;iBAAE,MAAM,EAAE,IAAI;;;iBACxC,IAAI,EAAE,SAAS;iBAAE,KAAK,EAAE,IAAI;iBAAE,MAAM,EAAE,GAAG;;;iBACvC,IAAI,EAAE,WAAW;iBAAE,KAAK,EAAE,IAAI;iBAAE,MAAM,EAAE,IAAI;;CACZ,CAAC;AAEhD;;;GAGG;AACH,eAAO,MAAM,aAAa,EAAE,SAAS,UAAU,EAG9C,CAAC;AAEF,8EAA8E;AAC9E,eAAO,MAAM,mBAAmB,iCAAiC,CAAC;AAElE,wEAAwE;AACxE,eAAO,MAAM,cAAc,EAAE,QAAQ,CAAC,WAAW,CAKhD,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,8FACkD,CAAC;AAExF;;;;;;;;;GASG;AACH,eAAO,MAAM,kBAAkB,EAAE,QAAQ,CAAC,SAAS,CASlD,CAAC;AAWF;;;GAGG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,cAAc,GAAG,cAAc,CAEnE;AAoDD;;GAEG;AACH,wBAAgB,aAAa,CAAC,MAAM,GAAE,cAAmB,GAAG,cAAc,CAczE"}
package/dist/config.js CHANGED
@@ -32,6 +32,40 @@ export const DEFAULT_COLORS = {
32
32
  brandWarm: "#db2777",
33
33
  foreground: "#ffffff",
34
34
  };
35
+ /**
36
+ * Default monospace stack for the `code` template. It ends in the generic
37
+ * `monospace` family so it always resolves to something, whatever fonts the
38
+ * machine running the build happens to have.
39
+ */
40
+ export const DEFAULT_CODE_FONT_FAMILY = '"JetBrains Mono", "Source Code Pro", "DejaVu Sans Mono", Menlo, Consolas, monospace';
41
+ /**
42
+ * Default `code` template styling. `charWidthRatio` and `lineHeight` drive the
43
+ * monospace grid the snippet is laid out on; the font-size bounds are
44
+ * fractions of the image width so they hold at every output size.
45
+ *
46
+ * `minFontScale` of `0.025` is roughly 30px on a 1200px-wide image, which
47
+ * still reads when a feed shows that image at half size. A snippet too long to
48
+ * fit at that size is truncated rather than shrunk, so a long sample loses
49
+ * lines on the shorter landscape formats.
50
+ */
51
+ export const DEFAULT_CODE_STYLE = {
52
+ theme: "github-dark",
53
+ fontFamily: DEFAULT_CODE_FONT_FAMILY,
54
+ charWidthRatio: 0.6,
55
+ lineHeight: 1.55,
56
+ tabSize: 2,
57
+ cornerScale: 0.025,
58
+ maxFontScale: 0.075,
59
+ minFontScale: 0.025,
60
+ };
61
+ /**
62
+ * Default warning handler. Colophon runs at build time, so a compromise the
63
+ * renderer had to make belongs in the build log by default — silence is opt-in
64
+ * via `config.onWarning`.
65
+ */
66
+ function warnToConsole(message) {
67
+ console.warn(`colophon: ${message}`);
68
+ }
35
69
  /**
36
70
  * Identity helper that returns its argument typed as {@link ColophonConfig}.
37
71
  * Use it in a config module to get editor completion and type-checking.
@@ -62,6 +96,9 @@ function defaultBackground(colors) {
62
96
  ],
63
97
  };
64
98
  }
99
+ function resolveCode(code) {
100
+ return { ...DEFAULT_CODE_STYLE, ...code };
101
+ }
65
102
  function resolveSizes(sizes) {
66
103
  if (sizes === undefined || sizes.length === 0) {
67
104
  return DEFAULT_SIZES;
@@ -86,6 +123,8 @@ export function resolveConfig(config = {}) {
86
123
  fontFamily: config.fontFamily ?? DEFAULT_FONT_FAMILY,
87
124
  footer: config.footer,
88
125
  badge: config.badge,
126
+ code: resolveCode(config.code),
127
+ onWarning: config.onWarning ?? warnToConsole,
89
128
  sizes: resolveSizes(config.sizes),
90
129
  templates: { ...builtinTemplates, ...config.templates },
91
130
  };
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAA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AA8D;IAC9D,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,gFAAgF;IAChF,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,6EAA6E;IAC7E,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IAChC,yDAAyD;IACzD,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;IAClC;;;OAGG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,iEAAiE;IACjE,QAAQ,CAAC,UAAU,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CACzC;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,uCAAuC;IACvC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,6BAA6B;IAC7B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,gFAAgF;IAChF,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,cAAc,CAAC;CAChC;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAIrD;AAMD;;;;GAIG;AACH,wBAAgB,YAAY,CAC1B,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACpC,OAAO,GAAE,IAAI,CACX,WAAW,EACX,UAAU,GAAG,eAAe,GAAG,iBAAiB,CAC5C,GACL,cAAc,GAAG,SAAS,CA4C5B;AA8BD;;;;GAIG;AACH,wBAAsB,WAAW,CAC/B,OAAO,EAAE,WAAW,GACnB,OAAO,CAAC,WAAW,EAAE,CAAC,CAgCxB"}
@@ -46,10 +46,9 @@ export function extractProps(frontmatter, options = {}) {
46
46
  if (template === undefined) {
47
47
  return undefined;
48
48
  }
49
- const titleRaw = record["title"];
50
- if (typeof titleRaw !== "string") {
51
- return undefined;
52
- }
49
+ // Title is optional: templates such as `code` describe the image entirely
50
+ // from their own fields, and requiring a title would be pure boilerplate.
51
+ const title = coerceString(record["title"]);
53
52
  const subtitle = coerceString(record["subtitle"]);
54
53
  const version = coerceString(record["version"]);
55
54
  const extras = {};
@@ -65,7 +64,7 @@ export function extractProps(frontmatter, options = {}) {
65
64
  return {
66
65
  ...extras,
67
66
  template,
68
- title: titleRaw,
67
+ ...(title !== undefined && { title }),
69
68
  ...(subtitle !== undefined && { subtitle }),
70
69
  ...(version !== undefined && { version }),
71
70
  };
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/content/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,MAAM,MAAM,aAAa,CAAC;AAIjC,MAAM,eAAe,GAAG,gBAAgB,CAAC;AACzC,MAAM,oBAAoB,GAAG,UAAU,CAAC;AACxC,MAAM,gBAAgB,GAAG,MAAM,CAAC;AAChC,MAAM,iBAAiB,GAAsB,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;AAElE,SAAS,YAAY,CAAC,KAAc;IAClC,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IACE,OAAO,KAAK,KAAK,QAAQ;QACzB,OAAO,KAAK,KAAK,SAAS;QAC1B,OAAO,KAAK,KAAK,QAAQ,EACzB,CAAC;QACD,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;IACvB,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC;AAoCD;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,QAAgB;IAC3C,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IACzC,MAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;IAChD,OAAO,IAAI,KAAK,OAAO,CAAC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,IAAI,EAAE,UAAU,CAAC;IAC1B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,qEAAqE;IACrE,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;CAC3B;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,sCAAsC;IACtC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,MAAM,CAAC,EAAE,cAAc,CAAC;IACjC,8EAA8E;IAC9E,QAAQ,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;IACzC,4CAA4C;IAC5C,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,UAAU,KAAK,MAAM,CAAC;IACtE,2EAA2E;IAC3E,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC;IAC7B,qDAAqD;IACrD,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,cAAc,KAAK,IAAI,CAAC;CACtD;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,UAAU,GAAG,MAAM,CAG7E;AAED;;;;;GAKG;AACH,wBAAsB,QAAQ,CAC5B,OAAO,EAAE,eAAe,GACvB,OAAO,CAAC,cAAc,EAAE,CAAC,CAwC3B"}
package/dist/generate.js CHANGED
@@ -29,7 +29,15 @@ export async function generate(options) {
29
29
  const isSkipped = existsSync(outputPath) && options.overwrite !== true;
30
30
  if (!isSkipped) {
31
31
  const dimensions = { width: size.width, height: size.height };
32
- const svg = buildSvg(file.props, resolved, dimensions);
32
+ // Warnings name the post they came from: a build renders many images,
33
+ // and "shorten the sample" is no use without knowing which sample.
34
+ const config = {
35
+ ...resolved,
36
+ onWarning: (message) => {
37
+ resolved.onWarning(`${file.contentPath}: ${message}`);
38
+ },
39
+ };
40
+ const svg = await buildSvg(file.props, config, dimensions);
33
41
  const png = await renderSvgToPng(svg, dimensions);
34
42
  await mkdir(path.dirname(outputPath), { recursive: true });
35
43
  await writeFile(outputPath, png);
@@ -1 +1 @@
1
- {"version":3,"file":"generate.js","sourceRoot":"","sources":["../src/generate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AA+BvD;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAAC,IAAiB,EAAE,IAAgB;IACnE,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IAClD,OAAO,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,GAAG,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,MAAM,CAAC,CAAC;AAC/D,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,QAAQ,CAC5B,OAAwB;IAExB,MAAM,QAAQ,GAAG,aAAa,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAC/C,MAAM,YAAY,GAAG,OAAO,CAAC,UAAU,IAAI,iBAAiB,CAAC;IAC7D,MAAM,KAAK,GAAG,MAAM,WAAW,CAAC,EAAE,GAAG,EAAE,OAAO,CAAC,UAAU,EAAE,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;IAE9E,MAAM,IAAI,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAClC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,EA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C,IAAI,OAAO,CAAC,SAAS,KAAK,IAAI,CAAC;QAEvE,IAAI,CAAC,SAAS,EAAE,CAAC;YACf,MAAM,UAAU,GAAG,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC;YAC9D,sEAAsE;YACtE,mEAAmE;YACnE,MAAM,MAAM,GAAG;gBACb,GAAG,QAAQ;gBACX,SAAS,EAAE,CAAC,OAAe,EAAQ,EAAE;oBACnC,QAAQ,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC,WAAW,KAAK,OAAO,EAAE,CAAC,CAAC;gBACxD,CAAC;aACF,CAAC;YACF,MAAM,GAAG,GAAG,MAAM,QAAQ,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC;YAC3D,MAAM,GAAG,GAAG,MAAM,cAAc,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;YAClD,MAAM,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;YAC3D,MAAM,SAAS,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC;QACnC,CAAC;QAED,MAAM,MAAM,GAAmB;YAC7B,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,IAAI;YACJ,UAAU;YACV,OAAO,EAAE,SAAS;SACnB,CAAC;QACF,OAAO,CAAC,QAAQ,EAAE,CAAC,MAAM,CAAC,CAAC;QAC3B,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC,CACH,CAAC;AACJ,CAAC"}
@@ -0,0 +1,75 @@
1
+ import type { BundledLanguage, BundledTheme, SpecialLanguage } from "shiki";
2
+ /**
3
+ * One highlighted run of text on a line, positioned by character column so the
4
+ * renderer can lay it out on a fixed monospace grid.
5
+ */
6
+ export interface CodeToken {
7
+ readonly text: string;
8
+ /** Zero-based character column where this run starts. */
9
+ readonly column: number;
10
+ /** Token colour as `#rrggbb`, or `undefined` to use the theme foreground. */
11
+ readonly color: string | undefined;
12
+ /** Opacity implied by an `#rrggbbaa` token colour, if any. */
13
+ readonly opacity: number | undefined;
14
+ readonly bold: boolean;
15
+ readonly italic: boolean;
16
+ }
17
+ /**
18
+ * A tokenised snippet ready for layout: the grid of lines, the theme's own
19
+ * colours, and its longest line in characters.
20
+ */
21
+ export interface HighlightedCode {
22
+ readonly lines: readonly (readonly CodeToken[])[];
23
+ /** Theme foreground, used for tokens the grammar gives no colour. */
24
+ readonly foreground: string;
25
+ /** Theme background, used to fill the code panel. */
26
+ readonly background: string;
27
+ /** Length in characters of the longest line, for width fitting. */
28
+ readonly longestLine: number;
29
+ }
30
+ /**
31
+ * Options for {@link highlightCode}.
32
+ */
33
+ export interface HighlightOptions {
34
+ /** Language name; unknown names fall back to plain text. */
35
+ readonly language: string;
36
+ /** Shiki theme name. */
37
+ readonly theme: string;
38
+ /** Spaces a tab expands to. */
39
+ readonly tabSize: number;
40
+ }
41
+ /**
42
+ * Map a frontmatter language name onto one Shiki understands, falling back to
43
+ * plain text so an unrecognised language still produces a readable image
44
+ * rather than throwing mid-build.
45
+ */
46
+ export declare function resolveLanguage(language: string): BundledLanguage | SpecialLanguage;
47
+ /**
48
+ * Validate a configured theme name. Unlike languages — which come from post
49
+ * frontmatter and fall back quietly — a bad theme is a config mistake worth
50
+ * failing on.
51
+ */
52
+ export declare function resolveTheme(theme: string): BundledTheme;
53
+ /**
54
+ * Expand tabs to spaces so every character occupies one monospace cell.
55
+ */
56
+ export declare function expandTabs(text: string, tabSize: number): string;
57
+ /**
58
+ * Strip the indentation common to every non-blank line. A snippet lifted out
59
+ * of a nested block would otherwise spend its width — the scarce dimension on
60
+ * the landscape sizes — on indentation that carries no meaning once the
61
+ * surrounding code is gone.
62
+ */
63
+ export declare function dedent(text: string): string;
64
+ /**
65
+ * Tokenise a snippet with Shiki and flatten it onto a character grid.
66
+ *
67
+ * The snippet is first normalised: surrounding blank lines trimmed, tabs
68
+ * expanded, and common leading indentation removed.
69
+ *
70
+ * Whitespace-only runs are dropped and each remaining run keeps its starting
71
+ * column, so the renderer can position every run absolutely instead of relying
72
+ * on SVG text flow to preserve indentation.
73
+ */
74
+ export declare function highlightCode(code: string, options: HighlightOptions): Promise<HighlightedCode>;
75
+ //# sourceMappingURL=highlight.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"highlight.d.ts","sourceRoot":"","sources":["../src/highlight.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,OAAO,CAAC;AAG5E;;;GAGG;AACH,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,yDAAyD;IACzD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,6EAA6E;IAC7E,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;IACnC,8DAA8D;IAC9D,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IACrC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;CAC1B;AAED;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC,SAAS,SAAS,EAAE,CAAC,EAAE,CAAC;IAClD,qEAAqE;IACrE,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,qDAAqD;IACrD,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,mEAAmE;IACnE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAC9B;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,4DAA4D;IAC5D,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,wBAAwB;IACxB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,+BAA+B;IAC/B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAyBD;;;;GAIG;AACH,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,MAAM,GACf,eAAe,GAAG,eAAe,CAOnC;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,YAAY,CAQxD;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAGhE;AAED;;;;;GAKG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAiB3C;AAsBD;;;;;;;;;GASG;AACH,wBAAsB,aAAa,CACjC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,eAAe,CAAC,CAoD1B"}
@@ -0,0 +1,137 @@
1
+ import { bundledLanguages, bundledThemes, codeToTokens } from "shiki";
2
+ /**
3
+ * Language names that differ between Pygments (which the original Python
4
+ * script used) and Shiki. Everything else is passed through — Shiki already
5
+ * understands `bash`, `python`, `typescript`, `yaml`, `toml`, `sql`, `json`,
6
+ * `js` and `text`.
7
+ */
8
+ const languageAliases = new Map([
9
+ ["html+handlebars", "handlebars"],
10
+ ["html+django", "jinja-html"],
11
+ ["html+jinja", "jinja-html"],
12
+ ["html+php", "php"],
13
+ ["console", "shellsession"],
14
+ ["shell-session", "shellsession"],
15
+ ["text", "plaintext"],
16
+ ["plain", "plaintext"],
17
+ ]);
18
+ const plainText = "plaintext";
19
+ // Shiki's font-style bit flags (`FontStyle` in `@shikijs/types`).
20
+ const italicFlag = 1;
21
+ const boldFlag = 2;
22
+ /**
23
+ * Map a frontmatter language name onto one Shiki understands, falling back to
24
+ * plain text so an unrecognised language still produces a readable image
25
+ * rather than throwing mid-build.
26
+ */
27
+ export function resolveLanguage(language) {
28
+ const normalised = language.trim().toLowerCase();
29
+ const aliased = languageAliases.get(normalised) ?? normalised;
30
+ return Object.hasOwn(bundledLanguages, aliased)
31
+ ? aliased
32
+ : plainText;
33
+ }
34
+ /**
35
+ * Validate a configured theme name. Unlike languages — which come from post
36
+ * frontmatter and fall back quietly — a bad theme is a config mistake worth
37
+ * failing on.
38
+ */
39
+ export function resolveTheme(theme) {
40
+ if (!Object.hasOwn(bundledThemes, theme)) {
41
+ throw new Error(`Unknown code theme "${theme}". See https://shiki.style/themes for the available names.`);
42
+ }
43
+ return theme;
44
+ }
45
+ /**
46
+ * Expand tabs to spaces so every character occupies one monospace cell.
47
+ */
48
+ export function expandTabs(text, tabSize) {
49
+ const spaces = " ".repeat(Math.max(1, Math.floor(tabSize)));
50
+ return text.replaceAll("\t", () => spaces);
51
+ }
52
+ /**
53
+ * Strip the indentation common to every non-blank line. A snippet lifted out
54
+ * of a nested block would otherwise spend its width — the scarce dimension on
55
+ * the landscape sizes — on indentation that carries no meaning once the
56
+ * surrounding code is gone.
57
+ */
58
+ export function dedent(text) {
59
+ const lines = text.split("\n");
60
+ let common = Infinity;
61
+ for (const line of lines) {
62
+ if (line.trim() === "") {
63
+ continue;
64
+ }
65
+ common = Math.min(common, line.length - line.trimStart().length);
66
+ }
67
+ if (common === 0 || !Number.isFinite(common)) {
68
+ return text;
69
+ }
70
+ return lines.map((line) => line.slice(common)).join("\n");
71
+ }
72
+ /**
73
+ * Split an `#rrggbb` or `#rrggbbaa` colour into a fill and an optional opacity,
74
+ * since SVG 1.1 `fill` does not accept an alpha channel.
75
+ */
76
+ function splitColor(color) {
77
+ if (color === undefined || color === "") {
78
+ return { color: undefined, opacity: undefined };
79
+ }
80
+ if (!/^#[0-9a-f]{8}$/i.test(color)) {
81
+ return { color, opacity: undefined };
82
+ }
83
+ const alpha = Number.parseInt(color.slice(7, 9), 16) / 255;
84
+ return { color: color.slice(0, 7), opacity: Math.round(alpha * 100) / 100 };
85
+ }
86
+ /**
87
+ * Tokenise a snippet with Shiki and flatten it onto a character grid.
88
+ *
89
+ * The snippet is first normalised: surrounding blank lines trimmed, tabs
90
+ * expanded, and common leading indentation removed.
91
+ *
92
+ * Whitespace-only runs are dropped and each remaining run keeps its starting
93
+ * column, so the renderer can position every run absolutely instead of relying
94
+ * on SVG text flow to preserve indentation.
95
+ */
96
+ export async function highlightCode(code, options) {
97
+ const source = dedent(expandTabs(code.replaceAll("\r\n", "\n"), options.tabSize)
98
+ .replace(/\n+$/, "")
99
+ .replace(/^\n+/, ""));
100
+ const result = await codeToTokens(source, {
101
+ lang: resolveLanguage(options.language),
102
+ theme: resolveTheme(options.theme),
103
+ });
104
+ let longestLine = 0;
105
+ const lines = result.tokens.map((tokens) => {
106
+ let column = 0;
107
+ const line = [];
108
+ for (const token of tokens) {
109
+ const start = column;
110
+ column += token.content.length;
111
+ const leading = token.content.length - token.content.trimStart().length;
112
+ const text = token.content.trim();
113
+ if (text === "") {
114
+ continue;
115
+ }
116
+ const { color, opacity } = splitColor(token.color);
117
+ const fontStyle = token.fontStyle ?? 0;
118
+ line.push({
119
+ text,
120
+ column: start + leading,
121
+ color,
122
+ opacity,
123
+ bold: (fontStyle & boldFlag) !== 0,
124
+ italic: (fontStyle & italicFlag) !== 0,
125
+ });
126
+ }
127
+ longestLine = Math.max(longestLine, column);
128
+ return line;
129
+ });
130
+ return {
131
+ lines,
132
+ foreground: result.fg ?? "#ffffff",
133
+ background: result.bg ?? "#000000",
134
+ longestLine,
135
+ };
136
+ }
137
+ //# sourceMappingURL=highlight.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"highlight.js","sourceRoot":"","sources":["../src/highlight.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AA4CtE;;;;;GAKG;AACH,MAAM,eAAe,GAAgC,IAAI,GAAG,CAAC;IAC3D,CAAC,iBAAiB,EAAE,YAAY,CAAC;IACjC,CAAC,aAAa,EAAE,YAAY,CAAC;IAC7B,CAAC,YAAY,EAAE,YAAY,CAAC;IAC5B,CAAC,UAA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AAC;YACnD,MAAM,SAAS,GAAG,KAAK,CAAC,SAAS,IAAI,CAAC,CAAC;YAEvC,IAAI,CAAC,IAAI,CAAC;gBACR,IAAI;gBACJ,MAAM,EAAE,KAAK,GAAG,OAAO;gBACvB,KAAK;gBACL,OAAO;gBACP,IAAI,EAAE,CAAC,SAAS,GAAG,QAAQ,CAAC,KAAK,CAAC;gBAClC,MAAM,EAAE,CAAC,SAAS,GAAG,UAAU,CAAC,KAAK,CAAC;aACvC,CAAC,CAAC;QACL,CAAC;QAED,WAAW,GAAG,IAAI,CAAC,GAAG,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;QAC5C,OAAO,IAAI,CAAC;IACd,CAAC,CAAC,CAAC;IAEH,OAAO;QACL,KAAK;QACL,UAAU,EAAE,MAAM,CAAC,EAAE,IAAI,SAAS;QAClC,UAAU,EAAE,MAAM,CAAC,EAAE,IAAI,SAAS;QAClC,WAAW;KACZ,CAAC;AACJ,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,8 +1,10 @@
1
- export type { Background, Badge, BrandColors, ColophonConfig, Dimensions, GradientStop, MetaImageProps, OutputSize, RenderedMetaImage, ResolvedConfig, Template, TemplateContext, } from "./types.js";
2
- export { DEFAULT_COLORS, DEFAULT_FONT_FAMILY, DEFAULT_SIZES, defineConfig, resolveConfig, SIZE_PRESETS, } from "./config.js";
1
+ export type { Background, Badge, BrandColors, CodeStyle, ColophonConfig, Dimensions, GradientStop, MetaImageProps, OutputSize, RenderedMetaImage, ResolvedConfig, Template, TemplateContext, WarningHandler, } from "./types.js";
2
+ export { DEFAULT_CODE_FONT_FAMILY, DEFAULT_CODE_STYLE, DEFAULT_COLORS, DEFAULT_FONT_FAMILY, DEFAULT_SIZES, defineConfig, resolveConfig, SIZE_PRESETS, } from "./config.js";
3
3
  export { backgroundSvg } from "./background.js";
4
4
  export { buildSvg, renderMetaImages, renderSvgToPng } from "./render.js";
5
- export { bannerTemplate, builtinTemplates, cardTemplate, } from "./templates/index.js";
5
+ export { bannerTemplate, builtinTemplates, cardTemplate, codeTemplate, } from "./templates/index.js";
6
+ export { dedent, expandTabs, highlightCode, resolveLanguage, } from "./highlight.js";
7
+ export type { CodeToken, HighlightedCode, HighlightOptions, } from "./highlight.js";
6
8
  export { defaultOutputPath, generate } from "./generate.js";
7
9
  export type { GeneratedImage, GenerateOptions } from "./generate.js";
8
10
  export { escapeXml, wrapText } from "./text.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,UAAU,EACV,KAAK,EACL,WAAW,EACX,cAAc,EACd,UAAU,EACV,YAAY,EACZ,cAAc,EACd,UAAU,EACV,iBAAiB,EACjB,cAAc,EACd,QAAQ,EACR,eAAe,GAChB,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,aAAa,EACb,YAAY,EACZ,aAAa,EACb,YAAY,GACb,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AACzE,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,YAAY,GACb,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC5D,YAAY,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAErE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAEhD,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAC7E,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,UAAU,EACV,KAAK,EACL,WAAW,EACX,SAAS,EACT,cAAc,EACd,UAAU,EACV,YAAY,EACZ,cAAc,EACd,UAAU,EACV,iBAAiB,EACjB,cAAc,EACd,QAAQ,EACR,eAAe,EACf,cAAc,GACf,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,wBAAwB,EACxB,kBAAkB,EAClB,cAAc,EACd,mBAAmB,EACnB,aAAa,EACb,YAAY,EACZ,aAAa,EACb,YAAY,GACb,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AACzE,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,YAAY,EACZ,YAAY,GACb,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EACL,MAAM,EACN,UAAU,EACV,aAAa,EACb,eAAe,GAChB,MAAM,gBAAgB,CAAC;AACxB,YAAY,EACV,SAAS,EACT,eAAe,EACf,gBAAgB,GACjB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC5D,YAAY,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAErE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAEhD,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAC7E,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC"}
package/dist/index.js CHANGED
@@ -1,7 +1,8 @@
1
- export { DEFAULT_COLORS, DEFAULT_FONT_FAMILY, DEFAULT_SIZES, defineConfig, resolveConfig, SIZE_PRESETS, } from "./config.js";
1
+ export { DEFAULT_CODE_FONT_FAMILY, DEFAULT_CODE_STYLE, DEFAULT_COLORS, DEFAULT_FONT_FAMILY, DEFAULT_SIZES, defineConfig, resolveConfig, SIZE_PRESETS, } from "./config.js";
2
2
  export { backgroundSvg } from "./background.js";
3
3
  export { buildSvg, renderMetaImages, renderSvgToPng } from "./render.js";
4
- export { bannerTemplate, builtinTemplates, cardTemplate, } from "./templates/index.js";
4
+ export { bannerTemplate, builtinTemplates, cardTemplate, codeTemplate, } from "./templates/index.js";
5
+ export { dedent, expandTabs, highlightCode, resolveLanguage, } from "./highlight.js";
5
6
  export { defaultOutputPath, generate } from "./generate.js";
6
7
  export { escapeXml, wrapText } from "./text.js";
7
8
  export { extractProps, slugFromPath, walkContent } from "./content/index.js";