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

Custom search.seperator with lookbehind, in combination with highlighter, produces highlighting all over the place #5655

Closed
4 tasks done
hendrikp opened this issue Jun 28, 2023 · 3 comments · Fixed by #5656
Labels
bug Issue reports a bug resolved Issue is resolved, yet unreleased if open

Comments

@hendrikp
Copy link
Contributor

hendrikp commented Jun 28, 2023

Context

A custom search.seperator with lookbehind, in combination with highlighter, produces highlighting all over the place on the page.

This occured when adjusting the camelCasing/PascalCasing seperator to not seperate words if the words get too small e.g. AStar should not be seperated to highlight A+Star. In such cases the relevance of pages containing AStar compared to chapters containing just Star gets left behind and not found by users.

Description

There is in the sourcecode a hack in place src\assets\javascripts\integrations\search\highlighter\index.ts which reuses the search.seperator for the highlighting by removing lookaheads, it does however not yet remove lookbehinds. Thus when using lookbehinds the highlighting goes bonkers.

There would be two ways to solve this:

  • add a new search.seperator_highlight parameter which only is used for highlight seperation (new feature)
  • for now also remove lookbehinds (bug of in place hack)

So its kind of a bug, but also a change request.

To solve the bug adjust in src\assets\javascripts\integrations\search\highlighter\index.ts:

-    const temp = term.replace(/(\(\?[!=][^)]+\))/g, "")
+    const temp = term.replace(/(\(\?[!=<][^)]+\))/g, "")

Related links

Use Cases

In general seperating things like IsFloat etc also is not useful as when searching code Is+Float will result in many results but not in the function to find.

So the idea was to start the seperation of camelCasing/PascalCasing only with 3>= characters. Which would start with the classic Get / Set / Can but not with Is, or Single char prefixes.

The separator casing fragment was modified in such way:

(?!\b)(?=[A-Z][a-z]{2,})(?<!\b\w{0,2})

Sample:

  • Starts seperating on GetThis, but not AStar or IsStar

Visuals

No response

Before submitting

@squidfunk
Copy link
Owner

Thanks for reporting and the possible fix. We're currently reworking the search and everything that is related, so we currently don't consider adding a new separator configuration setting, because highlighting will be solved differently with the new plugin. However, we can definitely merge the fix for the lookbehind.

@squidfunk squidfunk added bug Issue reports a bug resolved Issue is resolved, yet unreleased if open labels Jun 29, 2023
@squidfunk
Copy link
Owner

Keeping open until released.

@squidfunk squidfunk reopened this Jun 29, 2023
@squidfunk
Copy link
Owner

Released as part of 9.1.18. Thanks for your help on this issue!

github-merge-queue bot pushed a commit to slackhq/circuit that referenced this issue Jul 4, 2023
This PR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [mkdocs-material](https://togithub.com/squidfunk/mkdocs-material) |
patch | `==9.1.17` -> `==9.1.18` |

---

### ⚠ Dependency Lookup Warnings ⚠

Warnings were logged while processing this repo. Please check the
Dependency Dashboard for more information.

---

### Release Notes

<details>
<summary>squidfunk/mkdocs-material (mkdocs-material)</summary>

###
[`v9.1.18`](https://togithub.com/squidfunk/mkdocs-material/releases/tag/9.1.18):
mkdocs-material-9.1.18

[Compare
Source](https://togithub.com/squidfunk/mkdocs-material/compare/9.1.17...9.1.18)

-   Updated Danish translations
-   Added support for installing user requirements in Docker image
- Fixed
#&#8203;[squidfunk/mkdocs-material#5655):
Search separator with lookbehind breaks highlighting

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Renovate
Bot](https://togithub.com/renovatebot/renovate).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNS4xNTkuNCIsInVwZGF0ZWRJblZlciI6IjM1LjE1OS40IiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue reports a bug resolved Issue is resolved, yet unreleased if open
Projects
None yet
2 participants