Prose-only Blocks
This example demonstrates a prose-only block on bl.ocks.org, created from a Gist containing a single README.md file with no index.html. The block renders the README content as the main display, omitting the usual iframe visualization area. The implementation filters Gists based on file presence and renders additional file sources, while syntax-highlighting embedded code blocks using the Gist API and GitHub’s default UI. The page also includes a JavaScript shuffle function example to illustrate embedded code.
AI-generated descriptionYou 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!