Search code examples
syntax-highlightingwysiwyg

WYSIWYG editor for website with built-in syntax highlighting


I am looking for a WYSIWYG editor for my forum website. Which has inbuilt syntax highlighting like we have in www.stackoverflow.com or www.asp.net .

So that I can save the whole text [entered by user] into the database and can render on the page with syntax highlighting.

Please help.

Don't take me wrong but I have already searched on google and Stackoverflow for this and I am not able to get the required answer.

I would appreciate if it is an open source. :-)


Solution

  • I like and used tinymce editor, it's sample code something like following.

    <script src="/javascripts/tiny_mce/tiny_mce.js" type="text/javascript"></script>
    <script language="javascript" type="text/javascript">
    
    tinyMCE.init({
    
          mode : "textareas",
          theme : "advanced",
          plugins : "safari",
          convert_urls : false,
          width : "560",
          height : "15",
          // 'code' in 'theme_advanced_buttons1' is used for the HTML content
          theme_advanced_buttons1 : "fontselect,fontsizeselect, separator, bold,italic,underline,separator,forecolor,backcolor,code, justifyleft,justifycenter,justifyright,justifyfull",
    
          theme_advanced_buttons2 : "",
    
          theme_advanced_buttons3 : "",
    
          theme_advanced_toolbar_location : "top",
    
          theme_advanced_toolbar_align : "left", extended_valid_elements : "a[name|href|target|title|onclick],img[class|src| border=0|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name], hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style]" });
    
    </script>
    
    <textarea cols="40" id="template_content" name="template[content]" rows="20"></textarea>