From 36168d37c495d884f5eec0b0242f91a6fc11197a Mon Sep 17 00:00:00 2001 From: Groupr Date: Tue, 11 Nov 2025 04:08:32 +0000 Subject: [PATCH 01/17] 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/17] 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/17] 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/17] 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/17] 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 From 9989caf95f7cc973e7521f9121c9a1d7f8a7b023 Mon Sep 17 00:00:00 2001 From: Groupr Date: Thu, 27 Nov 2025 16:10:30 +0000 Subject: [PATCH 14/17] Update 7ad8508e50de_rename_mathjax_to_katex.py --- .../versions/7ad8508e50de_rename_mathjax_to_katex.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/remarkbox/scripts/alembic/versions/7ad8508e50de_rename_mathjax_to_katex.py b/remarkbox/scripts/alembic/versions/7ad8508e50de_rename_mathjax_to_katex.py index d90c383..a1818f7 100644 --- a/remarkbox/scripts/alembic/versions/7ad8508e50de_rename_mathjax_to_katex.py +++ b/remarkbox/scripts/alembic/versions/7ad8508e50de_rename_mathjax_to_katex.py @@ -17,8 +17,15 @@ import sqlalchemy as sa def upgrade(): - op.alter_column("rb_namespace", "mathjax", new_column_name="katex") + # Add new katex column and copy mathjax values + # Keep mathjax column for rollback safety + op.add_column("rb_namespace", sa.Column("katex", sa.Boolean(), server_default=sa.false())) + + # Copy existing mathjax values to katex + op.execute("UPDATE rb_namespace SET katex = mathjax") def downgrade(): - op.alter_column("rb_namespace", "katex", new_column_name="mathjax") + # Copy katex values back to mathjax and drop katex column + op.execute("UPDATE rb_namespace SET mathjax = katex") + op.drop_column("rb_namespace", "katex") -- 2.49.1 From a7e39520a7d490adc3ed07e1ec27f64dbcd465b1 Mon Sep 17 00:00:00 2001 From: Groupr Date: Thu, 27 Nov 2025 16:14:01 +0000 Subject: [PATCH 15/17] Update file notify.py --- remarkbox/lib/notify.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/remarkbox/lib/notify.py b/remarkbox/lib/notify.py index 751f91b..bf53d43 100644 --- a/remarkbox/lib/notify.py +++ b/remarkbox/lib/notify.py @@ -229,8 +229,8 @@ def send_immediate_notifications(request, notifications): }, ) log.info( - "notification frequency=immediately email={}, count={}".format( - notification.user.email, + "notification frequency=immediately username={}, count={}".format( + notification.user.name, notification.id, ) ) @@ -285,9 +285,9 @@ def send_digest_notifications(request, notification_dict, frequency="daily"): }, ) log.info( - "notification frequency={} email={}, count={}".format( + "notification frequency={} username={}, count={}".format( frequency, - recipient_email, + user.name, notifications_count, ) ) -- 2.49.1 From 30a62b872180f8997b7791d8f7d35031e6b4ebc2 Mon Sep 17 00:00:00 2001 From: Groupr Date: Thu, 27 Nov 2025 16:28:51 +0000 Subject: [PATCH 16/17] Update 7ad8508e50de_rename_mathjax_to_katex.py --- .../alembic/versions/7ad8508e50de_rename_mathjax_to_katex.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/remarkbox/scripts/alembic/versions/7ad8508e50de_rename_mathjax_to_katex.py b/remarkbox/scripts/alembic/versions/7ad8508e50de_rename_mathjax_to_katex.py index a1818f7..591247a 100644 --- a/remarkbox/scripts/alembic/versions/7ad8508e50de_rename_mathjax_to_katex.py +++ b/remarkbox/scripts/alembic/versions/7ad8508e50de_rename_mathjax_to_katex.py @@ -1,14 +1,14 @@ """Rename mathjax column to katex in rb_namespace Revision ID: 7ad8508e50de -Revises: fa8402aa1a00 +Revises: b8f3c9d4e5a1 Create Date: 2025-01-10 00:00:00.000000 """ # revision identifiers, used by Alembic. revision = "7ad8508e50de" -down_revision = "fa8402aa1a00" +down_revision = "b8f3c9d4e5a1" branch_labels = None depends_on = None -- 2.49.1 From 1ef1c8d621c68d8406e68e9f5b0d27efe8d7a2c4 Mon Sep 17 00:00:00 2001 From: Groupr Date: Thu, 27 Nov 2025 23:20:57 +0000 Subject: [PATCH 17/17] Update 7ad8508e50de_rename_mathjax_to_katex.py --- .../7ad8508e50de_rename_mathjax_to_katex.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/remarkbox/scripts/alembic/versions/7ad8508e50de_rename_mathjax_to_katex.py b/remarkbox/scripts/alembic/versions/7ad8508e50de_rename_mathjax_to_katex.py index 591247a..0c65c95 100644 --- a/remarkbox/scripts/alembic/versions/7ad8508e50de_rename_mathjax_to_katex.py +++ b/remarkbox/scripts/alembic/versions/7ad8508e50de_rename_mathjax_to_katex.py @@ -1,4 +1,4 @@ -"""Rename mathjax column to katex in rb_namespace +"""Add katex column in rb_namespace Revision ID: 7ad8508e50de Revises: b8f3c9d4e5a1 @@ -17,15 +17,14 @@ import sqlalchemy as sa def upgrade(): - # Add new katex column and copy mathjax values - # Keep mathjax column for rollback safety + # Add new katex column with default OFF op.add_column("rb_namespace", sa.Column("katex", sa.Boolean(), server_default=sa.false())) - # Copy existing mathjax values to katex - op.execute("UPDATE rb_namespace SET katex = mathjax") + # Turn katex ON for any namespace that had mathjax ON + op.execute("UPDATE rb_namespace SET katex = 1 WHERE mathjax = 1") def downgrade(): - # Copy katex values back to mathjax and drop katex column + # Copy katex values back to mathjax + # Note: SQLite doesn't support DROP COLUMN, so we just sync the data back op.execute("UPDATE rb_namespace SET mathjax = katex") - op.drop_column("rb_namespace", "katex") -- 2.49.1