What is meta? ×
Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 128 Stack Exchange communities.

As pointed out in this answer it is possible to create a link in formatted code. But, only by using explicit HTML. Since I think creating a link to documentation within a code block is a fairly common use case, it should be possible to do this using the GUI.

I should be able to highlight some code. Press the code format button code formatting button. Then highlight some code within that and press the link button and create a link.

Today this results in:

[parseInt][3]("01", 10);

it should result in:

parseInt("01",10);
share|improve this question
7  
So. How would you differentiate that from a multidimentional array? =D –  J. Steen Jan 31 '13 at 18:22
1  
Since I think creating a link to documentation within a code block is a fairly common use case I've never needed to do that. If I want to post a link to documentation it'll usually be in the explanation before or after the code block. –  Servy Jan 31 '13 at 18:42
    
@Servy That is what I do too. But, if it were easy to link to docs from within a code block I would do it. –  Adam Jan 31 '13 at 18:45
2  
Oh no, one mistake in your Objective-C and all hell breaks loose. Let's please leave the code-blocks as pure as possible. –  Bart Jan 31 '13 at 18:57
add comment

2 Answers 2

Not sure I like this suggestion.

Whenever I've needed to throw some code into the mix with a reference, I would write a blurb about the code block, including a link to the API, then use the code in action.

I don't see a reason to mix code with links. Code is code.

share|improve this answer
add comment

A link title with code formatting is possible, as when you are linking to the docs for a particular class or function:

You should use [`-[NSString rangeOfString:options:]`][1] for this, passing [`NSLiteralSearch`][2] for the `options:` argument.

becomes:

You should use -[NSString rangeOfString:options:] for this, passing NSLiteralSearch for the options: argument.

I think this is sufficient. (Note: Meta doesn't style links differently, but mouseover those first two code-formatted bits and you'll see the links.) Putting links into larger code blocks doesn't make a whole lot of sense to me. Code needs to be exact; mixing up some other language with makes editing more confusing than it needs to be. (It also makes the mouse selection target touchier -- dammit, I was trying to highlight the text, not click the link!)

As a bonus, putting links in the English text outside the code block encourages you to do a little explanation, too, which nearly always increases the answer's quality.

I don't have any great positive argument as to why this shouldn't be done; it's more that I think there's no need for it. Leave the code blocks for the machine.

share|improve this answer
add comment

You must log in to answer this question.

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