Skip to content

Commit

Permalink
Clean up more parse-backticks selectors (#4819)
Browse files Browse the repository at this point in the history
  • Loading branch information
kidonng committed Oct 1, 2021
1 parent e518fef commit da2a6db
Showing 1 changed file with 5 additions and 30 deletions.
35 changes: 5 additions & 30 deletions source/features/parse-backticks.tsx
Original file line number Diff line number Diff line change
@@ -1,44 +1,27 @@
import './parse-backticks.css';
import onetime from 'onetime';
import {observe} from 'selector-observer';
import zipTextNodes from 'zip-text-nodes';

import features from '.';
import {parseBackticks} from '../github-helpers/dom-formatters';
import parseBackticksCore from '../github-helpers/parse-backticks';

function init(): void {
const selectors = [
'.BorderGrid--spacious .f4.mt-3', // `isRepoHome` repository description
'.js-commits-list-item .mb-1', // `isCommitList` commit message
'.js-commits-list-item pre', // `isCommitList` commit description
'.Details[data-issue-and-pr-hovercards-enabled] .d-none a.link-gray-dark', // `isRepoRoot` commit message (GHE #4021)
'.Details[data-issue-and-pr-hovercards-enabled] .d-none a.Link--primary', // `isRepoRoot` commit message
'.commit-title', // `isCommit` commit message
'.commit-desc', // `isCommit` commit description
'.js-commit .pr-1 > code', // `isPRConversation` pushed commits
'.js-details-container .pr-1 > code', // `isCompare` pushed commits
'.Box-row .mb-1 a', // `isCompare` open Pull Request title
'.blame-commit-message', // `isBlame` commit message
'[id^=ref-issue-]', // `isIssue` issue and PR references
'[id^=ref-pullrequest-]', // `isPRConversation` issue and PR references
'[aria-label="Link issues"] a', // `isIssue`, `isPRConversation` linked issue and PR
'.Box-header.Details .link-gray', // `isSingleFile` commit message (GHE #4021)
'.Box-header.Details .Link--secondary', // `isSingleFile` commit message
'.Box-header.Details pre', // `isSingleFile` commit description
'.js-commit-group .pr-1 code', // `isPRConversation` commit message
'.js-commit-group pre', // `isPRConversation` commit description
'.release-header', // `isReleasesOrTags` Headers
'.existing-pull-contents .list-group-item-link', // `isCompare` with existing PR
'.Box-row .mb-1 a', // `isCompare` with existing PR
'#pull-requests a.link-gray-dark', // `isPulse` issue and PR title (GHE #4021)
'#pull-requests a.Link--primary', // `isPulse` issue and PR title
'[id^="check_suite"] a.link-gray-dark', // `isRepositoryActions` (GHE #4021)
'[id^="check_suite"] a.Link--primary', // `isRepositoryActions`
'.checks-summary-conclusion + .flex-auto .f3', // `isActions` run
'.js-socket-channel[data-url*="/header_partial"] h3', // `isActions` run
'.js-wiki-sidebar-toggle-display a', // `isWiki` sidebar pages title
'.wiki-wrapper .gh-header-title', // `isWiki` page title
'.js-recent-activity-container .text-bold', // `isDashboard` "Recent activity" titles
'#wiki-wrapper .gh-header-title', // `isWiki` page title
'.issues_labeled .text-gray-dark > a', // `isDashboard` "help wanted" event titles (GHE #4021)
'.issues_labeled .color-text-primary > a', // `isDashboard` "help wanted" event titles
'.commits blockquote', // `isDashboard` newsfeed commits
'#user-repositories-list [itemprop="description"]', // `isUserProfileRepoTab` repository description
'.js-hovercard-content > .Popover-message .link-gray-dark', // Hovercard (GHE #4021)
'.js-hovercard-content > .Popover-message .Link--primary', // Hovercard
Expand All @@ -52,14 +35,6 @@ function init(): void {
parseBackticks(element);
},
});

// `isRepoSearch` might highlight keywords inside backticks, breaking the regular dom-formatter #3509
observe('.codesearch-results .f4:not(.rgh-backticks-already-parsed)', {
add(element) {
element.classList.add('rgh-backticks-already-parsed');
zipTextNodes(element, parseBackticksCore(element.textContent!));
},
});
}

void features.add(__filebasename, {
Expand Down

0 comments on commit da2a6db

Please sign in to comment.