Skip to content

Commit

Permalink
Shortcodes for textile compiler
Browse files Browse the repository at this point in the history
  • Loading branch information
ralsina committed Sep 24, 2016
1 parent 0c5f6a4 commit d363b7c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion v7/textile/textile.plugin
Expand Up @@ -8,6 +8,6 @@ MinVersion = 7.0.0

[Documentation]
Author = Roberto Alsina
Version = 0.2
Version = 0.3
Website = http://getnikola.com
Description = Compile Textile into HTML
14 changes: 13 additions & 1 deletion v7/textile/textile.py
Expand Up @@ -54,13 +54,25 @@ def compile_html(self, source, dest, is_two_file=True):
if textile is None:
req_missing(['textile'], 'build this site (compile Textile)')
makedirs(os.path.dirname(dest))
try:
post = self.site.post_per_input_file[source]
except KeyError:
post = None
with codecs.open(dest, "w+", "utf8") as out_file:
with codecs.open(source, "r", "utf8") as in_file:
data = in_file.read()
if not is_two_file:
data = re.split('(\n\n|\r\n\r\n)', data, maxsplit=1)[-1]
output = textile(data, head_offset=1)
output = textile(data, html_type='html5')
output, shortcode_deps = self.site.apply_shortcodes(output, filename=source, with_dependencies=True, extra_context=dict(post=post))
out_file.write(output)
if post is None:
if shortcode_deps:
self.logger.error(
"Cannot save dependencies for post {0} due to unregistered source file name",
source)
else:
post._depfile[dest] += shortcode_deps

def create_post(self, path, **kw):
content = kw.pop('content', 'Write your post here.')
Expand Down

0 comments on commit d363b7c

Please sign in to comment.