cli-highlight
Advanced tools
Comparing version 1.2.2 to 1.2.3
@@ -20,3 +20,3 @@ "use strict"; | ||
}) | ||
.version(function () { return require('../../package.json').version; }) | ||
.version() | ||
.help('help') | ||
@@ -55,2 +55,3 @@ .alias('help', 'h') | ||
process.exit(1); | ||
throw new Error(); | ||
} | ||
@@ -62,3 +63,3 @@ Promise.all([codePromise, argv.theme ? fs.readFile(argv.theme, 'utf8') : undefined]) | ||
ignoreIllegals: true, | ||
theme: theme && theme_1.parse(theme), | ||
theme: (theme && theme_1.parse(theme)) || undefined, | ||
}; | ||
@@ -65,0 +66,0 @@ if (file) { |
@@ -11,18 +11,21 @@ "use strict"; | ||
if (theme === void 0) { theme = {}; } | ||
if (node.type === 'text') { | ||
return node.data; | ||
} | ||
else if (node.type === 'tag') { | ||
var hljsClass = /hljs-(\w+)/.exec(node.attribs.class); | ||
if (hljsClass) { | ||
var token = hljsClass[1]; | ||
var nodeData = node.childNodes | ||
.map(function (node) { return colorizeNode(node, theme); }) | ||
.join(''); | ||
return (theme[token] || theme_1.DEFAULT_THEME[token] || theme_1.plain)(nodeData); | ||
switch (node.type) { | ||
case 'text': { | ||
return node.data; | ||
} | ||
// Return the data itself when the class name isn't prefixed with a highlight.js token prefix. | ||
// This is common in instances of sublanguages (JSX, Markdown Code Blocks, etc.) | ||
return node.childNodes.map(function (node) { return colorizeNode(node, theme); }).join(''); | ||
case 'tag': { | ||
var hljsClass = /hljs-(\w+)/.exec(node.attribs.class); | ||
if (hljsClass) { | ||
var token = hljsClass[1]; | ||
var nodeData = node.childNodes | ||
.map(function (node) { return colorizeNode(node, theme); }) | ||
.join(''); | ||
return (theme[token] || theme_1.DEFAULT_THEME[token] || theme_1.plain)(nodeData); | ||
} | ||
// Return the data itself when the class name isn't prefixed with a highlight.js token prefix. | ||
// This is common in instances of sublanguages (JSX, Markdown Code Blocks, etc.) | ||
return node.childNodes.map(function (node) { return colorizeNode(node, theme); }).join(''); | ||
} | ||
} | ||
throw new Error('Invalid node type ' + node.type); | ||
} | ||
@@ -29,0 +32,0 @@ function colorize(code, theme) { |
@@ -1,1 +0,1 @@ | ||
{"name":"cli-highlight","version":"1.2.2","description":"Syntax highlighting in your terminal","main":"dist/index.js","types":"dist/index.d.ts","files":["dist","bin","README.md","LICENSE.txt"],"bin":{"highlight":"./bin/highlight"},"engines":{"node":">=4.0.0","npm":">=5.0.0"},"scripts":{"test":"jest","lint":"npm run tslint && npm run prettier","tslint":"tslint -c tslint.json -p tsconfig.json","prettier":"prettier --write --list-different '**/{*.ts,*.json,.prettierrc}'","build":"tsc -p .","watch":"tsc -p . -w","typedoc":"typedoc --media media --mode file --excludeNotExported --out typedoc src/index.ts","semantic-release":"semantic-release","commitmsg":"validate-commit-msg"},"jest":{"collectCoverage":true,"mapCoverage":true,"transform":{"^.+\\.tsx?$":"ts-jest"},"testRegex":"(/test/.*|/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$","testPathIgnorePatterns":["/node_modules/","/src/test/__fixtures__/"],"coverageReporters":["json","text"],"moduleFileExtensions":["ts","tsx","js","jsx","json"]},"config":{"commitizen":{"path":"./node_modules/cz-conventional-changelog"}},"release":{"verifyConditions":"@semantic-release/github"},"repository":{"type":"git","url":"https://github.com/felixfbecker/cli-highlight.git"},"keywords":["terminal","syntax","highlight","color","cli","ansi"],"author":"Felix Becker <felix.b@outlook.com>","license":"ISC","bugs":{"url":"https://github.com/felixfbecker/cli-highlight/issues"},"homepage":"https://github.com/felixfbecker/cli-highlight#readme","dependencies":{"chalk":"^2.3.0","highlight.js":"^9.6.0","mz":"^2.4.0","parse5":"^3.0.3","yargs":"^10.0.3"},"devDependencies":{"@sourcegraph/prettierrc":"^2.0.0","@sourcegraph/tslint-config":"^9.0.3","@types/highlight.js":"^9.12.1","@types/jest":"^21.1.8","@types/mz":"0.0.32","@types/node":"^8.0.53","@types/yargs":"^8.0.2","cz-conventional-changelog":"^2.1.0","husky":"^0.14.3","jest":"^21.2.1","prettier":"1.8.2","semantic-release":"^10.0.0","ts-jest":"^21.2.3","tslint":"^5.8.0","typedoc":"^0.9.0","typescript":"^2.6.1","validate-commit-msg":"^2.14.0"}} | ||
{"name":"cli-highlight","version":"1.2.3","description":"Syntax highlighting in your terminal","main":"dist/index.js","types":"dist/index.d.ts","files":["dist","bin","README.md","LICENSE.txt"],"bin":{"highlight":"./bin/highlight"},"engines":{"node":">=4.0.0","npm":">=5.0.0"},"scripts":{"test":"jest","lint":"npm run tslint && npm run prettier","tslint":"tslint -c tslint.json -p tsconfig.json","prettier":"prettier --write --list-different '**/{*.ts,*.json,.prettierrc}'","build":"tsc -p .","watch":"tsc -p . -w","typedoc":"typedoc --media media --mode file --excludeNotExported --out typedoc src/index.ts","semantic-release":"semantic-release","commitmsg":"validate-commit-msg"},"jest":{"collectCoverage":true,"mapCoverage":true,"transform":{"^.+\\.tsx?$":"ts-jest"},"testRegex":"(/test/.*|/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$","testPathIgnorePatterns":["/node_modules/","/src/test/__fixtures__/"],"coverageReporters":["json","text"],"moduleFileExtensions":["ts","tsx","js","jsx","json"]},"config":{"commitizen":{"path":"./node_modules/cz-conventional-changelog"}},"release":{"verifyConditions":"@semantic-release/github"},"repository":{"type":"git","url":"https://github.com/felixfbecker/cli-highlight.git"},"keywords":["terminal","syntax","highlight","color","cli","ansi"],"author":"Felix Becker <felix.b@outlook.com>","license":"ISC","bugs":{"url":"https://github.com/felixfbecker/cli-highlight/issues"},"homepage":"https://github.com/felixfbecker/cli-highlight#readme","dependencies":{"chalk":"^2.3.0","highlight.js":"^9.6.0","mz":"^2.4.0","parse5":"^3.0.3","yargs":"^10.0.3"},"devDependencies":{"@sourcegraph/prettierrc":"^2.0.0","@sourcegraph/tslint-config":"^9.0.3","@types/highlight.js":"^9.12.1","@types/jest":"^21.1.8","@types/mz":"0.0.32","@types/node":"^8.0.53","@types/yargs":"^8.0.2","cz-conventional-changelog":"^2.1.0","husky":"^0.14.3","jest":"^21.2.1","prettier":"1.8.2","semantic-release":"^10.0.0","ts-jest":"^21.2.3","tslint":"^5.8.0","typedoc":"^0.9.0","typescript":"^2.6.1","validate-commit-msg":"^2.14.0"}} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
34739
746