Some minor fixes
Jonas Haag
8 years ago
59 | 59 |
('patch', '/<repo>/commit/<rev>.diff'),
|
60 | 60 |
('patch', '/<repo>/commit/<rev>.patch'),
|
61 | 61 |
('index', '/<repo>/'),
|
62 | |
('history', '/<repo>/history'),
|
63 | 62 |
('history', '/<repo>/tree/<rev>/'),
|
64 | 63 |
('history', '/<repo>/tree/<rev>/<path:path>'),
|
65 | 64 |
('download', '/<repo>/tarball/<rev>/'),
|
73 | 73 |
)
|
74 | 74 |
|
75 | 75 |
|
76 | |
def pygmentize(code, filename, render_markup, ctags=None, ctags_baseurl=None):
|
|
76 |
def highlight_or_render(code, filename, render_markup=True, ctags=None, ctags_baseurl=None):
|
77 | 77 |
"""Render code using Pygments, markup (markdown, rst, ...) using the
|
78 | 78 |
corresponding renderer, if available.
|
79 | 79 |
|
16 | 16 |
{{ rendered_code }}
|
17 | 17 |
{% endif %}
|
18 | 18 |
{% endautoescape %}
|
|
19 |
<hr>
|
19 | 20 |
{% endif %}
|
20 | 21 |
|
21 | 22 |
{% include 'history.inc.html' %}
|
237 | 237 |
"""
|
238 | 238 |
git_dir = os.path.join(os.path.dirname(__file__), '..', '.git')
|
239 | 239 |
try:
|
240 | |
return check_output(
|
|
240 |
return force_unicode(check_output(
|
241 | 241 |
['git', 'log', '--format=%h', '-n', '1'],
|
242 | 242 |
cwd=git_dir
|
243 | |
).strip()
|
|
243 |
).strip())
|
244 | 244 |
except OSError:
|
245 | 245 |
# Either the git executable couldn't be found in the OS's PATH
|
246 | 246 |
# or no ".git" directory exists, i.e. this is no "bleeding-edge" installation.
|
18 | 18 |
CTAGS_CACHE = ctagscache.CTagsCache()
|
19 | 19 |
|
20 | 20 |
from klaus import markup
|
21 | |
from klaus.highlighting import pygmentize
|
|
21 |
from klaus.highlighting import highlight_or_render
|
22 | 22 |
from klaus.utils import parent_directory, subpaths, force_unicode, guess_is_binary, \
|
23 | 23 |
guess_is_image, replace_dupes
|
24 | 24 |
|
|
231 | 231 |
else:
|
232 | 232 |
self.context.update({
|
233 | 233 |
'is_markup': markup.can_render(readme_filename),
|
234 | |
'rendered_code': markup.render(readme_filename, readme_data),
|
|
234 |
'rendered_code': highlight_or_render(
|
|
235 |
force_unicode(readme_data),
|
|
236 |
force_unicode(readme_filename),
|
|
237 |
),
|
235 | 238 |
})
|
236 | 239 |
|
237 | 240 |
|
|
268 | 271 |
else:
|
269 | 272 |
ctags_args = {}
|
270 | 273 |
|
271 | |
return pygmentize(
|
|
274 |
return highlight_or_render(
|
272 | 275 |
force_unicode(self.context['blob_or_tree'].data),
|
273 | 276 |
self.context['filename'],
|
274 | 277 |
render_markup,
|