Skip to content

Commit a6deae5

Browse files
committed
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.
1 parent 459e906 commit a6deae5

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

htmlreport/cppcheck-htmlreport

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -527,10 +527,10 @@ if __name__ == '__main__':
527527

528528
output_file.write(HTML_HEAD_END)
529529
try:
530-
lexer = guess_lexer_for_filename(source_filename, '')
530+
lexer = guess_lexer_for_filename(source_filename, '', stripnl=False)
531531
except ClassNotFound:
532532
try:
533-
lexer = guess_lexer(content)
533+
lexer = guess_lexer(content, stripnl=False)
534534
except ClassNotFound:
535535
sys.stderr.write("ERROR: Couldn't determine lexer for the file' " + source_filename + " '. Won't be able to syntax highlight this file.")
536536
output_file.write("\n <tr><td colspan=\"5\"> Could not generate content because pygments failed to determine the code type.</td></tr>")

0 commit comments

Comments
 (0)