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

exception when using searchPattern #110

Open
ctcpip opened this issue Aug 22, 2023 · 1 comment
Open

exception when using searchPattern #110

ctcpip opened this issue Aug 22, 2023 · 1 comment

Comments

@ctcpip
Copy link

ctcpip commented Aug 22, 2023

searchPattern: "/(?<=[\\w\\d ])\\n(?=[\\w\\d])/g"

results in:

search-replace Custom rule [This rule threw an exception: Property 'range' of onError parameter is incorrect.]

what's interesting is that the rule actually seems to work, it's just a problem with the output. this rule is meant to catch linebreaks within a sentence. e.g.

The following line
break should not exist.
@OnkarRuikar
Copy link
Owner

@ctcpip From a plugin, we can't report error to markdownlint which spans multiple lines. The error range can't cross line ending.
As a workaround, when the plugin finds a multi line match it is split on \n and a separate error is reported for each line. So the match needs to have at least one character on both sides of \n. With following custom rule definition you can achieve what you want:

{
  "name": "no-hardwraps",
  "message": "Do not use hard wraps",
  "searchPattern": "/[\\w\\d ]\\n[\\w\\d]/gm",
  "searchScope": "text"
}

Note: Due to the limitation this will only report errors and will not be able to perform auto fixes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants