Skip to content

FinnRG/remark-mentions

Repository files navigation

remark-mentions

Build 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

npm install remark-mentions

Usage

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))