Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified archify.zip
Binary file not shown.
6 changes: 3 additions & 3 deletions archify/renderers/shared/repository-location.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ export function repositorySourceHref(provider, url, revision, source) {
const end = source.endLine && source.endLine !== source.line
? `-${provider === 'github' ? 'L' : ''}${source.endLine}` : '';
const fragment = source.line ? `#L${source.line}${end}` : '';
if (provider !== 'gitlab') return `${url}/blob/${revision}/${encodedPath}${fragment}`;
// GitLab renders Markdown blobs, where line anchors select nothing; the
// GitHub and GitLab render Markdown blobs, where line anchors select nothing; the
// plain view keeps the cited lines highlighted.
const plain = source.line && /\.(?:md|markdown)$/i.test(source.path) ? '?plain=1' : '';
const plain = ['github', 'gitlab'].includes(provider) && source.line && /\.(?:md|markdown)$/i.test(source.path) ? '?plain=1' : '';
if (provider !== 'gitlab') return `${url}/blob/${revision}/${encodedPath}${plain}${fragment}`;
return `${url}/-/blob/${revision}/${encodedPath}${plain}${fragment}`;
}

Expand Down
Binary file modified docs/assets/archify-live-proof.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions docs/assets/archify-live-proof.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
"fps": 10,
"frameCount": 54,
"durationSeconds": 5.4,
"bytes": 843870,
"sha256": "b1352f9557026653aeeccac19e11d26f5d24eca8ab013e6c7058529211838c9b",
"bytes": 836293,
"sha256": "46aaacb2d93c0d781da4f7de8063ea0a8b08c59430cfe678258a20624ea4859b",
"scenes": [
{
"id": "signal-flow",
Expand All @@ -31,7 +31,7 @@
{
"id": "classic",
"artifact": "docs/gallery/artifacts/cache-miss.sequence.html",
"artifactSha256": "7f68d7303c86988cfbe228202d25fc6da42fb174be47df5f637d57c39fbf5766",
"artifactSha256": "ca273484a235600f96a74351ac3976cdb6bffb1cfb5d0b86f9ced8c21bd1aa80",
"hash": "#route=web~db",
"eyebrow": "SEQUENCE · CLASSIC",
"title": "Cache Miss Request",
Expand Down
10 changes: 10 additions & 0 deletions test/repository-markdown-lines.test.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import test from 'node:test';
import assert from 'node:assert/strict';
import { repositorySourceHref } from '../archify/renderers/shared/repository-location.mjs';
test('GitHub Markdown line citations use plain source and preserve other links',()=>{
const url='https://github.com/example/repo',rev='a'.repeat(40);
for(const name of ['README.md','guide.MARKDOWN']) assert.equal(repositorySourceHref('github',url,rev,{path:name,line:1,endLine:3}),`${url}/blob/${rev}/${name}?plain=1#L1-L3`);
assert.equal(repositorySourceHref('github',url,rev,{path:'README.md'}),`${url}/blob/${rev}/README.md`);
assert.equal(repositorySourceHref('github',url,rev,{path:'a.js',line:2}),`${url}/blob/${rev}/a.js#L2`);
assert.equal(repositorySourceHref('gitee',url,rev,{path:'README.md',line:2}),`${url}/blob/${rev}/README.md#L2`);
});
Loading