Skip to content

Commit

Permalink
Prevent GitHub's code navigation styling on our links (#1696)
Browse files Browse the repository at this point in the history
* Prevent GitHub's code navigation styling on our links

* Update helper-insert-link snapshots

Co-authored-by: Stefan Buck <github@stefanbuck.com>
  • Loading branch information
xt0rted and stefanbuck committed Dec 4, 2022
1 parent a08030c commit 03b5e9e
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 10 deletions.
40 changes: 30 additions & 10 deletions packages/helper-insert-link/__tests__/__snapshots__/index.js.snap
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`insert-link does not remove closing parentheses from commented out require() calls 1`] = `
<div>
<div
clickadded="false"
>
// var faker = require(
<a
class="octolinker-link"
Expand Down Expand Up @@ -69,7 +71,9 @@ exports[`insert-link wraps a nested element 1`] = `
<div>
foo
<div>
<span>
<span
clickadded="false"
>
<i>
"
Expand All @@ -90,7 +94,9 @@ exports[`insert-link wraps a nested element 1`] = `
`;

exports[`insert-link wraps a single string 1`] = `
<div>
<div
clickadded="false"
>
foo
<a
class="octolinker-link"
Expand All @@ -105,7 +111,9 @@ exports[`insert-link wraps a single string 1`] = `
exports[`insert-link wraps a single word 1`] = `
<div>
foo
<span>
<span
clickadded="false"
>
<a
class="octolinker-link"
data-pjax="true"
Expand All @@ -119,7 +127,9 @@ exports[`insert-link wraps a single word 1`] = `
exports[`insert-link wraps double quotes 1`] = `
<div>
foo
<span>
<span
clickadded="false"
>
<a
class="octolinker-link"
data-pjax="true"
Expand All @@ -133,7 +143,9 @@ exports[`insert-link wraps double quotes 1`] = `
exports[`insert-link wraps mixed quotes 1`] = `
<div>
foo
<span>
<span
clickadded="false"
>
<a
class="octolinker-link"
data-pjax="true"
Expand All @@ -145,7 +157,9 @@ exports[`insert-link wraps mixed quotes 1`] = `
`;

exports[`insert-link wraps multiple strings 1`] = `
<div>
<div
clickadded="false"
>
foo
<a
class="octolinker-link"
Expand All @@ -160,7 +174,9 @@ exports[`insert-link wraps multiple strings 1`] = `
exports[`insert-link wraps single quotes 1`] = `
<div>
foo
<span>
<span
clickadded="false"
>
<a
class="octolinker-link"
data-pjax="true"
Expand All @@ -174,7 +190,9 @@ exports[`insert-link wraps single quotes 1`] = `
exports[`insert-link wraps the element once 1`] = `
<div>
foo
<span>
<span
clickadded="false"
>
<i>
"
Expand All @@ -196,7 +214,9 @@ exports[`insert-link wraps the element once 1`] = `
exports[`insert-link wraps the elements based on their char position which is specified in the keywords map 1`] = `
<div>
foo
<span>
<span
clickadded="false"
>
<i>
"
Expand Down
3 changes: 3 additions & 0 deletions packages/helper-insert-link/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ function injectUrl(node, value, startOffset, endOffset) {
return el;
},
});

// Prevent's GitHub's code navigation styling from being applied to our links
el.parentElement.setAttribute('clickadded', 'false');
} catch (error) {
// eslint-disable-next-line no-console
console.error(error);
Expand Down

0 comments on commit 03b5e9e

Please sign in to comment.