TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   The Lounge (http://www.talkphp.com/lounge/)
-   -   Prettifying Pasted Code on TalkPHP (http://www.talkphp.com/lounge/4563-prettifying-pasted-code-talkphp.html)

Wildhoney 06-16-2009 03:15 PM

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)

rguy84 06-17-2009 08:07 AM

GeSHi is great, I have it installed on my site. Do we use highlight within php bbcode?

Wildhoney 06-17-2009 11:19 AM

You specifying the language using the highlight tag.

[highlight=php]

:-)

rguy84 06-17-2009 06:11 PM

no sorry, I meant do we nest it within other tags? I posted some php with some html inside of it, the html showed up as plain text.

adamdecaf 06-17-2009 06:52 PM

Because HTML is not PHP, they are separate languages.

rguy84 06-17-2009 07:21 PM

well yes, I am asking would we use highlight within the php tag to nab the html.

adamdecaf 06-17-2009 08:12 PM

Well, we can try.

php Code:
<?php
// highlight=php
function hello(){
    print "Hello World!";
}
?>
<p>
   <?php
     hello();
   ?>
</p>

PHP Code:

<?php
// php
function hello(){
    print 
"Hello World!";
}
?>
<p>
   <?php
     hello
();
   
?>
</p>

Code:

<?php
// code
function hello(){
    print "Hello World!";
}
?>
<p>
  <?php
    hello();
  ?>
</p>


Wildhoney 06-25-2009 11:47 AM

I don't think it works, does it? :-( It would be nice because people have posted code where it contains both PHP and HTML. If I paste such code then I usually choose the language that is most prevalent in the code.

Don\'t worry about that too much.

rguy84 06-25-2009 05:24 PM

That is a bummer.

dhaval 07-17-2009 10:13 AM

Hello,
Can we chat?
because i know that my query is beyond to solution through quick replies.

Salathe 07-17-2009 10:18 AM

dhaval, stop asking "can we chat?" and start asking actual questions.

Edit: Amazingly, dhaval actually asked a question but it was in reply to this thread instead of a new one. I\'ve since moved it to a new thread.

Village Idiot 07-17-2009 03:54 PM

Quote:

Originally Posted by dhaval (Post 27135)
Hello,
Can we chat?
because i know that my query is beyond to solution through quick replies.

I've been helping people on forums for quite a few years now, you would be the first that would be true for.

adamdecaf 07-17-2009 03:56 PM

Quote:

Originally Posted by dhaval (Post 27135)
Hello,
Can we chat?
because i know that my query is beyond to solution through quick replies.

Your question is not unsolvable, it's that you have not posted any sample code nor explained your problem in a proper manor (understandable aka. concise).

suneelpavu 02-20-2010 12:40 PM

I don't think it works, does it? It would be nice because people have posted code where it contains both PHP and HTML. If I paste such code then I usually choose the language that is most prevalent in the code.

Don't worry about that too much.

jonathan2340 03-23-2012 12:26 PM

Great informatiom. I just want to say you thanks for all this.

amxiu12 01-04-2013 02:46 AM

lancel sac
 
lancel sac

Ici, rire ensemble le pain, les bourses d'huile chatoyantes, Bagage banlieue tag, le l'huile de la peau Cambridge paquet, Meg Shu Nvbao, tout, il ya toujours un bon pour vous.

sac lancel

Big bag pouvez mettre vos articles préférés ont été chargés dans le report, mais tendre la main et de trouver quelque chose d'embarrassant et gênant lors de l'achat vous dire, lancel bags on sale vous avez besoin d'un compact mini-paquet.

lancel bags

Mini paquet est petit et exquis achats de faciliter avec, il suffit de mettre quelques points importants peuvent main peut aussi assumer, les points forts, et une gamme d'enfants est également plein. lancel bag sale En particulier, le sac sur le bord dent de requin est son secret incarnations, un pull, ensemble, peuvent vous donner de multiples facettes infection sentiment style, bien sûr, de sécurité et de haute fonctionnalités pratiques en font un rare moment section forfaits chaud.mankag-djia21

http://www.lancelbagsale.com


All times are GMT. The time now is 05:54 PM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0