mirror of
https://github.com/suk-ws/ph-Bookshelf.git
synced 2025-01-31 13:12:47 +08:00
Eyre_S
e8fe17b673
- 使用 composer - 声明 php8, ext-xml, ext-mbstring - 添加了 league/commonmark>=2.3.8 - 删除了 /lib 文件夹 (以及 parsedown 依赖) - 抽象化 md 解析代码同时 md 解析器换为 commonmark - 使用 commonmark 规范 + gfm - disallowed html + attributes, footnote, description list - 修改 readme
28 lines
932 B
PHP
28 lines
932 B
PHP
<?php
|
|
|
|
require_once "./src/Data/PageMeta.php";
|
|
require_once "./src/Utils/Markdown/Parser.php";
|
|
|
|
$pageMarkdownContent = PageMeta::$page->getMarkdownContent();
|
|
|
|
// 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.
|
|
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;
|
|
}
|
|
echo "<!-- compatibility old-title policy triggered -->\n";
|
|
echo "<h1 id='phb-page-".PageMeta::$page->getId()."'>".PageMeta::$page->getName()."</h1>\n";
|
|
break;
|
|
}
|
|
}
|
|
|
|
echo Parser::parse($pageMarkdownContent);
|