What is the recommended way to mark out code snippets in the documents? I’ll be adding PHP, CSS and HTML in multiple spots in the middle of pages.
I’m interested in this too. I write mostly technical material, and while I didn’t purchase Scrivener for that task, now that I’ve been using it for awhile I would really like to be able to use Scrivener for all my writing!
I would love to hear of any solutions people have come up with. Or perhaps of a new feature in the works from L&L…
My favourite way of handling code blocks is to wrap everything you need into a Preset that you can apply to any block of text. Basically, set up the code block the way you want it to look; probably some fixed-width font, maybe a little indent, and finally a preserved format block (
/Format/Formatting/Preserve Formatting). The latter will protect it from the compiler if it is set to override text; and it doesn’t hurt anything if you don’t use it, and has the advantage of making the block stand out in your editor. Once you have all of that set up, just create a new preset with
/Format/Formatting/New Preset from Selection, saving all attributes.
I use MultiMarkdown, so the formatting specifics are unnecessary. With MMD, the preserve formatting block will emit a spaces in front of each line, which is MMD’s syntax for specifying a code or verbatim block. So this method is flexible with both methods of working.
I just stumbled across this thread. I’m writing a textbook on C++ programming, so thanks AmberV for that preset tip - it looks just the kind of thing I need!