Highlight regex issue when HTML is on a single line
See original GitHub issueI want to highlight all words in an HTML that start with a specific string, “OfficeSuite” in my case, e.g. “OfficeSuite” and “OfficeSuiteabc” should be highlighted.
It is not working when I have the following HTML:
<div>some text</div><div>OfficeSuite</div>
But it works when the HTML is formatted in multiple lines:
<div>some text</div>
<div>OfficeSuite</div>
I assume this is because when the HTML is on one line, after the tags are stripped what remains is “some textOfficeSuite” which violates the rule that the word should start with “OfficeSuite”.
Is there a way to make this work?
I’m using markjs v9.0.0
To Reproduce Example of working and not working version of the same code, the only difference being the HTML is/is not formatted on multiples lines. mark-js-test.zip
Desktop (please complete the following information):
- Chrome
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (1 by maintainers)
Top GitHub Comments
Hi ✋ @Nevca , I have tested your shared zip file (test.html). I observe the regex expression and modified it. After modifying it observed that updated expression is more efficient and matches your requirement.
`// window.htmlViewer.highlightRegex(‘(?<![\p{L}])(officesuite)’);
window.htmlViewer.highlightRegex(‘(?<![\p{L}0-9])(officesuite)’);`
Please check
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.