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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.adoc ADDED
@@ -0,0 +1,87 @@
1
+ = github-code
2
+ :toc:
3
+
4
+ image:https://img.shields.io/npm/v/github-code[npm version,link=https://www.npmjs.com/package/github-code]
5
+ image:https://img.shields.io/npm/l/github-code[License]
6
+ image:https://img.shields.io/badge/highlight.js-syntax%20highlighting-blue[highlight.js]
7
+
8
+ A web component for displaying GitHub files with syntax highlighting.
9
+
10
+ == Installation
11
+
12
+ Include the script in your HTML:
13
+
14
+ [source,html]
15
+ ----
16
+ <script type="module" src="https://cdn.jsdelivr.net/npm/github-code/dist/github-code.min.js"></script>
17
+ ----
18
+
19
+ Or install via npm:
20
+
21
+ [source,bash]
22
+ ----
23
+ npm install github-code
24
+ ----
25
+
26
+ == Usage
27
+
28
+ === Single File
29
+
30
+ [source,html]
31
+ ----
32
+ <github-code
33
+ file="https://github.com/owner/repo/blob/main/src/example.ts">
34
+ </github-code>
35
+ ----
36
+
37
+ === Multiple Files (Tabbed)
38
+
39
+ Comma-separate URLs to display files as tabs:
40
+
41
+ [source,html]
42
+ ----
43
+ <github-code
44
+ file="https://github.com/owner/repo/blob/main/src/app.ts,
45
+ https://github.com/owner/repo/blob/main/src/utils.ts">
46
+ </github-code>
47
+ ----
48
+
49
+ == Attributes
50
+
51
+ [cols="1,1,3"]
52
+ |===
53
+ | Attribute | Default | Description
54
+
55
+ | `file` | _(required)_ | GitHub blob URL(s). Comma-separated for multiple files.
56
+ | `theme` | `auto` | `light`, `dark`, or `auto` (follows system preference)
57
+ |===
58
+
59
+ == URL Format
60
+
61
+ URLs must be GitHub blob URLs:
62
+
63
+ ----
64
+ https://github.com/{owner}/{repo}/blob/{branch|commit}/{path}
65
+ ----
66
+
67
+ == Features
68
+
69
+ * Syntax highlighting via highlight.js (auto-detected language)
70
+ * Lazy loading (content fetched on demand)
71
+ * Keyboard-accessible tabs (Arrow keys, Home, End)
72
+ * CSP-compliant (no inline styles)
73
+ * Shadow DOM encapsulation
74
+
75
+ == Development
76
+
77
+ [source,bash]
78
+ ----
79
+ npm install
80
+ npm run build # Build dist files
81
+ npm run dev # Watch mode
82
+ npm run test:ci # Full CI check (lint + typecheck + build + tests)
83
+ ----
84
+
85
+ == License
86
+
87
+ MIT