From ecd9e407916a8aa264a9e5added59f3edb1e7de0 Mon Sep 17 00:00:00 2001 From: Arturs Artamonovs Date: Sun, 29 Jan 2023 16:52:57 +0000 Subject: fixed url and html --- src/md.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/md.py b/src/md.py index bcca756..4ab9aa1 100755 --- a/src/md.py +++ b/src/md.py @@ -8,6 +8,7 @@ import sys from jinja2 import Environment, PackageLoader, Template, FileSystemLoader import mistune +from mistune.util import escape as escape_text #global name for templates article = {}# @@ -23,6 +24,11 @@ class TocAnchorRenderer(mistune.HTMLRenderer): html += ' id="toc-' + str(self.count) + '"' self.count += 1 return html + '>' + text + '\n' + def block_html(self, html: str) -> str: + #if self._escape: + # return '

' + escape_text(html) + '

\n' + #return html + '\n' + return html ################################################################################ #get first tags and use them to configure some bits @@ -124,11 +130,17 @@ if not custom_render: md_rend = html_toc + mistune.html(data) else: ## Mistune with custom renderer - markdown = mistune.create_markdown(renderer=TocAnchorRenderer()) + #markdown = mistune.create_markdown(renderer=TocAnchorRenderer(),escape=False,plugins=['strikethrough', 'footnotes', 'table', 'speedup']) + markdown = mistune.create_markdown( + escape=False, + #plugins=['strikethrough', 'footnotes', 'table', 'speedup'], + plugins=['url','table'], + renderer=TocAnchorRenderer() + ) md_rend = html_toc + markdown(data) #print t.render( article=article, block = md_rend ) print(t.render( article=article, block = md_rend )) - +#print(raw_tags) f.close() \ No newline at end of file -- cgit v1.2.3