Socket
Book a DemoInstallSign in
Socket

to-mention-link

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

to-mention-link

Create links from @ mentions.

latest
Source
npmnpm
Version
0.1.0
Version published
Maintainers
1
Created
Source

Create links from @ mentions.

Install

Install with npm:

$ npm install --save to-mention-link

Usage

var toMention = require('to-mention-link');

API

toMention

Turn @ mentions in a string into links. Defaults to markdown links but allows html and custom link renders. See the example for more details.

Params

  • str {String}: Input string containing @ mentions.
  • options {Options}: Additional options to control url and link rendering.
  • options.url {String}: Specify the url to be used. Defaults to "https://github.com"
  • options.title {String|Function}: Specify the title to be used. May be a function that takes the parsed @ mention and returns a title string.
  • options.renderer {String|Function}: Specify the link renderer to use. Must be a rendered on the renderers object. May be a function that takes the mention, url, and title to be rendered. Defaults to "md".
  • returns {String}: Transformed string with @ mentions as links.

Example

// defaults to github urls
console.log(toMention('- @doowb\n- @jonschlinkert'));
//=> - [doowb](https://github.com/doowb)
//=> - [jonschlinkert](https://github.com/jonschlinkert)

// use custom url
console.log(toMention('- @doowb\n- @jonschlinkert', {url: 'https://twitter.com'}));
//=> - [doowb](https://twitter.com/doowb)
//=> - [jonschlinkert](https://twitter.com/jonschlinkert)

Renderers

Renderers are functions that take the mention, a url, and an optional title and return a formatted link string. Included renders are "md" and "html". "md" is provided by markdown-link. Additional renderers may be added and used by passing their name on the options.renderer option.

About

parse-mentions: Parse and optionally replace @ mentions from a string of text. | homepage

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.

Please read the contributing guide for avice on opening issues, pull requests, and coding standards.

Building docs

(This document was generated by verb-generate-readme (a verb generator), please don't edit the readme directly. Any changes to the readme must be made in .verb.md.)

To generate the readme and API documentation with verb:

$ npm install -g verb verb-generate-readme && verb

Running tests

Install dev dependencies:

$ npm install -d && npm test

Author

Brian Woodward

License

Copyright © 2016, Brian Woodward. Released under the MIT license.

This file was generated by verb-generate-readme, v0.1.30, on September 24, 2016.

Keywords

@-mention

FAQs

Package last updated on 24 Sep 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts