Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def handleMatch(self, m):
emoji = self.unescape(m.group(2))
if emoji not in EMOJIS:
return emoji
url = '{0}{1}.png'.format(
MARTOR_MARKDOWN_BASE_EMOJI_URL, emoji.replace(':', '')
)
if MARTOR_MARKDOWN_BASE_EMOJI_USE_STATIC is True:
url = static(url)
el = markdown.util.etree.Element('img')
el.set('src', url)
el.set('class', 'marked-emoji')
el.text = markdown.util.AtomicString(emoji)
return el
def render(self, name, value, attrs=None, renderer=None, **kwargs):
# Make the settings the default attributes to pass
attributes_to_pass = {
'data-enable-configs': MARTOR_ENABLE_CONFIGS,
'data-upload-url': MARTOR_UPLOAD_URL,
'data-markdownfy-url': MARTOR_MARKDOWNIFY_URL,
'data-search-users-url': MARTOR_SEARCH_USERS_URL,
'data-base-emoji-url': MARTOR_MARKDOWN_BASE_EMOJI_URL
}
# Make sure that the martor value is in the class attr passed in
if 'class' in attrs:
attrs['class'] += ' martor'
else:
attrs['class'] = 'martor'
# Update and overwrite with the attributes passed in
attributes_to_pass.update(attrs)
# Update and overwrite with any attributes that are on the widget
# itself. This is also the only way we can push something in without
# being part of the render chain.
attributes_to_pass.update(self.attrs)