Skip to content

Commit

Permalink
😄
Browse files Browse the repository at this point in the history
  • Loading branch information
tianxiang.wly committed Mar 8, 2016
1 parent c994b58 commit a13c157
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# markdown-tableify

[![Coverage Status](https://coveralls.io/repos/github/LingyuCoder/markdown-tableify/badge.svg?branch=master)](https://coveralls.io/github/LingyuCoder/markdown-tableify?branch=master)
[![Build Status](https://travis-ci.org/LingyuCoder/markdown-tableify.png)](https://travis-ci.org/LingyuCoder/markdown-tableify)
[![Coverage Status](https://coveralls.io/repos/github/ly-tools/markdown-tableify/badge.svg?branch=master)](https://coveralls.io/github/ly-tools/markdown-tableify?branch=master)
[![Build Status](https://travis-ci.org/ly-tools/markdown-tableify.png)](https://travis-ci.org/ly-tools/markdown-tableify)
[![Dependency Status](https://david-dm.org/ly-tools/markdown-tableify.svg)](https://david-dm.org/ly-tools/markdown-tableify)
[![devDependency Status](https://david-dm.org/ly-tools/markdown-tableify/dev-status.svg)](https://david-dm.org/ly-tools/markdown-tableify#info=devDependencies)
[![NPM version](http://img.shields.io/npm/v/markdown-tableify.svg?style=flat-square)](http://npmjs.org/package/markdown-tableify)
Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ module.exports = (data, config) => {
$rows.push(`| ${config.headers.map(hd => `${hd.title || capitalize(hd.name)}`).join(' | ')} |`);
$rows.push(`| ${config.headers.map(hd => `${hd.align || ':---:'}`).join(' | ')} |`);
$rows = $rows.concat(data.map(rowData => {
let $tds = config.headers.map(hd => `${rowData[hd.name] || ''}`);
let $tds = config.headers.map(hd => `${rowData[hd.name].replace(/[\n]/g, ' ') || ''}`);
return `| ${$tds.join(' | ')} |`;
}));
return $rows.join('\n');
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "markdown-tableify",
"version": "0.0.1",
"version": "0.0.2",
"description": "Convert json to markdown table",
"main": "index.js",
"scripts": {
Expand All @@ -17,15 +17,15 @@
},
"repository": {
"type": "git",
"url": "https://github.com/LingyuCoder/markdown-tableify"
"url": "https://github.com/ly-tools/markdown-tableify"
},
"keywords": [
"markdown",
"tableify",
"json"
],
"bugs": {
"url": "https://github.com/LingyuCoder/markdown-tableify/issues"
"url": "https://github.com/ly-tools/markdown-tableify/issues"
},
"publishConfig": {
"registry": "http://registry.npmjs.org/"
Expand Down
13 changes: 13 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,19 @@ describe('markdown-tableify', () => {
| optionalBool | Description of optionalBool. | bool | | false |
`.trim());
});
it('Multiline', () => {
return tableify([{
name: 'multiline',
description: 'Description of multiline.\nDescription of multiline.\nDescription of multiline.',
required: '',
type: 'array',
defaultValue: '[]'
}]).trim().should.be.eql(`
| Name | Description | Required | Type | DefaultValue |
| :---: | :---: | :---: | :---: | :---: |
| multiline | Description of multiline. Description of multiline. Description of multiline. | | array | [] |
`.trim());
});
it('No headers', () => {
return tableify([{
name: 'optionalArray',
Expand Down

0 comments on commit a13c157

Please sign in to comment.