How to print from GitHub

前端 未结 20 1096
伪装坚强ぢ
伪装坚强ぢ 2021-01-29 20:17

If I want to print a markdown file from GitHub as it appears on screen, for example: https://github.com/RestKit/RestKit/blob/master/Docs/Object%20Mapping.md

Then how can

相关标签:
20条回答
  • 2021-01-29 20:27

    I made a Chrome extension that does just this: GitHub Markdown Printer. It's a one-click solution for printing markdown files exactly how they appear on GitHub.

    Steps:

    1. Install the Chrome extension
    2. Go to any page on GitHub/GitHub Enterprise with a markdown preview
    3. Click the GMP icon to open the print dialog and either print or save as PDF

    Check out the repo for more info.

    0 讨论(0)
  • 2021-01-29 20:29

    I recommend taking a picture with http://awesomescreenshot.com/, then cropping the image and printing (I just did this and it worked for me :).

    0 讨论(0)
  • 2021-01-29 20:31

    Works for Chromium browsers and "current" GitHub html page structure

    1. Create a bookmark
    2. In the Address field enter :
    javascript:var content = document.querySelector('.repository-content'); 
    var toc = document.querySelector('#wiki-rightbar');
    toc.innerHTML = '';
    var wb = document.querySelector('.has-rightbar .wiki-body');
    wb.style.marginRight = '0px';
    var body = document.querySelector('body'); 
    body.innerHTML = ''; 
    body.appendChild(content);
    window.print();
    

    Selects the Wiki text, removes and formats the table of content, replaces the body content and calls the printer.

    0 讨论(0)
  • 2021-01-29 20:33

    Here's a super simple solution: Simply select all the text in the readme that you want to print, then print and choose "Only selected text".

    This worked perfectly in Chrome (including images) and required no javascript or external sites or downloading or building software.

    This is what I tested on: https://github.com/kroitor/gjk.c/blob/master/README.md

    0 讨论(0)
  • 2021-01-29 20:33

    Another option is pandoc. After installing (it supports Windows, Linux and Mac OS), the command would be along the lines of pandoc file.md -f markdown --smart -s -o file.pdf

    Then print the resulting PDF file.


    There is also this online converter, which produced the nicest output for me: http://www.markdowntopdf.com/

    Pandoc has an online demo as well.

    Update 2020: on macOS Catalina this command worked for me:

    brew cask install basictex
    pandoc README.md -f markdown+smart -s -o out.pdf --pdf-engine=/Library/TeX/texbin/pdflatex --pdf-engine=xelatex
    
    0 讨论(0)
  • 2021-01-29 20:33

    If you have an Instapaper account, navigate to the README.md file, save the link to Instapaper, then open the "text" option in Instapaper on that link. Most of the "clutter" is removed and the page prints well.

    0 讨论(0)
提交回复
热议问题