@wakeful-cloud/slidev-theme-illinois 0.0.0-stage → 0.1.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.
Files changed (82) hide show
  1. package/LICENSE +45 -0
  2. package/README.md +592 -2
  3. package/assets/logos/block-i-blue.svg +54 -0
  4. package/assets/logos/block-i-full.svg +54 -0
  5. package/assets/logos/block-i-orange.svg +54 -0
  6. package/assets/logos/wordmark-blue.svg +94 -0
  7. package/assets/logos/wordmark-formal-blue.svg +234 -0
  8. package/assets/logos/wordmark-formal-full.svg +234 -0
  9. package/assets/logos/wordmark-formal-orange.svg +234 -0
  10. package/assets/logos/wordmark-full.svg +94 -0
  11. package/assets/logos/wordmark-orange.svg +94 -0
  12. package/assets/logos/wordmark-vertical-blue.svg +94 -0
  13. package/assets/logos/wordmark-vertical-full.svg +94 -0
  14. package/assets/logos/wordmark-vertical-orange.svg +94 -0
  15. package/citations/engine.ts +738 -0
  16. package/citations/errors.ts +79 -0
  17. package/citations/plugin.ts +137 -0
  18. package/citations/styles.ts +300 -0
  19. package/citations/syntax.ts +357 -0
  20. package/components/bibliography.vue +185 -0
  21. package/components/callout.vue +42 -0
  22. package/components/card.vue +37 -0
  23. package/components/cite.vue +62 -0
  24. package/components/frame.vue +71 -0
  25. package/components/illinois-logo.vue +45 -0
  26. package/components/math-morph.vue +252 -0
  27. package/components/qr-code.vue +51 -0
  28. package/components/stat.vue +43 -0
  29. package/components/steps.vue +77 -0
  30. package/global.d.ts +14 -0
  31. package/internal/brand-logo.vue +48 -0
  32. package/internal/citations.ts +206 -0
  33. package/internal/kicker.vue +13 -0
  34. package/internal/layout-root.vue +42 -0
  35. package/internal/pattern.vue +20 -0
  36. package/internal/split.vue +147 -0
  37. package/internal/theme.ts +878 -0
  38. package/layouts/agenda.vue +82 -0
  39. package/layouts/appendix-right.vue +15 -0
  40. package/layouts/appendix.vue +25 -0
  41. package/layouts/canvas.vue +21 -0
  42. package/layouts/center.vue +17 -0
  43. package/layouts/compare.vue +48 -0
  44. package/layouts/cover-right.vue +15 -0
  45. package/layouts/cover.vue +170 -0
  46. package/layouts/default.vue +15 -0
  47. package/layouts/end-right.vue +15 -0
  48. package/layouts/end.vue +89 -0
  49. package/layouts/fact-right.vue +15 -0
  50. package/layouts/fact.vue +25 -0
  51. package/layouts/figure.vue +43 -0
  52. package/layouts/grid.vue +33 -0
  53. package/layouts/iframe-left.vue +16 -0
  54. package/layouts/iframe-right.vue +16 -0
  55. package/layouts/image-left.vue +16 -0
  56. package/layouts/image-right.vue +16 -0
  57. package/layouts/image.vue +40 -0
  58. package/layouts/media-left.vue +17 -0
  59. package/layouts/media-right.vue +17 -0
  60. package/layouts/people.vue +98 -0
  61. package/layouts/quote-right.vue +15 -0
  62. package/layouts/quote.vue +41 -0
  63. package/layouts/references.vue +36 -0
  64. package/layouts/section-right.vue +15 -0
  65. package/layouts/section.vue +53 -0
  66. package/layouts/statement-right.vue +15 -0
  67. package/layouts/statement.vue +30 -0
  68. package/layouts/two-cols-header.vue +32 -0
  69. package/layouts/two-cols.vue +31 -0
  70. package/package.json +114 -4
  71. package/setup/mermaid.ts +73 -0
  72. package/setup/shiki.ts +147 -0
  73. package/setup/transformers.ts +21 -0
  74. package/setup/unocss.ts +34 -0
  75. package/setup/vite-plugins.ts +8 -0
  76. package/slide-top.vue +149 -0
  77. package/styles/base.css +309 -0
  78. package/styles/components.css +336 -0
  79. package/styles/index.ts +19 -0
  80. package/styles/layouts.css +1242 -0
  81. package/styles/looks.css +307 -0
  82. package/styles/tokens.css +324 -0
@@ -0,0 +1,357 @@
1
+ /**
2
+ * @file Pandoc-style citation syntax shared by the markdown transformer and the citations plugin.
3
+ *
4
+ * Supported forms:
5
+ * - `[@key]`
6
+ * - `[@key, p. 12]` (locator)
7
+ * - `[see @key; @other, ch. 3]` (prefix, multiple items)
8
+ * - `[-@key]` (suppress author: author-date styles print only the year)
9
+ */
10
+
11
+ /**
12
+ * A single cited work inside a citation group
13
+ */
14
+ export interface CiteItem {
15
+ /**
16
+ * Bibliography key
17
+ */
18
+ key: string;
19
+
20
+ /**
21
+ * Locator such as `p. 12`
22
+ */
23
+ locator?: string;
24
+
25
+ /**
26
+ * Text before the key such as `see`
27
+ */
28
+ prefix?: string;
29
+
30
+ /**
31
+ * Print only the year (author-date styles)
32
+ */
33
+ suppressAuthor?: boolean;
34
+ }
35
+
36
+ /**
37
+ * A citation group found in markdown
38
+ */
39
+ interface CiteMatch {
40
+ /**
41
+ * Offset just past the closing bracket
42
+ */
43
+ end: number;
44
+
45
+ /**
46
+ * Cited works, in written order
47
+ */
48
+ items: CiteItem[];
49
+
50
+ /**
51
+ * Offset of the opening bracket
52
+ */
53
+ start: number;
54
+ }
55
+
56
+ /**
57
+ * Entries a slide lists besides the ones it cites
58
+ */
59
+ export interface ListedKeys {
60
+ /**
61
+ * Every entry of the bibliography is listed
62
+ */
63
+ all: boolean;
64
+
65
+ /**
66
+ * Keys listed explicitly
67
+ */
68
+ keys: string[];
69
+ }
70
+
71
+ /**
72
+ * A bracketed group containing at least one `@`, not followed by `(` or `[` (which would make it a
73
+ * markdown link); reference definitions (`[@x]: url` at the start of a line) are skipped separately
74
+ */
75
+ const GROUP_RE = /\[([^[\]\n]*@[^[\]\n]*)\](?![([])/gu;
76
+
77
+ /**
78
+ * Text before a group that starts a line (up to three spaces, as for reference definitions)
79
+ */
80
+ const LINE_START_RE = /(?:^|\n) {0,3}$/u;
81
+
82
+ /**
83
+ * One item: optional prefix (which must end in whitespace), optional `-`, `@key`, optional
84
+ * `, locator`
85
+ */
86
+ const ITEM_RE = /^(?:(.*\s))?(-?)@([\p{L}\p{N}_][\p{L}\p{N}_:.#$%&+?<>~/-]*?)\s*(?:,\s*(.+))?$/u;
87
+
88
+ /**
89
+ * A `<Cite>` component with a `keys` (or bound `:keys`) attribute
90
+ */
91
+ const CITE_TAG_RE = /<Cite\b[^>]*?\s(:?)keys="([^"]*)"/gu;
92
+
93
+ /**
94
+ * A `<Bibliography>` component and its attributes
95
+ */
96
+ const BIBLIOGRAPHY_TAG_RE = /<Bibliography\b([^>]*)>/giu;
97
+
98
+ /**
99
+ * An `all` attribute (plain or bound)
100
+ */
101
+ const ALL_RE = /\s(?::|v-bind:)?all(?![\w-])/u;
102
+
103
+ /**
104
+ * An `all` attribute bound to a literal `false`
105
+ */
106
+ const ALL_FALSE_RE = /\s(?::|v-bind:)all\s*=\s*(["'])\s*false\s*\1/u;
107
+
108
+ /**
109
+ * An object spread (`v-bind="options"`), which may set any attribute
110
+ */
111
+ const SPREAD_RE = /\sv-bind\s*=/u;
112
+
113
+ /**
114
+ * A `keys` attribute (plain or bound)
115
+ */
116
+ const KEYS_RE = /\s(?::|v-bind:)?keys(?![\w-])/u;
117
+
118
+ /**
119
+ * A plain `keys="a, b"` attribute
120
+ */
121
+ const PLAIN_KEYS_RE = /\skeys="([^"]*)"/u;
122
+
123
+ /**
124
+ * A `keys` attribute bound to an array literal (`:keys="['a', 'b']"`)
125
+ */
126
+ const BOUND_KEYS_RE = /\s(?::|v-bind:)keys="\s*\[([^\]"]*)\]\s*"/u;
127
+
128
+ /**
129
+ * Everything in a slide that is not prose, besides fenced code. One expression, so that whichever
130
+ * starts first wins, as in markdown: a backtick or `$` inside a tag opens nothing, and a tag inside
131
+ * code is code. In order:
132
+ * - HTML comments
133
+ * - `<script>` and `<style>` blocks, with their content
134
+ * - `tag`: HTML and component tags, with any attribute name Vue accepts (`@click`, `#slot`,
135
+ * `:[name]`)
136
+ * - display math
137
+ * - inline code
138
+ * - inline math, with Slidev's delimiter rules: `\$` is not a delimiter, the opening `$` is not
139
+ * followed by a space, and the closing `$` is not preceded by a space or followed by a digit (so
140
+ * prices like `$5 and $10` are text)
141
+ * - `escape`: an escaped opening bracket
142
+ */
143
+ const NON_PROSE_RE = new RegExp(
144
+ [
145
+ /<!--[\s\S]*?-->/u,
146
+ /<(?<raw>script|style)(?=[\s>])[^>]*>[\s\S]*?<\/\k<raw>\s*>/u,
147
+ /(?<tag><\/?[A-Za-z][\w-]*(?:\s+[^\s"'<>/=]+(?:\s*=\s*(?:[^\s"'=<>`]+|'[^']*'|"[^"]*"))?)*\s*\/?>)/u,
148
+ /\$\$[\s\S]*?\$\$/u,
149
+ /(?<ticks>`+)[\s\S]*?\k<ticks>/u,
150
+ /(?<!\\)\$(?=\S)(?:[^$\n\\]|\\.)*?(?<=[^\s\\])\$(?!\d)/u,
151
+ /(?<escape>\\\[)/u,
152
+ ]
153
+ .map(part => part.source)
154
+ .join("|"),
155
+ "gu",
156
+ );
157
+
158
+ /**
159
+ * Opening/closing line of a fenced code block
160
+ */
161
+ const FENCE_RE = /^[ \t]*(`{3,}|~{3,})/u;
162
+
163
+ /**
164
+ * Snippet import line (`<<< @/path`)
165
+ */
166
+ const SNIPPET_RE = /^\s*<<<\s/u;
167
+
168
+ /**
169
+ * Replace every character except newlines with a space (keeps offsets intact)
170
+ * @param text Text to blank out
171
+ * @returns Blanked text
172
+ */
173
+ const blank = (text: string) => text.replaceAll(/[^\n]/gu, " ");
174
+
175
+ /**
176
+ * Replace code and math (fenced and inline code, HTML comments, `<script>` and `<style>` blocks,
177
+ * math, snippet imports) with spaces, keeping offsets intact
178
+ * @param content Slide markdown
179
+ * @param prose Also replace HTML tags and escaped brackets, which leaves only prose
180
+ * @returns Masked markdown with identical offsets
181
+ */
182
+ const maskCode = (content: string, prose = false): string => {
183
+ let fence: string | undefined = undefined;
184
+
185
+ const lines = content.split("\n").map(line => {
186
+ const marker = FENCE_RE.exec(line)?.[1];
187
+
188
+ // Inside a fenced block: blank everything until the matching closing fence
189
+ if (fence !== undefined) {
190
+ if (marker !== undefined && marker[0] === fence[0] && marker.length >= fence.length) {
191
+ fence = undefined;
192
+ }
193
+ return blank(line);
194
+ }
195
+
196
+ // Opening fence
197
+ if (marker !== undefined) {
198
+ fence = marker;
199
+ return blank(line);
200
+ }
201
+
202
+ return SNIPPET_RE.test(line) ? blank(line) : line;
203
+ });
204
+
205
+ return lines.join("\n").replaceAll(NON_PROSE_RE, (match: string, ...rest: unknown[]) => {
206
+ // Tags and escaped brackets are matched either way (so nothing inside a tag is taken for code
207
+ // or math), but only blanked when asked for
208
+ const groups = rest.at(-1) as Record<string, string | undefined>;
209
+ const kept = !prose && (groups["tag"] !== undefined || groups["escape"] !== undefined);
210
+ return kept ? match : blank(match);
211
+ });
212
+ };
213
+
214
+ /**
215
+ * Parse a single citation item such as `see @key, p. 12`
216
+ * @param raw Item text
217
+ * @returns Parsed item, or `undefined` if the text is not a citation item
218
+ */
219
+ const parseItem = (raw: string): CiteItem | undefined => {
220
+ const match = ITEM_RE.exec(raw.trim());
221
+ if (match === null) {
222
+ return undefined;
223
+ }
224
+
225
+ const [, rawPrefix, dash, key, rawLocator] = match;
226
+ if (key === undefined) {
227
+ return undefined;
228
+ }
229
+
230
+ const item: CiteItem = {key};
231
+
232
+ const locator = rawLocator?.trim();
233
+ if (locator) {
234
+ item.locator = locator;
235
+ }
236
+
237
+ const prefix = rawPrefix?.trim();
238
+ if (prefix) {
239
+ item.prefix = prefix;
240
+ }
241
+
242
+ if (dash === "-") {
243
+ item.suppressAuthor = true;
244
+ }
245
+
246
+ return item;
247
+ };
248
+
249
+ /**
250
+ * Find every citation group in a slide's markdown
251
+ * @param content Slide markdown
252
+ * @returns Citation groups, in document order
253
+ */
254
+ export const findCitations = (content: string): CiteMatch[] => {
255
+ const matches: CiteMatch[] = [];
256
+
257
+ const masked = maskCode(content, true);
258
+
259
+ for (const match of masked.matchAll(GROUP_RE)) {
260
+ // `[@x]: url` at the start of a line is a reference definition
261
+ const end = match.index + match[0].length;
262
+ if (masked[end] === ":" && LINE_START_RE.test(masked.slice(0, match.index))) {
263
+ continue;
264
+ }
265
+
266
+ const items = (match[1] ?? "").split(";").map(raw => parseItem(raw));
267
+
268
+ // Only treat the group as a citation if every item parses (e.g. `[email me@x.com]` doesn't)
269
+ if (items.length === 0 || items.some(item => item === undefined)) {
270
+ continue;
271
+ }
272
+
273
+ matches.push({
274
+ end,
275
+ items: items as CiteItem[],
276
+ start: match.index,
277
+ });
278
+ }
279
+
280
+ return matches;
281
+ };
282
+
283
+ /**
284
+ * Keys of `<Cite>` components written directly in a slide (`keys="a, b"` or
285
+ * `:keys="['a', 'b']"`), with their offsets
286
+ * @param content Slide markdown
287
+ * @returns `[offset, key]` pairs
288
+ */
289
+ const citeTagKeys = (content: string): [number, string][] =>
290
+ [...maskCode(content).matchAll(CITE_TAG_RE)].flatMap(match => {
291
+ const [, bound, value = ""] = match;
292
+ const keys =
293
+ bound === ":"
294
+ ? [...value.matchAll(/'([^']+)'/gu)].map(([, key]) => key ?? "")
295
+ : value.split(/[,;\s]+/u);
296
+ return keys.filter(Boolean).map((key): [number, string] => [match.index, key]);
297
+ });
298
+
299
+ /**
300
+ * Unique cite keys of a slide (Pandoc-style citations and `<Cite>` components), in order of first
301
+ * appearance
302
+ * @param content Slide markdown
303
+ * @returns Cite keys
304
+ */
305
+ export const citedKeys = (content: string): string[] => {
306
+ const found: [number, string][] = [
307
+ ...findCitations(content).flatMap(match =>
308
+ match.items.map((item): [number, string] => [match.start, item.key]),
309
+ ),
310
+ ...citeTagKeys(content),
311
+ ];
312
+ found.sort(([a], [b]) => a - b);
313
+ return [...new Set(found.map(([, key]) => key))];
314
+ };
315
+
316
+ /**
317
+ * Entries a `<Bibliography>` component lists besides the cited ones
318
+ * @param attributes Attributes of the component, as written
319
+ * @returns Listed keys; everything when the attributes cannot be read statically (an expression
320
+ * or a spread), so the list never comes up short
321
+ */
322
+ const tagListedKeys = (attributes: string): ListedKeys => {
323
+ const everything: ListedKeys = {all: true, keys: []};
324
+
325
+ // `all`, unless it is bound to a literal `false`; a spread may set it as well
326
+ if ((ALL_RE.test(attributes) && !ALL_FALSE_RE.test(attributes)) || SPREAD_RE.test(attributes)) {
327
+ return everything;
328
+ }
329
+ if (!KEYS_RE.test(attributes)) {
330
+ return {all: false, keys: []};
331
+ }
332
+
333
+ const plain = PLAIN_KEYS_RE.exec(attributes)?.[1];
334
+ if (plain !== undefined) {
335
+ return {all: false, keys: plain.split(/[,;\s]+/u).filter(Boolean)};
336
+ }
337
+
338
+ // An array literal of quoted keys; anything else is only known at runtime
339
+ const bound = BOUND_KEYS_RE.exec(attributes)?.[1];
340
+ if (bound === undefined || bound.replaceAll(/'[^']*'|[\s,]/gu, "") !== "") {
341
+ return everything;
342
+ }
343
+ return {all: false, keys: [...bound.matchAll(/'([^']+)'/gu)].map(([, key]) => key ?? "")};
344
+ };
345
+
346
+ /**
347
+ * Entries the `<Bibliography>` components written in a slide list besides the cited ones (`all`
348
+ * or specific `keys`)
349
+ * @param content Slide markdown
350
+ * @returns Listed keys
351
+ */
352
+ export const listedKeys = (content: string): ListedKeys => {
353
+ const tags = [...maskCode(content).matchAll(BIBLIOGRAPHY_TAG_RE)].map(([, attributes = ""]) =>
354
+ tagListedKeys(attributes),
355
+ );
356
+ return {all: tags.some(tag => tag.all), keys: tags.flatMap(tag => tag.keys)};
357
+ };
@@ -0,0 +1,185 @@
1
+ <!--
2
+ Formatted reference list. Used by the `references` layout, but works on any slide.
3
+
4
+ - Lists entries cited anywhere in the deck by default (`all` also lists uncited entries)
5
+ - `keys` restricts the list to specific entries
6
+ - Uncited entries are only part of the build when `all` or `keys` is written in a slide (or in
7
+ the frontmatter of a `references` slide); see `listedEntries` in `citations/engine.ts`
8
+ - `from` / `to` (1-based, inclusive) split long lists across several slides
9
+ - `columns` sets the number of columns; text shrinks automatically to fit (`fit: false` disables)
10
+ - Entries that still do not fit are reported in the browser console
11
+ -->
12
+
13
+ <script setup lang="ts">
14
+ import {useSlideContext} from "@slidev/client";
15
+ import {computed, nextTick, onBeforeUnmount, onMounted, ref, watch} from "vue";
16
+ import {citations, entriesFor} from "#internal/citations.ts";
17
+
18
+ const {
19
+ all = false,
20
+ columns = 1,
21
+ fit = true,
22
+ from,
23
+ keys,
24
+ to,
25
+ } = defineProps<{
26
+ /**
27
+ * Also list entries that are never cited
28
+ */
29
+ all?: boolean;
30
+
31
+ /**
32
+ * Number of columns
33
+ */
34
+ columns?: number;
35
+
36
+ /**
37
+ * Shrink the text to fit the available space
38
+ */
39
+ fit?: boolean;
40
+
41
+ /**
42
+ * First entry to show (1-based)
43
+ */
44
+ from?: number;
45
+
46
+ /**
47
+ * Only list these cite keys (an array, or a string separated by commas, semicolons or spaces)
48
+ */
49
+ keys?: string[] | string;
50
+
51
+ /**
52
+ * Last entry to show (1-based, inclusive)
53
+ */
54
+ to?: number;
55
+ }>();
56
+
57
+ /**
58
+ * Smallest scale the list may shrink to
59
+ */
60
+ const MIN_SCALE = 0.55;
61
+
62
+ const {$page} = useSlideContext();
63
+
64
+ const error = computed(() => citations.value.error);
65
+ const numeric = computed(() => citations.value.numeric);
66
+
67
+ // Entries to show (optionally a slice for multi-slide bibliographies)
68
+ const list = computed(() => {
69
+ const entries = entriesFor(keys, citations.value, all);
70
+ const start = Math.max((from ?? 1) - 1, 0);
71
+ return entries.slice(start, to ?? entries.length);
72
+ });
73
+
74
+ const root = ref<HTMLElement>();
75
+ const scale = ref(1);
76
+
77
+ /**
78
+ * Warn about entries that are cut off (below the box, or in an overflowing column to the right)
79
+ * @param el List element
80
+ */
81
+ const warnIfCutOff = (el: HTMLElement) => {
82
+ const box = el.getBoundingClientRect();
83
+ const hidden = [...el.querySelectorAll<HTMLElement>("li[data-key]")]
84
+ .filter(item => {
85
+ const rect = item.getBoundingClientRect();
86
+ return rect.bottom > box.bottom + 1 || rect.right > box.right + 1;
87
+ })
88
+ .map(item => item.dataset["key"]);
89
+
90
+ if (hidden.length > 0) {
91
+ // oxlint-disable-next-line no-console -- tells the author to split the list
92
+ console.warn(
93
+ `[slidev-theme-illinois] Slide ${$page.value}: ${hidden.length} reference(s) do not fit (${hidden.join(", ")}); split the list with \`from\` / \`to\` or use \`columns\``,
94
+ );
95
+ }
96
+ };
97
+
98
+ // Incremented by every fit; an older fit that is still running stops (mount, resize, font loading
99
+ // and prop changes can all start one)
100
+ let generation = 0;
101
+
102
+ /**
103
+ * Shrink the text in small steps until the list fits its box, then report anything still cut off
104
+ */
105
+ const fitToBox = async () => {
106
+ generation += 1;
107
+ const current = generation;
108
+
109
+ scale.value = 1;
110
+ await nextTick();
111
+
112
+ const el = root.value;
113
+ if (!el || current !== generation) {
114
+ return;
115
+ }
116
+
117
+ if (fit) {
118
+ while (scale.value > MIN_SCALE && el.scrollHeight > el.clientHeight + 1) {
119
+ scale.value = Math.round((scale.value - 0.05) * 100) / 100;
120
+ // oxlint-disable-next-line no-await-in-loop -- each step needs a re-render to measure
121
+ await nextTick();
122
+ if (current !== generation) {
123
+ return;
124
+ }
125
+ }
126
+ }
127
+
128
+ warnIfCutOff(el);
129
+ };
130
+
131
+ // Re-fit when the box changes size (e.g. window or layout changes), not only on mount
132
+ let observer: ResizeObserver | undefined = undefined;
133
+ let lastHeight = 0;
134
+
135
+ /**
136
+ * Re-fit, ignoring failures (event handlers cannot await)
137
+ */
138
+ const refit = () => {
139
+ fitToBox().catch(() => undefined);
140
+ };
141
+
142
+ onMounted(() => {
143
+ refit();
144
+
145
+ // Web fonts may still be loading on mount; the final fonts can wrap lines differently
146
+ document.fonts.addEventListener("loadingdone", refit);
147
+
148
+ if (root.value) {
149
+ observer = new ResizeObserver(([entry]) => {
150
+ const height = Math.round(entry?.contentRect.height ?? 0);
151
+ if (height !== lastHeight) {
152
+ lastHeight = height;
153
+ refit();
154
+ }
155
+ });
156
+ observer.observe(root.value);
157
+ }
158
+ });
159
+
160
+ onBeforeUnmount(() => {
161
+ observer?.disconnect();
162
+ document.fonts.removeEventListener("loadingdone", refit);
163
+ });
164
+
165
+ watch([list, () => columns, () => fit], refit);
166
+ </script>
167
+
168
+ <template>
169
+ <div
170
+ ref="root"
171
+ class="il-bibliography"
172
+ :class="{'il-bibliography-numeric': numeric}"
173
+ :style="{'--il-bib-columns': columns, '--il-bib-scale': scale}"
174
+ >
175
+ <p v-if="error" class="il-bibliography-error">{{ error }}</p>
176
+ <p v-else-if="list.length === 0" class="il-bibliography-empty">No references cited yet.</p>
177
+ <ol v-else>
178
+ <li v-for="entry in list" :key="entry.key" :data-key="entry.key">
179
+ <span v-if="numeric" class="il-bibliography-number">[{{ entry.n }}]</span>
180
+ <!-- oxlint-disable-next-line vue/no-v-html -- formatted by citeproc from the user's bibliography -->
181
+ <span v-html="entry.html" />
182
+ </li>
183
+ </ol>
184
+ </div>
185
+ </template>
@@ -0,0 +1,42 @@
1
+ <!--
2
+ Highlighted note. `type`: `important` | `note` (default) | `question` | `tip` | `warning`.
3
+ `title` overrides the label (`title=""` hides it).
4
+ -->
5
+
6
+ <script setup lang="ts">
7
+ import {computed} from "vue";
8
+
9
+ const {title, type = "note"} = defineProps<{
10
+ /**
11
+ * Label above the text (defaults to the type's name; `""` hides it)
12
+ */
13
+ title?: string;
14
+
15
+ /**
16
+ * Kind of note
17
+ */
18
+ type?: "important" | "note" | "question" | "tip" | "warning";
19
+ }>();
20
+
21
+ /**
22
+ * Default label per type
23
+ */
24
+ const LABELS = {
25
+ important: "Important",
26
+ note: "Note",
27
+ question: "Question",
28
+ tip: "Tip",
29
+ warning: "Warning",
30
+ };
31
+
32
+ const label = computed(() => title ?? LABELS[type]);
33
+ </script>
34
+
35
+ <template>
36
+ <aside class="il-callout" :class="`il-callout-${type}`">
37
+ <p v-if="label" class="il-callout-label">{{ label }}</p>
38
+ <div class="il-callout-body">
39
+ <slot />
40
+ </div>
41
+ </aside>
42
+ </template>
@@ -0,0 +1,37 @@
1
+ <!--
2
+ Flat content card. `tone`: `accent` (accent rule on top) | `outline` (hairline) | `panel`
3
+ (default, tinted fill) | `plain`. Optional `label` (small uppercase label) and `title`.
4
+ -->
5
+
6
+ <script setup lang="ts">
7
+ const {
8
+ label,
9
+ title,
10
+ tone = "panel",
11
+ } = defineProps<{
12
+ /**
13
+ * Small uppercase label above the title
14
+ */
15
+ label?: string;
16
+
17
+ /**
18
+ * Card title
19
+ */
20
+ title?: string;
21
+
22
+ /**
23
+ * Visual style
24
+ */
25
+ tone?: "accent" | "outline" | "panel" | "plain";
26
+ }>();
27
+ </script>
28
+
29
+ <template>
30
+ <div class="il-card" :class="`il-card-${tone}`">
31
+ <p v-if="label" class="il-card-label">{{ label }}</p>
32
+ <h3 v-if="title" class="il-card-title">{{ title }}</h3>
33
+ <div class="il-card-body">
34
+ <slot />
35
+ </div>
36
+ </div>
37
+ </template>
@@ -0,0 +1,62 @@
1
+ <!--
2
+ In-text citation. Usually generated from Pandoc-style markdown (`[@key]`, `[see @a; @b, p. 3]`),
3
+ but it can also be used directly: `<Cite keys="smith2024" />` or `<Cite :keys="['a', 'b']" />`
4
+ (`locator` with a single key).
5
+ -->
6
+
7
+ <script setup lang="ts">
8
+ import {computed} from "vue";
9
+ import {
10
+ citations,
11
+ type CiteItem,
12
+ decodeItems,
13
+ entryOf,
14
+ formatCitation,
15
+ splitKeys,
16
+ } from "#internal/citations.ts";
17
+
18
+ const {items, keys, locator} = defineProps<{
19
+ /**
20
+ * Encoded items (generated by the markdown transformer)
21
+ */
22
+ items?: string;
23
+
24
+ /**
25
+ * Cite key(s): an array, or a string separated by commas, semicolons or spaces
26
+ */
27
+ keys?: string[] | string;
28
+
29
+ /**
30
+ * Locator such as "p. 12" (single key only)
31
+ */
32
+ locator?: string;
33
+ }>();
34
+
35
+ // Cited works, from the transformer's encoded items or the `keys`/`locator` props
36
+ const parsed = computed<CiteItem[]>(() => {
37
+ if (items !== undefined) {
38
+ return decodeItems(items);
39
+ }
40
+
41
+ const list = splitKeys(keys) ?? [];
42
+ if (list.length === 1 && locator !== undefined) {
43
+ return [{key: list[0] as string, locator}];
44
+ }
45
+ return list.map(key => ({key}));
46
+ });
47
+
48
+ const label = computed(() => formatCitation(parsed.value, citations.value));
49
+
50
+ const missing = computed(() => parsed.value.some(item => !entryOf(citations.value, item.key)));
51
+
52
+ // Full references, shown as a tooltip
53
+ const title = computed(() =>
54
+ parsed.value
55
+ .map(item => entryOf(citations.value, item.key)?.text ?? `Missing reference: ${item.key}`)
56
+ .join("\n\n"),
57
+ );
58
+ </script>
59
+
60
+ <template>
61
+ <span class="il-cite" :class="{'il-cite-missing': missing}" :title="title">{{ label }}</span>
62
+ </template>