From 8dcd83c78d39b5ed8b22b9d82ef6255fead7db53 Mon Sep 17 00:00:00 2001 From: Eyre_S Date: Wed, 25 Jan 2023 13:03:58 +0800 Subject: [PATCH] =?UTF-8?q?.tex=20=E7=AE=80=E5=8D=95=E6=94=AF=E6=8C=81?= =?UTF-8?q?=EF=BC=8C=E6=B5=8B=E8=AF=95=E6=80=A7=E8=B4=A8=E7=9A=84=E8=B5=84?= =?UTF-8?q?=E6=BA=90(=E5=9B=BE=E7=89=87)=E6=96=87=E4=BB=B6=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- composer.json | 3 ++- constant.php | 2 +- index.php | 18 ++++++++++++++++-- src/Utils/HTML/HTML.php | 19 +++++++++++++++++++ src/Utils/LaTeX/LaTeX.php | 24 ++++++++++++++++++++++++ template/raw-article.php | 4 ++++ 6 files changed, 66 insertions(+), 4 deletions(-) create mode 100644 src/Utils/HTML/HTML.php create mode 100644 src/Utils/LaTeX/LaTeX.php diff --git a/composer.json b/composer.json index 3079052..b4427db 100644 --- a/composer.json +++ b/composer.json @@ -23,6 +23,7 @@ "ext-mbstring": "*", "ext-fileinfo": "*", "league/commonmark": ">=2.3.8", - "gregwar/rst": "^1.0" + "gregwar/rst": "^1.0", + "xemlock/php-latex": "dev-master" } } diff --git a/constant.php b/constant.php index 7c0c39c..69b7d32 100644 --- a/constant.php +++ b/constant.php @@ -2,6 +2,6 @@ const APP_NAME = "ph-Bookshelf"; -const VERSION = "0.3.2"; +const VERSION = "0.3.3"; const CHANNEL = "suk-ws"; const BRANCH = "master"; diff --git a/index.php b/index.php index c036fe4..5abaa4f 100644 --- a/index.php +++ b/index.php @@ -52,8 +52,22 @@ try { // 页面寻找失败,寻找资源文件 - if (!is_file($resLoc = "./data/%assets/$req")) { // 全局文件夹的资源文件 - throw $e; + if ( // 搜索全局资源文件夹的指定文件 + file_exists($resLoc = "./data/%assets/$req") + ) {} else if ( // 搜索原始路径上的文件 + file_exists($resLoc = "./data/$req") + ) {} else if ( // 搜索可能存在的书籍资源文件夹中的指定文件 + sizeof($uri) > 1 && ($resBook = (SiteMeta::getBookshelf()->getBook($uri[0]))) != null && + file_exists($resLoc = "./data/{$resBook->getId()}/%assets/$uri[1]") + ) {} else if ( // 上面的 %root 兼容 + sizeof($uri) > 1 && ($resBook = $uri[0]) == "%root" && + file_exists($resLoc = "./data/$resBook/%assets/$uri[1]") + ) {} else if ( // 搜索以root书为根目录的原始路径上的文件 + file_exists($resLoc = "./data/%root/$req") + ) {} else if ( // 搜索root书中的书籍资源文件夹中的文件 + file_exists($resLoc = "./data/%root/%assets/$req") + ) {} else { + throw $e; // 找不到资源文件 } PageParse::outputBinaryFile($resLoc); diff --git a/src/Utils/HTML/HTML.php b/src/Utils/HTML/HTML.php new file mode 100644 index 0000000..b38f538 --- /dev/null +++ b/src/Utils/HTML/HTML.php @@ -0,0 +1,19 @@ +render((new PhpLatex_Parser())->parse($raw)); + } + +} \ No newline at end of file diff --git a/template/raw-article.php b/template/raw-article.php index 7cfd870..87fa456 100644 --- a/template/raw-article.php +++ b/template/raw-article.php @@ -1,6 +1,8 @@ hasContent(Markd } $parsers = array( + new HTML(), new Markdown(), + new LaTeX(), new ReST() );