Added markdown-admonition plugin

This commit is contained in:
Armin Ronacher 2015-12-26 13:08:50 +01:00
parent 2559b08a55
commit ecd97de551
5 changed files with 4 additions and 55 deletions

View File

@ -14,3 +14,4 @@ lektor-webpack-support = 0.1
lektor-disqus-comments = 0.1 lektor-disqus-comments = 0.1
lektor-markdown-header-anchors = 0.1 lektor-markdown-header-anchors = 0.1
lektor-markdown-highlighter = 0.1 lektor-markdown-highlighter = 0.1
lektor-markdown-admonition = 0.1

View File

@ -20,7 +20,9 @@ project:
* [markdown-highlighter :ext](https://github.com/lektor/lektor-markdown-highlighter): * [markdown-highlighter :ext](https://github.com/lektor/lektor-markdown-highlighter):
adds support for syntax highlighting to markdown code snippets. adds support for syntax highlighting to markdown code snippets.
* [markdown-header-anchors :ext](https://github.com/lektor/lektor-markdown-header-anchors): * [markdown-header-anchors :ext](https://github.com/lektor/lektor-markdown-header-anchors):
adds support for header anchors and table of contents to markdown. adds support for header anchors and table of contents to Markdown.
* [markdown-admonition :ext](https://github.com/lektor/lektor-mardown-admonition):
adds admonition block support to Markdown.
## Unofficial ## Unofficial

View File

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

View File

@ -1,34 +0,0 @@
# -*- coding: utf-8 -*-
import re
from lektor.pluginsystem import Plugin
_prefix_re = re.compile(r'^\s*(!{1,4})\s+')
CLASSES = {
1: 'note',
2: 'info',
3: 'tip',
4: 'warning',
}
class AdmonitionMixin(object):
def paragraph(self, text):
match = _prefix_re.match(text)
if match is None:
return super(AdmonitionMixin, self).paragraph(text)
level = len(match.group(1))
return '<div class="admonition admonition-%s"><p>%s</p></div>' % (
CLASSES[level],
text[match.end():]
)
class MarkdownAdmonitionPlugin(Plugin):
name = u'Markdown Admonition'
description = u'Adds admonitions to markdown.'
def on_markdown_config(self, config, **extra):
config.renderer_mixins.append(AdmonitionMixin)

View File

@ -1,15 +0,0 @@
from setuptools import setup
setup(
name='lektor-markdown-admonition',
version='0.1',
author=u'Armin Ronacher',
author_email='armin.ronacher@active-4.com',
license='MIT',
py_modules=['lektor_markdown_admonition'],
entry_points={
'lektor.plugins': [
'markdown-admonition = lektor_markdown_admonition:MarkdownAdmonitionPlugin',
]
}
)