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

Problem in detection of lang: in yaml front matter #156

Closed
GuillaumeAllain opened this issue Feb 16, 2022 · 2 comments
Closed

Problem in detection of lang: in yaml front matter #156

GuillaumeAllain opened this issue Feb 16, 2022 · 2 comments
Assignees
Labels
1-bug 🐛 Issue type: Bug report (something isn't working as expected) 2-confirmed Issue status: Confirmed, reproducible bug in LTeX 3-fixed Issue resolution: Issue has been fixed on the develop branch
Milestone

Comments

@GuillaumeAllain
Copy link

Describe the bug
In the case where lang: language where language is not in quotes, the yaml parsers seems to take on all following options as a language: 'language\nfollowingtitle: option\n'

Steps to reproduce
Steps to reproduce the behavior:

  1. Create document with some options after lang: language in yaml front matter. The language shouldn't be encased in quotes
  2. ltex can't initialize because the language is not recognized

Expected behavior
Only us language string and stop at newline

Sample document

---
lang: en
title: This is a test
---

Text.

LTeX LS log

 `ERROR][2022-02-16 10:48:51] .../vim/lsp/rpc.lua:420    "rpc"   "/Users/guillaumeallain/.local/share/nvim/lsp_servers/ltex/ltex-ls/bin/ltex-ls" "stderr"        "févr. 16, 2022 10:48:51 A.M. org.bsplines.ltexls.languagetool.LanguageToolJavaInterface <init>\nGRAVE: 'en\ntitle: This is a test' is not a recognized language. Leaving LanguageTool uninitialized, checking disabled.\n"`

Version information
List here the version information of the relevant software.

  • Operating system: macOS 11.6.3
  • ltex-ls: 15.2.0

Additional context/information

This works without problem when the language string is between quotes. By looking at tests, this doesn't seem like something that can be seen by the current tests for the yaml front matter

@GuillaumeAllain GuillaumeAllain 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 Feb 16, 2022
@GuillaumeAllain
Copy link
Author

The problem seems to be coming from regex which doesn't match new line in the case where there is no quotes:

"\\A---[ \t]*$.*?^lang:[ \t]+(?:\"(.+)\"|'(.+)'|(.+))$.*?^---[ \t]*$",

The regex:
"\\A---[ \t]*$.*?^lang:[ \t]+(?:\"(.+)\"|'(.+)'|(.+))$.*?^---[ \t]*$"

Should be replaced by:
"\\A---[ \t]*$.*?^lang:[ \t]+(?:\"(.+)\"|'(.+)'|([^\n]+))$.*?^---[ \t]*$"

To catch everything between lang: and the newline

However I have not tested this solution and a test should be added to catch this behaviour

@valentjn valentjn added 2-confirmed Issue status: Confirmed, reproducible bug in LTeX and removed 2-unconfirmed Issue status: Bug that needs to be reproduced (all new bugs have this label) labels Feb 12, 2023
@valentjn valentjn self-assigned this Feb 12, 2023
@valentjn valentjn added this to the 16.0.0 milestone Feb 12, 2023
valentjn added a commit that referenced this issue Feb 12, 2023
@valentjn valentjn added the 3-fixed Issue resolution: Issue has been fixed on the develop branch label Feb 12, 2023
@github-actions
Copy link

This issue is now fixed on develop. The fix will be included in the next release of LTEX.

If you don't want to wait, you can try out the nightly pre-release tomorrow. Nightly pre-releases are published every morning at around 4am UTC.

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-confirmed Issue status: Confirmed, reproducible bug in LTeX 3-fixed Issue resolution: Issue has been fixed on the develop branch
Projects
None yet
Development

No branches or pull requests

2 participants