mirror of
https://github.com/veekun/pokedex.git
synced 2024-08-20 18:16:34 +00:00
Try importing markdown utilities from markdown.util
etree and AtomicString will be moved in python-markdown 2.1 See commit https://github.com/waylan/Python-Markdown/commit/89a4f3d0829a7 : Cleaned up markdown namespace. This may be a backward incompatible change for some extensions. They should be importing from markdown.util
This commit is contained in:
parent
719c32de0b
commit
ebab8c6e43
1 changed files with 10 additions and 4 deletions
|
@ -15,6 +15,12 @@ import re
|
|||
|
||||
import markdown
|
||||
from sqlalchemy.orm.session import object_session
|
||||
try:
|
||||
# Markdown 2.1+
|
||||
from markdown.util import etree, AtomicString
|
||||
except ImportError:
|
||||
# Old Markdown
|
||||
from markdown import etree, AtomicString
|
||||
|
||||
class MarkdownString(object):
|
||||
"""Wraps a Markdown string.
|
||||
|
@ -195,8 +201,8 @@ class PokedexLinkPattern(markdown.inlinepatterns.Pattern):
|
|||
if url:
|
||||
el = self.factory.make_link(category, obj, url, label or name)
|
||||
else:
|
||||
el = markdown.etree.Element('span')
|
||||
el.text = markdown.AtomicString(label or name)
|
||||
el = etree.Element('span')
|
||||
el.text = AtomicString(label or name)
|
||||
return el
|
||||
|
||||
class PokedexLinkExtension(markdown.Extension):
|
||||
|
@ -218,9 +224,9 @@ class PokedexLinkExtension(markdown.Extension):
|
|||
|
||||
Override this to set custom attributes, e.g. title.
|
||||
"""
|
||||
el = markdown.etree.Element('a')
|
||||
el = etree.Element('a')
|
||||
el.set('href', url)
|
||||
el.text = markdown.AtomicString(text)
|
||||
el.text = AtomicString(text)
|
||||
return el
|
||||
|
||||
def identifier_url(self, category, identifier):
|
||||
|
|
Loading…
Reference in a new issue