-
-
Notifications
You must be signed in to change notification settings - Fork 222
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
Implement wildcards option #114
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd vote to name this option wildcards
instead of useWildcards
, as we have option names like diacritics
too, not useDiacritics
.
I'd also vote to ignore escaped wildcards, e.g. ignore them in the following keyword: lor\?m
, even if wildcards
is true
.
Do you agree?
Sure, no problem!
There is a problem with that...
What do you think? |
I'm against this option, since it's not common.
If you look at the |
Hmm, well the |
And normalize case insensitive diacritics array
One of the issues specified in #108 Squashed commit of the following: commit 867dabe Author: Julian Motz <me@julianmotz.com> Date: Mon Feb 6 10:48:58 2017 +0100 Update patch level commit e46fff2 Merge: 0644a91 5b2dadb Author: Julian Motz <me@julianmotz.com> Date: Mon Feb 6 10:46:23 2017 +0100 Merge branch 'master' into issue-108 Resolved merge conflict commit 0644a91 Author: Rob Garrison <wowmotty@gmail.com> Date: Mon Jan 30 15:22:56 2017 -0600 Prevent adding empty string synonyms. See #108
In the last update, the
So to get the demo in #119 working, you have two choices (see https://jsfiddle.net/Mottie/6kqr1d88/4/):
But, setting the option to include whitespace does have some consequences! if for example you use the keyword |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. However, why is it necessary to call setupWildcardsRegexp()
in the synonyms method, when the this.createWildcardsRegexp()
method is called after this.createSynonymsRegexp()
?
src/mark.js
Outdated
@@ -776,6 +828,20 @@ class Mark { // eslint-disable-line no-unused-vars | |||
* <li><i>limiters</i>: A custom array of string limiters for accuracy | |||
* "exactly" or "complementary"</li> | |||
* </ul> | |||
* @property {"disable"|"enable"|"includeSpaces"} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please outsource the JSDOC as a @typedef
like here. This way it's possible to reference it in other functions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, np!
"done": function () { | ||
new Mark($ctx2[0]).mark("Lor*m", { | ||
"synonyms": { | ||
"Lor*m": "Ips*m" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is it necessary to call setupWildcardsRegexp() in the synonyms method
This allows you to include wildcards in the synonyms. Does that sound reasonable?
First off, I incorrectly named an option in my last comment... it's not I'm also starting to think we might need to change the "?" wildcard to match zero or one characters instead of only one character. That way you could use "World?s" to mark |
|
"enable" -> "enabled" "disable" -> "disabled" "includeSpaces" -> "withSpaces"
Previously set to match only one
shit mate, I'm very sorry for the long delay. I'm doing some tests in the next hours and will come back with some review. |
Beautified code and outsourced the accuracy property into a @typedef definition to make it consistent with the wildcards property
They must be included after diacritics and synonyms tests, since they depend on them
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Mottie Thanks for the great work. It looks very good overall. The only thing I'm missing is a test for the disabled
value. Then I think we're safe to publish this as a new minor release!
The HTML <div>
<p>
Lorenzom ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod
tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.
Lorem ipsum dolor sit amet, consetetur sadipscing elitr. Loriem ipsum
dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor
invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.
Lorm ipsum Lorum ipsum, et Loram ipsum. Lor?m ipsum. Lor*m ipsum.
</p>
</div> Script new Mark($ctx4[0]).mark(["lor?m", "Lor*m"], {
"separateWordSearch": false,
"wildcards": "disabled",
"done": done
});
// ...
it("should find wildcards as plain characters when disabled", function () {
expect($ctx4.find("mark")).toHaveLength(2);
}); |
This PR adds the
useWildcard
enhancement discussed in #112.