0

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.

6
Contributors
6
Replies
7
Views
8 Years
Discussion Span
Last Post by Ezzaral
1

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.

Votes + Comments
ah... THAT'S what i was looking for!
0

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. :)

6

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. :)

Votes + Comments
A vampire indeed; crimson colored "C" FTW! :-)
Brilliant!
clever :P
tee hee hee
You have too much free time... :)
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.