V 0.3.3. build

This commit is contained in:
Estevão Soares dos Santos 2015-01-05 00:33:57 +00:00
parent 9e63fec598
commit a87754edfb
7 changed files with 158 additions and 8 deletions

View File

@ -116,7 +116,7 @@ Showdown.converter = function (converter_options) {
//
// Automatic Extension Loading (node only):
//
if (typeof module !== 'undefind' && typeof exports !== 'undefined' && typeof require !== 'undefind') {
if (typeof module !== 'undefined' && typeof exports !== 'undefined' && typeof require !== 'undefined') {
var fs = require('fs');
if (fs) {
@ -1452,5 +1452,155 @@ if (typeof define === 'function' && define.amd) {
return Showdown;
});
}
;/**
* Created by Tivie on 04-11-2014.
*/
//Check if AngularJs and Showdown is defined and only load ng-Showdown if both are present
if (angular && Showdown) {
(function (module, Showdown) {
module
.provider('$Showdown', provider)
.directive('sdModelToHtml', ['$Showdown', markdownToHtmlDirective])
.filter('sdStripHtml', stripHtmlFilter);
/**
* Angular Provider
* Enables configuration of showdown via angular.config and Dependency Injection into controllers, views
* directives, etc... This assures the directives and filters provided by the library itself stay consistent
* with the user configurations.
* If the user wants to use a different configuration in a determined context, he can use the "classic" Showdown
* object instead.
*
*/
function provider() {
// Configuration parameters for Showdown
var config = {
extensions: [],
stripHtml: true
};
/**
* Sets a configuration option
*
* @param {string} key Config parameter key
* @param {string} value Config parameter value
*/
this.setOption = function (key, value) {
config.key = value;
return this;
};
/**
* Gets the value of the configuration parameter specified by key
*
* @param {string} key The config parameter key
* @returns {string|null} Returns the value of the config parameter. (or null if the config parameter is not set)
*/
this.getOption = function (key) {
if (config.hasOwnProperty(key)) {
return config.key;
} else {
return null;
}
};
/**
* Loads a Showdown Extension
*
* @param {string} extensionName The name of the extension to load
*/
this.loadExtension = function (extensionName) {
config.extensions.push(extensionName);
return this;
};
function SDObject() {
var converter = new Showdown.converter(config);
/**
* Converts a markdown text into HTML
*
* @param {string} markdown The markdown string to be converted to HTML
* @returns {string} The converted HTML
*/
this.makeHtml = function (markdown) {
return converter.makeHtml(markdown);
};
/**
* Strips a text of it's HTML tags
*
* @param {string} text
* @returns {string}
*/
this.stripHtml = function (text) {
return String(text).replace(/<[^>]+>/gm, '');
};
}
// The object returned by service provider
this.$get = function () {
return new SDObject();
};
}
/**
* AngularJS Directive to Md to HTML transformation
*
* Usage example:
* <div sd-md-to-html-model="markdownText" ></div>
*
* @param $Showdown
* @returns {*}
*/
function markdownToHtmlDirective($Showdown) {
var link = function (scope, element) {
scope.$watch('model', function (newValue) {
var val;
if (typeof newValue === 'string') {
val = $Showdown.makeHtml(newValue);
} else {
val = typeof newValue;
}
element.html(val);
});
};
return {
restrict: 'A',
link: link,
scope: {
model: '=sdModelToHtml'
}
}
}
/**
* AngularJS Filter to Strip HTML tags from text
*
* @returns {Function}
*/
function stripHtmlFilter() {
return function (text) {
return String(text).replace(/<[^>]+>/gm, '');
};
}
})(angular.module('Showdown', []), Showdown);
} else {
/** TODO Since this library is opt out, maybe we should not throw an error so we can concatenate this
script with the main lib */
// throw new Error("ng-showdown was not loaded because one of it's dependencies (AngularJS or Showdown) wasn't met");
}
//# sourceMappingURL=showdown.js.map

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,2 +1,2 @@
/*! showdown 04-01-2015 */
/*! showdown 05-01-2015 */
!function(){var a=function(){return[{type:"lang",regex:"(~T){2}([^~]+)(~T){2}",replace:function(a,b,c){return"<del>"+c+"</del>"}}]};"undefined"!=typeof window&&window.Showdown&&window.Showdown.extensions&&(window.Showdown.extensions.github=a),"undefined"!=typeof module&&(module.exports=a)}();

View File

@ -1,2 +1,2 @@
/*! showdown 04-01-2015 */
/*! showdown 05-01-2015 */
!function(){var a=function(){return[{type:"output",filter:function(a){return a.replace(/(<pre>)?<code>/gi,function(a,b){return b?'<pre class="prettyprint linenums" tabIndex="0"><code data-inner="1">':'<code class="prettyprint">'})}}]};"undefined"!=typeof window&&window.Showdown&&window.Showdown.extensions&&(window.Showdown.extensions.prettify=a),"undefined"!=typeof module&&(module.exports=a)}();

View File

@ -1,2 +1,2 @@
/*! showdown 04-01-2015 */
/*! showdown 05-01-2015 */
!function(){var a=function(a){var b,c={},d="text-align:left;";return c.th=function(a){if(""===a.trim())return"";var b=a.trim().replace(/ /g,"_").toLowerCase();return'<th id="'+b+'" style="'+d+'">'+a+"</th>"},c.td=function(b){return'<td style="'+d+'">'+a.makeHtml(b)+"</td>"},c.ths=function(){var a="",b=0,d=[].slice.apply(arguments);for(b;b<d.length;b+=1)a+=c.th(d[b])+"\n";return a},c.tds=function(){var a="",b=0,d=[].slice.apply(arguments);for(b;b<d.length;b+=1)a+=c.td(d[b])+"\n";return a},c.thead=function(){var a,b=[].slice.apply(arguments);return a="<thead>\n",a+="<tr>\n",a+=c.ths.apply(this,b),a+="</tr>\n",a+="</thead>\n"},c.tr=function(){var a,b=[].slice.apply(arguments);return a="<tr>\n",a+=c.tds.apply(this,b),a+="</tr>\n"},b=function(a){var b,d,e=0,f=a.split("\n"),g=[];for(e;e<f.length;e+=1){if(b=f[e],b.trim().match(/^[|]{1}.*[|]{1}$/)){b=b.trim();var h=[];if(h.push("<table>"),d=b.substring(1,b.length-1).split("|"),h.push(c.thead.apply(this,d)),b=f[++e],b.trim().match(/^[|]{1}[-=| ]+[|]{1}$/)){for(b=f[++e],h.push("<tbody>");b.trim().match(/^[|]{1}.*[|]{1}$/);)b=b.trim(),h.push(c.tr.apply(this,b.substring(1,b.length-1).split("|"))),b=f[++e];h.push("</tbody>"),h.push("</table>"),g.push(h.join("\n"));continue}b=f[--e]}g.push(b)}return g.join("\n")},[{type:"lang",filter:b}]};"undefined"!=typeof window&&window.Showdown&&window.Showdown.extensions&&(window.Showdown.extensions.table=a),"undefined"!=typeof module&&(module.exports=a)}();

View File

@ -1,2 +1,2 @@
/*! showdown 04-01-2015 */
/*! showdown 05-01-2015 */
!function(){var a=function(){return[{type:"lang",regex:"\\B(\\\\)?@([\\S]+)\\b",replace:function(a,b,c){return"\\"===b?a:'<a href="http://twitter.com/'+c+'">@'+c+"</a>"}},{type:"lang",regex:"\\B(\\\\)?#([\\S]+)\\b",replace:function(a,b,c){return"\\"===b?a:'<a href="http://twitter.com/search/%23'+c+'">#'+c+"</a>"}},{type:"lang",regex:"\\\\@",replace:"@"}]};"undefined"!=typeof window&&window.Showdown&&window.Showdown.extensions&&(window.Showdown.extensions.twitter=a),"undefined"!=typeof module&&(module.exports=a)}();