jsfs11 commited on
Commit
7f76615
·
verified ·
1 Parent(s): f9e25ca

Add 2 files

Browse files
Files changed (2) hide show
  1. README.md +7 -5
  2. index.html +651 -19
README.md CHANGED
@@ -1,10 +1,12 @@
1
  ---
2
- title: Md Reader
3
- emoji: 🐠
4
- colorFrom: red
5
- colorTo: blue
6
  sdk: static
7
  pinned: false
 
 
8
  ---
9
 
10
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
  ---
2
+ title: md-reader
3
+ emoji: 🐳
4
+ colorFrom: blue
5
+ colorTo: purple
6
  sdk: static
7
  pinned: false
8
+ tags:
9
+ - deepsite
10
  ---
11
 
12
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
index.html CHANGED
@@ -1,19 +1,651 @@
1
- <!doctype html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width" />
6
- <title>My static Space</title>
7
- <link rel="stylesheet" href="style.css" />
8
- </head>
9
- <body>
10
- <div class="card">
11
- <h1>Welcome to your static Space!</h1>
12
- <p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
13
- <p>
14
- Also don't forget to check the
15
- <a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
16
- </p>
17
- </div>
18
- </body>
19
- </html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Markdown Story Viewer</title>
7
+ <script src="https://cdn.tailwindcss.com"></script>
8
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
9
+ <style>
10
+ .markdown-body {
11
+ font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
12
+ line-height: 1.6;
13
+ color: #374151;
14
+ width: 100%;
15
+ max-width: 100%;
16
+ overflow-wrap: break-word;
17
+ word-wrap: break-word;
18
+ hyphens: auto;
19
+ }
20
+ .markdown-body h1 {
21
+ font-size: 2em;
22
+ border-bottom: 1px solid #e5e7eb;
23
+ padding-bottom: 0.3em;
24
+ margin-top: 1em;
25
+ margin-bottom: 0.6em;
26
+ overflow-wrap: break-word;
27
+ }
28
+ .markdown-body h2 {
29
+ font-size: 1.5em;
30
+ border-bottom: 1px solid #e5e7eb;
31
+ padding-bottom: 0.3em;
32
+ margin-top: 1em;
33
+ margin-bottom: 0.6em;
34
+ overflow-wrap: break-word;
35
+ }
36
+ .markdown-body h3 {
37
+ font-size: 1.25em;
38
+ margin-top: 1em;
39
+ margin-bottom: 0.6em;
40
+ overflow-wrap: break-word;
41
+ }
42
+ .markdown-body p {
43
+ margin-top: 0.8em;
44
+ margin-bottom: 0.8em;
45
+ overflow-wrap: break-word;
46
+ }
47
+ .markdown-body a {
48
+ color: #3b82f6;
49
+ text-decoration: none;
50
+ overflow-wrap: break-word;
51
+ }
52
+ .markdown-body a:hover {
53
+ text-decoration: underline;
54
+ }
55
+ .markdown-body blockquote {
56
+ border-left: 4px solid #e5e7eb;
57
+ padding-left: 1em;
58
+ color: #6b7280;
59
+ margin-left: 0;
60
+ margin-right: 0;
61
+ overflow-wrap: break-word;
62
+ }
63
+ .markdown-body code {
64
+ font-family: ui-monospace, SFMono-Regular, SF Mono, Menlo, Consolas, Liberation Mono, monospace;
65
+ background-color: rgba(175, 184, 193, 0.2);
66
+ border-radius: 6px;
67
+ padding: 0.2em 0.4em;
68
+ font-size: 85%;
69
+ overflow-wrap: break-word;
70
+ white-space: pre-wrap;
71
+ }
72
+ .markdown-body pre {
73
+ background-color: #f9fafb;
74
+ border-radius: 6px;
75
+ padding: 1em;
76
+ overflow: auto;
77
+ line-height: 1.45;
78
+ max-width: 100%;
79
+ }
80
+ .markdown-body pre code {
81
+ background-color: transparent;
82
+ padding: 0;
83
+ border-radius: 0;
84
+ white-space: pre;
85
+ overflow-x: auto;
86
+ display: block;
87
+ }
88
+ .markdown-body img {
89
+ max-width: 100%;
90
+ height: auto;
91
+ border-radius: 6px;
92
+ margin: 1em 0;
93
+ }
94
+ .markdown-body ul, .markdown-body ol {
95
+ padding-left: 2em;
96
+ margin-top: 0.8em;
97
+ margin-bottom: 0.8em;
98
+ overflow-wrap: break-word;
99
+ }
100
+ .markdown-body li {
101
+ margin-bottom: 0.4em;
102
+ overflow-wrap: break-word;
103
+ }
104
+ .markdown-body table {
105
+ border-collapse: collapse;
106
+ width: 100%;
107
+ margin: 1em 0;
108
+ display: block;
109
+ overflow-x: auto;
110
+ white-space: nowrap;
111
+ }
112
+ .markdown-body th, .markdown-body td {
113
+ border: 1px solid #e5e7eb;
114
+ padding: 0.5em 1em;
115
+ }
116
+ .markdown-body th {
117
+ background-color: #f9fafb;
118
+ font-weight: 600;
119
+ }
120
+ .markdown-body hr {
121
+ border: none;
122
+ border-top: 1px solid #e5e7eb;
123
+ margin: 1.5em 0;
124
+ }
125
+ .fade-in {
126
+ animation: fadeIn 0.3s ease-in-out;
127
+ }
128
+ @keyframes fadeIn {
129
+ from { opacity: 0; }
130
+ to { opacity: 1; }
131
+ }
132
+ .sidebar-item:hover {
133
+ background-color: rgba(59, 130, 246, 0.1);
134
+ }
135
+ .sidebar-item.active {
136
+ background-color: rgba(59, 130, 246, 0.2);
137
+ border-left: 3px solid #3b82f6;
138
+ }
139
+ .content-container {
140
+ scroll-behavior: smooth;
141
+ overflow-x: hidden;
142
+ }
143
+ .scroll-top {
144
+ opacity: 0;
145
+ transition: all 0.3s ease;
146
+ }
147
+ .scroll-top.visible {
148
+ opacity: 1;
149
+ }
150
+ /* Responsive scaling */
151
+ .responsive-content {
152
+ width: 100%;
153
+ padding: 0 1rem;
154
+ box-sizing: border-box;
155
+ }
156
+ @media (min-width: 640px) {
157
+ .responsive-content {
158
+ padding: 0 2rem;
159
+ }
160
+ }
161
+ @media (min-width: 1024px) {
162
+ .responsive-content {
163
+ max-width: 80ch;
164
+ margin: 0 auto;
165
+ }
166
+ }
167
+ </style>
168
+ </head>
169
+ <body class="bg-gray-50 min-h-screen">
170
+ <div class="flex flex-col md:flex-row h-screen">
171
+ <!-- Sidebar -->
172
+ <div class="w-full md:w-64 bg-white border-r border-gray-200 overflow-y-auto flex-shrink-0">
173
+ <div class="p-4 border-b border-gray-200">
174
+ <h1 class="text-xl font-bold text-gray-800">Story Collection</h1>
175
+ <div class="mt-2 relative">
176
+ <input type="text" id="searchInput" placeholder="Search stories..."
177
+ class="w-full px-3 py-2 border border-gray-300 rounded-md text-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500">
178
+ <i class="fas fa-search absolute right-3 top-2.5 text-gray-400"></i>
179
+ </div>
180
+ </div>
181
+ <div id="storyList" class="divide-y divide-gray-200">
182
+ <!-- Stories will be loaded here -->
183
+ <div class="p-4 text-gray-500 text-center">
184
+ <i class="fas fa-book-open text-2xl mb-2"></i>
185
+ <p>No stories loaded</p>
186
+ </div>
187
+ </div>
188
+ </div>
189
+
190
+ <!-- Main content -->
191
+ <div class="flex-1 flex flex-col overflow-hidden">
192
+ <!-- Toolbar -->
193
+ <div class="bg-white border-b border-gray-200 p-4 flex justify-between items-center">
194
+ <div class="min-w-0">
195
+ <h2 id="currentStoryTitle" class="text-lg font-semibold text-gray-800 truncate">No Story Selected</h2>
196
+ <p id="storyInfo" class="text-sm text-gray-500 truncate">Select a story to begin reading</p>
197
+ </div>
198
+ <div class="flex space-x-2 flex-shrink-0">
199
+ <button id="fontSizeDown" class="p-2 rounded-md hover:bg-gray-100 text-gray-700">
200
+ <i class="fas fa-font text-sm"></i> <i class="fas fa-minus text-xs"></i>
201
+ </button>
202
+ <button id="fontSizeUp" class="p-2 rounded-md hover:bg-gray-100 text-gray-700">
203
+ <i class="fas fa-font text-sm"></i> <i class="fas fa-plus text-xs"></i>
204
+ </button>
205
+ <button id="darkModeToggle" class="p-2 rounded-md hover:bg-gray-100 text-gray-700">
206
+ <i class="fas fa-moon"></i>
207
+ </button>
208
+ <button id="scrollTopBtn" class="scroll-top p-2 rounded-md hover:bg-gray-100 text-gray-700">
209
+ <i class="fas fa-arrow-up"></i>
210
+ </button>
211
+ </div>
212
+ </div>
213
+
214
+ <!-- Content area -->
215
+ <div id="contentContainer" class="content-container flex-1 overflow-y-auto bg-white">
216
+ <div id="markdownContent" class="markdown-body responsive-content">
217
+ <div class="text-center py-20 text-gray-400">
218
+ <i class="fas fa-book-open text-5xl mb-4"></i>
219
+ <h3 class="text-xl font-medium text-gray-500">Select a story from the sidebar</h3>
220
+ <p class="mt-2">Or upload your own Markdown file to read</p>
221
+ <button id="uploadBtn" class="mt-4 bg-blue-500 hover:bg-blue-600 text-white font-medium py-2 px-6 rounded-lg transition">
222
+ <i class="fas fa-upload mr-2"></i> Upload Markdown
223
+ </button>
224
+ <input type="file" id="fileInput" class="hidden" accept=".md,.markdown">
225
+ </div>
226
+ </div>
227
+ </div>
228
+
229
+ <!-- Footer -->
230
+ <div class="bg-white border-t border-gray-200 p-4 text-center text-sm text-gray-500">
231
+ <p>Markdown Story Viewer • Use arrow keys to navigate</p>
232
+ </div>
233
+ </div>
234
+ </div>
235
+
236
+ <script>
237
+ document.addEventListener('DOMContentLoaded', function() {
238
+ // DOM elements
239
+ const storyList = document.getElementById('storyList');
240
+ const contentContainer = document.getElementById('contentContainer');
241
+ const markdownContent = document.getElementById('markdownContent');
242
+ const currentStoryTitle = document.getElementById('currentStoryTitle');
243
+ const storyInfo = document.getElementById('storyInfo');
244
+ const uploadBtn = document.getElementById('uploadBtn');
245
+ const fileInput = document.getElementById('fileInput');
246
+ const searchInput = document.getElementById('searchInput');
247
+ const fontSizeDown = document.getElementById('fontSizeDown');
248
+ const fontSizeUp = document.getElementById('fontSizeUp');
249
+ const darkModeToggle = document.getElementById('darkModeToggle');
250
+ const scrollTopBtn = document.getElementById('scrollTopBtn');
251
+
252
+ // State variables
253
+ let stories = [];
254
+ let currentStoryIndex = -1;
255
+ let fontSize = 16; // base font size in px
256
+ let isDarkMode = false;
257
+
258
+ // Sample stories (could be loaded from an API or localStorage)
259
+ const sampleStories = [
260
+ {
261
+ id: 'sample1',
262
+ title: 'The Adventure Begins',
263
+ content: `# The Adventure Begins
264
+
265
+ ## Chapter 1: A Mysterious Letter
266
+
267
+ It was a dark and stormy night when the letter arrived. The *wind howled* through the trees as **Professor Langdon** sat by the fireplace in his study.
268
+
269
+ > "Strange things are afoot," he muttered to himself, adjusting his spectacles.
270
+
271
+ The letter contained only three words:
272
+
273
+ 1. **Find**
274
+ 2. The
275
+ 3. *Orb*
276
+
277
+ [Continue reading](#)`,
278
+ wordCount: 85,
279
+ lastUpdated: '2023-05-15'
280
+ },
281
+ {
282
+ id: 'sample2',
283
+ title: 'The Lost City',
284
+ content: `# The Lost City
285
+
286
+ ## Discovery in the Desert
287
+
288
+ The team had been searching for months when they finally found the entrance to the ancient city. The sandstone walls were covered in strange symbols:
289
+
290
+ \`\`\`
291
+ ▲ ▲ ▼ ▼ ◀ ▶ ◀ ▶ B A
292
+ \`\`\`
293
+
294
+ ### What They Found Inside
295
+
296
+ - Golden artifacts
297
+ - Ancient scrolls
298
+ - A map to... somewhere else
299
+
300
+ ![Ancient City](https://images.unsplash.com/photo-1467269204594-9661b134dd2b?w=800&auto=format)`,
301
+ wordCount: 62,
302
+ lastUpdated: '2023-06-22'
303
+ }
304
+ ];
305
+
306
+ // Initialize with sample stories
307
+ loadSampleStories();
308
+
309
+ // Event listeners
310
+ uploadBtn.addEventListener('click', () => fileInput.click());
311
+ fileInput.addEventListener('change', handleFileUpload);
312
+ searchInput.addEventListener('input', filterStories);
313
+ fontSizeDown.addEventListener('click', decreaseFontSize);
314
+ fontSizeUp.addEventListener('click', increaseFontSize);
315
+ darkModeToggle.addEventListener('click', toggleDarkMode);
316
+ scrollTopBtn.addEventListener('click', scrollToTop);
317
+ contentContainer.addEventListener('scroll', handleScroll);
318
+
319
+ // Handle window resize
320
+ window.addEventListener('resize', handleResize);
321
+
322
+ // Keyboard navigation
323
+ document.addEventListener('keydown', (e) => {
324
+ // Only handle key events when a story is selected
325
+ if (currentStoryIndex === -1) return;
326
+
327
+ switch(e.key) {
328
+ case 'ArrowUp':
329
+ case 'ArrowLeft':
330
+ showPreviousStory();
331
+ break;
332
+ case 'ArrowDown':
333
+ case 'ArrowRight':
334
+ showNextStory();
335
+ break;
336
+ case 'Home':
337
+ scrollToTop();
338
+ break;
339
+ case 'End':
340
+ scrollToBottom();
341
+ break;
342
+ case '+':
343
+ increaseFontSize();
344
+ break;
345
+ case '-':
346
+ decreaseFontSize();
347
+ break;
348
+ case 'd':
349
+ case 'D':
350
+ if (e.ctrlKey) toggleDarkMode();
351
+ break;
352
+ }
353
+ });
354
+
355
+ // Load sample stories
356
+ function loadSampleStories() {
357
+ stories = [...sampleStories];
358
+ updateStoryList();
359
+ }
360
+
361
+ // Handle file upload
362
+ function handleFileUpload() {
363
+ const file = fileInput.files[0];
364
+ if (!file) return;
365
+
366
+ const reader = new FileReader();
367
+ reader.onload = (e) => {
368
+ const content = e.target.result;
369
+ const wordCount = content.split(/\s+/).length;
370
+
371
+ const newStory = {
372
+ id: 'uploaded-' + Date.now(),
373
+ title: file.name.replace(/\.[^/.]+$/, ""), // Remove extension
374
+ content: content,
375
+ wordCount: wordCount,
376
+ lastUpdated: new Date().toISOString().split('T')[0]
377
+ };
378
+
379
+ stories.unshift(newStory);
380
+ updateStoryList();
381
+ showStory(0); // Show the newly uploaded story
382
+ };
383
+ reader.readAsText(file);
384
+ }
385
+
386
+ // Update the story list in sidebar
387
+ function updateStoryList() {
388
+ storyList.innerHTML = '';
389
+
390
+ if (stories.length === 0) {
391
+ storyList.innerHTML = `
392
+ <div class="p-4 text-gray-500 text-center">
393
+ <i class="fas fa-book-open text-2xl mb-2"></i>
394
+ <p>No stories available</p>
395
+ </div>
396
+ `;
397
+ return;
398
+ }
399
+
400
+ stories.forEach((story, index) => {
401
+ const storyElement = document.createElement('div');
402
+ storyElement.className = `sidebar-item p-4 cursor-pointer ${index === currentStoryIndex ? 'active' : ''}`;
403
+ storyElement.innerHTML = `
404
+ <h3 class="font-medium text-gray-800 truncate">${story.title}</h3>
405
+ <div class="flex justify-between items-center mt-1">
406
+ <span class="text-xs text-gray-500">${story.wordCount} words</span>
407
+ <span class="text-xs text-gray-400">${story.lastUpdated}</span>
408
+ </div>
409
+ `;
410
+
411
+ storyElement.addEventListener('click', () => {
412
+ showStory(index);
413
+ });
414
+
415
+ storyList.appendChild(storyElement);
416
+ });
417
+ }
418
+
419
+ // Filter stories based on search input
420
+ function filterStories() {
421
+ const searchTerm = searchInput.value.toLowerCase();
422
+
423
+ document.querySelectorAll('.sidebar-item').forEach((item, index) => {
424
+ const story = stories[index];
425
+ const matches = story.title.toLowerCase().includes(searchTerm) ||
426
+ story.content.toLowerCase().includes(searchTerm);
427
+
428
+ item.style.display = matches ? 'block' : 'none';
429
+ });
430
+ }
431
+
432
+ // Show story at specified index
433
+ function showStory(index) {
434
+ if (index < 0 || index >= stories.length) return;
435
+
436
+ currentStoryIndex = index;
437
+ const story = stories[index];
438
+
439
+ // Update active item in sidebar
440
+ document.querySelectorAll('.sidebar-item').forEach((item, i) => {
441
+ if (i === index) {
442
+ item.classList.add('active');
443
+ } else {
444
+ item.classList.remove('active');
445
+ }
446
+ });
447
+
448
+ // Update header
449
+ currentStoryTitle.textContent = story.title;
450
+ storyInfo.textContent = `${story.wordCount} words • Last updated ${story.lastUpdated}`;
451
+
452
+ // Convert markdown to HTML (simplified - in a real app you might use a library like marked.js)
453
+ const htmlContent = convertMarkdownToHtml(story.content);
454
+
455
+ // Display the content
456
+ markdownContent.innerHTML = htmlContent;
457
+ markdownContent.style.fontSize = `${fontSize}px`;
458
+
459
+ // Ensure all content fits without horizontal scrolling
460
+ handleResize();
461
+
462
+ // Scroll to top
463
+ scrollToTop();
464
+ }
465
+
466
+ // Simple markdown to HTML converter (basic functionality)
467
+ function convertMarkdownToHtml(markdown) {
468
+ // Headers
469
+ let html = markdown
470
+ .replace(/^# (.*$)/gm, '<h1>$1</h1>')
471
+ .replace(/^## (.*$)/gm, '<h2>$1</h2>')
472
+ .replace(/^### (.*$)/gm, '<h3>$1</h3>')
473
+ .replace(/^#### (.*$)/gm, '<h4>$1</h4>');
474
+
475
+ // Bold and italic
476
+ html = html
477
+ .replace(/\*\*(.*?)\*\*/g, '<strong>$1</strong>')
478
+ .replace(/\*(.*?)\*/g, '<em>$1</em>')
479
+ .replace(/\_(.*?)\_/g, '<em>$1</em>');
480
+
481
+ // Links
482
+ html = html.replace(/\[(.*?)\]\((.*?)\)/g, '<a href="$2">$1</a>');
483
+
484
+ // Images
485
+ html = html.replace(/!\[(.*?)\]\((.*?)\)/g, '<img src="$2" alt="$1" class="rounded shadow max-w-full h-auto">');
486
+
487
+ // Blockquotes
488
+ html = html.replace(/^\> (.*$)/gm, '<blockquote>$1</blockquote>');
489
+
490
+ // Lists
491
+ html = html.replace(/^\* (.*$)/gm, '<li>$1</li>');
492
+ html = html.replace(/^\- (.*$)/gm, '<li>$1</li>');
493
+ html = html.replace(/^\+ (.*$)/gm, '<li>$1</li>');
494
+
495
+ // Code blocks
496
+ html = html.replace(/```([\s\S]*?)```/g, '<pre><code>$1</code></pre>');
497
+ html = html.replace(/`(.*?)`/g, '<code>$1</code>');
498
+
499
+ // Paragraphs (handle line breaks)
500
+ html = html.replace(/(^|\n)([^\n].+?)(\n|$)/g, function(match, p1, p2, p3) {
501
+ // Don't wrap already wrapped elements
502
+ if (p2.startsWith('<') || p2.trim() === '') return match;
503
+ return p1 + '<p>' + p2 + '</p>' + p3;
504
+ });
505
+
506
+ // Horizontal rule
507
+ html = html.replace(/^\-\-\-$/gm, '<hr>');
508
+
509
+ return html;
510
+ }
511
+
512
+ // Navigation functions
513
+ function showPreviousStory() {
514
+ if (currentStoryIndex > 0) {
515
+ showStory(currentStoryIndex - 1);
516
+ }
517
+ }
518
+
519
+ function showNextStory() {
520
+ if (currentStoryIndex < stories.length - 1) {
521
+ showStory(currentStoryIndex + 1);
522
+ }
523
+ }
524
+
525
+ // Font size adjustment
526
+ function increaseFontSize() {
527
+ if (fontSize < 24) {
528
+ fontSize += 1;
529
+ markdownContent.style.fontSize = `${fontSize}px`;
530
+ handleResize();
531
+ }
532
+ }
533
+
534
+ function decreaseFontSize() {
535
+ if (fontSize > 12) {
536
+ fontSize -= 1;
537
+ markdownContent.style.fontSize = `${fontSize}px`;
538
+ handleResize();
539
+ }
540
+ }
541
+
542
+ // Dark mode toggle
543
+ function toggleDarkMode() {
544
+ isDarkMode = !isDarkMode;
545
+
546
+ if (isDarkMode) {
547
+ document.body.classList.add('bg-gray-900');
548
+ document.body.classList.remove('bg-gray-50');
549
+ markdownContent.classList.add('text-gray-200');
550
+ markdownContent.classList.remove('text-gray-800');
551
+ darkModeToggle.innerHTML = '<i class="fas fa-sun"></i>';
552
+
553
+ // Update all markdown elements
554
+ const elements = ['h1', 'h2', 'h3', 'h4', 'p', 'li', 'blockquote', 'code', 'a'];
555
+ elements.forEach(el => {
556
+ document.querySelectorAll(`.markdown-body ${el}`).forEach(item => {
557
+ if (el === 'a') {
558
+ item.classList.add('text-blue-400');
559
+ item.classList.remove('text-blue-600');
560
+ } else if (el === 'code') {
561
+ // No change for code
562
+ } else {
563
+ item.classList.add('text-gray-300');
564
+ item.classList.remove('text-gray-800');
565
+ }
566
+ });
567
+ });
568
+
569
+ document.querySelectorAll('.markdown-body pre').forEach(pre => {
570
+ pre.classList.add('bg-gray-800');
571
+ pre.classList.remove('bg-gray-100');
572
+ });
573
+ } else {
574
+ document.body.classList.remove('bg-gray-900');
575
+ document.body.classList.add('bg-gray-50');
576
+ markdownContent.classList.remove('text-gray-200');
577
+ markdownContent.classList.add('text-gray-800');
578
+ darkModeToggle.innerHTML = '<i class="fas fa-moon"></i>';
579
+
580
+ // Revert all markdown elements
581
+ const elements = ['h1', 'h2', 'h3', 'h4', 'p', 'li', 'blockquote', 'code', 'a'];
582
+ elements.forEach(el => {
583
+ document.querySelectorAll(`.markdown-body ${el}`).forEach(item => {
584
+ if (el === 'a') {
585
+ item.classList.remove('text-blue-400');
586
+ item.classList.add('text-blue-600');
587
+ } else if (el === 'code') {
588
+ // No change for code
589
+ } else {
590
+ item.classList.remove('text-gray-300');
591
+ item.classList.add('text-gray-800');
592
+ }
593
+ });
594
+ });
595
+
596
+ document.querySelectorAll('.markdown-body pre').forEach(pre => {
597
+ pre.classList.remove('bg-gray-800');
598
+ pre.classList.add('bg-gray-100');
599
+ });
600
+ }
601
+ }
602
+
603
+ // Scroll functions
604
+ function scrollToTop() {
605
+ contentContainer.scrollTo({
606
+ top: 0,
607
+ behavior: 'smooth'
608
+ });
609
+ }
610
+
611
+ function scrollToBottom() {
612
+ contentContainer.scrollTo({
613
+ top: contentContainer.scrollHeight,
614
+ behavior: 'smooth'
615
+ });
616
+ }
617
+
618
+ function handleScroll() {
619
+ // Show/hide scroll to top button
620
+ if (contentContainer.scrollTop > 300) {
621
+ scrollTopBtn.classList.add('visible');
622
+ } else {
623
+ scrollTopBtn.classList.remove('visible');
624
+ }
625
+ }
626
+
627
+ // Handle window resize and ensure content fits
628
+ function handleResize() {
629
+ // Ensure code blocks don't cause horizontal scrolling
630
+ document.querySelectorAll('.markdown-body pre').forEach(pre => {
631
+ pre.style.maxWidth = '100%';
632
+ pre.style.overflowX = 'auto';
633
+ });
634
+
635
+ // Ensure images don't overflow
636
+ document.querySelectorAll('.markdown-body img').forEach(img => {
637
+ img.style.maxWidth = '100%';
638
+ img.style.height = 'auto';
639
+ });
640
+
641
+ // Ensure tables are scrollable if needed
642
+ document.querySelectorAll('.markdown-body table').forEach(table => {
643
+ table.style.display = 'block';
644
+ table.style.overflowX = 'auto';
645
+ table.style.whiteSpace = 'nowrap';
646
+ });
647
+ }
648
+ });
649
+ </script>
650
+ <p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=jsfs11/md-reader" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
651
+ </html>