本文整理匯總了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',))