Update book-to-static.php

Added the HTML to not show random Unicode characters 
Added customizable css
This commit is contained in:
2024-03-30 17:08:41 +11:00
parent b57e583acd
commit fa973917f2

View File

@@ -7,6 +7,7 @@
$apiUrl = getenv('BS_URL') ?: ''; $apiUrl = getenv('BS_URL') ?: '';
$clientId = getenv('BS_TOKEN_ID') ?: ''; $clientId = getenv('BS_TOKEN_ID') ?: '';
$clientSecret = getenv('BS_TOKEN_SECRET') ?: ''; $clientSecret = getenv('BS_TOKEN_SECRET') ?: '';
$htmlCss = getenv('BS_CSS_FILE') ?: '';
// Output Folder // Output Folder
// Can be provided as a arguments when calling the script // Can be provided as a arguments when calling the script
@@ -132,7 +133,8 @@ function getImageFile(string $url): string {
* Get the HTML representation of a book. * Get the HTML representation of a book.
*/ */
function getBookHtmlOutput(array $book, array $chapters, array $pages): string { function getBookHtmlOutput(array $book, array $chapters, array $pages): string {
$content = "<html><link rel='stylesheet' href='markdown.css'><head></head><body>"; global $htmlCss;
$content = "<html><link rel='stylesheet' href='{$htmlCss}'><head></head><body>";
$content .= "<h1>{$book['name']}</h1>"; $content .= "<h1>{$book['name']}</h1>";
$content .= "<p>{$book['description']}</p>"; $content .= "<p>{$book['description']}</p>";
$content .= "<hr>"; $content .= "<hr>";
@@ -157,7 +159,8 @@ function getBookHtmlOutput(array $book, array $chapters, array $pages): string {
* Get the HTML representation of a chapter. * Get the HTML representation of a chapter.
*/ */
function getChapterHtmlOutput(array $chapter, array $pages): string { function getChapterHtmlOutput(array $chapter, array $pages): string {
$content = "<html><link rel='stylesheet' href='markdown.css'><head></head><body>"; global $htmlCss;
$content = "<html><link rel='stylesheet' href='{$htmlCss}'><head></head><body>";
$content .= "<p><a href='./index.html'>Back to book</a></p>"; $content .= "<p><a href='./index.html'>Back to book</a></p>";
$content .= "<h1>{$chapter['name']}</h1>"; $content .= "<h1>{$chapter['name']}</h1>";
$content .= "<p>{$chapter['description']}</p>"; $content .= "<p>{$chapter['description']}</p>";
@@ -176,7 +179,8 @@ function getChapterHtmlOutput(array $chapter, array $pages): string {
* Get the HTML representation of a page. * Get the HTML representation of a page.
*/ */
function getPageHtmlOutput(array $page, ?array $parentChapter): string { function getPageHtmlOutput(array $page, ?array $parentChapter): string {
$content = "<html><link rel='stylesheet' href='markdown.css'><head></head><body>"; global $htmlCss;
$content = "<html><link rel='stylesheet' href='{$htmlCss}'><head></head><body>";
if (is_null($parentChapter)) { if (is_null($parentChapter)) {
$content .= "<p><a href='./index.html'>Back to book</a></p>"; $content .= "<p><a href='./index.html'>Back to book</a></p>";
} else { } else {