Saturday, January 13, 2007

A note to contributors

Author: Sestic, Maksim

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:

  1. Write article body first (no source code yet) using Compose tool, leaving blank paragraphs for future source code snippets
  2. When you have your article fully formatted, hit the Save Now button
  3. Switch to Edit Html tool. That's how article's underlying HTML looks like
  4. Find the spot where you want your source code snippet inserted
  5. Open actual source file (.cs) in Visual Studio, copy the source code (Ctrl+C)
  6. 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