angular-marked
Advanced tools
Comparing version 1.2.1 to 1.2.2
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.angularMarked = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ | ||
module.exports = function unindent(text) { | ||
if (!text) { | ||
return text; | ||
} | ||
var lines = text | ||
.replace(/\t/g, ' ') | ||
.split(/\r?\n/); | ||
var min = null; | ||
var len = lines.length; | ||
var i; | ||
for (i = 0; i < len; i++) { | ||
var line = lines[i]; | ||
var l = line.match(/^(\s*)/)[0].length; | ||
if (l === line.length) { | ||
continue; | ||
} | ||
min = (l < min || min === null) ? l : min; | ||
} | ||
if (min !== null && min > 0) { | ||
for (i = 0; i < len; i++) { | ||
lines[i] = lines[i].substr(min); | ||
} | ||
} | ||
return lines.join('\n'); | ||
}; | ||
},{}],2:[function(require,module,exports){ | ||
/* | ||
* angular-marked | ||
* (c) 2014 J. Harshbarger | ||
* (c) 2014 - 2016 J. Harshbarger | ||
* Licensed MIT | ||
*/ | ||
/* jshint undef: true, unused: true */ | ||
/* global angular, marked */ | ||
@@ -13,2 +43,4 @@ | ||
var unindent = require('./strip-indent'); | ||
/** | ||
@@ -75,6 +107,2 @@ * @ngdoc overview | ||
module.exports = 'hc.marked'; | ||
angular.module('hc.marked', []) | ||
/** | ||
@@ -166,3 +194,3 @@ * @ngdoc service | ||
.provider('marked', function () { | ||
function markedProvider() { | ||
var self = this; | ||
@@ -199,3 +227,3 @@ | ||
m = require('marked'); | ||
} catch (e) { | ||
} catch (err) { | ||
m = $window.marked || marked; | ||
@@ -224,3 +252,3 @@ } | ||
function wrapNonBindable(string) { | ||
return "<span ng-non-bindable>" + string + "</span>"; | ||
return '<span ng-non-bindable>' + string + '</span>'; | ||
} | ||
@@ -245,3 +273,3 @@ | ||
}]; | ||
}) | ||
} | ||
@@ -315,4 +343,4 @@ // xTODO: filter and tests */ | ||
*/ | ||
.directive('marked', ['marked', '$templateRequest', '$compile', function (marked, $templateRequest, $compile) { | ||
markedDirective.$inject = ['marked', '$templateRequest', '$compile']; | ||
function markedDirective(marked, $templateRequest, $compile) { | ||
return { | ||
@@ -328,9 +356,6 @@ restrict: 'AE', | ||
link: function (scope, element, attrs) { | ||
set(scope.marked || element.text() || ''); | ||
if (attrs.marked) { | ||
set(scope.marked); | ||
scope.$watch('marked', set); | ||
} | ||
if (attrs.src) { | ||
} else if (attrs.src) { | ||
scope.$watch('src', function (src) { | ||
@@ -344,36 +369,8 @@ $templateRequest(src, true).then(function (response) { | ||
}); | ||
} else { | ||
set(element.text()); | ||
} | ||
function unindent(text) { | ||
if (!text) { | ||
return text; | ||
} | ||
var lines = text | ||
.replace(/\t/g, ' ') | ||
.split(/\r?\n/); | ||
var min = null; | ||
var len = lines.length; | ||
var i; | ||
for (i = 0; i < len; i++) { | ||
var line = lines[i]; | ||
var l = line.match(/^(\s*)/)[0].length; | ||
if (l === line.length) { | ||
continue; | ||
} | ||
min = (l < min || min === null) ? l : min; | ||
} | ||
if (min !== null && min > 0) { | ||
for (i = 0; i < len; i++) { | ||
lines[i] = lines[i].substr(min); | ||
} | ||
} | ||
return lines.join('\n'); | ||
} | ||
function set(text) { | ||
text = unindent(text || ''); | ||
text = unindent(String(text || '')); | ||
element.html(marked(text, scope.opts || null)); | ||
@@ -386,5 +383,11 @@ if (scope.$eval(attrs.compile)) { | ||
}; | ||
}]); | ||
} | ||
},{"marked":"marked"}]},{},[1])(1) | ||
module.exports = | ||
angular.module('hc.marked', []) | ||
.directive('marked', markedDirective) | ||
.provider('marked', markedProvider) | ||
.name; | ||
},{"./strip-indent":1,"marked":"marked"}]},{},[2])(2) | ||
}); |
@@ -1,1 +0,1 @@ | ||
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.angularMarked=f()}})(function(){var define,module,exports;return function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s}({1:[function(require,module,exports){"use strict";module.exports="hc.marked";angular.module("hc.marked",[]).provider("marked",function(){var self=this;self.setRenderer=function(opts){this.renderer=opts};self.setOptions=function(opts){this.defaults=opts};self.$get=["$log","$window",function($log,$window){var m;try{m=require("marked")}catch(e){m=$window.marked||marked}if(angular.isUndefined(m)){$log.error("angular-marked Error: marked not loaded. See installation instructions.");return}var r=new m.Renderer;if(self.renderer){var o=Object.keys(self.renderer);var l=o.length;while(l--){r[o[l]]=self.renderer[o[l]]}}function wrapNonBindable(string){return"<span ng-non-bindable>"+string+"</span>"}var renderCode=r.code.bind(r);r.code=function(code,lang,escaped){return wrapNonBindable(renderCode(code,lang,escaped))};var renderCodespan=r.codespan.bind(r);r.codespan=function(code){return wrapNonBindable(renderCodespan(code))};self.defaults=self.defaults||{};self.defaults.renderer=r;m.setOptions(self.defaults);return m}]}).directive("marked",["marked","$templateRequest","$compile",function(marked,$templateRequest,$compile){return{restrict:"AE",replace:true,scope:{opts:"=",marked:"=",compile:"@",src:"="},link:function(scope,element,attrs){set(scope.marked||element.text()||"");if(attrs.marked){scope.$watch("marked",set)}if(attrs.src){scope.$watch("src",function(src){$templateRequest(src,true).then(function(response){set(response)},function(){set("");scope.$emit("$markedIncludeError",attrs.src)})})}function unindent(text){if(!text){return text}var lines=text.replace(/\t/g," ").split(/\r?\n/);var min=null;var len=lines.length;var i;for(i=0;i<len;i++){var line=lines[i];var l=line.match(/^(\s*)/)[0].length;if(l===line.length){continue}min=l<min||min===null?l:min}if(min!==null&&min>0){for(i=0;i<len;i++){lines[i]=lines[i].substr(min)}}return lines.join("\n")}function set(text){text=unindent(text||"");element.html(marked(text,scope.opts||null));if(scope.$eval(attrs.compile)){$compile(element.contents())(scope.$parent)}}}}}])},{marked:"marked"}]},{},[1])(1)}); | ||
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.angularMarked=f()}})(function(){var define,module,exports;return function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s}({1:[function(require,module,exports){module.exports=function unindent(text){if(!text){return text}var lines=text.replace(/\t/g," ").split(/\r?\n/);var min=null;var len=lines.length;var i;for(i=0;i<len;i++){var line=lines[i];var l=line.match(/^(\s*)/)[0].length;if(l===line.length){continue}min=l<min||min===null?l:min}if(min!==null&&min>0){for(i=0;i<len;i++){lines[i]=lines[i].substr(min)}}return lines.join("\n")}},{}],2:[function(require,module,exports){"use strict";var unindent=require("./strip-indent");function markedProvider(){var self=this;self.setRenderer=function(opts){this.renderer=opts};self.setOptions=function(opts){this.defaults=opts};self.$get=["$log","$window",function($log,$window){var m;try{m=require("marked")}catch(err){m=$window.marked||marked}if(angular.isUndefined(m)){$log.error("angular-marked Error: marked not loaded. See installation instructions.");return}var r=new m.Renderer;if(self.renderer){var o=Object.keys(self.renderer);var l=o.length;while(l--){r[o[l]]=self.renderer[o[l]]}}function wrapNonBindable(string){return"<span ng-non-bindable>"+string+"</span>"}var renderCode=r.code.bind(r);r.code=function(code,lang,escaped){return wrapNonBindable(renderCode(code,lang,escaped))};var renderCodespan=r.codespan.bind(r);r.codespan=function(code){return wrapNonBindable(renderCodespan(code))};self.defaults=self.defaults||{};self.defaults.renderer=r;m.setOptions(self.defaults);return m}]}markedDirective.$inject=["marked","$templateRequest","$compile"];function markedDirective(marked,$templateRequest,$compile){return{restrict:"AE",replace:true,scope:{opts:"=",marked:"=",compile:"@",src:"="},link:function(scope,element,attrs){if(attrs.marked){set(scope.marked);scope.$watch("marked",set)}else if(attrs.src){scope.$watch("src",function(src){$templateRequest(src,true).then(function(response){set(response)},function(){set("");scope.$emit("$markedIncludeError",attrs.src)})})}else{set(element.text())}function set(text){text=unindent(String(text||""));element.html(marked(text,scope.opts||null));if(scope.$eval(attrs.compile)){$compile(element.contents())(scope.$parent)}}}}}module.exports=angular.module("hc.marked",[]).directive("marked",markedDirective).provider("marked",markedProvider).name},{"./strip-indent":1,marked:"marked"}]},{},[2])(2)}); |
/* | ||
* angular-marked | ||
* (c) 2014 J. Harshbarger | ||
* (c) 2014 - 2016 J. Harshbarger | ||
* Licensed MIT | ||
*/ | ||
/* jshint undef: true, unused: true */ | ||
/* global angular, marked */ | ||
@@ -12,2 +11,4 @@ | ||
var unindent = require('./strip-indent'); | ||
/** | ||
@@ -74,6 +75,2 @@ * @ngdoc overview | ||
module.exports = 'hc.marked'; | ||
angular.module('hc.marked', []) | ||
/** | ||
@@ -165,3 +162,3 @@ * @ngdoc service | ||
.provider('marked', function () { | ||
function markedProvider() { | ||
var self = this; | ||
@@ -198,3 +195,3 @@ | ||
m = require('marked'); | ||
} catch (e) { | ||
} catch (err) { | ||
m = $window.marked || marked; | ||
@@ -223,3 +220,3 @@ } | ||
function wrapNonBindable(string) { | ||
return "<span ng-non-bindable>" + string + "</span>"; | ||
return '<span ng-non-bindable>' + string + '</span>'; | ||
} | ||
@@ -244,3 +241,3 @@ | ||
}]; | ||
}) | ||
} | ||
@@ -314,4 +311,4 @@ // xTODO: filter and tests */ | ||
*/ | ||
.directive('marked', ['marked', '$templateRequest', '$compile', function (marked, $templateRequest, $compile) { | ||
markedDirective.$inject = ['marked', '$templateRequest', '$compile']; | ||
function markedDirective(marked, $templateRequest, $compile) { | ||
return { | ||
@@ -327,9 +324,6 @@ restrict: 'AE', | ||
link: function (scope, element, attrs) { | ||
set(scope.marked || element.text() || ''); | ||
if (attrs.marked) { | ||
set(scope.marked); | ||
scope.$watch('marked', set); | ||
} | ||
if (attrs.src) { | ||
} else if (attrs.src) { | ||
scope.$watch('src', function (src) { | ||
@@ -343,36 +337,8 @@ $templateRequest(src, true).then(function (response) { | ||
}); | ||
} else { | ||
set(element.text()); | ||
} | ||
function unindent(text) { | ||
if (!text) { | ||
return text; | ||
} | ||
var lines = text | ||
.replace(/\t/g, ' ') | ||
.split(/\r?\n/); | ||
var min = null; | ||
var len = lines.length; | ||
var i; | ||
for (i = 0; i < len; i++) { | ||
var line = lines[i]; | ||
var l = line.match(/^(\s*)/)[0].length; | ||
if (l === line.length) { | ||
continue; | ||
} | ||
min = (l < min || min === null) ? l : min; | ||
} | ||
if (min !== null && min > 0) { | ||
for (i = 0; i < len; i++) { | ||
lines[i] = lines[i].substr(min); | ||
} | ||
} | ||
return lines.join('\n'); | ||
} | ||
function set(text) { | ||
text = unindent(text || ''); | ||
text = unindent(String(text || '')); | ||
element.html(marked(text, scope.opts || null)); | ||
@@ -385,2 +351,8 @@ if (scope.$eval(attrs.compile)) { | ||
}; | ||
}]); | ||
} | ||
module.exports = | ||
angular.module('hc.marked', []) | ||
.directive('marked', markedDirective) | ||
.provider('marked', markedProvider) | ||
.name; |
{ | ||
"name": "angular-marked", | ||
"version": "1.2.1", | ||
"version": "1.2.2", | ||
"description": "AngularJS Markdown using marked.", | ||
@@ -13,15 +13,14 @@ "main": "lib/angular-marked.js", | ||
"devDependencies": { | ||
"browserify": "^12.0.1", | ||
"grunt": "^0.4.5", | ||
"grunt-gh-pages": "^0.9.1", | ||
"grunt-ngdocs": "^0.2.5", | ||
"browserify": "^13.0.1", | ||
"grunt": "^1.0.1", | ||
"grunt-gh-pages": "^1.1.0", | ||
"grunt-ngdocs": "^0.2.10", | ||
"jasmine-core": "^2.4.1", | ||
"karma": "^0.13.15", | ||
"karma-chrome-launcher": "^0.2.3", | ||
"karma-jasmine": "^0.3.8", | ||
"karma-phantomjs-launcher": "^1.0.0", | ||
"load-grunt-tasks": "^0.4.0", | ||
"phantomjs-prebuilt": "^2.1.0", | ||
"karma": "^1.1.1", | ||
"karma-chrome-launcher": "^1.0.1", | ||
"karma-jasmine": "^1.0.2", | ||
"karma-phantomjs-launcher": "^1.0.1", | ||
"load-grunt-tasks": "^3.5.0", | ||
"uglifyjs": "^2.4.10", | ||
"xo": "^0.14.0" | ||
"xo": "^0.16.0" | ||
}, | ||
@@ -32,7 +31,9 @@ "scripts": { | ||
"compile": "npm run browserify && npm run uglify", | ||
"ngdocs": "grunt ngdocs", | ||
"build": "npm run compile && npm run ngdocs", | ||
"docs": "grunt ngdocs", | ||
"build": "npm run compile && npm run docs", | ||
"lint": "xo lib/*.js test/**/*.js", | ||
"test": "npm run compile && karma start --single-run --browsers PhantomJS", | ||
"check": "npm run lint && npm run test" | ||
"check": "npm run lint && npm run test", | ||
"prepublish": "npm run compile", | ||
"postpublish": "grunt deploy" | ||
}, | ||
@@ -39,0 +40,0 @@ "repository": { |
32156
12
6
664