Stackedit/js/extensions/emailConverter.js

18 lines
655 B
JavaScript
Raw Normal View History

2013-06-22 23:48:57 +00:00
define([
"classes/Extension",
], function(Extension) {
2013-05-29 19:55:23 +00:00
2013-06-22 23:48:57 +00:00
var emailConverter = new Extension("emailConverter", "Markdown Email", true);
emailConverter.settingsBlock = '<p>Converts email adresses in the form &lt;email@example.com&gt; into clickable links.</p>';
2013-05-29 19:55:23 +00:00
emailConverter.onEditorConfigure = function(editor) {
editor.getConverter().hooks.chain("postConversion", function(text) {
return text.replace(/<(mailto\:)?([^\s>]+@[^\s>]+\.\S+?)>/g, function(match, mailto, email) {
return '<a href="mailto:' + email + '">' + email + '</a>';
});
});
};
return emailConverter;
2013-05-27 23:27:38 +00:00
});