{"name":"cspell-grammar","version":"6.2.4-alpha.0","keywords":["cspell","grammar"],"author":{"name":"Jason Dent","email":"jason@streetsidesoftware.nl"},"license":"MIT","_id":"cspell-grammar@6.2.4-alpha.0","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.js"},"dist":{"shasum":"16499f0f1a13f36510415aeaddabc2510c1a0e96","tarball":"http://registry-npm.ywwl.com/cspell-grammar/download/cspell-grammar-6.2.4-alpha.0.tgz","fileCount":62,"integrity":"sha512-6ZgQnWoxLGzoQllnvgGa28fk3X1gzyuf7jrusic3K281DbOZ7X7nYbBd+LRcYVKR4bjaaWgu6xK/Ljo4Dph8Ug==","signatures":[{"sig":"MEYCIQCICohZjJx+bDBmah1lG1h5u0IlFpqsBiqwdef6aGZHgQIhAPY7rV9y59DWSza7yE64MVzV7/n5wqpFwkYqdvXFXzW6","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":82135,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiznE7ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmoMLw//TrdO+Xq0SyGLPBHTAD696VFQ3J8Yd1oebmv11DtDiFYWT0i1\r\nUd22ksEXetQ6rjj6/tzjCZemk3WJE6qAOEfWt9hONCl5PRHga+dCBXvFQc/Y\r\n45LYwBJQPqTjg2IxXRFjsa+Lt3nXUtBfLNcCU8OOv4pokoBhaSEYoIFD8sXK\r\nf7QeOCxETJpq/R08DvWucxJBlYALz5s+X3zrri0yVeXOWUKVnlhZauB3DfbU\r\nNTUEnTdYpSEXLLgCcMwaCgDNHwfSxt3T6PjZELT2cUOl2kbrlypCQgdFXh3f\r\nxxgOJZtt0NjOsaUQkBa9iJE8ZUbM7Pz++XkFO2ptQD5M2dQq7UbHF4PZcE6p\r\nAcRmIjp3Z7ujva6PHDOm+AMNwgsz3YzDrOUFfMeQ2m39kt72UeMJSCiFCiwS\r\nvPLRMZp09YG2u9qSunKtGkGbQn8nAplY5GwavBwLgIkq91hFH4kx2L3OQE3E\r\n3Ea5o/4IZ7tDDNM0J3Jc9lxl/nRFGAK8kV3K4OcyQxoG3O/awco4ONW3KkAw\r\nrZCBVpsjo25vFR/IBhR55W0RHF+s8idSDFdSJBs0KGPsG2UuDxd8+3UP+V3v\r\nAhELZ+UKBwhwvkoDy0axjcs8R5f3r90J2P/tUG8hNeRziP9pjBSB7deJwZ16\r\nBX1TuNmwb2WjgUq0+ICuorAYYyX+p+zD//E=\r\n=Bcco\r\n-----END PGP SIGNATURE-----\r\n","size":21307,"noattachment":false,"key":"/cspell-grammar/-/cspell-grammar-6.2.4-alpha.0.tgz"},"main":"dist/index.js","engines":{"node":">=14"},"exports":{".":"./dist/index.js","./parsers/typescript":"./dist/parsers/typescript/index.js","./parsers/typescript/index.js":"./dist/parsers/typescript/index.js"},"gitHead":"3509b9fb14722e573713ba1828af6da6088a24e8","scripts":{"test":"jest","build":"tsc -p .","clean":"rimraf dist coverage .tsbuildinfo","watch":"tsc -p . -w","coverage":"jest --coverage","build-dev":"tsc -p tsconfig.dev.json","test-watch":"jest --watch","clean-build":"npm run clean && npm run build"},"typings":"index.d.ts","_npmUser":{"name":"jason-dent","email":"jason@streetsidesoftware.nl"},"repository":{"url":"git+https://github.com/streetsidesoftware/cspell.git","type":"git"},"_npmVersion":"lerna/5.1.8/node@v16.14.2+x64 (darwin)","description":"Grammar parsing support for cspell","directories":{"dist":"dist"},"_nodeVersion":"16.14.2","dependencies":{"@cspell/cspell-pipe":"^6.2.4-alpha.0","@cspell/cspell-types":"^6.2.4-alpha.0"},"typesVersions":{"*":{"*":["dist/*"],"parsers/*":["dist/parsers/*"],"index.d.ts":["dist/index.d.ts"]}},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^28.1.2","rimraf":"^3.0.2","@types/node":"^18.0.3"},"_npmOperationalInternal":{"tmp":"tmp/cspell-grammar_6.2.4-alpha.0_1657696571568_0.5685279312515692","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":1657696571869,"maintainers":[{"name":"jason-dent","email":"jason@streetsidesoftware.nl"}],"_cnpm_publish_time":1657696571869,"dist-tags":{"latest":"10.4.0","next":"10.4.0-alpha.1"}}