Skip to content

Instantly share code, notes, and snippets.

@mbostock
Last active February 16, 2017 17:25
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mbostock/4454550 to your computer and use it in GitHub Desktop.
Save mbostock/4454550 to your computer and use it in GitHub Desktop.
Prose-only Blocks
license: none

You can now create prose-only blocks on bl.ocks.org by creating a Gist with a single file: README.md. When your Gist is missing an index.html file, <bl.ocks.org> will hide the example iframe but continue to display everything else. And thus you can use your README as a quick and convenient way of posting text with less clutter than the default GitHub UI.

Funnily enough, I added this feature because the GitHub Gist API recently developed a bug: when listing a user’s gists, the files hash for each gist is empty. I previously filtered gists based on the presence of an index.html file. By removing the filter, bl.ocks.org is now immune to the bug, but I had to make a corresponding change to the Gist display page.

Oh, and you can still embed code in your prose, and it will be syntax-highlighted:

function shuffle(array) {
  var m = array.length, t, i;

  // While there remain elements to shuffle…
  while (m) {

    // Pick a remaining element…
    i = Math.floor(Math.random() * m--);

    // And swap it with the current element.
    t = array[m];
    array[m] = array[i];
    array[i] = t;
  }

  return array;
}

You can also have additional files, and their source will be rendered as well. Enjoy!

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