I often post snippets of code or configuration files here. By default, WordPress doesn’t really have a built-in way of displaying these fragments in an easy to read format. I’ve tried several plugins to highlight syntax, but they either did strange things with the formatting or didn’t work as I expected.
I finally found one that does the job effortlessly: Crayon Syntax Highlighter.
Here are some examples:
1 2 3 4 5 6 7 8 |
td border: 1px solid #fff font-size: 24px font-weight: 100 width: 120px max-width: 120px overflow: hidden text-shadow: 0 0 1px rgba(#000, 0.5) |
1 2 3 4 5 6 7 8 9 10 11 12 13 |
update: (output, domEl) -> processes = output.split('\n') table = $(domEl).find('table') renderProcess = (cpu, name, id) -> "<div class='wrapper'>" + "#{cpu}<p>#{name}</p>" + "<div class='pid'>#{id}</div>" + "</div>" for process, i in processes args = process.split(',') table.find(".col#{i+1}").html renderProcess(args...) |
1 2 3 4 5 6 7 8 |
IFS=$'\n' # looks for "sample" directories first. for X in `find $STARTDIR -type d -iname "*sample*"` do echo "Processing $X..." mv $X $VOLTRASH/$DATETIME/ done |
Crayon supports just about every language, includes a custom theme editor so that you can make your snippets appear exactly the way you want to, and can even convert existing code that is wrapped in <pre> tags. As with all WordPress plugins that are free, click the donate button if this solves a need you have!