Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/freearhey/table2array
Converts HTML table to Javascript array
https://github.com/freearhey/table2array
Last synced: about 1 month ago
JSON representation
Converts HTML table to Javascript array
- Host: GitHub
- URL: https://github.com/freearhey/table2array
- Owner: freearhey
- License: mit
- Created: 2022-11-26T17:54:23.000Z (almost 2 years ago)
- Default Branch: master
- Last Pushed: 2022-11-26T18:18:30.000Z (almost 2 years ago)
- Last Synced: 2024-08-09T09:28:56.327Z (3 months ago)
- Language: JavaScript
- Size: 107 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# table2array
Node.js utility to convert HTML table to Javascript array.
## Installation
```sh
npm install table2array
```## Usage
```js
import table2array from 'table2array'const table = `
Name
Age
Chester
41
Steve
56
`const array = table2array(playlist)
console.log(array)
```Output:
```json
[
["Name", "Age"],
["Chester", "41"],
["Steve", "56"]
]
```## Examples
### Table with rowspan
Parent
Child
Marry
Sue
Steve
Tom
```json
[
["Parent", "Child"],
["Marry", "Sue"],
["Marry", "Steve"],
["Marry", "Tom"]
]
```### Table with colspan
Monday
Tuesday
Wednesday
Thursday
Friday
Saturday
Sunday
8:00 - 17:00
10:00 - 13:00
Closed
```json
[
["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"],
[
"8:00 - 17:00",
"8:00 - 17:00",
"8:00 - 17:00",
"8:00 - 17:00",
"8:00 - 17:00",
"10:00 - 13:00",
"Closed"
]
]
```### Complex table
Monday
Tuesday
Wednesday
Thursday
Friday
Saturday
Sunday
Superlift Off-Road Adventures
The American Car Prospector
Formula One Drift
Lund International Truck and Jeep Show
Hooked On Dirt
Car Files
World of Trucks
```json
[
["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"],
[
"Superlift Off-Road Adventures",
"Superlift Off-Road Adventures",
"Superlift Off-Road Adventures",
"Superlift Off-Road Adventures",
"The American Car Prospector",
"The American Car Prospector",
"Formula One Drift"
],
[
"Lund International Truck and Jeep Show",
"Hooked On Dirt",
"Car Files",
"Car Files",
"The American Car Prospector",
"The American Car Prospector",
"World of Trucks"
]
]
```## Testing
```sh
npm test
```## Contribution
If you find a bug or want to contribute to the code or documentation, you can help by submitting an [issue](https://github.com/freearhey/table2array/issues) or a [pull request](https://github.com/freearhey/table2array/pulls).
## License
[MIT](LICENSE)