diff --git a/hyde/ext/plugins/blockdown.py b/hyde/ext/plugins/blockdown.py
index f94946b..12c71f1 100644
--- a/hyde/ext/plugins/blockdown.py
+++ b/hyde/ext/plugins/blockdown.py
@@ -40,6 +40,6 @@ class BlockdownPlugin(TextyPlugin):
{% block blockname %} or equivalent and
Replace close pattern (default===[====]/[blockname][===========])
with
- {% block blockname %} or equivalent
+ {% endblock blockname %} or equivalent
"""
return super(BlockdownPlugin, self).text_to_tag(match, start)
diff --git a/hyde/ext/plugins/syntext.py b/hyde/ext/plugins/syntext.py
new file mode 100644
index 0000000..f4c3c0a
--- /dev/null
+++ b/hyde/ext/plugins/syntext.py
@@ -0,0 +1,45 @@
+# -*- coding: utf-8 -*-
+"""
+Syntext plugin
+"""
+
+from hyde.ext.plugins.texty import TextyPlugin
+
+class SyntextPlugin(TextyPlugin):
+ """
+ The plugin class for syntax text replacement.
+ """
+ def __init__(self, site):
+ super(SyntextPlugin, self).__init__(site)
+
+ @property
+ def tag_name(self):
+ """
+ The syntax tag.
+ """
+ return 'syntax'
+
+ @property
+ def default_open_pattern(self):
+ """
+ The default pattern for block open text.
+ """
+ return '^~~~+\s*([A-Za-z0-9_\-\.]+)\s*~*\s*$'
+
+ @property
+ def default_close_pattern(self):
+ """
+ The default pattern for block close text.
+ """
+ return '^\s*~~~+\s*$'
+
+ def text_to_tag(self, match, start=True):
+ """
+ Replace open pattern (default:~~~~~css~~~~~~)
+ with
+ {% syntax css %} or equivalent and
+ Replace close pattern (default: ~~~~~~)
+ with
+ {% endsyntax %} or equivalent
+ """
+ return super(SyntextPlugin, self).text_to_tag(match, start)
diff --git a/hyde/ext/plugins/texty.py b/hyde/ext/plugins/texty.py
index fdbd6d4..f8e679f 100644
--- a/hyde/ext/plugins/texty.py
+++ b/hyde/ext/plugins/texty.py
@@ -77,9 +77,7 @@ class TextyPlugin(Plugin):
Replaces the matched text with tag statement
given by the template.
"""
- if not match.lastindex:
- return ''
- params = match.groups(1)[0]
+ params = match.groups(1)[0] if match.lastindex else ''
return (self.template.get_open_tag(self.tag_name, params)
if start
else self.template.get_close_tag(self.tag_name, params))
diff --git a/hyde/ext/templates/jinja.py b/hyde/ext/templates/jinja.py
index 22e5076..c8649d1 100644
--- a/hyde/ext/templates/jinja.py
+++ b/hyde/ext/templates/jinja.py
@@ -12,6 +12,7 @@ from jinja2 import environmentfilter, Markup, Undefined, nodes
from jinja2.ext import Extension
from jinja2.exceptions import TemplateError
+logger = getLoggerWithNullHandler('Jinja2')
class SilentUndefined(Undefined):
"""
@@ -70,23 +71,22 @@ def syntax(env, value, lexer=None):
try:
import pygments
from pygments import lexers
- self.lexers = lexers
from pygments import formatters
except ImportError:
logger.error(u"pygments library is required to use syntax highlighting tags.")
raise TemplateError("Cannot load pygments")
- pyg = (self.lexers.get_lexer_by_name(lexer)
+ pyg = (lexers.get_lexer_by_name(lexer)
if lexer else
- self.lexers.guess_lexer(value))
+ lexers.guess_lexer(value))
settings = {}
if hasattr(env.config, 'syntax'):
settings = getattr(env.config.syntax, 'options', {})
formatter = formatters.HtmlFormatter(**settings)
- code = pygments.highlight(value, lexer, formatter)
+ code = pygments.highlight(value, pyg, formatter)
code = code.replace('\n\n', '\n \n').replace('\n', '
')
- return safestring.mark_safe('\n\n