MCPcopy Index your code
hub / github.com/refined-github/refined-github / linkifyContent

Function linkifyContent

source/features/linkify-code.tsx:9–29  ·  view source on GitHub ↗
(wrapper: HTMLElement)

Source from the content-addressed store, hash-verified

7import observe from '../helpers/selector-observer.js';
8
9function linkifyContent(wrapper: HTMLElement): void {
10 // Mark code block as touched to avoid `shorten-links` from acting on these new links in code
11 wrapper.classList.add(linkifiedUrlClass);
12
13 linkifyUrls(wrapper);
14
15 const currentRepo = pageDetect.isGlobalSearchResults()
16 // Look for the link on the line number
17 ? getRepo($('.blob-num a', wrapper.parentElement!).href)
18 : getRepo();
19 // Some non-repo pages like gists have issue references #3844
20 // They make no sense, but we still want `linkifyURLs` to run there
21 if (!currentRepo) {
22 return;
23 }
24
25 // $$optional because the content might not have any comments
26 for (const element of $$optional('.pl-c', wrapper)) {
27 linkifyIssues(currentRepo, element);
28 }
29}
30
31function init(signal: AbortSignal): void {
32 observe(codeElementsSelector, linkifyContent, {signal});

Callers

nothing calls this directly

Calls 2

linkifyUrlsFunction · 0.85
linkifyIssuesFunction · 0.85

Tested by

no test coverage detected