Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 158 Stack Exchange communities.

What is meta?
Here's how it works:
  1. Any Stack Exchange user can ask a question
  2. The community provides support, votes on ideas, and reports bugs
  3. Your voice helps shape the way Stack Exchange operates

I'm looking for something to take a link like

http://en.wikipedia.org/wiki/Solid_(object-oriented_design)

And make it into

http://en.wikipedia.org/wiki/Solid_%28object-oriented_design%29

so that it can be pasted into a comment automatically. Even better would be if said extension could do the replacement whenever I paste anything into a stack exchange site that looks like a URL.

Does such a thing exist?

share|improve this question

Rather than look up the HTML entities for _, (, and ), I just modify the URL to include a backslash before each. To use your example, I take:

http://en.wikipedia.org/wiki/Solid_(object-oriented_design)

and turn it into:

http://en.wikipedia.org/wiki/Solid\_\(object-oriented\_design\)

Then use that twice; once inside square brackets, and once inside parenthesis*:

[http://en.wikipedia.org/wiki/Solid\_\(object-oriented\_design\)](http://en.wikipedia.org/wiki/Solid\_\(object-oriented\_design\))

which then becomes:

http://en.wikipedia.org/wiki/Solid_(object-oriented_design)

It's a little convoluted, but I don't have to recall specific entities, run an extension, or do anything that doesn't work cross-browser.

* Preview makes it look as if you don't need this step—but if you skip it, the link in your post won't work.

share|improve this answer
    
    
@Billy - looks like a successful test to me. – Dori Dec 30 '10 at 22:48
    
+1 because this makes it easier, but I'm still looking for an extension that can do it. – Billy ONeal Dec 30 '10 at 23:42
    
@Billy - it would be easy enough to write a bookmarklet; let me know if you need one. And if you don't get an answer with an extension, please accept this one. – Dori Dec 30 '10 at 23:58
    
Will do lol. – Billy ONeal Dec 30 '10 at 23:59

I've built a simple Ubiquity (not Chrome, but it is useful to post it here I suppose) command to do this.

Install - Source
(Non-Ubiquity using users will just see a blank page)

Name: encode or url encode

The code is very simple, as JavaScript has it's own encodeURI function, but WMD is a little more strict about what you can put in there - ( ) : are also encoded. If I missed anything just drop a comment here.

var protocol = url.substring(0, url.indexOf('://') + 3)
return protocol + encodeURI(url).substring(url.indexOf('://') + 3).replace(/\(/g, '%28').replace(/\)/g, '%29%').replace(/:/g, '%3A');
share|improve this answer

I have used bit.ly to shorten the link and got it working.

Anyway I agree that there should be a better way to do it

share|improve this answer

You can do it with JavaScript's escape() function.

(function() {
    alert(escape(prompt('URL to escape:')));
})();

Bookmarklet format:

(function(){alert(escape(prompt('URL to escape:')));})();
share|improve this answer

You must log in to answer this question.

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