streetsidesoftware / cspell

A Spell Checker for Code!
https://cspell.org
MIT License
1.26k stars 103 forks source link

Latex special character codes #361

Open oli-ver opened 4 years ago

oli-ver commented 4 years ago

Is there a way to deal with LaTeX escaped special characters (i. e. umlauts)? The spell checker should detect such characters and interpret them as the UTF-8 character, for example:

k\"{o}nnen
können

Right now these words cannot be checked:

grafik

Im my opinion it would suffice to offer a string search and replace feature for something like that where I can input patterns I want to replace before spell-check, for example:

  "cSpell.search-replace": {
        "\"{o}": "ö",
        "\"{a}": "ä"
    }

Is there perhaps already something available that can be used?

nschonni commented 4 years ago

Did you try the repMap https://github.com/streetsidesoftware/cspell/tree/master/packages/cspell#dictionary-definition

oli-ver commented 4 years ago

I actually did not see this in the docs, thanks for the hint @nschonni.

Do I understand correctly that I just can use a separate dictionary file and use these repMap patterns? I tried to configure it like this:

# settings.json
    "cSpell.dictionaries": ["deTest"],
    "cSpell.dictionaryDefinitions": [{
        "name": "deTest",
        "path": "./de.txt",
        "repMap": [
            ["\"{o}", "ö"],
            ["\\\"{o}", "ö"], #not sure how to escape the characters here
            ["\"{a}", "ä"],
            ["\"{u}", "ü"]
        ]
    }]

# de.txt
könnte

#test.tex
k\"{o}nnte

The words with escaped umlauts still cannot be spell checked:

image

Did I perhaps configure it wrong?

nschonni commented 4 years ago

Sorry, I don't remember if I've actually used it before. Think I usually just ignored them with https://github.com/streetsidesoftware/cspell/tree/master/packages/cspell#exclude-patterns

I think you might need to escape the curly braces like \{ \} though

@Jason3S would probably be the one to properly answer