3 A CKEditor plugin to easily add code into your articles.
4 The plugin will create a dialog where you will be able to format your code as your will. When you press the **OK** button, the plugin will create a *pre* tag with your code inside.
7 See it in action ! http://prbaron.github.com/pbckcode/
10 1. Download the plugin from the Github repository : [https://github.com/prbaron/pbckcode/tags](https://github.com/prbaron/pbckcode/tags)
11 2. Rename it to **pbckcode** (it will be easier to call it into CKEditor)
12 3. Place the folder into the plugins folder of CKEditor ( *{Path to CKEDitor}/plugins/* )
13 4. Open the config.js file and add the following lines :
16 CKEDITOR.editorConfig = function( config ) {
17 // CKEDITOR TOOLBAR CUSTOMIZATION
18 // I only set the needed buttons, so feel frey to add those you want in the array
19 config.toolbarGroups = [
20 { name: 'pbckcode' } ,
21 // you other buttons here
24 // CKEDITOR PLUGINS LOADING
25 config.extraPlugins = 'pbckcode'; // add other plugins here (comma separated)
27 // ADVANCED CONTENT FILTER (ACF)
28 // ACF protects your CKEditor instance of adding unofficial tags
29 // however it strips out the pre tag of pbckcode plugin
30 // add this rule to enable it, useful when you want to re edit a post
31 config.allowedContent= 'pre[*]{*}(*)'; // add other rules here
34 // PBCKCODE CUSTOMIZATION
36 // An optional class to your pre tag.
39 // The syntax highlighter you will use in the output view
40 highlighter : 'PRETTIFY',
42 // An array of the available modes for you plugin.
43 // The key corresponds to the string shown in the select tag.
44 // The value correspond to the loaded file for ACE Editor.
45 modes : [ ['HTML', 'html'], ['CSS', 'css'], ['PHP', 'php'], ['JS', 'javascript'] ],
47 // The theme of the ACE Editor of the plugin.
50 // Tab indentation (in spaces)
55 And you are good to go! You will have the same configuration than the demo.
61 Choose your synta highlighter output. Remove the option if you want to output a basic <pre> tag, otherwise, choose one of them.
64 'HIGHLIGHT' // http://highlightjs.org/
65 'PRETTIFY' // https://code.google.com/p/google-code-prettify/
66 'PRISM' // http://prismjs.com/
67 'SYNTAX_HIGHLIGHTER' // http://alexgorbatchev.com/SyntaxHighlighter/
74 ['C9Search' , 'c9search']
75 ['Clojure' , 'clojure']
76 ['CoffeeScript' , 'coffee']
77 ['ColdFusion' , 'coldfusion']
88 ['JavaScript' , 'javascript']
96 ['LuaPage' , 'luapage']
97 ['Markdown' , 'markdown']
102 ['Powershell' , 'powershel1']
103 ['Python' , 'python']
105 ['OpenSCAD' , 'scad']
107 ['SCSS/Sass' , 'scss']
113 ['Textile' , 'textile']
131 'textmate' // default theme
154 'tomorrow_night_blue'
155 'tomorrow_night_bright'
156 'tomorrow_night_eighties'
163 * CKEditor : [http://ckeditor.com/](http://ckeditor.com/)
164 * ACE : [http://ace.ajax.org/](http://ace.ajax.org/)
165 * Lea Verou : [http://prismjs.com/](http://prismjs.com/)
166 * Google : [https://code.google.com/p/google-code-prettify/](https://code.google.com/p/google-code-prettify/)
167 * Ivan Sagalaev : [http://highlightjs.org/](http://highlightjs.org/)
168 * Alex Gorbatchev : [http://alexgorbatchev.com/SyntaxHighlighter/](http://alexgorbatchev.com/SyntaxHighlighter/)
172 Website : [http://www.pierrebaron.fr](http://www.pierrebaron.fr)
173 Twitter : [@prbaron](https://twitter.com/prbaron)
174 Contact : <prbaron22@gmail.com>