htmlreport: Fix source view with leading empty lines
For whatever reason, pygments removes leading empty lines by default. This results in the error messages being in the wrong line, shifted by how many empty lines were removed. Adding the option "stripnl=False" as an option to the lexer constructor avoids this issue.
This commit is contained in:
parent
459e906ae1
commit
a6deae5f94
|
@ -527,10 +527,10 @@ if __name__ == '__main__':
|
||||||
|
|
||||||
output_file.write(HTML_HEAD_END)
|
output_file.write(HTML_HEAD_END)
|
||||||
try:
|
try:
|
||||||
lexer = guess_lexer_for_filename(source_filename, '')
|
lexer = guess_lexer_for_filename(source_filename, '', stripnl=False)
|
||||||
except ClassNotFound:
|
except ClassNotFound:
|
||||||
try:
|
try:
|
||||||
lexer = guess_lexer(content)
|
lexer = guess_lexer(content, stripnl=False)
|
||||||
except ClassNotFound:
|
except ClassNotFound:
|
||||||
sys.stderr.write("ERROR: Couldn't determine lexer for the file' " + source_filename + " '. Won't be able to syntax highlight this file.")
|
sys.stderr.write("ERROR: Couldn't determine lexer for the file' " + source_filename + " '. Won't be able to syntax highlight this file.")
|
||||||
output_file.write("\n <tr><td colspan=\"5\"> Could not generate content because pygments failed to determine the code type.</td></tr>")
|
output_file.write("\n <tr><td colspan=\"5\"> Could not generate content because pygments failed to determine the code type.</td></tr>")
|
||||||
|
|
Loading…
Reference in New Issue