package/package.json000644 0000001136 3560116604 011547 0ustar00000000 000000 { "name": "@babel/highlight", "version": "7.5.0", "description": "Syntax highlight JavaScript strings for output in terminals.", "author": "suchipi ", "homepage": "https://babeljs.io/", "license": "MIT", "publishConfig": { "access": "public" }, "repository": "https://github.com/babel/babel/tree/master/packages/babel-highlight", "main": "lib/index.js", "dependencies": { "chalk": "^2.0.0", "esutils": "^2.0.2", "js-tokens": "^4.0.0" }, "devDependencies": { "strip-ansi": "^4.0.0" }, "gitHead": "49da9a07c81156e997e60146eb001ea77b7044c4" } package/LICENSE000644 0000002122 3560116604 010262 0ustar00000000 000000 MIT License Copyright (c) 2014-present Sebastian McKenzie and other contributors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. package/README.md000644 0000000511 3560116604 010534 0ustar00000000 000000 # @babel/highlight > Syntax highlight JavaScript strings for output in terminals. See our website [@babel/highlight](https://babeljs.io/docs/en/next/babel-highlight.html) for more information. ## Install Using npm: ```sh npm install --save-dev @babel/highlight ``` or using yarn: ```sh yarn add @babel/highlight --dev ``` package/lib/index.js000644 0000006147 3560116604 011503 0ustar00000000 000000 "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.shouldHighlight = shouldHighlight; exports.getChalk = getChalk; exports.default = highlight; function _jsTokens() { const data = _interopRequireWildcard(require("js-tokens")); _jsTokens = function () { return data; }; return data; } function _esutils() { const data = _interopRequireDefault(require("esutils")); _esutils = function () { return data; }; return data; } function _chalk() { const data = _interopRequireDefault(require("chalk")); _chalk = function () { return data; }; return data; } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } function getDefs(chalk) { return { keyword: chalk.cyan, capitalized: chalk.yellow, jsx_tag: chalk.yellow, punctuator: chalk.yellow, number: chalk.magenta, string: chalk.green, regex: chalk.magenta, comment: chalk.grey, invalid: chalk.white.bgRed.bold }; } const NEWLINE = /\r\n|[\n\r\u2028\u2029]/; const JSX_TAG = /^[a-z][\w-]*$/i; const BRACKET = /^[()[\]{}]$/; function getTokenType(match) { const [offset, text] = match.slice(-2); const token = (0, _jsTokens().matchToToken)(match); if (token.type === "name") { if (_esutils().default.keyword.isReservedWordES6(token.value)) { return "keyword"; } if (JSX_TAG.test(token.value) && (text[offset - 1] === "<" || text.substr(offset - 2, 2) == " colorize(str)).join("\n"); } else { return args[0]; } }); } function shouldHighlight(options) { return _chalk().default.supportsColor || options.forceColor; } function getChalk(options) { let chalk = _chalk().default; if (options.forceColor) { chalk = new (_chalk().default.constructor)({ enabled: true, level: 1 }); } return chalk; } function highlight(code, options = {}) { if (shouldHighlight(options)) { const chalk = getChalk(options); const defs = getDefs(chalk); return highlightTokens(defs, code); } else { return code; } }