juxscript 1.1.317 → 1.1.318
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tag.d.ts","sourceRoot":"","sources":["../../../lib/components/tag.ts"],"names":[],"mappings":"AAIA,UAAU,UAAU;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACtB;AAED,cAAM,GAAG;IACL,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,UAAU,CAAC;IACjB,OAAO,CAAC,QAAQ,CAA4B;gBAEhC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,UAAe;IAOjE,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAC5B,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAC1B,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAG1B,QAAQ,IAAI,MAAM;IAClB,UAAU,IAAI,MAAM;IACpB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAC3B,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAC7B,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAC3B,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAC3B,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAE/B,UAAU,IAAI,WAAW,GAAG,IAAI;IAEhC,MAAM,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,WAAW;CAuBvC;AAED,wBAAgB,GAAG,CAAC,EAAE,EAAE,MAAM,EAAE,OA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from '../utils/idgen.js';
|
|
2
2
|
import { pageState } from '../state/pageState.js';
|
|
3
|
-
import
|
|
3
|
+
import codeparser from '../utils/codeparser.js';
|
|
4
4
|
class Tag {
|
|
5
5
|
constructor(id, tagName, options = {}) {
|
|
6
6
|
this._element = null;
|
|
@@ -66,35 +66,16 @@ export function code(id, options = {}) {
|
|
|
66
66
|
if (!document.getElementById('__jux-hl-styles')) {
|
|
67
67
|
const style = document.createElement('style');
|
|
68
68
|
style.id = '__jux-hl-styles';
|
|
69
|
-
style.textContent =
|
|
70
|
-
.jux-code {
|
|
71
|
-
display: block;
|
|
72
|
-
background: hsl(var(--muted, 0 0% 96%));
|
|
73
|
-
border: 1px solid hsl(var(--border, 0 0% 89.8%));
|
|
74
|
-
border-radius: var(--radius, 6px);
|
|
75
|
-
padding: 12px 16px;
|
|
76
|
-
font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
|
|
77
|
-
font-size: 13px;
|
|
78
|
-
line-height: 1.5;
|
|
79
|
-
overflow-x: auto;
|
|
80
|
-
white-space: pre;
|
|
81
|
-
tab-size: 2;
|
|
82
|
-
}
|
|
83
|
-
.jux-hl-keyword { color: hsl(var(--primary, 262 83% 58%)); font-weight: 600; }
|
|
84
|
-
.jux-hl-string { color: hsl(142 71% 45%); }
|
|
85
|
-
.jux-hl-number { color: hsl(25 95% 53%); }
|
|
86
|
-
.jux-hl-comment { color: hsl(var(--muted-foreground, 0 0% 45%)); font-style: italic; }
|
|
87
|
-
.jux-hl-fn { color: hsl(221 83% 53%); }
|
|
88
|
-
.jux-hl-punct { color: hsl(var(--muted-foreground, 0 0% 45%)); }
|
|
89
|
-
.jux-hl-ident { color: hsl(var(--foreground, 0 0% 9%)); }
|
|
90
|
-
`;
|
|
69
|
+
style.textContent = codeparser.getCSS();
|
|
91
70
|
document.head.appendChild(style);
|
|
92
71
|
}
|
|
93
|
-
//
|
|
72
|
+
// Parse and highlight content
|
|
94
73
|
const raw = options.content || '';
|
|
95
74
|
const trimmed = raw.replace(/^\n+/, '').replace(/\n+$/, '');
|
|
96
|
-
const
|
|
97
|
-
//
|
|
75
|
+
const parsed = codeparser.parse(trimmed);
|
|
76
|
+
// Build line-by-line HTML
|
|
77
|
+
const linesHtml = parsed.map(line => `<div class="jux-code-line"><span class="jux-code-line-number">${line.lineNumber}</span><span class="jux-code-line-content">${line.html}</span></div>`).join('');
|
|
78
|
+
// Create as <pre> with inner code structure
|
|
98
79
|
const t = new Tag(id, 'pre', {
|
|
99
80
|
...options,
|
|
100
81
|
content: undefined,
|
|
@@ -104,7 +85,8 @@ export function code(id, options = {}) {
|
|
|
104
85
|
const el = t.getElement();
|
|
105
86
|
if (el) {
|
|
106
87
|
const codeEl = document.createElement('code');
|
|
107
|
-
codeEl.
|
|
88
|
+
codeEl.className = 'jux-code-lines';
|
|
89
|
+
codeEl.innerHTML = linesHtml;
|
|
108
90
|
el.appendChild(codeEl);
|
|
109
91
|
}
|
|
110
92
|
pageState.__register(t);
|