New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Rust Markdown parser tutorial #181
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm!
I’d like to see us take a pass at making it a bit more consistent with the other tutorials. For example how we handle prereqs and also using code block frontmatter for filenames, etc. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please see suggested changes below. I expanded on my previous comment with some links to the Docs Engine docs which hopefully makes things a bit clearer!
--- | ||
|
||
# Build a Markdown Parser with Rust and WebAssembly | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let’s add a "Before you start" section here, like we do in the other tutorials:
import TutorialsBeforeYouStart from "../../_partials/_tutorials-before-you-start.md"
# Build a Markdown parser with Rust and WebAssembly
<TutorialsBeforeYouStart/>
<!-- ... -->
(Note: “parser” also lowercased.)
difficulty: Advanced | ||
--- | ||
|
||
# Build a Markdown Parser with Rust and WebAssembly |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
“Parser” → “parser”
In the command line, generate your Workers project by passing in a project name (we'll use rustwasm-markdown-parser), and the template URL to base your project on. | ||
|
||
```sh | ||
wrangler generate rustwasm-markdown-parser https://github.com/cloudflare/rustwasm-worker-template/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefix line with at least $
. See https://docs-engine-docs.adam.workers.dev/markdown#terminals for examples. If it’s a series of steps requiring a specific set of directors, prefix with ~/ $
to start and then after e.g. cd-ing into rustwasm-markdown-parser
, prefix with ~/rustwasm-markdown-parser $
etc.
You can test how your Workers function will look when it's deployed by using the preview service, which you can access with the `wrangler dev` command: | ||
|
||
```sh | ||
wrangler dev |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Per previous, should be:
~/rustwasm-markdown-parser $ wrangler dev
Since it’s required that you be in the project directory for wrangler dev
to work.
|
||
[`wrangler dev`](/cli-wrangler/commands#dev) starts a server on localhost that executes your Worker on incoming HTTP requests. By default, it'll listen on port :8787. | ||
|
||
<Aside>The first time you run `wrangler dev` might take a couple minutes to compile to WebAssembly. </Aside> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Must be on separate lines for parsing:
<Aside>
The first time you run `wrangler dev` might take a couple minutes to compile to WebAssembly.
</Aside>
See https://docs-engine-docs.adam.workers.dev/markdown#asides
```toml | ||
## Cargo.toml | ||
|
||
[dependencies] | ||
pulldown-cmark = "0.4.0" | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use filenames feature (see https://docs-engine-docs.adam.workers.dev/markdown#filenames):
```toml
---
filename: Cargo.toml
---
[dependencies]
pulldown-cmark = "0.4.0"
```
our `src/lib.rs` to look like this: | ||
|
||
```rust | ||
// src/lib.rs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use filenames feature of code blocks (see https://docs-engine-docs.adam.workers.dev/markdown#filenames).
`dev` or `publish`, you can run the `build` command: | ||
|
||
```sh | ||
wrangler build |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
~/rustwasm-markdown-parser $ wrangler build
To preview this code in the browser, and get runtime errors in your terminal, you can run: | ||
|
||
```sh | ||
wrangler dev |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
~/rustwasm-markdown-parser $ wrangler dev
To do: