增加超级html模式,可以输入由 !!! 三个感叹号包裹的任意html文本
This commit is contained in:
+27
-5
@@ -1,4 +1,4 @@
|
||||
// Generated by CoffeeScript 1.12.1
|
||||
// Generated by CoffeeScript 1.12.2
|
||||
(function() {
|
||||
var Parser,
|
||||
slice = [].slice;
|
||||
@@ -97,6 +97,7 @@
|
||||
table: 'table|tbody|thead|tfoot|tr|td|th'
|
||||
};
|
||||
this.hooks = {};
|
||||
this.html = false;
|
||||
}
|
||||
|
||||
Parser.prototype.makeHtml = function(text) {
|
||||
@@ -112,6 +113,10 @@
|
||||
return this.call('makeHtml', html);
|
||||
};
|
||||
|
||||
Parser.prototype.enableHtml = function(html1) {
|
||||
this.html = html1 != null ? html1 : true;
|
||||
};
|
||||
|
||||
Parser.prototype.hook = function(type, cb) {
|
||||
if (this.hooks[type] == null) {
|
||||
this.hooks[type] = [];
|
||||
@@ -265,7 +270,7 @@
|
||||
return function() {
|
||||
var escaped, matches, url;
|
||||
matches = 1 <= arguments.length ? slice.call(arguments, 0) : [];
|
||||
escaped = _this.escapeBracket(matches[1]);
|
||||
escaped = htmlspecialchars(_this.escapeBracket(matches[1]));
|
||||
url = _this.escapeBracket(matches[2]);
|
||||
url = _this.cleanUrl(url);
|
||||
return _this.makeHolder("<img src=\"" + url + "\" alt=\"" + escaped + "\" title=\"" + escaped + "\">");
|
||||
@@ -275,7 +280,7 @@
|
||||
return function() {
|
||||
var escaped, matches, result;
|
||||
matches = 1 <= arguments.length ? slice.call(arguments, 0) : [];
|
||||
escaped = _this.escapeBracket(matches[1]);
|
||||
escaped = htmlspecialchars(_this.escapeBracket(matches[1]));
|
||||
result = _this.definitions[matches[2]] != null ? "<img src=\"" + _this.definitions[matches[2]] + "\" alt=\"" + escaped + "\" title=\"" + escaped + "\">" : escaped;
|
||||
return _this.makeHolder(result);
|
||||
};
|
||||
@@ -409,6 +414,19 @@
|
||||
this.setBlock(key);
|
||||
continue;
|
||||
}
|
||||
if (this.html) {
|
||||
if (!!(matches = line.match(/^(\s*)!!!(\s*)$/i))) {
|
||||
if (this.isBlock('shtml')) {
|
||||
this.setBlock(key).endBlock();
|
||||
} else {
|
||||
this.startBlock('shtml', key);
|
||||
}
|
||||
continue;
|
||||
} else if (this.isBlock('shtml')) {
|
||||
this.setBlock(key);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (!!(matches = line.match(new RegExp("^\\s*<(" + special + ")(\\s+[^>]*)?>", 'i')))) {
|
||||
tag = matches[1].toLowerCase();
|
||||
if (!(this.isBlock('html', tag)) && !(this.isBlock('pre'))) {
|
||||
@@ -650,6 +668,10 @@
|
||||
}
|
||||
};
|
||||
|
||||
Parser.prototype.parseShtml = function(lines) {
|
||||
return trim((lines.slice(1, -1)).join("\n"));
|
||||
};
|
||||
|
||||
Parser.prototype.parseSh = function(lines, num) {
|
||||
var line;
|
||||
line = this.parseInline(trim(lines[0], '# '));
|
||||
@@ -860,10 +882,10 @@
|
||||
|
||||
Parser.prototype.cleanUrl = function(url) {
|
||||
var matches;
|
||||
if (!!(matches = url.match(/^\s*((http|https|ftp|mailto):[x80-xff_a-z0-9-\.\/%#@\?\+=~\|\,&\(\)]+)/i))) {
|
||||
if (!!(matches = url.match(/^\s*((http|https|ftp|mailto):[x80-xff_a-z0-9-\.\/%#!@\?\+=~\|\,&\(\)]+)/i))) {
|
||||
matches[1];
|
||||
}
|
||||
if (!!(matches = url.match(/^\s*([x80-xff_a-z0-9-\.\/%#@\?\+=~\|\,&]+)/i))) {
|
||||
if (!!(matches = url.match(/^\s*([x80-xff_a-z0-9-\.\/%#!@\?\+=~\|\,&]+)/i))) {
|
||||
return matches[1];
|
||||
} else {
|
||||
return '#';
|
||||
|
||||
Reference in New Issue
Block a user