Skip to content

Commit

Permalink
doc: update document
Browse files Browse the repository at this point in the history
  • Loading branch information
姚元璋 committed Sep 26, 2023
1 parent 4e2ec9e commit aa7d630
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 17 deletions.
1 change: 0 additions & 1 deletion .npmrc

This file was deleted.

36 changes: 22 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,26 +34,15 @@ Install via npm
npm install tabletomd --save
```

### Remote (`convertUrl`)

```typescript
import { convertUrl } from 'tabletomd';

const markdown = await convertUrl('https://www.npmjs.com/package/rc-table');
```

### Local (`convert`)

```typescript
import { convert } from 'tabletomd';
import fs from 'fs';
import path from 'path';
const html = fs.readFileSync(
path.resolve(process.cwd(), './test/table.html'),
{
encoding: 'utf-8',
}
);
const html = fs.readFileSync(path.resolve(process.cwd(), './test/table.html'), {
encoding: 'utf-8',
});
const converted = convert(html);
console.log(converted);
// | Company | Contact | Country |
Expand All @@ -62,6 +51,25 @@ console.log(converted);
// | Centro comercial Moctezuma | Francisco Chang | Mexico |
```

### Remote (`convertUrl`)

```typescript
import { convertUrl } from 'tabletomd';

const markdown = await convertUrl('https://www.npmjs.com/package/rc-table');
```

## Credits

The following node libraries make this utility super easy:

- [tabletojson](https://github.com/maugenst/tabletojson)
- [mdtable](https://github.com/Jamesford/mdtable)

## LICENSE

[MIT](https://github.com/yyz945947732/cnname/blob/master/LICENSE)

---

This project is created using [generator-stupid](https://github.com/yyz945947732/generator-stupid).
2 changes: 1 addition & 1 deletion src/fetch-polyfill.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* istanbul ignore file */
/* istanbul ignore file -- @preserve */

// @ts-nocheck
import fetch, { Headers, Request, Response } from 'node-fetch';
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export function convert(html: string) {
* @param {string} html string
* @returns {string} string
*/
/* istanbul ignore next */
/* istanbul ignore next -- @preserve */
export async function convertUrl(url: string) {
try {
const json = await Tabletojson.convertUrl(url);
Expand Down

0 comments on commit aa7d630

Please sign in to comment.