You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Go bindings for the Rust library[cloudflare/lol-html](https://github.com/cloudflare/lol-html/), the *Low Output Latency streaming HTML rewriter/parser with CSS-selector based API*, talking via cgo.
5
+
Go bindings for the Rust crate[cloudflare/lol-html](https://github.com/cloudflare/lol-html/), the *Low Output Latency streaming HTML rewriter/parser with CSS-selector based API*, talking via cgo.
6
6
7
-
**Status:** All abilities provided by C-API implemented, except for customized user data in handlers. Tests are partially covered. The code is at its early stage and the API is therefore subject to change. If you have any ideas on how API can be better structured, feel free to open a PR or an issue.
7
+
**Status:**
8
+
9
+
**All abilities provided by lol_html's c-api are available**, except for customized user data in handlers. The original tests included in c-api package have also been translated to examine this binding's functionality.
10
+
11
+
The code is at its early stage and **breaking changes might be introduced**. If you have any ideas on how the public API can be better structured, feel free to open a PR or an issue.
12
+
13
+
*[go-lolhtml](#go-lolhtml)
14
+
* [Installation](#installation)
15
+
* [Features](#features)
16
+
* [Getting Started](#getting-started)
17
+
* [Examples](#examples)
18
+
* [Documentation](#documentation)
19
+
* [Other Bindings](#other-bindings)
20
+
* [Versioning](#versioning)
21
+
* [Help Wanted!](#help-wanted)
22
+
* [License](#license)
23
+
* [Disclaimer](#disclaimer)
8
24
9
25
## Installation
10
26
11
-
For Linux/macOS/Windows x86_64 platforms, installation is as simple as a single `go get`:
27
+
For Linux/macOS/Windows x86_64 platform users, installation is as simple as a single `go get` command:
12
28
13
29
```shell
14
30
$ go get github.com/coolspring8/go-lolhtml
15
31
```
16
32
17
-
There is no need for you to install Rust. That's because lol-html could be prebuilt into static libraries, stored and shipped in `/build` folder, so that cgo can handle other matters naturally and smoothly.
33
+
Installing Rust is not a necessary step. That's because lol-html could be prebuilt into static libraries, stored and shipped in `/build` folder, so that cgo can handle other compilation matters naturally and smoothly, without intervention.
18
34
19
-
For other platforms, you'll have to compile it yourself.
35
+
For other platforms, you will have to compile it yourself.
36
+
37
+
## Features
38
+
39
+
- Fast: A Go (cgo) wrapper built around the highly-optimized Rust HTML parsing crate lol_html.
// explicitly close the writer and flush the remaining content
90
+
err = w.Close()
67
91
if err != nil {
68
92
log.Fatal(err)
69
93
}
70
94
// Output: Hello, <span>LOL-HTML</span>!
71
95
}
72
96
```
73
97
74
-
The above program takes the chunk `Hello, <span>World</span>!` as input, is configured to rewrite all texts in `span` tags to "LOL-HTML" and prints the result to standard output.
98
+
The above program creates a new Writer configured to rewrite all texts in `span` tags to "LOL-HTML". It takes the chunk `Hello, <span>World</span>!` as input, and prints the result to standard output.
75
99
76
100
And the result is `Hello, <span>LOL-HTML</span>!` .
77
101
78
-
For more examples, please see the `/examples` directory.
102
+
## Examples
103
+
104
+
example_test.go contains two examples.
105
+
106
+
For more detailed examples, please visit the `/examples` subdirectory.
107
+
108
+
- defer-scripts
109
+
110
+
Usage: curl -NL https://git.io/JeOSZ | go run main.go
111
+
112
+
- mixed-content-rewriter
113
+
114
+
Usage: curl -NL https://git.io/JeOSZ | go run main.go
115
+
116
+
- web-scraper
117
+
118
+
A ported Go version of https://web.scraper.workers.dev/.
79
119
80
120
## Documentation
81
121
@@ -86,6 +126,14 @@ Available at [pkg.go.dev](https://pkg.go.dev/github.com/coolspring8/go-lolhtml).
This package does not really follow [Semantic Versioning](https://semver.org/). The current strategy is to follow lol_html's major and minor version, and the patch version number is reserved for this binding's updates, for Go Modul to upgrade correctly.
132
+
133
+
## Help Wanted!
134
+
135
+
There are a few interesting things at [Projects](https://github.com/coolspring8/go-lolhtml/projects/1) panel that I have considered but is not yet implemented. Other contributions and suggestions are also welcome!
0 commit comments