better links
This commit is contained in:
parent
a722edbf32
commit
1854c5e37c
@ -92,10 +92,10 @@ block.lexer = function(str) {
|
||||
// grab link definitons
|
||||
str = str.replace(
|
||||
/^ {0,3}\[([^\]]+)\]: *([^ ]+)(?: +"([^"]+)")? *(?:\n|$)/gm,
|
||||
function(_, id, href, title) {
|
||||
function(__, id, href, title) {
|
||||
links[id] = {
|
||||
href: href,
|
||||
title: unquote(title)
|
||||
title: title
|
||||
};
|
||||
return '';
|
||||
}
|
||||
@ -241,8 +241,8 @@ var inline = {
|
||||
escape: /^\\([\\`*{}\[\]()#+\-.!])/,
|
||||
autolink: /^<([^ >]+(@|:\/)[^ >]+)>/,
|
||||
tag: /^<[^\n>]+>/,
|
||||
link: /^!?\[([^\]]+)\]\(([^\)]+)\)/,
|
||||
reflink: /^!?\[([^\]]+)\]\[([^\]]+)\]/,
|
||||
link: /^!?\[([^\]]+)\] *\(([^\)]*)\)/,
|
||||
reflink: /^!?\[([^\]]+)\] *\[([^\]]+)\]/,
|
||||
strong: /^__([\s\S]+?)__|^\*\*([\s\S]+?)\*\*/,
|
||||
em: /^_([^_]+)_|^\*([^*]+)\*/,
|
||||
code: /^`([^`]+)`|^``([\s\S]+?)``/
|
||||
@ -324,9 +324,10 @@ inline.lexer = function(str) {
|
||||
if (!link) throw new
|
||||
Error('Undefined Reference: ' + cap[2]);
|
||||
} else {
|
||||
text = /^\s*([^\s]*)(?:\s+"([^"]+)")?\s*$/.exec(cap[2]);
|
||||
link = {
|
||||
href: cap[2],
|
||||
title: unquote(cap[3])
|
||||
href: text[1],
|
||||
title: text[2]
|
||||
};
|
||||
}
|
||||
out += '<a href="'
|
||||
@ -346,10 +347,10 @@ inline.lexer = function(str) {
|
||||
if (!link) throw new
|
||||
Error('Undefined Reference: ' + cap[2]);
|
||||
} else {
|
||||
text = /^([^\s]+)\s*(.+)?$/.exec(cap[2]);
|
||||
text = /^\s*([^\s]*)(?:\s+"([^"]+)")?\s*$/.exec(cap[2]);
|
||||
link = {
|
||||
href: text[1],
|
||||
title: unquote(text[2])
|
||||
title: text[2]
|
||||
};
|
||||
}
|
||||
out += '<img src="'
|
||||
@ -529,9 +530,10 @@ var each = function(obj, func) {
|
||||
|
||||
var unquote = function(str) {
|
||||
if (!str) return str;
|
||||
var ch = str[0];
|
||||
/*var ch = str[0];
|
||||
return (ch === '"' || ch === '\'')
|
||||
? str.slice(1, -1) : str;
|
||||
? str.slice(1, -1) : str;*/
|
||||
return str.replace(/^['"\s]+|['"\s]+$/g, '');
|
||||
};
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user