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

Function linkifyUrls

source/github-helpers/dom-formatters.tsx:120–143  ·  view source on GitHub ↗
(element: HTMLElement)

Source from the content-addressed store, hash-verified

118}
119
120export function linkifyUrls(element: HTMLElement): void {
121 if (element.textContent.length < 15) { // Must be long enough for a URL
122 return;
123 }
124
125 if (elementExists(linkifiedUrlSelector, element)) {
126 console.warn('Links already exist', element);
127 throw new Error('Links already exist');
128 }
129
130 const linkified = linkifyUrlsToDom(element.textContent, {
131 attributes: {
132 rel: 'noreferrer noopener',
133 class: linkifiedUrlClass, // Necessary to avoid also shortening the links
134 },
135 });
136
137 if (linkified.children.length === 0) { // Children are <a>
138 return;
139 }
140
141 zipTextNodes(element, linkified);
142 repositionAnchors(element);
143}
144
145export function parseBackticks(element: Element): void {
146 for (const node of getTextNodes(element)) {

Callers 1

linkifyContentFunction · 0.85

Calls 1

repositionAnchorsFunction · 0.85

Tested by

no test coverage detected