mirror of
				https://github.com/searxng/searxng.git
				synced 2025-11-03 19:17:07 -05:00 
			
		
		
		
	Merge pull request #1060 from return42/switch-md-parser
[mod] replace Markdown parser mistletoe by markdown-it-py
This commit is contained in:
		
						commit
						7217e43070
					
				@ -126,6 +126,10 @@ extensions = [
 | 
				
			|||||||
    'notfound.extension',  # https://github.com/readthedocs/sphinx-notfound-page
 | 
					    'notfound.extension',  # https://github.com/readthedocs/sphinx-notfound-page
 | 
				
			||||||
]
 | 
					]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					myst_enable_extensions = [
 | 
				
			||||||
 | 
					  "replacements", "smartquotes"
 | 
				
			||||||
 | 
					]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
suppress_warnings = ['myst.domains']
 | 
					suppress_warnings = ['myst.domains']
 | 
				
			||||||
 | 
					
 | 
				
			||||||
intersphinx_mapping = {
 | 
					intersphinx_mapping = {
 | 
				
			||||||
 | 
				
			|||||||
@ -14,5 +14,5 @@ httpx-socks[asyncio]==0.7.2
 | 
				
			|||||||
langdetect==1.0.9
 | 
					langdetect==1.0.9
 | 
				
			||||||
setproctitle==1.2.2
 | 
					setproctitle==1.2.2
 | 
				
			||||||
redis==4.2.2
 | 
					redis==4.2.2
 | 
				
			||||||
mistletoe==0.8.2
 | 
					markdown-it-py==2.0.1
 | 
				
			||||||
typing_extensions==4.1.1
 | 
					typing_extensions==4.1.1
 | 
				
			||||||
 | 
				
			|||||||
@ -29,7 +29,7 @@ import typing
 | 
				
			|||||||
import urllib.parse
 | 
					import urllib.parse
 | 
				
			||||||
import jinja2
 | 
					import jinja2
 | 
				
			||||||
from flask.helpers import url_for
 | 
					from flask.helpers import url_for
 | 
				
			||||||
import mistletoe
 | 
					from markdown_it import MarkdownIt
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from .. import get_setting
 | 
					from .. import get_setting
 | 
				
			||||||
from ..compat import cached_property
 | 
					from ..compat import cached_property
 | 
				
			||||||
@ -71,13 +71,17 @@ class InfoPage:
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    @cached_property
 | 
					    @cached_property
 | 
				
			||||||
    def html(self):
 | 
					    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/
 | 
					        .. _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
 | 
					    def get_ctx(self):  # pylint: disable=no-self-use
 | 
				
			||||||
        """Jinja context to render :py:obj:`InfoPage.content`"""
 | 
					        """Jinja context to render :py:obj:`InfoPage.content`"""
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user