{"name":"cspell-grammar","version":"6.30.2","keywords":["cspell","grammar"],"author":{"name":"Jason Dent","email":"jason@streetsidesoftware.nl"},"license":"MIT","_id":"cspell-grammar@6.30.2","homepage":"https://github.com/streetsidesoftware/cspell/tree/main/packages/cspell-gitignore#readme","bugs":{"url":"https://github.com/streetsidesoftware/cspell/labels/cspell-grammar"},"bin":{"cspell-grammar":"bin.mjs"},"dist":{"shasum":"a117ce65f30ab9c66d94c363fed50087768f0bfb","tarball":"http://registry-npm.ywwl.com/cspell-grammar/download/cspell-grammar-6.30.2.tgz","fileCount":120,"integrity":"sha512-x9x80/uPwpXGLu2Vg/vb9Ncn1Mw8Y0Xzz2WXqzLufKyWk2S0tGHVvkDS6YkQRuK6gOabk5nDwhtnpwt93sgn1Q==","signatures":[{"sig":"MEQCIAL8lPvIdzwJvmsomyKq3hqUyjjbDH4crkwczkA+gdIjAiA6SnZhIoBUpS+vccb+Y2tdgxhqxgk3ZjnQKQquvSeBtg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":148708,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJkFgcsACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpaQRAAgAFqzKNaBMPUJp+wI+pYJnP9qbvLGXgl+GHHRpAjvAevdXNW\r\nBOAVdmM8HudVhzPmzDiJK4XFVDFTAUiQUkilQG9B7OHOUip0EgL98/h/DfEo\r\n+lYTkq4iX7KnD/2zrgXrBq1nqsw6p7T+9/ZcOL2SunQ8A2Me8ho0XKnl2UbB\r\nWWvMCBLgyjqLVNiRNmP7RgwwB3no4MPt/LkonytMEL3QTM+k8ZQNEW1AxR4D\r\nlHBZuCTHtHK2oLZ0e+lCTAOrAoaw1sBJO2cA04Sb15LhZ/Y7Ej5iLYapSU5l\r\nz1K8Z1ppD1qR+5N1+S3QkMF8+jMFVnWGYRwqJlA4ZCDfuVO6kYN7vSvn55lJ\r\nSMJo26T28BJTL4IPgJ2SIKFib/jC3BDnaytOni7wDLF7zdLwI0yLj4EFR+wo\r\n7QFGNXGcocrk8AHwDJYhLLCHLxeGgslugfvC7bi+qRkwLTcc4B7FPkDSdWx3\r\nXOZ3NlxIE4kpLkpFpHDXBzbM45tbu5aTGxCFFddlF3Pv5C9n6HgN7upsM0j1\r\n0Np+0BwpNgwSE+AidY0cmLDlLEFx4T3UPr+eEawjR0qQO6I52cGwnNBe3R6l\r\n7TEsECbsVR6xo69oo1VLVgSdfWtwmpr27PsaMYdCF291lAbrIqj11KWqjd0Y\r\nJnoI03Im10pwKqI032dW0NI3FlKb2OTrrtc=\r\n=MAvE\r\n-----END PGP SIGNATURE-----\r\n","size":37780,"noattachment":false,"key":"/cspell-grammar/-/cspell-grammar-6.30.2.tgz"},"main":"dist/cjs/index.js","type":"commonjs","types":"dist/cjs/index.d.ts","module":"dist/esm/index.mjs","engines":{"node":">=14"},"exports":{".":{"import":"./dist/esm/index.mjs","require":"./dist/cjs/index.js"},"./parsers/typescript":{"import":"./dist/esm/parsers/typescript/index.mjs","require":"./dist/cjs/parsers/typescript/index.js"}},"gitHead":"4da6895c680084f3b741ad24a73c5bb011a57b35","scripts":{"test":"vitest run","build":"tsc -b . && ts2mjs dist/esm","clean":"shx rm -rf dist coverage .tsbuildinfo","watch":"tsc -b . -w","coverage":"pnpm coverage:vitest && pnpm coverage:fix","build:esm":"tsc -p tsconfig.esm.json","test:watch":"vitest","clean-build":"pnpm run clean && pnpm run build","coverage:fix":"nyc report --temp-dir \"$(pwd)/coverage\" --reporter lcov --report-dir \"$(pwd)/coverage\" --cwd ../..","coverage:vitest":"vitest run --coverage"},"_npmUser":{"name":"jason-dent","email":"jason@streetsidesoftware.nl"},"repository":{"url":"git+https://github.com/streetsidesoftware/cspell.git","type":"git"},"_npmVersion":"lerna/1.17.0/node@v18.15.0+x64 (linux)","description":"Grammar parsing support for cspell","directories":{},"_nodeVersion":"18.15.0","dependencies":{"@cspell/cspell-pipe":"6.30.2","@cspell/cspell-types":"6.30.2"},"typesVersions":{"*":{"*":["dist/cjs/*.d.ts","dist/cjs/*/index.d.ts"],"index.js":["dist/cjs/index.d.ts"],"index.d.ts":["dist/cjs/index.d.ts"],"dist/cjs/*.d.ts":["dist/cjs/*.d.ts"],"parsers/typescript":["dist/cjs/parsers/typescript/index.d.ts"],"parsers/typescript/*.d.ts":["dist/cjs/parsers/typescript/*.d.ts"]}},"_hasShrinkwrap":false,"devDependencies":{"jest":"^29.5.0"},"_npmOperationalInternal":{"tmp":"tmp/cspell-grammar_6.30.2_1679165227796_0.0022002450501947823","host":"s3://npm-registry-packages"},"readme":"# `cspell-grammar`\n\nCSpell Grammar is used to generate a parser. The Parser is used to add context / scope to parts of a document, making it easier to define the parts to spell spell checked.\n\nThis is to address the issues and limitations related to `ignoreRegExpList` and `includeRegExpList`.\n\nThe parser is use to add `scope` to sections of a document. The `scope` can then be used to apply spell checking rules.\n\nExample: Only check comments and strings\n\n```yaml\nrules:\n  '*': false\n  comment: true\n  string: true\n```\n\nIt can be even more powerful like controlling the language settings based upon scope.\n\n```yaml\nrules:\n  comment:\n    language: en\n  string:\n    language: en,fr\n    dictionaries: ['marketing-terms'],\n    caseSensitive: true\n  string.javascript:\n    caseSensitive: false\n```\n\nRules are applied in the order they match the scope of the text.\n\nWhen checking JavaScript files with the above example rules:\n\n- strings will:\n  - use the locale `en,fr`\n  - the `marketing-terms` dictionary will be enabled\n  - `caseSensitive` will be `true`\n- everything else:\n  - locale: `en`\n  - `caseSensitive` will be `false`\n\nAt its core, `cspell-grammar` uses a simplified form of the TextMate grammar.\n\n## Reasoning\n\nWhy use a grammar parser? Couldn't a colorizer / highlighter or a language AST be used?\nAt one level, needs of the spell checker are simpler and different from colorizers or language AST parsers.\nThe goal of a spell checker is to spell check **_relevant_** text. The spell check does not need to care about\nthe syntactical correctness of a document or presentation.\n\nThe goal of a grammar parser for the spell checker is to allow the user to decide:\n\n1. What text should be checked.\n1. Which dictionaries (or languages) should be used.\n1. Are accents and case important\n\nNote: CSpell is a pure JavaScript application, so including the Oniguruma is not an option.\n\n### Considerations\n\n- Parsing a document should be fast - meaning the grammar should be as simple as possible to meet\n  the needs of the spell checker and not focus on scope detail. This is where a colorizer grammar is\n  not a good fit to be used.\n- AST's are a bit of an overkill for a spell checker. They provide too much detail while not bringing much benefit\n  from the detail.\n\n## Transformation\n\nConsider the following bit of LaTeX:\n\n```latex\nk\\\"{o}nnen\nkönnen\n```\n\n<!--- cspell:ignore können nnen   -->\n\nFor the spell checker to work correctly, the `\\\"{o}` should be transformed into `ö` before it is checked against the German dictionary.\n\nThis creates a few challenges.\n\nPossible options:\n\n1. Simple whole document substitution\n   - Challenges\n     - It is not context aware and might replace the wrong text.\n     - It changes the location of the words and messes up issue reporting (some sort of Map would be needed to get the correct line / character offset).\n\n- Advantages\n  - Easy to implement except for the context and mapping.\n\n1. Scope level substitution\n   Transformations occur at the scope level.\n   - Challenges\n     - offset mapping is still and issue (maybe)\n     - need a way to merge text with adjacent scopes after transformation\n   - Advantages\n     - it is context aware\n","publish_time":1679165228003,"maintainers":[{"name":"jason-dent","email":"jason@streetsidesoftware.nl"}],"_cnpm_publish_time":1679165228003,"dist-tags":{"latest":"10.4.0","next":"10.4.0-alpha.1"}}