|
Add SyntaxHighLighter on CKEditor
CKEditor Plugin URL : http://code.google.com/p/ckeditor-syntaxhighlight/
SyntaxHighLighter URL : http://alexgorbatchev.com/SyntaxHighlighter/
* Install
1. Download "CKEditor Plugin" Code, copy the folder "syntaxhighlight" in /ckeditor/plugins/
2. Edit "/ckeditor/plugins/syntaxhighlight/dialogs/syntaxhighlight.js" file
- Choose apply file type
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | [ 'C#' , 'csharp' ],
[ 'C++' , 'cpp' ],
[ 'CSS' , 'css' ],
[ 'Javascript' , 'jscript' ],
[ 'Java' , 'java' ],
[ 'Perl' , 'perl' ],
[ 'PHP' , 'php' ],
[ 'Python' , 'python' ],
[ 'Ruby' , 'ruby' ],
[ 'SQL' , 'sql' ],
[ 'XML/XHTML' , 'xml' ]
|
3. Edit "/ckeditor/config.js" file
1 2 3 | CKEDITOR.editorConfig = function (config) {
config.extraPlugins = 'syntaxhighlight' ;
config.toolbar_Full.push([ 'Code' ]);
|
4. Download "SyntaxHighLighter" code, copy file to your site.
styles : shCore.css, shThemeDefault.css
scripts : shCore.js, shBrushPhp.js, shBrushJava.js ( You need JS file - choose apply file type [2.] )
5. Include HTML file, css and js, and use the CKEditor
6. Call the SyntaxHighlighter,
1 2 3 | <script type= "text/javascript" >
SyntaxHighlighter.all()
</script>
|
* Change odd number line color, edit "shThemeDefault.css" file
1 2 3 | .syntaxhighlighter .line.alt 2 {
background-color : #DFE7FF !important ;
}
|
|