1
0
mirror of https://github.com/gryf/jekyll-rst.git synced 2025-12-19 12:28:20 +01:00

modify for python3

(cherry picked from commit 04b37d3313fbc31f22cf26534257b43e2840bdc4)
This commit is contained in:
wuyingren
2017-10-13 22:27:07 +08:00
committed by Roman Dobosz
parent c6a78ef0b5
commit 5b8eef7d05

View File

@@ -1,7 +1,7 @@
# Define a new directive `code-block` (aliased as `sourcecode`) that uses the # Define a new directive `code-block` (aliased as `sourcecode`) that uses the
# `pygments` source highlighter to render code in color. # `pygments` source highlighter to render code in color.
# #
# Incorporates code from the `Pygments`_ documentation for `Using Pygments in # Incorporates code from the `Pygments`_ documentation for `Using Pygments in
# ReST documents`_ and `Octopress`_. # ReST documents`_ and `Octopress`_.
# #
# .. _Pygments: http://pygments.org/ # .. _Pygments: http://pygments.org/
@@ -51,8 +51,8 @@ class Pygments(Directive):
# Construct cache filename # Construct cache filename
cache_file = None cache_file = None
content_text = u'\n'.join(self.content) content_text = u'\n'.join(self.content).encode('utf-8')
cache_file_name = '%s-%s.html' % (lexer_name, hashlib.md5(content_text).hexdigest()) cache_file_name = u'%s-%s.html' % (lexer_name, hashlib.md5(content_text).hexdigest())
cached_path = os.path.join(PYGMENTS_CACHE_DIR, cache_file_name) cached_path = os.path.join(PYGMENTS_CACHE_DIR, cache_file_name)
# Look for cached version, otherwise parse # Look for cached version, otherwise parse
@@ -94,4 +94,4 @@ class Pygments(Directive):
return [nodes.raw('', code, format='html')] return [nodes.raw('', code, format='html')]
directives.register_directive('code-block', Pygments) directives.register_directive('code-block', Pygments)
directives.register_directive('sourcecode', Pygments) directives.register_directive('sourcecode', Pygments)