Accuracy: exactly + accrossElements: true doesn't work with <br> delimited text
See original GitHub issueHi,
Mark.js doesn’t highlight words which ends with <br>
tag:
For example, <p>Some one<br>Some two</p>
.
“Some one” will not be found, when options contains both of accuracy: exactly and accrossElements: true.
As I understood, when you’re looking accross elements, you concatenate text nodes of dom element tree, and than try to match accuracy exactly regexp /(^|\s)({{ word }})(?=$|\s)/gim. So previous example will search matches in string “Some oneSome two” and will not match.
Steps to reproduce
JSFiddle: https://jsfiddle.net/bw7ghxd0/2/
Thanx.
Issue Analytics
- State:
- Created 7 years ago
- Comments:18 (6 by maintainers)
Top Results From Across the Web
mark.js - Bountysource
Accuracy : exactly + accrossElements: true doesn't work with <br> delimited ... text nodes of dom element tree, and than try to match...
Read more ><br>: The Line Break element - HTML - MDN Web Docs - Mozilla
The HTML element produces a line break in text (carriage-return). It is useful for writing a poem or an address, where the division...
Read more >How to change the height of a <br>? [duplicate] - Stack Overflow
<br> means you just put another line to your text and single paragraph should have fixed line height. If some text is separated,...
Read more >HTML Line Break – How to Break a Line with the HTML <br ...
If you don't insert your own line breaks, then the text gets formatted in an odd way. In this tutorial, I'm going to...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yes, this would be the solution for the issue. However, it needs a rewrite of the internal DOM iterator and therefore will take some time. The option to differentiate between block elements and non-block elements won’t make it easier… However, I’ll come back to this.
Hi @julmot,
I’m the developer of Highlightall extension, which makes use of your excellent library to highlight text upon selection. If there’s still a chance that this issue be fixed in a future release, it would be decisive to add a “Match whole words” option in the extension (which I was about to add but I can’t do it with this issue). Thanks anyway for the great job.
Jerome