javascript - Ruby on Rails with Showdown adding extensions error -
i have code directly from:
https://github.com/coreyti/showdown
i created extensions dir , added twitter.js following code:
var demo = function(converter) { return [ // replace escaped @ symbols { type: 'lang', regex: '\\@', replace: 'red' } ]; }
on page have:
<%= javascript_include_tag "showdown" %> <%= javascript_include_tag "extensions/twitter.js" %> <script type="text/javascript"> var converter = new showdown.converter({ extensions: 'twitter' }); </script> <script type="text/javascript"> $('#design_description').keyup(function () { var converter = new showdown.converter(); var impt = converter.makehtml($(this).val()); $(".preview").html(impt); }); </script>
this web console error getting:
[15:04:30.945] uncaught exception: extension 'undefined' not loaded. either not found or not valid extension.
any appreciated.
wrap demo function:
(function(){ var demo = function(converter) { return [ // replace escaped @ symbols { type: 'lang', regex: '\\@', replace: 'red' } ]; }; // client-side export if (typeof window !== 'undefined' && window.showdown && window.showdown.extensions) { window.showdown.extensions.demo = demo; } // server-side export if (typeof module !== 'undefined') module.exports = demo; }());
Comments
Post a Comment