From b98775d61c5f850a5ee4f89b594a6711d5ce7321 Mon Sep 17 00:00:00 2001 From: daudix Date: Sun, 29 Sep 2024 02:48:21 +0300 Subject: [PATCH] Allow enabling KaTeX per page/section (fixes #89) --- CHANGELOG.md | 2 ++ config.toml | 3 ++- content/demo/index.md | 1 + templates/partials/head.html | 22 +++++++++++----------- 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d26bb0c..da62afa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed +- Allow enabling KaTeX per page/section. +- Improve the logic of inclusion feeds in ``. - Restly the heading anchors. ## Fixed diff --git a/config.toml b/config.toml index 1d4ee95..ffe702f 100644 --- a/config.toml +++ b/config.toml @@ -127,7 +127,8 @@ show_read_time = true show_share_button = true # Whether to enable the KaTeX library for rendering LaTeX. # Note: This will make your page significantly heavier. -katex = true +# Instead, consider enabling it per page/section. +# katex = true # Display outlines around all elements for debugging purposes # debug_layout = true diff --git a/content/demo/index.md b/content/demo/index.md index 7dbb046..44e875e 100644 --- a/content/demo/index.md +++ b/content/demo/index.md @@ -1,6 +1,7 @@ +++ title = "Demo Page" [extra] +katex = true archive = "This page is in fact not archived. It is only here to demonstrate the archival statement." trigger = "This page contains blackjack and hookers, and bad jokes such as this one." disclaimer = """ diff --git a/templates/partials/head.html b/templates/partials/head.html index ff3d697..c9cbff6 100644 --- a/templates/partials/head.html +++ b/templates/partials/head.html @@ -10,15 +10,6 @@ {% include "partials/title.html" %} - {%- if config.markdown.highlight_code and config.markdown.highlight_theme == "css" %} - {%- if config.markdown.highlight_themes_css | length > 0 %} - - - {%- else %} - - {%- endif %} - {%- endif %} - {%- if config.extra.comments %} {%- endif %} @@ -45,7 +36,7 @@ {%- set styles = styles | concat(with=["fonts.css"]) %} {%- endif %} - {%- if config.extra.katex %} + {%- if page.extra.katex or section.extra.katex or config.extra.katex %} {%- set styles = styles | concat(with=["katex.css"]) %} {%- endif %} @@ -63,6 +54,15 @@ {%- endfor %} + {%- if config.markdown.highlight_code and config.markdown.highlight_theme == "css" %} + {%- if config.markdown.highlight_themes_css | length > 0 %} + + + {%- else %} + + {%- endif %} + {%- endif %} + {%- if config.extra.show_copy_button %} {%- include "partials/copy_button.html" %} {%- endif %} @@ -73,7 +73,7 @@ {%- set scripts = scripts | concat(with=["count.js"]) %} {%- endif %} - {%- if config.extra.katex %} + {%- if page.extra.katex or section.extra.katex or config.extra.katex %} {%- set scripts = scripts | concat(with=["katex.min.js", "auto-render.min.js"]) %}