Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
raw_source_code_list[i] = " "
raw_source_code_lines_of_interest = raw_source_code_list[
(start_line - 1) : (end_line)
]
try:
lexer = get_lexer_for_filename(path)
except Exception:
lexer = None
if lexer and highlight:
highlighted = True
# convert string into tokens
tokens = lexer.get_tokens("\n".join(raw_source_code_lines_of_interest))
# format tokens into nice, marked up list of html
formatter = (
htmllistformatter.HtmlListFormatter()
) # Don't add newlines after each line
source_code = formatter.get_marked_up_list(tokens)
else:
highlighted = False
source_code = raw_source_code_lines_of_interest
return jsonify(
{
"source_code_array": source_code,
"path": path,
"last_modified_unix_sec": last_modified,
"highlighted": highlighted,
"start_line": start_line,
"end_line": end_line,
"num_lines_in_file": num_lines_in_file,
}