-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support fenced code blocks in explanations #345
Comments
This was referenced Jul 29, 2024
I tried the following quick patch. Fenced code blocks are rendered correctly now, but the issues with extra newlines and comments are still there. diff --git a/quiz/templatetags/quiz_extras.py b/quiz/templatetags/quiz_extras.py
index 99bed09..20cd738 100644
--- a/quiz/templatetags/quiz_extras.py
+++ b/quiz/templatetags/quiz_extras.py
@@ -41,7 +41,7 @@ def to_html(text, autoescape=None):
return mark_safe(
standard_ref(
custom_linebreaks(
- markdown.markdown(text))))
+ markdown.markdown(text, extensions=['pymdownx.superfences']))))
@register.filter()
diff --git a/requirements.in b/requirements.in
index 7da8dd6..4fb8a02 100644
--- a/requirements.in
+++ b/requirements.in
@@ -1,5 +1,6 @@
Django>=4.1,<5
Markdown
+pymdown-extensions
mock
parameterized
tweepy
diff --git a/requirements.txt b/requirements.txt
index 59c20e1..1afa779 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,5 +1,5 @@
#
-# This file is autogenerated by pip-compile with Python 3.11
+# This file is autogenerated by pip-compile with Python 3.12
# by the following command:
#
# pip-compile requirements.in
@@ -27,7 +27,9 @@ idna==3.7
lxml==5.2.2
# via splinter
markdown==3.6
- # via -r requirements.in
+ # via
+ # -r requirements.in
+ # pymdown-extensions
mock==5.1.0
# via -r requirements.in
oauthlib==3.2.2
@@ -42,10 +44,14 @@ pip-tools==7.4.1
# via -r requirements.in
pycodestyle==2.11.1
# via autopep8
+pymdown-extensions==10.9
+ # via -r requirements.in
pyproject-hooks==1.1.0
# via
# build
# pip-tools
+pyyaml==6.0.1
+ # via pymdown-extensions
requests==2.32.3
# via
# requests-oauthlib |
knatten
added a commit
that referenced
this issue
Jul 30, 2024
We want newlines to be treated as hard breaks; like StackOverflow and GitHub flavored Markdown do. Previously this was done with a custom hack, let's use an officially supported extension to our markdown renderer instead. Fixes knatten/cppquiz23#257 and helps with #345
knatten
added a commit
that referenced
this issue
Jul 30, 2024
We want newlines to be treated as hard breaks; like StackOverflow and GitHub flavored Markdown do. Previously this was done with a custom hack, let's use an officially supported extension to our markdown renderer instead. Fixes knatten/cppquiz23#257 Fixes #343 Helps with #345
knatten
added a commit
that referenced
this issue
Jul 30, 2024
We want newlines to be treated as hard breaks; like StackOverflow and GitHub flavored Markdown do. Previously this was done with a custom hack, let's use an officially supported extension to our markdown renderer instead. Fixes knatten/cppquiz23#257 Fixes #343 Helps with #345
knatten
added a commit
that referenced
this issue
Jul 30, 2024
Fixes #345 Co-authored-by: tocic <[email protected]>
knatten
added a commit
that referenced
this issue
Jul 30, 2024
Fixes #345 Co-authored-by: tocic <[email protected]>
Merged
tocic
added a commit
to tocic/cppquiz
that referenced
this issue
Aug 7, 2024
tocic
added a commit
to tocic/cppquiz
that referenced
this issue
Aug 10, 2024
tocic
added a commit
to tocic/cppquiz
that referenced
this issue
Aug 10, 2024
tocic
added a commit
to tocic/cppquiz
that referenced
this issue
Aug 10, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Explanations are rendered in quiz/templatetags/quiz_extras.py, using the Markdown package. It looks like it can only render code blocks using indentation, not using fences ("```").
I had a quick look at the docs, and this package comes with some extensions, one of which is fenced code blocks. That one has a warning, though:
So I think we need to look into using that extension, or using a different markdown renderer alltogether.
Alternatively, we could keep using indentation for code blocks, but I think people expect to be able to use fences. And since we don't have a good preview, people won't notice that it doesn't work, especially for porting efforts like #293.
When fixing this issue, we should also see if the solution we pick can fix #343.
The text was updated successfully, but these errors were encountered: