views:

1286

answers:

4

I am using a CMS that has FCK editor. It doesn't have an option to enter a Code sample like the way Stack Overflow's has.

I think the easiest way to do it would be to use an external editor, convert into HTML and use the HTML in the CMS to edit content.

Any suggestions?

EDIT: @IAN - It doesnt seem to be working for me. I tried using the <pre> markup both in the HTML view and the WYSISWG view. The link says that I need the include JS and css file:

<link href="prettify.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="prettify.js"></script>

Does the FCK editor already include this?

+1  A: 

Can you implement WMD and use a syntax highlighter for you code? This is what StackOverflow uses.

strager
No, not really. Unfortunately, the CMS does not allow me to use my own editor
A: 

Try Manoli he/it will format c#, VB, html, xml, t-sql with some basic syntax highlighting - works for me. Source is also available, so you can extend it if interested.

MrTelly
+4  A: 

Two favorites:

For on-demand conversion: http://www.manoli.net/csharpformat/

For on-the-fly conversion on a web page using Javascript: http://code.google.com/p/syntaxhighlighter/

Andrew Arnott
+2  A: 

For formatting I am a big fan of Google Code Javascript code prettifier.

Essentially you could paste your code in the FCK editor and wrap it as follows:

<pre class="prettyprint lang-cs">
 Code here
</pre>

The FCK editor should handle the html conversion "<" and ">" to &lt; and &gt; if you paste it in to the "WYSIWYG" portion (not the source view).

Ian Robinson