Skip to content

Commit

Permalink
preparing alpha release.
Browse files Browse the repository at this point in the history
* added index.js to repo for coverall report
* added fixture for testing.
  • Loading branch information
markus cecot committed Mar 19, 2015
1 parent 7ab8dc4 commit 22121dd
Show file tree
Hide file tree
Showing 6 changed files with 200 additions and 17 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@ node_modules/
temp/
coverage/
*.log
index.js
61 changes: 61 additions & 0 deletions dist/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
'use strict';
var PluginError, createPluginError, gutil, markdownIt, markdownItPlugin, through;

through = require('through2');

gutil = require('gulp-util');

PluginError = gutil.PluginError;

markdownIt = require('markdown-it');

createPluginError = function(message) {
return new PluginError('gulp-markdown-it', message);
};

markdownItPlugin = function(opt) {
var i, len, md, options, plugin, plugins, preset, ref, ref1, ref2;
if (opt == null) {
opt = {};
}
preset = (ref = opt.preset) != null ? ref : 'default';
plugins = (ref1 = opt.plugins) != null ? ref1 : [];
options = (ref2 = opt.options) != null ? ref2 : {};
md = markdownIt(preset, options);
for (i = 0, len = plugins.length; i < len; i++) {
plugin = plugins[i];
md.use(require(plugin));
}
return through.obj(function(file, encoding, callback) {
var err;
if (file.isNull() || file.content === null) {
callback(null, file);
return;
}
if (file.isStream()) {
callback(new gutil.PluginError('gulp-markdown-it', 'stream content is not supported'));
return;
}
try {
file.contents = new Buffer(md.render(file.contents.toString()));
file.path = gutil.replaceExtension(file.path, '.html');
this.push(file);
} catch (_error) {
err = _error;
callback(new gutil.PluginError('gulp-markdown-it', err, {
fileName: file.path,
showstack: true
}));
}
callback();
});
};

'use strict';


/**
* Module dependencies.
*/

module.exports = markdownItPlugin;
9 changes: 5 additions & 4 deletions gulpfile.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,18 @@ gulp.task 'coffee', ->

# remove `index.js` and `coverage` dir
gulp.task 'clean', (cb) ->
del ['index.js', 'coverage'], cb
del ['dist', 'coverage', 'temp'], cb

# run tests
gulp.task 'test', ['coffee'], ->
spawn 'npm', ['test'], stdio: 'inherit'

# run `gulp-markdown-it` for testing purposes
gulp.task 'gulp-markdown-it', ->
# run `md` for testing purposes
gulp.task 'md', ->
markdownIt = require './index.coffee'
gulp.src('./{,test/,test/fixtures/}*.coffee')
gulp.src('./{,test/,test/fixtures/}*.md')
.pipe(markdownIt())
.pipe(gulp.dest './temp')

# start workflow
gulp.task 'default', ['coffee'], ->
Expand Down
11 changes: 0 additions & 11 deletions lib/markdown-it-wrapper.coffee

This file was deleted.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gulp-markdown-it",
"version": "0.0.0",
"version": "0.1.0",
"description": "A plugin for gulp to render markdown with markdown-it",
"keywords": [
"gulp",
Expand Down
133 changes: 133 additions & 0 deletions test/fixture/sample.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
# Markdown Sampler

# h1 Heading
## h2 Heading
### h3 Heading
#### h4 Heading
##### h5 Heading
###### h6 Heading


## Horizontal Rules

___

---

***


## Typographic replacements

Enable typographer option to see result.

(c) (C) (r) (R) (tm) (TM) (p) (P) +-

test.. test... test..... test?..... test!....

!!!!!! ???? ,, -- ---

"Smartypants, double quotes" and 'single quotes'


## Emphasis

**This is bold text**

__This is bold text__

*This is italic text*

_This is italic text_

~~Strikethrough~~


## Blockquotes


> Blockquotes can also be nested...
>> ...by using additional greater-than signs right next to each other...
> > > ...or with spaces between arrows.

## Lists

Unordered

+ Create a list by starting a line with `+`, `-`, or `*`
+ Sub-lists are made by indenting 2 spaces:
- Marker character change forces new list start:
* Ac tristique libero volutpat at
+ Facilisis in pretium nisl aliquet
- Nulla volutpat aliquam velit
+ Very easy!

Ordered

1. Lorem ipsum dolor sit amet
2. Consectetur adipiscing elit
3. Integer molestie lorem at massa


1. You can use sequential numbers...
1. ...or keep all the numbers as `1.`

Start numbering with offset:

57. foo
1. bar


## Code

Inline `code`

Indented code

// Some comments
line 1 of code
line 2 of code
line 3 of code


Block code "fences"

```
Sample text here...
```

Syntax highlighting

``` js
var foo = function (bar) {
return bar++;
};

console.log(foo(5));
```

## Tables

| Option | Description |
| ------ | ----------- |
| data | path to data files to supply the data that will be passed into templates. |
| engine | engine to be used for processing templates. Handlebars is the default. |
| ext | extension to be used for dest files. |

Right aligned columns

| Option | Description |
| ------:| -----------:|
| data | path to data files to supply the data that will be passed into templates. |
| engine | engine to be used for processing templates. Handlebars is the default. |
| ext | extension to be used for dest files. |


## Links

[link text](http://dev.nodeca.com)

[link with title](http://nodeca.github.io/pica/demo/ "title text!")

Autoconverted link https://github.com/nodeca/pica (enable linkify to see)

0 comments on commit 22121dd

Please sign in to comment.