This is a follow up to my previous article Code Coloring in Postach.io. You will need to read that first to understand the changes below.



Good news! Evernote now supports code blocks. These work in a similar way to GitHub’s Markdown fenced code blocks. Simply type three backticks (```) then press enter. You should see a wonderful little grey box appear.

Any code that you place inside the code block will not have code colouring in Evernote. However, you can use the updated JavaScript below to make highlight.js work on your blog:

$(document).ready(function () {
$('div').each(function () {
if ($(this).css('box-sizing') !== 'border-box') {
return;
}
$(this).replaceWith(function () {
var result = '';
$(this).find('> div').each(function () {
result += $(this).text() + '\n';
});
if (result.trim() === '') {
return '';
}
return '
' + result + '
';
});
});

$('pre code').each(function(i, block) {
hljs.highlightBlock(block);
});
});



Tip: When pasting code in the code block you should use Command+Option+Shift+V on Mac to paste with no formatting. I'm not sure what the equivalent is on Windows.