xonecas.io
6533
Yo

yoctomarkdown / files

yoctomarkdown / src / themes.ts

1.4 KB
1import * as colors from "yoctocolors";
2
3export interface Theme {
4  heading: (text: string) => string;
5  bold: (text: string) => string;
6  italic: (text: string) => string;
7  code: (text: string) => string;
8  codeBlock: (text: string) => string;
9  link: (text: string) => string;
10  listMarker: (text: string) => string;
11  blockquote: (text: string) => string;
12  hr: (text: string) => string;
13}
14
15const none: Theme = {
16  heading: (t) => t,
17  bold: (t) => t,
18  italic: (t) => t,
19  code: (t) => t,
20  codeBlock: (t) => t,
21  link: (t) => t,
22  listMarker: (t) => t,
23  blockquote: (t) => t,
24  hr: (t) => t,
25};
26
27const minimal: Theme = {
28  heading: colors.bold,
29  bold: colors.bold,
30  italic: colors.italic,
31  code: colors.bgGray,
32  codeBlock: colors.dim,
33  link: colors.underline,
34  listMarker: colors.dim,
35  blockquote: colors.dim,
36  hr: colors.dim,
37};
38
39const ansi16: Theme = {
40  heading: (t) => colors.cyan(colors.bold(t)),
41  bold: colors.bold,
42  italic: colors.italic,
43  code: (t) => colors.bgBlack(colors.yellow(t)),
44  codeBlock: colors.yellow,
45  link: colors.blue,
46  listMarker: colors.magenta,
47  blockquote: colors.green,
48  hr: colors.gray,
49};
50
51const ansi256 = ansi16; // In a full implementation we might map specific 256 colors
52const truecolor = ansi16; // Same
53
54export const themes: Record<string, Theme> = {
55  none,
56  minimal,
57  "16": ansi16,
58  "256": ansi256,
59  truecolor: truecolor,
60};