roojs-all.js
[roojs1] / Roo / Markdown.js
index 8db398e..6ffe6e0 100644 (file)
@@ -6,24 +6,24 @@
  */
 
 
-//
-// marked usage:
-// 
-//   alert( Roo.Markdown.toHtml("Markdown *rocks*.") );
-// 
-// Note: move the sample code to the bottom of this
-// file before uncommenting it.
-//
-
+/**
+ *
+ * Roo.Markdown - is a very crude wrapper around marked..
+ *
+ * usage:
+ * 
+ * alert( Roo.Markdown.toHtml("Markdown *rocks*.") );
+ * 
+ * Note: move the sample code to the bottom of this
+ * file before uncommenting it.
+ *
+ */
 
-//
-// Showdown namespace
-//
 Roo.Markdown = {};
 Roo.Markdown.toHtml = function(text) {
     
-    var c = new Roo.ux.Markdown.marked.setOptions({
-            renderer: new Roo.ux.Showdown.marked.Renderer(),
+    var c = new Roo.Markdown.marked.setOptions({
+            renderer: new Roo.Markdown.marked.Renderer(),
             gfm: true,
             tables: true,
             breaks: false,
@@ -32,7 +32,9 @@ Roo.Markdown.toHtml = function(text) {
             smartLists: true,
             smartypants: false
           });
-
+    // A FEW HACKS!!?
+    
+    text = text.replace(/\\\n/g,' ');
     return Roo.Markdown.marked(text);
 };
 //
@@ -366,7 +368,7 @@ Roo.Markdown.toHtml = function(text) {
             loose = next || /\n\n(?!\s*$)/.test(item);
             if (i !== l - 1) {
               next = item.charAt(item.length - 1) === '\n';
-              if (!loose) loose = next;
+              if (!loose) { loose = next; }
             }
     
             this.tokens.push({
@@ -648,7 +650,7 @@ Roo.Markdown.toHtml = function(text) {
             ? this.options.sanitizer
               ? this.options.sanitizer(cap[0])
               : escape(cap[0])
-            : cap[0]
+            : cap[0];
           continue;
         }
     
@@ -750,7 +752,7 @@ Roo.Markdown.toHtml = function(text) {
      */
     
     InlineLexer.prototype.smartypants = function(text) {
-      if (!this.options.smartypants) return text;
+      if (!this.options.smartypants)  { return text; }
       return text
         // em-dashes
         .replace(/---/g, '\u2014')
@@ -773,7 +775,7 @@ Roo.Markdown.toHtml = function(text) {
      */
     
     InlineLexer.prototype.mangle = function(text) {
-      if (!this.options.mangle) return text;
+      if (!this.options.mangle) { return text; }
       var out = ''
         , l = text.length
         , i = 0
@@ -863,7 +865,7 @@ Roo.Markdown.toHtml = function(text) {
     };
     
     Renderer.prototype.table = function(header, body) {
-      return '<table>\n'
+      return '<table class="table table-striped">\n'
         + '<thead>\n'
         + header
         + '</thead>\n'
@@ -1137,7 +1139,7 @@ Roo.Markdown.toHtml = function(text) {
         // explicitly match decimal, hex, and named HTML entities 
       return html.replace(/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/g, function(_, n) {
         n = n.toLowerCase();
-        if (n === 'colon') return ':';
+        if (n === 'colon') { return ':'; }
         if (n.charAt(0) === '#') {
           return n.charAt(1) === 'x'
             ? String.fromCharCode(parseInt(n.substring(2), 16))
@@ -1151,7 +1153,7 @@ Roo.Markdown.toHtml = function(text) {
       regex = regex.source;
       opt = opt || '';
       return function self(name, val) {
-        if (!name) return new RegExp(regex, opt);
+        if (!name) { return new RegExp(regex, opt); }
         val = val.source || val;
         val = val.replace(/(^|[^\[])\^/g, '$1');
         regex = regex.replace(name, val);
@@ -1233,7 +1235,7 @@ Roo.Markdown.toHtml = function(text) {
     
         delete opt.highlight;
     
-        if (!pending) return done();
+        if (!pending) { return done(); }
     
         for (; i < tokens.length; i++) {
           (function(token) {
@@ -1241,7 +1243,7 @@ Roo.Markdown.toHtml = function(text) {
               return --pending || done();
             }
             return highlight(token.text, token.lang, function(err, code) {
-              if (err) return done(err);
+              if (err) { return done(err); }
               if (code == null || code === token.text) {
                 return --pending || done();
               }
@@ -1255,7 +1257,7 @@ Roo.Markdown.toHtml = function(text) {
         return;
       }
       try {
-        if (opt) opt = merge({}, marked.defaults, opt);
+        if (opt) { opt = merge({}, marked.defaults, opt); }
         return Parser.parse(Lexer.lex(src, opt), opt);
       } catch (e) {
         e.message += '\nPlease report this to https://github.com/chjj/marked.';