Added admonitions

This commit is contained in:
Armin Ronacher 2015-12-25 13:21:46 +01:00
parent 14d1dc1e94
commit b260294f97
5 changed files with 109 additions and 1 deletions

File diff suppressed because one or more lines are too long

View File

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

View File

@ -0,0 +1,34 @@
# -*- 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

@ -0,0 +1,15 @@
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',
]
}
)

View File

@ -327,6 +327,10 @@ div.doc-styling {
padding: 5px 10px;
}
tr {
background: white;
}
tr:nth-child(odd) {
background: #f8f8f8;
}
@ -613,6 +617,56 @@ div.sourceviewer {
}
}
div.admonition {
margin: 15px 0;
background: white;
padding: 10px 15px;
padding-bottom: 0;
&:before {
margin: -10px -15px 10px -15px;
padding: 10px 15px;
line-height: 1;
background: #ccc;
display: block;
content: "";
font-weight: bold;
font-size: 13px;
}
&.admonition-note {
&:before {
content: "Note";
background: #8FC4E0;
}
border: 1px solid #8FC4E0;
}
&.admonition-info {
&:before {
content: "Info";
background: #E0C18F;
}
border: 1px solid #E0C18F;
}
&.admonition-tip {
&:before {
content: "Tip";
background: #9EB675;
}
border: 1px solid #9EB675;
}
&.admonition-warning {
&:before {
content: "Warning";
background: #E0AA8F;
}
border: 1px solid #E0AA8F;
}
}
/* search */
div.doc-styling div.gsc-control-cse {
font-family: $font-family-base!important;