Inserting Source Code Snippets
Seems more complex than actually writing it :-) I embedded some tiny JavaScript source code parser in the blog head tag, here's how authors should use it to avoid article/code malformatting:
- Write article body first (no source code yet) using Compose tool, leaving blank paragraphs for future source code snippets
- When you have your article fully formatted, hit the Save Now button
- Switch to Edit Html tool. That's how article's underlying HTML looks like
- Find the spot where you want your source code snippet inserted
- Open actual source file (.cs) in Visual Studio, copy the source code (Ctrl+C)
- Go back to article's HTML and paste (Ctrl+V) code snippet enclosing it with <pre><\pre> tags, as in:
<pre class="c-sharp:collapse" name="code">
...your source code snippet goes here...
</pre>
In case you're posting VB.NET code snippet then replace c-sharp constructor parameter with vb. If you want your code snippet expanded by default, omit :collapse part of the constructor. But I suggest you always use collapsed source snippets due to physical message length and scrolling issues. Of course, don't forget to hit Save Now button at the end.
No comments:
Post a Comment