You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Oct 1, 2024. It is now read-only.
remark plugin to automatically add target and rel attributes
to external links.
Note!
This plugin is ready for the new parser in remark
(remarkjs/remark#536).
The current and previous versions of the plugin work with the current and
previous versions of remark.
Install
This package is ESM only:
Node 12+ is needed to use it and it must be imported instead of required.
This package exports no identifiers.
The default export is remarkExternalLinks.
unified().use(remarkExternalLinks[, options])
Automatically add target and rel attributes to external links.
options
options.target
How to display referenced documents (string?: _self, _blank, _parent,
or _top, default: _blank).
Pass false to not set targets on links.
options.rel
Link types to hint about the referenced documents (Array.<string>
or string, default: ['nofollow', 'noopener', 'noreferrer']).
Pass false to not set rels on links.
When using a target, add noopener and noreferrer to avoid
exploitation of the window.opener API.
options.protocols
Protocols to check, such as mailto or tel (Array.<string>, default:
['http', 'https']).
options.content
hast content to insert at the end of external links
(Node or Children).
Will be inserted in a <span> element.
Properties to add to the span wrapping content, when
given.
Security
options.content is used and injected into the tree when it’s given.
This could open you up to a cross-site scripting (XSS) attack if you pass
user provided content in.
This may become a problem if the Markdown later transformed to
rehype (hast) or opened in an unsafe Markdown viewer.
Most likely though, this plugin will instead protect you from exploitation of
the window.opener API.