I reused the CodeMirror javascript library already present within Bolt.
In my own _footer.twig I added the following lines:
<link rel="stylesheet" href="{{ paths.app }}view/lib/ckeditor/plugins/codemirror/css/codemirror.min.css">
<script src="{{ paths.app }}view/lib/ckeditor/plugins/codemirror/js/codemirror.min.js"></script>
Next in the javascripts/app.js I added:
$( function() {
$("textarea.code").each( function( i,el ) {
CodeMirror.fromTextArea(el, {
lineNumbers : true
});
});
});
Now when I create content with a piece of code in it I change the view to code and put the code between tags:
<textarea class="code"">
10 Print "Hello"
20 goto 10
</textarea>
You can add the syntax highlighting js files from the codeMirror site and add those to the included script links.
All in all this gave me syntax highlighted code sniplets without pretty printing in advance. I do regret the textarea construct but could replace it with a jQuery part that converts a block to a textarea block. I let the code being editable as a convenience but CodeMirror is very configurable and you could stop that.
NB: I am just starting with Bolt so there might be a better way for this.. Perhaps I should create a Bolt extension to do this.