added better debug tools in strict mode

* assertion errors can now be opened in vscode
feature/strict-mode
Michael Ochmann 3 years ago
parent 4eb24000e1
commit 543112f89e
  1. 36
      index.php

@ -3,7 +3,6 @@
require __DIR__."/vendor/autoload.php"; require __DIR__."/vendor/autoload.php";
$source = file_get_contents(dirname(__FILE__)."/README.md");
echo " echo "
<style> <style>
@ -28,5 +27,36 @@ echo "
</style> </style>
"; ";
$Instance = new parkdown\Parkdown($source); $file = dirname(__FILE__)."/README.md";
echo $Instance->html(); $source = file_get_contents($file);
try {
$Instance = new parkdown\Parkdown($source, true, $file);
echo $Instance->html();
} catch (AssertionError $error) {
echo "<pre>";
$message = explode(" ", $error->getMessage());
$location = array_shift($message);
$file = explode(":", $location)[0];
if ($file === "INPUT_STRING")
echo "$location ".implode(" ", $message);
else
echo "<a href='vscode://file/".substr($location, 0, -1)."'>$location</a> ".implode(" ", $message);
$stackTrace = explode("\n", $error->getTraceAsString());
array_shift($stackTrace);
echo "<p><small>";
foreach ($stackTrace as $step) {
$step = explode(" ", $step);
array_shift($step);
$location = array_shift($step);
$location = preg_replace("/\(([0-9]+)\):/", ":\$1:", $location);
echo "<a href='vscode://file/".substr($location, 0, -1)."'>$location</a> ".implode(" ", $step)."<br>";
}
echo "</small></p>";
}
Loading…
Cancel
Save