diff --git a/mkht.php b/mkht.php
index 6c978c2..54284b6 100755
--- a/mkht.php
+++ b/mkht.php
@@ -82,18 +82,16 @@ foreach ($config['base-url'] as $url)
$feed = ob_get_clean();
foreach ($files_dates as $src_page => $last_mod) {
- $dest_page = str_replace('/src/', '/', $src_page);
-
$content = file_get_contents($src_page);
preg_match('/^# ?(?
.*)$/Dm', $content, $matches);
$title = $matches['title'] ?? NULL;
- $path_parts = pathinfo($dest_page);
+ $path_parts = pathinfo(str_replace('/src/', '/', $src_page));
$base_filepath = $path_parts['dirname'] . '/' . $path_parts['filename'];
- if (!file_exists($dest_page) OR (filemtime($src_page) > filemtime($dest_page)) OR $opt['force']) {
+ if (!file_exists($base_filepath . '.html') OR (filemtime($src_page) > filemtime($base_filepath . '.html')) OR $opt['force']) {
echo 'Compiling ' . $src_page . ' ' . date("Y-m-d H:i:s", $last_mod) . LF;
// Create parent directory if needed
@@ -109,7 +107,7 @@ foreach ($files_dates as $src_page => $last_mod) {
// Convert Gemtext to Markdown
if ($path_parts['extension'] === 'gmi') {
$content = preg_replace_callback(
- '/^=>\h*(?\H+)(:?\h+(?\H+))?$/Dm',
+ '/^=>\h*(?\S+)(:?\h+(?\V+))?$/m',
function ($matches) {
if (!str_contains($matches['addr'], ':') AND str_ends_with($matches['addr'], '.gmi'))
$matches['addr'] = substr($matches['addr'], 0, -3) . 'md';
@@ -121,7 +119,7 @@ foreach ($files_dates as $src_page => $last_mod) {
}
// Compile Markdown to HTML
- $process = proc_open('pandoc --fail-if-warnings -f markdown_phpextra-citations-native_divs-native_spans+abbreviations+hard_line_breaks+lists_without_preceding_blankline -t html --wrap none', [
+ $process = proc_open('pandoc --fail-if-warnings -f markdown_phpextra-citations-native_divs-native_spans+abbreviations+hard_line_breaks+lists_without_preceding_blankline -t html --wrap none', [
0 => ['pipe', 'r'],
1 => ['pipe', 'w'],
], $pipes);