Changes formatter.
This commit is contained in:
parent
386d9c3aae
commit
d4aaa2d66b
@ -31,10 +31,11 @@ class MarkdownRenderer(HTMLRenderer):
|
|||||||
lang = 'bash'
|
lang = 'bash'
|
||||||
# return '\n<pre><code>%s</code></pre>\n' % escape(code)
|
# return '\n<pre><code>%s</code></pre>\n' % escape(code)
|
||||||
lexer = get_lexer_by_name(lang, stripall=True)
|
lexer = get_lexer_by_name(lang, stripall=True)
|
||||||
if not lexer:
|
|
||||||
return f"<pre>{code}</pre>"
|
|
||||||
formatter = html.HtmlFormatter(lineseparator="<br>")
|
formatter = html.HtmlFormatter(lineseparator="<br>")
|
||||||
return highlight(code, lexer, formatter)
|
result = highlight(code, lexer, formatter)
|
||||||
|
if not result:
|
||||||
|
return f"<pre>{code}</pre>"
|
||||||
|
return result
|
||||||
|
|
||||||
def render(self):
|
def render(self):
|
||||||
markdown_string = self.app.template_path.joinpath(self.template).read_text()
|
markdown_string = self.app.template_path.joinpath(self.template).read_text()
|
||||||
|
Loading…
Reference in New Issue
Block a user