|
Last change
on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 13 days ago |
|
Fix frontend appearance
|
-
Property mode
set to
100644
|
|
File size:
2.2 KB
|
| Line | |
|---|
| 1 | # supports-hyperlinks [](https://travis-ci.org/jamestalmage/supports-hyperlinks) [](https://codecov.io/gh/jamestalmage/supports-hyperlinks?branch=master)
|
|---|
| 2 |
|
|---|
| 3 | > Detect whether a terminal emulator supports hyperlinks
|
|---|
| 4 |
|
|---|
| 5 | Terminal emulators are [starting to support hyperlinks](https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda). 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](https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda) began supporting HTML like links, where the link text and destination could be specified separately.
|
|---|
| 6 |
|
|---|
| 7 | This module allows you to detect if hyperlinks are supported in the current Terminal.
|
|---|
| 8 |
|
|---|
| 9 | 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.
|
|---|
| 10 |
|
|---|
| 11 | ## Install
|
|---|
| 12 |
|
|---|
| 13 | ```
|
|---|
| 14 | $ npm install supports-hyperlinks
|
|---|
| 15 | ```
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 | ## Usage
|
|---|
| 19 |
|
|---|
| 20 | ```js
|
|---|
| 21 | const supportsHyperlinks = require('supports-hyperlinks');
|
|---|
| 22 |
|
|---|
| 23 | if (supportsHyperlinks.stdout) {
|
|---|
| 24 | console.log('Terminal stdout supports hyperlinks');
|
|---|
| 25 | }
|
|---|
| 26 |
|
|---|
| 27 | if (supportsHyperlinks.stderr) {
|
|---|
| 28 | console.log('Terminal stderr supports hyperlinks');
|
|---|
| 29 | }
|
|---|
| 30 | ```
|
|---|
| 31 |
|
|---|
| 32 | ## API
|
|---|
| 33 |
|
|---|
| 34 | 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.
|
|---|
| 35 |
|
|---|
| 36 | ## Info
|
|---|
| 37 |
|
|---|
| 38 | Obeys the `--no-hyperlinks`, `--hyperlink=always`, and `--hyperlink=never` CLI flags.
|
|---|
| 39 |
|
|---|
| 40 | 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.
|
|---|
| 41 |
|
|---|
| 42 | ## Related
|
|---|
| 43 |
|
|---|
| 44 | * [`hyperlinker`](https://github.com/jamestalmage/hyperlinker): Write hyperlinks for the Terminal.
|
|---|
| 45 |
|
|---|
| 46 | ## License
|
|---|
| 47 |
|
|---|
| 48 | MIT © [James Talmage](https://github.com/jamestalmage)
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.