Language and colour tags
If I leave the language out of the code, then I can use colour just fine, like so
printf("%d. file has been created\r",i);
fflush(stdout);
But if I add a language, say 'c', then it all goes pear shaped and the colour tags are no longer parsed.
printf("%d. file has been created\r",i);
fflush(stdout);
Salem
Posting Sage
11,531 posts since Dec 2005
Reputation Points: 5,862
Solved Threads: 953
That's the intended behaviour. When using language-specific tags, snippets are already color-coded. If you want to point out something specific, refer to it by line. If you absolutely have to point something out via color, use non language specific tags.
cscgal
The Queen of DaniWeb
19,420 posts since Feb 2002
Reputation Points: 1,474
Solved Threads: 229
Exactly.
I thought that was blatantly obvious.
I mean if you tagged something as red with c++ code tags it would hardly stand out amongst the other mix of colours.
iamthwee
Posting Expert
5,950 posts since Aug 2005
Reputation Points: 1,543
Solved Threads: 439
One possibility to consider is to allow BOLD and ITALIC using language-specific tags. Just a thought.
WaltP
Posting Sage w/ dash of thyme
10,474 posts since May 2006
Reputation Points: 3,342
Solved Threads: 938
Bold and italic tags are already being used with the language-specific tags for specific keywords. For example, in the line
printf("%d. file has been created\r",i);
the word "printf" is actually in bold in contrast to the rest of the line. However, bold font is hard to distinguish in Courier New (or any fixed width font, for that matter). In fact, when I was very anti-color, and before we had syntax-specific code tags, the reason I conceded to allowing color was because people pointed out that bold and italic tags were not doing a good enough job pointing out specific lines in code.
cscgal
The Queen of DaniWeb
19,420 posts since Feb 2002
Reputation Points: 1,474
Solved Threads: 229
Wouldn't it be better if your parser at least removed the color tags from syntax-highlighted code? Some people aren't aware that color tags don't work in syntax-highlighted code tags (or they paste it from their editor, which for some reason has the code all colored), and then all we see is a bunch of BBCode crap.
John A
Vampirical Lurker
7,630 posts since Apr 2006
Reputation Points: 2,240
Solved Threads: 339
Wouldn't it be better if your parser at least removed the color tags from syntax-highlighted code? Some people aren't aware that color tags don't work in syntax-highlighted code tags (or they paste it from their editor, which for some reason has the code all colored), and then all we see is a bunch of BBCode crap.
Nyah. If they want to screw up their code and post without a PREVIEW, let them. We just don't have to read it since they didn't care enough to verify their post.:icon_twisted:
WaltP
Posting Sage w/ dash of thyme
10,474 posts since May 2006
Reputation Points: 3,342
Solved Threads: 938
What if someone wants to type code that uses the [param=value] format? If someone types [x=y] in their code it should be stripped?
cscgal
The Queen of DaniWeb
19,420 posts since Feb 2002
Reputation Points: 1,474
Solved Threads: 229
What if someone wants to type code that uses the [param=value] format? If someone types [x=y] in their code it should be stripped?
Well, you would only strip[color=xxx], [b], [i], etc. And considering that it would be parsed anyway if they had just used a normal [code] tag, what difference does it make?
John A
Vampirical Lurker
7,630 posts since Apr 2006
Reputation Points: 2,240
Solved Threads: 339
Because this way people have a method for when they NEED to use such things in their code. If both code methods stripped them, they'd be SOL to display any code in bbcode format.
cscgal
The Queen of DaniWeb
19,420 posts since Feb 2002
Reputation Points: 1,474
Solved Threads: 229
>If both code methods stripped them, they'd be SOL to display any code in bbcode format.
There's always [ noparse ].
[color=red]text[/color]
I'm guessing that people who need to post such bbcode in code tags that know enough about the code tag behavior are also aware of the noparse tag. It seems like a pretty weak argument, in any case.
John A
Vampirical Lurker
7,630 posts since Apr 2006
Reputation Points: 2,240
Solved Threads: 339
> It seems like a pretty weak argument, in any case.
It's just as weak as the argument as to why code snippets should start behaving differently than they ever have before by starting to strip characters. :)
cscgal
The Queen of DaniWeb
19,420 posts since Feb 2002
Reputation Points: 1,474
Solved Threads: 229
Addendum: You should also note that someone wouldn't necessarily be intentionally typing bbcode and therefore think of using the noparse tag. Anything in the format [x=y] would be parsed.
cscgal
The Queen of DaniWeb
19,420 posts since Feb 2002
Reputation Points: 1,474
Solved Threads: 229
>Anything in the format [x=y] would be parsed.
I'm not requesting that all BBcode is parsed, just that [color], [b], [i], and [u] are stripped (assuming the parser finds their respective closing tags). The only time I've ever seen the aforementioned tags present in code tags is when someone was trying to format their code.
John A
Vampirical Lurker
7,630 posts since Apr 2006
Reputation Points: 2,240
Solved Threads: 339
That's really hard to integrate into our existing highlighter.
cscgal
The Queen of DaniWeb
19,420 posts since Feb 2002
Reputation Points: 1,474
Solved Threads: 229