-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathcustom-theme.js
More file actions
executable file
·180 lines (157 loc) · 3.81 KB
/
custom-theme.js
File metadata and controls
executable file
·180 lines (157 loc) · 3.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
#!/usr/bin/env node
/**
* Custom theming example
*
* This example demonstrates how to use custom themes with cli-html
* to control the appearance of rendered HTML and Markdown.
*/
import { renderHTML, renderMarkdown } from '../../index.js';
// Define custom themes
const darkTheme = {
h1: 'magenta bold',
h2: 'cyan bold',
h3: 'blue bold',
a: 'cyan underline',
blockquote: 'gray italic',
code: {
color: 'yellowBright',
inline: 'bgBlack yellow',
numbers: 'blackBright dim'
},
table: {
header: 'magenta bold',
caption: 'bold cyan',
cell: 'white'
},
ul: {
color: 'green',
markers: [
{ marker: '◆', color: 'green' },
{ marker: '■', color: 'greenBright' },
{ marker: '▸', color: 'cyan' }
]
},
ol: {
color: 'blueBright',
markers: [
{ marker: '1', color: 'blueBright' },
{ marker: 'A', color: 'cyanBright' },
{ marker: 'a', color: 'magentaBright' },
{ marker: 'I', color: 'greenBright' },
{ marker: 'i', color: 'yellowBright' }
]
}
};
const lightTheme = {
h1: 'blue bold',
h2: 'green bold',
h3: 'yellow bold',
a: 'blue underline',
blockquote: 'blackBright italic',
code: {
color: 'blue',
inline: 'bgWhite black',
numbers: 'gray dim'
},
table: {
header: 'blue bold',
caption: 'bold green',
cell: 'black'
}
};
const vibrantTheme = {
h1: 'redBright bold',
h2: 'yellowBright bold',
h3: 'greenBright bold',
a: 'cyanBright underline',
blockquote: 'magentaBright italic',
code: {
color: 'greenBright',
inline: 'bgBlack greenBright',
numbers: 'gray'
},
table: {
header: 'redBright bold',
caption: 'bold yellowBright',
cell: 'whiteBright'
},
ul: {
color: 'cyanBright',
markers: [
{ marker: '★', color: 'yellowBright' },
{ marker: '✦', color: 'cyanBright' },
{ marker: '✧', color: 'magentaBright' }
]
}
};
// Example content
const htmlContent = `
<h1>Custom Theme Demo</h1>
<p>This is a paragraph with <strong>bold text</strong> and <code>inline code</code>.</p>
<h2>Features</h2>
<ul>
<li>Custom colors</li>
<li>Custom markers</li>
<li>Flexible styling</li>
</ul>
<h2>Code Example</h2>
<pre><code class="language-javascript">
const theme = {
h1: "magenta bold",
code: { color: "yellowBright" }
};
</code></pre>
<h3>Data Table</h3>
<table>
<thead>
<tr><th>Feature</th><th>Status</th></tr>
</thead>
<tbody>
<tr><td>Theming</td><td>✓ Supported</td></tr>
<tr><td>Colors</td><td>✓ Full support</td></tr>
</tbody>
</table>
`;
const markdownContent = `
# Custom Theme Demo
This is a paragraph with **bold text** and \`inline code\`.
## Features
- Custom colors
- Custom markers
- Flexible styling
## Code Example
\`\`\`javascript
const theme = {
h1: "magenta bold",
code: { color: "yellowBright" }
};
\`\`\`
### Data Table
| Feature | Status |
|----------|----------------|
| Theming | ✓ Supported |
| Colors | ✓ Full support |
> [!TIP]
> You can customize every aspect of the theme!
`;
// Render with different themes
console.log('='.repeat(60));
console.log('DARK THEME (HTML)');
console.log('='.repeat(60));
console.log(renderHTML(htmlContent, darkTheme));
console.log('\n' + '='.repeat(60));
console.log('LIGHT THEME (HTML)');
console.log('='.repeat(60));
console.log(renderHTML(htmlContent, lightTheme));
console.log('\n' + '='.repeat(60));
console.log('VIBRANT THEME (HTML)');
console.log('='.repeat(60));
console.log(renderHTML(htmlContent, vibrantTheme));
console.log('\n' + '='.repeat(60));
console.log('DARK THEME (Markdown)');
console.log('='.repeat(60));
console.log(renderMarkdown(markdownContent, darkTheme));
console.log('\n' + '='.repeat(60));
console.log('VIBRANT THEME (Markdown)');
console.log('='.repeat(60));
console.log(renderMarkdown(markdownContent, vibrantTheme));