md.viewer.php
<?php
// Markdown Viewer Page
$file = $_GET['file'] ?? null;
echo "<h2>Markdown Viewer</h2>";
if (!$file) {
echo "<div class='alert alert-warning'>No file specified.</div>";
return;
}
$path = __DIR__ . "/$file";
if (!file_exists($path)) {
echo "<div class='alert alert-danger'>File not found: $file</div>";
return;
}
$content = file_get_contents($path);
?>
<link rel="stylesheet" href="/system/css/md.styles.css">
<script type="module" src="/system/js/md.renderer.js"></script>
<div id="md-content" style="white-space: pre-wrap;">
<?= htmlspecialchars($content) ?>
</div>
<script>
import { renderMarkdown } from "/system/js/md.renderer.js";
const raw = document.getElementById("md-content").innerText;
document.getElementById("md-content").innerHTML = renderMarkdown(raw);
</script>