Commit 365008c5 authored by Laurent Peuch's avatar Laurent Peuch
Browse files

feat(deprecated): anchors to lines on links to files

parent d17d0efea687
......@@ -16,7 +16,8 @@ from pygments.formatters.html import HtmlFormatter
def highlight_code(file_content, lineno, full_file=False):
if full_file:
return highlight(file_content, get_lexer_by_name("python", stripnl=False),
HtmlFormatter(wrapcode=True, linenos=True, hl_lines=[lineno]))
HtmlFormatter(wrapcode=True, linenos=True, lineanchors="L",
anchorlinenos=True, hl_lines=[lineno]))
file_content = file_content.split("\n")[:lineno + 4]
......
......@@ -127,3 +127,9 @@ table.qa td.readthedocs a {
.highlighttable pre {
margin-top: 0;
}
.highlighttable a {
color: black;
text-decoration: none;
padding-top: 300px;
}
......@@ -59,7 +59,7 @@
{% if "file_content" in warning %}
{% set file_uri_path = str(project.id) + "_" + path.replace("/", "_") %}
{{- render_source_code_file(warning["file_content"], file_uri_path, path, warning["lineno"]) or "" -}}
In <a href="file/{{ file_uri_path }}.html#{{ warning["lineno"] }}">{{ path }}</a> line {{ lineno }} (<a href="traceback/{{ traceback_id }}.html">full traceback</a>)
In <a href="file/{{ file_uri_path }}.html#L-{{ warning["lineno"] }}">{{ path }}</a> line {{ lineno }} (<a href="traceback/{{ traceback_id }}.html">full traceback</a>)
{% else %}
In <u>{{ path }}</u> line {{ lineno }} (<a href="traceback/{{ traceback_id }}.html">full traceback</a>)
{% endif %}
......
......@@ -15,7 +15,7 @@
{% if frame["file_content"] %}
{% set file_uri_path = str(project_id) + "_" + frame["filename"].replace("/", "_") %}
{{- render_source_code_file(frame["file_content"], file_uri_path, frame["filename"], frame["lineno"]) or "" -}}
<span><a href="../file/{{ file_uri_path }}.html#{{ frame["lineno"] }}">{{ frame["filename"] }}</a> line {{ frame["lineno"] }}<span>
<span><a href="../file/{{ file_uri_path }}.html#L-{{ frame["lineno"] }}">{{ frame["filename"] }}</a> line {{ frame["lineno"] }}<span>
{{ highlight_code(frame["file_content"], frame["lineno"]) }}
{% else %}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment