<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Gergely Hodicska &#187; productivity</title>
	<atom:link href="http://blog.felho.hu/stock/productivity/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.felho.hu</link>
	<description>Random secrets of PHP, web development</description>
	<lastBuildDate>Fri, 30 Nov 2007 10:16:33 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>WordPress quicktag toolbar tweaking again</title>
		<link>http://blog.felho.hu/wordpress-quicktag-toolbar-tweaking-again.html</link>
		<comments>http://blog.felho.hu/wordpress-quicktag-toolbar-tweaking-again.html#comments</comments>
		<pubDate>Sat, 10 Nov 2007 20:39:03 +0000</pubDate>
		<dc:creator>Felho</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[productivity]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://blog.felho.hu/wordpress-quicktag-toolbar-tweaking-again.html</guid>
		<description><![CDATA[It is said that it is a good behavior to set title attribute to a tags. I usually put to the title the text of the link. The process is: I put the link to the clipboard, go to the editor, select the text, press Ctrl-A, insert the link to the dialog box, press enter, [...]]]></description>
			<content:encoded><![CDATA[<p>It is said that it is a good behavior to set <code>title</code> attribute to <code>a</code> tags. I usually put to the <code>title</code> the text of the link. The process is: I put the link to the clipboard, go to the editor, select the text, press <code>Ctrl-A</code>, insert the link to the dialog box, press enter, then put the text of the link to the clipboard, go to the opening <code>a</code> tag, insert <code> title=""</code> and finally paste the text from the clipboard to the attribute. This is a repetitive and tedious task, so like in the <a href="http://blog.felho.hu/posting-source-code-in-wordpress-escaping-and-syntax-highlighting-the-inserted-code.html" title="previous case">previous case</a> I automate it. <span id="more-42"></span></p>
<p>To get <a href="http://wordpress.org/" title="WordPress">WordPress</a> to insert the <code>title</code> attribute automatically to <code>a</code> tag we had to modify the <a href="http://" title="wp-includes/js/quicktags.js">wp-includes/js/quicktags.js</a> file by adding a few lines of code to the <code>edInsertTag</code> function at two places:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>341
342
343
</pre></td><td class="code"><div class="javascript" style="font-family: monospace;"><span style="color: #000066; font-weight: bold;">if</span> <span style="color: #66cc66;">&#40;</span>edButtons<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">id</span> == <span style="color: #3366CC;">'ed_link'</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; edButtons<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">tagStart</span> = edButtons<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">tagStart</span>.<span style="color: #006600;">replace</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066FF;">/&gt;/</span>, <span style="color: #3366CC;">' title=&amp;qout;'</span>+selectedText+<span style="color: #3366CC;">'&amp;qout;&gt;'</span><span style="color: #66cc66;">&#41;</span>;<br />
<span style="color: #66cc66;">&#125;</span></div></td></tr></table></div>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>357
358
359
</pre></td><td class="code"><div class="javascript" style="font-family: monospace;"><span style="color: #000066; font-weight: bold;">if</span> <span style="color: #66cc66;">&#40;</span>edButtons<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">id</span> == <span style="color: #3366CC;">'ed_link'</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; edButtons<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">tagStart</span> = edButtons<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">tagStart</span>.<span style="color: #006600;">replace</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066FF;">/&gt;/</span>, <span style="color: #3366CC;">' title=&amp;qout;'</span>+selectedText+<span style="color: #3366CC;">'&amp;qout;&gt;'</span><span style="color: #66cc66;">&#41;</span>;<br />
<span style="color: #66cc66;">&#125;</span></div></td></tr></table></div>

<p>You can download the fully modified version <a href="http://blog.felho.hu/wp-includes/js/quicktags.js" title="The modified version of quicktags.js">from here</a> (this file contains my former modifications).</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.felho.hu/wordpress-quicktag-toolbar-tweaking-again.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Posting source code in WordPress: escaping and syntax highlighting the inserted code</title>
		<link>http://blog.felho.hu/posting-source-code-in-wordpress-escaping-and-syntax-highlighting-the-inserted-code.html</link>
		<comments>http://blog.felho.hu/posting-source-code-in-wordpress-escaping-and-syntax-highlighting-the-inserted-code.html#comments</comments>
		<pubDate>Sun, 04 Nov 2007 08:26:00 +0000</pubDate>
		<dc:creator>Felho</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[productivity]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[geshi]]></category>
		<category><![CDATA[highlighting]]></category>
		<category><![CDATA[syntax]]></category>
		<category><![CDATA[wp-syntax]]></category>

		<guid isPermaLink="false">http://blog.felho.hu/posting-source-code-in-wordpress-escaping-and-syntax-highlighting-the-inserted-code.html</guid>
		<description><![CDATA[I have already mentioned that I had difficulty in finding a suitable solution to post source code in my blog. However good the workaround presented in my previous post is functioning, I was not satisfied with it. I noticed two annoying things. The first was that I had to escape HTML special chars &#8220;manually&#8221; in [...]]]></description>
			<content:encoded><![CDATA[<p>I <a href="http://blog.felho.hu/escaping-problem-with-wp-syntax-wordpress-plugin.html">have already mentioned</a> that I had difficulty in finding a suitable solution to post source code in my blog. However good the workaround presented in my previous post is functioning, I was not satisfied with it. I noticed two annoying things. The first was that I had to escape HTML special chars &#8220;manually&#8221; in the inserted code, which was a pain in the ass. My second problem was (I like to indent my code with TAB) that indentation was too wide, which looked not really nice out (and was impractical when your code has multiple nested control structures). After a little JavaScript hacking and playing with <a href="http://qbnz.com/highlighter/" title="GeSHi - Generic Syntax Highlighter">GeSHi</a> and CSS I solved both of them.<span id="more-20"></span></p>
<p>A little side note: I found that the built-in rich text editor is almost absolutely useless, so I turned it off, and I suggest it to every WordPress user.  </p>
<h2>Escaping the inserted code</h2>
<p>When you want to put some source code to the post, you usually simply enclose it in <code>code</code> or <code>pre</code> tags. The problem is, that the source code may contain characters which have special meaning in the HTML language, so they should be escaped. These characters are: <code>&lt;</code>, <code>&gt;</code>, <code>&amp;</code>, <code>&qout;</code> and they should be converted to: <code>&amp;lt;</code>, <code>&amp;gt;</code>, <code>&amp;amp;</code>, <code>&amp;qout;</code>. I would like to have some kind of automation for this task, which could be run when we insert the text to the post.</p>
<p>When you insert a code (and use a syntax highlighter) you should specify the language of that code. For example if you use the WP-Syntax plugin you should enclose your code in <code>pre</code> tags and use the <code>lang</code> attribute to specify the language. In addition you can mark if you want line numbers to appear. Enclosing the copy-pasted text is another repetitive and tedious task so it is another good candidate for automation</p>
<p>It would be great if we could do this two task in one step, so I thought I extend the toolbar above the textarea to provide this functionality by adding a new <code>sourcecode</code> button to it:<br />
<img width="500" src='http://blog.felho.hu/wp-content/toolbarsourcecodebutton.png' alt='Toolbar sourcecode button' /></p>
<p>The <code>sourcecode</code> button works similar as the others button on the toolbar, if no text is selected on the first click it inserts the open tag, on the second click it inserts the close tag. If text is selected it encloses the text in <code>pre</code> tags when you activate it. The button can be accessed via <code>Ctrl-F</code> keyboard shortcut too. Before it ads the open tag to the editor it prompts for the syntax highlighting parameters and generates the proper open tag to them. When text is selected the special characters will be replaced to HTML entities in it. This way adding source code to your post will be very straightforward:</p>
<p>1. Select the text in te editor:<br />
<img width="500" src='http://blog.felho.hu/wp-content/selectthesourcecode.png' alt='Select the source code' /><br />
2. Select the inserted text and press <code>Ctrl-F</code>:<br />
<img width="500" src='http://blog.felho.hu/wp-content/selecttheinsertedtext.png' alt='Select the inserted text' /><br />
3. Type the syntax highlighting information:<br />
<img width="350" src='http://blog.felho.hu/wp-content/typesyntaxhighlightinginformation.png' alt='Type syntax highlighting information' /><br />
4. The resulted text is:<br />
<img width="500" src='http://blog.felho.hu/wp-content/theresulttext.png' alt='The resulted text' /></p>
<p>Extending the toolbar is quite easy, only the <code>wp-includes/js/quicktags.js</code> file should be slightly modified (you can download the fully modified version <a href="http://blog.felho.hu/wp-includes/js/quicktags.js">from here</a>, all the modifications are commented). To add a new button to the toolbar you should add the following code:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>127
128
129
130
131
132
133
</pre></td><td class="code"><div class="javascript" style="font-family: monospace;">edButtons<span style="color: #66cc66;">&#91;</span>edButtons.<span style="color: #006600;">length</span><span style="color: #66cc66;">&#93;</span> = <br />
<span style="color: #003366; font-weight: bold;">new</span> edButton<span style="color: #66cc66;">&#40;</span>&amp;#<span style="color: #CC0000;">39</span>;ed_pre&amp;#<span style="color: #CC0000;">39</span>;<br />
,&amp;#<span style="color: #CC0000;">39</span>;pre&amp;#<span style="color: #CC0000;">39</span>;<br />
,&amp;#<span style="color: #CC0000;">39</span>;&lt;pre&gt;&amp;#<span style="color: #CC0000;">39</span>;<br />
,&amp;#<span style="color: #CC0000;">39</span>;&lt;/pre&gt;&amp;#<span style="color: #CC0000;">39</span>;<br />
,&amp;#<span style="color: #CC0000;">39</span>;f&amp;#<span style="color: #CC0000;">39</span>;<br />
<span style="color: #66cc66;">&#41;</span>;</div></td></tr></table></div>

<p>After then we should modify the <code>edInsertTag</code> function, and we are ready:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
</pre></td><td class="code"><div class="javascript" style="font-family: monospace;"><span style="color: #009900; font-style: italic;">//------&lt;code modification&gt;-------</span><br />
<span style="color: #009900; font-style: italic;">// Prompts for syntax highlighting parameter, and return the appropriate start tag.</span><br />
<span style="color: #009900; font-style: italic;">// TODO: l10n support.</span><br />
<span style="color: #003366; font-weight: bold;">function</span> edGetPreStartTag<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> syntaxInfo = <span style="color: #000066;">prompt</span><span style="color: #66cc66;">&#40;</span>&amp;#<span style="color: #CC0000;">39</span>;Please insert syntax highlighting information:&amp;#<span style="color: #CC0000;">39</span>;+&amp;qout;\n&amp;qout;+&amp;#<span style="color: #CC0000;">39</span>;language<span style="color: #66cc66;">&#91;</span>, line number<span style="color: #66cc66;">&#93;</span>!&amp;#<span style="color: #CC0000;">39</span>;, &amp;#<span style="color: #CC0000;">39</span>;php,<span style="color: #CC0000;">1</span>&amp;#<span style="color: #CC0000;">39</span>;<span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">split</span><span style="color: #66cc66;">&#40;</span>&amp;#<span style="color: #CC0000;">39</span>;,&amp;#<span style="color: #CC0000;">39</span>;<span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">return</span> &amp;#<span style="color: #CC0000;">39</span>;&lt;pre lang=&amp;qout;&amp;#<span style="color: #CC0000;">39</span>;+syntaxInfo<span style="color: #66cc66;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #66cc66;">&#93;</span>+&amp;#<span style="color: #CC0000;">39</span>;&amp;qout;&amp;#<span style="color: #CC0000;">39</span>;+<span style="color: #66cc66;">&#40;</span>syntaxInfo<span style="color: #66cc66;">&#91;</span><span style="color: #CC0000;">1</span><span style="color: #66cc66;">&#93;</span> != undefined ? &amp;#<span style="color: #CC0000;">39</span>; line=&amp;qout;&amp;#<span style="color: #CC0000;">39</span>;+syntaxInfo<span style="color: #66cc66;">&#91;</span><span style="color: #CC0000;">1</span><span style="color: #66cc66;">&#93;</span>+&amp;#<span style="color: #CC0000;">39</span>;&amp;qout;&amp;#<span style="color: #CC0000;">39</span>; : &amp;#<span style="color: #CC0000;">39</span>;&amp;#<span style="color: #CC0000;">39</span>;<span style="color: #66cc66;">&#41;</span>+&amp;#<span style="color: #CC0000;">39</span>;&gt;&amp;#<span style="color: #CC0000;">39</span>;+&amp;qout;\n&amp;qout;;<br />
<span style="color: #66cc66;">&#125;</span><br />
<br />
<span style="color: #009900; font-style: italic;">// It converts all HTML special chars to HTML entites</span><br />
<span style="color: #003366; font-weight: bold;">function</span> edHtmlSpecialChars<span style="color: #66cc66;">&#40;</span>string<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">return</span> string.<span style="color: #006600;">replace</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066FF;">/&amp;/g, &amp;#<span style="color: #CC0000;">39</span>;&amp;amp;&amp;#<span style="color: #CC0000;">39</span>;<span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">replace</span><span style="color: #66cc66;">&#40;</span>/&lt;/g</span>, &amp;#<span style="color: #CC0000;">39</span>;&amp;lt;&amp;#<span style="color: #CC0000;">39</span>;<span style="color: #66cc66;">&#41;</span>.<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #006600;">replace</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066FF;">/&gt;/g, &amp;#<span style="color: #CC0000;">39</span>;&amp;gt;&amp;#<span style="color: #CC0000;">39</span>;<span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">replace</span><span style="color: #66cc66;">&#40;</span>/&amp;qout;/g</span>, &amp;#<span style="color: #CC0000;">39</span>;&amp;qout;&amp;#<span style="color: #CC0000;">39</span>;<span style="color: #66cc66;">&#41;</span>.<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #006600;">replace</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066FF;">/&amp;#<span style="color: #CC0000;">39</span>;/g</span>, &amp;#<span style="color: #CC0000;">39</span>;&amp;#<span style="color: #CC0000;">39</span>;&amp;#<span style="color: #CC0000;">39</span>;<span style="color: #66cc66;">&#41;</span>;<br />
<span style="color: #66cc66;">&#125;</span><br />
<span style="color: #009900; font-style: italic;">//------&lt;/code modification&gt;-------</span><br />
<br />
<span style="color: #009900; font-style: italic;">// insertion code</span><br />
<br />
<span style="color: #003366; font-weight: bold;">function</span> edInsertTag<span style="color: #66cc66;">&#40;</span>myField, i<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #009900; font-style: italic;">//IE support</span><br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #66cc66;">&#40;</span>document.<span style="color: #006600;">selection</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; myField.<span style="color: #000066;">focus</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; sel = document.<span style="color: #006600;">selection</span>.<span style="color: #006600;">createRange</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #66cc66;">&#40;</span>sel.<span style="color: #006600;">text</span>.<span style="color: #006600;">length</span> &gt; <span style="color: #CC0000;">0</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">//------&lt;code modification&gt;-------</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #66cc66;">&#40;</span>edButtons<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">id</span> == &amp;#<span style="color: #CC0000;">39</span>;ed_pre&amp;#<span style="color: #CC0000;">39</span>;<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sel.<span style="color: #006600;">text</span> = edHtmlSpecialChars<span style="color: #66cc66;">&#40;</span>sel.<span style="color: #006600;">text</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; edButtons<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">tagStart</span> = edGetPreStartTag<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">//------&lt;/code modification&gt;-------</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sel.<span style="color: #006600;">text</span> = edButtons<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">tagStart</span> + sel.<span style="color: #006600;">text</span> + edButtons<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">tagEnd</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #66cc66;">&#40;</span>!edCheckOpenTags<span style="color: #66cc66;">&#40;</span>i<span style="color: #66cc66;">&#41;</span> || edButtons<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">tagEnd</span> == &amp;#<span style="color: #CC0000;">39</span>;&amp;#<span style="color: #CC0000;">39</span>;<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">//------&lt;code modification&gt;-------</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #66cc66;">&#40;</span>edButtons<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">id</span> == &amp;#<span style="color: #CC0000;">39</span>;ed_pre&amp;#<span style="color: #CC0000;">39</span>;<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; edButtons<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">tagStart</span> = edGetPreStartTag<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">//------&lt;/code modification&gt;-------</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sel.<span style="color: #006600;">text</span> = edButtons<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">tagStart</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; edAddTag<span style="color: #66cc66;">&#40;</span>i<span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sel.<span style="color: #006600;">text</span> = edButtons<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">tagEnd</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; edRemoveTag<span style="color: #66cc66;">&#40;</span>i<span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; myField.<span style="color: #000066;">focus</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #009900; font-style: italic;">//MOZILLA/NETSCAPE support</span><br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #66cc66;">&#40;</span>myField.<span style="color: #006600;">selectionStart</span> || myField.<span style="color: #006600;">selectionStart</span> == &amp;#<span style="color: #CC0000;">39</span>;<span style="color: #CC0000;">0</span>&amp;#<span style="color: #CC0000;">39</span>;<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> startPos = myField.<span style="color: #006600;">selectionStart</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> endPos = myField.<span style="color: #006600;">selectionEnd</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> cursorPos = endPos;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> scrollTop = myField.<span style="color: #006600;">scrollTop</span>;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #66cc66;">&#40;</span>startPos != endPos<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">//------&lt;code modification&gt;-------</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> selectedText = myField.<span style="color: #006600;">value</span>.<span style="color: #006600;">substring</span><span style="color: #66cc66;">&#40;</span>startPos, endPos<span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> selectedTextLengthGrowth = <span style="color: #CC0000;">0</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #66cc66;">&#40;</span>edButtons<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">id</span> == &amp;#<span style="color: #CC0000;">39</span>;ed_pre&amp;#<span style="color: #CC0000;">39</span>;<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; edButtons<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">tagStart</span> = edGetPreStartTag<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; selectedTextLengthGrowth = selectedText.<span style="color: #006600;">length</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; selectedText = edHtmlSpecialChars<span style="color: #66cc66;">&#40;</span>selectedText<span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; selectedTextLengthGrowth = selectedText.<span style="color: #006600;">length</span> - selectedTextLengthGrowth;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; myField.<span style="color: #006600;">value</span> = myField.<span style="color: #006600;">value</span>.<span style="color: #006600;">substring</span><span style="color: #66cc66;">&#40;</span><span style="color: #CC0000;">0</span>, startPos<span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; + edButtons<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">tagStart</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; + selectedText<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; + edButtons<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">tagEnd</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; + myField.<span style="color: #006600;">value</span>.<span style="color: #006600;">substring</span><span style="color: #66cc66;">&#40;</span>endPos, myField.<span style="color: #006600;">value</span>.<span style="color: #006600;">length</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cursorPos += edButtons<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">tagStart</span>.<span style="color: #006600;">length</span> + edButtons<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">tagEnd</span>.<span style="color: #006600;">length</span> + selectedTextLengthGrowth;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">//------&lt;/code modification&gt;-------</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #66cc66;">&#40;</span>!edCheckOpenTags<span style="color: #66cc66;">&#40;</span>i<span style="color: #66cc66;">&#41;</span> || edButtons<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">tagEnd</span> == &amp;#<span style="color: #CC0000;">39</span>;&amp;#<span style="color: #CC0000;">39</span>;<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">//------&lt;code modification&gt;-------</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #66cc66;">&#40;</span>edButtons<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">id</span> == &amp;#<span style="color: #CC0000;">39</span>;ed_pre&amp;#<span style="color: #CC0000;">39</span>;<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; edButtons<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">tagStart</span> = edGetPreStartTag<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">//------&lt;/code modification&gt;-------</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; myField.<span style="color: #006600;">value</span> = myField.<span style="color: #006600;">value</span>.<span style="color: #006600;">substring</span><span style="color: #66cc66;">&#40;</span><span style="color: #CC0000;">0</span>, startPos<span style="color: #66cc66;">&#41;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; + edButtons<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">tagStart</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; + myField.<span style="color: #006600;">value</span>.<span style="color: #006600;">substring</span><span style="color: #66cc66;">&#40;</span>endPos, myField.<span style="color: #006600;">value</span>.<span style="color: #006600;">length</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; edAddTag<span style="color: #66cc66;">&#40;</span>i<span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cursorPos = startPos + edButtons<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">tagStart</span>.<span style="color: #006600;">length</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; myField.<span style="color: #006600;">value</span> = myField.<span style="color: #006600;">value</span>.<span style="color: #006600;">substring</span><span style="color: #66cc66;">&#40;</span><span style="color: #CC0000;">0</span>, startPos<span style="color: #66cc66;">&#41;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; + edButtons<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">tagEnd</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; + myField.<span style="color: #006600;">value</span>.<span style="color: #006600;">substring</span><span style="color: #66cc66;">&#40;</span>endPos, myField.<span style="color: #006600;">value</span>.<span style="color: #006600;">length</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; edRemoveTag<span style="color: #66cc66;">&#40;</span>i<span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cursorPos = startPos + edButtons<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">tagEnd</span>.<span style="color: #006600;">length</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; myField.<span style="color: #000066;">focus</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; myField.<span style="color: #006600;">selectionStart</span> = cursorPos;<br />
&nbsp; &nbsp; &nbsp; &nbsp; myField.<span style="color: #006600;">selectionEnd</span> = cursorPos;<br />
&nbsp; &nbsp; &nbsp; &nbsp; myField.<span style="color: #006600;">scrollTop</span> = scrollTop;<br />
&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #66cc66;">&#40;</span>!edCheckOpenTags<span style="color: #66cc66;">&#40;</span>i<span style="color: #66cc66;">&#41;</span> || edButtons<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">tagEnd</span> == &amp;#<span style="color: #CC0000;">39</span>;&amp;#<span style="color: #CC0000;">39</span>;<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">//------&lt;code modification&gt;-------</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #66cc66;">&#40;</span>edButtons<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">id</span> == &amp;#<span style="color: #CC0000;">39</span>;ed_pre&amp;#<span style="color: #CC0000;">39</span>;<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; edButtons<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">tagStart</span> = edGetPreStartTag<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">//------&lt;/code modification&gt;-------</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; myField.<span style="color: #006600;">value</span> += edButtons<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">tagStart</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; edAddTag<span style="color: #66cc66;">&#40;</span>i<span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; myField.<span style="color: #006600;">value</span> += edButtons<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">tagEnd</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; edRemoveTag<span style="color: #66cc66;">&#40;</span>i<span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; myField.<span style="color: #000066;">focus</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
<span style="color: #66cc66;">&#125;</span></div></td></tr></table></div>

<h2>Controlling the indentation</h2>
<p>The <a href="http://wordpress.org/extend/plugins/wp-syntax/" title="WP-Syntax plugin home page">WP-Syntax plugin</a> uses GeSHi with default settings, which means that GeSHi wraps code blocks in <code>pre</code> tags. In this mode GeSHi doesn&#8217;t replace TAB characters with spaces, so we can&#8217;t control the appearance of the indentation. But if we instruct GeSHi to use <code>div</code> tags instead of <code>pre</code>, it will replace leading TAB characters to spaces, and you can set the number of spaces. If we want to use 4 spaces we should modify the plugin accordingly to the following:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>79
80
81
82
</pre></td><td class="code"><div class="php" style="font-family: monospace;"><span style="color: #0000ff;">$geshi</span> = <span style="color: #000000; font-weight: bold;">new</span> GeSHi<span style="color: #66cc66;">&#40;</span>htmlspecialchars_decode<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$code</span><span style="color: #66cc66;">&#41;</span>, <span style="color: #0000ff;">$language</span><span style="color: #66cc66;">&#41;</span>;<br />
<span style="color: #0000ff;">$geshi</span>-&gt;<span style="color: #006600;">enable_keyword_links</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">false</span><span style="color: #66cc66;">&#41;</span>;<br />
<span style="color: #0000ff;">$geshi</span>-&gt;<span style="color: #006600;">set_header_type</span><span style="color: #66cc66;">&#40;</span>GESHI_HEADER_DIV<span style="color: #66cc66;">&#41;</span>;<br />
<span style="color: #0000ff;">$geshi</span>-&gt;<span style="color: #006600;">set_tab_width</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">4</span><span style="color: #66cc66;">&#41;</span>;</div></td></tr></table></div>

<p>After this modification you should probably modify your CSS. I use now the following code:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
</pre></td><td class="code"><div class="css" style="font-family: monospace;"><span style="color: #808080; font-style: italic;">/***** SYNTAX HIGHLIGHTER *****/</span><br />
<span style="color: #6666ff;">.wp_syntax</span> <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">color</span>: <span style="color: #cc00cc;">#<span style="color: #933;">100</span></span>;<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">background-color</span>: <span style="color: #cc00cc;">#f9f9f9</span>;<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">border</span>: <span style="color: #933;">1px</span> <span style="color: #993333;">solid</span> <span style="color: #993333;">silver</span>;<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">margin</span>: <span style="color: #933;">0</span> <span style="color: #933;">0</span> <span style="color: #933;">1</span><span style="color: #6666ff;"><span style="color: #933;">.5em</span></span> <span style="color: #933;">0</span>;<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">overflow</span>: <span style="color: #993333;">auto</span>;<br />
<span style="color: #66cc66;">&#125;</span><br />
<br />
<span style="color: #808080; font-style: italic;">/* IE FIX */</span><br />
<span style="color: #6666ff;">.wp_syntax</span> <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; overflow-x: <span style="color: #993333;">auto</span>;<br />
&nbsp; &nbsp; overflow-y: <span style="color: #993333;">hidden</span>;<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">padding-bottom</span>: expression<span style="color: #66cc66;">&#40;</span>this<span style="color: #6666ff;">.scrollWidth</span> &gt; this<span style="color: #6666ff;">.offsetWidth</span> ? <span style="color: #933;">15</span> : <span style="color: #933;">0</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">width</span>: <span style="color: #933;"><span style="color: #933;">100</span>%</span>;<br />
<span style="color: #66cc66;">&#125;</span><br />
<br />
<span style="color: #6666ff;">.wp_syntax</span> table <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">border-collapse</span>: <span style="color: #993333;">collapse</span>;<br />
<span style="color: #66cc66;">&#125;</span><br />
<br />
<span style="color: #6666ff;">.wp_syntax</span> div, <span style="color: #6666ff;">.wp_syntax</span> td <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">vertical-align</span>: <span style="color: #000000; font-weight: bold;">top</span>;<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">padding</span>: <span style="color: #933;">2px</span> <span style="color: #933;">4px</span>;<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">white-space</span>: <span style="color: #993333;">nowrap</span>;<br />
<span style="color: #66cc66;">&#125;</span><br />
<br />
<span style="color: #6666ff;">.wp_syntax</span> <span style="color: #6666ff;">.line_numbers</span> <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">text-align</span>: <span style="color: #000000; font-weight: bold;">right</span>;<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">background-color</span>: <span style="color: #cc00cc;">#e8e9dc</span>;<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">color</span>: <span style="color: #993333;">gray</span>;<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">overflow</span>: <span style="color: #993333;">visible</span>;<br />
<span style="color: #66cc66;">&#125;</span><br />
<br />
td<span style="color: #6666ff;">.code</span> div <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">padding-top</span>: <span style="color: #933;">0px</span>;<br />
<span style="color: #66cc66;">&#125;</span></div></td></tr></table></div>

<p>I think these modifications would be interesting in the official WordPress version too, I found them useful, now I can insert source code to the post in a very convenient way.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.felho.hu/posting-source-code-in-wordpress-escaping-and-syntax-highlighting-the-inserted-code.html/feed</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
		<item>
		<title>NEON &#8211; Zend Studio for Eclipse</title>
		<link>http://blog.felho.hu/neon-zend-studio-for-eclipse.html</link>
		<comments>http://blog.felho.hu/neon-zend-studio-for-eclipse.html#comments</comments>
		<pubDate>Sat, 27 Oct 2007 14:13:04 +0000</pubDate>
		<dc:creator>Felho</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[productivity]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[zend]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[neon]]></category>
		<category><![CDATA[pdt]]></category>
		<category><![CDATA[zend studio]]></category>

		<guid isPermaLink="false">http://blog.felho.hu/neon-zend-studio-for-eclipse</guid>
		<description><![CDATA[A couple of days ago Zend announced the beta version of NEON, the Zend Studio for Eclipse, based on PDT. NEON is now a rich featured IDE for PHP developers, which supports the full development life cycle. I will cover now the most interesting parts of it, which ones could be useful for PHP developers, [...]]]></description>
			<content:encoded><![CDATA[<p>A couple of days ago <a href="http://www.zend.com/company/zend_news/press_releases/2007/10/zend_announces_zend_studio_for_eclipse_pre_release_version_available_under_code_name_neon">Zend announced</a> the beta version of NEON, the <a href="http://www.zend.com/products/zend_studio">Zend Studio</a> for <a href="http://www.eclipse.org/">Eclipse</a>, based on <a href="http://www.zend.com/pdt">PDT</a>. NEON is now a rich featured <a href="http://en.wikipedia.org/wiki/Integrated_development_environment">IDE</a> for PHP developers, which supports the full development life cycle. I will cover now the most interesting parts of it, which ones could be useful for PHP developers, but NEON has a lot of more advanced features (like web service editor) which ones I will cover in later blog entries.<span id="more-6"></span></p>
<h3>Code Assist</h3>
<p>While in PHP you can not specify the type of the function&#8217;s return variable, if you use a factory to instantiate a class, the editor has no information about the type of the variable, so the code assist won&#8217;t work. Fortunately you can help the editor to find out the type of the variable by specifying it as meta data. You have two options to achieve this:</p>
<ul>
<li>Function&#8217;s DocBlock comment:

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
</pre></td><td class="code"><div class="php" style="font-family: monospace;"><span style="color: #808080; font-style: italic;">/**<br />
* @return Foo<br />
*/</span><br />
<span style="color: #000000; font-weight: bold;">function</span> getFooInstance<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">new</span> Foo<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
<span style="color: #66cc66;">&#125;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">class</span> Foo <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">function</span> baz<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
<span style="color: #66cc66;">&#125;</span><br />
<br />
<span style="color: #0000ff;">$foo</span> = getFooInstance<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
<span style="color: #0000ff;">$foo</span>-&gt; <span style="color: #808080; font-style: italic;">// baz will apear in the selection list</span></div></td></tr></table></div>

</li>
<li> Class type hint:

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><div class="php" style="font-family: monospace;"><span style="color: #0000ff;">$foo</span> = getFooInstance<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
<span style="color: #808080; font-style: italic;">/* @var $foo Foo */</span><br />
<span style="color: #0000ff;">$foo</span>-&gt; <span style="color: #808080; font-style: italic;">// baz will apear in the selection list</span></div></td></tr></table></div>

</li>
</ul>
<p>NEON supports code assist at include statements too.</p>
<h3>Code Formatter</h3>
<p>At last NEON has a great code formatter functionality. You can fully customize (even on project basis) how your code should be appear. You can set it up suitably to your own coding standards, and then any time you press Ctrl+Shift+F, NEON will render the code according to it. It could be very handy, if you have to edit or copy-paste third party code.</p>
<h3>Debugging</h3>
<p>NEON has great debugging capabilities with a full featured debugger. You have all the possibilities like in PDT, but NEON could install a toolbar to your browser, with which you can start easily debugging your application. If you are familiar with Zend Studio you know this could be very useful, for example before posting a form you can set &#8220;debug next page&#8221;. Unfortunately NEON currently not supports <a href="http://xdebug.org/">XDebug</a> only Zend Debugger.</p>
<h3> More wizards</h3>
<p>NEON supports more wizards for creating new PHP elements: class, interface, unit test, unit test case, and has built-in support creating <a href="http://framework.zend.com/">Zend Framework</a> related elements (controller, view, model etc.).</p>
<h3>Refactoring</h3>
<p><a href="http://www.refactoring.com/">Refactoring</a> a PHP application was earlier a tedious task, in <a href="http://www.phpeclipse.de/tiki-view_articles.php">PHPEclipse</a> or PDT you could only rename local variables. NEON has some new refactoring possibilities. You can rename, move your PHP files, and all the references for them will be automatically updated. It can help you organizing include files, for example it can collect possibly unused include statement and you can easily remove theme, or it can offer missing include statements.</p>
<p>You can also rename all PHP elements: classes, interfaces, functions, methods, and the references for theme will be updated too. You have the possibility to preview these updates. With these functions refactoring will be more easier, maybe more PHP developers will pay attention to this very important area.</p>
<h3>Profiling</h3>
<p>With NEON you can profile your application very easily. After profiling you can see overall information, detailed information about the running time of different files, execution statistics, execution flow.</p>
<p>NEON can provide <a href="http://en.wikipedia.org/wiki/Code_coverage">code coverage</a> information too, which can be very useful, when you try to find out how to organize your files (if some parts of your code need almost every time, it could be a good idea to put them in to one file, this way you can save some includes).</p>
<h3>Unit testing</h3>
<p>NEON supports generating <a href="http://en.wikipedia.org/wiki/Unit_testing">unit test</a> skeletons. You should choose the file with the class you want to test, and NEON generates a unit test for the given class. In the generated test class there will be an empty test method for all the public methods of the tested class, you should only fill theme.</p>
<p>NEON can run your tests and generates a visual report from theme, and additionally provide detailed code coverage information which could be very-very useful. NEON supports the <a href="http://www.phpunit.de/">PHPUnit</a> developed by <a href="http://sebastian-bergmann.de/">Sebastian Bergmann</a></p>
<h3>Code analyzer</h3>
<p>NEON can analyze your code and can find problematic parts (for example unreachable code). It can help developers to use good coding practices by giving theme suggestions about their code. This could be very useful even if you are an experienced developer: you can see immediately if you misspelled a variable name, or you left a global keyword (okey I know, you never use this latter <img src='http://blog.felho.hu/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> ).</p>
<h3>Settings</h3>
<p>NEON provide more settings than PDT, you can set up for example the coding standards related to your project, and a lot more other things related to the lot of features.</p>
<p>I think Eclipse is in default a very good developer tool, so it was a good decision from Zend to build the next generation PHP IDE  on top of it (consider that Eclipse has a great plug in architecture). NEON is already a very powerful tool, Zend did a great job about it, and I believe there are a lot of potential in it too.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.felho.hu/neon-zend-studio-for-eclipse.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>


