Skip to content

Commit

Permalink
Update renderer.js
Browse files Browse the repository at this point in the history
  • Loading branch information
NoahDragon committed Apr 2, 2017
1 parent 0463d62 commit 75a61f4
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions lib/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,23 @@ var stripHTML = util.stripHTML;
var MarkedRenderer = marked.Renderer;

function Renderer() {
MarkedRenderer.listitem = function(text) {
if (/^\s*\[[x ]\]\s*/.test(text)) {
text = text.replace(/^\s*\[ \]\s*/, '<i class="empty checkbox icon"></i> ').replace(/^\s*\[x\]\s*/, '<i class="checked checkbox icon"></i> ');
return '<li style="list-style: none">' + text + '</li>';
} else {
return '<li>' + text + '</li>';
}
};

MarkedRenderer.apply(this);

this._headingId = {};
}

require('util').inherits(Renderer, MarkedRenderer);

// Support To-Do List
Renderer.prototype.listitem = function(text) {
if (/^\s*\[[x ]\]\s*/.test(text)) {
text = text.replace(/^\s*\[ \]\s*/, '<input type="checkbox"></input> ').replace(/^\s*\[x\]\s*/, '<input type="checkbox" checked></input> ');
return '<li style="list-style: none">' + text + '</li>';
} else {
return '<li>' + text + '</li>';
}
};

// Add id attribute to headings
Renderer.prototype.heading = function(text, level) {
var transformOption = this.options.modifyAnchors;
Expand Down

0 comments on commit 75a61f4

Please sign in to comment.