Changes formatter.
This commit is contained in:
		
							parent
							
								
									d4aaa2d66b
								
							
						
					
					
						commit
						a301e2c5bf
					
				| @ -1,7 +1,7 @@ | ||||
| # Original source: https://brandonjay.dev/posts/2021/render-markdown-html-in-python-with-jinja2 | ||||
| 
 | ||||
| from types import SimpleNamespace | ||||
| 
 | ||||
| from html.parser import escape | ||||
| from app.cache import time_cache_async | ||||
| from mistune import HTMLRenderer, Markdown | ||||
| from pygments import highlight | ||||
| @ -34,7 +34,7 @@ class MarkdownRenderer(HTMLRenderer): | ||||
|         formatter = html.HtmlFormatter(lineseparator="<br>") | ||||
|         result = highlight(code, lexer, formatter) | ||||
|         if not result: | ||||
|             return f"<pre>{code}</pre>" | ||||
|             return f"<pre>{escape(code)}</pre>" | ||||
|         return result  | ||||
| 
 | ||||
|     def render(self): | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user