TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
 
 
LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old 06-16-2009, 03:15 PM   #1 (permalink)
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
Wildhoney is on a distinguished road
Application Go Prettifying Pasted Code on TalkPHP

You may notice that when you post code, you can wrap it in a few BBCodes. Mostly we use [code], [php] and [highlight], as described below.

Some people, however, don't wrap their code in any BBCodes at all, which ends up looking messy, and likely to immediately deter people from reading your code, thus replies will be scarce.

Option 1: [code]

At the very least we should be using this BBCode because at least it preserves white-space, tabbing being the most important. However, when using this BBCode, there is no colour highlighting and so whilst it's acceptable, it's not perfect.

This really should be limited to code that is in a language that is unsupported by any other of our BBCodes. Pseudo code, for instance.

Option 2: [php]

As this is a PHP forum, if you hadn't noticed, I imagine most people will want to use this tag. It is the most popular, and will get the job done nicely. It has all the advantages of the aforementioned BBCode, but with the added nicety of PHP syntax highlighting.

This, whilst more than fine, is not quite as advanced as the last of the BBCode tags, but when it comes to PHP highlighting, this or the subsequent will be more than appreciated.

One thing though, please do not use this tag for non-PHP code, as the highlighting will likely resemble that of a firework in a paint pot.

Option 3: [highlight]

This BBCode is something I added to TalkPHP because it allows for much more advanced syntax highlighting. I use this for PHP as well because I find it looks nicer than the antecedent BBCode, but each to their own.

The highlight BBCode uses Geshi syntax highlighting, which supports a wide-range of programming languages. To specify the language you wish to place in between the BBCode tags, you can do the following. For example, if you wish to show PHP:

[highlight=php]/* PHP code */[/highlight]

Albeit this is not a comprehensive list of supported languages, but the ones that are most common on TalkPHP:
  • highlight=php (PHP)
  • highlight=javascript (JavaScript)
  • highlight=html4strict (HTML)
  • highlight=css (CSS)
  • highlight=xml (XML)
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.

Last edited by Wildhoney : 06-25-2009 at 07:49 PM.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is offline  
Reply With Quote
 



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
TalkPHP IRC: Come and join us! Wildhoney News and Announcements 50 04-13-2013 08:14 AM
Tips to Improve Your Coding and Projects Village Idiot Tips & Tricks 45 12-03-2012 07:46 AM
Writing Clean Code Village Idiot Tips & Tricks 10 06-25-2012 12:35 PM
Game: Let's Develop Something Crazy! Wildhoney The Lounge 25 05-23-2009 09:18 PM
Snipply.com - Code snippet website codyodell Show Off 27 04-13-2008 02:09 PM


All times are GMT. The time now is 10:44 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design