File size: 15,922 Bytes
2bd0113
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Markdown Parser</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <script>
        tailwind.config = {
            theme: {
                extend: {
                    colors: {
                        primary: '#4F46E5',
                        secondary: '#818CF8',
                        dark: '#1E293B',
                        light: '#F8FAFC'
                    }
                }
            }
        }
    </script>
    <style>
        .markdown-body {
            font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
            line-height: 1.6;
            color: #333;
        }
        .markdown-body h1 {
            font-size: 2em;
            border-bottom: 1px solid #eaecef;
            padding-bottom: 0.3em;
            margin-top: 1em;
            margin-bottom: 0.8em;
        }
        .markdown-body h2 {
            font-size: 1.5em;
            border-bottom: 1px solid #eaecef;
            padding-bottom: 0.3em;
            margin-top: 1em;
            margin-bottom: 0.8em;
        }
        .markdown-body h3 {
            font-size: 1.25em;
            margin-top: 1em;
            margin-bottom: 0.6em;
        }
        .markdown-body p {
            margin-bottom: 1em;
        }
        .markdown-body ul, .markdown-body ol {
            padding-left: 2em;
            margin-bottom: 1em;
        }
        .markdown-body blockquote {
            border-left: 4px solid #dfe2e5;
            padding: 0 1em;
            color: #6a737d;
            margin-bottom: 1em;
        }
        .markdown-body pre {
            background-color: #f6f8fa;
            padding: 1em;
            border-radius: 6px;
            overflow: auto;
            margin-bottom: 1em;
        }
        .markdown-body code {
            background-color: rgba(175,184,193,0.2);
            padding: 0.2em 0.4em;
            border-radius: 6px;
            font-family: ui-monospace, SFMono-Regular, SF Mono, Menlo, Consolas, Liberation Mono, monospace;
        }
        .markdown-body table {
            border-collapse: collapse;
            width: 100%;
            margin-bottom: 1em;
        }
        .markdown-body th, .markdown-body td {
            border: 1px solid #dfe2e5;
            padding: 6px 13px;
        }
        .markdown-body th {
            background-color: #f6f8fa;
            font-weight: 600;
        }
        .markdown-body tr:nth-child(even) {
            background-color: #f6f8fa;
        }
        .editor, .preview {
            min-height: 500px;
        }
        .resize-handle {
            width: 4px;
            background-color: #c7d2fe;
            cursor: col-resize;
            transition: background-color 0.2s;
        }
        .resize-handle:hover {
            background-color: #818CF8;
        }
        .tab-btn {
            border-bottom: 3px solid #4F46E5;
            color: #4F46E5;
            font-weight: 600;
        }
        .syntax-highlight {
            color: #d63384;
        }
        .hljs {
            display: block;
            overflow-x: auto;
            padding: 0.5em;
            background: #f8f8f8;
        }
    </style>
</head>
<body class="bg-gray-50">
    <header class="bg-gradient-to-r from-primary to-secondary text-white shadow-lg">
        <div class="container mx-auto px-4 py-6">
            <div class="flex items-center justify-between">
                <div class="flex items-center space-x-3">
                    <i class="fas fa-code text-2xl"></i>
                    <h1 class="text-2xl md:text-3xl font-bold">Markdown Parser</h1>
                </div>
                <div class="flex space-x-4">
                    <button class="bg-white text-primary px-4 py-2 rounded-lg font-medium hover:bg-gray-100 transition">
                        <i class="fas fa-download mr-2"></i>Export
                    </button>
                    <button class="bg-white text-primary px-4 py-2 rounded-lg font-medium hover:bg-gray-100 transition">
                        <i class="fas fa-share-alt mr-2"></i>Share
                    </button>
                </div>
            </div>
        </div>
    </header>

    <main class="container mx-auto px-4 py-8">
        <div class="bg-white rounded-xl shadow-lg overflow-hidden">
            <!-- Tabs -->
            <div class="flex border-b">
                <button id="editor-tab" class="tab-btn px-6 py-4 text-sm md:text-base">Editor</button>
                <button id="preview-tab" class="px-6 py-4 text-sm md:text-base text-gray-600 hover:text-primary">Preview</button>
                <button id="split-tab" class="px-6 py-4 text-sm md:text-base text-gray-600 hover:text-primary">Split View</button>
            </div>

            <!-- Editor and Preview Area -->
            <div class="flex flex-col md:flex-row" id="content-area">
                <!-- Editor -->
                <div class="w-full md:w-1/2" id="editor-container">
                    <div class="p-4 bg-gray-50 border-b md:border-b-0 md:border-r border-gray-200">
                        <div class="flex justify-between items-center mb-2">
                            <h3 class="font-medium text-gray-700">
                                <i class="fas fa-edit mr-2 text-secondary"></i>Markdown Editor
                            </h3>
                            <div class="text-sm text-gray-500">
                                <span id="line-count">0</span> lines
                            </div>
                        </div>
                        <textarea id="editor" class="editor w-full h-96 p-4 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary focus:border-transparent font-mono text-sm" placeholder="Start typing your Markdown here..."># Welcome to Markdown Parser

## This is a simple Markdown editor

You can write **bold text**, *italic text*, and even ~~strikethrough~~.

### Lists

- Item 1
- Item 2
- Item 3

### Code Block

```javascript
function helloWorld() {
  console.log("Hello, Markdown!");
}
```

### Blockquote

> This is a blockquote. It can span multiple lines.

### Table

| Syntax      | Description |
| ----------- | ----------- |
| Header      | Title       |
| Paragraph   | Text        |

### Link

[Visit GitHub](https://github.com)

### Image

![Markdown Logo](https://markdown-here.com/img/icon256.png)</textarea>
                    </div>
                </div>

                <!-- Resize Handle -->
                <div class="resize-handle hidden md:block" id="resize-handle"></div>

                <!-- Preview -->
                <div class="w-full md:w-1/2" id="preview-container">
                    <div class="p-4">
                        <div class="flex justify-between items-center mb-2">
                            <h3 class="font-medium text-gray-700">
                                <i class="fas fa-eye mr-2 text-secondary"></i>Preview
                            </h3>
                            <div class="text-sm text-gray-500">
                                <span id="word-count">0</span> words
                            </div>
                        </div>
                        <div id="preview" class="preview markdown-body p-4 border border-gray-300 rounded-lg overflow-auto h-96 bg-white"></div>
                    </div>
                </div>
            </div>
        </div>

        <!-- Markdown Cheatsheet -->
        <div class="mt-8 bg-white rounded-xl shadow-lg overflow-hidden">
            <div class="bg-gray-50 px-4 py-3 border-b">
                <h2 class="text-lg font-semibold text-gray-800">
                    <i class="fas fa-book mr-2 text-primary"></i>Markdown Cheatsheet
                </h2>
            </div>
            <div class="p-4">
                <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4">
                    <div class="p-3 border rounded-lg">
                        <h3 class="font-medium text-gray-800 mb-2">Text</h3>
                        <p><code>**Bold**</code><strong>Bold</strong></p>
                        <p><code>*Italic*</code><em>Italic</em></p>
                        <p><code>~~Strikethrough~~</code><s>Strikethrough</s></p>
                    </div>
                    <div class="p-3 border rounded-lg">
                        <h3 class="font-medium text-gray-800 mb-2">Headers</h3>
                        <p><code># H1</code></p>
                        <p><code>## H2</code></p>
                        <p><code>### H3</code></p>
                    </div>
                    <div class="p-3 border rounded-lg">
                        <h3 class="font-medium text-gray-800 mb-2">Lists</h3>
                        <p><code>- Item 1</code></p>
                        <p><code>- Item 2</code></p>
                        <p><code>1. Ordered 1</code></p>
                        <p><code>2. Ordered 2</code></p>
                    </div>
                    <div class="p-3 border rounded-lg">
                        <h3 class="font-medium text-gray-800 mb-2">Other</h3>
                        <p><code>[Link](url)</code></p>
                        <p><code>![Image](src)</code></p>
                        <p><code>&gt; Blockquote</code></p>
                        <p><code>``` Code block ```</code></p>
                    </div>
                </div>
            </div>
        </div>
    </main>

    <footer class="bg-dark text-gray-300 py-8 mt-12">
        <div class="container mx-auto px-4">
            <div class="flex flex-col md:flex-row justify-between items-center">
                <div class="mb-4 md:mb-0">
                    <h3 class="text-xl font-bold text-white">Markdown Parser</h3>
                    <p class="mt-2">A simple and powerful Markdown editor</p>
                </div>
                <div class="flex space-x-6">
                    <a href="#" class="hover:text-white transition"><i class="fab fa-github text-xl"></i></a>
                    <a href="#" class="hover:text-white transition"><i class="fab fa-twitter text-xl"></i></a>
                    <a href="#" class="hover:text-white transition"><i class="fab fa-linkedin text-xl"></i></a>
                </div>
            </div>
            <div class="mt-8 text-center text-sm">
                <p>© 2023 Markdown Parser. All rights reserved.</p>
            </div>
        </div>
    </footer>

    <script>
        // Initialize Marked.js
        marked.setOptions({
            breaks: true,
            highlight: function(code, lang) {
                return code;
            }
        });

        // Get DOM elements
        const editor = document.getElementById('editor');
        const preview = document.getElementById('preview');
        const lineCount = document.getElementById('line-count');
        const wordCount = document.getElementById('word-count');
        const editorTab = document.getElementById('editor-tab');
        const previewTab = document.getElementById('preview-tab');
        const splitTab = document.getElementById('split-tab');
        const editorContainer = document.getElementById('editor-container');
        const previewContainer = document.getElementById('preview-container');
        const resizeHandle = document.getElementById('resize-handle');
        const contentArea = document.getElementById('content-area');

        // Initial render
        updatePreview();
        updateCounts();

        // Event listeners
        editor.addEventListener('input', () => {
            updatePreview();
            updateCounts();
        });

        // Tab switching
        editorTab.addEventListener('click', () => {
            setActiveTab('editor');
        });

        previewTab.addEventListener('click', () => {
            setActiveTab('preview');
        });

        splitTab.addEventListener('click', () => {
            setActiveTab('split');
        });

        // Resize functionality
        let isResizing = false;

        resizeHandle.addEventListener('mousedown', (e) => {
            isResizing = true;
            document.body.style.cursor = 'col-resize';
            e.preventDefault();
        });

        document.addEventListener('mousemove', (e) => {
            if (!isResizing) return;
            
            const containerRect = contentArea.getBoundingClientRect();
            const containerWidth = containerRect.width;
            const mouseX = e.clientX - containerRect.left;
            
            const editorWidth = (mouseX / containerWidth) * 100;
            const previewWidth = 100 - editorWidth;
            
            editorContainer.style.width = `${editorWidth}%`;
            previewContainer.style.width = `${previewWidth}%`;
        });

        document.addEventListener('mouseup', () => {
            isResizing = false;
            document.body.style.cursor = 'default';
        });

        // Functions
        function updatePreview() {
            const markdownText = editor.value;
            preview.innerHTML = marked.parse(markdownText);
        }

        function updateCounts() {
            // Line count
            const lines = editor.value.split('\n').length;
            lineCount.textContent = lines;
            
            // Word count
            const words = editor.value.trim() === '' ? 0 : editor.value.trim().length;
            wordCount.textContent = words;
        }

        function setActiveTab(tab) {
            // Reset all tabs
            editorTab.classList.remove('tab-btn');
            previewTab.classList.remove('tab-btn');
            splitTab.classList.remove('tab-btn');
            editorTab.classList.add('text-gray-600');
            previewTab.classList.add('text-gray-600');
            splitTab.classList.add('text-gray-600');
            
            // Hide/show elements based on tab
            if (tab === 'editor') {
                editorTab.classList.add('tab-btn');
                editorContainer.classList.remove('hidden');
                previewContainer.classList.add('hidden');
                resizeHandle.classList.add('hidden');
            } else if (tab === 'preview') {
                previewTab.classList.add('tab-btn');
                editorContainer.classList.add('hidden');
                previewContainer.classList.remove('hidden');
                resizeHandle.classList.add('hidden');
            } else {
                splitTab.classList.add('tab-btn');
                editorContainer.classList.remove('hidden');
                previewContainer.classList.remove('hidden');
                resizeHandle.classList.remove('hidden');
                editorContainer.style.width = '50%';
                previewContainer.style.width = '50%';
            }
        }

        // Initialize with split view
        setActiveTab('split');
    </script>
<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=tatht/markdown-parser" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html>