Add emojify plugin

This commit is contained in:
Felipe Martin 2016-12-26 12:41:53 +01:00
parent a14ce75cca
commit bead0a825f
3 changed files with 53 additions and 0 deletions

5
packages/emojify/.gitignore vendored Normal file
View File

@ -0,0 +1,5 @@
dist
build
*.pyc
*.pyo
*.egg-info

View File

@ -0,0 +1,32 @@
# -*- coding: utf-8 -*-
import emoji
from lektor.pluginsystem import Plugin
class EmojifyPlugin(Plugin):
name = u'lektor-emojify'
description = u'Add emoji to your pages'
def emojize(self, text):
return emoji.emojize(text, use_aliases=True)
def on_markdown_config(self, config, **extra):
class EmojizeMixin(object):
def link(ren, link, title, text):
text = self.emojize(text)
return super(EmojizeMixin, ren).link(link, title, text)
def table_cell(ren, content, **kwargs):
result = super(EmojizeMixin, ren).table_cell(content, **kwargs)
return self.emojize(result)
def list_item(ren, text):
result = super(EmojizeMixin, ren).list_item(text)
return self.emojize(result)
def paragraph(ren, text):
result = super(EmojizeMixin, ren).paragraph(text)
return self.emojize(result)
config.renderer_mixins.append(EmojizeMixin)

16
packages/emojify/setup.py Normal file
View File

@ -0,0 +1,16 @@
from setuptools import setup
setup(
name='lektor-emojify',
version='0.1',
author=u'Felipe Martin',
author_email='me@fmartingr.com',
license='MIT',
py_modules=['lektor_emojify'],
install_requires=['emoji'],
entry_points={
'lektor.plugins': [
'emojify = lektor_emojify:EmojifyPlugin',
]
}
)