Skip to content

Instantly share code, notes, and snippets.

@lucifr
Created January 2, 2013 06:34
Show Gist options
  • Save lucifr/4432697 to your computer and use it in GitHub Desktop.
Save lucifr/4432697 to your computer and use it in GitHub Desktop.
markdown.js for hexo
var marked = require('marked'),
mdiscn = require('discount'),
_ = require('underscore'),
highlight = require('../util').highlight,
extend = require('../extend');
var regex = {
backtick: /^`{3}\s*([^\n]+)\n([^`]+)/,
captionUrl: /([^\s]+)\s*(.*)(https?:\/\/\S+)\s*(.*)/,
caption: /([^\s]+)\s*(.*)/
};
marked.setOptions({
gfm: true,
pedantic: false,
sanitize: false,
highlight: function(code, lang){
return highlight(code, {lang: lang, gutter: false});
}
});
var markdown = function(file, content){
return mdiscn.parse(content, mdiscn.flags.extraFootnote);
};
extend.renderer.register('md', 'html', markdown, true);
extend.renderer.register('markdown', 'html', markdown, true);
extend.renderer.register('mkd', 'html', markdown, true);
extend.renderer.register('mkdn', 'html', markdown, true);
extend.renderer.register('mdwn', 'html', markdown, true);
extend.renderer.register('mdtxt', 'html', markdown, true);
extend.renderer.register('mdtext', 'html', markdown, true);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment