Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1057)

Side by Side Diff: polymer_0.5.4/bower_components/marked/lib/marked.js

Issue 895523005: Added Polymer 0.5.4 (Closed) Base URL: https://chromium.googlesource.com/infra/third_party/npm_modules.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /** 1 /**
2 * marked - a markdown parser 2 * marked - a markdown parser
3 * Copyright (c) 2011-2014, Christopher Jeffrey. (MIT Licensed) 3 * Copyright (c) 2011-2014, Christopher Jeffrey. (MIT Licensed)
4 * https://github.com/chjj/marked 4 * https://github.com/chjj/marked
5 */ 5 */
6 6
7 ;(function() { 7 ;(function() {
8 8
9 /** 9 /**
10 * Block-Level Grammar 10 * Block-Level Grammar
11 */ 11 */
12 12
13 var block = { 13 var block = {
14 newline: /^\n+/, 14 newline: /^\n+/,
15 code: /^( {4}[^\n]+\n*)+/, 15 code: /^( {4}[^\n]+\n*)+/,
16 fences: noop, 16 fences: noop,
17 hr: /^( *[-*_]){3,} *(?:\n+|$)/, 17 hr: /^( *[-*_]){3,} *(?:\n+|$)/,
18 heading: /^ *(#{1,6}) *([^\n]+?) *#* *(?:\n+|$)/, 18 heading: /^ *(#{1,6}) *([^\n]+?) *#* *(?:\n+|$)/,
19 nptable: noop, 19 nptable: noop,
20 lheading: /^([^\n]+)\n *(=|-){2,} *(?:\n+|$)/, 20 lheading: /^([^\n]+)\n *(=|-){2,} *(?:\n+|$)/,
21 blockquote: /^( *>[^\n]+(\n(?!def)[^\n]+)*\n*)+/, 21 blockquote: /^( *>[^\n]+(\n(?!def)[^\n]+)*\n*)+/,
22 list: /^( *)(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/, 22 list: /^( *)(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,
23 html: /^ *(?:comment|closed|closing) *(?:\n{2,}|\s*$)/, 23 html: /^ *(?:comment *(?:\n|\s*$)|closed *(?:\n{2,}|\s*$)|closing *(?:\n{2,}|\ s*$))/,
24 def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +["(]([^\n]+)[")])? *(?:\n+|$)/, 24 def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +["(]([^\n]+)[")])? *(?:\n+|$)/,
25 table: noop, 25 table: noop,
26 paragraph: /^((?:[^\n]+\n?(?!hr|heading|lheading|blockquote|tag|def))+)\n*/, 26 paragraph: /^((?:[^\n]+\n?(?!hr|heading|lheading|blockquote|tag|def))+)\n*/,
27 text: /^[^\n]+/ 27 text: /^[^\n]+/
28 }; 28 };
29 29
30 block.bullet = /(?:[*+-]|\d+\.)/; 30 block.bullet = /(?:[*+-]|\d+\.)/;
31 block.item = /^( *)(bull) [^\n]*(?:\n(?!\1bull )[^\n]*)*/; 31 block.item = /^( *)(bull) [^\n]*(?:\n(?!\1bull )[^\n]*)*/;
32 block.item = replace(block.item, 'gm') 32 block.item = replace(block.item, 'gm')
33 (/bull/g, block.bullet) 33 (/bull/g, block.bullet)
(...skipping 827 matching lines...) Expand 10 before | Expand all | Expand 10 after
861 861
862 Renderer.prototype.link = function(href, title, text) { 862 Renderer.prototype.link = function(href, title, text) {
863 if (this.options.sanitize) { 863 if (this.options.sanitize) {
864 try { 864 try {
865 var prot = decodeURIComponent(unescape(href)) 865 var prot = decodeURIComponent(unescape(href))
866 .replace(/[^\w:]/g, '') 866 .replace(/[^\w:]/g, '')
867 .toLowerCase(); 867 .toLowerCase();
868 } catch (e) { 868 } catch (e) {
869 return ''; 869 return '';
870 } 870 }
871 if (prot.indexOf('javascript:') === 0) { 871 if (prot.indexOf('javascript:') === 0 || prot.indexOf('vbscript:') === 0) {
872 return ''; 872 return '';
873 } 873 }
874 } 874 }
875 var out = '<a href="' + href + '"'; 875 var out = '<a href="' + href + '"';
876 if (title) { 876 if (title) {
877 out += ' title="' + title + '"'; 877 out += ' title="' + title + '"';
878 } 878 }
879 out += '>' + text + '</a>'; 879 out += '>' + text + '</a>';
880 return out; 880 return out;
881 }; 881 };
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
1147 , i = 0; 1147 , i = 0;
1148 1148
1149 try { 1149 try {
1150 tokens = Lexer.lex(src, opt) 1150 tokens = Lexer.lex(src, opt)
1151 } catch (e) { 1151 } catch (e) {
1152 return callback(e); 1152 return callback(e);
1153 } 1153 }
1154 1154
1155 pending = tokens.length; 1155 pending = tokens.length;
1156 1156
1157 var done = function() { 1157 var done = function(err) {
1158 var out, err; 1158 if (err) {
1159 opt.highlight = highlight;
1160 return callback(err);
1161 }
1162
1163 var out;
1159 1164
1160 try { 1165 try {
1161 out = Parser.parse(tokens, opt); 1166 out = Parser.parse(tokens, opt);
1162 } catch (e) { 1167 } catch (e) {
1163 err = e; 1168 err = e;
1164 } 1169 }
1165 1170
1166 opt.highlight = highlight; 1171 opt.highlight = highlight;
1167 1172
1168 return err 1173 return err
1169 ? callback(err) 1174 ? callback(err)
1170 : callback(null, out); 1175 : callback(null, out);
1171 }; 1176 };
1172 1177
1173 if (!highlight || highlight.length < 3) { 1178 if (!highlight || highlight.length < 3) {
1174 return done(); 1179 return done();
1175 } 1180 }
1176 1181
1177 delete opt.highlight; 1182 delete opt.highlight;
1178 1183
1179 if (!pending) return done(); 1184 if (!pending) return done();
1180 1185
1181 for (; i < tokens.length; i++) { 1186 for (; i < tokens.length; i++) {
1182 (function(token) { 1187 (function(token) {
1183 if (token.type !== 'code') { 1188 if (token.type !== 'code') {
1184 return --pending || done(); 1189 return --pending || done();
1185 } 1190 }
1186 return highlight(token.text, token.lang, function(err, code) { 1191 return highlight(token.text, token.lang, function(err, code) {
1192 if (err) return done(err);
1187 if (code == null || code === token.text) { 1193 if (code == null || code === token.text) {
1188 return --pending || done(); 1194 return --pending || done();
1189 } 1195 }
1190 token.text = code; 1196 token.text = code;
1191 token.escaped = true; 1197 token.escaped = true;
1192 --pending || done(); 1198 --pending || done();
1193 }); 1199 });
1194 })(tokens[i]); 1200 })(tokens[i]);
1195 } 1201 }
1196 1202
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
1246 marked.Renderer = Renderer; 1252 marked.Renderer = Renderer;
1247 1253
1248 marked.Lexer = Lexer; 1254 marked.Lexer = Lexer;
1249 marked.lexer = Lexer.lex; 1255 marked.lexer = Lexer.lex;
1250 1256
1251 marked.InlineLexer = InlineLexer; 1257 marked.InlineLexer = InlineLexer;
1252 marked.inlineLexer = InlineLexer.output; 1258 marked.inlineLexer = InlineLexer.output;
1253 1259
1254 marked.parse = marked; 1260 marked.parse = marked;
1255 1261
1256 if (typeof exports === 'object') { 1262 if (typeof module !== 'undefined' && typeof exports === 'object') {
1257 module.exports = marked; 1263 module.exports = marked;
1258 } else if (typeof define === 'function' && define.amd) { 1264 } else if (typeof define === 'function' && define.amd) {
1259 define(function() { return marked; }); 1265 define(function() { return marked; });
1260 } else { 1266 } else {
1261 this.marked = marked; 1267 this.marked = marked;
1262 } 1268 }
1263 1269
1264 }).call(function() { 1270 }).call(function() {
1265 return this || (typeof window !== 'undefined' ? window : global); 1271 return this || (typeof window !== 'undefined' ? window : global);
1266 }()); 1272 }());
OLDNEW
« no previous file with comments | « polymer_0.5.4/bower_components/marked/index.js ('k') | polymer_0.5.4/bower_components/marked/man/marked.1 » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698