forked from TingjiaInFuture/allbemcp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapi.html
More file actions
820 lines (754 loc) · 36.2 KB
/
api.html
File metadata and controls
820 lines (754 loc) · 36.2 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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>API Reference - AllBeAPI Documentation</title>
<meta name="description" content="Complete API reference for AllBeAPI. Detailed documentation for all endpoints, parameters, and response formats.">
<!-- Stylesheets -->
<link rel="stylesheet" href="../assets/css/main.css">
<link rel="stylesheet" href="../assets/css/components.css">
<link rel="stylesheet" href="../assets/css/docs.css">
<!-- Syntax highlighting -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/github.min.css" id="highlight-light">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/github-dark.min.css" id="highlight-dark" disabled>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js"></script>
</head>
<body>
<!-- Navigation -->
<nav class="navbar">
<div class="container">
<div class="navbar-content">
<a href="../index.html" class="navbar-brand">
<span class="brand-icon">🚀</span>
AllBeAPI
</a>
<ul class="navbar-nav">
<li><a href="index.html">Documentation</a></li>
<li><a href="getting-started.html">Getting Started</a></li>
<li><a href="api.html" class="active">API Reference</a></li>
<li><a href="sdk.html">SDK Guide</a></li>
<li><a href="https://github.com/TingjiaInFuture/allbeapi" target="_blank">GitHub</a></li>
</ul>
<div class="navbar-actions">
<button class="theme-toggle" aria-label="Toggle dark mode">
<span class="theme-icon-dark">🌙</span>
<span class="theme-icon-light">☀️</span>
</button>
</div>
</div>
</div>
</nav>
<div class="docs-layout">
<!-- Sidebar -->
<aside class="docs-sidebar">
<div class="sidebar-content">
<h3 class="sidebar-title">API Reference</h3>
<nav class="sidebar-nav">
<ul>
<li><a href="#overview" class="nav-link">Overview</a></li>
<li><a href="#authentication" class="nav-link">Authentication</a></li>
<li><a href="#text-processing" class="nav-link">Text Processing</a>
<ul class="nav-sublist">
<li><a href="#marked">Markdown</a></li>
<li><a href="#beautifulsoup">HTML Parsing</a></li>
<li><a href="#sanitize-html">HTML Sanitization</a></li>
</ul>
</li>
<li><a href="#code-tools" class="nav-link">Code Tools</a>
<ul class="nav-sublist">
<li><a href="#prettier">Code Formatting</a></li>
<li><a href="#eslint">Linting</a></li>
<li><a href="#pygments">Syntax Highlighting</a></li>
</ul>
</li>
<li><a href="#data-processing" class="nav-link">Data Processing</a>
<ul class="nav-sublist">
<li><a href="#ajv">JSON Validation</a></li>
<li><a href="#csv-parser">CSV Processing</a></li>
<li><a href="#diff">Text Comparison</a></li>
</ul>
</li>
<li><a href="#media-generation" class="nav-link">Media Generation</a>
<ul class="nav-sublist">
<li><a href="#qrcode">QR Codes</a></li>
<li><a href="#mermaid">Diagrams</a></li>
<li><a href="#pdfkit">PDF Generation</a></li>
<li><a href="#pillow">Image Processing</a></li>
</ul>
</li>
<li><a href="#error-codes" class="nav-link">Error Codes</a></li>
</ul>
</nav>
</div>
</aside>
<!-- Main Content -->
<main class="docs-main">
<div class="docs-content">
<!-- Header -->
<header class="docs-header">
<h1>API Reference</h1>
<p class="docs-lead">
Complete reference documentation for the AllBeAPI REST API. All endpoints return JSON responses
and support both GET and POST methods where applicable.
</p>
<div class="api-info-card">
<div class="api-info-item">
<strong>Base URL:</strong> <code>https://res.allbeapi.top</code>
</div>
<div class="api-info-item">
<strong>Content-Type:</strong> <code>application/json</code>
</div>
<div class="api-info-item">
<strong>Rate Limit:</strong> 1000 requests/hour
</div>
</div>
</header>
<!-- Overview -->
<section id="overview" class="docs-section">
<h2>Overview</h2>
<p>
The AllBeAPI provides a unified REST interface to access multiple popular libraries.
All endpoints follow RESTful conventions and return consistent JSON responses.
</p>
<h3>Request Format</h3>
<pre><code class="language-http">POST /library-name/endpoint
Content-Type: application/json
{
"parameter1": "value1",
"parameter2": "value2"
}</code></pre>
<h3>Response Format</h3>
<pre><code class="language-json">{
"success": true,
"data": {
"result": "processed output"
},
"metadata": {
"processing_time": 0.125,
"library_version": "1.0.0"
}
}</code></pre>
<h3>Error Response Format</h3>
<pre><code class="language-json">{
"success": false,
"error": {
"code": "VALIDATION_ERROR",
"message": "Invalid input parameters",
"details": {
"field": "markdown",
"reason": "Required field missing"
}
}
}</code></pre>
</section>
<!-- Authentication -->
<section id="authentication" class="docs-section">
<h2>Authentication</h2>
<p>
AllBeAPI is currently free to use without authentication. For production use or higher rate limits,
you can obtain an API key.
</p>
<h3>Using API Keys (Optional)</h3>
<pre><code class="language-http">POST /marked/render
Authorization: Bearer your-api-key-here
Content-Type: application/json
{
"markdown": "# Hello World"
}</code></pre>
</section>
<!-- Text Processing -->
<section id="text-processing" class="docs-section">
<h2>Text Processing</h2>
<!-- Marked.js -->
<div id="marked" class="api-endpoint">
<h3>📝 Markdown Processing (Marked.js)</h3>
<p>Convert Markdown text to HTML using the popular Marked.js library.</p>
<div class="endpoint-details">
<div class="endpoint-method">POST</div>
<div class="endpoint-url">/marked/render</div>
</div>
<h4>Parameters</h4>
<div class="params-table">
<table>
<thead>
<tr>
<th>Parameter</th>
<th>Type</th>
<th>Required</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>markdown</code></td>
<td>string</td>
<td>Yes</td>
<td>The Markdown text to convert</td>
</tr>
<tr>
<td><code>options</code></td>
<td>object</td>
<td>No</td>
<td>Marked.js options (breaks, gfm, etc.)</td>
</tr>
</tbody>
</table>
</div>
<h4>Example Request</h4>
<pre><code class="language-bash">curl -X POST https://res.allbeapi.top/marked/render \
-H "Content-Type: application/json" \
-d '{
"markdown": "# Hello World\n\nThis is **bold** text with a [link](https://example.com).",
"options": {
"breaks": true,
"gfm": true
}
}'</code></pre>
<h4>Example Response</h4>
<pre><code class="language-json">{
"success": true,
"data": {
"html": "<h1>Hello World</h1>\n<p>This is <strong>bold</strong> text with a <a href=\"https://example.com\">link</a>.</p>"
},
"metadata": {
"processing_time": 0.045,
"library_version": "marked@5.1.2"
}
}</code></pre>
</div>
<!-- BeautifulSoup -->
<div id="beautifulsoup" class="api-endpoint">
<h3>🔍 HTML Parsing (BeautifulSoup)</h3>
<p>Parse HTML and extract data using CSS selectors or XPath expressions.</p>
<div class="endpoint-details">
<div class="endpoint-method">POST</div>
<div class="endpoint-url">/beautifulsoup/parse</div>
</div>
<h4>Parameters</h4>
<div class="params-table">
<table>
<thead>
<tr>
<th>Parameter</th>
<th>Type</th>
<th>Required</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>html</code></td>
<td>string</td>
<td>Yes</td>
<td>The HTML content to parse</td>
</tr>
<tr>
<td><code>selector</code></td>
<td>string</td>
<td>No</td>
<td>CSS selector to extract specific elements</td>
</tr>
<tr>
<td><code>action</code></td>
<td>string</td>
<td>No</td>
<td>Action to perform: "find", "find_all", "get_text"</td>
</tr>
</tbody>
</table>
</div>
<h4>Example Request</h4>
<pre><code class="language-bash">curl -X POST https://res.allbeapi.top/beautifulsoup/parse \
-H "Content-Type: application/json" \
-d '{
"html": "<div class=\"content\"><h1>Title</h1><p>Content here</p></div>",
"selector": "h1",
"action": "get_text"
}'</code></pre>
<h4>Example Response</h4>
<pre><code class="language-json">{
"success": true,
"data": {
"result": ["Title"],
"count": 1
}
}</code></pre>
</div>
<!-- HTML Sanitization -->
<div id="sanitize-html" class="api-endpoint">
<h3>🛡️ HTML Sanitization</h3>
<p>Clean HTML content to prevent XSS attacks and ensure content safety.</p>
<div class="endpoint-details">
<div class="endpoint-method">POST</div>
<div class="endpoint-url">/sanitize-html/clean</div>
</div>
<h4>Parameters</h4>
<div class="params-table">
<table>
<thead>
<tr>
<th>Parameter</th>
<th>Type</th>
<th>Required</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>html</code></td>
<td>string</td>
<td>Yes</td>
<td>The HTML content to sanitize</td>
</tr>
<tr>
<td><code>allowedTags</code></td>
<td>array</td>
<td>No</td>
<td>List of allowed HTML tags</td>
</tr>
<tr>
<td><code>allowedAttributes</code></td>
<td>object</td>
<td>No</td>
<td>Allowed attributes per tag</td>
</tr>
</tbody>
</table>
</div>
<h4>Example Request</h4>
<pre><code class="language-bash">curl -X POST https://res.allbeapi.top/sanitize-html/clean \
-H "Content-Type: application/json" \
-d '{
"html": "<p>Safe content</p><script>alert(\"xss\")</script>",
"allowedTags": ["p", "strong", "em"],
"allowedAttributes": {}
}'</code></pre>
</div>
</section>
<!-- Code Tools -->
<section id="code-tools" class="docs-section">
<h2>Code Tools</h2>
<!-- Prettier -->
<div id="prettier" class="api-endpoint">
<h3>✨ Code Formatting (Prettier)</h3>
<p>Format code using Prettier with support for multiple languages and configurations.</p>
<div class="endpoint-details">
<div class="endpoint-method">POST</div>
<div class="endpoint-url">/prettier/format</div>
</div>
<h4>Parameters</h4>
<div class="params-table">
<table>
<thead>
<tr>
<th>Parameter</th>
<th>Type</th>
<th>Required</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>code</code></td>
<td>string</td>
<td>Yes</td>
<td>The code to format</td>
</tr>
<tr>
<td><code>parser</code></td>
<td>string</td>
<td>Yes</td>
<td>Parser: "babel", "typescript", "css", "html", "json", "markdown"</td>
</tr>
<tr>
<td><code>options</code></td>
<td>object</td>
<td>No</td>
<td>Prettier formatting options</td>
</tr>
</tbody>
</table>
</div>
<h4>Example Request</h4>
<pre><code class="language-bash">curl -X POST https://res.allbeapi.top/prettier/format \
-H "Content-Type: application/json" \
-d '{
"code": "const x=1;function test(){return x;}",
"parser": "babel",
"options": {
"semi": true,
"singleQuote": true,
"tabWidth": 2
}
}'</code></pre>
<h4>Example Response</h4>
<pre><code class="language-json">{
"success": true,
"data": {
"formatted": "const x = 1;\nfunction test() {\n return x;\n}\n"
}
}</code></pre>
</div>
<!-- ESLint -->
<div id="eslint" class="api-endpoint">
<h3>🔧 Code Linting (ESLint)</h3>
<p>Analyze JavaScript and TypeScript code for errors and code quality issues.</p>
<div class="endpoint-details">
<div class="endpoint-method">POST</div>
<div class="endpoint-url">/eslint/analyze</div>
</div>
<h4>Parameters</h4>
<div class="params-table">
<table>
<thead>
<tr>
<th>Parameter</th>
<th>Type</th>
<th>Required</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>code</code></td>
<td>string</td>
<td>Yes</td>
<td>The JavaScript/TypeScript code to analyze</td>
</tr>
<tr>
<td><code>config</code></td>
<td>object</td>
<td>No</td>
<td>ESLint configuration options</td>
</tr>
<tr>
<td><code>filename</code></td>
<td>string</td>
<td>No</td>
<td>Filename for context (affects rules)</td>
</tr>
</tbody>
</table>
</div>
<h4>Example Request</h4>
<pre><code class="language-bash">curl -X POST https://res.allbeapi.top/eslint/analyze \
-H "Content-Type: application/json" \
-d '{
"code": "var x = 1; console.log(x)",
"config": {
"rules": {
"no-console": "warn",
"prefer-const": "error"
}
}
}'</code></pre>
</div>
</section>
<!-- Data Processing -->
<section id="data-processing" class="docs-section">
<h2>Data Processing</h2>
<!-- AJV -->
<div id="ajv" class="api-endpoint">
<h3>✅ JSON Schema Validation (AJV)</h3>
<p>Validate JSON data against JSON Schema using the fastest validator available.</p>
<div class="endpoint-details">
<div class="endpoint-method">POST</div>
<div class="endpoint-url">/ajv/validate</div>
</div>
<h4>Parameters</h4>
<div class="params-table">
<table>
<thead>
<tr>
<th>Parameter</th>
<th>Type</th>
<th>Required</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>schema</code></td>
<td>object</td>
<td>Yes</td>
<td>JSON Schema definition</td>
</tr>
<tr>
<td><code>data</code></td>
<td>any</td>
<td>Yes</td>
<td>Data to validate against the schema</td>
</tr>
</tbody>
</table>
</div>
<h4>Example Request</h4>
<pre><code class="language-bash">curl -X POST https://res.allbeapi.top/ajv/validate \
-H "Content-Type: application/json" \
-d '{
"schema": {
"type": "object",
"properties": {
"name": {"type": "string"},
"age": {"type": "number", "minimum": 0}
},
"required": ["name"]
},
"data": {
"name": "John Doe",
"age": 30
}
}'</code></pre>
<h4>Example Response</h4>
<pre><code class="language-json">{
"success": true,
"data": {
"valid": true,
"errors": []
}
}</code></pre>
</div>
</section>
<!-- Media Generation -->
<section id="media-generation" class="docs-section">
<h2>Media Generation</h2>
<!-- QR Code -->
<div id="qrcode" class="api-endpoint">
<h3>📱 QR Code Generation</h3>
<p>Generate QR codes with customizable options and formats.</p>
<div class="endpoint-details">
<div class="endpoint-method">POST</div>
<div class="endpoint-url">/python-qrcode/generate-qrcode</div>
</div>
<h4>Parameters</h4>
<div class="params-table">
<table>
<thead>
<tr>
<th>Parameter</th>
<th>Type</th>
<th>Required</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>data</code></td>
<td>string</td>
<td>Yes</td>
<td>Data to encode in the QR code</td>
</tr>
<tr>
<td><code>size</code></td>
<td>number</td>
<td>No</td>
<td>Size of the QR code (default: 10)</td>
</tr>
<tr>
<td><code>border</code></td>
<td>number</td>
<td>No</td>
<td>Border size (default: 4)</td>
</tr>
<tr>
<td><code>error_correction</code></td>
<td>string</td>
<td>No</td>
<td>Error correction level: "L", "M", "Q", "H"</td>
</tr>
</tbody>
</table>
</div>
<h4>Example Request</h4>
<pre><code class="language-bash">curl -X POST https://res.allbeapi.top/python-qrcode/generate-qrcode \
-H "Content-Type: application/json" \
-d '{
"data": "https://allbeapi.com",
"size": 10,
"border": 4,
"error_correction": "M"
}' \
--output qrcode.png</code></pre>
<div class="response-note">
<strong>Note:</strong> This endpoint returns a binary PNG image.
The response Content-Type will be <code>image/png</code>.
</div>
</div>
</section>
<!-- Error Codes -->
<section id="error-codes" class="docs-section">
<h2>Error Codes</h2>
<p>AllBeAPI uses standard HTTP status codes and custom error codes for specific situations.</p>
<div class="error-codes-table">
<h3>HTTP Status Codes</h3>
<table>
<thead>
<tr>
<th>Status Code</th>
<th>Meaning</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>200</code></td>
<td>Success</td>
<td>Request processed successfully</td>
</tr>
<tr>
<td><code>400</code></td>
<td>Bad Request</td>
<td>Invalid request parameters or format</td>
</tr>
<tr>
<td><code>401</code></td>
<td>Unauthorized</td>
<td>Invalid or missing API key</td>
</tr>
<tr>
<td><code>429</code></td>
<td>Rate Limit Exceeded</td>
<td>Too many requests in the given time period</td>
</tr>
<tr>
<td><code>500</code></td>
<td>Internal Server Error</td>
<td>Server error during processing</td>
</tr>
<tr>
<td><code>503</code></td>
<td>Service Unavailable</td>
<td>Service temporarily unavailable</td>
</tr>
</tbody>
</table>
</div>
<div class="error-codes-table">
<h3>Custom Error Codes</h3>
<table>
<thead>
<tr>
<th>Error Code</th>
<th>Description</th>
<th>Resolution</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>VALIDATION_ERROR</code></td>
<td>Request validation failed</td>
<td>Check required parameters and data types</td>
</tr>
<tr>
<td><code>PROCESSING_ERROR</code></td>
<td>Error during content processing</td>
<td>Verify input data format and content</td>
</tr>
<tr>
<td><code>LIBRARY_ERROR</code></td>
<td>Underlying library error</td>
<td>Check input compatibility with the specific library</td>
</tr>
<tr>
<td><code>RATE_LIMIT_EXCEEDED</code></td>
<td>Rate limit exceeded</td>
<td>Wait before making more requests or upgrade plan</td>
</tr>
<tr>
<td><code>CONTENT_TOO_LARGE</code></td>
<td>Input content exceeds size limits</td>
<td>Reduce content size or split into smaller chunks</td>
</tr>
</tbody>
</table>
</div>
<h3>Example Error Response</h3>
<pre><code class="language-json">{
"success": false,
"error": {
"code": "VALIDATION_ERROR",
"message": "Missing required parameter 'markdown'",
"details": {
"parameter": "markdown",
"type": "string",
"required": true
}
},
"request_id": "req_123456789"
}</code></pre>
</section>
</div>
<!-- Table of Contents -->
<aside class="docs-toc">
<h4>Quick Navigation</h4>
<nav class="toc-nav">
<ul>
<li><a href="#overview">Overview</a></li>
<li><a href="#authentication">Authentication</a></li>
<li><a href="#text-processing">Text Processing</a></li>
<li><a href="#code-tools">Code Tools</a></li>
<li><a href="#data-processing">Data Processing</a></li>
<li><a href="#media-generation">Media Generation</a></li>
<li><a href="#error-codes">Error Codes</a></li>
</ul>
</nav>
<div class="toc-cta">
<h5>Try it out!</h5>
<p>Test the API endpoints directly from your browser or with our interactive SDK examples.</p>
<a href="sdk.html" class="btn btn-sm btn-primary">SDK Guide</a>
</div>
</aside>
</main>
</div>
<!-- Scripts -->
<script src="../assets/js/main.js"></script>
<script src="../assets/js/docs.js"></script>
<script>
// Initialize syntax highlighting
hljs.highlightAll();
// Initialize theme
const savedTheme = localStorage.getItem('theme') || 'light';
document.documentElement.setAttribute('data-theme', savedTheme);
// Update highlight.js theme
function updateHighlightTheme(theme) {
const lightLink = document.getElementById('highlight-light');
const darkLink = document.getElementById('highlight-dark');
if (theme === 'dark') {
lightLink.disabled = true;
darkLink.disabled = false;
} else {
lightLink.disabled = false;
darkLink.disabled = true;
}
}
updateHighlightTheme(savedTheme);
// Theme toggle
document.querySelector('.theme-toggle')?.addEventListener('click', () => {
const currentTheme = document.documentElement.getAttribute('data-theme');
const newTheme = currentTheme === 'dark' ? 'light' : 'dark';
document.documentElement.setAttribute('data-theme', newTheme);
localStorage.setItem('theme', newTheme);
updateHighlightTheme(newTheme);
});
// Copy code functionality
document.querySelectorAll('pre code').forEach(block => {
const button = document.createElement('button');
button.className = 'copy-code-btn';
button.innerHTML = '📋';
button.title = 'Copy to clipboard';
button.addEventListener('click', async () => {
try {
await navigator.clipboard.writeText(block.textContent);
button.innerHTML = '✅';
setTimeout(() => button.innerHTML = '📋', 2000);
} catch (err) {
console.error('Failed to copy: ', err);
}
});
block.parentNode.style.position = 'relative';
block.parentNode.appendChild(button);
});
</script>
</body>
</html>