Add emojify plugin
This commit is contained in:
parent
a14ce75cca
commit
bead0a825f
3 changed files with 53 additions and 0 deletions
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)
|
Loading…
Add table
Add a link
Reference in a new issue