Skip to content
Browse files
Merge pull request #202 from getnikola/supporting-new-interface
Adding support for new compile_string interface
  • Loading branch information
felixfontein committed Jan 8, 2017
2 parents 773bcbf + 7fceefb commit 953493ff0679afd091e660ff5cdf0a9df0d42b40
@@ -84,15 +84,15 @@ def _compile_content(self, compiler_name, content, filename):
compiler =[compiler_name]
if compiler_name == 'rest':
content, error_level, _ = compiler.compile_string(content)
content, error_level, _, _ = compiler.compile_string(content)
if error_level >= 3:
_LOGGER.error("reStructuredText page compiler ({0}) failed to compile comment {1}!".format(compiler_name, filename))
return content
return compiler.compile_string(content)[0]
except AttributeError:
except (AttributeError, NotImplementedError):
return compiler.compile_to_string(content)
except AttributeError:
@@ -400,4 +400,4 @@ The source code for any program binaries or compressed scripts that are
included with the WordPress compiler plugin for Nikola can be freely
obtained at the following URL:
@@ -190,7 +190,14 @@ def __formatData(self, data, context, source=None):
_LOGGER.warning("The post '" + source + "' still contains shortcodes: " + str(left_shortcodes))
return output

def compile_string(self, data, source_path=None, is_two_file=True, post=None, lang=None):
"""Compile the source file into HTML strings."""
context = Context(hash(data), name=source_path)
html = self.__formatData(data, context)
return (html, []) # second part are shortcode dependencies

def compile_to_string(self, source_data, name=None, additional_data=None):
"""Old interface. Might be removed at some time."""
context = Context(hash(source_data), name=name, additional_data=additional_data)
return self.__formatData(source_data, context)

0 comments on commit 953493f

Please sign in to comment.