<commit_before>import select from 'select-dom';
import zipTextNodes from 'zip-text-nodes';
import features from '../libs/features';
import observeEl from '../libs/simplified-element-observer';
import parseBackticks from '../libs/parse-backticks';
import {linkifyIssuesInDom} from './linkify-urls-in-code';

function init(): void {
	observeEl(
		select('#partial-discussion-header')!.parentElement!,
		() => {
			const title = select('.js-issue-title:not(.rgh-formatted-title)');

			if (title) {
				title.classList.add('rgh-formatted-title');
				linkifyIssuesInDom(title);

				const fragment = parseBackticks(title.textContent!);

				if (fragment.children.length > 0) {
					zipTextNodes(title, fragment);
				}
			}
		});
}

features.add({
	id: __featureName__,
	description: 'Make issue/PR references in issue/PR titles clickable and parse `code in backticks` that appear as Markdown',
	screenshot: 'https://user-images.githubusercontent.com/22439276/58927232-71ae2780-876b-11e9-941e-bb56a7389123.png',
	include: [
		features.isPR,
		features.isIssue
	],
	load: features.onAjaxedPages,
	init
});<commit_msg>Extend `format-discussion-titles` to issue sticky header (#2256)<commit_after>import select from 'select-dom';
import zipTextNodes from 'zip-text-nodes';
import features from '../libs/features';
import observeEl from '../libs/simplified-element-observer';
import parseBackticks from '../libs/parse-backticks';
import {linkifyIssuesInDom} from './linkify-urls-in-code';

function init(): void {
	observeEl(
		select('#partial-discussion-header')!.parentElement!,
		() => {
			for (const title of select.all('.js-issue-title:not(.rgh-formatted-title)')) {
				if (title) {
					title.classList.add('rgh-formatted-title');
					linkifyIssuesInDom(title);

					const fragment = parseBackticks(title.textContent!);

					if (fragment.children.length > 0) {
						zipTextNodes(title, fragment);
					}
				}
			}
		});
}

features.add({
	id: __featureName__,
	description: 'Make issue/PR references in issue/PR titles clickable and parse `code in backticks` that appear as Markdown',
	screenshot: 'https://user-images.githubusercontent.com/22439276/58927232-71ae2780-876b-11e9-941e-bb56a7389123.png',
	include: [
		features.isPR,
		features.isIssue
	],
	load: features.onAjaxedPages,
	init
});
{'fraction_non_alphanumeric': 0.14602346805736635, 'fraction_numerical': 0.03737505432420687, 'mean_word_length': 4.391100702576113, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6530934', 'n_tokens_mistral': 904, 'n_tokens_neox': 760, 'n_words': 152}