Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplifying code. #203

Merged
merged 1 commit into from Jan 10, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 10 additions & 12 deletions v7/static_comments/static_comments.py
Expand Up @@ -83,21 +83,19 @@ def _compile_content(self, compiler_name, content, filename):
_LOGGER.error("Cannot find page compiler '{0}' for comment {1}!".format(compiler_name, filename))
exit(1)
compiler = self.site.compilers[compiler_name]
if compiler_name == 'rest':
content, error_level, _, _ = compiler.compile_string(content)
if error_level >= 3:
try:
result = compiler.compile_string(content, source_path=filename, is_two_file=True, lang=self.site.default_lang)
if compiler_name == 'rest' and result[1] >= 3:
# The reStructured Text page compiler returns error_level as second return value
_LOGGER.error("reStructuredText page compiler ({0}) failed to compile comment {1}!".format(compiler_name, filename))
exit(1)
return content
else:
return result[0]
except (AttributeError, NotImplementedError):
try:
return compiler.compile_string(content)[0]
except (AttributeError, NotImplementedError):
try:
return compiler.compile_to_string(content)
except AttributeError:
_LOGGER.error("Page compiler plugin '{0}' provides no compile_string or compile_to_string function (comment {1})!".format(compiler_name, filename))
exit(1)
return compiler.compile_to_string(content)
except AttributeError:
_LOGGER.error("Page compiler plugin '{0}' provides no compile_string or compile_to_string function (comment {1})!".format(compiler_name, filename))
exit(1)

def _read_comment(self, filename, owner, id):
"""Read a comment from a file."""
Expand Down