From 907e4a0e68e7769db11e6cc54e26a06ed659c093 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 7 Aug 2024 19:32:27 +0000 Subject: [PATCH 1/4] Bump django from 4.2.14 to 4.2.15 Bumps [django](https://github.com/django/django) from 4.2.14 to 4.2.15. - [Commits](https://github.com/django/django/compare/4.2.14...4.2.15) --- updated-dependencies: - dependency-name: django dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index eecd9456c..3affd8196 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,7 +5,7 @@ bleach==6.1.0 colorama==0.4.6 dill==0.3.7 dj-database-url==2.1.0 -Django==4.2.14 +Django==4.2.15 django-markdownify==0.9.3 django-on-heroku==1.1.2 gunicorn==22.0.0 From c7733c8299b54760b46853de419e0c80d1fb3798 Mon Sep 17 00:00:00 2001 From: Sarah Withee <2601974+geekygirlsarah@users.noreply.github.com> Date: Wed, 7 Aug 2024 20:06:50 +0000 Subject: [PATCH 2/4] Update check-docker-build.yml to use Docker Compose v2 --- .github/workflows/check-docker-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/check-docker-build.yml b/.github/workflows/check-docker-build.yml index 22732c34e..46590c0c7 100644 --- a/.github/workflows/check-docker-build.yml +++ b/.github/workflows/check-docker-build.yml @@ -10,4 +10,4 @@ jobs: steps: - uses: actions/checkout@v4 - name: Docker Compose Build - run: docker-compose build \ No newline at end of file + run: docker compose build From de12b6e374ebb8fef37eb5263dae5256b0b2e14c Mon Sep 17 00:00:00 2001 From: penw0lf Date: Sat, 5 Oct 2024 23:48:22 +0530 Subject: [PATCH 3/4] Added default lexer, Fix #746 --- codethesaurus/settings.py | 4 ++++ web/views.py | 14 +++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/codethesaurus/settings.py b/codethesaurus/settings.py index 2ce80463c..50f9ecae3 100644 --- a/codethesaurus/settings.py +++ b/codethesaurus/settings.py @@ -177,5 +177,9 @@ } } +SIMILAR_LEXERS = { + "clips": "prolog", +} + # Configure Django App for Heroku. django_on_heroku.settings(locals(), test_runner=False, databases=False, staticfiles=True, logging=True) diff --git a/web/views.py b/web/views.py index 52a090221..c6aecd0f9 100644 --- a/web/views.py +++ b/web/views.py @@ -16,6 +16,8 @@ from pygments import highlight from pygments.formatters.html import HtmlFormatter from pygments.lexers import get_lexer_by_name +from pygments.util import ClassNotFound +from django.conf import settings from web.models import ( Language, @@ -307,6 +309,15 @@ def error_handler_500_server_error(request): response = render(request, 'error500.html') return HttpResponseServerError(response) +#get lexer +def get_highlighter(language): + SIMILAR_LEXERS = settings.SIMILAR_LEXERS + try: + lexer = get_lexer_by_name(language, startinline=True) + except ClassNotFound: + + lexer = get_lexer_by_name(SIMILAR_LEXERS.get(language, "text"), startinline=True) + return lexer # Helper functions def format_code_for_display(concept_key, lang): @@ -322,9 +333,10 @@ def format_code_for_display(concept_key, lang): if lang.concept_unknown(concept_key) or lang.concept_code(concept_key) is None: return "Unknown" if lang.concept_implemented(concept_key): + lexer = get_highlighter(lang.key) return highlight( lang.concept_code(concept_key), - get_lexer_by_name(lang.key, startinline=True), + lexer, HtmlFormatter() ) return None From 25d76f745ec54f77896e29237bb13166ea0b2b8c Mon Sep 17 00:00:00 2001 From: penw0lf Date: Sun, 6 Oct 2024 00:55:12 +0530 Subject: [PATCH 4/4] Removed extra line --- web/views.py | 1 - 1 file changed, 1 deletion(-) diff --git a/web/views.py b/web/views.py index c6aecd0f9..9584e7ef7 100644 --- a/web/views.py +++ b/web/views.py @@ -315,7 +315,6 @@ def get_highlighter(language): try: lexer = get_lexer_by_name(language, startinline=True) except ClassNotFound: - lexer = get_lexer_by_name(SIMILAR_LEXERS.get(language, "text"), startinline=True) return lexer