summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Heiser <markus.heiser@darmarIT.de>2022-04-09 16:30:51 +0200
committerGitHub <noreply@github.com>2022-04-09 16:30:51 +0200
commit7217e430706ce36897b7da0889247f70ab420fce (patch)
tree7545f79fc62e013a98e79a037225a25a694f9fb0
parent5e7f46991104a6583676c6c9319a81b6f9a4b151 (diff)
parente7644271531a7ea4d784bbb586f9e2725c546fd4 (diff)
Merge pull request #1060 from return42/switch-md-parser
[mod] replace Markdown parser mistletoe by markdown-it-py
-rw-r--r--docs/conf.py4
-rw-r--r--requirements.txt2
-rw-r--r--searx/infopage/__init__.py12
3 files changed, 13 insertions, 5 deletions
diff --git a/docs/conf.py b/docs/conf.py
index 5db9e8178..0e2244a2e 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -126,6 +126,10 @@ extensions = [
'notfound.extension', # https://github.com/readthedocs/sphinx-notfound-page
]
+myst_enable_extensions = [
+ "replacements", "smartquotes"
+]
+
suppress_warnings = ['myst.domains']
intersphinx_mapping = {
diff --git a/requirements.txt b/requirements.txt
index 4cd221336..590fc9aad 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -14,5 +14,5 @@ httpx-socks[asyncio]==0.7.2
langdetect==1.0.9
setproctitle==1.2.2
redis==4.2.2
-mistletoe==0.8.2
+markdown-it-py==2.0.1
typing_extensions==4.1.1
diff --git a/searx/infopage/__init__.py b/searx/infopage/__init__.py
index 44f3bdbd7..143f523d8 100644
--- a/searx/infopage/__init__.py
+++ b/searx/infopage/__init__.py
@@ -29,7 +29,7 @@ import typing
import urllib.parse
import jinja2
from flask.helpers import url_for
-import mistletoe
+from markdown_it import MarkdownIt
from .. import get_setting
from ..compat import cached_property
@@ -71,13 +71,17 @@ class InfoPage:
@cached_property
def html(self):
- """Render Markdown (CommonMark_) to HTML by using mistletoe_.
+ """Render Markdown (CommonMark_) to HTML by using markdown-it-py_.
.. _CommonMark: https://commonmark.org/
- .. _mistletoe: https://github.com/miyuchina/mistletoe
+ .. _markdown-it-py: https://github.com/executablebooks/markdown-it-py
"""
- return mistletoe.markdown(self.content)
+ return MarkdownIt(
+ "commonmark", {"typographer": True}
+ ).enable(
+ ["replacements", "smartquotes"]
+ ).render(self.content)
def get_ctx(self): # pylint: disable=no-self-use
"""Jinja context to render :py:obj:`InfoPage.content`"""