Skip to content

Commit 99ac720

Browse files
talmogithub-actions[bot]claude
authored
Fix source markdown link positioning in docs (#66)
- Insert link inside the <h1> tag instead of prepending before content - Add explicit width/height on SVG to prevent it from expanding to fill container - Use float:right to position on the right side of the title line Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 951be76 commit 99ac720

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

docs/assets/extra.css

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,16 @@ body[data-md-page-path="demo/"] .md-content {
4040

4141
.md-source-file-link {
4242
float: right;
43-
margin-top: 0.4em;
4443
opacity: 0.5;
4544
transition: opacity 0.2s;
45+
line-height: 1;
4646
}
4747

4848
.md-source-file-link:hover {
4949
opacity: 1;
5050
}
5151

5252
.md-source-file-link svg {
53-
width: 1.2em;
54-
height: 1.2em;
5553
fill: currentColor;
54+
vertical-align: middle;
5655
}

hooks/copy_source_markdown.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,21 @@ def on_page_content(html: str, page, config, files) -> str: # noqa: ARG001
1010
md_url = f"../{src_path.name}"
1111

1212
svg_icon = (
13-
'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">'
13+
'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"'
14+
' width="18" height="18">'
1415
'<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 '
1516
'2-2V8l-6-6m4 18H6V4h7v5h5v11M13 9V3.5L18.5 9H13Z"/></svg>'
1617
)
1718
source_link = (
1819
f'<a href="{md_url}" title="View markdown source"'
19-
f' class="md-source-file-link">{svg_icon}</a>\n'
20+
f' class="md-source-file-link">{svg_icon}</a>'
2021
)
2122

23+
# Insert inside the <h1> tag (before the headerlink) so it renders inline
24+
h1_close = html.find("</h1>")
25+
if h1_close >= 0:
26+
return html[:h1_close] + source_link + html[h1_close:]
27+
2228
return source_link + html
2329

2430

0 commit comments

Comments
 (0)