Skip to content

Commit

Permalink
Move shortcode handling to reST compiler’s compile_string
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Warrick <kwpolska@gmail.com>
  • Loading branch information
Kwpolska committed Jan 8, 2017
1 parent 5c5355b commit bb3fd70
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion nikola/plugins/command/rst2html/__init__.py
Expand Up @@ -52,7 +52,7 @@ def _execute(self, options, args):
source = args[0]
with io.open(source, "r", encoding="utf8") as in_file:
data = in_file.read()
output, error_level, deps = compiler.compile_string(data, source, True)
output, error_level, deps, shortcode_deps = compiler.compile_string(data, source, True)

rstcss_path = resource_filename('nikola', 'data/themes/base/assets/css/rst.css')
with io.open(rstcss_path, "r", encoding="utf8") as fh:
Expand Down
8 changes: 4 additions & 4 deletions nikola/plugins/compile/rest/__init__.py
Expand Up @@ -59,7 +59,7 @@ class CompileRest(PageCompiler):
demote_headers = True
logger = None

def compile_string(self, data, source_path=None, is_two_file=True):
def compile_string(self, data, source_path=None, is_two_file=True, post=None):
"""Compile reST into HTML strings."""
# If errors occur, this will be added to the line number reported by
# docutils so the line number matches the actual line number (off by
Expand Down Expand Up @@ -88,7 +88,8 @@ def compile_string(self, data, source_path=None, is_two_file=True):
# To prevent some weird bugs here or there.
# Original issue: empty files. `output` became a bytestring.
output = output.decode('utf-8')
return output, error_level, deps
output, shortcode_deps = self.site.apply_shortcodes(output, filename=source, with_dependencies=True, extra_context=dict(post=post))
return output, error_level, deps, shortcode_deps

# TODO remove in v8
def compile_html_string(self, data, source_path=None, is_two_file=True):
Expand All @@ -102,8 +103,7 @@ def compile(self, source, dest, is_two_file=True, post=None, lang=None):
with io.open(dest, "w+", encoding="utf8") as out_file:
with io.open(source, "r", encoding="utf8") as in_file:
data = in_file.read()
output, error_level, deps = self.compile_string(data, source, is_two_file)
output, shortcode_deps = self.site.apply_shortcodes(output, filename=source, with_dependencies=True, extra_context=dict(post=post))
output, error_level, deps, shortcode_deps = self.compile_string(data, source, is_two_file)
out_file.write(output)
if post is None:
if deps.list:
Expand Down

0 comments on commit bb3fd70

Please sign in to comment.