how to use [code] tags?

specifically, how do i type the opening and closing code tags in my post, as an example, without causing the code tags to activate?

like this:


HEY NOOB! USE CODE TAGS, AIGHT???

<code=c>
int main(void)
{
// your noob code here
return 0;
}
</code>

with [ square ] instead of < angle > brackets of course.

Use

Without a space on either side of = . ;)

Without a space on either side of =

Used to do the same before Peter_Budo told me about the noparse tags.

You can use the noparse tags around your code block like this :-

[noparse] [code=xyz]

[/code]
[/noparse]

You can read more about the various vB tags here.

commented: ah... THAT'S what i was looking for! +7

Used to do the same before Peter_Budo told me about the noparse tags.

You can use the noparse tags around your code block like this :-

[noparse] [code=xyz]

[/code]
[/noparse]

You can read more about the various vB tags here.

Thanks! I didn't know about tags. :)[noparse] tags. :)

The only problem with explaining the usage of noparse tags is that it becomes somewhat cumbersome to explain the exact usage of the noparse tags themselves. For example, consider the following:

Use noparse tags like this:
[noparse] [code] code goes here [/code] [/noparse]

The above example was created by using two nested levels of noparse tags. But that's so dull and boring! Some bbcode formatting would help make our theoretical explanation clearer. The problem is of course, you can't put bbcode formatting inside a noparse tag because of the very nature of a noparse tag. Therefore, we have to resort to a little bit of bbcode black magic. Using the fact that [some[b][/b]tag] will be parsed into [sometag], we can quickly see that we can implement the same intended functionality of noparse while still being able to selectively enable the bbcode parser.

Thus, we can write the following in our post:
[no[[b][/b]b][/b]parse] [b[b][/b]][co[[b][/b]b][/b]de=[col[[b][/b]b][/b]or="red"]c[/color]][/b] [inlinecode]code goes here[/inlinecode] [b]
[/code][/b] [/noparse]

Which parses down nicely to become:

[noparse] [code=c] code goes here
[/code]
[/noparse]

There. Now you can with confidence explain to other people not only how to use code tags, but how to clearly use noparse tags with full bbcode formatting. :)

commented: You have too much free time... :) +16
commented: tee hee hee +6
commented: clever :P +8
commented: Brilliant! +14
commented: A vampire indeed; crimson colored "C" FTW! :-) +27

I am getting a head ache.

And if you don't like having to type so much to yell at the noobs, the Clippings add-on for Firefox can it effortless :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.