forked from Hypercubed/angular-marked
-
Notifications
You must be signed in to change notification settings - Fork 0
/
angular-marked.min.js
executable file
·6 lines (6 loc) · 1.3 KB
/
angular-marked.min.js
1
2
3
4
5
6
/*
* angular-marked 0.0.16
* (c) 2015 J. Harshbarger
* Licensed MIT
*/
!function(){"use strict";"undefined"!=typeof module&&"object"==typeof exports&&(module.exports="hc.marked"),angular.module("hc.marked",[]).provider("marked",function(){var a=this;a.setRenderer=function(a){this.renderer=a},a.setOptions=function(a){this.defaults=a},a.$get=["$window","$log",function(b,c){var d=function(){return"undefined"!=typeof module&&"object"==typeof exports?require("marked"):b.marked||marked}();if(angular.isUndefined(d))return void c.error("angular-marked Error: marked not loaded. See installation instructions.");if(a.renderer){for(var e=new d.Renderer,f=Object.keys(a.renderer),g=f.length;g--;)e[f[g]]=a.renderer[f[g]];a.defaults=a.defaults?a.defaults.renderer=e:a.defaults={renderer:e}}return d.setOptions(a.defaults),d}]}).directive("marked",["marked",function(a){return{restrict:"AE",replace:!0,scope:{opts:"=",marked:"="},link:function(b,c,d){function e(a){if(!a)return a;var b,c,d,e=a.replace(/\t/g," ").split(/\r?\n/),f=null,g=e.length;for(b=0;g>b;b++)d=e[b],c=d.match(/^(\s*)/)[0].length,c!==d.length&&(f=f>c||null===f?c:f);if(null!==f&&f>0)for(b=0;g>b;b++)e[b]=e[b].substr(f);return e.join("\n")}function f(d){d=e(d||""),c.html(a(d,b.opts||null))}f(b.marked||c.text()||""),d.marked&&b.$watch("marked",f)}}}])}();