properly set language in include_code

This commit is contained in:
Jake Vanderplas
2013-05-09 07:38:34 -07:00
parent ce11ec8b20
commit 92e448340c

View File

@@ -6,7 +6,7 @@ based on the octopress video tag [1]_
Syntax
------
{% include_code path/to/code [Title text] %}
{% include_code path/to/code [lang:python] [Title text] %}
The "path to code" is specified relative to the ``code`` subdirectory of
the content directory Optionally, this subdirectory can be specified in the
@@ -82,8 +82,15 @@ def include_code(preprocessor, tag, markup):
open_tag = preprocessor.configs.htmlStash.store(open_tag, safe=True)
close_tag = preprocessor.configs.htmlStash.store(close_tag, safe=True)
if lang:
lang_include = ':::' + lang + '\n '
else:
lang_include = ''
source = (open_tag
+ '\n\n ' + '\n '.join(code.split('\n')) + '\n\n'
+ '\n\n '
+ lang_include
+ '\n '.join(code.split('\n')) + '\n\n'
+ close_tag + '\n')
return source