Add emojify plugin
This commit is contained in:
parent
a14ce75cca
commit
bead0a825f
3 changed files with 53 additions and 0 deletions
5
packages/emojify/.gitignore
vendored
Normal file
5
packages/emojify/.gitignore
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
dist
|
||||
build
|
||||
*.pyc
|
||||
*.pyo
|
||||
*.egg-info
|
32
packages/emojify/lektor_emojify.py
Normal file
32
packages/emojify/lektor_emojify.py
Normal 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
16
packages/emojify/setup.py
Normal 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',
|
||||
]
|
||||
}
|
||||
)
|
Loading…
Add table
Add a link
Reference in a new issue