Reputation:
Imagine a regular webpage where somebody wrote
[this *unprocessed* markdown](https://stackoverflow.com)...
Is there a bookmarklet that I can click such that it processes any raw markdown on the page?
It does not have to work everywhere, or accurately, just reasonably simple websites.
What I have tried so far:
javascript:(function(){
document.body.appendChild(document.createElement('script'))
.src='https://cdnjs.cloudflare.com/ajax/libs/showdown/1.7.2/showdown.min.js';
var converter = new showdown.Converter();
//and then?
})();`
But here I am already running into ReferenceError: showdown is not defined
.
I have seen http://heckyesmarkdown.com but that does literally the opposite of what I want.
Upvotes: 1
Views: 94
Reputation: 5299
I think you just have to add a small timeout for the markdown library to load. Let's say, 3 seconds like so:
javascript:(function(){
document.body.appendChild(document.createElement('script'))
.src='https://cdnjs.cloudflare.com/ajax/libs/showdown/1.7.2/showdown.min.js';
setTimeout("var converter = new showdown.Converter(); alert(converter);", 3000);
})();
Upvotes: 0