I have a README.md
file for my project underscore-cli, a pretty sweet tool for hacking JSON and JS on the command-line, and I want to document the --color
flag.
Currently, the ONLY way to do this is with a screenshot (which can be stored in the project repo):
But screenshots aren't text, preventing readers from copy/pasting the command in the screenshot. They're also a pain to create / edit / maintain, and are slower for browsers to load. The modern web uses text styles, not a bunch of rendered images of text.
While some markdown parsers support inline HTML styling, Github doesn't.
This doesn't work:
<span style="color: green"> Some green text </span>
This doesn't work:
<font color="green"> Some green text </font>
Below, you'll find clever answers with some creative hacks:
[Unicornist] Using emojis as colored bullets (????????????????) -- this is one of the better ideas, but is near the bottom, so consider giving it a vote. [Luke Hutchison] makes a similar suggestion, but Unicornist has a better selection of emoji bullets to choose from.
[AlecRust] Using a placeholder image service to render colored squares -- this predates the emoji solution, but solves a similar problem. It's more flexible on color, but less flexible on shape, and requires fetching an image from an external service, so really, it's just a screenshot that you can create programmatically.
[Vladimir Panteleev] using text rendering instructions in an SVG file, which is fewer bytes than a screenshot image, but has the same downside: no copy/paste support. Kind of neat though; makes me think I should play with SVG more.
[craigmichaelmartin] Abusing the DIFF color scheme to color entire lines in one of ~5 different colors -- caveat, requires including an extraneous initial character to trigger coloration (but incorporating that character into text like "-! Warning !-" is a really clever hack to hide it)
[ling] hacked up an entire text coloration service, although this seems more operationally fragile than just using pre-rendered screenshots.
There's still no solution for the general case of coloring arbitrary structured text
After upvoting this question and a few of the better answers, consider adding your +1 to the GitHub feature request: https://github.com/github/markup/issues/1440