0

I'm using markjs (https://markjs.io/) in my project. This is basically used to highlight text. It works fine except for some text with unicode characters in it. For example text with characters "\xA0"

Here is the jsfiddle link for testing https://jsfiddle.net/trupti11/4zh3w0a8/2/

Here is the code sample

JQuery script

$(function() {

  alert($('.txtHolder').text())
  alert($('.txtHolder').text().toSource());

   $('.txtHolder1').mark($('.txtHolder1').text());
   $('.txtHolder2').mark($('.txtHolder2').text());


});

HTML

 <div class="txtHolder">

<div class="editor"><span class="sitepoint-creditspage-contrib"><sen name="28" class="h h28">Technical Editor:&nbsp;</sen></span><span class="firstname"><sen name="29" class="h h29">Editor</sen></span> <span class="surname"><sen name="30" class="h h30">One</sen></span></div>

  <div class="editor"><span class="sitepoint-creditspage-contrib"><sen name="31" class="h h31">English Editor:&nbsp;</sen></span><span class="firstname"><sen name="32" class="h h32">Editor</sen></span> <span class="surname"><sen name="33" class="h h33">Two</sen></span>
  This doesn't get marked.</div>
<br/>
  <div class="txtHolder2">
  This text gets marked.
  </div>
  </div>

Thanks for any help!

pravid
  • 719
  • 9
  • 27
  • I also tried using one of the options in makjs "synonyms": { "\xA0": " " } but that doesn't work. Also tried replacing unicode characters var newText = _text.replace(/[^\x00-\x7F]/g, ""); which doesn't work as well. – pravid Mar 08 '17 at 11:38

1 Answers1

0

Solved in the following GitHub issue:

https://github.com/julmot/mark.js/issues/124

dude
  • 5,678
  • 11
  • 54
  • 81
  • This is not the correct solution. If you add filter parameter to mark function, it doesn't work as expected. See the fiddle with require filter parameter https://jsfiddle.net/trupti11/4zh3w0a8/11/ Not sure what is missing here. – pravid Mar 15 '17 at 15:09