cspell-grammar
Grammar parsing support for cspell
Last updated a year ago by jason-dent .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ gnpm install cspell-grammar 
SYNC missed versions from official npm registry.

cspell-grammar

CSpell 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.

This is to address the issues and limitations related to ignoreRegExpList and includeRegExpList.

The parser is use to add scope to sections of a document. The scope can then be used to apply spell checking rules.

Example: Only check comments and strings

rules:
  '*': false
  comment: true
  string: true

It can be even more powerful like controlling the language settings based upon scope.

rules:
  comment:
    language: en
  string:
    language: en,fr
    dictionaries: ['marketing-terms'],
    caseSensitive: true
  string.javascript:
    caseSensitive: false

Rules are applied in the order they match the scope of the text.

When checking JavaScript files with the above example rules:

  • strings will:
    • use the locale en,fr
    • the marketing-terms dictionary will be enabled
    • caseSensitive will be true
  • everything else:
    • locale: en
    • caseSensitive will be false

At its core, cspell-grammar uses a simplified form of the TextMate grammar.

Reasoning

Why use a grammar parser? Couldn't a colorizer / highlighter or a language AST be used? At one level, needs of the spell checker are simpler and different from colorizers or language AST parsers. The goal of a spell checker is to spell check relevant text. The spell check does not need to care about the syntactical correctness of a document or presentation.

The goal of a grammar parser for the spell checker is to allow the user to decide:

  1. What text should be checked.
  2. Which dictionaries (or languages) should be used.
  3. Are accents and case important

Note: CSpell is a pure JavaScript application, so including the Oniguruma is not an option.

Considerations

  • Parsing a document should be fast - meaning the grammar should be as simple as possible to meet the needs of the spell checker and not focus on scope detail. This is where a colorizer grammar is not a good fit to be used.
  • AST's are a bit of an overkill for a spell checker. They provide too much detail while not bringing much benefit from the detail.

Transformation

Consider the following bit of LaTeX:

k\"{o}nnen
können

For the spell checker to work correctly, the \"{o} should be transformed into ö before it is checked against the German dictionary.

This creates a few challenges.

Possible options:

  1. Simple whole document substitution
    • Challenges
      • It is not context aware and might replace the wrong text.
      • 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).
  • Advantages
    • Easy to implement except for the context and mapping.
  1. Scope level substitution Transformations occur at the scope level.
    • Challenges
      • offset mapping is still and issue (maybe)
      • need a way to merge text with adjacent scopes after transformation
    • Advantages
      • it is context aware

Current Tags

  • 7.3.6                                ...           latest (a year ago)
  • 7.0.1-alpha.9                                ...           next (a year ago)

103 Versions

  • 7.3.6                                ...           a year ago
  • 7.3.5                                ...           a year ago
  • 7.3.4                                ...           a year ago
  • 7.3.3                                ...           a year ago
  • 7.3.2                                ...           a year ago
  • 7.3.1                                ...           a year ago
  • 7.3.0                                ...           a year ago
  • 7.2.0                                ...           a year ago
  • 7.1.1                                ...           a year ago
  • 7.0.2                                ...           a year ago
  • 7.0.1                                ...           a year ago
  • 7.0.0                                ...           a year ago
  • 7.0.1-alpha.9                                ...           a year ago
  • 6.31.3                                ...           a year ago
  • 7.0.1-alpha.8                                ...           a year ago
  • 7.0.1-alpha.7                                ...           a year ago
  • 7.0.1-alpha.6                                ...           a year ago
  • 7.0.1-alpha.5                                ...           a year ago
  • 7.0.1-alpha.4                                ...           a year ago
  • 7.0.1-alpha.3                                ...           a year ago
  • 7.0.1-alpha.2                                ...           a year ago
  • 7.0.1-alpha.1                                ...           a year ago
  • 7.0.1-alpha.0                                ...           2 years ago
  • 7.0.0-alpha.2                                ...           2 years ago
  • 7.0.0-alpha.1                                ...           2 years ago
  • 6.31.1                                ...           2 years ago
  • 6.31.0                                ...           2 years ago
  • 6.30.2                                ...           2 years ago
  • 6.30.1                                ...           2 years ago
  • 6.30.0                                ...           2 years ago
  • 6.29.3                                ...           2 years ago
  • 6.29.2                                ...           2 years ago
  • 6.29.1                                ...           2 years ago
  • 6.29.0                                ...           2 years ago
  • 6.28.0                                ...           2 years ago
  • 6.27.0                                ...           2 years ago
  • 6.26.3                                ...           2 years ago
  • 6.26.2                                ...           2 years ago
  • 6.26.1                                ...           2 years ago
  • 6.26.0                                ...           2 years ago
  • 6.25.0                                ...           2 years ago
  • 6.24.0                                ...           2 years ago
  • 6.23.1                                ...           2 years ago
  • 6.23.0                                ...           2 years ago
  • 6.22.0                                ...           2 years ago
  • 6.21.0                                ...           2 years ago
  • 6.20.1                                ...           2 years ago
  • 6.20.0                                ...           2 years ago
  • 6.19.2                                ...           2 years ago
  • 6.19.1                                ...           2 years ago
  • 6.19.0                                ...           2 years ago
  • 6.18.1                                ...           2 years ago
  • 6.18.0                                ...           2 years ago
  • 6.17.0                                ...           2 years ago
  • 6.16.0                                ...           2 years ago
  • 6.15.1                                ...           2 years ago
  • 6.15.0                                ...           2 years ago
  • 6.14.3                                ...           2 years ago
  • 6.14.2                                ...           2 years ago
  • 6.14.1                                ...           2 years ago
  • 6.14.0                                ...           2 years ago
  • 6.13.3                                ...           2 years ago
  • 6.13.2                                ...           2 years ago
  • 6.13.1                                ...           2 years ago
  • 6.13.0                                ...           2 years ago
  • 6.12.0                                ...           2 years ago
  • 6.11.1                                ...           2 years ago
  • 6.11.0                                ...           2 years ago
  • 6.10.1                                ...           2 years ago
  • 6.10.0                                ...           2 years ago
  • 6.9.1                                ...           2 years ago
  • 6.9.0                                ...           2 years ago
  • 6.8.2                                ...           2 years ago
  • 6.8.1                                ...           2 years ago
  • 6.8.0                                ...           2 years ago
  • 6.7.0                                ...           2 years ago
  • 6.6.1                                ...           2 years ago
  • 6.6.1-alpha.9                                ...           2 years ago
  • 6.6.1-alpha.2                                ...           2 years ago
  • 6.6.1-alpha.1                                ...           2 years ago
  • 6.6.1-alpha.0                                ...           2 years ago
  • 6.6.0                                ...           2 years ago
  • 6.5.0                                ...           2 years ago
  • 6.4.2                                ...           2 years ago
  • 6.4.1                                ...           2 years ago
  • 6.4.0                                ...           2 years ago
  • 6.4.0-alpha.0                                ...           2 years ago
  • 6.3.0                                ...           2 years ago
  • 6.2.4-alpha.0                                ...           2 years ago
  • 6.2.3                                ...           2 years ago
  • 6.2.2                                ...           2 years ago
  • 6.2.1                                ...           2 years ago
  • 6.2.0                                ...           2 years ago
  • 6.2.0-alpha.1                                ...           2 years ago
  • 6.2.0-alpha.0                                ...           2 years ago
  • 6.1.3                                ...           2 years ago
  • 6.1.3-alpha.1                                ...           2 years ago
  • 6.1.3-alpha.0                                ...           2 years ago
  • 0.1.5                                ...           7 years ago
  • 0.1.3                                ...           7 years ago
  • 0.1.2                                ...           7 years ago
  • 0.1.1                                ...           7 years ago
  • 0.1.0                                ...           7 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 20
Last Day 0
Last Week 20
Last Month 0
Dependencies (2)
Dev Dependencies (1)

Copyright 2013 - present © cnpmjs.org | Home |