-
-
Save jtyr/06c4f02c321328f6ce21 to your computer and use it in GitHub Desktop.
Tampermonkey script for chrome to display README.md files rendered as html from markdown in gitweb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Gitwebmarkdown | |
// @version 0.2 | |
// @description Renders readme files in markdown. | |
// @include http://yourserverhere.com/git/* | |
// @require http://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js | |
// @require https://cdn.rawgit.com/showdownjs/showdown/1.3.0/dist/showdown.min.js | |
// ==/UserScript== | |
var converter = new showdown.Converter(); | |
// Lets find out if there is a README.md that we want to render | |
$('a.list').each(function( index ) { | |
var hrefcontent = $( this ).attr("href"); | |
var tmparray = hrefcontent.split("f="); | |
if (tmparray[1].indexOf("README.md") > -1) { | |
var thelink = $(this).parent().next().find('a').last().attr("href"); | |
$.get(thelink, function (markdown) { | |
var html = converter.makeHtml(markdown); | |
$('.page_body').append('<div id="gitwebmarkdown">' + html + '</div>'); | |
}); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment