{"name":"vscode-textmate","version":"3.1.5","description":"VSCode TextMate grammar helpers","author":{"name":"Microsoft Corporation"},"main":"./release/main.js","typings":"./release/main.d.ts","repository":{"type":"git","url":"git+https://github.com/Microsoft/vscode-textmate.git"},"license":"MIT","bugs":{"url":"https://github.com/Microsoft/vscode-textmate/issues"},"scripts":{"watch":"tsc -watch","compile":"tsc","test":"npm run compile && mocha out/tests/tests","test-travis":"istanbul cover ./node_modules/mocha/bin/_mocha -- -R spec out/tests/tests","benchmark":"node benchmark/benchmark.js","inspect":"node scripts/inspect.js","prepublish":"node scripts/release.js"},"dependencies":{"fast-plist":"^0.1.2","oniguruma":"^6.0.1"},"devDependencies":{"coveralls":"^2.11.12","istanbul":"^0.4.4","mocha":"^3.0.2","remap-istanbul":"^0.6.4","tslint":"^3.15.1","typescript":"^2.0.8","typings":"^1.3.2"},"gitHead":"95f30b198b5d01b23f0d81c4f1e5e41dcb45695f","homepage":"https://github.com/Microsoft/vscode-textmate#readme","_id":"vscode-textmate@3.1.5","_shasum":"1b899fc013f33b282bf1ab05157c1b5910f5beeb","_from":".","_npmVersion":"4.4.4","_nodeVersion":"5.12.0","_npmUser":{"name":"aeschli","email":"martinae@microsoft.com"},"dist":{"shasum":"1b899fc013f33b282bf1ab05157c1b5910f5beeb","tarball":"http://registry-npm.ywwl.com/vscode-textmate/download/vscode-textmate-3.1.5.tgz","integrity":"sha512-GPDsyzgYTgdCi/K8VBPRKPdAwa4z0pWwiZhK/lH9ScWTptd5+Pd16kuywP+EJtLJRowXeNEQ2gR5SCw0ubTobA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDilcDLCIDpNBnfRKEAH9fqt0eZtsSLUS60lmvP1IoC0gIhANEJavsJUGg5L7dp8yHS7FxuBF9MSbeHcn0lIROJuJeY"}],"size":24562,"noattachment":false,"key":"/vscode-textmate/-/vscode-textmate-3.1.5.tgz"},"maintainers":[{"name":"aeschli","email":"martinae@microsoft.com"},{"name":"alexandrudima","email":"alexdima@microsoft.com"},{"name":"bpasero","email":"benjpas@microsoft.com"},{"name":"egamma","email":"egamma@microsoft.com"},{"name":"microsoft","email":"npmjs@microsoft.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/vscode-textmate-3.1.5.tgz_1496060350506_0.3594517505262047"},"directories":{},"readme":"# VSCode TextMate [![Build Status](https://dev.azure.com/ms/vscode-textmate/_apis/build/status/microsoft.vscode-textmate?branchName=master)](https://dev.azure.com/ms/vscode-textmate/_build/latest?definitionId=172&branchName=master)\n\nAn interpreter for grammar files as defined by TextMate. TextMate grammars use the oniguruma dialect (https://github.com/kkos/oniguruma). Supports loading grammar files from JSON or PLIST format. This library is used in VS Code. Cross - grammar injections are currently not supported.\n\n## Installing\n\n```sh\nnpm install vscode-textmate\n```\n\n## Using\n\n```javascript\nconst fs = require('fs');\nconst path = require('path');\nconst vsctm = require('vscode-textmate');\nconst oniguruma = require('vscode-oniguruma');\n\n/**\n * Utility to read a file as a promise\n */\nfunction readFile(path) {\n    return new Promise((resolve, reject) => {\n        fs.readFile(path, (error, data) => error ? reject(error) : resolve(data));\n    })\n}\n\nconst wasmBin = fs.readFileSync(path.join(__dirname, './node_modules/vscode-oniguruma/release/onig.wasm')).buffer;\nconst vscodeOnigurumaLib = oniguruma.loadWASM(wasmBin).then(() => {\n    return {\n        createOnigScanner(patterns) { return new oniguruma.OnigScanner(patterns); },\n        createOnigString(s) { return new oniguruma.OnigString(s); }\n    };\n});\n\n// Create a registry that can create a grammar from a scope name.\nconst registry = new vsctm.Registry({\n    onigLib: vscodeOnigurumaLib,\n    loadGrammar: (scopeName) => {\n        if (scopeName === 'source.js') {\n            // https://github.com/textmate/javascript.tmbundle/blob/master/Syntaxes/JavaScript.plist\n            return readFile('./JavaScript.plist').then(data => vsctm.parseRawGrammar(data.toString()))\n        }\n        console.log(`Unknown scope name: ${scopeName}`);\n        return null;\n    }\n});\n\n// Load the JavaScript grammar and any other grammars included by it async.\nregistry.loadGrammar('source.js').then(grammar => {\n    const text = [\n        `function sayHello(name) {`,\n        `\\treturn \"Hello, \" + name;`,\n        `}`\n    ];\n    let ruleStack = vsctm.INITIAL;\n    for (let i = 0; i < text.length; i++) {\n        const line = text[i];\n        const lineTokens = grammar.tokenizeLine(line, ruleStack);\n        console.log(`\\nTokenizing line: ${line}`);\n        for (let j = 0; j < lineTokens.tokens.length; j++) {\n            const token = lineTokens.tokens[j];\n            console.log(` - token from ${token.startIndex} to ${token.endIndex} ` +\n              `(${line.substring(token.startIndex, token.endIndex)}) ` +\n              `with scopes ${token.scopes.join(', ')}`\n            );\n        }\n        ruleStack = lineTokens.ruleStack;\n    }\n});\n\n/* OUTPUT:\n\nUnknown scope name: source.js.regexp\n\nTokenizing line: function sayHello(name) {\n - token from 0 to 8 (function) with scopes source.js, meta.function.js, storage.type.function.js\n - token from 8 to 9 ( ) with scopes source.js, meta.function.js\n - token from 9 to 17 (sayHello) with scopes source.js, meta.function.js, entity.name.function.js\n - token from 17 to 18 (() with scopes source.js, meta.function.js, punctuation.definition.parameters.begin.js\n - token from 18 to 22 (name) with scopes source.js, meta.function.js, variable.parameter.function.js\n - token from 22 to 23 ()) with scopes source.js, meta.function.js, punctuation.definition.parameters.end.js\n - token from 23 to 24 ( ) with scopes source.js\n - token from 24 to 25 ({) with scopes source.js, punctuation.section.scope.begin.js\n\nTokenizing line:        return \"Hello, \" + name;\n - token from 0 to 1 (  ) with scopes source.js\n - token from 1 to 7 (return) with scopes source.js, keyword.control.js\n - token from 7 to 8 ( ) with scopes source.js\n - token from 8 to 9 (\") with scopes source.js, string.quoted.double.js, punctuation.definition.string.begin.js\n - token from 9 to 16 (Hello, ) with scopes source.js, string.quoted.double.js\n - token from 16 to 17 (\") with scopes source.js, string.quoted.double.js, punctuation.definition.string.end.js\n - token from 17 to 18 ( ) with scopes source.js\n - token from 18 to 19 (+) with scopes source.js, keyword.operator.arithmetic.js\n - token from 19 to 20 ( ) with scopes source.js\n - token from 20 to 24 (name) with scopes source.js, support.constant.dom.js\n - token from 24 to 25 (;) with scopes source.js, punctuation.terminator.statement.js\n\nTokenizing line: }\n - token from 0 to 1 (}) with scopes source.js, punctuation.section.scope.end.js\n\n*/\n\n```\n\n## For grammar authors\n\nSee [vscode-tmgrammar-test](https://github.com/PanAeon/vscode-tmgrammar-test) that can help you write unit tests against your grammar.\n\n## API doc\n\nSee [the main.ts file](./src/main.ts)\n\n## Developing\n\n* Clone the repository\n* Run `npm install`\n* Compile in the background with `npm run watch`\n* Run tests with `npm test`\n* Run benchmark with `npm run benchmark`\n* Troubleshoot a grammar with `npm run inspect -- PATH_TO_GRAMMAR PATH_TO_FILE`\n\n## Code of Conduct\n\nThis project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.\n\n\n## License\n[MIT](https://github.com/Microsoft/vscode-textmate/blob/master/LICENSE.md)\n\n","publish_time":1496060351518,"_cnpm_publish_time":1496060351518,"dist-tags":{"latest":"9.3.2","next":"4.0.0-next.3"}}