修正解析顺序

This commit is contained in:
joyqi 2016-12-14 10:56:38 +08:00
parent 627e5cf54e
commit 12c4b8fe98
2 changed files with 20 additions and 20 deletions

View File

@ -1,4 +1,4 @@
// Generated by CoffeeScript 1.11.1
// Generated by CoffeeScript 1.12.1
(function() {
var Parser,
slice = [].slice;
@ -212,6 +212,13 @@
enableAutoLink = true;
}
text = this.call('beforeParseInline', text);
text = text.replace(/(^|[^\\])(`+)(.+?)\2/mg, (function(_this) {
return function() {
var matches;
matches = 1 <= arguments.length ? slice.call(arguments, 0) : [];
return matches[1] + _this.makeHolder('<code>' + (htmlspecialchars(matches[3])) + '</code>');
};
})(this));
text = text.replace(/\\(.)/g, (function(_this) {
return function() {
var escaped, matches;
@ -221,13 +228,6 @@
return _this.makeHolder(escaped);
};
})(this));
text = text.replace(/(^|[^\\])(`+)(.+?)\2/mg, (function(_this) {
return function() {
var matches;
matches = 1 <= arguments.length ? slice.call(arguments, 0) : [];
return matches[1] + _this.makeHolder('<code>' + (htmlspecialchars(matches[3])) + '</code>');
};
})(this));
text = text.replace(/<(https?:\/\/.+)>/ig, (function(_this) {
return function() {
var link, matches, url;

View File

@ -242,18 +242,7 @@ class HyperDown
public function parseInline($text, $whiteList = '', $clearHolders = true, $enableAutoLink = true)
{
$self = $this;
$text = $this->call('beforeParseInline', $text);
// escape
$text = preg_replace_callback(
"/\\\(.)/u",
function ($matches) use ($self) {
$escaped = htmlspecialchars($matches[1]);
$escaped = str_replace('$', '&dollar;', $escaped);
return $self->makeHolder($escaped);
},
$text
);
$text = $this->call('beforeParseInline', $text);
// code
$text = preg_replace_callback(
@ -266,6 +255,17 @@ class HyperDown
$text
);
// escape
$text = preg_replace_callback(
"/\\\(.)/u",
function ($matches) use ($self) {
$escaped = htmlspecialchars($matches[1]);
$escaped = str_replace('$', '&dollar;', $escaped);
return $self->makeHolder($escaped);
},
$text
);
// link
$text = preg_replace_callback(
"/<(https?:\/\/.+)>/i",