diff --git a/mkht.php b/mkht.php index 3be815c..fe74ed0 100755 --- a/mkht.php +++ b/mkht.php @@ -23,12 +23,6 @@ else if (file_exists(SITE . "/config.ini")) $config = parse_ini_file(SITE . "/config.ini"); -if (!isset($config['trueBlack'])) - $config['trueBlack'] = false; - -if (!isset($config['siteTitle'])) - $config['siteTitle'] = "Site"; - if (!isset($config['css'])) $config['css'] = true; @@ -52,18 +46,11 @@ require ROOT . "/less.php/lib/Less/Autoloader.php"; Less_Autoloader::register(); $colorScheme = array( - "darkColor" => "#2a2a2a", - "darkerColor" => "#222222", + "darkColor" => "black", "lightColor" => "white", - "lightlessColor" => "#eeeeee", "mainColor" => "red", ); -if ($config['trueBlack']) { - $colorScheme['darkColor'] = "#000000"; - $colorScheme['darkerColor'] = "#000000"; -} - $options = array( 'cache_dir' => SITE . '/css', 'compress' => true, @@ -114,21 +101,11 @@ foreach ($pages as $page) { if ($pathParts['extension'] === "gmi") { $gmilines = explode("\n", file_get_contents($pathParts['dirname'] . "/" . $pathParts['basename'])); - if (substr($gmilines[0], 0, 2) === "# ") - $title = substr($gmilines[0], 2); - else - $title = NULL; - foreach ($gmilines as $key => $line) { if (substr($line, 0, 2) === "=>") { preg_match("/=> +(.[^ ]+)/", $line, $lnUrl); preg_match("/=> +.[^ ]+ +(.+)/", $line, $lnTitle); - // Escape Markdown special characters - $mdSpecial = array("[", "]", "(", ")"); - $htmlEntities = array("[", "]", "(", ")"); - $lnUrl[1] = str_replace($mdSpecial, $htmlEntities, $lnUrl[1]); - $urlPathParts = pathinfo(parse_url($lnUrl[1], PHP_URL_PATH)); // .gmi > .md for local links @@ -136,7 +113,6 @@ foreach ($pages as $page) { $lnUrl[1] = $urlPathParts['dirname'] . "/" . $urlPathParts['filename'] . ".md"; if (isset($lnTitle[1])) { - $lnTitle[1] = str_replace($mdSpecial, $htmlEntities, $lnTitle[1]); $gmilines[$key] = "[" . $lnTitle[1] . "](" . $lnUrl[1] . ")"; } else { $gmilines[$key] = "[" . $lnUrl[1] . "](" . $lnUrl[1] . ")"; @@ -152,13 +128,18 @@ foreach ($pages as $page) { // Compile Markdown to HTML with Parsedown + $markdown = file_get_contents($pathParts['dirname'] . "/" . $pathParts['filename'] . ".md"); + if (preg_match("/# (.*)\\n/", $markdown, $matches)) // If a main heading is found + $title = $matches[1]; // Then it will be the HTML page