GitHub: fix Asciidoc rendering

Fix Asciidoc rendering on GitHub: add standard Asciidoc icons to NOTE/TIP/etc., highlight block titles, fix TOC.

2015-04-23 या दिनांकाला. सर्वात नवीन आवृत्ती पाहा.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

You will need to install an extension such as Tampermonkey to install this script.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==UserScript==
// @name        GitHub: fix Asciidoc rendering
// @namespace   https://github.com/powerman/userjs-github-asciidoc
// @description Fix Asciidoc rendering on GitHub: add standard Asciidoc icons to NOTE/TIP/etc., highlight block titles, fix TOC.
// @include     /^https://github.com/[^/]+/[^/]+$/
// @include     /^https://github.com/[^/]+/[^/]+/blob/.*\.(asciidoc|adoc|asc)$/
// @include     /^https://github.com/[^/]+/[^/]+/wiki.*$/
// @version     1.0
// @grant       none
// ==/UserScript==

window.addEventListener('load', function(){
	'use strict';
	var icons='https://raw.githubusercontent.com/powerman/asciidoc-cheatsheet/master/images/icons/';

	// Replace text with icons for NOTE/TIP/etc.
	$('tbody > tr > td:first-child > div')
		.filter(function(){ return this.innerHTML==='Note'; })
		.html('<img src="'+icons+'note.png">');
	$('tbody > tr > td:first-child > div')
		.filter(function(){ return this.innerHTML==='Tip'; })
		.html('<img src="'+icons+'tip.png">');
	$('tbody > tr > td:first-child > div')
		.filter(function(){ return this.innerHTML==='Important'; })
		.html('<img src="'+icons+'important.png">');
	$('tbody > tr > td:first-child > div')
		.filter(function(){ return this.innerHTML==='Warning'; })
		.html('<img src="'+icons+'warning.png">');
	$('tbody > tr > td:first-child > div')
		.filter(function(){ return this.innerHTML==='Caution'; })
		.html('<img src="'+icons+'caution.png">');
	// Remove border around NOTE/TIP/etc.
	$('tbody:has(> tr > td:first-child > div > img)').find('tr, td').css({'border':'none'});

	// Make block titles bold
	$('.markdown-body div > div:first-child + *').prev().filter(':not(:has(*))').css({'font-weight':'bold'});
	$('.markdown-body td > div:first-child').filter(':not(:has(*))').css({'font-weight':'bold'});

	// Fix TOC
	$('#user-content-toc ul ul li:has(ul)').addClass('toc-node');
	$('head').append('<style>#user-content-toc ul ul li.toc-node:before { content:\'\' }</style>');

}, false);