Security News
New Proposed CISA Mandate Would Require Critical Infrastructure to Report Ransom Payments Within 24 Hours
CISA has proposed a set of new rules that would require critical infrastructure to report cyber incidents and ransom payments.
supports-hyperlinks
Advanced tools
Detect if your terminal emulator supports hyperlinks
Weekly downloads
Package description
The supports-hyperlinks npm package is used to check if the terminal environment supports hyperlinks. This is useful for developers who want to include clickable links in their terminal applications, but need to ensure compatibility with the user's terminal emulator.
Checking if hyperlinks are supported
This feature allows you to check if the standard output (stdout) and standard error (stderr) streams of the terminal support hyperlinks. The package exports an object with two properties: stdout and stderr, which are booleans indicating support.
const supportsHyperlinks = require('supports-hyperlinks');
if (supportsHyperlinks.stdout) {
console.log('Terminal supports hyperlinks');
} else {
console.log('Terminal does not support hyperlinks');
}
if (supportsHyperlinks.stderr) {
console.log('Stderr supports hyperlinks');
}
The terminal-link package allows you to create clickable links in the terminal. It is similar to supports-hyperlinks but goes a step further by providing a function to generate the actual hyperlink strings. It also internally checks if the terminal supports hyperlinks before creating one.
While not directly related to hyperlinks, supports-color is similar in the sense that it checks for terminal capabilities, specifically color support. It is used to determine if the terminal supports different levels of color depth, which is useful for styling terminal output.
Readme
Detect whether a terminal emulator supports hyperlinks
Terminal emulators are starting to support hyperlinks. While many terminals have long detected URL's and linkified them, allowing you to Command-Click or Control-Click them to open a browser, you were forced to print the long unsightly URL's on the screen. As of spring 2017 a few terminals began supporting HTML like links, where the link text and destination could be specified separately.
This module allows you to detect if hyperlinks are supported in the current Terminal.
As this is a new development, we anticipate the list of supported Terminals to grow rapidly. Please open an issue or submit a PR as new Terminals implement support.
$ npm install supports-hyperlinks
const supportsHyperlinks = require('supports-hyperlinks');
if (supportsHyperlinks.stdout) {
console.log('Terminal stdout supports hyperlinks');
}
if (supportsHyperlinks.stderr) {
console.log('Terminal stderr supports hyperlinks');
}
Returns an Object
with a stdout
and stderr
property for testing either streams. Each property is a boolean
, indicating whether or not hyperlinks are supported.
Obeys the --no-hyperlinks
, --hyperlink=always
, and --hyperlink=never
CLI flags.
Can be overridden by the user with the flags --hyperlinks=always
and --no-hyperlinks
. For situations where using those flags are not possible, add the environment variable FORCE_HYPERLINK=1
to forcefully enable hyperlinks or FORCE_HYPERLINK=0
to forcefully disable. The use of FORCE_HYPERLINK
overrides all other hyperlink support checks.
hyperlinker
: Write hyperlinks for the Terminal.MIT © James Talmage
FAQs
Detect if your terminal emulator supports hyperlinks
The npm package supports-hyperlinks receives a total of 12,935,589 weekly downloads. As such, supports-hyperlinks popularity was classified as popular.
We found that supports-hyperlinks demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
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.
Security News
CISA has proposed a set of new rules that would require critical infrastructure to report cyber incidents and ransom payments.
Security News
Redis is no longer OSS, breaking its explicit commitment to remain under the BSD 3-Clause License forever. This has angered contributors who are now working to fork the software.
Product
Socket AI now enables 'AI detected potential malware' alerts by default, ensuring users benefit from AI-powered state-of-the-art malware detection without needing to opt-in.