Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -223,6 +223,13 @@ def convert_endpoint():
|
|
| 223 |
"load-error-handling": "ignore",
|
| 224 |
"load-media-error-handling": "ignore"
|
| 225 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 226 |
|
| 227 |
if data.get('download', False):
|
| 228 |
if data.get('download_type') == 'html':
|
|
@@ -362,6 +369,7 @@ def index():
|
|
| 362 |
}
|
| 363 |
async function process(action, type = null) {
|
| 364 |
const btn = document.getElementById('gen-btn');
|
|
|
|
| 365 |
let md = "";
|
| 366 |
const checks = document.querySelectorAll('.c-check');
|
| 367 |
let hasSelection = false;
|
|
@@ -379,9 +387,10 @@ def index():
|
|
| 379 |
|
| 380 |
if(!hasSelection) md = document.getElementById('md-input').value;
|
| 381 |
const payload = {
|
| 382 |
-
|
| 383 |
-
|
| 384 |
-
|
|
|
|
| 385 |
styles: {
|
| 386 |
font_family: document.getElementById('f_family').value,
|
| 387 |
font_size: document.getElementById('f_size').value,
|
|
|
|
| 223 |
"load-error-handling": "ignore",
|
| 224 |
"load-media-error-handling": "ignore"
|
| 225 |
}
|
| 226 |
+
if data.get('current_html') and data.get('current_html').strip():
|
| 227 |
+
# We wrap it in the necessary boilerplate if it's just the inner content
|
| 228 |
+
image_html = f"<!DOCTYPE html><html><head><meta charset='UTF-8'></head><body>{data['current_html']}</body></html>"
|
| 229 |
+
else:
|
| 230 |
+
image_html = build_full_html(data.get('markdown_text', ''), data.get('styles', {}), for_image=True)
|
| 231 |
+
|
| 232 |
+
preview_html = build_full_html(data.get('markdown_text', ''), data.get('styles', {}), for_image=False)
|
| 233 |
|
| 234 |
if data.get('download', False):
|
| 235 |
if data.get('download_type') == 'html':
|
|
|
|
| 369 |
}
|
| 370 |
async function process(action, type = null) {
|
| 371 |
const btn = document.getElementById('gen-btn');
|
| 372 |
+
const htmlPreviewContent = document.getElementById('html-prev').innerHTML
|
| 373 |
let md = "";
|
| 374 |
const checks = document.querySelectorAll('.c-check');
|
| 375 |
let hasSelection = false;
|
|
|
|
| 387 |
|
| 388 |
if(!hasSelection) md = document.getElementById('md-input').value;
|
| 389 |
const payload = {
|
| 390 |
+
markdown_text: md,
|
| 391 |
+
current_html: htmlPreviewContent,
|
| 392 |
+
download: action === 'download',
|
| 393 |
+
download_type: type,
|
| 394 |
styles: {
|
| 395 |
font_family: document.getElementById('f_family').value,
|
| 396 |
font_size: document.getElementById('f_size').value,
|