Skip to content

Commit

Permalink
Wrap surrogate pairs in the same anonymous <span> (#139)
Browse files Browse the repository at this point in the history
  • Loading branch information
palemieux authored Dec 23, 2018
1 parent 92f9507 commit 71072b4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
20 changes: 17 additions & 3 deletions src/main/js/html.js
Original file line number Diff line number Diff line change
Expand Up @@ -299,13 +299,27 @@

// wrap characters in spans to find the line wrap locations

var cbuf = '';

for (var j = 0; j < isd_element.text.length; j++) {

var span = document.createElement("span");
cbuf += isd_element.text.charAt(j);

var cc = isd_element.text.charCodeAt(j);

if (cc < 0xD800 || cc > 0xDBFF || j === isd_element.text.length) {

/* wrap the character(s) in a span unless it is a high surrogate */

span.textContent = isd_element.text.charAt(j);
var span = document.createElement("span");

e.appendChild(span);
span.textContent = cbuf;

e.appendChild(span);

cbuf = '';

}

}

Expand Down

0 comments on commit 71072b4

Please sign in to comment.