vmg / sundown

Standards compliant, fast, secure markdown processing library in C
1.99k stars 385 forks source link

Bookmarklets as links #105

Open guide42 opened 12 years ago

guide42 commented 12 years ago

Hello,

I tried to include bookmarklets as links, and a simple example works great, but a real one no.


File A: success

Header
======

This is a [bookmarklet].

[bookmarklet]: javascript:(function(){alert('Hello');})();
<h1>Header</h1>

<p>This is a <a href="javascript:(function()%7Balert(&#x27;Hello&#x27;);%7D)();">bookmarklet</a>.</p>

File B: fails

Header
======

This is a [bookmarklet].

[bookmarklet]: javascript:(function(d){var i,k=d.getElementsByTagName('link'),c=['//twitter.github.com/bootstrap/assets/css/bootstrap.css'],h='<link rel=stylesheet type=text/css href=%s />';for(i=0;i<k.length;i++)(k[i].type=='text/css'||k[i].rel=='stylesheet')&&k[i].parentNode.removeChild(k[i]);for(i=0;i<c.length;i++)d.head.innerHTML+=h.replace('%s',c[i]);})(document);
<h1>Header</h1>

<p>This is a [bookmarklet].</p>

<p>[bookmarklet]: javascript:(function(d){var i,k=d.getElementsByTagName(&#39;link&#39;),c=[&#39;//twitter.github.com/bootstrap/assets/css/bootstrap.css&#39;],h=&#39;<link rel=stylesheet type=text/css href=%s />&#39;;for(i=0;i&lt;k.length;i++)(k[i].type==&#39;text/css&#39;||k[i].rel==&#39;stylesheet&#39;)&amp;&amp;k[i].parentNode.removeChild(k[i]);for(i=0;i&lt;c.length;i++)d.head.innerHTML+=h.replace(&#39;%s&#39;,c[i]);})(document);</p>