-
Notifications
You must be signed in to change notification settings - Fork 0
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
0 parents
commit 00c8ee5
Showing
11 changed files
with
192 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# editorconfig.org | ||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
indent_size = 4 | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
node_modules | ||
npm-debug.log | ||
tmp |
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
language: node_js | ||
node_js: | ||
- 'iojs' | ||
- '0.12' |
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
Copyright (c) Ben Briggs <[email protected]> (http://beneb.info) | ||
|
||
Permission is hereby granted, free of charge, to any person | ||
obtaining a copy of this software and associated documentation | ||
files (the "Software"), to deal in the Software without | ||
restriction, including without limitation the rights to use, | ||
copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the | ||
Software is furnished to do so, subject to the following | ||
conditions: | ||
|
||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES | ||
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT | ||
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | ||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
OTHER DEALINGS IN THE SOFTWARE. |
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 |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# [metalsmith][metalsmith]-mdast [![Build Status](https://travis-ci.org/ben-eb/metalsmith-mdast.svg?branch=master)][ci] [![NPM version](https://badge.fury.io/js/metalsmith-mdast.svg)][npm] [![Dependency Status](https://gemnasium.com/ben-eb/metalsmith-mdast.svg)][deps] | ||
|
||
> Convert markdown to html with mdast. | ||
*If you have any issues with the output of this plugin, please use the | ||
[mdast tracker](https://github.com/wooorm/mdast/issues).* | ||
|
||
## Install | ||
|
||
With [npm](https://npmjs.org/package/metalsmith-mdast) do: | ||
|
||
``` | ||
npm install metalsmith-mdast --save | ||
``` | ||
|
||
## Example | ||
|
||
The [mdast-html][mdasthtml] plugin is bundled for you automatically: | ||
|
||
```js | ||
var mdast = require('metalsmith-mdast'), | ||
Metalsmith = require('metalsmith'); | ||
|
||
Metalsmith('fixtures') | ||
.use(mdast()) | ||
.build(function (err) { | ||
if (err) { | ||
throw err; | ||
} | ||
}); | ||
``` | ||
|
||
Add further plugins by passing an array: | ||
|
||
```js | ||
var rmBadges = require('mdast-strip-badges'), | ||
rmParas = require('mdast-squeeze-paragraphs'); | ||
|
||
Metalsmith('fixtures') | ||
.use(mdast([ rmBadges, rmParas ])) | ||
.build(function (err) { | ||
if (err) { | ||
throw err; | ||
} | ||
}); | ||
``` | ||
|
||
## Contributing | ||
|
||
Pull requests are welcome. If you add functionality, then please add unit | ||
tests to cover it. | ||
|
||
## License | ||
|
||
MIT © [Ben Briggs](http://beneb.info) | ||
|
||
[ci]: https://travis-ci.org/ben-eb/metalsmith-mdast | ||
[deps]: https://gemnasium.com/ben-eb/metalsmith-mdast | ||
[mdasthtml]: https://github.com/wooorm/mdast-html | ||
[metalsmith]: https://github.com/segmentio/metalsmith | ||
[npm]: http://badge.fury.io/js/metalsmith-mdast |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
<h1>Hello, world!</h1> |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
<h1>Hello, world!</h1> |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Hello, world! | ||
|
||
![build](https://img.shields.io/travis/ben-eb/cssnano.svg) |
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
'use strict'; | ||
|
||
var mdast = require('mdast'), | ||
html = require('mdast-html'), | ||
extname = require('path').extname; | ||
|
||
function plugin (plugins) { | ||
return function (files, metalsmith) { | ||
Object.keys(files).map(function (file) { | ||
var extension = extname(file); | ||
if (extension !== '.md' && extension !== '.markdown') { | ||
return true; | ||
} | ||
var markdown = String(files[file].contents); | ||
var result = mdast.use(plugins).use(html).process(markdown); | ||
files[file].contents = new Buffer(result); | ||
var data = files[file]; | ||
delete files[file]; | ||
files[file.replace(extension, '.html')] = data; | ||
}); | ||
} | ||
} | ||
|
||
/** | ||
* Expose `plugin`. | ||
*/ | ||
|
||
module.exports = plugin; |
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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{ | ||
"name": "metalsmith-mdast", | ||
"version": "0.0.0", | ||
"description": "Convert markdown to html with mdast", | ||
"license": "MIT", | ||
"homepage": "https://github.com/ben-eb/metalsmith-mdast", | ||
"author": { | ||
"name": "Ben Briggs", | ||
"email": "[email protected]", | ||
"url": "http://beneb.info" | ||
}, | ||
"files": [ | ||
"LICENSE-MIT", | ||
"index.js" | ||
], | ||
"main": "index.js", | ||
"dependencies": { | ||
"mdast": "^1.1.0", | ||
"mdast-html": "^1.0.0" | ||
}, | ||
"devDependencies": { | ||
"assert-dir-equal": "^1.0.1", | ||
"mdast-squeeze-paragraphs": "^1.1.0", | ||
"mdast-strip-badges": "^1.0.0", | ||
"metalsmith": "^1.0.1", | ||
"tap-spec": "^4.1.0", | ||
"tape": "^4.2.0" | ||
}, | ||
"keywords": [ | ||
"markdown", | ||
"mdast", | ||
"metalsmith" | ||
], | ||
"scripts": { | ||
"test": "tape test.js | tap-spec" | ||
}, | ||
"repository": "ben-eb/metalsmith-mdast" | ||
} |
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
'use strict'; | ||
|
||
var test = require('tape'), | ||
equal = require('assert-dir-equal'), | ||
mdast = require('./'), | ||
rmBadges = require('mdast-strip-badges'), | ||
rmParas = require('mdast-squeeze-paragraphs'), | ||
Metalsmith = require('metalsmith'); | ||
|
||
test('should convert svg files', function (t) { | ||
t.plan(2); | ||
|
||
Metalsmith('fixtures') | ||
.use(mdast([ rmBadges, rmParas ])) | ||
.build(function (err) { | ||
t.notOk(err, 'should not error'); | ||
t.doesNotThrow(function () { | ||
equal('fixtures/build', 'fixtures/expected'); | ||
}); | ||
}); | ||
}); |