Skip to content
Permalink
Browse files

Move shortcode handling to reST compiler’s compile_string

Signed-off-by: Chris Warrick <kwpolska@gmail.com>
  • Loading branch information
Kwpolska committed Jan 8, 2017
1 parent 5c5355b commit bb3fd70a136738dea2986daccfc9afc960f93b07
Showing with 5 additions and 5 deletions.
  1. +1 −1 nikola/plugins/command/rst2html/__init__.py
  2. +4 −4 nikola/plugins/compile/rest/__init__.py
@@ -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:
@@ -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
@@ -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):
@@ -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:

0 comments on commit bb3fd70

Please sign in to comment.
You can’t perform that action at this time.