I have a vault within my source tree in order to document some aspects of the project.
For this I use the to display highlighted php and js source files like in
the example below:
Here is the souveof the load.php.
<?php
/*
* ***********************************************
* used in Obsidian to embed highlighted code for
* php and js sources. Script is located in the
* root folder the project.
*
* <iframe style="border:1px solid black" width="700" height="400"
* src="http://localhost/project/load.php?s=phpriservaCoreClasses/errorHandler.php">
* </iframe>
*
* script must be able to open file gine in $_GET['s']
* **********************************************
*/
$h = $_GET['s'];
$arr = explode('.', basename($h));
if (count($arr) > 1 && $arr[1] === 'js') {
$add = "<?php // <== just a trick \r\n";
} else {
$add = '';
}
echo "<b>$h</b>";
$s = highlight_string($add . file_get_contents($h)); // will output the string