summaryrefslogtreecommitdiff
path: root/source/features/linkify-code.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'source/features/linkify-code.tsx')
-rw-r--r--source/features/linkify-code.tsx26
1 files changed, 14 insertions, 12 deletions
diff --git a/source/features/linkify-code.tsx b/source/features/linkify-code.tsx
index a4049dd3..2abd2c84 100644
--- a/source/features/linkify-code.tsx
+++ b/source/features/linkify-code.tsx
@@ -19,20 +19,22 @@ function initTitle(): void {
}
}
-function init(): Deinit {
- return observe(`:is(${codeElementsSelector}):not(.${linkifiedURLClass})`, {
- add(wrappers) {
- linkifyURLs(wrappers);
+function linkifyContent(wrapper: Element): void {
+ linkifyURLs(wrapper);
+
+ // Linkify issue refs in comments
+ const currentRepo = getRepo() ?? {};
+ for (const element of select.all('.pl-c', wrapper)) {
+ linkifyIssues(currentRepo, element);
+ }
- // Linkify issue refs in comments
- const currentRepo = getRepo() ?? {};
- for (const element of select.all('.pl-c', wrappers)) {
- linkifyIssues(currentRepo, element);
- }
+ // Mark code block as touched to avoid linkifying twice https://github.com/refined-github/refined-github/pull/4710#discussion_r694896008
+ wrapper.classList.add(linkifiedURLClass);
+}
- // Mark code block as touched to avoid linkifying twice https://github.com/refined-github/refined-github/pull/4710#discussion_r694896008
- wrappers.classList.add(linkifiedURLClass);
- },
+function init(): Deinit {
+ return observe(`:is(${codeElementsSelector}):not(.${linkifiedURLClass})`, {
+ add: linkifyContent,
});
}