Files
MD2HTML/src/md2html.php
T
IgorMino 715a0e354b pridaná generovaná navigácia z H1–H3 s unikátnymi ID,
pridaný responzívny panel a ukladanie stavu podľa URL,
pridané verzovanie CSS a JS pomocou MD5 hashov,
aktualizovaná dokumentácia
2026-10-26 19:08:34 +01:00

31 lines
1.3 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
require dirname(__DIR__) . '/vendor/autoload.php';
$path = $_GET['file'] ?? $_SERVER['REQUEST_URI'];
$file = realpath('d:/www/' . $path);
if (!$file || !str_ends_with($file, '.md')) {
http_response_code(404);
exit('Not found');
}
$md = file_get_contents($file);
$parser = new Parsedown();
echo '<!doctype html>';
echo '<meta charset="utf-8">';
echo '<meta name="viewport" content="width=device-width, initial-scale=1">';
echo '<link rel="stylesheet" href="//localhost/md2html/src/markdown.css?h=' . md5_file(__DIR__ . '/markdown.css') . '">';
echo '<script src="//localhost/md2html/src/toc.js?h=' . md5_file(__DIR__ . '/toc.js') . '" defer></script>';
echo '<button class="md2html-toc-toggle" type="button" aria-expanded="false" aria-label="Zobraziť obsah dokumentu" hidden><span aria-hidden="true">☰</span></button>';
echo '<div class="md2html-toc-backdrop" aria-hidden="true" hidden></div>';
echo '<nav class="md2html-toc" aria-label="Obsah dokumentu" hidden>';
echo '<div class="md2html-toc-header"><strong>Obsah dokumentu</strong><button class="md2html-toc-close" type="button" aria-label="Zatvoriť obsah dokumentu">×</button></div>';
echo '<ol class="md2html-toc-list"></ol>';
echo '</nav>';
echo '<div class="md2html-document">';
echo '<div class="markdown-body">';
echo $parser->text($md);
echo '</div>';
echo '</div>';