felixfbecker / cli-highlight Goto Github PK
View Code? Open in Web Editor NEWSyntax highlighting for your terminal 💻✨
Home Page: https://cli-highlight.surge.sh
License: ISC License
Syntax highlighting for your terminal 💻✨
Home Page: https://cli-highlight.surge.sh
License: ISC License
Hi @felixfbecker, we at the AMP Project (github.com/ampproject/amphtml) have been using cli-highlight
to highlight compiler errors seen while building the AMP runtime. We've found the highlighter to be very useful while presenting errors to developers.
Today, we came across a case where the highlighter errors out for certain input strings even though ignoreIllegals
was set to true.
Error: Illegal lexeme ":" for mode "<unnamed>"
Here is the input string: https://gist.github.com/rsimha/801894e377fd1960dbb184367fe44469
Is this expected? If not, is there something we could do to mitigate the problem?
Highlight.js v9 is very, very old and v10 contains 100s of fixes and improvements. We also just officially entirely dropped support for v9 and it should now be treated as a potential security risk for anyone still using it. Your simple uses case makes me think it'd be pretty easy for you to upgrade if you decided to do so.
Would be very useful to be able to pass in custom language definitions which would be passed down to highlight.js
Cheers
Pending a fix from the open issue on a dependency of this project we'll need to update this repo to pull in their changes.
There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.
Error type: undefined. Note: this is a nested preset so please contact the preset author if you are unable to fix it yourself.
index.js
const highlight = require('cli-highlight').highlight
console.log(highlight('module.exports = {a: 1}', { language: 'js' }))
node index.js > t.js
output is
�[36mmodule�[39m.exports = {�[36ma�[39m: �[32m1�[39m}
It's caused by 7384705 according to vuejs/vue-cli#6084 (comment)
This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.
Warning
These dependencies are deprecated:
Datasource | Name | Replacement PR? |
---|---|---|
npm | @types/parse5 |
|
npm | @types/parse5-htmlparser2-tree-adapter |
These updates are currently rate-limited. Click on a checkbox below to force their creation now.
parse5
, @types/parse5
)parse5-htmlparser2-tree-adapter
, @types/parse5-htmlparser2-tree-adapter
)These updates have been manually edited so Renovate will no longer make changes. To discard all commits and start over, click on a checkbox.
yargs
, @types/yargs
)These updates have all been created already. Click a checkbox below to force a retry/rebase of any.
@commitlint/cli
, @commitlint/config-conventional
)@types/jest
, jest
, ts-jest
).github/workflows/build.yml
actions/checkout v2
actions/setup-node v1
package.json
chalk ^4.0.0
highlight.js ^10.7.1
mz ^2.4.0
parse5 ^5.1.1
parse5-htmlparser2-tree-adapter ^6.0.0
yargs ^16.0.0
@commitlint/cli ^11.0.0
@commitlint/config-conventional ^11.0.0
@eclass/semantic-release-surge ^1.0.7
@sourcegraph/eslint-config ^0.20.16
@sourcegraph/prettierrc ^3.0.3
@types/jest ^24.0.9
@types/mz 0.0.32
@types/node ^14.14.9
@types/parse5 ^5.0.2
@types/parse5-htmlparser2-tree-adapter ^5.0.1
@types/yargs ^13.0.0
eslint ^7.14.0
husky ^3.0.0
jest ^24.1.0
prettier ^2.2.0
semantic-release ^17.2.4
ts-jest ^24.0.0
typedoc ^0.19.0
typescript ^4.1.2
node >=8.0.0
npm >=5.0.0
Cmd:
$ highlight S3.js
Output:
// S3/index.js
// -----------
// Module for securely storing, retrieving, and deleting objects on S3.
import https from 'https';
import S3SDK from 'aws-sdk/clients/s3';
import { log } from 'shared/log';
import APIInterface from 'shared/server/_lib/APIInterface';
import { uuid } from 'shared/utilities';
export default <span class="hljs-class">class S3 extends APIInterface </span>{
get requiredConfigKeys() {
return ['bucket', 'endpoint', 'accessKeyId', 'secretAccessKey'];
}
constructor({ bucket, endpoint, accessKeyId, secretAccessKey } = {
bucket: process.env.AWS_S3_BUCKET,
endpoint: process.env.AWS_S3_ENDPOINT,
accessKeyId: process.env.AWS_ACCESS_KEY_ID,
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
}, createDuplicate = false) {
const defaults = {
region: 'us-east-1',
sslEnabled: true,
httpOptions: { agent: new https.Agent() },
apiVersion: '2006-03-01',
};
super(Object.assign(defaults, { bucket, endpoint, accessKeyId, secretAccessKey }), false, createDuplicate);
}
Perhaps this is a highlight.js
issue?
Hello, great library, but I'm wondering if it is possible to reuse the themes/styles defined in highlight.js, which this library depends on; I could of course look at the theme definitions in the source and convert them to the JSON format expected here, but it would be nice not to have to. Thanks!
if you convert the esc[39m to esc[0m then the output is much easier for other programs to interpret
I have to do this to use ansi2html.sh to create web versions of log output
Thanks for the tool
const newdb ={
id : results[i].tb_email_reminder_2004_id,
tgl : results[i].tgl_proses,
jenis: results[i].jenis_surat_email,
minpem: results[i].min_pembayaran,
total : results[i].total_tagihan,
jatuhtem: results[i].jatuh_tempo,
email: results[i].email,
car_no: results[i].card_no,
status: results[i].status
}
console.log(highlight(newdb))
so there is anyway to fix it ?
curl -s https://jsonplaceholder.typicode.com/posts | highlight -l json | less -r
The syntax colors are not preserved when piping into less -r
.
Currently, NodeJS 4 is not supported. Seeing as this is a LTS release, supporting it would be awesome.
see:
typeorm/typeorm#1242
Can I change the theme from code, not from cli parameter?
When trying to highlight an XML file, the hljs
HTML tags are output. Is this expected behaviour? Using the --language XML
option does not change the output.
Command:
>highlight pom.xml
Result:
<span class="hljs-tag"><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"></span>
<span class="hljs-tag"><modelVersion></span>4.0.0<span class="hljs-tag"></modelVersion></span>
<span class="hljs-tag"><parent></span>
<span class="hljs-tag"><groupId></span>org.springframework.boot<span class="hljs-tag"></groupId></span>
<span class="hljs-tag"><artifactId></span>spring-boot-starter-parent<span class="hljs-tag"></artifactId></span>
<span class="hljs-tag"><version></span>1.5.2.RELEASE<span class="hljs-tag"></version></span>
<span class="hljs-tag"></parent></span>
To see what happens to your code in Node.js 10, Greenkeeper has created a branch with the following changes:
.travis.yml
package.json
files, so that was left aloneIf you’re interested in upgrading this repo to Node.js 10, you can open a PR with these changes. Please note that this issue is just intended as a friendly reminder and the PR as a possible starting point for getting your code running on Node.js 10.
Greenkeeper has checked the engines
key in any package.json
file, the .nvmrc
file, and the .travis.yml
file, if present.
engines
was only updated if it defined a single version, not a range..nvmrc
was updated to Node.js 10.travis.yml
was only changed if there was a root-level node_js
that didn’t already include Node.js 10, such as node
or lts/*
. In this case, the new version was appended to the list. We didn’t touch job or matrix configurations because these tend to be quite specific and complex, and it’s difficult to infer what the intentions were.For many simpler .travis.yml
configurations, this PR should suffice as-is, but depending on what you’re doing it may require additional work or may not be applicable at all. We’re also aware that you may have good reasons to not update to Node.js 10, which is why this was sent as an issue and not a pull request. Feel free to delete it without comment, I’m a humble robot and won’t feel rejected 🤖
There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.
Your Greenkeeper Bot 🌴
Does anyone run into the issue with coloring css tags using highlight? I can't produce colored css tags and template tags in either html file containing css or independent css file, just the css properties and its values, even if I specify css to highlight as the parsing language. Here's the screenshot (This is the best result I can get from cli-highlight)
Did I do it wrong? or the features have not been implemented?
It would be nice if this cli had an option to pretty print. I would be happy to create a PR to, but I thought I'd create an issue first.
/app/node_modules/cli-highlight/node_modules/chalk/source/index.js:103
...styles,
^^^
SyntaxError: Unexpected token ...
at createScript (vm.js:53:10)
at Object.runInThisContext (vm.js:95:10)
at Module._compile (module.js:543:28)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Module.require (module.js:498:17)
at require (internal/module.js:20:19)
at Object. (/app/node_modules/cli-highlight/dist/theme.js:10:28)
chalk version from package.json
"cli-highlight": {
"version": "2.1.4",
"resolved": "https://registry.npmjs.org/cli-highlight/-/cli-highlight-2.1.4.tgz",
"integrity": "sha512-s7Zofobm20qriqDoU9sXptQx0t2R9PEgac92mENNm7xaEe1hn71IIMsXMK+6encA6WRCWWxIGQbipr3q998tlQ==",
"requires": {
"chalk": "^3.0.0",
"highlight.js": "^9.6.0",
"mz": "^2.4.0",
"parse5": "^5.1.1",
"parse5-htmlparser2-tree-adapter": "^5.1.1",
"yargs": "^15.0.0"
}
node.js version - v12.14.1
npm version - 6.14.8
nest version - 7.5.1
typeorm - "version": "0.2.26"
"cli-highlight": "^2.0.0"
One of the most well put-together and useful libraries I've seen in a while. Lots of functionality packed in out of the box, super easy to use.
Fantastic work. You can close this whenever you see it.
On registry https://registry.npmjs.org/
, the "latest" version (v2.14.0) of dependency validate-commit-msg
has the following deprecation notice:
Check out CommitLint which provides the same functionality with a more user-focused experience.
Marking the latest version of an npm package as deprecated results in the entire package being considered deprecated, so contact the package author you think this is a mistake.
Affected package file(s): package.json
If you don't care about this, you can close this issue and not be warned about validate-commit-msg
's deprecation again. If you would like to completely disable all future deprecation warnings then add the following to your config:
"suppressNotifications": ["deprecationWarningIssues"]
Currently a RegExp is used, which works for JSON and SQL, but not for languages where the tokens get nested like XML.
Could either use a basic HTML parser or construct a DOM and do a depth-first tree traversal to wrap the nodes.
master
branch failed. 🚨I recommend you give this issue a high priority, so other packages depending on you could benefit from your bug fixes and new features.
You can find below the list of errors reported by semantic-release. Each one of them has to be resolved in order to automatically publish your package. I’m sure you can resolve this 💪.
Errors are usually caused by a misconfiguration or an authentication problem. With each error reported below you will find explanation and guidance to help you to resolve it.
Once all the errors are resolved, semantic-release will release your package the next time you push a commit to the master
branch. You can also manually restart the failed CI job that runs semantic-release.
If you are not sure how to resolve this, here is some links that can help you:
If those don’t help, or if this issue is reporting something you think isn’t right, you can always ask the humans behind semantic-release.
The npm token configured in the NPM_TOKEN
environment variable must be a valid token allowing to publish to the registry https://registry.npmjs.org/
.
If you are using Two-Factor Authentication, make configure the auth-only
level is supported. semantic-release cannot publish with the default auth-and-writes
level.
Please make sure to set the NPM_TOKEN
environment variable in your CI with the exact value of the npm token.
Good luck with your project ✨
Your semantic-release bot 📦🚀
I have a repo that transitively depends on cli-highlight. I received a dependabot security alert, requesting that highlight.js be upgraded to v10.4.1 or higher. It linked to this article.
@joshgoebel do you have any insight?
Is there a way to use highlight inside the node repl or ts-node so it highlights all the code commands I wrote there?
Is there any plan to be ported to deno? maybe published to deno.land/x?
Btw, great lib xD
Hi, I want to have clear text, from the clipboard, to be Highlighted and be put back in the clipboard as Highlighted text, that can be pasted into Word/Google-docs-programs.
Can this cli do something like this? or is the purpose, to much in another direction?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.