Skip to content

Commit

Permalink
Bug fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
streeter committed Jan 15, 2013
1 parent be910e6 commit 78323c6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion pelican_gist/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
__title__ = 'pelican-gist'
__version__ = '0.1.0'
__version__ = '0.1.1'
__author__ = 'Chris Streeter'
__license__ = 'MIT'
__copyright__ = 'Copyright 2013'
Expand Down
13 changes: 7 additions & 6 deletions pelican_gist/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,15 @@
import os
import re

from jinja2 import Template
from pelican import signals


logger = logging.getLogger(__name__)
gist_regex = re.compile(r'(<p>\[gist:id\=([0-9]+),file\=([^\]]+)\]</p>)')
gist_template = Template("""<div class="gist">
gist_template = """<div class="gist">
<script src='{{script_url}}'></script>
<noscript>
<pre><code>{{code}}</code></pre>
</noscript>
</div>""")
</div>"""


def html_output(script_url, code):
Expand Down Expand Up @@ -90,6 +87,9 @@ def setup_gist(pelican):

def replace_gist_tags(generator):
"""Replace gist tags in the article content."""
from jinja2 import Template
template = Template(gist_template)

should_cache = generator.context.get('GIST_CACHE_ENABLED')
cache_location = generator.context.get('GIST_CACHE_LOCATION')

Expand Down Expand Up @@ -124,13 +124,14 @@ def replace_gist_tags(generator):
})

# Render the template
replacement = gist_template.render(context)
replacement = template.render(context)

article._content = article._content.replace(match[0], replacement)


def register():
"""Plugin registration."""
from pelican import signals

signals.initialized.connect(setup_gist)

Expand Down

0 comments on commit 78323c6

Please sign in to comment.