diff --git a/mkht.php b/mkht.php
index d0179b3..5f2e757 100755
--- a/mkht.php
+++ b/mkht.php
@@ -84,9 +84,9 @@ $feed = ob_get_clean();
foreach ($files_dates as $src_page => $last_mod) {
$dest_page = str_replace('/src/', '/', $src_page);
- $page_content = file_get_contents($src_page);
+ $content = file_get_contents($src_page);
- preg_match('/^# ?(?
.*)$/Dm', $page_content, $matches);
+ preg_match('/^# ?(?.*)$/Dm', $content, $matches);
$title = $matches['title'] ?? NULL;
$path_parts = pathinfo($dest_page);
@@ -102,13 +102,13 @@ foreach ($files_dates as $src_page => $last_mod) {
// Execute PHP code
ob_start();
- eval('?>' . $page_content);
- file_put_contents($base_filepath . '.gmi', ob_get_contents());
- ob_end_clean();
+ eval('?>' . $content);
+ $content = ob_get_clean();
+ file_put_contents($base_filepath . '.gmi', $content);
// Convert Gemtext to Markdown
if ($path_parts['extension'] === 'gmi') {
- $gmilines = explode(LF, file_get_contents($base_filepath . '.gmi'));
+ $gmilines = explode(LF, $content);
foreach ($gmilines as $key => $line) {
if (str_starts_with($line, '=>')) {
@@ -124,26 +124,26 @@ foreach ($files_dates as $src_page => $last_mod) {
$gmilines[$key] = '[' . ($lnTitle[1] ?? $lnUrl[1]) . '](' . $lnUrl[1] . ')';
}
}
- file_put_contents($base_filepath . '.md', implode(LF, $gmilines));
+ $content = implode(LF, $gmilines);
+ file_put_contents($base_filepath . '.md', $content);
}
// Compile Markdown to HTML
- $markdown = file_get_contents($base_filepath . '.md');
$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);
if (is_resource($process) !== true)
exit('Can\'t spawn pandoc.' . PHP_EOL);
- fwrite($pipes[0], $markdown);
+ fwrite($pipes[0], $content);
fclose($pipes[0]);
- $pageContent = stream_get_contents($pipes[1]);
+ $content = stream_get_contents($pipes[1]);
fclose($pipes[1]);
if (proc_close($process) !== 0)
exit('pandoc failed.' . PHP_EOL);
// .md > .html for local links
- $pageContent = preg_replace('##', '', $pageContent);
+ $content = preg_replace('##', '', $content);
$relativePathToRoot = '';
for ($i = substr_count(str_replace(SITE, '', $path_parts['dirname']), '/') ; $i > 0 ; $i--)
@@ -190,7 +190,6 @@ foreach ($files_dates as $src_page => $last_mod) {
echo '' . LF;
}
-
if (file_exists(SITE . '/head.inc.html'))
echo file_get_contents(SITE . '/head.inc.html');
?>
@@ -214,26 +213,26 @@ foreach ($files_dates as $src_page => $last_mod) {
}
if ($config['center-index'] AND $path_parts['filename'] === 'index')
- echo '' . $pageContent . '
';
+ echo '' . $content . '
';
else
- echo '' . $pageContent . '';
+ echo '' . $content . '';
if (file_exists(SITE . '/end.inc.html'))
require SITE . '/end.inc.html';
echo '