Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

autifyhq/html-table-parser

Repository files navigation

html-table-parser

table to json by 🏁 [@moriyak]

Installation

npm install html-table-parser

Usage

import { parseTable } from "html-table-parser"
// Table element look like this:
// <table>
// <thead>
// <tr><th>th 1</th><th>th 2</th></tr>
// </thead>
// <tbody>
// <tr><td>td 1</td><td>td 2</td></tr>
// </tbody>
// </table>
const parsed = parseTable(table)
// `parsed` will be:
// [
// [
// {
// elementId: 0,
// tagName: "TH",
// textContent: "th 1",
// left: 0,
// top: 0,
// right: 0,
// bottom: 0,
// attributes: {}
// },
// {
// elementId: 1,
// tagName: "TH",
// textContent: "th 2",
// left: 1,
// top: 0,
// right: 1,
// bottom: 0,
// attributes: {}
// }
// ],
// [
// {
// elementId: 2,
// tagName: "TD",
// textContent: "td 1",
// left: 0,
// top: 1,
// right: 0,
// bottom: 1,
// attributes: {}
// },
// {
// elementId: 3,
// tagName: "TD",
// textContent: "td 2",
// left: 1,
// top: 1,
// right: 1,
// bottom: 1,
// attributes: {}
// }
// ]
// ]

See more example at https://github.com/autifyhq/html-table-parser/blob/master/lib/html-table-parser.test.ts

About

table to json by 🏁 [@moriyak]

Resources

License

Code of conduct

Stars

Watchers

Forks

Contributors 3

AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /