Skip to content
Permalink
Browse files
Shortcode support for txt2tags
  • Loading branch information
ralsina committed Sep 24, 2016
1 parent ece4030 commit da1da2a9d793370f3c013150994a2a1f39f53e7b
Showing with 16 additions and 1 deletion.
  1. +1 −1 v7/txt2tags/txt2tags.plugin
  2. +15 −0 v7/txt2tags/txt2tags.py
@@ -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

@@ -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.')

0 comments on commit da1da2a

Please sign in to comment.