将文件路径转换为可点击的超链接红宝石

时间:2018-10-30 17:37:35

标签: html ruby

我正在尝试打印出文件路径,该路径应显示为Intellij控制台输出中的链接。我尝试过以下操作

evalRules

这只会向我显示一条语句C:// Users,但不会将其更改为可点击的链接。请让我知道将其转换为可点击链接所缺少的内容。

1 个答案:

答案 0 :(得分:0)

您可以为此使用npm软件包:https://github.com/sindresorhus/terminal-link

示例:

            mifrill@mifrill-desktop:~$ npm install terminal-link

            npm WARN saveError ENOENT: no such file or directory, open '/home/mifrill/package.json'
            npm notice created a lockfile as package-lock.json. You should commit this file.
            npm WARN enoent ENOENT: no such file or directory, open '/home/mifrill/package.json'
            npm WARN mifrill No description
            npm WARN mifrill No repository field.
            npm WARN mifrill No README data
            npm WARN mifrill No license field.

            + terminal-link@1.1.0
            added 6 packages from 2 contributors and audited 6 packages in 2.868s
            found 0 vulnerabilities

_

            mifrill@mifrill-desktop:~$ node

            > const terminalLink = require('terminal-link');
            undefined

_

            > console.log(terminalLink('file', 'C://Users'))

            file

此字符串(文件)将是可单击的

或者您可以仅使用特殊字符(在ruby上):

irb
link  = 'C://Users'
title = 'File'
puts "\u001b]8;;#{link}\u0007#{title}\u001b]8;;\u0007"