From fdbc6ed8f3ba1b7a302a9f90594e46ead3ae27c7 Mon Sep 17 00:00:00 2001 From: Eyre_S Date: Tue, 23 Nov 2021 12:11:26 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BD=BF=E6=AD=A3=E6=96=87=E4=B8=8D=E5=86=8D?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E8=BE=93=E5=87=BA=E4=B8=BB=E6=A0=87=E9=A2=98?= =?UTF-8?q?=EF=BC=8C=E4=BD=BFxml=E8=A7=A3=E6=9E=90=E5=99=A8=E5=85=81?= =?UTF-8?q?=E8=AE=B8=E6=B3=A8=E9=87=8A=EF=BC=8C=E4=BD=BF=20#text=20?= =?UTF-8?q?=E4=BB=85=E5=9C=A8=E6=B2=A1=E6=9C=89=E5=AD=97=E7=AC=A6=E6=97=B6?= =?UTF-8?q?=E8=A2=AB=E5=BF=BD=E7=95=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- constant.php | 2 +- src/Element/BookCollection.php | 4 +++- src/Element/BookContent/Chapter.php | 4 +++- src/Element/BookContent/Page.php | 1 - src/Element/Bookshelf.php | 4 +++- src/Element/LinkCollection.php | 4 +++- template/raw-article.php | 2 +- 7 files changed, 14 insertions(+), 7 deletions(-) diff --git a/constant.php b/constant.php index 421eed3..6a327b0 100644 --- a/constant.php +++ b/constant.php @@ -2,6 +2,6 @@ const APP_NAME = "ph-Bookshelf"; -const VERSION = "0.3.0.6"; +const VERSION = "0.3.0.7"; const CHANNEL = "suk-ws"; const BRANCH = "master"; diff --git a/src/Element/BookCollection.php b/src/Element/BookCollection.php index 50ab88a..74b03f9 100644 --- a/src/Element/BookCollection.php +++ b/src/Element/BookCollection.php @@ -44,8 +44,10 @@ class BookCollection { case "Collection": array_push($node->array, BookCollection::parse($child, $node)); break; - case "#text": + case "#comment": break; + case "#text": + if (empty(trim($child->nodeValue))) break; default: throw new Exception("Unsupported element type \"$child->nodeName\" in BookCollection named \"$name\""); } diff --git a/src/Element/BookContent/Chapter.php b/src/Element/BookContent/Chapter.php index 0210313..8029230 100644 --- a/src/Element/BookContent/Chapter.php +++ b/src/Element/BookContent/Chapter.php @@ -37,8 +37,10 @@ class Chapter { case "Chapter": array_push($node->childs, self::parse($child, $node)); break; - case "#text": + case "#comment": break; + case "#text": + if (empty(trim($child->nodeValue))) break; default: throw new Exception("Unsupported element type \"$child->nodeName\" in Chapter \"$node->name\""); } diff --git a/src/Element/BookContent/Page.php b/src/Element/BookContent/Page.php index 9c79f9a..ee08a42 100644 --- a/src/Element/BookContent/Page.php +++ b/src/Element/BookContent/Page.php @@ -38,7 +38,6 @@ class Page { for ($child = $xmlData->firstChild;$child != null ; $child = $child->nextSibling) { switch ($child->nodeName) { case "#text": - break; default: throw new Exception("Unsupported element type \"$child->nodeName\" in Page with id $id"); } diff --git a/src/Element/Bookshelf.php b/src/Element/Bookshelf.php index cf78aa0..2d86397 100644 --- a/src/Element/Bookshelf.php +++ b/src/Element/Bookshelf.php @@ -42,8 +42,10 @@ class Bookshelf { case "rootBook": $return->rootBook = BookContented::parse($rc); break; - case "#text": + case "#comment": break; + case "#text": + if (empty(trim($rc->nodeValue))) break; default: throw new Exception("Unsupported element type \"$rc->nodeName\" in root child of Bookshelf"); } diff --git a/src/Element/LinkCollection.php b/src/Element/LinkCollection.php index 08ff67c..11c3c50 100644 --- a/src/Element/LinkCollection.php +++ b/src/Element/LinkCollection.php @@ -43,8 +43,10 @@ class LinkCollection { case "Collection": array_push($node->array, LinkCollection::parse($child, $node)); break; - case "#text": + case "#comment": break; + case "#text": + if (empty(trim($child->nodeValue))) break; default: throw new Exception("Unsupported element type \"$child->nodeName\" in LinkCollection named \"$name\""); } diff --git a/template/raw-article.php b/template/raw-article.php index 4a0e86e..47c17cf 100644 --- a/template/raw-article.php +++ b/template/raw-article.php @@ -8,5 +8,5 @@ $parser = new ParsedownExtend(); $parser->setMarkupEscaped(false); $parser->setSafeMode(false); -echo "

".PageMeta::$page->getName()."

\n"; +//echo "

".PageMeta::$page->getName()."

\n"; echo $parser->text(PageMeta::$page->getMarkdownContent());