Skip to content

Commit 7492ca5

Browse files
authored
Merge pull request #4 from ae-utbm/wasm
add WASM bindings
2 parents 6a92c37 + 39e9028 commit 7492ca5

6 files changed

Lines changed: 129 additions & 11 deletions

File tree

Cargo.lock

Lines changed: 61 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,27 @@
11
[package]
2+
edition = "2024"
23
name = "aemark"
34
version = "0.1.1"
4-
edition = "2024"
55

66
[lib]
77
name = "aemark"
88
crate-type = ["cdylib"]
99

10-
[workspace]
11-
resolver = "3"
12-
members = ["mark"]
13-
1410
[dependencies]
1511
pyo3 = "0.29.0"
16-
mark = { path = "mark" }
12+
13+
[dependencies.mark]
14+
path = "mark"
15+
16+
[workspace]
17+
members = [
18+
"mark",
19+
"wasm",
20+
]
21+
resolver = "3"
1722

1823
[profile.release]
19-
strip = true
20-
panic = "abort"
2124
lto = "fat"
2225
codegen-units = 1
23-
26+
panic = "abort"
27+
strip = true

wasm/.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/target
2+
**/*.rs.bk
3+
Cargo.lock
4+
bin/
5+
pkg/
6+
wasm-pack.log

wasm/Cargo.toml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
[package]
2+
name = "wasm"
3+
version = "0.1.1"
4+
authors = ["Thomas Girod <thgirod@hotmail.com>"]
5+
edition = "2018"
6+
7+
[package.metadata.wasm-pack.profile.release]
8+
wasm-opt = false
9+
10+
[lib]
11+
crate-type = ["cdylib"]
12+
13+
[dependencies]
14+
wasm-bindgen = "0.2.84"
15+
mark = { path = "../mark" }
16+
17+
[profile.release]
18+
lto = "fat"
19+
codegen-units = 1
20+
panic = "abort"
21+
strip = true

wasm/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
JS bindings for the aemark parser, built upon Rust and WASM.
2+
3+
Exemple :
4+
5+
```javascript
6+
import { markdown } from "@ae_utbm/aemark"
7+
8+
const result = markdown("This some *text* formatted in __markdown__");
9+
console.log(result);
10+
// <p>This some <em>text</em> formatted in <u>markdown</u></p>\n
11+
```

wasm/src/lib.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
use wasm_bindgen::prelude::*;
2+
3+
/// Generate HTML from a markdown string following the aemark spec.
4+
///
5+
/// # Exemple
6+
///
7+
/// ```javascript
8+
/// import { markdown } from "@ae_utbm/aemark"
9+
///
10+
/// const result = markdown("This some *text* formatted in __markdown__");
11+
/// console.log(result);
12+
/// // <p>This some <em>text</em> formatted in <u>markdown</u></p>\n
13+
/// ```
14+
#[wasm_bindgen]
15+
pub fn markdown(s: &str) -> String {
16+
mark::markdown(s)
17+
}

0 commit comments

Comments
 (0)