-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.html
More file actions
365 lines (335 loc) · 21.2 KB
/
Copy pathindex.html
File metadata and controls
365 lines (335 loc) · 21.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>URL to Markdown</title>
<meta name="description" content="Convert any webpage or HTML into clean, structured Markdown instantly.">
<link rel="icon"
href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 32 32%22><rect rx=%226%22 width=%2232%22 height=%2232%22 fill=%22%23C2410C%22/><path d=%22M8 10h4l4 6 4-6h4v12h-3.5v-7.5L17 17.5h-2l-3.5-3v7h-3.5V10z%22 fill=%22white%22/></svg>">
<script src="https://cdn.tailwindcss.com?plugins=typography"></script>
<script src="js/config.js"></script>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap"
rel="stylesheet">
<script src="https://unpkg.com/turndown/dist/turndown.js"></script>
<script src="https://unpkg.com/turndown-plugin-gfm/dist/turndown-plugin-gfm.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/dompurify/3.0.6/purify.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
<link rel="stylesheet" href="css/main.css">
</head>
<body>
<!-- Header -->
<header class="app-header">
<div class="header-inner">
<a href="#" class="brand" title="URL to Markdown">
<div class="brand-mark">
<svg width="18" height="18" viewBox="0 0 32 32" fill="none">
<path d="M8 10h4l4 6 4-6h4v12h-3.5v-7.5L17 17.5h-2l-3.5-3v7h-3.5V10z" fill="currentColor"/>
</svg>
</div>
<span class="brand-name">URL to Markdown</span>
</a>
<div class="header-actions">
<div class="shortcut-hint">
<kbd>Ctrl</kbd><span class="shortcut-sep">+</span><kbd>Enter</kbd>
<span class="shortcut-divider"></span>
<kbd>Ctrl</kbd><span class="shortcut-sep">+</span><kbd>Shift</kbd><span class="shortcut-sep">+</span><kbd>C</kbd>
</div>
<button onclick="loadDemo()" class="header-btn header-btn--accent" title="Load demo content">
<svg width="13" height="13" viewBox="0 0 24 24" fill="currentColor">
<path d="M8 5v14l11-7z"/>
</svg>
Demo
</button>
<button onclick="showHelp()" class="header-btn" title="Keyboard shortcuts">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<rect x="2" y="4" width="20" height="16" rx="2"/>
<path d="M6 8h.01M10 8h.01M14 8h.01M18 8h.01M8 12h.01M12 12h.01M16 12h.01M8 16h8"/>
</svg>
<span class="hide-mobile">Shortcuts</span>
</button>
</div>
</div>
</header>
<!-- Main Application -->
<main class="app-main">
<!-- LEFT: Input Column -->
<section class="col col--input">
<!-- Controls Panel -->
<div class="card controls-card">
<!-- URL Row -->
<div class="input-row">
<div class="field field--url">
<div class="field-icon">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"/>
<path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"/>
</svg>
</div>
<input type="text" id="url-input" placeholder="Paste a URL and press Enter..."
class="field-input" autocomplete="off" spellcheck="false">
<button onclick="fetchURL(true)" id="fetch-btn" class="fetch-btn" title="Fetch URL content and convert">
<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">
<polyline points="1 4 1 10 7 10"/>
<path d="M3.51 15a9 9 0 1 0 2.13-9.36L1 10"/>
</svg>
Fetch
</button>
</div>
<div class="field field--selector">
<div class="field-icon">
<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<polyline points="16 18 22 12 16 6"/>
<polyline points="8 6 2 12 8 18"/>
</svg>
</div>
<input type="text" id="selector-input" list="selector-list" placeholder="body"
value="body" class="field-input font-mono" autocomplete="off" spellcheck="false">
<button onclick="toggleSelectorDropdown()" id="selector-dropdown-btn"
class="selector-expand-btn hidden" title="Browse selectors">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<polyline points="6 9 12 15 18 9"/>
</svg>
</button>
<datalist id="selector-list"></datalist>
</div>
</div>
<!-- Selector Panel -->
<div id="selector-panel" class="selector-panel hidden">
<div class="selector-panel-head">
<span class="selector-panel-title">Available Selectors</span>
<span id="selector-count" class="selector-panel-count"></span>
<button onclick="hideSelectorPanel()" class="selector-panel-close" title="Close">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/>
</svg>
</button>
</div>
<div id="drill-path-display" class="drill-path hidden">
<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<polyline points="9 18 15 12 9 6"/>
</svg>
<span id="drill-path-text" class="drill-path-text"></span>
<button onclick="resetDrillPath()" class="drill-reset">
<svg width="10" height="10" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">
<line x1="19" y1="12" x2="5" y2="12"/><polyline points="12 19 5 12 12 5"/>
</svg>
Reset
</button>
</div>
<div class="selector-filters">
<button onclick="filterSelectors('all')" class="selector-filter active" data-filter="all">All</button>
<button onclick="filterSelectors('id')" class="selector-filter" data-filter="id">IDs</button>
<button onclick="filterSelectors('class')" class="selector-filter" data-filter="class">Classes</button>
<button onclick="filterSelectors('tag')" class="selector-filter" data-filter="tag">Tags</button>
</div>
<div class="selector-search-wrap">
<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<circle cx="11" cy="11" r="8"/><line x1="21" y1="21" x2="16.65" y2="16.65"/>
</svg>
<input type="text" id="selector-search" placeholder="Filter..."
oninput="searchSelectors(this.value)" class="selector-search-input">
</div>
<div id="selector-items" class="selector-items"></div>
</div>
<!-- Hidden checkboxes — read by processHTML() -->
<input type="checkbox" id="align-tables" checked style="display:none">
<input type="checkbox" id="remove-media" checked style="display:none">
<input type="checkbox" id="clean-noise" checked style="display:none">
<input type="checkbox" id="extract-meta" style="display:none">
<input type="checkbox" id="preserve-links" checked style="display:none">
<!-- Options — JS-driven toggle buttons -->
<div class="options-section">
<span class="options-label">Options</span>
<div class="options-strip">
<button type="button" class="opt on" data-for="align-tables" title="Align markdown table columns" onclick="toggleOpt(this)">
<div class="opt-track"><div class="opt-knob"></div></div>
<span>Align Tables</span>
</button>
<button type="button" class="opt on" data-for="remove-media" title="Remove images, videos, and media" onclick="toggleOpt(this)">
<div class="opt-track"><div class="opt-knob"></div></div>
<span>Strip Media</span>
</button>
<button type="button" class="opt on" data-for="clean-noise" title="Remove ads, navigation, and boilerplate" onclick="toggleOpt(this)">
<div class="opt-track"><div class="opt-knob"></div></div>
<span>Smart Clean</span>
</button>
<button type="button" class="opt" data-for="extract-meta" title="Extract page metadata (title, OG tags)" onclick="toggleOpt(this)">
<div class="opt-track"><div class="opt-knob"></div></div>
<span>Extract Meta</span>
</button>
<button type="button" class="opt on" data-for="preserve-links" title="Keep hyperlinks in the output" onclick="toggleOpt(this)">
<div class="opt-track"><div class="opt-knob"></div></div>
<span>Keep Links</span>
</button>
</div>
</div>
<!-- Convert Button -->
<button onclick="processHTML()" class="convert-btn" title="Convert to Markdown (Ctrl+Enter)">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<line x1="5" y1="12" x2="19" y2="12"/>
<polyline points="12 5 19 12 12 19"/>
</svg>
Convert to Markdown
<span class="convert-shortcut">Ctrl+Enter</span>
</button>
</div>
<!-- HTML Input Card -->
<div class="card card--grow">
<div class="card-head">
<div class="card-head-left">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="card-head-icon">
<polyline points="16 18 22 12 16 6"/><polyline points="8 6 2 12 8 18"/>
</svg>
<span class="card-head-title">HTML Input</span>
</div>
<div class="card-head-right">
<span id="input-char-count" class="stat-badge">0 chars</span>
<span id="input-status" class="stat-badge stat-badge--status"></span>
<button onclick="clearInput()" class="text-action" title="Clear input (Ctrl+Shift+X)">Clear</button>
</div>
</div>
<div class="card-body">
<textarea id="html-input" class="code-textarea"
placeholder="Paste HTML here, or enter a URL above and click Fetch..."></textarea>
</div>
</div>
</section>
<!-- RIGHT: Output Column -->
<section class="col col--output">
<div class="card card--grow">
<!-- Tab Bar -->
<div class="tab-bar">
<div class="tab-bar-left">
<button id="tab-btn-markdown" onclick="switchTab('markdown')" class="tab-btn active">
<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/>
<polyline points="14 2 14 8 20 8"/>
</svg>
Markdown
</button>
<button id="tab-btn-preview" onclick="switchTab('preview')" class="tab-btn">
<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"/>
<circle cx="12" cy="12" r="3"/>
</svg>
Preview
</button>
<button id="tab-btn-json" onclick="switchTab('json')" class="tab-btn">
<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<path d="M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1"/>
<path d="M16 21h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1"/>
</svg>
JSON
</button>
</div>
<div class="tab-bar-right">
<button onclick="copyToClipboard()" class="icon-action" title="Copy (Ctrl+Shift+C)">
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<rect x="9" y="9" width="13" height="13" rx="2" ry="2"/>
<path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/>
</svg>
</button>
<button onclick="downloadOutput()" class="icon-action" title="Download">
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/>
<polyline points="7 10 12 15 17 10"/>
<line x1="12" y1="15" x2="12" y2="3"/>
</svg>
</button>
</div>
</div>
<!-- Stats Row -->
<div class="stats-row">
<span class="stat-label"><span id="char-count" class="stat-value">0</span> characters</span>
</div>
<!-- Output Views -->
<div id="view-markdown" class="output-view">
<textarea id="markdown-output" readonly class="code-textarea code-textarea--output"
placeholder="Your converted Markdown will appear here..."></textarea>
</div>
<div id="view-preview" class="output-view hidden">
<div class="preview-pane prose prose-sm">
<div class="empty-state">
<svg width="48" height="48" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" class="empty-state-icon">
<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/>
<polyline points="14 2 14 8 20 8"/>
<line x1="16" y1="13" x2="8" y2="13"/>
<line x1="16" y1="17" x2="8" y2="17"/>
<polyline points="10 9 9 9 8 9"/>
</svg>
<p>Convert some HTML to see the rendered preview</p>
</div>
</div>
</div>
<div id="view-json" class="output-view hidden">
<textarea id="json-output" readonly class="code-textarea code-textarea--json"
placeholder="JSON output will appear here..."></textarea>
</div>
</div>
</section>
</main>
<!-- Toast Notification -->
<div id="toast" class="toast-wrap">
<div id="toast-content" class="toast">
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">
<polyline points="20 6 9 17 4 12"/>
</svg>
<span id="toast-message">Done</span>
</div>
</div>
<!-- Help Modal -->
<div id="help-modal" class="modal-overlay hidden">
<div class="modal" onclick="event.stopPropagation()">
<div class="modal-head">
<h2 class="modal-title">Keyboard Shortcuts</h2>
<button onclick="hideHelp()" class="modal-close" title="Close">
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/>
</svg>
</button>
</div>
<div class="modal-body">
<div class="shortcut-list">
<div class="shortcut-item">
<span>Convert HTML to Markdown</span>
<div class="shortcut-keys"><kbd>Ctrl</kbd><kbd>Enter</kbd></div>
</div>
<div class="shortcut-item">
<span>Copy output to clipboard</span>
<div class="shortcut-keys"><kbd>Ctrl</kbd><kbd>Shift</kbd><kbd>C</kbd></div>
</div>
<div class="shortcut-item">
<span>Fetch URL content</span>
<div class="shortcut-keys"><kbd>Ctrl</kbd><kbd>Shift</kbd><kbd>F</kbd></div>
</div>
<div class="shortcut-item">
<span>Clear input</span>
<div class="shortcut-keys"><kbd>Ctrl</kbd><kbd>Shift</kbd><kbd>X</kbd></div>
</div>
<div class="shortcut-item shortcut-item--last">
<span>Open this dialog</span>
<div class="shortcut-keys"><kbd>?</kbd></div>
</div>
</div>
<div class="modal-note">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<circle cx="12" cy="12" r="10"/><line x1="12" y1="16" x2="12" y2="12"/><line x1="12" y1="8" x2="12.01" y2="8"/>
</svg>
<p>URL fetching uses public CORS proxies. For production use, deploy your own proxy or a browser extension.</p>
</div>
</div>
</div>
</div>
<!-- Loading Overlay -->
<div id="loading-overlay" class="loading-overlay hidden">
<div class="loading-card">
<div class="loading-spinner"></div>
<span id="loading-text" class="loading-label">Fetching...</span>
</div>
</div>
<script src="js/app.js"></script>
</body>
</html>