1
0
mirror of https://github.com/suk-ws/ph-Bookshelf.git synced 2024-12-05 01:16:53 +08:00

使正文不再自动输出主标题,使xml解析器允许注释,使 #text 仅在没有字符时被忽略

This commit is contained in:
A.C.Sukazyo Eyre 2021-11-23 12:11:26 +08:00
parent 6a56ee1730
commit fdbc6ed8f3
Signed by: Eyre_S
GPG Key ID: EFB47D98FE082FAD
7 changed files with 14 additions and 7 deletions

View File

@ -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";

View File

@ -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\"");
}

View File

@ -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\"");
}

View File

@ -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");
}

View File

@ -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");
}

View File

@ -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\"");
}

View File

@ -8,5 +8,5 @@ $parser = new ParsedownExtend();
$parser->setMarkupEscaped(false);
$parser->setSafeMode(false);
echo "<h1 id='phb-page-".PageMeta::$page->getId()."'>".PageMeta::$page->getName()."</h1>\n";
//echo "<h1 id='phb-page-".PageMeta::$page->getId()."'>".PageMeta::$page->getName()."</h1>\n";
echo $parser->text(PageMeta::$page->getMarkdownContent());