From 0866cd93181f24d2529830d21c4ed8a9e5cffa4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment?= Date: Fri, 12 Jul 2024 10:19:56 +0200 Subject: [PATCH 1/4] add django-jinja-markdown extension --- content/pages/a_page.md | 17 +++++++++++++++++ jssg/jinja2.py | 3 ++- jssg/settings.py | 4 +++- requirements.txt | 1 + 4 files changed, 23 insertions(+), 2 deletions(-) diff --git a/content/pages/a_page.md b/content/pages/a_page.md index 19c7922..221750c 100644 --- a/content/pages/a_page.md +++ b/content/pages/a_page.md @@ -8,8 +8,25 @@ template_engine jinja2 } --- +{% from "widgets/page_header.html" import page_header %} +

Page 1

Go to page 2

+
+{% markdown %} +``` +This is markdown. +``` +{% endmarkdown %} +
+ + +{{ page_header(markdown(' +test +#test +####test + +')) }} \ No newline at end of file diff --git a/jssg/jinja2.py b/jssg/jinja2.py index 5bea8bb..e91e1d5 100644 --- a/jssg/jinja2.py +++ b/jssg/jinja2.py @@ -1,6 +1,6 @@ from django.templatetags.static import static from django.urls import reverse - +from django_jinja_markdown.templatetags.md import markdown from jinja2 import Environment from jssg.templatetags.filter_opengraph_metadata import filter_opengraph_metadata @@ -14,6 +14,7 @@ def environment(**options): { "static": static, "url": reverse, + "markdown": markdown } ) env.filters.update( diff --git a/jssg/settings.py b/jssg/settings.py index 830599b..32822be 100644 --- a/jssg/settings.py +++ b/jssg/settings.py @@ -58,6 +58,7 @@ # Application definition INSTALLED_APPS = [ + "django_jinja_markdown", "django.contrib.contenttypes", "whitenoise.runserver_nostatic", "django.contrib.staticfiles", @@ -80,7 +81,8 @@ "DIRS": [path / "jinja2" for path in JFME_TEMPLATES_DIRS], "APP_DIRS": True, "OPTIONS": { - "environment": "jssg.jinja2.environment" + "environment": "jssg.jinja2.environment", + "extensions": ["django_jinja_markdown.extensions.MarkdownExtension"] }, }, { diff --git a/requirements.txt b/requirements.txt index c196e9e..dc05782 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,3 +4,4 @@ django_vite_plugin==3.0.0 markdown2[all]==2.4.13 whitenoise==6.7.0 Jinja2==3.1.4 +django_jinja_markdown.extensions.MarkdownExtension \ No newline at end of file From 434aea2bba771e33a7ac9cd79cbf7f0380e4f429 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment?= Date: Mon, 15 Jul 2024 09:53:41 +0200 Subject: [PATCH 2/4] add dependency in requirement.txt --- content/pages/a_page.md | 11 ++++++----- requirements.txt | 4 ++-- tsconfig.json | 25 ++++++++++++++++++++++++- 3 files changed, 32 insertions(+), 8 deletions(-) diff --git a/content/pages/a_page.md b/content/pages/a_page.md index 221750c..941bbd4 100644 --- a/content/pages/a_page.md +++ b/content/pages/a_page.md @@ -24,9 +24,10 @@ This is markdown. -{{ page_header(markdown(' +{{ page_header( + markdown(' test -#test -####test - -')) }} \ No newline at end of file +**test** +`test` + ') +) }} \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index dc05782..ec36189 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,7 @@ -Django==5.0.6 +Django==4.2.9 django-distill django_vite_plugin==3.0.0 markdown2[all]==2.4.13 whitenoise==6.7.0 Jinja2==3.1.4 -django_jinja_markdown.extensions.MarkdownExtension \ No newline at end of file +django-jinja-markdown \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index 984c649..40307d7 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -19,7 +19,30 @@ "strict": true, "noUnusedLocals": true, "noUnusedParameters": true, - "noFallthroughCasesInSwitch": true + "noFallthroughCasesInSwitch": true, + "paths": { + "@/*": [ + "./*" + ], + "@s:django_jinja_markdown/*": [ + "./env/lib/python3.9/site-packages/django_jinja_markdown/static/django_jinja_markdown/*" + ], + "@t:django_jinja_markdown/*": [ + "./env/lib/python3.9/site-packages/django_jinja_markdown/templates/django_jinja_markdown/*" + ], + "@s:django_distill/*": [ + "./env/lib/python3.9/site-packages/django_distill/static/django_distill/*" + ], + "@t:django_distill/*": [ + "./env/lib/python3.9/site-packages/django_distill/templates/django_distill/*" + ], + "@s:jssg/*": [ + "./jssg/static/jssg/*" + ], + "@t:jssg/*": [ + "./jssg/templates/jssg/*" + ] + } }, "include": [ "content/front/" From e84e64aefc2c3cf447465af04ec208cf24f41b9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment?= Date: Mon, 15 Jul 2024 10:04:30 +0200 Subject: [PATCH 3/4] fix syntax error --- jssg/jinja2.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jssg/jinja2.py b/jssg/jinja2.py index 1747661..8c87f1b 100644 --- a/jssg/jinja2.py +++ b/jssg/jinja2.py @@ -91,7 +91,7 @@ def environment(**options): { "static": static, "url": reverse, - "markdown": markdown + "markdown": markdown, "url_for_slug": url_for_slug, "url_for_slug_path" : url_for_slug_path } From 466a920baf71324c8f5795c22d4aab03d9938d5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment?= Date: Tue, 23 Jul 2024 16:35:02 +0200 Subject: [PATCH 4/4] Add examples for markdown in page1 --- content/pages/a_page.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/content/pages/a_page.md b/content/pages/a_page.md index f6dc4da..e8f4205 100644 --- a/content/pages/a_page.md +++ b/content/pages/a_page.md @@ -15,11 +15,15 @@ template_engine jinja2

Go to page 2

+
{% markdown %} ``` -This is markdown. +This is markdown : ``` +test +**test** +`test` {% endmarkdown %}