Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs: how to ignore a markdown block based on its syntaxe #31

Closed
nweldev opened this issue Apr 1, 2020 · 4 comments
Closed

Docs: how to ignore a markdown block based on its syntaxe #31

nweldev opened this issue Apr 1, 2020 · 4 comments
Assignees
Labels
1-bug 🐛 Issue type: Bug report (something isn't working as expected) 2-unconfirmed Issue status: Bug that needs to be reproduced (all new bugs have this label) 3-not-a-bug Issue resolution: LTeX behaves as expected, or bug cannot be reproduced

Comments

@nweldev
Copy link

nweldev commented Apr 1, 2020

This is more a question than a bug, as there is no documentation for this use case.

Description
I want to ignore all Vuepress Code Snippet Import blocks in my markdown files. ignoreRuleInSentence permit to do that, but based on the README it seems like a hack, and I guess there is a better approach for that, as this increased memory & CPU consumption.

Steps to reproduce
Steps to reproduce the behavior:

  1. Add a Vuepress Code Snippet Import block to a markdown file
Lorem ipsum:

<<< @/path/to/a/file.js

Lorem ipsum dolor ...
  1. A bunch of LTex warnings should show for this block. Click on one of these warnings, and select "ignore rule in this sentence"
  2. Go to VS Code settings, and remove the end of the sentence in ltex.ignoreRuleInSentence in order to match all sentences starting with <<< @/. Here is an example :
{
  "ltex.ignoreRuleInSentence": [
    {
      "rule": "FR_SPELLING_RULE",
      "sentence": "^\\Q<<< @/../\\E"
    },
    {
      "rule": "DOUBLE_PUNCTUATION",
      "sentence": "^\\Q<<< @/../\\E"
    }
  ]
}
  1. Restart VS Code. All LTex warnings disappeared.
  2. Go to Help > Open Process Explorer : (small) memory consumption increased (using top, we can see that CPU load increased too)
@nweldev nweldev added 1-bug 🐛 Issue type: Bug report (something isn't working as expected) 2-unconfirmed Issue status: Bug that needs to be reproduced (all new bugs have this label) labels Apr 1, 2020
@valentjn
Copy link
Owner

@noelmace What exactly is the bug or your question?

@valentjn valentjn added the 2-needs-info Issue status: We need more information (usually) from the submitter before continuing label Apr 10, 2020
@nweldev
Copy link
Author

nweldev commented Apr 10, 2020

Sorry @valentjn it wasn't clear enough 😅

So, to rephrase that: is there a better way to ignore some markdown blocks based on their syntax?

Also:

  1. Is ignoreRuleInSentence supposed to be used this way? (wording and performances make me think it doesn't)
  2. What's the exact format for this option? Looks like kind of a regex, but not exactly 🤷 Notice I removed the $ because it doesn't work if I don't.
  3. Should we think about a better way to do that? Maybe a dedicated option?

Ultimately, this could be considered a "discussion + request for doc" issue 😉

@valentjn valentjn removed the 2-needs-info Issue status: We need more information (usually) from the submitter before continuing label Apr 18, 2020
@valentjn valentjn self-assigned this May 1, 2020
valentjn added a commit that referenced this issue May 1, 2020
@valentjn
Copy link
Owner

valentjn commented May 1, 2020

@noelmace Thanks for the clarification.

  1. Basically yes. The primary way to use ignoreRuleInSentence was/is by using the respective quick fix. But it's also possible to manually edit the sentence. The description wasn't really clear about this. I've clarified this now (see e66b3a3).
  2. It is simply a Java-compatible regex.
    Basically, LT tokenizes the document into so-called "sentences" (usually based on periods). After getting the matches from LT, LTEX checks for each of the rule matches if the sentence, in which the rule occurred, matches one of the regexes given in ignoreRuleInSentence. The reason for it being a regex instead of a plain string is that sometimes, especially in LATEX documents, parts of the text such as formulas are replaced by "dummy" words which include a counter as a suffix. This is simply to avoid LT matches of repeated words. The regex can cope with this variable suffix.
    I guess you have to remove the $ because the LT sentence continues after the <<< @. Probably the whole line is an LT "sentence". You can see the sentence if you use the quick fix and look for the new entry in settings.json.
  3. Hm. I think this is a pretty special case, and I haven't heard of VuePress before. As long as it works for you, we shouldn't introduce even more settings as there already are.

Regarding the performance, there was an issue affecting the performance when using ignore rule/sentence pairs (see #29). It should be much faster now.

@valentjn valentjn closed this as completed May 1, 2020
@valentjn valentjn added 3-not-a-bug Issue resolution: LTeX behaves as expected, or bug cannot be reproduced and removed 2-unconfirmed Issue status: Bug that needs to be reproduced (all new bugs have this label) labels May 1, 2020
@nweldev
Copy link
Author

nweldev commented May 2, 2020

Great, Thx.

@valentjn valentjn added the 2-unconfirmed Issue status: Bug that needs to be reproduced (all new bugs have this label) label Jul 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1-bug 🐛 Issue type: Bug report (something isn't working as expected) 2-unconfirmed Issue status: Bug that needs to be reproduced (all new bugs have this label) 3-not-a-bug Issue resolution: LTeX behaves as expected, or bug cannot be reproduced
Projects
None yet
Development

No branches or pull requests

2 participants