Skip to content
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 improved docs on what this project is #1147

Merged
merged 7 commits into from
May 9, 2023
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
55 changes: 42 additions & 13 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,31 +55,63 @@ You can use the many existing plugins or you can make your own.

## What is this?

You can use plugins to turn markdown into HTML.
**In**:
With this project and a plugin, you can turn this markdown:

```markdown
# Hello, *Mercury*!
```

**Out**:
…into the following HTML:

```html
<h1>Hello, <em>Mercury</em>!</h1>
```

You can use plugins to change markdown.
**In**:
<details><summary>Show example code</summary>

```js
import {unified} from 'unified'
import remarkParse from 'remark-parse'
import remarkHtml from 'remark-html'

const file = await unified()
.use(remarkParse)
.use(remarkHtml)
.process('# Hello, *Mercury*!')

console.log(String(file)) // => '<h1>Hello, <em>Mercury</em>!</h1>'
```

</details>

With another plugin, you can turn this markdown:

```markdown
# Hi, Saturn!
```

**Plugin**:
…into the following markdown:

```markdown
## Hi, Saturn!
```

<details><summary>Show example code</summary>

```js
import {unified} from 'unified'
import remarkParse from 'remark-parse'
import remarkStringify from 'remark-stringify'
import {visit} from 'unist-util-visit'

const file = await unified()
.use(remarkParse)
.use(myRemarkPluginToIncreaseHeadings)
.use(remarkStringify)
.process('# Hi, Saturn!')

console.log(String(file)) // => '## Hi, Saturn!'

/** @type {import('unified').Plugin<[], import('mdast').Root>} */
function myRemarkPluginToIncreaseHeadings() {
return (tree) => {
Expand All @@ -92,11 +124,7 @@ function myRemarkPluginToIncreaseHeadings() {
}
```

**Out**:

```markdown
## Hi, Saturn!
```
</details>

You can use remark for many different things.
**[unified][]** is the core project that transforms content with ASTs.
Expand Down Expand Up @@ -349,13 +377,14 @@ extensions.

The syntax tree format used in remark is [mdast][].
It represents markdown constructs as JSON objects.
**In**:

This markdown:

```markdown
## Hello *Pluto*!
```

**Out**:
yields the following tree:

```js
{
Expand Down