diff --git a/assets/bread-card-markdown-compat-highlight-js.css b/assets/bread-card-markdown-compat-highlight-js.css
index 1ce2f09..9c61062 100644
--- a/assets/bread-card-markdown-compat-highlight-js.css
+++ b/assets/bread-card-markdown-compat-highlight-js.css
@@ -11,17 +11,8 @@
##############################################################################
******************************************************************************/
-:root {
- --bcm-color-highlight-bg: #223b5c; /* user define */
-}
-
-pre {
- background: var(--bcm-color-highlight-bg);
-}
-
.hljs,
code.hljs,
pre code.hljs {
- background: var(--bcm-color-highlight-bg);
padding: 0.2rem 1.2rem 0.6rem;
}
diff --git a/assets/bread-card-markdown.css b/assets/bread-card-markdown.css
index c58c0ac..4411295 100644
--- a/assets/bread-card-markdown.css
+++ b/assets/bread-card-markdown.css
@@ -245,3 +245,7 @@ mark {
color: var(--bcm-color-font-base-mark);
border-radius: 0.1rem;
}
+
+img {
+ max-width: 100%;
+}
diff --git a/composer.json b/composer.json
index d3ea68d..461d3f8 100644
--- a/composer.json
+++ b/composer.json
@@ -23,6 +23,7 @@
"ext-mbstring": "*",
"ext-fileinfo": "*",
"league/commonmark": ">=2.3.8",
+ "symfony/yaml": ">=4.0",
"gregwar/rst": "^1.0",
"xemlock/php-latex": "dev-master"
}
diff --git a/composer.lock b/composer.lock
index 26de57e..3b53504 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
- "content-hash": "ffafb389bb041261bde7ae336b613721",
+ "content-hash": "992b2bf6550d780081ce38b8a3010d02",
"packages": [
{
"name": "dflydev/dot-access-data",
@@ -587,6 +587,88 @@
],
"time": "2022-11-25T10:21:52+00:00"
},
+ {
+ "name": "symfony/polyfill-ctype",
+ "version": "v1.27.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/symfony/polyfill-ctype.git",
+ "reference": "5bbc823adecdae860bb64756d639ecfec17b050a"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/5bbc823adecdae860bb64756d639ecfec17b050a",
+ "reference": "5bbc823adecdae860bb64756d639ecfec17b050a",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=7.1"
+ },
+ "provide": {
+ "ext-ctype": "*"
+ },
+ "suggest": {
+ "ext-ctype": "For best performance"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-main": "1.27-dev"
+ },
+ "thanks": {
+ "name": "symfony/polyfill",
+ "url": "https://github.com/symfony/polyfill"
+ }
+ },
+ "autoload": {
+ "files": [
+ "bootstrap.php"
+ ],
+ "psr-4": {
+ "Symfony\\Polyfill\\Ctype\\": ""
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Gert de Pagter",
+ "email": "BackEndTea@gmail.com"
+ },
+ {
+ "name": "Symfony Community",
+ "homepage": "https://symfony.com/contributors"
+ }
+ ],
+ "description": "Symfony polyfill for ctype functions",
+ "homepage": "https://symfony.com",
+ "keywords": [
+ "compatibility",
+ "ctype",
+ "polyfill",
+ "portable"
+ ],
+ "support": {
+ "source": "https://github.com/symfony/polyfill-ctype/tree/v1.27.0"
+ },
+ "funding": [
+ {
+ "url": "https://symfony.com/sponsor",
+ "type": "custom"
+ },
+ {
+ "url": "https://github.com/fabpot",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2022-11-03T14:55:06+00:00"
+ },
{
"name": "symfony/polyfill-mbstring",
"version": "v1.27.0",
@@ -753,6 +835,80 @@
],
"time": "2022-11-03T14:55:06+00:00"
},
+ {
+ "name": "symfony/yaml",
+ "version": "v6.2.5",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/symfony/yaml.git",
+ "reference": "2bbfbdacc8a15574f8440c4838ce0d7bb6c86b19"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/symfony/yaml/zipball/2bbfbdacc8a15574f8440c4838ce0d7bb6c86b19",
+ "reference": "2bbfbdacc8a15574f8440c4838ce0d7bb6c86b19",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=8.1",
+ "symfony/polyfill-ctype": "^1.8"
+ },
+ "conflict": {
+ "symfony/console": "<5.4"
+ },
+ "require-dev": {
+ "symfony/console": "^5.4|^6.0"
+ },
+ "suggest": {
+ "symfony/console": "For validating YAML files using the lint command"
+ },
+ "bin": [
+ "Resources/bin/yaml-lint"
+ ],
+ "type": "library",
+ "autoload": {
+ "psr-4": {
+ "Symfony\\Component\\Yaml\\": ""
+ },
+ "exclude-from-classmap": [
+ "/Tests/"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Fabien Potencier",
+ "email": "fabien@symfony.com"
+ },
+ {
+ "name": "Symfony Community",
+ "homepage": "https://symfony.com/contributors"
+ }
+ ],
+ "description": "Loads and dumps YAML files",
+ "homepage": "https://symfony.com",
+ "support": {
+ "source": "https://github.com/symfony/yaml/tree/v6.2.5"
+ },
+ "funding": [
+ {
+ "url": "https://symfony.com/sponsor",
+ "type": "custom"
+ },
+ {
+ "url": "https://github.com/fabpot",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2023-01-10T18:53:53+00:00"
+ },
{
"name": "xemlock/php-latex",
"version": "dev-master",
diff --git a/constant.php b/constant.php
index 703a32c..33d702d 100644
--- a/constant.php
+++ b/constant.php
@@ -2,6 +2,6 @@
const APP_NAME = "ph-Bookshelf";
-const VERSION = "0.3.4";
+const VERSION = "0.4.0";
const CHANNEL = "suk-ws";
const BRANCH = "master";
diff --git a/src/Data/PageMeta.php b/src/Data/PageMeta.php
index c1bf95f..50bb544 100644
--- a/src/Data/PageMeta.php
+++ b/src/Data/PageMeta.php
@@ -2,6 +2,7 @@
namespace SukWs\Bookshelf\Data;
+use SukWs\Bookshelf\Data\SiteConfig\ConfigName;
use SukWs\Bookshelf\Element\BookContent\BookContented;
use SukWs\Bookshelf\Element\BookContent\Page;
@@ -34,15 +35,36 @@ class PageMeta {
}
public static function compatibilityOldTitlePolicy (): bool {
- if (self::getConfigurationLevelPage("compatibility.article.title.oldversion") == "true")
+ if (self::getConfigurationLevelPage(ConfigName::old_title_gen) == "true")
return true;
return false;
}
public static function highlightJsTheme (): string {
- $theme = trim(self::getConfigurationLevelPage("customization.article.codeblock.highlightjs.theme"));
+ $theme = trim(self::getConfigurationLevelPage(ConfigName::highlightjs_theme));
if (empty($theme)) return "atom-one-dark";
return $theme;
}
+ /**
+ * @return string[]
+ */
+ public static function highlightJsLanguages (): array {
+ $langDef = "";
+ {
+ $langDefList = array();
+ $langDefList[] = SiteMeta::getConfigurationLevelShelf(ConfigName::highlightjs_lang);
+ $langDefList[] = PageMeta::getConfigurationLevelBook(ConfigName::highlightjs_lang);
+ $langDefList[] = PageMeta::getConfigurationLevelPage(ConfigName::highlightjs_lang);
+ foreach ($langDefList as $langDefNode) $langDef .= $langDefNode . ";";
+ }
+ $lang = array();
+ foreach (explode(";", $langDef) as $i) {
+ $i = trim($i);
+ if ($i != "") $lang[] =$i;
+ }
+ $lang = array_unique($lang);
+ return $lang;
+ }
+
}
diff --git a/src/Data/SiteMeta.php b/src/Data/SiteMeta.php
index f5ca061..d598844 100644
--- a/src/Data/SiteMeta.php
+++ b/src/Data/SiteMeta.php
@@ -3,6 +3,7 @@
namespace SukWs\Bookshelf\Data;
use Exception;
+use SukWs\Bookshelf\Data\SiteConfig\ConfigName;
use SukWs\Bookshelf\Data\SiteConfig\RobotsPolicy;
use SukWs\Bookshelf\Element\Bookshelf;
@@ -39,37 +40,39 @@ class SiteMeta {
// "/assets/gitbook/gitbook-plugin-fontsettings/website.css",
// "/assets/gitbook-fix.css",
// "/assets/ref.css",
- (PageMeta::getConfigurationLevelPage("customization.article.codeblock.highlightjs")=="false"?
- null:"//cdnjs.cloudflare.com/ajax/libs/highlight.js/11.3.1/styles/".PageMeta::highlightJsTheme().".min.css"),
- (PageMeta::getConfigurationLevelPage("customization.article.regex.highlight")=="false")?
+ (PageMeta::getConfigurationLevelPage(ConfigName::highlightjs)=="false"?
+ null:"//cdnjs.cloudflare.com/ajax/libs/highlight.js/11.7.0/styles/".PageMeta::highlightJsTheme().".min.css"),
+ (PageMeta::getConfigurationLevelPage(ConfigName::regex_highlight)=="false")?
null:"//cdn.jsdelivr.net/gh/suk-ws/regex-colorizer@master/regex-colorizer-default.min.css",
- "/assets/bread-card-markdown.css?ver=1",
+ "/assets/bread-card-markdown.css?ver=2",
"/assets/bread-card-markdown-footnote.css?ver=1",
"/assets/bread-card-markdown-task-list.css?ver=1",
"/assets/bread-card-markdown-heading-permalink.css?ver=1",
- (PageMeta::getConfigurationLevelPage("customization.article.listing.rainbow.marker")=="true"?
+ (PageMeta::getConfigurationLevelPage(ConfigName::ext_listing_rainbow)=="true"?
"/assets/bread-card-markdown-enhanced-listing-rainbow.css?ver=1":null),
- "/assets/bread-card-markdown-compat-highlight-js.css?ver=1",
+ "/assets/bread-card-markdown-compat-highlight-js.css?ver=2",
"/assets/main.css?ver=1",
);
}
public static function getJavascriptList (): array {
- return array(
+ return array_merge(array(
// "/assets/gitbook/gitbook.js",
// "/assets/gitbook-fix.js",
// "https://cdn.jsdelivr.net/npm/marked/marked.min.js",
// "/assets/ref.js",
- (PageMeta::getConfigurationLevelPage("customization.article.codeblock.highlightjs")=="false"?
- null:"//cdnjs.cloudflare.com/ajax/libs/highlight.js/11.3.1/highlight.min.js"),
- (PageMeta::getConfigurationLevelPage("customization.article.regex.highlight")=="false"?
+ (PageMeta::getConfigurationLevelPage(ConfigName::highlightjs)=="false"?
+ null:"//cdnjs.cloudflare.com/ajax/libs/highlight.js/11.7.0/highlight.min.js"),
+ (PageMeta::getConfigurationLevelPage(ConfigName::regex_highlight)=="false"?
null:"//cdn.jsdelivr.net/gh/suk-ws/regex-colorizer@master/regex-colorizer.min.js"),
- (PageMeta::getConfigurationLevelPage("enhanced.web.web-title.rolling-title")=="true"?
+ (PageMeta::getConfigurationLevelPage(ConfigName::ext_rolling_title)=="true"?
"/assets/enhanced-rolling-title.js?ver=1":null),
- (PageMeta::getConfigurationLevelPage("customization.article.title.permalink.highlight-on-focus")=="true"?
+ (PageMeta::getConfigurationLevelPage(ConfigName::ext_title_permalink_flash)=="true"?
"/assets/bread-card-markdown-heading-permalink-highlight.js?ver=1":null),
"/assets/utils-touchscreen-event.js?ver=1",
"/assets/main.js?ver=1",
+ ),
+ self::getHighlightLanguagesJs(PageMeta::highlightJsLanguages())
);
}
@@ -95,7 +98,7 @@ class SiteMeta {
}
public static function getRobotsPolicy (): RobotsPolicy {
- return match (self::getConfigurationLevelShelf("site.robots")) {
+ return match (self::getConfigurationLevelShelf(ConfigName::robots_txt)) {
"allow", null => RobotsPolicy::allow,
"deny" => RobotsPolicy::deny,
"custom", "file" => RobotsPolicy::file,
@@ -103,4 +106,12 @@ class SiteMeta {
};
}
+ public static function getHighlightLanguagesJs (array $languages): array {
+ $links = array();
+ foreach ($languages as $lang) {
+ $links[] = "//cdnjs.cloudflare.com/ajax/libs/highlight.js/11.7.0/languages/$lang.min.js";
+ }
+ return $links;
+ }
+
}
diff --git a/src/Utils/Markdown/Markdown.php b/src/Utils/Markdown/Markdown.php
index 7bf8a34..f819414 100644
--- a/src/Utils/Markdown/Markdown.php
+++ b/src/Utils/Markdown/Markdown.php
@@ -9,6 +9,7 @@ use League\CommonMark\Extension\Autolink\AutolinkExtension;
use League\CommonMark\Extension\CommonMark\CommonMarkCoreExtension;
use League\CommonMark\Extension\DescriptionList\DescriptionListExtension;
use League\CommonMark\Extension\Footnote\FootnoteExtension;
+use League\CommonMark\Extension\FrontMatter\FrontMatterExtension;
use League\CommonMark\Extension\HeadingPermalink\HeadingPermalinkExtension;
use League\CommonMark\Extension\Strikethrough\StrikethroughExtension;
use League\CommonMark\Extension\Table\TableExtension;
@@ -48,6 +49,9 @@ class Markdown implements PageContentType {
// + heading(title) permalink # [title](#title)
$parserEnv->addExtension(new HeadingPermalinkExtension());
+ // + front matter --- title: Front Matter? ---
+ $parserEnv->addExtension(new FrontMatterExtension());
+
// from GitHub Flavor Markdown
// + autolink [https://link.to]
// + strikethrough ~~removed~~
diff --git a/template/footer.php b/template/footer.php
index 6384dd4..325ab22 100644
--- a/template/footer.php
+++ b/template/footer.php
@@ -1,3 +1,4 @@
+
@@ -13,9 +14,9 @@
diff --git a/template/header.php b/template/header.php
index a207388..880829f 100644
--- a/template/header.php
+++ b/template/header.php
@@ -1,3 +1,4 @@
+
@@ -26,7 +27,11 @@