valentjn / ltex-ls

LTeX Language Server: LSP language server for LanguageTool :mag::heavy_check_mark: with support for LaTeX :mortar_board:, Markdown :pencil:, and others
https://valentjn.github.io/ltex
Mozilla Public License 2.0
717 stars 33 forks source link

restructuredText ltex.hiddenFalsePositive #301

Open koeppe-at-pdtec opened 2 months ago

koeppe-at-pdtec commented 2 months ago

Hello,

i want to use ltex on rst files in vscode. As it lacks some linting capabilities for rst i want to add them myself to remove false positives.

i have a .vscode\ltex.hiddenFalsePositives.en-US.txt file that works for me except I fail to match code blocks via regex. Actually i even fail to match the first line. I'm out of clues what i'am doing wrong.

here is my example. example.zip

.vscode\ltex.hiddenFalsePositives.en-US.txt The last line does not match

{"rule":"DOUBLE_PUNCTUATION","sentence":"(\\.\\./)+"}
{"rule":"MORFOLOGIK_RULE_EN_US","sentence":"^\\ *?\\.\\.\\ +\\w+\\:\\:.*?$"}
{"rule":"MORFOLOGIK_RULE_EN_US","sentence":"(\\w+_)+\\w+"}
{"rule":"UPPERCASE_SENTENCE_START","sentence":"(\\w+_)+\\w+"}
{"rule":"MORFOLOGIK_RULE_EN_US","sentence":"\\|\\w+\\|"}
{"rule":"UPPERCASE_SENTENCE_START","sentence":"^\\ *\\.\\.\\ +code-block::.*?$"}

test.rst

.. code-block:: json

    {
        "test": 123
    }
koeppe-at-pdtec commented 2 months ago

Might be a bug:

the request to the LS is

Params: {
    "command": "_ltex.checkDocument",
    "arguments": [
        {
            "uri": "file:///c%3A/pdtec/gitlab/simdata-manager-reference-manual/test.rst",
            "codeLanguageId": "restructuredtext",
            "text": ".. code-block:: json\r\n\r\n    {\r\n        \"test\": 123\r\n    }\r\n"
        }
    ]
}

the configuration request result (only the important part):

        "hiddenFalsePositives": {
            "en-US": [
                "{\"rule\":\"DOUBLE_PUNCTUATION\",\"sentence\":\"(\\\\.\\\\./)+\"}",
                "{\"rule\":\"MORFOLOGIK_RULE_EN_US\",\"sentence\":\"(\\\\w+_)+\\\\w+\"}",
                "{\"rule\":\"MORFOLOGIK_RULE_EN_US\",\"sentence\":\"\\\\|\\\\w+\\\\|\"}",
                "{\"rule\":\"MORFOLOGIK_RULE_EN_US\",\"sentence\":\"^\\\\ *?\\\\.\\\\.\\\\ +\\\\w+\\\\:\\\\:.*?$\"}",
                "{\"rule\":\"UPPERCASE_SENTENCE_START\",\"sentence\":\"(\\\\w+_)+\\\\w+\"}",
                "{\"rule\":\"UPPERCASE_SENTENCE_START\",\"sentence\":\"^\\\\ *\\\\.\\\\.\\\\ +code-block::.*?$\"}"
            ],

the rule "{\"rule\":\"UPPERCASE_SENTENCE_START\",\"sentence\":\"^\\\\ *\\\\.\\\\.\\\\ +code-block::.*?$\"}"

results, after parsed twice, in this regex ^\ *\.\.\ +code-block::.*?$ that matches this string ".. code-block:: json\r\n\r\n {\r\n \"test\": 123\r\n }\r\n"

So either the regexp is wrong escaped or the server does apply the regex differently than i think