42 lines
1.5 KiB
HTML
42 lines
1.5 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="es">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<title>Visor Markdown</title>
|
|
<style>
|
|
body { font-family: sans-serif; max-width: 800px; margin: 0 auto; padding: 20px; line-height: 1.6; }
|
|
img { max-width: 100%; }
|
|
pre { background: #f4f4f4; padding: 10px; border-radius: 5px; overflow-x: auto; }
|
|
/* Puedes añadir aquí CSS para que se vea como GitHub o tu estilo preferido */
|
|
</style>
|
|
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
|
|
</head>
|
|
<body>
|
|
<div id="content">Cargando documento...</div>
|
|
|
|
<script>
|
|
// 1. Detectar qué archivo .md se pidió (viene en la URL)
|
|
const urlParams = new URLSearchParams(window.location.search);
|
|
const file = urlParams.get('file');
|
|
|
|
if (file) {
|
|
// 2. Descargar el archivo .md
|
|
fetch(file)
|
|
.then(response => {
|
|
if (!response.ok) throw new Error("No se encontró el archivo.");
|
|
return response.text();
|
|
})
|
|
.then(text => {
|
|
// 3. Convertir Markdown a HTML y mostrarlo
|
|
document.getElementById('content').innerHTML = marked.parse(text);
|
|
})
|
|
.catch(err => {
|
|
document.getElementById('content').innerHTML = "Error: " + err.message;
|
|
});
|
|
} else {
|
|
document.getElementById('content').innerHTML = "No se ha especificado ningún archivo.";
|
|
}
|
|
</script>
|
|
</body>
|
|
</html>
|