Skip to content

Instantly share code, notes, and snippets.

@jtyr
Forked from nemoo/Gitwebmarkdown
Last active January 3, 2017 15:49
Show Gist options
  • Save jtyr/06c4f02c321328f6ce21 to your computer and use it in GitHub Desktop.
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
// ==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