Skip to content

Commit 752452f

Browse files
committed
Improve code annotation
- hover shows line highlighting - below support clicking element to show line highlighting
1 parent 2b9ce20 commit 752452f

File tree

4 files changed

+216
-173
lines changed

4 files changed

+216
-173
lines changed

src/format/html/format-html.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -721,6 +721,11 @@ function processCodeAnnotations(format: Format, doc: Document) {
721721
if (ddEl) {
722722
ddEl.innerHTML = "";
723723
ddEl.innerText = annotation;
724+
const codeCell = annoteEl.getAttribute(kCodeCellAttr);
725+
if (codeCell) {
726+
ddEl.setAttribute(kCodeCellTargetAttr, codeCell);
727+
ddEl.setAttribute(kCodeAnnotationTargetAttr, annotation);
728+
}
724729
}
725730
}
726731
};

src/resources/formats/html/_quarto-rules.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,7 @@ div.column {
583583
}
584584

585585
.code-annotation-container-hidden {
586-
display: none;
586+
display: none !important;
587587
}
588588

589589
dl.code-annotation-container-grid {

src/resources/formats/html/bootstrap/_bootstrap-rules.scss

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1783,20 +1783,32 @@ dl.code-annotation-container-grid {
17831783
}
17841784
}
17851785

1786-
dl.code-annotation-container-grid dt {
1787-
font-family: $font-family-code;
1788-
color: var(--quarto-hl-co-color);
1789-
border: solid var(--quarto-hl-co-color) 1px;
1790-
border-radius: 50%;
1791-
height: 22px;
1792-
width: 22px;
1793-
line-height: 22px;
1794-
font-size: 11px;
1786+
dl.code-annotation-container-grid {
1787+
dt {
1788+
font-family: $font-family-code;
1789+
color: theme-dim($body-color, 10%);
1790+
border: solid theme-dim($body-color, 10%) 1px;
1791+
border-radius: 50%;
1792+
height: 22px;
1793+
width: 22px;
1794+
line-height: 22px;
1795+
font-size: 11px;
17951796

1796-
text-align: center;
1797-
vertical-align: middle;
1797+
text-align: center;
1798+
vertical-align: middle;
17981799

1799-
text-decoration: none;
1800+
text-decoration: none;
1801+
}
1802+
1803+
dt[data-target-cell] {
1804+
cursor: pointer;
1805+
}
1806+
1807+
dt[data-target-cell].code-annotation-active {
1808+
color: $body-bg;
1809+
border: solid #aaaaaa 1px;
1810+
background-color: #aaaaaa;
1811+
}
18001812
}
18011813

18021814
pre.code-annotation-code {

0 commit comments

Comments
 (0)