Closed lynear24 closed 2 years ago
Thanks for reporting.
That's the consequence of my bad code. I used regex to highlight the HTML code directly, and when r
keyword is typed, it tries to wrap the r
letter of <mark>
tag again, causing this strange behavior.
I don't have a good idea how to fix this yet.
@lynear24 maybe integrating this instead (or as an option) for the current search function in the theme can help? https://codewithhugo.com/hugo-lunrjs-search-index/
hi, the trivial workaround is to disable the keyword highlithing removing the tag from the marker function:
public static marker(match) { return match; }
but I like keyword highlithing and I want to try to work on it. My idea is to posticipate the marker substitution at the end of the search and not in the meantime from one keyword search and the others.
Describe the bug
Using a single character as a keyword in the search page creates this weird behavior that nests \<mark> tags improperly (showing the "rk>" part of \<mark> as text in the search outputs). It also duplicates matched text the more you type the same letter again.
Expected behavior
It shouldn't nest the mark tags improperly and it shouldn't duplicate the text in the search output. I just manually tweaked search.tsx to only accept keywords that are at least 2 chars long (as a temporary fix).
To Reproduce
Type a complete word and a letter in that same word separated by whitespace. Typing the same letter again and again as another word duplicates the text that matches the search.
Screenshots
\<mark> nesting improperly
duplicating results
Environment
Content of config.yaml
Link to the demo site and/or source repository
Link to site