metalsmith-markdown
Advanced tools
Comparing version 0.0.1 to 0.1.0
0.1.0 - February 5, 2013 | ||
------------------------ | ||
* add `keys` option | ||
0.0.1 - February 4, 2013 | ||
------------------------ | ||
:sparkles: |
@@ -16,3 +16,4 @@ | ||
* | ||
* @param {Object} options | ||
* @param {Object} options (optional) | ||
* @property {Array} keys | ||
* @return {Function} | ||
@@ -22,2 +23,6 @@ */ | ||
function plugin(options){ | ||
options = options || {}; | ||
var keys = options.keys || ['body']; | ||
if (!~keys.indexOf('body')) keys.push('body'); | ||
return function(files, metalsmith, done){ | ||
@@ -31,3 +36,7 @@ setImmediate(done); | ||
if ('.' != dir) html = dir + '/' + html; | ||
data.body = marked(data.body, options); | ||
keys.forEach(function(key) { | ||
data[key] = marked(data[key], options); | ||
}); | ||
delete files[file]; | ||
@@ -34,0 +43,0 @@ files[html] = data; |
@@ -5,3 +5,3 @@ { | ||
"repository": "git://github.com/segmentio/metalsmith-markdown.git", | ||
"version": "0.0.1", | ||
"version": "0.1.0", | ||
"license": "MIT", | ||
@@ -17,2 +17,2 @@ "main": "lib/index.js", | ||
} | ||
} | ||
} |
var assert = require('assert'); | ||
var equal = require('assert-dir-equal'); | ||
@@ -8,3 +9,3 @@ var Metalsmith = require('metalsmith'); | ||
it('should convert markdown files', function(done){ | ||
Metalsmith('test/fixture') | ||
Metalsmith('test/fixtures/basic') | ||
.use(markdown({ | ||
@@ -15,6 +16,19 @@ smartypants: true | ||
if (err) return done(err); | ||
equal('test/fixture/expected', 'test/fixture/build'); | ||
equal('test/fixtures/basic/expected', 'test/fixtures/basic/build'); | ||
done(); | ||
}); | ||
}); | ||
it('should allow a "keys" option', function(done){ | ||
Metalsmith('test/fixtures/keys') | ||
.use(markdown({ | ||
keys: ['custom'], | ||
smartypants: true | ||
})) | ||
.build(function(err, files){ | ||
if (err) return done(err); | ||
assert.equal('<p><em>a</em></p>\n', files['index.html'].custom); | ||
done(); | ||
}); | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3934
12
71