# URLs with ' are not recognized in preview window

Examples:

The original Markdown was:

1. http://en.wikipedia.org/wiki/Two's_complement
2. [two's complement][1]
3. [two's complement](http://en.wikipedia.org/wiki/Two's_complement)

[1]: http://en.wikipedia.org/wiki/Two's_complement


Shows in preview (when editing) as:

1. http://en.wikipedia.org/wiki/Two's_complement
2. two's complement
3. two's complement
-
What about those of us with less than the required rep to edit? – The Unhandled Exception May 6 '10 at 22:15
@Josh: You can build the “revisions” URL yourself (and use “view source”) even for single revision questions/answers: http://[sofu].com/posts/[num]/revisions meta.stackexchange.com/questions/41391/… – Chris Johnsen May 12 '10 at 4:05
@Chris: This question is about how it looks in the preview window when editing, not the markdown source. – Gnome May 12 '10 at 4:57
@Josh: You can type the markdown into either a new question ('ask question' button at the top) or an answer (below) to see how the preview behaves. (As far as I know, both kinds of previews should be identical.) – Gnome May 12 '10 at 4:58
@The Cat: The question at the time of Josh's comment did not include the code block that showed the markup (see the timeline). Also, since it only had one revision, it did not include the “edited … ago” link to the ‘revisions’ page. My comment tells how a non-editor can arrange to see the markup for a single revision post (manually construct the URL to the ‘revisions’ page; then use the “view source” link). – Chris Johnsen May 12 '10 at 6:32

Workaround is using %27 instead of '

1. http://en.wikipedia.org/wiki/Two%27s_complement
2. [two's complement][1]
3. [two's complement](http://en.wikipedia.org/wiki/Two%27s_complement)

[1]: http://en.wikipedia.org/wiki/Two%27s_complement


will be

-
Actually, just using [ text ]( href ) works just fine when posted, just not in the preview. – Gnome May 12 '10 at 4:55
That's not even a workaround, but the required way reserved characters should be encoded. Nice if some editors or browsers make it easy for you, but I think it's still a reserved character... – Arjan May 12 '10 at 5:39
@The Cat: yes, I know that it works once it is posted. But this bug report is specifically about the preview window. @S.Mark thanks for the suggestion, but it seems rather complicated to me. I wonder why the markdown can not just be parsed in the same way as it is later parsed (when posted). – tanascius May 12 '10 at 15:47

And a quick fix could be, changing following 3 regexes from

/^(<a\shref="(\#\d+|(https?|ftp):\/\/[-A-Za-z0-9+&@#\/%?=~_|!:,.;]+)"(\stitle="[^"<>]+")?\s?>|<\/a>)$/i /(^|\s)(https?|ftp)(:\/\/[-A-Z0-9+&@#\/%?=~_|!:,\.;]*[-A-Z0-9+&@#\/%=~_|])($|\W)/gi

/<((https?|ftp):[^'">\s]+)>/gi


to

/^(<a\shref="(\#\d+|(https?|ftp):\/\/[-A-Za-z0-9+&@#\/%?=~_|!:,.;']+)"(\stitle="[^"<>]+")?\s?>|<\/a>)$/i /(^|\s)(https?|ftp)(:\/\/[-A-Z0-9+&@#\/%?=~_|!:,\.;']*[-A-Z0-9+&@#\/%=~_|])($|\W)/gi

/<((https?|ftp):[^">\s]+)>/gi


in wmd.js

Note: I am not sure those could cause different flaws though :)

-