Skip to content
This repository has been archived by the owner on Sep 5, 2019. It is now read-only.

Commit

Permalink
Merge branch 'release-1.0.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
thetutlage committed Jun 11, 2016
2 parents 2e193ea + 96ec55e commit c97d080
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
<a name="1.0.1"></a>
## 1.0.1 (2016-06-11)


### Features

* **markdown:** expose marked renderer and option to wrap toc inside a div([05e1b6b](https://github.com/poppinss/docketjs/commit/05e1b6b))



<a name="1.0.0"></a>
# 1.0.0 (2016-06-10)

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "docketjs",
"version": "1.0.0",
"version": "1.0.1",
"description": "DocketJs is a battery included Markdown to HTML converter for Node.js. It has everything you need to successfully convert a bunch of markdown files to HTML and generate toc and a menu file.",
"main": "index.js",
"scripts": {
Expand Down
11 changes: 8 additions & 3 deletions src/Markdown/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,12 @@ class Markdown {

constructor (markedOptions, tocOptions) {
this.marked = marked.setOptions(markedOptions)
this.renderer = new marked.Renderer()
this.tocOptions = _.merge({
minDepth: 1,
maxDepth: 6
maxDepth: 6,
wrap: true,
divId: 'toc'
}, tocOptions)
}

Expand Down Expand Up @@ -63,10 +66,12 @@ class Markdown {
*/
_getToc (markdown) {
const generatedToc = toc(markdown, this.tocOptions)
return _(generatedToc.json)
let tocUl = _(generatedToc.json)
.filter((heading) => this._filterHeadingsForToc(heading))
.map((heading) => this._makeTocHeading(heading))
.value().join('\n')
tocUl = this.marked(tocUl)
return this.tocOptions.wrap ? `<div id="${this.tocOptions.divId}">${tocUl}</div>` : tocUl
}

/**
Expand All @@ -84,7 +89,7 @@ class Markdown {
contents = contents.trim()
const parsedDoc = meta(contents)
const markdown = parsedDoc.content.replace(/{{\s*TOC\s*}}/, this._getToc(parsedDoc.content))
const html = this.marked(markdown)
const html = this.marked(markdown, {renderer: this.renderer})
return {html, meta: parsedDoc.data}
}

Expand Down

0 comments on commit c97d080

Please sign in to comment.