Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use markdown-it instead of marked #180

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 14 additions & 10 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -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');
Expand Down Expand Up @@ -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);
}


Expand Down Expand Up @@ -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);
};


Expand All @@ -295,7 +299,7 @@ Cleaver.prototype.renderAuthorSlide = function (content) {
* @param {string} The full document
* @return {Array.<string>} A list of all slides
*/
Cleaver.prototype.slice = function(document) {
Cleaver.prototype.slice = function (document) {
var cuts = document.split(/\n(?=\-\-)/);
var slices = [];
var nlIndex;
Expand Down
12 changes: 9 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@
"version": "0.8.6",
"author": "Jordan Scales <scalesjordan@gmail.com>",
"description": "30-second slideshows for hackers",
"keywords": ["markdown", "static", "slideshow", "presentation"],
"keywords": [
"markdown",
"static",
"slideshow",
"presentation"
],
"bin": {
"cleaver": "./bin/cleaver"
},
Expand All @@ -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"
Expand Down