javascript - Display space characters in pre tag -


in visual studio , other code editors possible view white space characters. these appear small ellipses in line.

is possible mimic feature in html. have been able use pre tag display text @ loss on how display white space characters.

is possible via css or javascript show white space characters?

you can wrap each space in pre elements in span background, spaces become visible, copy text usually. here jsfiddle example.

example script (assuming there no nested tags in pre):

var pres = document.queryselectorall('pre');  (var = 0; < pres.length; i++) {     pres[i].innerhtml = pres[i].innerhtml.replace(/ /g, '<span> </span>') } 

css:

pre > span {     display: inline-block;     background: radial-gradient(circle, #cc0, rgba(192,192,0,0) 2px); } 

alternatively, can use custom font pre elements, in whitespace characters replaced visible.


Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

php - joomla get content in onBeforeCompileHead function -