diff --git a/lib/marked.js b/lib/marked.js
index cb1b398b..0b8ba7a1 100644
--- a/lib/marked.js
+++ b/lib/marked.js
@@ -176,94 +176,6 @@ lex.token = function lex(str, tokens, line) {
* Inline Processing
*/
-// this is really bad. i should define
-// some lexemes for all of the inline stuff,
-// but this was just easier for the time being.
-
-if(0) var inline = function(str) {
- var hash = ['#'];
-
- str = str.replace(/#/g, '#0#');
-
- str = str.replace(/`([^`]+)`/g, function(__, text) {
- text = '' + escape(text) + '
';
- return '#' + (hash.push(text) - 1) + '#';
- });
-
- // for links
- str = str.replace(
- /<([^<>:\/ ]+:(?:\/\/)?[^>\n]+?|[^<>\n]+?(@)[^<>\n]+?)>/g,
- function(__, href, at) {
- if (at) {
- // according to the markdown "spec"
- // we need to mangle email addresses
- var href = mangle(href)
- , mail = mangle('mailto:') + href;
- return '' + href + '';
- }
- return '' + href + '';
- }
- );
-
- str = str.replace(/<[^\n>]+>/g, function(tag) {
- return '#' + (hash.push(tag) - 1) + '#';
- });
-
- str = escape(str);
-
- // links
- str = str.replace(
- /\[([^\]]+)\]\(([^\)]+)\)/g,
- '$1'
- );
-
- // This is [an example][id]
- // reference-style link.
- str = str.replace(
- /\[([^\]]+)\]\[([^\]]+)\]/g,
- function(__, text, id) {
- var link = tokens.links[id];
- return '' + text + '';
- }
- );
-
- // img
- str = str.replace(
- /!\[([^\]]+)\]\(([^\s\)]+)\s*([^\)]*)\)/g,
- function(_, alt, src, title) {
- return '
';
- });
-
- // strong
- str = str.replace(/__([^_]+)__/g, '$1');
- str = str.replace(/\*\*([^*]+)\*\*/g, '$1');
-
- // em
- str = str.replace(/_([^_]+)_/g, '$1');
- str = str.replace(/\*([^*]+)\*/g, '$1');
-
- // br
- str = str.replace(/ $/gm, '
');
-
- str = str.replace(/#(\d+)#/g, function(__, i) {
- return hash[i];
- });
-
- return str;
-};
-
var inline = (function() {
var inline = {
tag: /^<[^\n>]+>/,
@@ -298,7 +210,7 @@ var inline = (function() {
, i
, key
, rule
- , out = []
+ , out = ''
, links = tokens.links;
while (str.length) {
@@ -312,10 +224,10 @@ var inline = (function() {
switch (key) {
case 'tag':
- out.push(cap[0];
+ out += cap[0];
break;
case 'img':
- out.push('
');
+ + '>';
break;
case 'link':
case 'reflink':
var link = links[cap[2]] || '';
- out.push(''
+ inline.lexer(cap[1])
- + '');
+ + '';
break;
case 'autolink':
var mailto = cap[2]
@@ -349,29 +261,29 @@ var inline = (function() {
mailto = mangle(mailto);
mail = mangle('mailto:') + mailto;
}
- out.push(''
+ (mailto || escape(href))
- + '');
+ + '';
break;
case 'strong':
- out.push(''
+ out += ''
+ inline.lexer(cap[2] || cap[1])
- + '');
+ + '';
break;
case 'em':
- out.push(''
+ out += ''
+ inline.lexer(cap[2] || cap[1])
- + '');
+ + '';
break;
case 'escape':
- out.push(''
+ out += ''
+ escape(cap[2] || cap[1])
- + '
');
+ + '
';
break;
case 'text':
- out.push(escape(cap[1]));
+ out += escape(cap[1]);
break;
default:
break;
@@ -380,7 +292,7 @@ var inline = (function() {
}
}
- return out.join('');
+ return out;
};
return inline.lexer;
})();