https://github.com/zsmatrix62/diff-html
https://github.com/zsmatrix62/diff-html
diff-html extism
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/zsmatrix62/diff-html
- Owner: zsmatrix62
- Created: 2025-01-20T08:57:13.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2025-01-24T12:48:07.000Z (8 months ago)
- Last Synced: 2025-06-23T19:51:41.150Z (3 months ago)
- Topics: diff-html, extism
- Language: Rust
- Homepage:
- Size: 30.3 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# diff-html
A WebAssembly plugin for Extism that performs HTML diffing between two HTML documents.
For more information about using Extism plugins, see the [Extism official documentation](https://extism.org/docs/overview).
## Features
- Performs semantic HTML diffing
- Preserves document structure
- Highlights changes with andtags
- Works as a lightweight WebAssembly module## Example
### Input JSON
```json
{
"before": "",Original content with some text
"after": ""Modified content with different text
}
```### Output HTML
```html
OriginalModified content
with somewith different text
```### Rendered Output
```html
Original
Modified content
with some
with different text
```## Installation
1. Install Extism CLI and Rust toolchain:
```bash
make setup
```2. Build the optimized WebAssembly module:
```bash
make build
```3. The compiled WebAssembly module will be available at:
```
target/wasm32-unknown-unknown/release/diff_html.wasm
```## Usage with Extism
### Rust Example
```rust
use extism_pdk::*;#[plugin_fn]
pub fn diff_html(input: String) -> FnResult {
let input: serde_json::Value = serde_json::from_str(&input)?;
let before = input["before"].as_str().unwrap();
let after = input["after"].as_str().unwrap();
let result = diff_html_rs::diff(before, after);
Ok(result)
}
```### JavaScript Example
```javascript
import { Plugin } from 'extism';async function diffHtml(before, after) {
const plugin = await Plugin.fromWasmFile(
'./target/wasm32-unknown-unknown/release/diff_html.wasm'
);const input = JSON.stringify({
before,
after
});const output = await plugin.call('diff_html', input);
return output.text();
}// Example usage
const beforeHtml = '';Content
const afterHtml = '';Modified Content
diffHtml(beforeHtml, afterHtml).then(result => {
console.log('Diff result:', result);
});
```## License
MIT