MCPcopy Index your code
hub / github.com/DHTMLX/gantt / splitSpaces

Function splitSpaces

samples/common/codehighlight/codemirror.js:1860–1871  ·  view source on GitHub ↗
(text, trailingBefore)

Source from the content-addressed store, hash-verified

1858 // Change some spaces to NBSP to prevent the browser from collapsing
1859 // trailing spaces at the end of a line when rendering text (issue #1362).
1860 function splitSpaces(text, trailingBefore) {
1861 if (text.length > 1 && !/ /.test(text)) { return text }
1862 var spaceBefore = trailingBefore, result = "";
1863 for (var i = 0; i < text.length; i++) {
1864 var ch = text.charAt(i);
1865 if (ch == " " && spaceBefore && (i == text.length - 1 || text.charCodeAt(i + 1) == 32))
1866 { ch = "\u00a0"; }
1867 result += ch;
1868 spaceBefore = ch == " ";
1869 }
1870 return result
1871 }
1872
1873 // Work around nonsense dimensions being reported for stretches of
1874 // right-to-left text.

Callers 1

buildTokenFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected