Previewing Your GitHub Markdown Files Using Yield

08 Aug 2013 · By Casey Scarborough

It is very common when uploading your repositories to GitHub to include a file called with your repository. This file is usually written in GitHub Flavored Markdown, which is essentially traditional markdown with a few added features from GitHub. Markdown is a super simple, text-focused language that gives you easy ways to add lists, font formatting, blockquotes, code snippets, headers, and much more.

When working with multiple projects on GitHub, I've noticed that it is sometimes inconvenient that you cannot view the output of your markdown until your changes are pushed up to GitHub. If you make a mistake, or something is not formatted as you'd like, this can lead to unnecessary commits. To solve this issue, I've created a small Ruby gem called yield, that allows you to view the output of your markdown rendered by GitHub's Markdown API.

Installing the Gem

Installing the gem requires Ruby v1.9.3 or greater, so be sure to have that installed before the installation. To get started with yield, you can begin by running the following command to install the latest version:

gem install yield

This will install the yield gem, and will give you access to its executable.

Using Yield to Render Markdown

After installation, from any repository with a file, issue the yield command to fire up the server and parse your markdown file:

=* Yield is serving your markdown at http://localhost:4000/

This will start up a server instance using Thin, and open your browser to localhost:4000. You should see something in your browser similar to the following, which is the file for the yield gem.


You can render markdown files that are not named by specifying the name of the file as an argument to yield.


This will render the contents of the file in the browser at localhost:4000.

Yield also supports relative URLs, so you can render markdown files just by navigating to their filename in the browser. For instance, the file can be viewed at localhost:4000/

Finally, you can set the port for the server to start on by using the -p or --port option, shown below.

# Specify the port to serve on
yield -p 8080
=* Yield is serving your markdown at http://localhost:8080/

Check out the repository on GitHub for the latest updates and to view the source for the gem. This gem is still in development so many updates and improvements are likely to come.


yield homepage
yield source code on GitHub
Markdown Syntax Guide
GitHub Flavored Markdown
GitHub's Markdown API

comments powered by Disqus