Swiftpack.co - ptrkstr/Slab as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
ptrkstr/Slab
Swift package to convert a HTML table into an array of dictionaries.
.package(url: "https://github.com/ptrkstr/Slab.git", from: "1.0.5")




Swift package to convert a HTML table into an array of dictionaries.

Example

GIVEN I have the following table

A B
1 2
3 4

WHEN I use Slab

let array: [[String: String]] = try Slab().convert(htmlString)

THEN I see an array of dictionaries

[
    ["A": "1", "B": "2"],
    ["A": "3", "B": "4"]
]

Features

Colspan Support

A B
1
3 4
[
    ["A": "1", "B": "1"],
    ["A": "3", "B": "4"]
]

Rowspan Support

A B
1 2
4
[
    ["A": "1", "B": "2"],
    ["A": "4", "B": "2"]
]

Linebreak Support

A
A
B
1 2
3
3
4
[
    ["A\\nA": "1", "B": "2"],
    ["A\\nA": "3\\n3", "B": "2"]
]

Modification

Prior to row data being entered, you have the opportunity to modify the SwiftSoup.Element.

A[1] B
1 2[2]
[
    ["A": "1", "B": "2"]
]

Notes

  • Empty <td></td> is converted into an empty String

Installation

SPM

Add the following to your project:

https://github.com/ptrkstr/Slab

GitHub

link
Stars: 1
Last commit: 4 days ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

Submit a free job ad (while I'm testing this). The analytics numbers for this website are here.

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics