3

I posted a question in the and noticed the code wasn't highlighted. I think it would be appropriate to associate with the Javascript language, similar to for instance backbone.js.

I know how to get the highlighting to work: tag it with or use Syntax highlighting language hints. I could do that, but (as I see it now) it's a d3.js question. If I'd tag it with Javascript, that would be just to get the highlighting. I wouldn't tag an asp.net question with c#, just to get the highlighting to work.

If that is the preferred way instead of requesting associating a tag with a language, I'll be happy to do that, just let me know in an answer here.

4
  • @Close voter: why is this off topic?
    – Marijn
    Jul 13, 2012 at 9:13
  • Why would you not also tag that question with javascript? Jul 13, 2012 at 12:15
  • Well, I could do that, but (as I see it now) it's a d3.js question. If I'd tag it with Javascript, that would be just to get the highlighting. I wouldn't tag an asp.net question with c#, just to get the highlighting to work. I'll edit my question a bit.
    – Marijn
    Jul 13, 2012 at 12:32
  • 4
    Okay, that makes sense. I do see a lot of uses of the tag by itself, and it's rarely used in conjunction with other languages that aren't JavaScript, so I guess it won't hurt anything. I went ahead and applied lang-js to the d3.js tag. Jul 13, 2012 at 12:38

2 Answers 2

1

You can use an HTML comment in your answer to specify a language for syntax highlighting. From Markdown help:

To manually specify the language of a code block, insert an HTML comment like this before the block:

<!-- language: lang-js -->

    setTimeout(function () { alert("JavaScript"); }, 1000);

You can also specify a language for all code blocks in the answer with:

<!-- language-all: lang-js -->

I've edited that into your answer.

5
  • Thanks, I'm familiar with that option!
    – Marijn
    Jul 13, 2012 at 9:11
  • Yeah, I agree it would probably be easier if it was picked up automatically, but thought this could be useful for some people. It took me ages to realise you could do this! Jul 13, 2012 at 9:12
  • It's good to know indeed; especially when you have tags with conflicting highlighting languages.
    – Marijn
    Jul 13, 2012 at 9:14
  • Thanks for the edit to my question, but I'll remove it so that my feature request is clear for everyone.
    – Marijn
    Jul 13, 2012 at 9:16
  • If this can't be implemented I'll add it again later.
    – Marijn
    Jul 13, 2012 at 9:17
0

Bill fixed this, see his comments to my question above .

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .