Download the PHP package league/commonmark-ext-external-link without Composer
On this page you can find all versions of the php package league/commonmark-ext-external-link. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download league/commonmark-ext-external-link
More information about league/commonmark-ext-external-link
Files in league/commonmark-ext-external-link
Package commonmark-ext-external-link
Short Description Extension for league/commonmark which adds extra classes and HTML attributes to external links
License BSD-3-Clause
Homepage https://github.com/thephpleague/commonmark-ext-external-link
Informations about the package commonmark-ext-external-link
Extension to denote external links for league/commonmark
DEPRECATED
This extension has been deprecated. All of its functionality now exists in league/commonmark
1.3+ under the League\CommonMark\Extension\ExternalLink
namespace, so you should upgrade to that version and use that bundled extension instead of this one.
Overview
This extension to the league/commonmark
PHP Markdown parser can detect links to external sites and adjust the markup accordingly:
- Adds a
rel="noopener noreferrer"
attribute - Optionally adds any custom HTML classes
Install
Via Composer
Usage
Configure your Environment
as usual and simply add the ExternalLinkExtension
provided by this package:
Configuration
This extension supports three configuration options under the external_link
configuration:
internal_hosts
This option defines a whitelist of hosts which are considered non-external and should not receive the external link treatment.
This can be a single host name, like 'example.com'
, which must match exactly.
If you need to match subdomains, use a regular expression like '/(^|\.)example\.com$/'
. Note that you must use /
characters to delimit your regex.
This configuration option also accepts an array of multiple strings and/or regexes:
By default, if this option is not provided, all links will be considered external.
open_in_new_window
This option (which defaults to false
) determines whether any external links should open in a new tab/window.
html_class
This option allows you to provide a string
containing one or more HTML classes that should be added to the external link <a>
tags: No classes are added by default.
Advanced Rendering
When an external link is detected, the ExternalLinkProcessor
will set the external
data option on the Link
node to either true
or false
. You can therefore create a custom link renderer which checks this value and behaves accordingly:
Changelog
Please see CHANGELOG for more information what has changed recently.
Testing
Security
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
Credits
- Colin O'Dell
- All Contributors
License
This library is licensed under the BSD-3 license. See the License File for more information.