2021-11-22 22:53:02 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
require_once "./src/Data/PageMeta.php";
|
2023-01-24 19:08:15 +08:00
|
|
|
require_once "./src/Utils/Markdown/Parser.php";
|
2021-11-22 22:53:02 +08:00
|
|
|
|
2021-11-24 14:24:09 +08:00
|
|
|
$pageMarkdownContent = PageMeta::$page->getMarkdownContent();
|
|
|
|
|
2023-01-24 19:08:15 +08:00
|
|
|
// if the `compatibility.article.title.oldversion` is enabled
|
|
|
|
// that means the title should be auto-generated from book.xml
|
|
|
|
// but not written on page.md.
|
|
|
|
// this code will generate a title from book.xml if the start
|
|
|
|
// of the page.md is not `# Title` formatting page title.
|
2021-11-24 14:24:09 +08:00
|
|
|
if (PageMeta::compatibilityOldTitlePolicy()) {
|
|
|
|
$length = strlen($pageMarkdownContent);
|
|
|
|
for ($i=0; $i<$length; $i++) {
|
|
|
|
if (empty(trim($pageMarkdownContent[$i]))) {
|
|
|
|
continue;
|
|
|
|
} else if ($pageMarkdownContent[$i] == '#' && $pageMarkdownContent[$i+1] != '#') {
|
|
|
|
break;
|
|
|
|
}
|
2021-11-25 03:36:59 +08:00
|
|
|
echo "<!-- compatibility old-title policy triggered -->\n";
|
2021-11-24 14:24:09 +08:00
|
|
|
echo "<h1 id='phb-page-".PageMeta::$page->getId()."'>".PageMeta::$page->getName()."</h1>\n";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-24 19:08:15 +08:00
|
|
|
echo Parser::parse($pageMarkdownContent);
|