From 36168d37c495d884f5eec0b0242f91a6fc11197a Mon Sep 17 00:00:00 2001 From: Groupr Date: Tue, 11 Nov 2025 04:08:32 +0000 Subject: [PATCH 01/13] Update __init__.py Renamed add_mathjax() to add_katex() request method. Updated to reference namespace.katex instead of namespace.mathjax. --- remarkbox/__init__.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/remarkbox/__init__.py b/remarkbox/__init__.py index 863097f..a005a2a 100644 --- a/remarkbox/__init__.py +++ b/remarkbox/__init__.py @@ -524,8 +524,8 @@ def main(global_config, **settings): def add_node_order(request): return request.params.get("order", request.namespace.node_order) - def add_mathjax(request): - return "true" if request.namespace.mathjax else "false" + def add_katex(request): + return "true" if request.namespace.katex else "false" def add_theme_mode(request): """ @@ -604,7 +604,7 @@ def main(global_config, **settings): config.add_request_method(add_page_size, "page_size", reify=True) config.add_request_method(add_page_offset, "page_offset", reify=True) config.add_request_method(add_node_order, "node_order", reify=True) - config.add_request_method(add_mathjax, "mathjax", reify=True) + config.add_request_method(add_katex, "katex", reify=True) config.add_request_method(add_theme_mode, "theme_mode", reify=True) # all of the web application routes. -- 2.49.1 From ca93bd16ae72641e63e42c3df44ae89b4dd86d5d Mon Sep 17 00:00:00 2001 From: Groupr Date: Tue, 11 Nov 2025 04:10:20 +0000 Subject: [PATCH 02/13] Update javascript-includes.j2 Replaced MathJax CDN with KaTeX CDN. Now loads KaTeX CSS, JS, and auto-render extension from jsdelivr. Added auto-render configuration with $$ and $ delimiters. --- .../templates/snippets/javascript-includes.j2 | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/remarkbox/templates/snippets/javascript-includes.j2 b/remarkbox/templates/snippets/javascript-includes.j2 index 4dd19bb..b42b5a7 100644 --- a/remarkbox/templates/snippets/javascript-includes.j2 +++ b/remarkbox/templates/snippets/javascript-includes.j2 @@ -17,13 +17,18 @@ gtag('config', '{{ request.namespace.google_analytics_id }}'); {%- endif %} -{% if request.namespace and request.namespace.mathjax %} - - + + {%- endif %} {%- include 'google-analytics.j2' %} -- 2.49.1 From b07a2ebe888157a60ca63892f17029e3a74d9122 Mon Sep 17 00:00:00 2001 From: Groupr Date: Tue, 11 Nov 2025 04:12:51 +0000 Subject: [PATCH 03/13] Update custom.js Updated previewAjax() and sendPreview() functions to use katex parameter instead of mathjax. Replaced MathJax.Hub.Queue() call with KaTeXrenderMathInElement() for live preview rendering. --- remarkbox/static/js/custom.js | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/remarkbox/static/js/custom.js b/remarkbox/static/js/custom.js index ab28d8a..51b6e2b 100644 --- a/remarkbox/static/js/custom.js +++ b/remarkbox/static/js/custom.js @@ -2,7 +2,7 @@ // previewTimer must live outside the functions. var previewTimer = null; -function previewAjax(textarea, div, show_raw = false, mathjax = false){ +function previewAjax(textarea, div, show_raw = false, katex = false){ // set div to raw textarea while waiting for remote Markdown rendering. if (show_raw) { // bust HTML tags like ', clean_html - ) + self.assertTrue(cleaner.katex) - # test mathjax disabled. - namespace.mathjax = False + # test katex disabled. + namespace.katex = False cleaner = make_cleaner_from_namespace(namespace) - self.assertFalse(cleaner.mathjax) - clean_html = clean_raw_html(raw_html, cleaner) - self.assertNotIn( - '', clean_html - ) + self.assertFalse(cleaner.katex) def test_link_protection_enabled(self): raw_html = markdown_to_raw_html(SAMPLE_MARKDOWN) -- 2.49.1 From f5ab803fd38ac6f6a8ad0d8a48bd4ac817cf91dc Mon Sep 17 00:00:00 2001 From: Groupr Date: Tue, 11 Nov 2025 04:38:23 +0000 Subject: [PATCH 12/13] Update test_models.py Updated all test methods to use namespace.katex instead of namespace.mathjax in test_namespace_production_custom_settings(), test_namespace_development_custom_settings(), and test_namespace_simulate_expired_subscription(). --- remarkbox/tests/test_models.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/remarkbox/tests/test_models.py b/remarkbox/tests/test_models.py index b5ffda9..2ee6acd 100644 --- a/remarkbox/tests/test_models.py +++ b/remarkbox/tests/test_models.py @@ -138,20 +138,20 @@ class TestNamespace(unittest.TestCase): self.namespace.subscription_type = "production" self.namespace.link_protection = True self.namespace.hide_powered_by = True - self.namespace.mathjax = True + self.namespace.katex = True self.assertTrue(self.namespace.link_protection) self.assertTrue(self.namespace.hide_powered_by) - self.assertTrue(self.namespace.mathjax) + self.assertTrue(self.namespace.katex) self.assertFalse(self.namespace.memoized_attr_protection) def test_namespace_development_custom_settings(self): self.namespace.subscription_type = "development" self.namespace.link_protection = True self.namespace.hide_powered_by = True - self.namespace.mathjax = True + self.namespace.katex = True self.assertFalse(self.namespace.link_protection) self.assertFalse(self.namespace.hide_powered_by) - self.assertFalse(self.namespace.mathjax) + self.assertFalse(self.namespace.katex) self.assertTrue(self.namespace.memoized_attr_protection) def test_namespace_simulate_expired_subscription(self): @@ -159,10 +159,10 @@ class TestNamespace(unittest.TestCase): self.namespace.subscription_type = "production" self.namespace.link_protection = True self.namespace.hide_powered_by = True - self.namespace.mathjax = True + self.namespace.katex = True self.assertTrue(self.namespace.link_protection) self.assertTrue(self.namespace.hide_powered_by) - self.assertTrue(self.namespace.mathjax) + self.assertTrue(self.namespace.katex) # next the namespace subscription expires with custom settings. self.namespace.subscription_type = "development" @@ -170,7 +170,7 @@ class TestNamespace(unittest.TestCase): self.assertTrue(self.namespace.memoized_attr_protection) self.assertFalse(self.namespace.link_protection) self.assertFalse(self.namespace.hide_powered_by) - self.assertFalse(self.namespace.mathjax) + self.assertFalse(self.namespace.katex) # finally the namespace subscription is renewed with custom settings. self.namespace.subscription_type = "production" @@ -178,7 +178,7 @@ class TestNamespace(unittest.TestCase): self.assertFalse(self.namespace.memoized_attr_protection) self.assertTrue(self.namespace.link_protection) self.assertTrue(self.namespace.hide_powered_by) - self.assertTrue(self.namespace.mathjax) + self.assertTrue(self.namespace.katex) class TestNamespaceRequest(unittest.TestCase): -- 2.49.1 From f408487224e50f9a46138a745c69005405a87f24 Mon Sep 17 00:00:00 2001 From: Groupr Date: Tue, 11 Nov 2025 04:40:41 +0000 Subject: [PATCH 13/13] Upload New File --- .../7ad8508e50de_rename_mathjax_to_katex.py | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 remarkbox/scripts/alembic/versions/7ad8508e50de_rename_mathjax_to_katex.py diff --git a/remarkbox/scripts/alembic/versions/7ad8508e50de_rename_mathjax_to_katex.py b/remarkbox/scripts/alembic/versions/7ad8508e50de_rename_mathjax_to_katex.py new file mode 100644 index 0000000..d90c383 --- /dev/null +++ b/remarkbox/scripts/alembic/versions/7ad8508e50de_rename_mathjax_to_katex.py @@ -0,0 +1,24 @@ +"""Rename mathjax column to katex in rb_namespace + +Revision ID: 7ad8508e50de +Revises: fa8402aa1a00 +Create Date: 2025-01-10 00:00:00.000000 + +""" + +# revision identifiers, used by Alembic. +revision = "7ad8508e50de" +down_revision = "fa8402aa1a00" +branch_labels = None +depends_on = None + +from alembic import op +import sqlalchemy as sa + + +def upgrade(): + op.alter_column("rb_namespace", "mathjax", new_column_name="katex") + + +def downgrade(): + op.alter_column("rb_namespace", "katex", new_column_name="mathjax") -- 2.49.1