';
if (!empty($anRetMessage['error'])) {
$retHtmlString .= '
';
$retHtmlString .= 'ERROR:
';
$retHtmlString .= $anRetMessage['error'];
$retHtmlString .= '
';
}
if (!empty($anRetMessage['warning'])) {
$retHtmlString .= '
';
$retHtmlString .= 'WARNING:
';
$retHtmlString .= $anRetMessage['warning'];
$retHtmlString .= '
';
}
if (!empty($anRetMessage['notice'])) {
$retHtmlString .= '
';
$retHtmlString .= 'Info:
';
$retHtmlString .= $anRetMessage['notice'];
$retHtmlString .= '
';
}
if (!empty($anRetMessage['success'])) {
$retHtmlString .= '
';
$retHtmlString .= 'SUCCESS:
';
$retHtmlString .= $anRetMessage['success'];
$retHtmlString .= '
';
}
$retHtmlString .= '
';
}
return $retHtmlString;
}
/** load a MarkdownFile with yaml header
*
* @param string $fileName filename of the markdown file
* @return array associative array('yaml'=>array(..), 'mdText'=>string) containing the yamlHeader as associative array and the markdown text as string
*/
function loadMarkdownFile($fileName)
{
// load the whole file
$fileText = file_get_contents($fileName);
// split at '---' to get ((),yamls,array)
$fileParts = preg_split('/[\n]*[-]{3}[\n]/', $fileText, 3);
// not all mdFiles have a yamlHeader, so the mdText can be at different indices
$yaml = [];
$mdText = '';
switch(count($fileParts)) {
case 1:{
$mdText = $fileParts[0];
break;
}
case 3:{
$yaml = Spyc::YAMLLoadString($fileParts[1]);
$mdText = $fileParts[2];
break;
}
default:{
$mdText = $fileText;
}
}
// get a title, if none is in the markdown
if (!array_key_exists('title', $yaml)) {
// find the first heading, set it as header and remove it from the markdown
if (preg_match('/^#(.*)$/m', $mdText, $matches)) {
$yaml['title'] = $matches[1];
$mdText = preg_replace('/^#(.*)$/m', '', $mdText, 1);
} else {
// fallback for the title, if not even one heading is found
$yaml['title'] = '