Skip to content

Commit 8f6bd4a

Browse files
committedJan 10, 2017
Simplifying code.
1 parent 953493f commit 8f6bd4a

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed
 

‎v7/static_comments/static_comments.py

+10-12
Original file line numberDiff line numberDiff line change
@@ -83,21 +83,19 @@ def _compile_content(self, compiler_name, content, filename):
8383
_LOGGER.error("Cannot find page compiler '{0}' for comment {1}!".format(compiler_name, filename))
8484
exit(1)
8585
compiler = self.site.compilers[compiler_name]
86-
if compiler_name == 'rest':
87-
content, error_level, _, _ = compiler.compile_string(content)
88-
if error_level >= 3:
86+
try:
87+
result = compiler.compile_string(content, source_path=filename, is_two_file=True, lang=self.site.default_lang)
88+
if compiler_name == 'rest' and result[1] >= 3:
89+
# The reStructured Text page compiler returns error_level as second return value
8990
_LOGGER.error("reStructuredText page compiler ({0}) failed to compile comment {1}!".format(compiler_name, filename))
9091
exit(1)
91-
return content
92-
else:
92+
return result[0]
93+
except (AttributeError, NotImplementedError):
9394
try:
94-
return compiler.compile_string(content)[0]
95-
except (AttributeError, NotImplementedError):
96-
try:
97-
return compiler.compile_to_string(content)
98-
except AttributeError:
99-
_LOGGER.error("Page compiler plugin '{0}' provides no compile_string or compile_to_string function (comment {1})!".format(compiler_name, filename))
100-
exit(1)
95+
return compiler.compile_to_string(content)
96+
except AttributeError:
97+
_LOGGER.error("Page compiler plugin '{0}' provides no compile_string or compile_to_string function (comment {1})!".format(compiler_name, filename))
98+
exit(1)
10199

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

0 commit comments

Comments
 (0)
Please sign in to comment.