本文整理汇总了Python中misaka.html方法的典型用法代码示例。如果您正苦于以下问题:Python misaka.html方法的具体用法?Python misaka.html怎么用?Python misaka.html使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类misaka
的用法示例。
在下文中一共展示了misaka.html方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: save
# 需要导入模块: import misaka [as 别名]
# 或者: from misaka import html [as 别名]
def save(self, *args, **kwargs):
self.slug = slugify(self.name)
self.description_html = misaka.html(self.description)
super().save(*args, **kwargs)
示例2: save
# 需要导入模块: import misaka [as 别名]
# 或者: from misaka import html [as 别名]
def save(self,*args,**kwargs):
self.message_html = misaka.html(self.message)
super().save(*args,**kwargs)
示例3: markdown
# 需要导入模块: import misaka [as 别名]
# 或者: from misaka import html [as 别名]
def markdown(text):
return markupsafe.Markup(
misaka.html(text, extensions=MARKDOWN_EXTENSIONS, render_flags=MARKDOWN_RENDER_FLAGS)
)
示例4: _content_to_slug
# 需要导入模块: import misaka [as 别名]
# 或者: from misaka import html [as 别名]
def _content_to_slug(self):
content = self._remove_url_from_content()
new_slug = re.sub('<[^<]+?>', '', misaka.html(content))
new_slug = new_slug.split()
new_slug = '-'.join(new_slug[:6])
return new_slug
示例5: convert_to_html
# 需要导入模块: import misaka [as 别名]
# 或者: from misaka import html [as 别名]
def convert_to_html(content):
html_content = misaka.html(content, extensions=(
'fenced-code', 'autolink', 'strikethrough',
'underline', 'highlight', 'quote', 'math', 'no-intra-emphasis'
))
html_content = html_content.replace('<a href', r'<a target="_blank" href')
return html_content
示例6: save
# 需要导入模块: import misaka [as 别名]
# 或者: from misaka import html [as 别名]
def save(self, *args, **kwargs):
self.message_html = misaka.html(self.message)
super().save(*args, **kwargs)
示例7: rebuild_html
# 需要导入模块: import misaka [as 别名]
# 或者: from misaka import html [as 别名]
def rebuild_html(html):
# ????
desc = html[:html.find('<hr>', 1)]
# ?????
html = html.replace('<hr>', '', 1)
soup = BeautifulSoup(html, 'html.parser')
# ??lazyload??
for img in soup.find_all('img'):
try:
src = img['data-src']
except KeyError:
try:
src = img['src']
except KeyError:
src = ''
try:
if 'lazyload' in img['class']:
continue
except KeyError:
img['class'] = []
img['class'].append('lazyload')
img['data-src'] = src
del img['src']
return str(soup), desc
示例8: render
# 需要导入模块: import misaka [as 别名]
# 或者: from misaka import html [as 别名]
def render(content):
return misaka.html(content, extensions=('fenced-code', 'strikethrough',))