Skip to content

Commit

Permalink
Rename
Browse files Browse the repository at this point in the history
  • Loading branch information
developit committed Nov 5, 2014
1 parent 033512d commit f1ae8d9
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions snarkdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
module.exports = factory();
}
else {
root.sharkdown = factory();
root.snarkdown = factory();
}
}(this, function() {
var tags = {
Expand All @@ -28,24 +28,24 @@
context[end?'pop':'push'](token);
return desc[ end ? 1 : 0 ];
}

function outdent(str, ch) {
ch = (ch || '') + (str.match(/^(\t| )+/m) || ['[\\t ]*'])[0];
return str.replace(new RegExp('^'+ch,'gm'),'');
}

function trim(str) {
return str.replace(/(^\n+|\n+$)/g,'');
}

function parse(md) {
var tokenizer = /(?:^```(\w*)\n([\s\S]*?)\n```$)|((?:(?:^|\n+)(?:\t| {2,}).+)+\n*)|((?:(?:^|\n)([>*+-]|\d+\.)\s+.*)+)|(?:\[([^\]]+?)\]\(([^\)]+?)\)|(?:(?:^|\n+)([^\s].*)\n(\-{3,}|={3,})(?:\n+|$))|(?:(?:^|\n+)(#{1,3})\s*(.+)(?:\n+|$))|(?:`([^`].*?)`)|( \n\n*|\n{2,}|__|\*\*|[_*]))/gm,
context = [],
out = '',
last = 0,
chunk, prev, token, esc, reg, inner, t, i;
md = trim(md);

tokenizer.lastIndex = 0;
while ( (token=tokenizer.exec(md)) ) {
prev = md.substring(last, token.index);
Expand Down Expand Up @@ -97,15 +97,15 @@
out += prev;
out += chunk;
}

out += md.substring(last);
for (i=context.length; i--; ) {
out += tag(context, context[i]);
}

return trim(out);
}

parse.parse = parse;
return parse;
}));
}));

0 comments on commit f1ae8d9

Please sign in to comment.