Skip to content

Commit

Permalink
Shortcode support for txt2tags
Browse files Browse the repository at this point in the history
  • Loading branch information
ralsina committed Sep 24, 2016
1 parent ece4030 commit da1da2a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion v7/txt2tags/txt2tags.plugin
Expand Up @@ -7,7 +7,7 @@ plugincategory = Compiler

[Documentation]
Author = Roberto Alsina
Version = 0.2
Version = 0.3
Website = http://plugins.getnikola.com/#txt2tags
Description = Compile Txt2tags into HTML

15 changes: 15 additions & 0 deletions v7/txt2tags/txt2tags.py
Expand Up @@ -56,6 +56,21 @@ def compile_html(self, source, dest, is_two_file=True):
makedirs(os.path.dirname(dest))
cmd = ["-t", "html", "--no-headers", "--outfile", dest, source]
txt2tags(cmd)
try:
post = self.site.post_per_input_file[source]
except KeyError:
post = None
with open(dest, 'r', encoding='utf-8') as inf:
output, shortcode_deps = self.site.apply_shortcodes(inf.read(), with_dependencies=True)
with open(dest, 'w', encoding='utf-8') as outf:
outf.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 da1da2a

Please sign in to comment.