question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Accuracy: exactly + accrossElements: true doesn't work with <br> delimited text

See original GitHub issue

Hi, 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:closed
  • Created 7 years ago
  • Comments:18 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
julmotcommented, Feb 9, 2018

Would it be possible to handle the closing tag of each block-level element as a space

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.

1reaction
J3r0mcommented, Nov 15, 2020

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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found