From e29ea655f6d0c3c151fb003f8fb8bcdf93ec086b Mon Sep 17 00:00:00 2001 From: at15 Date: Tue, 4 Aug 2015 21:45:49 +1000 Subject: [PATCH] For #17 support to do list - support [ ] - support [x] need to change the style and allow config class --- doc/README.md | 5 +++++ lib/renderer/toc-renderer.js | 12 ++++++++++++ 2 files changed, 17 insertions(+) diff --git a/doc/README.md b/doc/README.md index b678e88..5260931 100644 --- a/doc/README.md +++ b/doc/README.md @@ -26,6 +26,11 @@ var y = 3 | ---- | ---- | ------- | | id | int | test | +#### I am check list + +- [ ] a +- [x] b + ## Contribute make a pr, and then ... \ No newline at end of file diff --git a/lib/renderer/toc-renderer.js b/lib/renderer/toc-renderer.js index 170864b..9102028 100644 --- a/lib/renderer/toc-renderer.js +++ b/lib/renderer/toc-renderer.js @@ -18,4 +18,16 @@ TocRenderer.prototype.heading = function (text, level) { return '' + text + ''; }; +// TODO: move the to do list render to another file +TocRenderer.prototype.listitem = function(text) { + if (/^\s*\[[x ]\]\s*/.test(text)) { + text = text + .replace(/^\s*\[ \]\s*/, '') + .replace(/^\s*\[x\]\s*/, ''); + return '
  • ' + text + '
  • '; + } else { + return '
  • ' + text + '
  • '; + } +}; + module.exports = TocRenderer; \ No newline at end of file