diff --git a/lib/index.js b/lib/index.js index 7e36978..bcc7157 100644 --- a/lib/index.js +++ b/lib/index.js @@ -1,7 +1,8 @@ var Q = require('q'); var debug = require('debug'); var path = require('path'); -var marked = require('marked'); +var markdownIt = require('markdown-it'); +var markdownItAttrs = require('markdown-it-attrs'); var hljs = require('highlight.js'); var yaml = require('js-yaml'); var mustache = require('mustache'); @@ -60,16 +61,19 @@ function Cleaver(document, options, includePath) { this.slides = []; this.override = false; - marked.setOptions({ - gfm: true, + this.md = markdownIt({ + html: true, highlight: function (code, lang) { - try { - return hljs.highlight(lang, code).value; - } catch (e) { - return code; + if (lang && hljs.getLanguage(lang)) { + try { + return hljs.highlight(code, { language: lang }).value; + } catch (__) { } } + + return ''; // use external default escaping } - }); + }) + .use(markdownItAttrs); } @@ -274,7 +278,7 @@ Cleaver.prototype.renderSlideshow = function () { * @return {string} The formatted slide */ Cleaver.prototype.renderSlide = function (content) { - return marked(content); + return this.md.render(content); }; @@ -295,7 +299,7 @@ Cleaver.prototype.renderAuthorSlide = function (content) { * @param {string} The full document * @return {Array.} A list of all slides */ -Cleaver.prototype.slice = function(document) { +Cleaver.prototype.slice = function (document) { var cuts = document.split(/\n(?=\-\-)/); var slices = []; var nlIndex; diff --git a/package.json b/package.json index 126cbb6..3e40bdc 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,12 @@ "version": "0.8.6", "author": "Jordan Scales ", "description": "30-second slideshows for hackers", - "keywords": ["markdown", "static", "slideshow", "presentation"], + "keywords": [ + "markdown", + "static", + "slideshow", + "presentation" + ], "bin": { "cleaver": "./bin/cleaver" }, @@ -16,9 +21,10 @@ "dependencies": { "commander": "~2.12.2", "debug": "^3.1.0", - "highlight.js": "~9.12.0", + "highlight.js": "^11.3.1", "js-yaml": "3.10.0", - "marked": "^0.3.7", + "markdown-it": "^12.2.0", + "markdown-it-attrs": "^4.1.0", "mustache": "^2.3.0", "q": "1.5.1", "tiny-lr": "^1.0.5"