jekyll-github-code 0.1.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.
@@ -0,0 +1,381 @@
1
+ /* Jekyll GitHub Code Styles
2
+ * Supports both light and dark themes
3
+ * For Chirpy theme: uses data-mode="light" for light, default for dark
4
+ */
5
+
6
+ .github-code-block {
7
+ --github-code-bg: #0d1117;
8
+ --github-code-header-bg: #161b22;
9
+ --github-code-border: #30363d;
10
+ --github-code-text: #e6edf3;
11
+ --github-code-text-secondary: #8b949e;
12
+ --github-code-link: #58a6ff;
13
+ --github-code-link-hover: #79c0ff;
14
+ --github-code-copy-hover: #238636;
15
+
16
+ font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
17
+ background-color: var(--github-code-bg);
18
+ border: 1px solid var(--github-code-border);
19
+ border-radius: 8px;
20
+ margin: 16px 0;
21
+ overflow: hidden;
22
+ box-sizing: border-box;
23
+ transition: border-color 0.2s ease, box-shadow 0.2s ease;
24
+ }
25
+
26
+ .github-code-block:hover {
27
+ border-color: var(--github-code-link);
28
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
29
+ }
30
+
31
+ /* Light theme support */
32
+ [data-mode="light"] .github-code-block,
33
+ .light .github-code-block,
34
+ [data-theme="light"] .github-code-block,
35
+ .github-code-block.light {
36
+ --github-code-bg: #ffffff;
37
+ --github-code-header-bg: #f6f8fa;
38
+ --github-code-border: #d0d7de;
39
+ --github-code-text: #1f2328;
40
+ --github-code-text-secondary: #656d76;
41
+ --github-code-link: #0969da;
42
+ --github-code-link-hover: #0550ae;
43
+ }
44
+
45
+ [data-mode="light"] .github-code-block:hover,
46
+ .light .github-code-block:hover,
47
+ [data-theme="light"] .github-code-block:hover,
48
+ .github-code-block.light:hover {
49
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
50
+ }
51
+
52
+ /* Prefer color scheme for automatic detection */
53
+ @media (prefers-color-scheme: light) {
54
+ .github-code-block:not([data-theme]):not(.dark) {
55
+ --github-code-bg: #ffffff;
56
+ --github-code-header-bg: #f6f8fa;
57
+ --github-code-border: #d0d7de;
58
+ --github-code-text: #1f2328;
59
+ --github-code-text-secondary: #656d76;
60
+ --github-code-link: #0969da;
61
+ --github-code-link-hover: #0550ae;
62
+ }
63
+
64
+ .github-code-block:not([data-theme]):not(.dark):hover {
65
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
66
+ }
67
+ }
68
+
69
+ /* Header */
70
+ .github-code-header {
71
+ display: flex;
72
+ align-items: center;
73
+ justify-content: space-between;
74
+ padding: 10px 16px;
75
+ background-color: var(--github-code-header-bg);
76
+ border-bottom: 1px solid var(--github-code-border);
77
+ font-size: 14px;
78
+ }
79
+
80
+ .github-code-filename {
81
+ display: flex;
82
+ align-items: center;
83
+ gap: 8px;
84
+ color: var(--github-code-text);
85
+ min-width: 0;
86
+ overflow: hidden;
87
+ }
88
+
89
+ .github-code-filename a {
90
+ color: var(--github-code-link);
91
+ text-decoration: none;
92
+ font-weight: 600;
93
+ transition: color 0.2s ease;
94
+ word-break: break-word;
95
+ overflow-wrap: break-word;
96
+ }
97
+
98
+ .github-code-filename a:hover {
99
+ color: var(--github-code-link-hover);
100
+ text-decoration: underline;
101
+ }
102
+
103
+ .github-icon {
104
+ flex-shrink: 0;
105
+ color: var(--github-code-text-secondary);
106
+ }
107
+
108
+ /* Copy button */
109
+ .github-code-copy {
110
+ display: flex;
111
+ align-items: center;
112
+ justify-content: center;
113
+ padding: 6px;
114
+ background: transparent;
115
+ border: none;
116
+ border-radius: 6px;
117
+ cursor: pointer;
118
+ color: var(--github-code-text-secondary);
119
+ transition: all 0.2s ease;
120
+ flex-shrink: 0;
121
+ }
122
+
123
+ .github-code-copy:hover {
124
+ background: rgba(128, 128, 128, 0.2);
125
+ color: var(--github-code-text);
126
+ }
127
+
128
+ .github-code-copy.copied {
129
+ color: var(--github-code-copy-hover);
130
+ }
131
+
132
+ .github-code-copy svg {
133
+ flex-shrink: 0;
134
+ }
135
+
136
+ /* Code content */
137
+ .github-code-content {
138
+ overflow-x: auto;
139
+ }
140
+
141
+ .github-code-content pre {
142
+ margin: 0;
143
+ padding: 16px;
144
+ background: transparent !important;
145
+ border: none !important;
146
+ border-radius: 0 !important;
147
+ }
148
+
149
+ .github-code-content code {
150
+ font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
151
+ font-size: 14px;
152
+ line-height: 1.6;
153
+ color: var(--github-code-text);
154
+ background: transparent !important;
155
+ padding: 0 !important;
156
+ border: none !important;
157
+ white-space: pre;
158
+ word-wrap: normal;
159
+ overflow-wrap: normal;
160
+ }
161
+
162
+ /* Error state */
163
+ .github-code-error {
164
+ --github-code-error-bg: #3d1f28;
165
+ --github-code-error-border: #f85149;
166
+
167
+ font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif;
168
+ background-color: var(--github-code-error-bg);
169
+ border: 1px solid var(--github-code-error-border);
170
+ border-radius: 8px;
171
+ padding: 16px;
172
+ margin: 16px 0;
173
+ font-size: 14px;
174
+ }
175
+
176
+ .github-code-error strong {
177
+ display: block;
178
+ margin-bottom: 4px;
179
+ color: var(--github-code-error-border);
180
+ }
181
+
182
+ .github-code-error {
183
+ color: var(--github-code-error-border);
184
+ }
185
+
186
+ /* Light theme error state */
187
+ [data-mode="light"] .github-code-error,
188
+ .light .github-code-error,
189
+ [data-theme="light"] .github-code-error,
190
+ .github-code-error.light {
191
+ --github-code-error-bg: #ffebe9;
192
+ --github-code-error-border: #cf222e;
193
+ }
194
+
195
+ @media (prefers-color-scheme: light) {
196
+ .github-code-error:not([data-theme]):not(.dark) {
197
+ --github-code-error-bg: #ffebe9;
198
+ --github-code-error-border: #cf222e;
199
+ }
200
+ }
201
+
202
+ /* Syntax highlighting tokens (GitHub-inspired) - Dark theme */
203
+ .github-code-content .token.comment,
204
+ .github-code-content .token.prolog,
205
+ .github-code-content .token.doctype,
206
+ .github-code-content .token.cdata {
207
+ color: #8b949e;
208
+ }
209
+
210
+ .github-code-content .token.punctuation {
211
+ color: #c9d1d9;
212
+ }
213
+
214
+ .github-code-content .token.property,
215
+ .github-code-content .token.tag,
216
+ .github-code-content .token.boolean,
217
+ .github-code-content .token.number,
218
+ .github-code-content .token.constant,
219
+ .github-code-content .token.symbol,
220
+ .github-code-content .token.deleted {
221
+ color: #79c0ff;
222
+ }
223
+
224
+ .github-code-content .token.selector,
225
+ .github-code-content .token.attr-name,
226
+ .github-code-content .token.string,
227
+ .github-code-content .token.char,
228
+ .github-code-content .token.builtin,
229
+ .github-code-content .token.inserted {
230
+ color: #a5d6ff;
231
+ }
232
+
233
+ .github-code-content .token.operator,
234
+ .github-code-content .token.entity,
235
+ .github-code-content .token.url,
236
+ .github-code-content .language-css .token.string,
237
+ .github-code-content .style .token.string {
238
+ color: #d2a8ff;
239
+ }
240
+
241
+ .github-code-content .token.atrule,
242
+ .github-code-content .token.attr-value,
243
+ .github-code-content .token.keyword {
244
+ color: #ff7b72;
245
+ }
246
+
247
+ .github-code-content .token.function,
248
+ .github-code-content .token.class-name {
249
+ color: #d2a8ff;
250
+ }
251
+
252
+ .github-code-content .token.regex,
253
+ .github-code-content .token.important,
254
+ .github-code-content .token.variable {
255
+ color: #ffa657;
256
+ }
257
+
258
+ /* Syntax highlighting - Light theme */
259
+ [data-mode="light"] .github-code-content .token.comment,
260
+ [data-mode="light"] .github-code-content .token.prolog,
261
+ [data-mode="light"] .github-code-content .token.doctype,
262
+ [data-mode="light"] .github-code-content .token.cdata,
263
+ .light .github-code-content .token.comment,
264
+ .light .github-code-content .token.prolog,
265
+ .light .github-code-content .token.doctype,
266
+ .light .github-code-content .token.cdata,
267
+ [data-theme="light"] .github-code-content .token.comment,
268
+ [data-theme="light"] .github-code-content .token.prolog,
269
+ [data-theme="light"] .github-code-content .token.doctype,
270
+ [data-theme="light"] .github-code-content .token.cdata {
271
+ color: #6e7781;
272
+ }
273
+
274
+ [data-mode="light"] .github-code-content .token.punctuation,
275
+ .light .github-code-content .token.punctuation,
276
+ [data-theme="light"] .github-code-content .token.punctuation {
277
+ color: #24292f;
278
+ }
279
+
280
+ [data-mode="light"] .github-code-content .token.property,
281
+ [data-mode="light"] .github-code-content .token.tag,
282
+ [data-mode="light"] .github-code-content .token.boolean,
283
+ [data-mode="light"] .github-code-content .token.number,
284
+ [data-mode="light"] .github-code-content .token.constant,
285
+ [data-mode="light"] .github-code-content .token.symbol,
286
+ [data-mode="light"] .github-code-content .token.deleted,
287
+ .light .github-code-content .token.property,
288
+ .light .github-code-content .token.tag,
289
+ .light .github-code-content .token.boolean,
290
+ .light .github-code-content .token.number,
291
+ .light .github-code-content .token.constant,
292
+ .light .github-code-content .token.symbol,
293
+ .light .github-code-content .token.deleted,
294
+ [data-theme="light"] .github-code-content .token.property,
295
+ [data-theme="light"] .github-code-content .token.tag,
296
+ [data-theme="light"] .github-code-content .token.boolean,
297
+ [data-theme="light"] .github-code-content .token.number,
298
+ [data-theme="light"] .github-code-content .token.constant,
299
+ [data-theme="light"] .github-code-content .token.symbol,
300
+ [data-theme="light"] .github-code-content .token.deleted {
301
+ color: #0550ae;
302
+ }
303
+
304
+ [data-mode="light"] .github-code-content .token.selector,
305
+ [data-mode="light"] .github-code-content .token.attr-name,
306
+ [data-mode="light"] .github-code-content .token.string,
307
+ [data-mode="light"] .github-code-content .token.char,
308
+ [data-mode="light"] .github-code-content .token.builtin,
309
+ [data-mode="light"] .github-code-content .token.inserted,
310
+ .light .github-code-content .token.selector,
311
+ .light .github-code-content .token.attr-name,
312
+ .light .github-code-content .token.string,
313
+ .light .github-code-content .token.char,
314
+ .light .github-code-content .token.builtin,
315
+ .light .github-code-content .token.inserted,
316
+ [data-theme="light"] .github-code-content .token.selector,
317
+ [data-theme="light"] .github-code-content .token.attr-name,
318
+ [data-theme="light"] .github-code-content .token.string,
319
+ [data-theme="light"] .github-code-content .token.char,
320
+ [data-theme="light"] .github-code-content .token.builtin,
321
+ [data-theme="light"] .github-code-content .token.inserted {
322
+ color: #0a3069;
323
+ }
324
+
325
+ [data-mode="light"] .github-code-content .token.atrule,
326
+ [data-mode="light"] .github-code-content .token.attr-value,
327
+ [data-mode="light"] .github-code-content .token.keyword,
328
+ .light .github-code-content .token.atrule,
329
+ .light .github-code-content .token.attr-value,
330
+ .light .github-code-content .token.keyword,
331
+ [data-theme="light"] .github-code-content .token.atrule,
332
+ [data-theme="light"] .github-code-content .token.attr-value,
333
+ [data-theme="light"] .github-code-content .token.keyword {
334
+ color: #cf222e;
335
+ }
336
+
337
+ [data-mode="light"] .github-code-content .token.function,
338
+ [data-mode="light"] .github-code-content .token.class-name,
339
+ [data-mode="light"] .github-code-content .token.operator,
340
+ [data-mode="light"] .github-code-content .token.entity,
341
+ [data-mode="light"] .github-code-content .token.url,
342
+ .light .github-code-content .token.function,
343
+ .light .github-code-content .token.class-name,
344
+ .light .github-code-content .token.operator,
345
+ .light .github-code-content .token.entity,
346
+ .light .github-code-content .token.url,
347
+ [data-theme="light"] .github-code-content .token.function,
348
+ [data-theme="light"] .github-code-content .token.class-name,
349
+ [data-theme="light"] .github-code-content .token.operator,
350
+ [data-theme="light"] .github-code-content .token.entity,
351
+ [data-theme="light"] .github-code-content .token.url {
352
+ color: #8250df;
353
+ }
354
+
355
+ [data-mode="light"] .github-code-content .token.regex,
356
+ [data-mode="light"] .github-code-content .token.important,
357
+ [data-mode="light"] .github-code-content .token.variable,
358
+ .light .github-code-content .token.regex,
359
+ .light .github-code-content .token.important,
360
+ .light .github-code-content .token.variable,
361
+ [data-theme="light"] .github-code-content .token.regex,
362
+ [data-theme="light"] .github-code-content .token.important,
363
+ [data-theme="light"] .github-code-content .token.variable {
364
+ color: #953800;
365
+ }
366
+
367
+ /* Responsive */
368
+ @media (max-width: 520px) {
369
+ .github-code-header {
370
+ flex-wrap: wrap;
371
+ gap: 8px;
372
+ }
373
+
374
+ .github-code-content pre {
375
+ padding: 12px;
376
+ }
377
+
378
+ .github-code-content code {
379
+ font-size: 12px;
380
+ }
381
+ }
@@ -0,0 +1,30 @@
1
+ /**
2
+ * GitHub Code Block - Copy functionality
3
+ */
4
+ function copyGitHubCode(button) {
5
+ const codeBlock = button.closest('.github-code-block');
6
+ const codeElement = codeBlock.querySelector('code');
7
+ const text = codeElement.textContent;
8
+
9
+ navigator.clipboard.writeText(text).then(() => {
10
+ button.classList.add('copied');
11
+ button.innerHTML = `
12
+ <svg viewBox="0 0 16 16" width="16" height="16">
13
+ <path fill="currentColor" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"/>
14
+ </svg>
15
+ `;
16
+
17
+ setTimeout(() => {
18
+ button.classList.remove('copied');
19
+ button.innerHTML = `
20
+ <svg viewBox="0 0 16 16" width="16" height="16">
21
+ <path fill="currentColor" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"/>
22
+ <path fill="currentColor" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"/>
23
+ </svg>
24
+ `;
25
+ }, 2000);
26
+ }).catch(err => {
27
+ console.error('Failed to copy code:', err);
28
+ });
29
+ }
30
+