diff --git a/src/docc/plugins/html/static/docc.css b/src/docc/plugins/html/static/docc.css
index fc1d3f9..61258d7 100644
--- a/src/docc/plugins/html/static/docc.css
+++ b/src/docc/plugins/html/static/docc.css
@@ -2,6 +2,8 @@
* docc | GPL-3.0 License | https://github.com/SamWilsn/docc
*/
:root {
+ --bg-highlight-color: #ffeeba;
+
--default-color: black;
--default-font-weight: normal;
@@ -63,6 +65,15 @@ table.verbatim > tbody > tr > th {
padding: 0 0.5ex;
}
+.verbatim a.line {
+ color: inherit;
+ text-decoration: none;
+}
+
+table.verbatim > tbody > tr:target > th {
+ background-color: var(--bg-highlight-color);
+}
+
section section {
padding-left: 1em;
margin-top: 2em;
diff --git a/src/docc/plugins/verbatim/html.py b/src/docc/plugins/verbatim/html.py
index 191e11d..ce514d8 100644
--- a/src/docc/plugins/verbatim/html.py
+++ b/src/docc/plugins/verbatim/html.py
@@ -52,17 +52,24 @@ def render_line(
assert isinstance(parent, (HTMLRoot, HTMLTag))
assert isinstance(node, Line)
+ line_id = f"L{node.number}"
+
line_text = TextNode(str(node.number))
+ line_link = HTMLTag(
+ "a", attributes={"class": "line", "href": f"#{line_id}"}
+ )
+ line_link.append(line_text)
+
line_cell = HTMLTag("th")
- line_cell.append(line_text)
+ line_cell.append(line_link)
code_pre = HTMLTag("pre")
code_cell = HTMLTag("td")
code_cell.append(code_pre)
- row = HTMLTag("tr")
+ row = HTMLTag("tr", attributes={"id": line_id})
row.append(line_cell)
row.append(code_cell)