-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
78038a3
commit 34b0dea
Showing
3 changed files
with
64 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,5 +28,5 @@ | |
"white": false, | ||
"eqnull": true, | ||
"esnext": true, | ||
"unused": true | ||
"unused": "vars" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,57 @@ | ||
/* jshint node: true */ | ||
'use strict'; | ||
|
||
var Filter = require('broccoli-filter'); | ||
var marked = require('marked'); | ||
marked.setOptions({ | ||
gfm: true, | ||
sanitize: true | ||
}); | ||
|
||
function TemplateCompiler(inputNode, options) { | ||
if (!(this instanceof TemplateCompiler)) { | ||
return new TemplateCompiler(inputNode, options); | ||
} | ||
|
||
options = options || {}; | ||
Filter.call(this, inputNode, options); | ||
this.compile = marked; | ||
} | ||
|
||
TemplateCompiler.prototype = Object.create(Filter.prototype); | ||
TemplateCompiler.prototype.constructor = TemplateCompiler; | ||
TemplateCompiler.prototype.extensions = ['md']; | ||
TemplateCompiler.prototype.targetExtension = 'hbs'; | ||
|
||
TemplateCompiler.prototype.processString = function(string, relativePath) { | ||
return this.compile(string).replace(/{/g, '{'); | ||
}; | ||
|
||
module.exports = { | ||
name: 'ember-cli-markdown-compiler' | ||
name: 'ember-cli-markdown-compiler', | ||
|
||
isDevelopingAddon: function() { | ||
return true; | ||
}, | ||
|
||
setupPreprocessorRegistry: function(type, registry) { | ||
registry.add('template', { | ||
name: 'ember-cli-markdown-compiler', | ||
ext: ['md'], | ||
toTree: function(tree) { | ||
return TemplateCompiler(tree); | ||
} | ||
}); | ||
|
||
if (type === 'parent') { | ||
this.parentRegistry = registry; | ||
} | ||
}, | ||
|
||
included: function(app) { | ||
this._super.included.apply(this, arguments); | ||
|
||
this.setupPreprocessorRegistry('parent', app.registry); | ||
} | ||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters