torch2424 opened PR #3193 (assigned to torch2424) from torch2424/rust-wasi-markdown-parser-example
to main
:
This implements the example that is missing on the Wasmtime Docs: https://docs.wasmtime.dev/examples-markdown.html
It uses the same pulldown-cmark library I've seen used across many Rust/Wasm markdown examples (for example: https://github.com/tschneidereit/pulldown-cmark-wasm )
The example is also inspired by the WASI example on the WasmByExample website: https://wasmbyexample.dev/examples/wasi-hello-world/wasi-hello-world.rust.en-us.html
Example
torch2424 at torch2424-XPS-13-7390 in ~/Source/wasmtime/docs/rust_wasi_markdown_parser on torch2424/rust-wasi-markdown-parser-example $ cargo build --target wasm32-wasi Finished dev [unoptimized + debuginfo] target(s) in 0.01s torch2424 at torch2424-XPS-13-7390 in ~/Source/wasmtime/docs/rust_wasi_markdown_parser on torch2424/rust-wasi-markdown-parser-example $ wasmtime --mapdir .::. target/wasm32-wasi/debug/rust_wasi_markdown_parser.wasm ./example_markdown.md <h1>Hello!</h1> <p>I am example markdown for this demo!</p> torch2424 at torch2424-XPS-13-7390 in ~/Source/wasmtime/docs/rust_wasi_markdown_parser on torch2424/rust-wasi-markdown-parser-example $
torch2424 assigned PR #3193 to torch2424.
torch2424 requested tschneidereit for a review on PR #3193.
torch2424 edited PR #3193 (assigned to torch2424) from torch2424/rust-wasi-markdown-parser-example
to main
:
This implements the example that is missing on the Wasmtime Docs: https://docs.wasmtime.dev/examples-markdown.html
It uses the same pulldown-cmark library I've seen used across many Rust/Wasm markdown examples (for example: https://github.com/tschneidereit/pulldown-cmark-wasm )
The example is also inspired by the WASI example on the WasmByExample website: https://wasmbyexample.dev/examples/wasi-hello-world/wasi-hello-world.rust.en-us.html
Example
torch2424 at torch2424-XPS-13-7390 in ~/Source/wasmtime/docs/rust_wasi_markdown_parser on torch2424/rust-wasi-markdown-parser-example $ cargo build --target wasm32-wasi Finished dev [unoptimized + debuginfo] target(s) in 0.01s torch2424 at torch2424-XPS-13-7390 in ~/Source/wasmtime/docs/rust_wasi_markdown_parser on torch2424/rust-wasi-markdown-parser-example $ wasmtime --mapdir .::. target/wasm32-wasi/debug/rust_wasi_markdown_parser.wasm ./example_markdown.md <h1>Hello!</h1> <p>I am example markdown for this demo!</p> torch2424 at torch2424-XPS-13-7390 in ~/Source/wasmtime/docs/rust_wasi_markdown_parser on torch2424/rust-wasi-markdown-parser-example $
(Yes, I will update my chrome after this :joy: )
![Screenshot from 2021-08-16 15-26-13](https://user-images.githubusercontent.com/1448289/129636885-684916f5-76b1-458e-a93a-9f9588dc465e.png)
tschneidereit submitted PR review.
tschneidereit submitted PR review.
tschneidereit created PR review comment:
Nit: I think
render_markdown
might be a better name thanformat
tschneidereit created PR review comment:
I think it'd be nice to use one of the existing arg parsing crates here, to get good help messages, etc. Using StructOpt, that could look roughly like this:
#[derive(StructOpt)] pub struct Options { /// The markdown file to render #[structopt(parse(from_os_str))] filename: PathBuf, } fn main() { let options = Options::from_args(); // and then use `options.filename` // [..] }
tschneidereit created PR review comment:
I think I'd slightly prefer simply dropping this comment, at least with the name change suggested above.
tschneidereit created PR review comment:
I'm a bit confused by the need of all these—you really should only need to exclude
target
, which contains all of these.I also think all the others below aren't really needed for this example, so perhaps just make this
.gitignore
file match whatcargo new
creates by default—i.e. only include/target
?
tschneidereit created PR review comment:
I think for this example
--dir
would also work, and be a bit easier to follow along with.
torch2424 updated PR #3193 (assigned to torch2424) from torch2424/rust-wasi-markdown-parser-example
to main
.
tschneidereit submitted PR review.
tschneidereit submitted PR review.
tschneidereit created PR review comment:
To grant the capability to read in a directory using the Wasmtime CLI, we need to use the --dir flag. --dir will instruct wasmtime to make the passed directory available to access files from. (You can also `--mapdir GUEST_DIRECTORY::HOST_DIRECTORY` to make it available under a different path inside the content.) For example:
tschneidereit updated PR #3193 (assigned to torch2424) from torch2424/rust-wasi-markdown-parser-example
to main
.
tschneidereit submitted PR review.
tschneidereit created PR review comment:
```bash
tschneidereit submitted PR review.
tschneidereit created PR review comment:
```bash
tschneidereit created PR review comment:
tschneidereit created PR review comment:
```bash
tschneidereit created PR review comment:
```bash $ wasmtime --dir . target/wasm32-wasi/debug/rust_wasi_markdown_parser.wasm -- ./example_markdown.md
tschneidereit created PR review comment:
```bash
tschneidereit updated PR #3193 (assigned to torch2424) from torch2424/rust-wasi-markdown-parser-example
to main
.
torch2424 updated PR #3193 (assigned to torch2424) from torch2424/rust-wasi-markdown-parser-example
to main
.
torch2424 updated PR #3193 (assigned to torch2424) from torch2424/rust-wasi-markdown-parser-example
to main
.
torch2424 updated PR #3193 (assigned to torch2424) from torch2424/rust-wasi-markdown-parser-example
to main
.
alexcrichton submitted PR review.
alexcrichton submitted PR review.
alexcrichton created PR review comment:
I think this may no longer be necessary since this is part of the main workspace?
alexcrichton created PR review comment:
Similar to above I think this is no longer needed?
torch2424 updated PR #3193 (assigned to torch2424) from torch2424/rust-wasi-markdown-parser-example
to main
.
alexcrichton merged PR #3193.
Last updated: Dec 23 2024 at 12:05 UTC