Skip to content

Commit 6ef803b

Browse files
committed
Update docs and license
1 parent 2037d0b commit 6ef803b

4 files changed

Lines changed: 39 additions & 8 deletions

File tree

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2022 Tim Branyen (@tbranyen)
1+
Copyright (c) 2023 Tim Branyen (@tbranyen)
22

33
Permission is hereby granted, free of charge, to any person obtaining a copy of
44
this software and associated documentation files (the "Software"), to deal in

packages/diffhtml-rust-parser/README.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Internals.parse = parse;
2929

3030
// Now the html`` tagged template will be parsed using WASM
3131
innerHTML(document.body, html`
32-
<div>Parsed with TL using WASM</div>
32+
<div>Parsed with TL using WASM</div>
3333
`);
3434

3535
// Simple HTML strings are also automatically parsed using WASM now
@@ -44,9 +44,9 @@ your build step. This is done with the `NODE_OPTIONS` env var and the
4444

4545
```json
4646
{
47-
"scripts": {
48-
"build": "NODE_OPTIONS=--experimental-wasm-modules babel input.js -o output.js"
49-
}
47+
"scripts": {
48+
"build": "NODE_OPTIONS=--experimental-wasm-modules babel input.js -o output.js"
49+
}
5050
}
5151
```
5252

@@ -75,4 +75,3 @@ example of how you could integrate the WASM parser in both development and
7575
production is available.
7676

7777
- [Sample webpack example](./examples/webpack)
78-

packages/diffhtml-website/config.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
"Parser": ["parser.html", {
2424
"Options": "#options",
2525
"Override parser": "#override-parser",
26-
"Dynamic values": "#dynamic-values",
27-
"Rust WASM": "#rust-wasm"
26+
"Rust WASM": "#rust-wasm",
27+
"Dynamic values": "#dynamic-values"
2828
}],
2929

3030
"Middleware": ["middleware.html", {

packages/diffhtml-website/pages/parser.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,38 @@ Internals.parse = input => {
174174
};
175175
```
176176

177+
<a name="rust-wasm"></a>
178+
179+
---
180+
181+
## <a href="#rust-wasm">Rust WASM</a>
182+
183+
An alternative parser is readily available that is authored in Rust and
184+
compiled to [WASM](https://webassembly.org/). You can install this with:
185+
186+
```bash
187+
npm install diffhtml-rust-parser --save
188+
```
189+
190+
To use, simply import and attach to the `Internals.parse` as described in the
191+
section above. For example:
192+
193+
```
194+
import { Internals, innerHTML, html } from 'diffhtml';
195+
import { parse } from 'diffhtml-rust-parser';
196+
197+
// Use the rust parser
198+
Internals.parse = parse;
199+
200+
// Now the html`` tagged template will be parsed using WASM
201+
innerHTML(document.body, html`
202+
<div>Parsed with TL using WASM</div>
203+
`);
204+
205+
// Simple HTML strings are also automatically parsed using WASM now
206+
innerHTML(document.body, '<div>Also parsed with WASM</div>');
207+
```
208+
177209
<a name="dynamic-values"></a>
178210

179211
---

0 commit comments

Comments
 (0)