-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# remark-mentions | ||
|
||
[![Build][build-badge]][build] | ||
[![Coverage][coverage-badge]][coverage] | ||
|
||
|
||
## What is this? | ||
|
||
This package is a [unified][] ([remark][]) plugin to convert @ mentions to links: `@wooorm` -> `[**@wooorm**](https://github.com/wooorm)`. | ||
|
||
**unified** is a project that transforms content with abstract syntax trees | ||
(ASTs). | ||
**remark** adds support for markdown to unified. | ||
**mdast** is the markdown AST that remark uses. | ||
This is a remark plugin that transforms mdast. | ||
|
||
## Install | ||
|
||
```sh | ||
npm install remark-mentions | ||
``` | ||
## Usage | ||
```js | ||
import {remark} from 'remark' | ||
import remarkMentions from 'remark-mentions' | ||
|
||
const markdown = "Hello @user!"; | ||
|
||
const file = await remark() | ||
.use(remarkMentions, { | ||
usernameLink: (username) => `/User/Profile/${username}`, // This is optional | ||
}) | ||
.process(markdown) | ||
|
||
console.log(String(file)) | ||
``` | ||
|
||
<!-- Definitions --> | ||
|
||
[build-badge]: https://github.com/finnrg/remark-mentions/workflows/main/badge.svg | ||
|
||
[build]: https://github.com/finnrg/remark-mentions/actions | ||
|
||
[coverage-badge]: https://img.shields.io/codecov/c/github/finnrg/remark-mentions.svg | ||
|
||
[coverage]: https://codecov.io/github/finnrg/remark-mentions |