Skip to content

Instantly share code, notes, and snippets.

@hangxingliu
Created May 23, 2018 19:26
Show Gist options
  • Star 34 You must be signed in to star a gist
  • Fork 9 You must be signed in to fork a gist
  • Save hangxingliu/37ff8a8754327886b8ec46ecfcbf2d86 to your computer and use it in GitHub Desktop.
Save hangxingliu/37ff8a8754327886b8ec46ecfcbf2d86 to your computer and use it in GitHub Desktop.
GitHub Markdown Print Script
// Refrence from: https://gist.github.com/beevelop/a0f2c76e79610dca01550c9a93f83876
// Copy following scripts in the developer console of page included markdown content you want to print:
(function () {
var $ = document.querySelector.bind(document);
$('#readme').setAttribute('style', 'position:absolute;top:0;left:0;right:0;bottom:0;z-index:100;background-color:white');
$('#readme>article').setAttribute('style', 'border: none');
$('body').innerHTML = $('#readme').outerHTML;
window.print();
})();
@pReya
Copy link

pReya commented Jun 26, 2021

Thanks for this! I modified it a little bit to work for GitLab:

(function () {
    var $ = document.querySelector.bind(document);
    $('.md').setAttribute('style', 'position:absolute;top:0;left:0;right:0;bottom:0;z-index:100;background-color:white');
    $('body').innerHTML = $('.md').outerHTML;
    window.print();
})();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment