- {{ message.message |linebreaks }}
+ {{ message.message | markdown_to_html }}
diff --git a/chat/templatetags/chat_filters.py b/chat/templatetags/chat_filters.py
new file mode 100644
index 0000000..fe5b7d5
--- /dev/null
+++ b/chat/templatetags/chat_filters.py
@@ -0,0 +1,19 @@
+import markdown
+from django import template
+from django.utils.safestring import mark_safe
+
+register = template.Library()
+
+
+@register.filter(name="markdown_to_html", is_safe=True)
+def markdown_to_html(value):
+ """
+ Converts Markdown text to HTML.
+
+ Args:
+ value (str): The Markdown text to be converted.
+
+ Returns:
+ str: The HTML representation of the Markdown text.
+ """
+ return mark_safe(markdown.markdown(value))
diff --git a/poetry.lock b/poetry.lock
index 758c37b..6941ff4 100644
--- a/poetry.lock
+++ b/poetry.lock
@@ -839,6 +839,22 @@ files = [
pydantic = ">=1,<2"
requests = ">=2,<3"
+[[package]]
+name = "markdown"
+version = "3.7"
+description = "Python implementation of John Gruber's Markdown."
+category = "main"
+optional = false
+python-versions = ">=3.8"
+files = [
+ {file = "Markdown-3.7-py3-none-any.whl", hash = "sha256:7eb6df5690b81a1d7942992c97fad2938e956e79df20cbc6186e9c3a77b1c803"},
+ {file = "markdown-3.7.tar.gz", hash = "sha256:2ae2471477cfd02dbbf038d5d9bc226d40def84b4fe2986e49b59b6b472bbed2"},
+]
+
+[package.extras]
+docs = ["mdx-gh-links (>=0.2)", "mkdocs (>=1.5)", "mkdocs-gen-files", "mkdocs-literate-nav", "mkdocs-nature (>=0.6)", "mkdocs-section-index", "mkdocstrings[python]"]
+testing = ["coverage", "pyyaml"]
+
[[package]]
name = "marshmallow"
version = "3.20.1"
@@ -1963,4 +1979,4 @@ multidict = ">=4.0"
[metadata]
lock-version = "2.0"
python-versions = "3.11.6"
-content-hash = "e912d9538bdbf9cec33fccdf63aa2b94c4b5d668f695c0d80f73676418de76af"
+content-hash = "4598f527c98a18ed192b2b8df67b2ff51a5375a14438825b40113b53ed37202d"
diff --git a/pyproject.toml b/pyproject.toml
index b8c15b1..2fb1396 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -23,6 +23,7 @@ pillow = "^10.0.0"
django-resized = "^1.0.2"
pymupdf = "^1.23.3"
honcho = "^1.1.0"
+markdown = "^3.7"
[tool.poetry.group.dev.dependencies]
diff --git a/rulesbot/settings.py b/rulesbot/settings.py
index 7da9d45..994cd7c 100644
--- a/rulesbot/settings.py
+++ b/rulesbot/settings.py
@@ -48,7 +48,7 @@
if IS_HEROKU_APP:
ALLOWED_HOSTS = ["*"]
else:
- ALLOWED_HOSTS = ["new.rulesbot.ai", "www.rulesbot.ai", "rulesbot.ai"]
+ ALLOWED_HOSTS = ["new.rulesbot.ai", "www.rulesbot.ai", "rulesbot.ai", "localhost"]
# Set the domain for the CSRF cookie
CSRF_TRUSTED_ORIGINS = [