markdown-it-external-anchor

2.0.0 • Public • Published

MarkdownIt External Anchor

npm bundle size CI Test

Mark external, absolute links with appropriate rel & target attributes

  • Prevents XSS attacks & provides good UX
  • Does not affect HTML within markdown

Usage

Install

$ npm install --save markdown-it markdown-it-external-anchor

Example

import md from 'markdown-it';
import pluginExternalAnchor from 'markdown-it-external-anchor';

md.use(pluginExternalAnchor, {
    domain: 'example.net',
    class: 'external'
});

md.render('[text](https://example.com)'); // => <a href="https://example/com" rel="noopener noreferrer" target="_blank">text</a>

Options

  • domain (default: null) - A domain which is considered an internal link.
    • When domain is provided, localhost is implicit.
  • class (default: null) - a class name

Maintenance

This is just a personal project. I do not consider it "released". That said, I'm open to suggestions and contributions.

Legal

All source-code is provided under the terms of the MIT license.

Copyright 2025 Binyamin Aron Green.

Package Sidebar

Install

npm i markdown-it-external-anchor

Weekly Downloads

82

Version

2.0.0

License

MIT

Unpacked Size

10.3 kB

Total Files

11

Last publish

Collaborators

  • b3u