https://github.com/finnrg/remark-mentions
remark plugin to replace @ mentions with links
https://github.com/finnrg/remark-mentions
markdown mention mentions remark remark-plugin
Last synced: 3 months ago
JSON representation
remark plugin to replace @ mentions with links
- Host: GitHub
- URL: https://github.com/finnrg/remark-mentions
- Owner: FinnRG
- License: mit
- Created: 2023-08-01T13:55:22.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-07-29T14:31:54.000Z (about 1 year ago)
- Last Synced: 2025-03-18T13:19:18.284Z (7 months ago)
- Topics: markdown, mention, mentions, remark, remark-plugin
- Language: JavaScript
- Homepage:
- Size: 98.6 KB
- Stars: 9
- Watchers: 1
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: license
Awesome Lists containing this project
README
# remark-mentions
[![Build][build-badge]][build]
[![Coverage][coverage-badge]][coverage]## What is this?
This package is a [unified][unified-link] ([remark][remark-link]) 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))
```[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
[unified-link]: https://github.com/unifiedjs/unified
[remark-link]: https://github.com/remarkjs/remark