add debug.php zur Überprüfung / Logging von import, yaml-mapping, export
This commit is contained in:
parent
10be39ae5f
commit
51573e2fe7
1 changed files with 49 additions and 0 deletions
49
debug.php
Normal file
49
debug.php
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
<?php
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', 1);
|
||||
|
||||
// Diese Datei dient zur Überprüfung des Markdown-Parsings und der Fehlerbehandlung
|
||||
|
||||
// Funktion zum Laden des Markdown-Inhalts von einer URL
|
||||
function fetch_markdown($url) {
|
||||
$content = file_get_contents($url);
|
||||
if ($content === false) {
|
||||
throw new Exception("Fehler beim Laden der URL: $url");
|
||||
}
|
||||
return $content;
|
||||
}
|
||||
|
||||
// Funktion zum Parsen des Markdown-Inhalts
|
||||
function parse_markdown($markdown) {
|
||||
if (preg_match('/^---\s*(.*?)\s*---\s*(.*)$/s', $markdown, $matches)) {
|
||||
$yaml_raw = $matches[1];
|
||||
$content_md = $matches[2];
|
||||
|
||||
require_once 'lib/spyc.php';
|
||||
require_once 'lib/Parsedown.php';
|
||||
|
||||
$yaml = Spyc::YAMLLoadString($yaml_raw);
|
||||
$html = (new Parsedown())->text($content_md);
|
||||
return [$yaml, $html];
|
||||
} else {
|
||||
throw new Exception("YAML-Header im Markdown nicht gefunden.");
|
||||
}
|
||||
}
|
||||
|
||||
// Hauptlogik
|
||||
try {
|
||||
$url = 'https://git.rpi-virtuell.de/Comenius-Institut/FOERBICO/raw/branch/main/Website/content/posts/2025-02-25-KLT-M%C3%BCnster/index.md';
|
||||
echo "Lade Markdown von: $url\n\n";
|
||||
$markdown = fetch_markdown($url);
|
||||
echo "Markdown-Inhalt:\n" . $markdown . "\n\n";
|
||||
|
||||
list($yaml, $html) = parse_markdown($markdown);
|
||||
|
||||
echo "--- YAML-Header als Array ---\n";
|
||||
print_r($yaml);
|
||||
echo "\n--- Generiertes HTML ---\n";
|
||||
echo $html . "\n";
|
||||
|
||||
} catch (Exception $e) {
|
||||
echo "Fehler: " . $e->getMessage();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue